@openchambery/web 1.19.12 → 1.19.13-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (168) hide show
  1. package/dist/assets/{AgentAvatar-CX0a1rKE.js → AgentAvatar-mbvX7YlW.js} +1 -1
  2. package/dist/assets/AssistantView-D5c557Oe.js +2 -0
  3. package/dist/assets/DiagramView-CjNUrHsU.js +1 -0
  4. package/dist/assets/FadeInOnReveal-moBbL8Ll.js +1 -0
  5. package/dist/assets/{Icon-BYM02QyU.js → Icon-CkzzhaLr.js} +1 -1
  6. package/dist/assets/MarkdownRenderer-BHfbAwVO.js +2 -0
  7. package/dist/assets/MarkdownRendererImpl-CkBoUibc.js +7 -0
  8. package/dist/assets/{MarkstreamRendererImpl-BFdJzxia.js → MarkstreamRendererImpl-BrXUOI9g.js} +1 -1
  9. package/dist/assets/MobileDetailNavigation-aY9-HwBN.js +1 -0
  10. package/dist/assets/MobileShareBridge-CRt_8DmM.js +4 -0
  11. package/dist/assets/MobileSurface-CIhtF-CU.js +2 -0
  12. package/dist/assets/{MultiRunWindow-C3p3lj3U.js → MultiRunWindow-DDq6C8t7.js} +1 -1
  13. package/dist/assets/OnboardingScreen-j0iCyH7f.js +1 -0
  14. package/dist/assets/{OverlayScrollbar-KUpvYHdv.js → OverlayScrollbar-CDC5B3RH.js} +1 -1
  15. package/dist/assets/SettingsView-DFWWMvAj.js +25 -0
  16. package/dist/assets/{SettingsWindow-8IDuPZA5.js → SettingsWindow-CnYfBplB.js} +1 -1
  17. package/dist/assets/TerminalView-D5CQFVVm.js +8 -0
  18. package/dist/assets/ToolOutputDialog-VMI7TQFT.js +10 -0
  19. package/dist/assets/{appThemeRegistry-B87OLIgc.js → appThemeRegistry-UIrP0-5h.js} +1 -1
  20. package/dist/assets/assistant-attachment-cache-C0aRnFkj.js +1 -0
  21. package/dist/assets/{button-C0cth9tl.js → button-xx1UOBA5.js} +1 -1
  22. package/dist/assets/{clipboard-DJ4nQEuY.js → clipboard-CUasgPiF.js} +1 -1
  23. package/dist/assets/{collapsible-DFT9cE80.js → collapsible-CACHBRYZ.js} +1 -1
  24. package/dist/assets/{context-menu-CAp74NfV.js → context-menu-CYbm4wBZ.js} +1 -1
  25. package/dist/assets/desktopHosts-DILvrAok.js +1 -0
  26. package/dist/assets/desktopRelayRestore-t8asCr3m.js +1 -0
  27. package/dist/assets/{diagram-BryzMuta.js → diagram-u0BC9uuY.js} +1 -1
  28. package/dist/assets/{dialog-CgbV5ljg.js → dialog-BwQ3rY_x.js} +1 -1
  29. package/dist/assets/dualLimitLru-D8Sphgua.js +1 -0
  30. package/dist/assets/{es-BHqnSjoZ.js → es-CRjOwvYM.js} +1 -1
  31. package/dist/assets/fileQueries-Bgly-E8f.js +1 -0
  32. package/dist/assets/{fr-BfrlJY9i.js → fr-D9taEN9L.js} +1 -1
  33. package/dist/assets/{gitApi-tTtHQVA3.js → gitApi-Bu4W3bgD.js} +1 -1
  34. package/dist/assets/imageSource-BlAJJUEI.js +1 -0
  35. package/dist/assets/{input-DFLpqjGR.js → input-CI730njs.js} +1 -1
  36. package/dist/assets/insertionBoundaries-B1AqxsBD.js +4 -0
  37. package/dist/assets/{ja-DP-7qt-x.js → ja-CYQ5aoWp.js} +1 -1
  38. package/dist/assets/{ko-E2B5vGQP.js → ko-BwASV0Q0.js} +1 -1
  39. package/dist/assets/main-CqcB6tKc.js +169 -0
  40. package/dist/assets/main-DG-k0j8A.js +2 -0
  41. package/dist/assets/markdown-worker-CptoICmq.js +2 -0
  42. package/dist/assets/markdownHeightCache-DEjGKLv8.js +3 -0
  43. package/dist/assets/markdownTheme-DOfGg-A7.js +1 -0
  44. package/dist/assets/miniChat-BQtYQrsh.js +2 -0
  45. package/dist/assets/mobile-8iyqtXkr.js +2 -0
  46. package/dist/assets/{multirun-B0V3hdnD.js → multirun-CG_FCb_Z.js} +1 -1
  47. package/dist/assets/persistence-YbQKzHUQ.js +3 -0
  48. package/dist/assets/{pl-r8X5gRM5.js → pl-DUI1vPil.js} +1 -1
  49. package/dist/assets/platform-DzsGqlGW.js +2 -0
  50. package/dist/assets/projectMeta-DMpMDWE1.js +3 -0
  51. package/dist/assets/{pt-BR-DcpdXCf5.js → pt-BR-CZQFJllP.js} +1 -1
  52. package/dist/assets/relay-image-stream-DM7atqJs.js +2 -0
  53. package/dist/assets/renderElectronMiniChatApp-DBzRdJl8.js +2 -0
  54. package/dist/assets/renderMobileApp-CIseqCyn.js +28 -0
  55. package/dist/assets/runtime-auth-D66yq6ie.js +1 -0
  56. package/dist/assets/runtime-fetch-zIalUnbb.js +1 -0
  57. package/dist/assets/runtime-switch-LvWDU-SL.js +1 -0
  58. package/dist/assets/runtimeConfig-D8nJYB-e.js +2 -0
  59. package/dist/assets/runtimeEndpointReset-CSub_ecV.js +147 -0
  60. package/dist/assets/{sessionChangeSummary-hVby3sJk.js → sessionChangeSummary-DQDZ5HW-.js} +1 -1
  61. package/dist/assets/{sessionLookup-B6P_aCun.js → sessionLookup-BiBD-4wC.js} +1 -1
  62. package/dist/assets/sortable-tabs-strip-Dom6Sthu.js +1 -0
  63. package/dist/assets/src-AA-5nXsF.css +2 -0
  64. package/dist/assets/{store-BDFdnk6l.js → store-CSnH_QXM.js} +2 -2
  65. package/dist/assets/terminalApi-noa4Cdbh.js +1 -0
  66. package/dist/assets/{textarea-Cgo_nWUU.js → textarea-BfNtUdJE.js} +1 -1
  67. package/dist/assets/{tooltip-BifLJ8o0.js → tooltip-DPxumadF.js} +1 -1
  68. package/dist/assets/{uk-Di0vl9V-.js → uk-C1FYZlmA.js} +1 -1
  69. package/dist/assets/{url-Pk6tQ1EZ.js → url-CVhsI9kR.js} +1 -1
  70. package/dist/assets/{useAppFontEffects-Dmes1chr.js → useAppFontEffects-qHt5uaFN.js} +32 -32
  71. package/dist/assets/useAssistantUIStore-CLPCNoj_.js +1 -0
  72. package/dist/assets/useDesktopWindowControlsLayout-BipyIXiK.js +1 -0
  73. package/dist/assets/{useEffectiveDirectory-CU2ChP0J.js → useEffectiveDirectory-DSNCCbCt.js} +1 -1
  74. package/dist/assets/useFontPreferences-CB-cGo3I.js +1 -0
  75. package/dist/assets/useMobileNavigationStore-C1NJGAik.js +413 -0
  76. package/dist/assets/useSessionAutoCleanup-Dcn6Unvd.js +2 -0
  77. package/dist/assets/useUIStore-CxOoCv7B.js +1 -0
  78. package/dist/assets/useWorkerHighlightedLines-CzpT4M7V.js +7 -0
  79. package/dist/assets/{utils-BiK3tBGM.js → utils-BHTVlVov.js} +1 -1
  80. package/dist/assets/{zh-CN-coFCfeQE.js → zh-CN-C96qP1ip.js} +1 -1
  81. package/dist/assets/{zh-TW-oDRZ1-yb.js → zh-TW-BsRk1Rbb.js} +1 -1
  82. package/dist/index.html +12 -9
  83. package/dist/mini-chat.html +12 -9
  84. package/dist/mobile.html +12 -9
  85. package/package.json +1 -1
  86. package/server/index.js +19 -0
  87. package/server/lib/assistant-delivery-parts.js +19 -1
  88. package/server/lib/assistants/DOCUMENTATION.md +56 -11
  89. package/server/lib/assistants/assign.js +455 -30
  90. package/server/lib/assistants/assign.test.js +351 -0
  91. package/server/lib/assistants/cards.js +16 -2
  92. package/server/lib/assistants/cards.test.js +16 -1
  93. package/server/lib/assistants/contact-active-turn.http.test.js +134 -0
  94. package/server/lib/assistants/contact-attachments.http.test.js +436 -0
  95. package/server/lib/assistants/contact-attachments.js +814 -0
  96. package/server/lib/assistants/contact-attachments.p1.test.js +307 -0
  97. package/server/lib/assistants/contact-attachments.test.js +249 -0
  98. package/server/lib/assistants/contact-store.js +552 -19
  99. package/server/lib/assistants/contact-store.test.js +415 -1
  100. package/server/lib/assistants/contact-tools.js +114 -14
  101. package/server/lib/assistants/contact-tools.test.js +135 -6
  102. package/server/lib/assistants/contracts.js +42 -2
  103. package/server/lib/assistants/harness.js +4 -1
  104. package/server/lib/assistants/harness.test.js +124 -0
  105. package/server/lib/assistants/routes.js +46 -1
  106. package/server/lib/assistants/service.js +569 -84
  107. package/server/lib/assistants/service.test.js +936 -37
  108. package/server/lib/fs/prompt-attachment-store.js +663 -0
  109. package/server/lib/fs/prompt-attachment-store.test.js +263 -0
  110. package/server/lib/fs/routes.js +28 -72
  111. package/server/lib/fs/routes.test.js +15 -30
  112. package/server/lib/llm/catalog.js +91 -16
  113. package/server/lib/llm/catalog.test.js +152 -11
  114. package/server/lib/notifications/APNS.md +20 -4
  115. package/server/lib/notifications/DOCUMENTATION.md +5 -0
  116. package/server/lib/notifications/apns-runtime.js +136 -18
  117. package/server/lib/notifications/apns-runtime.test.js +128 -0
  118. package/server/lib/notifications/apns-titles.js +21 -1
  119. package/server/lib/notifications/live-activity-refresh-runtime.js +185 -0
  120. package/server/lib/notifications/live-activity-refresh-runtime.test.js +242 -0
  121. package/server/lib/notifications/runtime.js +93 -2
  122. package/server/lib/notifications/runtime.test.js +167 -4
  123. package/server/lib/opencode/core-routes.js +2 -1
  124. package/server/lib/opencode/settings-helpers.js +12 -0
  125. package/server/lib/opencode/settings-runtime.js +16 -0
  126. package/server/lib/opencode/settings-runtime.test.js +21 -0
  127. package/server/lib/scheduled-tasks/runtime.js +21 -0
  128. package/server/lib/scheduled-tasks/runtime.test.js +24 -0
  129. package/dist/assets/AssistantView-DxIghtun.js +0 -2
  130. package/dist/assets/DiagramView-BeUgp_Y0.js +0 -1
  131. package/dist/assets/FadeInOnReveal-CTlNE4Hg.js +0 -1
  132. package/dist/assets/MarkdownRenderer-C4MGa_kQ.js +0 -2
  133. package/dist/assets/MarkdownRendererImpl-DB4Q3kGa.js +0 -7
  134. package/dist/assets/MobileDetailNavigation-B_RwWOwv.js +0 -1
  135. package/dist/assets/MobileShareBridge-UiOLx0-2.js +0 -4
  136. package/dist/assets/MobileSurface-CNChj_dX.js +0 -2
  137. package/dist/assets/OnboardingScreen-DS2nugLX.js +0 -1
  138. package/dist/assets/SettingsView-BXfKsz0J.js +0 -25
  139. package/dist/assets/TerminalView-BiKCueth.js +0 -8
  140. package/dist/assets/ToolOutputDialog-BC2F_Fdl.js +0 -10
  141. package/dist/assets/desktopHosts-Dc2PS66M.js +0 -1
  142. package/dist/assets/desktopRelayRestore-T9y0orqa.js +0 -1
  143. package/dist/assets/fileQueries-BY-9OWzp.js +0 -1
  144. package/dist/assets/insertionBoundaries-CCQpZ5zn.js +0 -4
  145. package/dist/assets/main-C_PUoT3E.js +0 -169
  146. package/dist/assets/main-Dkg31fRY.js +0 -2
  147. package/dist/assets/markdown-worker-CTsrtpPh.js +0 -2
  148. package/dist/assets/markdownHeightCache-CYDlisxr.js +0 -3
  149. package/dist/assets/markdownTheme-DyJ4Gfcj.js +0 -2
  150. package/dist/assets/miniChat-C9QMj8T8.js +0 -2
  151. package/dist/assets/mobile-Z_X7CbzB.js +0 -2
  152. package/dist/assets/persistence-DdUac14I.js +0 -3
  153. package/dist/assets/platform-B4KKLnZ5.js +0 -2
  154. package/dist/assets/projectMeta-DRW9MQ4z.js +0 -3
  155. package/dist/assets/renderElectronMiniChatApp-Dn1Su1dd.js +0 -2
  156. package/dist/assets/renderMobileApp-BG1JJt1Q.js +0 -28
  157. package/dist/assets/runtimeConfig-C6matIEB.js +0 -2
  158. package/dist/assets/runtimeEndpointReset-kgwmUJDb.js +0 -147
  159. package/dist/assets/sortable-tabs-strip-C8_9kHqu.js +0 -1
  160. package/dist/assets/src-B-P5qIBc.css +0 -2
  161. package/dist/assets/terminalApi-947l7Ra3.js +0 -1
  162. package/dist/assets/useAssistantUIStore-me6s63b2.js +0 -1
  163. package/dist/assets/useDesktopWindowControlsLayout-DuZ6URPR.js +0 -1
  164. package/dist/assets/useFontPreferences-BCOBlaAd.js +0 -1
  165. package/dist/assets/useMobileNavigationStore-C8_J-qTp.js +0 -413
  166. package/dist/assets/useSessionAutoCleanup-FOQeu1_T.js +0 -1
  167. package/dist/assets/useUIStore-CuaA8-Hp.js +0 -1
  168. package/dist/assets/useWorkerHighlightedLines-GBqKnki1.js +0 -7
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{$ as t,J as n,X as r,Y as i,Z as a,nt as o,rt as s}from"./vendor-base-ui-CnHfUmDN.js";import{n as c}from"./vendor-react-DLPElpoQ.js";import{n as l}from"./clipboard-DJ4nQEuY.js";import{t as u}from"./utils-BiK3tBGM.js";import{t as d}from"./SettingsView-BXfKsz0J.js";var f=c(),p=e(s(),1),m=o(),h=e=>{let o=(0,f.c)(19),{open:s,onOpenChange:c}=e,{t:h}=l(),_=p.useId(),v=g,y;o[0]===c?y=o[1]:(y=e=>{!e&&v()||c(e)},o[0]=c,o[1]=y);let b;o[2]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,m.jsx)(t,{className:u(`fixed inset-0 z-50 bg-black/50 dark:bg-black/75`,`transition-opacity duration-150 ease-out`,`data-[starting-style]:opacity-0 data-[ending-style]:opacity-0`)}),o[2]=b):b=o[2];let x;o[3]===Symbol.for(`react.memo_cache_sentinel`)?(x=u(`relative pointer-events-auto`,`w-[90vw] max-w-[1200px] h-[85vh] max-h-[900px]`,`rounded-xl border shadow-none overflow-hidden origin-center`,`bg-background`,`transition-all duration-150 ease-out`,`data-[starting-style]:opacity-0 data-[starting-style]:scale-[0.98]`,`data-[ending-style]:opacity-0 data-[ending-style]:scale-[0.98]`,`data-[nested-dialog-open]:brightness-[0.55] dark:data-[nested-dialog-open]:brightness-[0.4]`),o[3]=x):x=o[3];let S;o[4]===h?S=o[5]:(S=h(`settings.window.description`),o[4]=h,o[5]=S);let C;o[6]!==_||o[7]!==S?(C=(0,m.jsx)(a,{id:_,className:`sr-only`,children:S}),o[6]=_,o[7]=S,o[8]=C):C=o[8];let w;o[9]===c?w=o[10]:(w=(0,m.jsx)(d,{onClose:()=>c(!1),isWindowed:!0}),o[9]=c,o[10]=w);let T;o[11]!==_||o[12]!==C||o[13]!==w?(T=(0,m.jsxs)(i,{children:[b,(0,m.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center pointer-events-none`,children:(0,m.jsxs)(r,{"aria-describedby":_,className:x,children:[C,w]})})]}),o[11]=_,o[12]=C,o[13]=w,o[14]=T):T=o[14];let E;return o[15]!==s||o[16]!==y||o[17]!==T?(E=(0,m.jsx)(n,{open:s,onOpenChange:y,children:T}),o[15]=s,o[16]=y,o[17]=T,o[18]=E):E=o[18],E};function g(){return typeof document>`u`?!1:!!document.querySelector(`[data-slot="dropdown-menu-content"][data-open], [data-slot="select-content"][data-open]`)}export{h as SettingsWindow};
1
+ import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{$ as t,J as n,X as r,Y as i,Z as a,nt as o,rt as s}from"./vendor-base-ui-CnHfUmDN.js";import{n as c}from"./vendor-react-DLPElpoQ.js";import{n as l}from"./clipboard-CUasgPiF.js";import{t as u}from"./utils-BHTVlVov.js";import{t as d}from"./SettingsView-DFWWMvAj.js";var f=c(),p=e(s(),1),m=o(),h=e=>{let o=(0,f.c)(19),{open:s,onOpenChange:c}=e,{t:h}=l(),_=p.useId(),v=g,y;o[0]===c?y=o[1]:(y=e=>{!e&&v()||c(e)},o[0]=c,o[1]=y);let b;o[2]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,m.jsx)(t,{className:u(`fixed inset-0 z-50 bg-black/50 dark:bg-black/75`,`transition-opacity duration-150 ease-out`,`data-[starting-style]:opacity-0 data-[ending-style]:opacity-0`)}),o[2]=b):b=o[2];let x;o[3]===Symbol.for(`react.memo_cache_sentinel`)?(x=u(`relative pointer-events-auto`,`w-[90vw] max-w-[1200px] h-[85vh] max-h-[900px]`,`rounded-xl border shadow-none overflow-hidden origin-center`,`bg-background`,`transition-all duration-150 ease-out`,`data-[starting-style]:opacity-0 data-[starting-style]:scale-[0.98]`,`data-[ending-style]:opacity-0 data-[ending-style]:scale-[0.98]`,`data-[nested-dialog-open]:brightness-[0.55] dark:data-[nested-dialog-open]:brightness-[0.4]`),o[3]=x):x=o[3];let S;o[4]===h?S=o[5]:(S=h(`settings.window.description`),o[4]=h,o[5]=S);let C;o[6]!==_||o[7]!==S?(C=(0,m.jsx)(a,{id:_,className:`sr-only`,children:S}),o[6]=_,o[7]=S,o[8]=C):C=o[8];let w;o[9]===c?w=o[10]:(w=(0,m.jsx)(d,{onClose:()=>c(!1),isWindowed:!0}),o[9]=c,o[10]=w);let T;o[11]!==_||o[12]!==C||o[13]!==w?(T=(0,m.jsxs)(i,{children:[b,(0,m.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center pointer-events-none`,children:(0,m.jsxs)(r,{"aria-describedby":_,className:x,children:[C,w]})})]}),o[11]=_,o[12]=C,o[13]=w,o[14]=T):T=o[14];let E;return o[15]!==s||o[16]!==y||o[17]!==T?(E=(0,m.jsx)(n,{open:s,onOpenChange:y,children:T}),o[15]=s,o[16]=y,o[17]=T,o[18]=E):E=o[18],E};function g(){return typeof document>`u`?!1:!!document.querySelector(`[data-slot="dropdown-menu-content"][data-open], [data-slot="select-content"][data-open]`)}export{h as SettingsWindow};
@@ -0,0 +1,8 @@
1
+ import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{n as t}from"./runtime-fetch-zIalUnbb.js";import{Xt as n}from"./persistence-YbQKzHUQ.js";import{nt as r,rt as i,tt as a}from"./vendor-base-ui-CnHfUmDN.js";import{c as o,s,t as c}from"./useUIStore-CxOoCv7B.js";import{o as l}from"./terminalApi-noa4Cdbh.js";import{n as u,r as d,t as f}from"./vendor-ghostty-web-HohRXr3g.js";import{n as ee,t as p}from"./clipboard-CUasgPiF.js";import{c as m}from"./useMobileNavigationStore-C1NJGAik.js";import{t as h}from"./utils-BHTVlVov.js";import{n as g}from"./Icon-CkzzhaLr.js";import{t as _}from"./button-xx1UOBA5.js";import{n as v}from"./useThemeSystem-DMzWVJaW.js";import{i as y,t as b}from"./OverlayScrollbar-CDC5B3RH.js";import{n as te}from"./useRuntimeAPIs-DSLXJybW.js";import{n as x}from"./useEffectiveDirectory-DSNCCbCt.js";import{t as S}from"./sortable-tabs-strip-Dom6Sthu.js";import{n as C,t as w}from"./useFontPreferences-CB-cGo3I.js";import{r as T}from"./projectActions-CWvNGKfA.js";var E=e(i(),1);function ne(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 re(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 ie=e(a(),1),D=r(),O=null;function k(){return O||=d.load(),O}function ae(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 oe=E.forwardRef(({sessionKey:e,chunks:t,onInput:n,onResize:r,theme:i,fontFamily:a,fontSize:o,className:s,enableTouchScroll:c,autoFocus:l=!0,isVisible:d=!0},m)=>{let{t:g}=ee(),_=E.useRef(null),v=E.useRef(null),y=E.useRef(null),te=E.useRef(null),x=E.useRef(n),S=E.useRef(r),C=E.useRef(null),w=E.useRef(``),T=E.useRef(null),ne=E.useRef(!1),O=E.useRef(null),oe=E.useRef(!0),A=E.useRef(null),j=E.useRef(null),se=E.useRef(0),ce=E.useRef(null),M=E.useRef(null),N=E.useRef(!1),P=E.useRef(!1),le=E.useRef(null),ue=E.useRef(null),de=E.useRef(null),F=E.useRef(``),fe=E.useRef(null),pe=E.useRef(!c),me=E.useRef(d),[,he]=E.useReducer(e=>e+1,0),[ge,_e]=E.useReducer(e=>e+1,0);x.current=n,S.current=r;let ve=typeof navigator<`u`&&(/Android/i.test(navigator.userAgent)||navigator.userAgentData?.platform===`Android`),I=!!c;E.useEffect(()=>{if(!c){pe.current=!0,me.current=d;return}!me.current&&d&&(pe.current=!1),me.current=d},[c,d]);let ye=E.useCallback(()=>{if(!I)return;let e=_.current,t=ce.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`)})},[I]),L=E.useCallback(e=>{if(fe.current===e)return;let t=y.current;if(t)try{if(typeof t.setOption==`function`){t.setOption(`cursorBlink`,e),fe.current=e;return}t.options&&(t.options.cursorBlink=e,fe.current=e)}catch{}},[]),R=I&&ve,z=E.useCallback((e,t)=>{let n=R?M.current:ce.current,r=_.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{}}},[R]),B=E.useCallback(()=>{if(I){z(),L(!0);return}y.current?.focus(),L(!0)},[z,L,I]),V=E.useCallback(e=>e instanceof HTMLTextAreaElement||e instanceof HTMLInputElement?e.value:e.textContent??``,[]),H=E.useCallback(e=>{if(e instanceof HTMLTextAreaElement||e instanceof HTMLInputElement){e.value=``;return}e.textContent=``},[]),be=E.useCallback(e=>{if(typeof window>`u`||R)return;de.current!==null&&(window.clearTimeout(de.current),de.current=null);let t=0,n=()=>{de.current=window.setTimeout(()=>{de.current=null;let r=V(e);if(!r){if(t+=1,t<3){n();return}return}let i=F.current;F.current=r;let a=r.startsWith(i)?r.slice(i.length):r;a&&x.current(a.replace(/\r\n|\r|\n/g,`\r`)),H(e),F.current=``},t===0?0:24)};n()},[H,V,R]);E.useEffect(()=>{let e=_.current;if(!I||!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{}z()}};return e.addEventListener(`focusin`,t,!0),()=>{e.removeEventListener(`focusin`,t,!0)}},[c,I,z]);let U=E.useCallback(()=>{let e=y.current;if(!e||typeof e.getSelection!=`function`)return``;let t=e.getSelection();return typeof t==`string`?t:``},[]),xe=E.useCallback(()=>{if(typeof window>`u`)return``;let e=window.getSelection();if(!e)return``;let t=e.toString();if(!t.trim())return``;let n=_.current;if(!n)return``;let r=e.anchorNode,i=e.focusNode;return r&&!n.contains(r)||i&&!n.contains(i)?``:t},[]),Se=E.useCallback(async()=>{if(typeof document>`u`)return;let e=U()||xe();e.trim()&&await p(e)},[xe,U]),Ce=E.useCallback(()=>U().trim()?!0:!!xe().trim(),[xe,U]);E.useEffect(()=>{if(typeof window>`u`)return;let e=e=>{Ce()&&(e.preventDefault(),Se())};return window.addEventListener(`openchamber:copy`,e),()=>{window.removeEventListener(`openchamber:copy`,e)}},[Se,Ce]);let W=E.useCallback(()=>{w.current=``,T.current!==null&&typeof window<`u`&&window.cancelAnimationFrame(T.current),T.current=null,ne.current=!1,O.current=null},[]),G=E.useCallback(()=>{let e=te.current,t=y.current,n=_.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=C.current;(!r||r.cols!==n.cols||r.rows!==n.rows)&&(C.current=n,S.current(n.cols,n.rows))}catch{}},[]),K=E.useCallback(()=>{if(ne.current)return;let e=y.current;if(!e){W();return}if(!w.current)return;let t=w.current;w.current=``,ne.current=!0,e.write(t,()=>{ne.current=!1,w.current&&(typeof window<`u`?T.current=window.requestAnimationFrame(()=>{T.current=null,K()}):K())})},[W]),we=E.useCallback(()=>{T.current===null&&(typeof window<`u`?T.current=window.requestAnimationFrame(()=>{T.current=null,K()}):K())},[K]),q=E.useCallback(e=>{e&&(w.current+=e,we())},[we]),Te=E.useCallback(()=>{if(A.current?.(),A.current=null,j.current!==null&&typeof window<`u`&&(window.clearTimeout(j.current),j.current=null),!c){se.current=0;return}let e=_.current;if(!e)return;let t=y.current;if(!t)return;se.current=0;let n=2.2,r=2.8,i=.25,a=.05,s=.015,l={lastY:null,lastTime:null,velocity:0,rafId:null,startX:null,startY:null,didMove:!1},u=()=>typeof performance<`u`?performance.now():Date.now(),d=Math.max(12,Math.round(o*1.35)),f=0,ee=e=>{if(!e)return!1;let n=t.getViewportY(),r=f+e,i=Math.trunc(r/d);return f=r-i*d,i!==0&&t.scrollLines(i),t.getViewportY()!==n},p=()=>{l.rafId!==null&&typeof window<`u`&&window.cancelAnimationFrame(l.rafId),l.rafId=null},m={passive:!1,capture:!1};if(typeof window<`u`&&`PointerEvent`in window){let t=Object.assign(l,{pointerId:null,startX:null,startY:null,moved:!1}),o=n=>{if(n.pointerType===`touch`){p(),t.pointerId=n.pointerId,t.startX=n.clientX,t.startY=n.clientY,t.moved=!1,t.lastY=n.clientY,t.lastTime=u(),t.velocity=0;try{e.setPointerCapture(n.pointerId)}catch{}}},d=e=>{if(e.pointerType!==`touch`||t.pointerId!==e.pointerId)return;if(t.startX!==null&&t.startY!==null&&!t.moved){let n=e.clientX-t.startX,r=e.clientY-t.startY;Math.hypot(n,r)>=6&&(t.moved=!0)}if(t.lastY===null){t.lastY=e.clientY,t.lastTime=u();return}let a=t.lastY,o=t.lastTime??u(),s=u();t.lastY=e.clientY,t.lastTime=s;let c=a-e.clientY;if(Math.abs(c)<1)return;let l=Math.max(s-o,8),d=c*(n+Math.min(r,Math.abs(c)/25)),f=d/l;t.velocity=t.velocity*.75+f*i,t.velocity>8?t.velocity=8:t.velocity<-8&&(t.velocity=-8),t.moved&&(e.cancelable&&e.preventDefault(),e.stopPropagation()),ee(d)},f=n=>{if(n.pointerType!==`touch`||t.pointerId!==n.pointerId)return;let r=!t.moved;t.pointerId=null,t.startX=null,t.startY=null,t.moved=!1,t.lastY=null,t.lastTime=null;try{e.releasePointerCapture(n.pointerId)}catch{}if(r){I?z(n.clientX,n.clientY):c&&!pe.current&&(pe.current=!0,y.current?.focus());return}if(typeof window>`u`)return;if(Math.abs(t.velocity)<a){t.velocity=0;return}let i=u(),o=()=>{let e=u(),n=Math.max(e-i,8);i=e;let r=ee(t.velocity*n)??!1,c=Math.sign(t.velocity),l=Math.max(0,Math.abs(t.velocity)-s*n);if(t.velocity=l*c,!r||l<=a){p(),t.velocity=0;return}t.rafId=window.requestAnimationFrame(o)};t.rafId=window.requestAnimationFrame(o)};e.addEventListener(`pointerdown`,o,m),e.addEventListener(`pointermove`,d,m),e.addEventListener(`pointerup`,f,m),e.addEventListener(`pointercancel`,f,m);let h=e.style.touchAction,g=e.style.overscrollBehaviorY;e.style.touchAction=`none`,e.style.overscrollBehaviorY=`contain`,A.current=()=>{p(),j.current!==null&&typeof window<`u`&&(window.clearTimeout(j.current),j.current=null),se.current=0,e.removeEventListener(`pointerdown`,o,m),e.removeEventListener(`pointermove`,d,m),e.removeEventListener(`pointerup`,f,m),e.removeEventListener(`pointercancel`,f,m),e.style.touchAction=h,e.style.overscrollBehaviorY=g};return}let h=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)},g=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];I?z(t?.clientX,t?.clientY):c&&!pe.current&&(pe.current=!0,y.current?.focus());return}if(typeof window>`u`)return;if(Math.abs(n)<a){l.velocity=0;return}let r=u(),i=()=>{let e=u(),t=Math.max(e-r,8);r=e;let n=ee(l.velocity*t)??!1,o=Math.sign(l.velocity),c=Math.max(0,Math.abs(l.velocity)-s*t);if(l.velocity=c*o,!n||c<=a){p(),l.velocity=0;return}l.rafId=window.requestAnimationFrame(i)};l.rafId=window.requestAnimationFrame(i)};e.addEventListener(`touchstart`,h,m),e.addEventListener(`touchmove`,g,m),e.addEventListener(`touchend`,v,m),e.addEventListener(`touchcancel`,v,m);let b=e.style.touchAction,te=e.style.overscrollBehaviorY;e.style.touchAction=`none`,e.style.overscrollBehaviorY=`contain`,A.current=()=>{p(),j.current!==null&&typeof window<`u`&&(window.clearTimeout(j.current),j.current=null),se.current=0,e.removeEventListener(`touchstart`,h,m),e.removeEventListener(`touchmove`,g,m),e.removeEventListener(`touchend`,v,m),e.removeEventListener(`touchcancel`,v,m),e.style.touchAction=b,e.style.overscrollBehaviorY=te}},[c,I,z,o]);E.useEffect(()=>{let e=!1,t=null,n=null,r=null,s=[],l=null,d=null,ee=null,p=_.current;if(!p)return;if(p.tabIndex=I?-1:0,I){let e=p.focus.bind(p),t=p;t.focus=((...e)=>{z()}),ee=()=>{t.focus=e}}let m=()=>{L(!0)},h=()=>{L(!1)},g=e=>{let t=e.target;if(t&&p.contains(t)){if(I&&t instanceof HTMLElement){window.setTimeout(()=>{t.blur(),z()},0),L(!1);return}if(c&&!pe.current&&t instanceof HTMLElement){window.setTimeout(()=>{t.blur()},0),L(!1);return}L(!0);return}L(!1)},b=()=>{L(!1)},S=null;return(async()=>{try{let ee=await k();if(e)return;let g=re(a,o,i,ee,!1),_=new u(g);oe.current=!0,I&&(_.focus=()=>{});let b=_;if(typeof b.scrollToBottom==`function`){let e=b.scrollToBottom.bind(b);b.scrollToBottom=()=>{oe.current&&e()},l=()=>{b.scrollToBottom=e}}let C=new f;if(t=_,y.current=_,te.current=C,_.loadAddon(C),_.open(p),c){let e=_.renderer;if(e&&typeof e.renderScrollbar==`function`){let t=e.renderScrollbar.bind(e);e.renderScrollbar=()=>{},d=()=>{e.renderScrollbar=t}}}_e(),fe.current=!1,S=_.textarea??p.querySelector(`textarea`),S&&(S.addEventListener(`focus`,m),S.addEventListener(`blur`,h)),ye(),typeof MutationObserver<`u`&&(r=new MutationObserver(()=>{ye()}),r.observe(p,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`contenteditable`,`role`,`tabindex`,`aria-label`]}));let w=ae(p);w?(w.classList.add(`overlay-scrollbar-target`,`overlay-scrollbar-container`),v.current=w,he()):v.current=null,G();let T=C;typeof T.observeResize==`function`&&T.observeResize(),Te(),s=[_.onData(e=>{x.current(e)}),_.onScroll(e=>{if(typeof e==`number`&&Number.isFinite(e)){let t=typeof _.hasSelection==`function`&&_.hasSelection();oe.current=!t&&e<=.5}}),_.onSelectionChange(()=>{if(typeof _.hasSelection==`function`&&_.hasSelection()){oe.current=!1;return}let e=typeof _.getViewportY==`function`?_.getViewportY():0;oe.current=e<=.5})],n=new ResizeObserver(()=>{G()}),n.observe(p),typeof window<`u`&&window.setTimeout(()=>{G()},0)}catch{}})(),document.addEventListener(`focusin`,g,!0),window.addEventListener(`blur`,b),()=>{e=!0,A.current?.(),A.current=null,document.removeEventListener(`focusin`,g,!0),window.removeEventListener(`blur`,b),s.forEach(e=>e.dispose()),l?.(),l=null,d?.(),d=null,S&&(S.removeEventListener(`focus`,m),S.removeEventListener(`blur`,h)),n?.disconnect(),r?.disconnect(),ee?.(),t?.dispose(),y.current=null,te.current=null,v.current=null,C.current=null,fe.current=null,W()}},[ye,c,G,z,a,o,Te,i,W,L,I]),E.useEffect(()=>{let e=y.current;e&&(e.reset(),W(),C.current=null,G())},[e,ge,G,W]),E.useEffect(()=>{l&&y.current&&B()},[l,B,e,ge]),E.useEffect(()=>(Te(),()=>{A.current?.(),A.current=null}),[Te,e]),E.useEffect(()=>{let e=y.current;if(!e)return;if(t.length===0){O.current!==null&&(e.reset(),W(),G());return}let n=O.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&&q(r.map(e=>e.data).join(``)),O.current=t[t.length-1].id},[t,ge,q,G,W]),E.useImperativeHandle(m,()=>({focus:()=>{B()},clear:()=>{let e=y.current;e&&(e.reset(),W(),G())},fit:()=>{G()}}),[B,G,W]);let J=E.useCallback(e=>{if(!I)return;let t=_.current,n=e.relatedTarget,r=n?.tagName;r===`INPUT`||r===`TEXTAREA`||n?.isContentEditable,n?.getAttribute(`data-terminal-hidden-input`),n&&t?.contains(n)},[I]),Y=E.useCallback(e=>{let t=e.nativeEvent,n=t?.inputType??``,r=typeof t?.data==`string`?t.data:``;if(ue.current=typeof performance<`u`?performance.now():Date.now(),n===`insertCompositionText`){N.current=!0;return}if(!n&&r){if(N.current)return;e.preventDefault(),x.current(r),le.current={type:`insertText`,at:typeof performance<`u`?performance.now():Date.now()},P.current=!0;return}if(n===`insertText`&&r){if(N.current)return;e.preventDefault(),x.current(r),le.current={type:n,at:typeof performance<`u`?performance.now():Date.now()},P.current=!0;return}if(n===`insertLineBreak`){if(N.current)return;e.preventDefault(),x.current(`\r`),le.current={type:n,at:typeof performance<`u`?performance.now():Date.now()},P.current=!0;return}if(n===`deleteContentBackward`){if(N.current)return;e.preventDefault(),x.current(``),le.current={type:n,at:typeof performance<`u`?performance.now():Date.now()},P.current=!0}},[]),X=E.useCallback(e=>{let t=e.currentTarget;if(ue.current=typeof performance<`u`?performance.now():Date.now(),N.current)return;if(P.current){let e=le.current,n=typeof performance<`u`?performance.now():Date.now();if(e&&n-e.at<50){P.current=!1,H(t);return}P.current=!1}let n=V(t);if(!n)return;F.current=n;let r=n.replace(/\r\n|\r|\n/g,`\r`);x.current(r),H(t),F.current=``},[H,V]),Ee=E.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)&&Ce()){e.preventDefault(),Se();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)),H(e.currentTarget);return}}if(e.altKey&&!e.ctrlKey&&!e.metaKey&&e.key.length===1){e.preventDefault(),e.nativeEvent?.stopImmediatePropagation(),x.current(`\x1B`+e.key),H(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),H(e.currentTarget);return}let a=e.currentTarget;if(e.nativeEvent?.isComposing)return;let o=le.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`),H(a);return}if(e.key===`Backspace`){if(e.preventDefault(),c&&o?.type===`deleteContentBackward`)return;V(a)||x.current(``)}if(e.key.length===1&&!e.ctrlKey&&!e.metaKey&&!e.altKey){let t=ue.current;t&&s-t<50||(e.preventDefault(),x.current(e.key),P.current=!0,le.current={type:`keydown-text`,at:s})}be(a)},[H,Se,Ce,V,be]),De=E.useCallback(e=>{e.stopPropagation();let t=e.currentTarget;e.nativeEvent?.isComposing||be(t)},[be]),Oe=E.useCallback(e=>{let t=e.currentTarget;N.current=!1;let n=e.data||V(t);if(ue.current=typeof performance<`u`?performance.now():Date.now(),!n)return;let r=n.replace(/\r\n|\r|\n/g,`\r`);x.current(r),H(t),le.current={type:`compositionend`,at:typeof performance<`u`?performance.now():Date.now()},P.current=!0},[H,V]),ke=E.useCallback(e=>{e.stopPropagation();let t=e.clipboardData?.getData(`text`)??``;if(!t)return;e.preventDefault();let n=y.current?.hasBracketedPaste?.()?`\x1b[200~${t}\x1b[201~`:t;x.current(n)},[]),Ae={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,D.jsxs)(`div`,{ref:_,className:h(`relative h-full w-full terminal-viewport-container`,s),"data-hidden-input-overlay-active":I?`true`:void 0,style:{backgroundColor:i.background},onTouchStart:e=>{if(!(!I||c)&&!Ce()){let t=e.touches?.[0];z(t?.clientX,t?.clientY)}},onClick:e=>{if(!c)if(I){if(Ce())return;z(e.clientX,e.clientY)}else y.current?.focus()},onMouseUp:()=>{!c&&Ce()&&Se()},onTouchEnd:()=>{!c&&Ce()&&Se()},children:[I&&typeof document<`u`?(0,ie.createPortal)((0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`input`,{ref:M,type:`text`,inputMode:`text`,autoCapitalize:`off`,autoComplete:`off`,autoCorrect:`off`,spellCheck:!1,tabIndex:-1,enterKeyHint:`send`,"data-terminal-hidden-input":`true`,"aria-label":g(`terminalView.viewport.inputAria`),"aria-hidden":`true`,style:{...Ae,display:R?`block`:`none`},onBlur:J,onBeforeInput:Y,onCompositionStart:()=>{N.current=!0},onInput:X,onKeyDown:Ee,onKeyUp:De,onCompositionEnd:Oe,onPaste:ke}),(0,D.jsx)(`textarea`,{ref:ce,inputMode:`text`,autoCapitalize:`off`,autoComplete:`off`,autoCorrect:`off`,spellCheck:!1,tabIndex:-1,enterKeyHint:`send`,"data-terminal-hidden-input":`true`,"aria-label":g(`terminalView.viewport.inputAria`),"aria-hidden":`true`,style:{...Ae,display:R?`none`:`block`},onBlur:J,onBeforeInput:Y,onCompositionStart:()=>{N.current=!0},onInput:X,onKeyDown:Ee,onKeyUp:De,onCompositionEnd:Oe,onPaste:ke})]}),document.body):null,v.current&&!c?(0,D.jsx)(b,{containerRef:v,disableHorizontal:!0,className:`overlay-scrollbar--flush overlay-scrollbar--dense overlay-scrollbar--zero`}):null]})});oe.displayName=`TerminalViewport`;var A=RegExp(`\x1B\\[[0-9;?]*[ -/]*[@-~]`,`g`),j=/(https?:\/\/(?:localhost|127\.0\.0\.1|0\.0\.0\.0|\[(?:::1|::)\])(?::\d{2,5})?(?:\/[^\s<>'"`]*)?)/gi,se=/(?:➜\s*(?:Local|Network):)|\b(?:local|network|loopback|serving|listening|available|ready|started|running|server|vite|webpack|next\.js|astro|sveltekit|nuxt)\b/i,ce=/Serving HTTP on .*? port (\d{2,5})/i,M=new Set([`.`,`,`,`;`,`:`,`!`,`?`]),N=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(M.has(e)){t=t.slice(0,-1);continue}break}return t},P=e=>{let t=N(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},le=e=>{if(!e)return null;let t=e.replace(A,``),n=t.match(ce);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
+ `);for(let e of r){if(!se.test(e))continue;let t=Array.from(e.matchAll(j));if(t.length!==0)return P((t.find(e=>{try{return!!new URL(P(e[1])).port}catch{return!1}})??t[0])[1])}return null},ue=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)}},de={esc:`\x1B`,tab:` `,enter:`\r`,"arrow-up":`\x1B[A`,"arrow-down":`\x1B[B`,"arrow-left":`\x1B[D`,"arrow-right":`\x1B[C`},F={ctrl:`5`,cmd:`3`},fe={retry:{maxRetries:3,initialDelayMs:500,maxDelayMs:8e3},connectionTimeoutMs:1e4},pe={retry:{maxRetries:8,initialDelayMs:400,maxDelayMs:8e3},connectionTimeoutMs:15e3},me=(e,t)=>{if(t)switch(e){case`arrow-up`:return`\u001b[1;${F[t]}A`;case`arrow-down`:return`\u001b[1;${F[t]}B`;case`arrow-right`:return`\u001b[1;${F[t]}C`;case`arrow-left`:return`\u001b[1;${F[t]}D`}return de[e]??null},he=()=>{let{t:e}=ee(),{terminal:t,runtime:r}=te(),{currentTheme:i}=v(),{monoFont:a}=w(),u=c(e=>e.terminalFontSize),d=c(e=>e.bottomTerminalHeight),f=c(e=>e.isBottomTerminalExpanded),{isMobile:p,isTablet:b,hasTouchOnlyPointer:re}=y(),ie=p||b,O=(ie||re)&&r.platform===`web`,k=r.platform!==`vscode`,ae=c(e=>e.showTerminalQuickKeysOnDesktop),A=!n()&&(ie||ae),j=m(e=>e.currentSessionId),se=m(e=>e.newSessionDraft),ce=j!==null||se?.open===!0,M=x()??null,N=C(e=>e.sessions),P=C(e=>e.hasHydrated),de=C(e=>e.ensureDirectory),F=C(e=>e.createTab),he=C(e=>e.setActiveTab),ge=C(e=>e.closeTab),_e=C(e=>e.setTabSessionId),ve=C(e=>e.setTabLifecycle),I=C(e=>e.setConnecting),ye=C(e=>e.appendToBuffer),L=C(e=>e.setTabPreviewUrl),R=C(e=>e.clearBuffer),z=c(e=>e.openContextPreview),B=E.useMemo(()=>{if(M)return N.get(M)},[N,M]),V=E.useMemo(()=>B?k?B.activeTabId??B.tabs[0]?.id??null:B.tabs[0]?.id??null:null,[B,k]),H=E.useMemo(()=>{if(B)return V?B.tabs.find(e=>e.id===V)??B.tabs[0]:B.tabs[0]},[B,V]),be=E.useMemo(()=>(B?.tabs??[]).map(t=>({icon:(()=>{let e=t.iconKey?T[t.iconKey]??`terminal`:`terminal`;return(0,D.jsx)(g,{name:e,className:`h-4 w-4`})})(),id:t.id,label:t.label,title:t.label,closeLabel:e(`terminalView.tabs.closeTabTitle`)})),[B?.tabs,e]),U=H?.terminalSessionId??null,xe=H?.lifecycle??`idle`,Se=H?.bufferChunks??[],Ce=H?.isConnecting??!1,W=H?.previewUrl??null,[G,K]=E.useState(null),[we,q]=E.useState(!1),[Te,J]=E.useState(!1),[Y,X]=E.useState(null),[Ee,De]=E.useState(!1),[Oe,ke]=E.useState(0),Ae=E.useRef(null),je=E.useRef(null),Me=E.useRef(V),Ne=E.useRef(U),Pe=E.useRef(M),Fe=E.useRef(null),Ie=E.useRef(null),Le=E.useRef(!1),Re=E.useRef(!1),ze=E.useRef(null),Be=E.useRef(null),Ve=E.useRef(new Set),He=E.useRef(!1),Ue=E.useRef(``),We=E.useRef(new Set),Ge=E.useRef(0),Ke=E.useCallback(()=>{Ue.current=``,We.current.clear(),Ge.current+=1},[]),qe=E.useCallback(()=>{O||typeof document<`u`&&!document.hasFocus()||Fe.current?.focus()},[O]),Je=E.useCallback(()=>{O||Fe.current?.focus()},[O]);E.useEffect(()=>{if(!P||He.current)return;He.current=!0;let e=new Set;for(let[,t]of C.getState().sessions.entries())for(let n of t.tabs)n.terminalSessionId&&e.add(n.terminalSessionId);Ve.current=e},[P]);let Ye=c(e=>e.activeMainTab),Xe=c(e=>e.isBottomTerminalOpen),Ze=c(e=>e.setBottomTerminalOpen),Qe=c(e=>e.setBottomTerminalExpanded),$e=Ye===`terminal`,Z=$e||Xe,[et,tt]=E.useState(Z);E.useEffect(()=>{!Z||r.platform===`vscode`||l()},[Z,r.platform]),E.useEffect(()=>{Z&&tt(!0)},[Z]),E.useEffect(()=>{Re.current=Z},[Z]),E.useEffect(()=>{Ne.current=U},[U]),E.useEffect(()=>{Me.current=V,Ke()},[V,Ke]),E.useEffect(()=>{Pe.current=M},[M]),E.useEffect(()=>{!A&&Y!==null&&X(null)},[A,Y,X]),E.useEffect(()=>{!U&&Y!==null&&X(null)},[U,Y,X]);let Q=E.useCallback(()=>{Ae.current?.(),Ae.current=null,je.current=null,ze.current=null,J(!1)},[]);E.useEffect(()=>()=>{Q(),Ne.current=null},[Q]);let nt=E.useCallback((e,t,n)=>{if(!n)return;let r=`${Ue.current}${n}`.replace(/\r\n|\r/g,`
3
+ `),i=r.split(`
4
+ `),a=r.endsWith(`
5
+ `)?i.join(`
6
+ `):i.slice(0,-1).join(`
7
+ `);if(Ue.current=r.endsWith(`
8
+ `)?``:(i[i.length-1]??``).slice(-1024),!a)return;let o=le(a);if(!o||We.current.has(o))return;let s=Ge.current;We.current.add(o),ue(o).then(n=>{if(We.current.delete(o),!n||Ge.current!==s)return;let r=C.getState().getDirectoryState(e)?.tabs.find(e=>e.id===t);!r||r.previewUrlLocked||r.previewUrl===o||L(e,t,o,{locked:!1,autoOpened:!1})})},[L]),rt=E.useCallback((n,r,i,a=fe,o=!1)=>{if(je.current===i)return;Q(),je.current=i;let s=t.connect(i,{onEvent:a=>{if(je.current===i)switch(a.type){case`connected`:ze.current=i,I(n,r,!1),K(null),q(!1),J(!1),qe(),Be.current===i&&(Be.current=null,t.sendInput(i,`\r`).catch(()=>{}));break;case`reconnecting`:K(null),q(!1),J(!0);break;case`data`:a.data&&(ye(n,r,a.data),nt(n,r,a.data));break;case`exit`:{let t=typeof a.exitCode==`number`?a.exitCode:null,i=typeof a.signal==`number`?a.signal:null,o=!!(C.getState().getDirectoryState(n)?.tabs.find(e=>e.id===r))?.label?.startsWith(`Action:`);ye(n,r,e(`terminalView.stream.processExitedMessage`,{exitCodeSegment:t===null?``:e(`terminalView.stream.processExitedWithCode`,{exitCode:t}),signalSegment:i===null?``:e(`terminalView.stream.processExitedWithSignal`,{signal:i})})),ve(n,r,`exited`),_e(n,r,null),I(n,r,!1),K(o?null:e(`terminalView.error.sessionEnded`)),q(!1),J(!1),Q();break}}},onError:(t,a)=>{if(je.current===i){if(!a){K(null),q(!1);return}if(/session not found/i.test(t.message)||o){J(!1),K(null),q(!1),I(n,r,!0),R(n,r),ve(n,r,`idle`),_e(n,r,null),Q();return}J(!1),K(e(`terminalView.error.connectionFailed`,{message:t.message})),q(!0),I(n,r,!1),R(n,r),ve(n,r,`exited`),_e(n,r,null),Q()}}},a);Ae.current=()=>{s.close(),je.current=null}},[ye,R,Q,qe,nt,I,ve,_e,e,t]);E.useEffect(()=>{let n=!1;if(!(!P||!et)){if(!M){K(e(ce?`terminalView.empty.noWorkingDirectory`:`terminalView.empty.selectSession`));return}return(async()=>{let r=M;if(!Pe.current||Pe.current!==r)return;de(r);let i=C.getState().getDirectoryState(r);if(!i||i.tabs.length===0)return;let a=k?i.activeTabId??i.tabs[0]?.id??null:i.tabs[0]?.id??null;if(!a)return;let o=i.tabs.find(e=>e.id===a)??i.tabs[0],s=o?.terminalSessionId??null,c=o?.lifecycle??`idle`,l=!!o?.label?.startsWith(`Action:`),u=(o?.bufferLength??0)>0||(o?.bufferChunks?.length??0)>0;if(s)return;if(c===`exited`){I(r,a,!1);return}if(l&&u){I(r,a,!1);return}let d=Ie.current;if(!(!d&&Re.current)){K(null),q(!1),J(!1),I(r,a,!0);try{let e=await t.createSession({cwd:r,cols:d?.cols,rows:d?.rows});if(!(!n&&Pe.current===r&&Me.current===a)){try{await t.close(e.sessionId)}catch{}return}if(C.getState().getDirectoryState(r)?.tabs.find(e=>e.id===a)?.terminalSessionId){try{await t.close(e.sessionId)}catch{}return}_e(r,a,e.sessionId)}catch(t){n||(K(t instanceof Error?t.message:e(`terminalView.error.startSessionFailed`)),q(!0),J(!1),I(r,a,!1))}}})(),()=>{n=!0}}},[ce,M,U,xe,V,et,Oe,k,P,de,I,_e,e,t]);let it=E.useRef(rt);it.current=rt;let at=E.useRef(Q);at.current=Q,E.useEffect(()=>{if(!P||!et)return;if(!M){at.current();return}let e=M,t=C.getState().getDirectoryState(e);if(!t||t.tabs.length===0){at.current();return}let n=k?t.activeTabId??t.tabs[0]?.id??null:t.tabs[0]?.id??null;if(!n){at.current();return}let r=t.tabs.find(e=>e.id===n)??t.tabs[0],i=r?.terminalSessionId??null;if(!i){at.current(),Ne.current=null;return}if(je.current===i&&Ae.current){Ne.current=i;return}Ne.current=i;let a=Ve.current.has(i),o=a&&(r?.bufferLength??0)===0&&(r?.bufferChunks?.length??0)===0;a&&Ve.current.delete(i),o&&(Be.current=i),it.current(e,n,i,a?pe:fe,a)},[M,U,V,k,et,P]),E.useEffect(()=>{if(!Z||O)return;if(typeof window>`u`){qe();return}let e=window.requestAnimationFrame(()=>{qe()});return()=>{window.cancelAnimationFrame(e)}},[V,qe,Z,O]);let ot=E.useCallback(async()=>{if(!M||Ee)return;let t=C.getState().getDirectoryState(M),n=k?V??t?.activeTabId??t?.tabs[0]?.id??null:t?.tabs[0]?.id??null;if(n){De(!0),K(null),q(!1),J(!1),Q(),R(M,n),Ke();try{await ge(M,n)}catch(t){K(t instanceof Error?t.message:e(`terminalView.error.restartFailed`)),q(!0),J(!1)}finally{De(!1)}}},[V,R,ge,Q,M,k,Ee,Ke,e]),st=E.useCallback(async()=>{await ot()},[ot]),ct=E.useCallback(()=>{if(!M)return;let e=F(M);he(M,e),K(null),q(!1),J(!1),Q()},[F,Q,M,he]),lt=E.useCallback(e=>{M&&(he(M,e),K(null),q(!1),J(!1),Q())},[Q,M,he]),ut=E.useCallback(e=>{M&&(e===V&&Q(),K(null),q(!1),J(!1),ge(M,e))},[V,ge,Q,M]),dt=E.useCallback(n=>{if(!n||Te)return;let r=n,i=!1;if(Y&&n.length>0){let e=n[0];if(e.length===1&&/[a-zA-Z]/.test(e)){let t=e.toUpperCase();(Y===`ctrl`||Y===`cmd`)&&(r=String.fromCharCode(t.charCodeAt(0)&31),i=!0)}i||=!0}let a=Ne.current;!a||ze.current!==a||(t.sendInput(a,r).catch(t=>{Te||K(t instanceof Error?t.message:e(`terminalView.error.sendInputFailed`))}),i&&(X(null),Je()))},[Y,Je,Te,X,e,t]),ft=E.useCallback((e,n)=>{let r=Ie.current;if((!r||r.cols!==e||r.rows!==n)&&(Ie.current={cols:e,rows:n}),Le.current||(Le.current=!0,ke(e=>e+1)),!Re.current)return;let i=Ne.current;!i||ze.current!==i||t.resize({sessionId:i,cols:e,rows:n}).catch(()=>{})},[t]),pt=E.useCallback(e=>{X(t=>t===e?null:e),Je()},[Je,X]),mt=E.useCallback(e=>{let t=me(e,Y);t&&(dt(t),X(null),Je())},[Y,Je,dt,X]);E.useEffect(()=>{if(!A||!Y||!U)return;let e=e=>{if(e.repeat)return;let t=e.key;if(!t||t===`Control`||t===`Meta`||t===`Alt`||t===`Shift`)return;let n=t.length===1?t.toLowerCase():t,r=e.code??``,i=r.startsWith(`Key`)&&r.length===4?r.slice(3).toUpperCase():null,a=t.length===1&&/[a-zA-Z]/.test(t)?t.toUpperCase():i,o={Tab:`tab`,Enter:`enter`,ArrowUp:`arrow-up`,ArrowDown:`arrow-down`,ArrowLeft:`arrow-left`,ArrowRight:`arrow-right`,Escape:`esc`,tab:`tab`,enter:`enter`,arrowup:`arrow-up`,arrowdown:`arrow-down`,arrowleft:`arrow-left`,arrowright:`arrow-right`,escape:`esc`};if(n in o){e.preventDefault(),e.stopPropagation(),mt(o[n]);return}if(Y===`ctrl`&&a&&a.length===1&&a>=`A`&&a<=`Z`){let t=String.fromCharCode(a.charCodeAt(0)&31);e.preventDefault(),e.stopPropagation(),dt(t),X(null),Je()}};return window.addEventListener(`keydown`,e),()=>{window.removeEventListener(`keydown`,e)}},[Y,mt,dt,Je,A,X,U]);let ht=E.useMemo(()=>{let e=s[o].stack;if(typeof window>`u`)return(s[a]??s[`system-mono`]).stack;let t=window.getComputedStyle(document.documentElement).getPropertyValue(`--font-family-mono`);return t&&t.trim().length>0?t.trim():(s[a]??s[`system-mono`]).stack??e},[a]),gt=E.useMemo(()=>ne(i),[i]),_t=E.useMemo(()=>`${M??`no-dir`}::${V??`no-tab`}`,[M,V]);if(E.useEffect(()=>{if(!Z||O)return;let e=Fe.current;if(!e)return;let t=()=>{e.fit()};if(typeof window<`u`){let e=window.requestAnimationFrame(()=>{t(),qe()}),n=[220,400].map(e=>window.setTimeout(t,e));return()=>{window.cancelAnimationFrame(e),n.forEach(e=>window.clearTimeout(e))}}t()},[qe,Z,O,_t,U]),E.useEffect(()=>{if(O||!Z||!Xe)return;let e=Fe.current;if(!e)return;let t=()=>{e.fit()};if(typeof window<`u`){let e=window.requestAnimationFrame(()=>{t()}),n=[0,80,180,320].map(e=>window.setTimeout(t,e));return()=>{window.cancelAnimationFrame(e),n.forEach(e=>window.clearTimeout(e))}}t()},[d,f,Xe,Z,O]),!ce)return(0,D.jsx)(`div`,{className:`flex h-full items-center justify-center p-4 text-center text-sm text-muted-foreground`,children:e(`terminalView.empty.selectSession`)});if(!M)return(0,D.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-2 p-4 text-center text-sm text-muted-foreground`,children:[(0,D.jsx)(`p`,{children:e(`terminalView.empty.noWorkingDirectoryForSession`)}),(0,D.jsx)(`button`,{onClick:ot,className:`rounded-lg bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90`,children:e(`terminalView.actions.retry`)})]});let $=!U||Ce||Ee||Te,vt=et,yt=!ie&&Xe&&!$e,bt=(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(_,{type:`button`,size:`sm`,variant:`outline`,className:`h-6 px-2 text-xs`,onClick:()=>mt(`esc`),disabled:$,children:e(`terminalView.quickKeys.escape`)}),(0,D.jsxs)(_,{type:`button`,size:`sm`,variant:`outline`,className:`h-6 w-9 p-0`,onClick:()=>mt(`tab`),disabled:$,children:[(0,D.jsx)(g,{name:`arrow-right`,className:`h-4 w-4`}),(0,D.jsx)(`span`,{className:`sr-only`,children:e(`terminalView.quickKeys.tabAria`)})]}),(0,D.jsxs)(_,{type:`button`,size:`sm`,variant:`chip`,"aria-pressed":Y===`ctrl`,className:`h-6 w-9 p-0`,onClick:()=>pt(`ctrl`),disabled:$,children:[(0,D.jsx)(`span`,{className:`text-xs font-medium`,children:e(`terminalView.quickKeys.controlLabel`)}),(0,D.jsx)(`span`,{className:`sr-only`,children:e(`terminalView.quickKeys.controlModifierAria`)})]}),(0,D.jsxs)(_,{type:`button`,size:`sm`,variant:`chip`,"aria-pressed":Y===`cmd`,className:`h-6 w-9 p-0`,onClick:()=>pt(`cmd`),disabled:$,children:[(0,D.jsx)(g,{name:`command`}),(0,D.jsx)(`span`,{className:`sr-only`,children:e(`terminalView.quickKeys.commandModifierAria`)})]}),(0,D.jsxs)(_,{type:`button`,size:`sm`,variant:`outline`,className:`h-6 w-9 p-0`,onClick:()=>mt(`arrow-up`),disabled:$,children:[(0,D.jsx)(g,{name:`arrow-up`}),(0,D.jsx)(`span`,{className:`sr-only`,children:e(`terminalView.quickKeys.arrowUpAria`)})]}),(0,D.jsxs)(_,{type:`button`,size:`sm`,variant:`outline`,className:`h-6 w-9 p-0`,onClick:()=>mt(`arrow-left`),disabled:$,children:[(0,D.jsx)(g,{name:`arrow-left`}),(0,D.jsx)(`span`,{className:`sr-only`,children:e(`terminalView.quickKeys.arrowLeftAria`)})]}),(0,D.jsxs)(_,{type:`button`,size:`sm`,variant:`outline`,className:`h-6 w-9 p-0`,onClick:()=>mt(`arrow-down`),disabled:$,children:[(0,D.jsx)(g,{name:`arrow-down`}),(0,D.jsx)(`span`,{className:`sr-only`,children:e(`terminalView.quickKeys.arrowDownAria`)})]}),(0,D.jsxs)(_,{type:`button`,size:`sm`,variant:`outline`,className:`h-6 w-9 p-0`,onClick:()=>mt(`arrow-right`),disabled:$,children:[(0,D.jsx)(g,{name:`arrow-right`}),(0,D.jsx)(`span`,{className:`sr-only`,children:e(`terminalView.quickKeys.arrowRightAria`)})]}),(0,D.jsxs)(_,{type:`button`,size:`sm`,variant:`outline`,className:`h-6 w-9 p-0`,onClick:()=>mt(`enter`),disabled:$,children:[(0,D.jsx)(g,{name:`arrow-go-back`}),(0,D.jsx)(`span`,{className:`sr-only`,children:e(`terminalView.quickKeys.enterAria`)})]})]});return(0,D.jsxs)(`div`,{"data-terminal-view":`true`,className:`flex h-full flex-col overflow-hidden bg-[var(--surface-background)]`,children:[(0,D.jsxs)(`div`,{className:h(`app-region-no-drag sticky top-0 z-20 shrink-0 bg-[var(--surface-background)] text-xs`,ie?`px-3 py-1.5`:`pl-3 pr-1.5 py-1`),children:[k&&B?(0,D.jsxs)(`div`,{className:`flex items-center gap-2 pl-1 pr-1`,children:[(0,D.jsx)(`div`,{className:h(`min-w-0 flex-1`,ie?`h-8`:`h-7`),children:(0,D.jsx)(S,{items:be,activeId:V,onSelect:lt,onClose:ut,layoutMode:`scrollable`,variant:`default`,className:`h-full bg-transparent`})}),(0,D.jsx)(_,{type:`button`,size:`xs`,variant:`ghost`,className:h(`shrink-0`,ie?`h-8 w-8 p-0`:`h-7 w-7 p-0`),onClick:ct,title:e(`terminalView.tabs.newTabTitle`),children:(0,D.jsx)(g,{name:`add`,className:`${ie?`h-[18px] w-[18px]`:`h-4 w-4`}`})}),(0,D.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1 overflow-visible`,children:[W?(0,D.jsxs)(_,{type:`button`,size:`xs`,variant:`outline`,className:`h-6 shrink-0 gap-1 px-2`,onClick:()=>{M&&z(M,W)},title:e(`terminalView.preview.openTitle`),children:[(0,D.jsx)(g,{name:`global`,className:`h-3.5 w-3.5 shrink-0`}),(0,D.jsx)(`span`,{className:`whitespace-nowrap`,children:e(`terminalView.preview.open`)})]}):null,yt?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(_,{type:`button`,size:`xs`,variant:`ghost`,onClick:()=>Qe(!f),className:h(`shrink-0 p-0`,p?`h-8 w-8`:`h-7 w-7`),title:e(f?`terminalView.bottomDock.restoreTitle`:`terminalView.bottomDock.expandTitle`),"aria-label":e(f?`terminalView.bottomDock.restoreAria`:`terminalView.bottomDock.expandAria`),children:f?(0,D.jsx)(g,{name:`fullscreen-exit`,className:`h-4 w-4`}):(0,D.jsx)(g,{name:`fullscreen`,className:`h-4 w-4`})}),(0,D.jsx)(_,{type:`button`,size:`xs`,variant:`ghost`,onClick:()=>Ze(!1),className:h(`shrink-0 p-0`,p?`h-8 w-8`:`h-7 w-7`),title:e(`terminalView.bottomDock.closeTitle`),"aria-label":e(`terminalView.bottomDock.closeAria`),children:(0,D.jsx)(g,{name:`close`,className:`h-4 w-4`})})]}):null]})]}):null,!p&&A&&k&&B?(0,D.jsx)(`div`,{className:`mt-2 flex flex-wrap items-center gap-1 pl-1 pr-1`,children:bt}):null,A&&(p||!k||!B)?(0,D.jsx)(`div`,{className:`mt-2 flex flex-wrap items-center gap-1`,children:bt}):null]}),(0,D.jsxs)(`div`,{className:`relative flex-1 overflow-hidden`,style:{backgroundColor:gt.background},children:[(0,D.jsx)(`div`,{className:`h-full w-full box-border pl-4 pr-1.5 pt-3 pb-4`,children:vt?(0,D.jsx)(oe,{ref:e=>{Fe.current=e},sessionKey:_t,chunks:Se,onInput:dt,onResize:ft,theme:gt,fontFamily:ht,fontSize:u,enableTouchScroll:O,autoFocus:!O&&Z,isVisible:Z},_t):null}),!Te&&G&&(0,D.jsxs)(`div`,{className:`absolute inset-x-0 bottom-0 bg-[var(--status-error-background)] px-3 py-2 text-xs text-[var(--status-error-foreground)] flex items-center justify-between gap-2`,children:[(0,D.jsx)(`span`,{children:G}),we&&p&&(0,D.jsx)(_,{size:`sm`,variant:`secondary`,className:`h-6 px-2 py-0 text-xs`,onClick:st,disabled:Ee,title:e(`terminalView.actions.hardRestartTitle`),type:`button`,children:e(`terminalView.actions.hardRestart`)})]})]})]})};export{he as TerminalView};
@@ -0,0 +1,10 @@
1
+ import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{n as t}from"./runtime-fetch-zIalUnbb.js";import{nt as n,rt as r,tt as i}from"./vendor-base-ui-CnHfUmDN.js";import{g as a}from"./useUIStore-CxOoCv7B.js";import{n as o}from"./vendor-react-DLPElpoQ.js";import{a as s,i as c}from"./vendor-pierre-diffs-DX7XTPG3.js";import{n as l}from"./vendor-reactuses-core-DDoDDyM9.js";import{n as u}from"./clipboard-CUasgPiF.js";import{n as d,t as f}from"./dialog-BwQ3rY_x.js";import{t as p}from"./utils-BHTVlVov.js";import{n as m}from"./Icon-CkzzhaLr.js";import{t as h}from"./button-xx1UOBA5.js";import{n as g,t as _}from"./useThemeSystem-DMzWVJaW.js";import{i as v,n as y,s as b}from"./markdownTheme-DOfGg-A7.js";import{i as x,t as S}from"./appThemeRegistry-UIrP0-5h.js";import{n as ee}from"./MarkdownRenderer-BHfbAwVO.js";import{c as C}from"./markdown-worker-CptoICmq.js";import{n as te}from"./useEffectiveDirectory-DSNCCbCt.js";import{s as w}from"./imageSource-BlAJJUEI.js";import{_ as T,d as E,f as ne,g as D,h as re,l as O,m as k,n as A,p as j,r as M,s as N,t as P,u as F}from"./useWorkerHighlightedLines-CzpT4M7V.js";import{t as I}from"./vendor-tanstack-react-virtual-tlDgH6PG.js";var ie=e(i(),1),L=o(),R=e(r(),1),z=n(),B=80,ae=20,V=R.memo(e=>{let t=(0,L.c)(26),{lines:n,language:r,maxHeight:i,showLineNumbers:a,lineStyles:o}=e,s=i===void 0?`60vh`:i,c=a===void 0||a,{currentTheme:l}=g(),u;t[0]===l?u=t[1]:(u=y(l),t[0]=l,t[1]=u);let d=u,f;t[2]===n?f=t[3]:(f=n.map(W).join(`
2
+ `),t[2]=n,t[3]=f);let p=P(f,r);if(!(n.length>B)){let e=d,r;t[4]!==s||t[5]!==e?(r={...e,maxHeight:s,overflow:`auto`},t[4]=s,t[5]=e,t[6]=r):r=t[6];let i;if(t[7]!==p||t[8]!==o||t[9]!==n||t[10]!==c){let e;t[12]!==p||t[13]!==o||t[14]!==c?(e=(e,t)=>(0,z.jsx)(U,{line:e,html:p?.[t],showLineNumbers:c,style:o?.(e)},t),t[12]=p,t[13]=o,t[14]=c,t[15]=e):e=t[15],i=n.map(e),t[7]=p,t[8]=o,t[9]=n,t[10]=c,t[11]=i}else i=t[11];let a;return t[16]!==r||t[17]!==i?(a=(0,z.jsx)(`div`,{className:`typography-code font-mono w-full min-w-0`,style:r,children:i}),t[16]=r,t[17]=i,t[18]=a):a=t[18],a}let m;return t[19]!==p||t[20]!==o||t[21]!==n||t[22]!==s||t[23]!==c||t[24]!==d?(m=(0,z.jsx)(H,{lines:n,highlighted:p,syntaxVars:d,maxHeight:s,showLineNumbers:c,lineStyles:o}),t[19]=p,t[20]=o,t[21]=n,t[22]=s,t[23]=c,t[24]=d,t[25]=m):m=t[25],m});V.displayName=`VirtualizedCodeBlock`;var H=R.memo(({lines:e,highlighted:t,syntaxVars:n,maxHeight:r,showLineNumbers:i,lineStyles:a})=>{let o=R.useRef(null),s=`min(${e.length*ae}px, ${r})`,c=I({count:e.length,getScrollElement:()=>o.current,estimateSize:()=>ae,overscan:20}),l=c.getVirtualItems();return(0,z.jsx)(`div`,{ref:o,className:`typography-code font-mono w-full min-w-0`,style:{...n,height:s,maxHeight:r,overflow:`auto`},children:(0,z.jsx)(`div`,{style:{height:c.getTotalSize(),position:`relative`},children:l.map(n=>{let r=e[n.index];return r?(0,z.jsx)(`div`,{"data-index":n.index,ref:c.measureElement,style:{position:`absolute`,top:0,left:0,width:`100%`,transform:`translateY(${n.start}px)`},children:(0,z.jsx)(U,{line:r,html:t?.[n.index],showLineNumbers:i,style:a?.(r)})},n.index):null})})})});H.displayName=`VirtualizedRows`;var U=R.memo(e=>{let t=(0,L.c)(12),{line:n,html:r,showLineNumbers:i,style:a}=e,o;t[0]!==n.isInfo||t[1]!==n.lineNumber||t[2]!==i?(o=i&&(0,z.jsx)(`span`,{className:`w-10 flex-shrink-0 text-right pr-3 select-none border-r mr-3 -my-0.5 py-0.5`,style:{color:`var(--tools-edit-line-number)`,borderColor:`var(--tools-border)`},children:!n.isInfo&&n.lineNumber!=null?n.lineNumber:``}),t[0]=n.isInfo,t[1]=n.lineNumber,t[2]=i,t[3]=o):o=t[3];let s;t[4]!==r||t[5]!==n.isInfo||t[6]!==n.text?(s=(0,z.jsx)(`div`,{className:`flex-1 min-w-0`,children:n.isInfo?(0,z.jsx)(`div`,{className:`whitespace-pre-wrap break-words text-muted-foreground/70 italic`,children:n.text}):r===void 0?(0,z.jsx)(`div`,{className:`whitespace-pre`,children:n.text}):(0,z.jsx)(`div`,{className:`whitespace-pre`,dangerouslySetInnerHTML:{__html:r}})}),t[4]=r,t[5]=n.isInfo,t[6]=n.text,t[7]=s):s=t[7];let c;return t[8]!==a||t[9]!==o||t[10]!==s?(c=(0,z.jsxs)(`div`,{className:`typography-code font-mono flex w-full min-w-0`,style:a,children:[o,s]}),t[8]=a,t[9]=o,t[10]=s,t[11]=c):c=t[11],c});U.displayName=`VirtualizedCodeBlock.Row`;function W(e){return e.text}var G=R.memo(function({jsonString:e,className:t,maxHeight:n=`100%`,initiallyExpandedDepth:r=2}){let{t:i}=u(),a=R.useRef(null),[o,s]=R.useState(null),c=R.useMemo(()=>{try{let t=e.trim();if(!t)return s(i(`jsonTreeView.error.emptyJson`)),null;let n=JSON.parse(t);return s(null),n}catch(e){return s(e instanceof Error?e.message:i(`jsonTreeView.error.invalidJson`)),null}},[e,i]),l=R.useCallback(()=>{a.current?.expandAll()},[]),d=R.useCallback(()=>{a.current?.collapseAll()},[]);return o?(0,z.jsx)(`div`,{className:t,children:(0,z.jsxs)(`div`,{className:`rounded-md border border-[var(--interactive-border)] bg-[var(--syntax-base-background)] p-4`,children:[(0,z.jsx)(`div`,{className:`mb-1 font-medium text-[var(--surface-foreground)]`,children:i(`jsonTreeView.error.invalidJsonTitle`)}),(0,z.jsx)(`div`,{className:`font-mono text-xs text-[var(--surface-mutedForeground)]`,children:o})]})}):c===null?null:(0,z.jsxs)(`div`,{className:t,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-1 border-b border-[var(--interactive-border)] px-2 py-1`,children:[(0,z.jsxs)(h,{variant:`ghost`,size:`xs`,onClick:l,className:`gap-1 text-xs text-muted-foreground`,children:[(0,z.jsx)(m,{name:`arrow-down-s`,className:`h-3 w-3`}),i(`jsonTreeView.actions.expandAll`)]}),(0,z.jsxs)(h,{variant:`ghost`,size:`xs`,onClick:d,className:`gap-1 text-xs text-muted-foreground`,children:[(0,z.jsx)(m,{name:`arrow-up-s`,className:`h-3 w-3`}),i(`jsonTreeView.actions.collapseAll`)]})]}),(0,z.jsx)(`div`,{className:`bg-[var(--syntax-base-background)] py-1`,style:{maxHeight:n,overflow:`auto`},children:(0,z.jsx)(M,{ref:a,data:c,maxHeight:n,initiallyExpandedDepth:r})})]})}),K=class extends Error{key;params;constructor(e,t){super(e),this.name=`MermaidLoadFailure`,this.key=e,this.params=t}},q=(e,t)=>new K(e,t),oe=e=>e instanceof K,se=e=>e+1,ce=(e,t)=>e===t,J=e=>{let t=e.indexOf(`,`);if(t<0)throw q(`chat.toolOutputDialog.mermaid.dataUrlMalformed`);let n=e.slice(0,t).toLowerCase(),r=e.slice(t+1);return n.includes(`;base64`)?atob(r):decodeURIComponent(r)},le=e=>Promise.resolve().then(()=>J(e)),Y=1,X=56,Z=(e,t,n)=>Math.min(n,Math.max(t,e)),ue=({isMobile:e,pointerType:t,cancelled:n,moved:r,suppressTap:i,targetWasCanvas:a,start:o,end:s,startScale:c,hasMultipleImages:l})=>{if(n||i)return`none`;let u={x:s.x-o.x,y:s.y-o.y},d=Math.hypot(u.x,u.y),f=t!==`mouse`;if(e&&f&&c<=1.01&&Math.abs(u.x)>=X&&Math.abs(u.x)>Math.abs(u.y)*1.2)return l?u.x<0?`next`:`previous`:`none`;let p=!r&&d<=10;return e&&f&&p||!e&&t===`mouse`&&p&&a?`close`:`none`},de=(e,t)=>{if(e.width<=0||e.height<=0||t.width<=0||t.height<=0)return{width:1,height:1};let n=Math.min(t.width/e.width,t.height/e.height);return{width:Math.max(1,e.width*n),height:Math.max(1,e.height*n)}},fe=(e,t)=>{let n=t.minScale??Y,r=t.maxScale??5,i=Z(e.scale,n,r),a=Math.max(0,(t.image.width*i-t.viewport.width)/2),o=Math.max(0,(t.image.height*i-t.viewport.height)/2);return{scale:i,x:Z(e.x,-a,a),y:Z(e.y,-o,o)}},pe=(e,t,n,r,i)=>{let a=Z(t,i.minScale??Y,i.maxScale??5),o=a/e.scale;return fe({scale:a,x:n.x-r.x-(n.x-r.x-e.x)*o,y:n.y-r.y-(n.y-r.y-e.y)*o},i)},me=(e,t,n)=>fe({...e,x:e.x+t.x,y:e.y+t.y},n),he=(e,t,n,r,i,a)=>{let o=Z(r,a.minScale??Y,a.maxScale??5),s=o/e.scale;return fe({scale:o,x:n.x-i.x-(t.x-i.x-e.x)*s,y:n.y-i.y-(t.y-i.y-e.y)*s},a)},Q=500,$=24,ge=(e,t={})=>{let n=t.target??(typeof document>`u`?null:document);if(!n)return()=>{};let r=t.durationMs??Q,i=t.maxDistance??$,a=!0,o,s=()=>{a&&(a=!1,n.removeEventListener(`click`,c,!0),o!==void 0&&globalThis.clearTimeout(o))},c=t=>{let n=t;typeof n.clientX==`number`&&typeof n.clientY==`number`&&(Math.hypot(n.clientX-e.x,n.clientY-e.y)>i||(s(),t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation()))};return n.addEventListener(`click`,c,!0),o=globalThis.setTimeout(s,r),s},_e=(e,t,n={})=>{ge(e,n),t()},ve=500,ye=400,be=(e,t)=>new K(e,t),xe=e=>{let t=`h-3.5 w-3.5 flex-shrink-0`,n=e.toLowerCase();return n===`reasoning`?(0,z.jsx)(m,{name:`brain-ai-3`,className:t}):n===`image-preview`?(0,z.jsx)(m,{name:`file-image`,className:t}):n===`mermaid-preview`?(0,z.jsx)(m,{name:`file-list-2`,className:t}):n===`edit`||n===`multiedit`||n===`apply_patch`||n===`str_replace`||n===`str_replace_based_edit_tool`?(0,z.jsx)(m,{name:`pencil-ai`,className:t}):n===`write`||n===`create`||n===`file_write`||n===`read`||n===`view`||n===`file_read`||n===`cat`?(0,z.jsx)(m,{name:`file-pdf`,className:t}):n===`bash`||n===`shell`||n===`cmd`||n===`terminal`?(0,z.jsx)(m,{name:`terminal-box`,className:t}):n===`list`||n===`ls`||n===`dir`||n===`list_files`?(0,z.jsx)(m,{name:`folder-6`,className:t}):n===`search`||n===`grep`||n===`find`||n===`ripgrep`?(0,z.jsx)(m,{name:`search`,className:t}):n===`glob`?(0,z.jsx)(m,{name:`file-search`,className:t}):n===`fetch`||n===`curl`||n===`wget`||n===`webfetch`?(0,z.jsx)(m,{name:`global`,className:t}):n===`web-search`||n===`websearch`||n===`search_web`||n===`google`||n===`bing`||n===`duckduckgo`?(0,z.jsx)(m,{name:`search`,className:t}):n===`todowrite`||n===`todoread`?(0,z.jsx)(m,{name:`list-check-3`,className:t}):n.startsWith(`git`)?(0,z.jsx)(m,{name:`git-branch`,className:t}):(0,z.jsx)(m,{name:`tools`,className:t})},Se=150,Ce=40,we=120,Te=3,Ee={style:{background:`transparent`,backgroundColor:`transparent`,fontSize:`inherit`}},De={download:!1,copy:!1,showPanZoomControls:!0},Oe=`
3
+ [data-diff-header],
4
+ [data-diff] {
5
+ [data-separator] {
6
+ height: 24px !important;
7
+ }
8
+ }
9
+ `,ke={hunkLineCount:50,lineHeight:24,diffHeaderHeight:44,hunkSeparatorHeight:24,spacing:0},Ae=()=>{let e=(0,L.c)(22),t=_(),n;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=b(!1),e[0]=n):n=e[0];let r=n,i;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(i=b(!0),e[1]=i):i=e[1];let a=i,o;e[2]===t?.availableThemes?o=e[3]:(o=()=>t?.availableThemes??[r,a],e[2]=t?.availableThemes,e[3]=o),t?.availableThemes;let s;e[4]===o?s=e[5]:(s=o(),e[4]=o,e[5]=s);let c=s,l=t?.lightThemeId??r.metadata.id,u=t?.darkThemeId??a.metadata.id,d;e[6]!==c||e[7]!==l?(d=c.find(e=>e.metadata.id===l)??r,e[6]=c,e[7]=l,e[8]=d):d=e[8];let f=d,p;e[9]!==c||e[10]!==u?(p=c.find(e=>e.metadata.id===u)??a,e[9]=c,e[10]=u,e[11]=p):p=e[11];let m=p,h,g;e[12]!==m||e[13]!==f?(h=()=>{S(f),S(m)},g=[m,f],e[12]=m,e[13]=f,e[14]=h,e[15]=g):(h=e[14],g=e[15]),R.useEffect(h,g);let v=t?.currentTheme.metadata.variant??`light`,y;e[16]!==m.metadata.id||e[17]!==f.metadata.id?(y={light:f.metadata.id,dark:m.metadata.id},e[16]=m.metadata.id,e[17]=f.metadata.id,e[18]=y):y=e[18];let x=v===`dark`?`dark`:`light`,ee;return e[19]!==y||e[20]!==x?(ee={theme:y,themeType:x},e[19]=y,e[20]=x,e[21]=ee):ee=e[21],ee},je=()=>({width:typeof window<`u`?window.innerWidth:0,height:typeof window<`u`?window.innerHeight:0}),Me={mobile:{widthRatio:.94,heightRatio:.86,padding:10},desktop:{widthRatio:.8,heightRatio:.8,padding:16}},Ne=(e,t)=>{let n=t?Me.mobile:Me.desktop,r=Math.max(160,e.width-n.padding*2),i=Math.max(160,e.height-n.padding*2);return{maxWidth:Math.max(160,Math.min(r,e.width*n.widthRatio)),maxHeight:Math.max(160,Math.min(i,e.height*n.heightRatio))}},Pe=e=>{try{let t=Array.from(e.querySelectorAll(`g`)),n=0,r=null;for(let e of t){if(!(e instanceof SVGGraphicsElement))continue;let t=e.getBBox();if(!(t.width>0&&t.height>0))continue;let i=t.width*t.height;i>n&&(n=i,r=t.width/t.height)}if(r&&Number.isFinite(r)&&r>0)return r}catch{}let t=e.getAttribute(`viewBox`);if(t){let e=t.trim().split(/\s+/).map(Number);if(e.length===4){let t=e[2],n=e[3];if(Number.isFinite(t)&&Number.isFinite(n)&&t>0&&n>0)return t/n}}let n=Number(e.getAttribute(`width`)),r=Number(e.getAttribute(`height`));if(Number.isFinite(n)&&Number.isFinite(r)&&n>0&&r>0)return n/r;let i=e.getBoundingClientRect();return i.width>0&&i.height>0?i.width/i.height:null},Fe=e=>{let t=(0,L.c)(7),[n,r]=R.useState(e),[i,a]=R.useState(e),[o,s]=R.useState(!1),c,l;t[0]===e?(c=t[1],l=t[2]):(c=()=>{if(e){if(r(!0),s(!0),typeof window>`u`){a(!0);return}let e=window.requestAnimationFrame(()=>{a(!0)}),t=window.setTimeout(()=>{s(!1)},Se);return()=>{window.cancelAnimationFrame(e),window.clearTimeout(t)}}if(a(!1),s(!0),typeof window>`u`){r(!1);return}let t=window.setTimeout(()=>{r(!1),s(!1)},Se);return()=>{window.clearTimeout(t)}},l=[e],t[0]=e,t[1]=c,t[2]=l),R.useEffect(c,l);let u;return t[3]!==n||t[4]!==o||t[5]!==i?(u={isRendered:n,isVisible:i,isTransitioning:o},t[3]=n,t[4]=o,t[5]=i,t[6]=u):u=t[6],u},Ie=e=>{let t=(0,L.c)(3),[n,r]=R.useState(je),i,a;return t[0]===e?(i=t[1],a=t[2]):(i=()=>{if(!e||typeof window>`u`)return;let t=()=>{r(je())};return t(),window.addEventListener(`resize`,t),()=>{window.removeEventListener(`resize`,t)}},a=[e],t[0]=e,t[1]=i,t[2]=a),R.useEffect(i,a),n},Le=({popup:e,onOpenChange:t,isMobile:n})=>{let{t:r}=u(),i=_(),a=te()??``,o=R.useMemo(()=>{let t=e.image;if(!t)return[];let n=Array.isArray(t.gallery)?t.gallery.filter(e=>!!e?.url):[];return n.length>0?n:[{url:t.url,mimeType:t.mimeType,filename:t.filename,size:t.size}]},[e.image]),[s,c]=R.useState(0),[d,f]=R.useState(null),[g,y]=R.useState(!1),{isRendered:b,isVisible:S,isTransitioning:ee}=Fe(e.open),C=Ie(e.open),E=R.useRef(null),ne=R.useRef(null),D=R.useRef(null),re=R.useRef(null),O=R.useRef(null),k=R.useRef(null),A=R.useRef({scale:1,x:0,y:0}),j=R.useRef({image:{width:1,height:1},viewport:{width:1,height:1},maxScale:5}),M=R.useRef(new Map),N=R.useRef(null),P=R.useRef(null),F=R.useRef(null),I=R.useRef(null),L=R.useRef(0);R.useEffect(()=>{e.open&&(L.current=typeof performance<`u`?performance.now():Date.now())},[e.open]);let B=l(()=>(typeof performance<`u`?performance.now():Date.now())-L.current<ye),ae=l(()=>!B()&&(t(!1),!0));x({id:`image-preview`,active:e.open&&n,layer:`overlay`,onBack:ae,surfaceRef:ne});let V=l(()=>{let e=N.current;e?.longPressTimer&&(clearTimeout(e.longPressTimer),e.longPressTimer=null)});R.useEffect(()=>{if(!e.open||o.length===0)return;let t=typeof e.image?.index==`number`?e.image.index:-1;if(t>=0&&t<o.length){c(t);return}let n=e.image?.url?o.findIndex(t=>t.url===e.image?.url):-1;c(n>=0?n:0)},[o,e.image?.index,e.image?.url,e.open]);let H=o[s]??o[0]??e.image,U=w(H?.url??``,a),W=H?.filename||e.title,G=o.length>1,K=l(()=>{let t=H?.url??e.image?.url??``;if(!t&&!U)return;let n=H?.mimeType||e.image?.mimeType,r=H?.filename||e.image?.filename||e.title,i=O.current;if(i&&i.naturalWidth>0){T(i,n||`image/png`).then(e=>{v({sourceUrl:t||U,displayUrl:U||i.currentSrc||i.src||void 0,filename:r,mimeType:n,effectiveDirectory:a,prefetchedBlob:e??void 0})});return}v({sourceUrl:t||U,displayUrl:U||void 0,filename:r,mimeType:n,effectiveDirectory:a})}),q=l(()=>{o.length<=1||c(e=>(e-1+o.length)%o.length)}),oe=l(()=>{o.length<=1||c(e=>(e+1)%o.length)}),se=R.useMemo(()=>{let e={width:Math.max(1,C.width),height:Math.max(1,C.height)};return d?de(d,e):e},[d,C.height,C.width]),ce=R.useMemo(()=>({image:se,viewport:{width:Math.max(1,C.width),height:Math.max(1,C.height)},maxScale:5}),[se,C.height,C.width]),J=l((e,t=!1)=>{let n=fe(e,j.current);A.current=n,I.current={transform:n,animate:t},!(F.current!==null||typeof window>`u`)&&(F.current=window.requestAnimationFrame(()=>{F.current=null;let e=I.current;I.current=null,e&&(O.current&&(O.current.style.transition=e.animate?`transform 180ms cubic-bezier(0.22, 1, 0.36, 1)`:`none`,O.current.style.transform=`translate3d(${e.transform.x}px, ${e.transform.y}px, 0) scale(${e.transform.scale})`),k.current&&(k.current.textContent=`${Math.round(e.transform.scale*100)}%`),E.current&&(E.current.style.cursor=e.transform.scale>1?`grab`:`zoom-in`))}))}),le=l((e=!0)=>{J({scale:1,x:0,y:0},e)}),Y=l(()=>({x:j.current.viewport.width/2,y:j.current.viewport.height/2})),X=l((e,t,n=!1)=>{J(pe(A.current,e,t,Y(),j.current),n)}),Z=l(e=>{if(A.current.scale>1.01){le(!0);return}X(2,e,!0)}),Q=l(e=>{if(e.key===`Escape`){e.preventDefault(),t(!1);return}if(e.key===`Tab`){let t=ne.current;if(!t)return;let n=Array.from(t.querySelectorAll(`button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])`));if(n.length===0){e.preventDefault(),t.focus({preventScroll:!0});return}let r=n[0],i=n[n.length-1];if(e.shiftKey&&(document.activeElement===r||!t.contains(document.activeElement))){e.preventDefault(),i.focus({preventScroll:!0});return}!e.shiftKey&&(document.activeElement===i||!t.contains(document.activeElement))&&(e.preventDefault(),r.focus({preventScroll:!0}));return}if(!n){if(e.key===`+`||e.key===`=`){e.preventDefault(),X(A.current.scale*1.4,Y(),!0);return}if(e.key===`-`||e.key===`_`){e.preventDefault(),X(A.current.scale/1.4,Y(),!0);return}if(e.key===`0`){e.preventDefault(),le(!0);return}if(e.key===`ArrowLeft`&&G){e.preventDefault(),q();return}e.key===`ArrowRight`&&G&&(e.preventDefault(),oe())}});R.useEffect(()=>{if(e.open)return window.addEventListener(`keydown`,Q),()=>{window.removeEventListener(`keydown`,Q)}},[e.open]),R.useLayoutEffect(()=>{if(!(!e.open||!b))return re.current=document.activeElement instanceof HTMLElement?document.activeElement:null,D.current?.focus({preventScroll:!0}),()=>{let e=re.current;re.current=null,e?.isConnected&&e.focus({preventScroll:!0})}},[b,e.open]),R.useEffect(()=>{F.current!==null&&window.cancelAnimationFrame(F.current),F.current=null,I.current=null,f(null),y(!1),A.current={scale:1,x:0,y:0},M.current.clear(),N.current=null,P.current=null,O.current&&(O.current.style.transform=`translate3d(0, 0, 0) scale(1)`),k.current&&(k.current.textContent=`100%`)},[H?.url,U]),R.useLayoutEffect(()=>{j.current=ce;let e=fe(A.current,j.current);A.current=e,O.current&&(O.current.style.transition=`none`,O.current.style.transform=`translate3d(${e.x}px, ${e.y}px, 0) scale(${e.scale})`)},[ce]),R.useEffect(()=>()=>{F.current!==null&&window.cancelAnimationFrame(F.current),F.current=null,I.current=null;let e=N.current;e?.longPressTimer&&(clearTimeout(e.longPressTimer),e.longPressTimer=null)},[]);let $=l(e=>{if(n)return;e.preventDefault();let t={x:e.clientX,y:e.clientY},r=Math.exp(-e.deltaY*.002);X(A.current.scale*r,t)});R.useEffect(()=>{let e=E.current;if(!(!b||n||!e))return e.addEventListener(`wheel`,$,{passive:!1}),()=>e.removeEventListener(`wheel`,$)},[n,b]);let ge=l(e=>{n||(e.preventDefault(),Z({x:e.clientX,y:e.clientY}))}),be=l(e=>{e.preventDefault(),e.stopPropagation()}),xe=l(e=>{e.pointerType!==`mouse`&&e.preventDefault(),e.currentTarget.setPointerCapture(e.pointerId);let t={x:e.clientX,y:e.clientY};if(M.current.set(e.pointerId,{point:t,pointerType:e.pointerType}),M.current.size===1){if(N.current={pointerId:e.pointerId,pointerType:e.pointerType,start:t,transform:A.current,moved:!1,targetWasCanvas:e.target===e.currentTarget,suppressTap:!1,longPressTimer:null,longPressTriggered:!1},e.pointerType!==`mouse`||A.current.scale<=1.01){let t=N.current;t.longPressTimer=setTimeout(()=>{!N.current||N.current.pointerId!==e.pointerId||N.current.moved||(N.current.longPressTriggered=!0,N.current.suppressTap=!0,K())},ve)}E.current&&A.current.scale>1&&(E.current.style.cursor=`grabbing`);return}V(),N.current&&(N.current.suppressTap=!0,N.current.longPressTriggered=!1);let n=Array.from(M.current.values()).slice(0,2).map(e=>e.point),r=n[1].x-n[0].x,i=n[1].y-n[0].y;P.current={distance:Math.max(1,Math.hypot(r,i)),midpoint:{x:(n[0].x+n[1].x)/2,y:(n[0].y+n[1].y)/2},transform:A.current},N.current&&(N.current.suppressTap=!0)}),Se=l(e=>{if(!M.current.has(e.pointerId))return;e.preventDefault();let t={x:e.clientX,y:e.clientY};if(M.current.set(e.pointerId,{point:t,pointerType:e.pointerType}),M.current.size>=2&&P.current){V();let e=Array.from(M.current.values()).slice(0,2).map(e=>e.point),t=e[1].x-e[0].x,n=e[1].y-e[0].y,r={x:(e[0].x+e[1].x)/2,y:(e[0].y+e[1].y)/2},i=P.current.transform.scale*Math.hypot(t,n)/P.current.distance;J(he(P.current.transform,P.current.midpoint,r,i,Y(),j.current));return}let n=N.current;if(!n||n.pointerId!==e.pointerId)return;let r={x:t.x-n.start.x,y:t.y-n.start.y};Math.hypot(r.x,r.y)>10&&(n.moved=!0,V()),n.transform.scale>1.01&&J(me(n.transform,r,j.current))}),Ce=l((e,r)=>{let i=N.current,a=M.current.get(e.pointerId)?{x:e.clientX,y:e.clientY}:void 0;if(M.current.delete(e.pointerId),i?.pointerId===e.pointerId&&(V(),a&&!i.longPressTriggered)){let e=ue({isMobile:n,pointerType:i.pointerType,cancelled:r,moved:i.moved||Math.hypot(a.x-i.start.x,a.y-i.start.y)>10,suppressTap:i.suppressTap,targetWasCanvas:i.targetWasCanvas,start:i.start,end:a,startScale:i.transform.scale,hasMultipleImages:G});if(e===`next`&&oe(),e===`previous`&&q(),e===`close`){if(B())return;if(n&&i.pointerType!==`mouse`){_e(a,()=>t(!1));return}t(!1)}}if(M.current.size===1){let[e,t]=Array.from(M.current.entries())[0];N.current={pointerId:e,pointerType:t.pointerType,start:t.point,transform:A.current,moved:!1,targetWasCanvas:!1,suppressTap:!0,longPressTimer:null,longPressTriggered:!1},P.current=null}else M.current.size===0&&(N.current=null,P.current=null,E.current&&(E.current.style.cursor=A.current.scale>1?`grab`:`zoom-in`));e.currentTarget.hasPointerCapture(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId)}),we=l(e=>{e.preventDefault(),e.stopPropagation(),K()}),Te=l(e=>{let t=e.currentTarget;t.naturalWidth>0&&t.naturalHeight>0&&f(e=>e?.width===t.naturalWidth&&e.height===t.naturalHeight?e:{width:t.naturalWidth,height:t.naturalHeight}),y(!0)});if(!b||!H||typeof document>`u`)return null;let Ee=i?.currentTheme.metadata.variant===`dark`,De=Ee?`bg-background text-foreground`:`bg-foreground text-background`,Oe=Ee?`border-foreground/15 bg-foreground/10 text-foreground`:`border-background/15 bg-background/10 text-background`,ke=Ee?`text-foreground hover:bg-foreground/15 hover:text-foreground`:`text-background hover:bg-background/15 hover:text-background`,Ae=(0,z.jsxs)(`div`,{ref:ne,className:p(`fixed inset-0 z-50 overflow-hidden select-none`,De,ee&&`transition-opacity duration-150 ease-out`,S?`opacity-100`:`opacity-0`,`pointer-events-auto`),role:`dialog`,"aria-modal":`true`,"aria-label":W,tabIndex:-1,onClick:be,children:[(0,z.jsx)(h,{ref:D,className:`sr-only`,onClick:()=>t(!1),children:r(`dialog.common.actions.close`)}),(0,z.jsxs)(`div`,{ref:E,className:`absolute inset-0 flex items-center justify-center overflow-hidden touch-none [overscroll-behavior:none]`,onDoubleClick:n?void 0:ge,onContextMenu:we,onPointerDown:xe,onPointerMove:Se,onPointerUp:e=>Ce(e,!1),onPointerCancel:e=>Ce(e,!0),onLostPointerCapture:e=>Ce(e,!0),children:[!g&&(0,z.jsx)(`div`,{className:`pointer-events-none absolute inset-0 flex items-center justify-center`,role:`status`,children:(0,z.jsxs)(`span`,{className:`flex items-center gap-2 typography-ui-label opacity-70`,children:[(0,z.jsx)(m,{name:`loader-4`,className:`size-4 animate-spin`}),r(`common.loading`)]})}),(0,z.jsx)(`img`,{ref:O,src:U||void 0,alt:W??``,className:p(`block max-w-none object-contain will-change-transform`,g?`opacity-100`:`opacity-0`),style:{width:`${se.width}px`,height:`${se.height}px`},loading:`lazy`,draggable:!1,onLoad:Te})]}),(0,z.jsx)(`div`,{className:`pointer-events-none absolute inset-x-0 bottom-0 z-10 flex justify-center px-2 pb-[max(0.5rem,env(safe-area-inset-bottom))]`,children:(0,z.jsxs)(`div`,{className:p(`pointer-events-auto flex h-10 items-center gap-0.5 rounded-full border px-1 shadow-lg backdrop-blur-xl`,Oe),onPointerDown:e=>e.stopPropagation(),onDoubleClick:e=>e.stopPropagation(),children:[G&&(0,z.jsx)(h,{variant:`ghost`,size:`icon`,className:p(`size-8 rounded-full`,ke),onClick:q,"aria-label":r(`chat.toolOutputDialog.image.previousAria`),title:r(`chat.toolOutputDialog.image.previousAria`),children:(0,z.jsx)(m,{name:`arrow-left-s`,className:`size-5`})}),G&&(0,z.jsxs)(`span`,{className:`min-w-10 px-1 text-center typography-micro tabular-nums opacity-80`,children:[s+1,` / `,o.length]}),G&&(0,z.jsx)(h,{variant:`ghost`,size:`icon`,className:p(`size-8 rounded-full`,ke),onClick:oe,"aria-label":r(`chat.toolOutputDialog.image.nextAria`),title:r(`chat.toolOutputDialog.image.nextAria`),children:(0,z.jsx)(m,{name:`arrow-right-s`,className:`size-5`})}),G&&(0,z.jsx)(`span`,{className:`mx-0.5 h-4 w-px bg-current opacity-15`,"aria-hidden":`true`}),(0,z.jsx)(h,{variant:`ghost`,size:`icon`,className:p(`size-8 rounded-full`,ke),onClick:()=>X(A.current.scale/1.4,Y(),!0),"aria-label":r(`chat.toolOutputDialog.image.zoomOutAria`),title:r(`chat.toolOutputDialog.image.zoomOutAria`),children:(0,z.jsx)(m,{name:`subtract`,className:`size-4`})}),(0,z.jsxs)(h,{variant:`ghost`,size:`sm`,className:p(`h-8 min-w-14 rounded-full px-2 tabular-nums`,ke),onClick:()=>le(!0),"aria-label":r(`chat.toolOutputDialog.image.resetZoomAria`),title:r(`chat.toolOutputDialog.image.resetZoomAria`),children:[(0,z.jsx)(m,{name:`restart`,className:`size-3.5`}),(0,z.jsx)(`span`,{ref:k,children:`100%`})]}),(0,z.jsx)(h,{variant:`ghost`,size:`icon`,className:p(`size-8 rounded-full`,ke),onClick:()=>X(A.current.scale*1.4,Y(),!0),"aria-label":r(`chat.toolOutputDialog.image.zoomInAria`),title:r(`chat.toolOutputDialog.image.zoomInAria`),children:(0,z.jsx)(m,{name:`add`,className:`size-4`})})]})})]});return(0,ie.createPortal)(Ae,document.body)},Re=R.memo(e=>{let t=(0,L.c)(7),{popup:n,diffViewMode:r,pierreThemeConfig:i}=e,a=n.content||``,o=r===`unified`?`unified`:`split`,s;t[0]!==i.theme||t[1]!==i.themeType||t[2]!==o?(s={diffStyle:o,diffIndicators:`none`,hunkSeparators:`line-info-basic`,lineDiffType:`none`,disableFileHeader:!0,maxLineDiffLength:1e3,expansionLineCount:20,overflow:`wrap`,theme:i.theme,themeType:i.themeType,unsafeCSS:Oe},t[0]=i.theme,t[1]=i.themeType,t[2]=o,t[3]=s):s=t[3];let l;return t[4]!==a||t[5]!==s?(l=(0,z.jsx)(`div`,{className:`typography-code`,children:(0,z.jsx)(c,{patch:a,metrics:ke,options:s,className:`block w-full`})}),t[4]=a,t[5]=s,t[6]=l):l=t[6],l});Re.displayName=`DialogUnifiedDiff`;var ze=R.memo(e=>{let t=(0,L.c)(29),{popup:n,pierreThemeConfig:r}=e,i;t[0]===n.content?i=t[1]:(i=O(n.content),t[0]=n.content,t[1]=i);let a=i,o=n.metadata?.input,c;t[2]===o?c=t[3]:(c=typeof o==`object`&&o?o:{},t[2]=o,t[3]=c);let l=c,u=typeof l.offset==`number`?l.offset:0,d=typeof l.file_path==`string`?l.file_path:typeof l.filePath==`string`?l.filePath:typeof l.path==`string`?l.path:`read-output`,f;t[4]===a.lines?f=t[5]:(f=a.lines.map(He).join(`
10
+ `),t[4]=a.lines,t[5]=f);let p=f,m;t[6]!==d||t[7]!==n.language?(m=n.language||C(d)||`text`,t[6]=d,t[7]=n.language,t[8]=m):m=t[8];let h=m,g;t[9]===a.lines?g=t[10]:(g=a.lines.some(Ue),t[9]=a.lines,t[10]=g);let _=g,v;if(t[11]!==_||t[12]!==u||t[13]!==a.lines||t[14]!==a.type){v=[];let e=u;for(let t of a.lines){t.lineNumber!==null&&(e=t.lineNumber);let n=a.type===`file`&&!_&&t.lineNumber===null&&!t.isInfo,r=t.lineNumber??(n?e+1:null);typeof r==`number`&&(e=r),v.push({text:t.text,lineNumber:r,isInfo:t.isInfo})}t[11]=_,t[12]=u,t[13]=a.lines,t[14]=a.type,t[15]=v}else v=t[15];let y=v;if(a.type===`file`){let e=h||void 0,n;t[16]!==p||t[17]!==d||t[18]!==e?(n={name:d,contents:p,lang:e},t[16]=p,t[17]=d,t[18]=e,t[19]=n):n=t[19];let i;t[20]!==r.theme||t[21]!==r.themeType?(i={disableFileHeader:!0,overflow:`wrap`,theme:r.theme,themeType:r.themeType},t[20]=r.theme,t[21]=r.themeType,t[22]=i):i=t[22];let a;return t[23]!==n||t[24]!==i?(a=(0,z.jsx)(s,{file:n,options:i,className:`block w-full`}),t[23]=n,t[24]=i,t[25]=a):a=t[25],a}let b;return t[26]!==y||t[27]!==h?(b=(0,z.jsx)(V,{lines:y,language:h,maxHeight:`70vh`}),t[26]=y,t[27]=h,t[28]=b):b=t[28],b});ze.displayName=`DialogReadContent`;var Be=e=>{let n=(0,L.c)(90),{popup:r,onOpenChange:i,isMobile:a}=e,{t:o}=u(),[s,c]=R.useState(r.mermaid?.source||``),[l,d]=R.useState(r.mermaid?.source?`ready`:`idle`),[f,h]=R.useState(``),{isRendered:g,isVisible:_,isTransitioning:v}=Fe(r.open),[y,b]=R.useState(null),x=Ie(r.open),S=R.useRef(0),C=R.useRef(null),te=qe,w;n[0]!==r.mermaid||n[1]!==o?(w=async()=>{let e=r.mermaid,n=se(S.current);if(S.current=n,!e?.url){d(`error`),h(o(`chat.toolOutputDialog.mermaid.missingSource`));return}if(e.source){c(e.source),d(`ready`),h(``);return}d(`loading`),h(``);let i;if(e.url.startsWith(`data:`))i=le(e.url);else if(e.url.toLowerCase().startsWith(`file://`)){let n=te(e.url);i=n?t(`/api/fs/raw`,{query:{path:n}}).then(Je):Promise.reject(be(`chat.toolOutputDialog.mermaid.invalidLocalPath`))}else{let t=typeof URL.canParse==`function`&&URL.canParse(e.url,window.location.origin)?new URL(e.url,window.location.origin):null;i=!t||t.protocol!==`http:`&&t.protocol!==`https:`?Promise.reject(be(`chat.toolOutputDialog.mermaid.unsupportedUrlProtocol`)):fetch(t.toString()).then(Ye)}await i.then(e=>{ce(S.current,n)&&(c(e),d(`ready`))}).catch(e=>{ce(S.current,n)&&(d(`error`),h(oe(e)?o(e.key,e.params):o(`chat.toolOutputDialog.mermaid.loadFailed`)))})},n[0]=r.mermaid,n[1]=o,n[2]=w):w=n[2];let T=w,E,ne;n[3]!==T||n[4]!==r.mermaid||n[5]!==r.open?(E=()=>{!r.open||!r.mermaid||T()},ne=[T,r.mermaid,r.open],n[3]=T,n[4]=r.mermaid,n[5]=r.open,n[6]=E,n[7]=ne):(E=n[6],ne=n[7]),R.useEffect(E,ne);let D,re;n[8]!==i||n[9]!==r.open?(D=()=>{if(!r.open)return;let e=e=>{e.key===`Escape`&&i(!1)};return window.addEventListener(`keydown`,e),()=>{window.removeEventListener(`keydown`,e)}},re=[i,r.open],n[8]=i,n[9]=r.open,n[10]=D,n[11]=re):(D=n[10],re=n[11]),R.useEffect(D,re);let O;n[12]!==r.open||n[13]!==l?(O=()=>{if(!r.open||l!==`ready`){b(null);return}let e=()=>{let e=C.current?.querySelector(`svg`);if(!e)return!1;let t=Pe(e);return!t||!Number.isFinite(t)||t<=0?!1:(b(e=>e&&Math.abs(e-t)<.001?e:t),!0)},t=window.requestAnimationFrame(()=>{e()||(t=window.requestAnimationFrame(()=>{e()}))}),n=0,i,a=()=>{n>=Te||(i=window.setTimeout(()=>{n+=1,e()||a()},we))};a();let o=new MutationObserver(()=>{e()});return C.current&&o.observe(C.current,{childList:!0,subtree:!0,attributes:!0}),()=>{window.cancelAnimationFrame(t),typeof i==`number`&&window.clearTimeout(i),o.disconnect()}},n[12]=r.open,n[13]=l,n[14]=O):O=n[14];let k;n[15]!==r.open||n[16]!==s||n[17]!==l?(k=[r.open,s,l],n[15]=r.open,n[16]=s,n[17]=l,n[18]=k):k=n[18],R.useEffect(O,k);let A=`\`\`\`mermaid\n${s}\n\`\`\``,j;if(n[19]!==y||n[20]!==a||n[21]!==x){bb0:{let{maxWidth:e,maxHeight:t}=Ne(x,a),r=Math.max(160,t-Ce);if(y&&y<1){let t=Math.min(e,r),i;n[23]===t?i=n[24]:(i=Math.round(t),n[23]=t,n[24]=i);let a;n[25]===t?a=n[26]:(a=Math.round(t),n[25]=t,n[26]=a);let o;n[27]!==a||n[28]!==i?(o={width:i,height:a},n[27]=a,n[28]=i,n[29]=o):o=n[29],j=o;break bb0}let i=Math.round(e),o;n[30]===r?o=n[31]:(o=Math.round(r),n[30]=r,n[31]=o),j={width:i,height:o}}n[19]=y,n[20]=a,n[21]=x,n[22]=j}else j=n[22];let M=j;if(!g||typeof document>`u`)return null;let N=r.open?`pointer-events-auto`:`pointer-events-none`,P;n[32]===N?P=n[33]:(P=p(`fixed inset-0 z-50`,N),n[32]=N,n[33]=P);let F=v&&`transition-opacity duration-150 ease-out`,I=_?`opacity-100`:`opacity-0`,B;n[34]!==F||n[35]!==I?(B=p(`absolute inset-0`,F,I),n[34]=F,n[35]=I,n[36]=B):B=n[36];let ae;n[37]===Symbol.for(`react.memo_cache_sentinel`)?(ae={backgroundColor:`color-mix(in srgb, var(--surface-background) 70%, transparent)`},n[37]=ae):ae=n[37];let V;n[38]===i?V=n[39]:(V=()=>i(!1),n[38]=i,n[39]=V);let H;n[40]!==B||n[41]!==V?(H=(0,z.jsx)(`div`,{"aria-hidden":`true`,className:B,style:ae,onMouseDown:V}),n[40]=B,n[41]=V,n[42]=H):H=n[42];let U=a?`p-2.5`:`p-4`,W;n[43]===U?W=n[44]:(W=p(`absolute inset-0 flex items-center justify-center pointer-events-none`,U),n[43]=U,n[44]=W);let G=v&&`transition-opacity duration-150 ease-out`,K=_?`opacity-100`:`opacity-0`,q;n[45]!==G||n[46]!==K?(q=p(`pointer-events-auto flex flex-col gap-2`,G,K),n[45]=G,n[46]=K,n[47]=q):q=n[47];let J=`${M.width}px`,Y;n[48]===J?Y=n[49]:(Y={width:J},n[48]=J,n[49]=Y);let X;n[50]===i?X=n[51]:(X=()=>i(!1),n[50]=i,n[51]=X);let Z;n[52]===o?Z=n[53]:(Z=o(`chat.toolOutputDialog.mermaid.closeAria`),n[52]=o,n[53]=Z);let ue;n[54]===Symbol.for(`react.memo_cache_sentinel`)?(ue=(0,z.jsx)(m,{name:`close`,className:`h-4 w-4`}),n[54]=ue):ue=n[54];let de;n[55]!==X||n[56]!==Z?(de=(0,z.jsx)(`div`,{className:`flex items-center justify-end`,children:(0,z.jsx)(`button`,{type:`button`,className:`h-8 w-8 flex items-center justify-center rounded-lg text-muted-foreground/80 hover:text-foreground focus:outline-none focus:ring-2 focus:ring-primary/60`,onClick:X,"aria-label":Z,children:ue})}),n[55]=X,n[56]=Z,n[57]=de):de=n[57];let fe=`${M.height}px`,pe;n[58]===fe?pe=n[59]:(pe={height:fe},n[58]=fe,n[59]=pe);let me;n[60]!==l||n[61]!==o?(me=l===`loading`&&(0,z.jsxs)(`div`,{className:`h-full min-h-28 flex items-center justify-center gap-2 text-muted-foreground typography-meta`,children:[(0,z.jsx)(m,{name:`loader-4`,className:`h-4 w-4 animate-spin`}),(0,z.jsx)(`span`,{children:o(`chat.toolOutputDialog.mermaid.loading`)})]}),n[60]=l,n[61]=o,n[62]=me):me=n[62];let he;n[63]!==f||n[64]!==T||n[65]!==l||n[66]!==o?(he=l===`error`&&(0,z.jsxs)(`div`,{className:`rounded-xl border p-3 space-y-3`,style:{backgroundColor:`var(--status-error-background)`,borderColor:`var(--status-error-border)`},children:[(0,z.jsx)(`p`,{className:`typography-markdown`,style:{color:`var(--status-error)`},children:f||o(`chat.toolOutputDialog.mermaid.renderFailed`)}),(0,z.jsx)(`button`,{type:`button`,onClick:()=>{T()},className:`px-3 py-1.5 rounded-lg typography-meta border transition-colors hover:bg-[var(--interactive-hover)]`,style:{borderColor:`var(--interactive-border)`,color:`var(--surface-foreground)`},children:o(`chat.toolOutputDialog.mermaid.retry`)})]}),n[63]=f,n[64]=T,n[65]=l,n[66]=o,n[67]=he):he=n[67];let Q;n[68]!==A||n[69]!==l?(Q=l===`ready`&&(0,z.jsx)(`div`,{ref:C,className:`h-full`,children:(0,z.jsx)(ee,{content:A,variant:`tool`,allowMermaidWheelEvents:!0,className:`markdown-mermaid-fullscreen h-full`,mermaidControls:De,enableFileReferences:!1})}),n[68]=A,n[69]=l,n[70]=Q):Q=n[70];let $;n[71]!==me||n[72]!==he||n[73]!==Q?($=(0,z.jsxs)(`div`,{className:`h-full overflow-hidden`,children:[me,he,Q]}),n[71]=me,n[72]=he,n[73]=Q,n[74]=$):$=n[74];let ge;n[75]!==pe||n[76]!==$?(ge=(0,z.jsx)(`div`,{className:`relative overflow-hidden`,style:pe,children:$}),n[75]=pe,n[76]=$,n[77]=ge):ge=n[77];let _e;n[78]!==q||n[79]!==Y||n[80]!==de||n[81]!==ge?(_e=(0,z.jsxs)(`div`,{className:q,style:Y,onMouseDown:Xe,children:[de,ge]}),n[78]=q,n[79]=Y,n[80]=de,n[81]=ge,n[82]=_e):_e=n[82];let ve;n[83]!==W||n[84]!==_e?(ve=(0,z.jsx)(`div`,{className:W,children:_e}),n[83]=W,n[84]=_e,n[85]=ve):ve=n[85];let ye;return n[86]!==P||n[87]!==H||n[88]!==ve?(ye=(0,ie.createPortal)((0,z.jsxs)(`div`,{className:P,children:[H,ve]}),document.body),n[86]=P,n[87]=H,n[88]=ve,n[89]=ye):ye=n[89],ye},Ve=e=>{let t=(0,L.c)(48),{popup:n,onOpenChange:r,isMobile:i}=e,{t:o}=u(),[c,l]=R.useState(`unified`),h=Ae(),g;t[0]===n.open?g=t[1]:(g=()=>{n.open&&l(`unified`)},t[0]=n.open,t[1]=g);let _;if(t[2]!==n.open||t[3]!==n.title?(_=[n.open,n.title],t[2]=n.open,t[3]=n.title,t[4]=_):_=t[4],R.useEffect(g,_),n.image){let e;return t[5]!==i||t[6]!==r||t[7]!==n?(e=(0,z.jsx)(Le,{popup:n,onOpenChange:r,isMobile:i}),t[5]=i,t[6]=r,t[7]=n,t[8]=e):e=t[8],e}if(n.mermaid){let e;return t[9]!==i||t[10]!==r||t[11]!==n?(e=(0,z.jsx)(Be,{popup:n,onOpenChange:r,isMobile:i}),t[9]=i,t[10]=r,t[11]=n,t[12]=e):e=t[12],e}let v=n.open,y=i?`w-[95vw] max-w-[95vw]`:`max-w-5xl`,b=i?`[&>button]:right-1`:`[&>button]:top-2.5 [&>button]:right-4`,x;t[13]!==y||t[14]!==b?(x=p(`overflow-hidden flex flex-col min-h-0 pt-3 pb-4 px-4 gap-1`,`[&>button]:top-1.5`,y,b),t[13]=y,t[14]=b,t[15]=x):x=t[15];let S;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(S={maxHeight:`90vh`},t[16]=S):S=t[16];let te;t[17]===n.metadata?te=t[18]:(te=n.metadata?.tool?xe(n.metadata.tool):(0,z.jsx)(m,{name:`tools`,className:`h-3.5 w-3.5 text-foreground flex-shrink-0`}),t[17]=n.metadata,t[18]=te);let w;t[19]===n.title?w=t[20]:(w=(0,z.jsx)(`span`,{className:`break-words flex-1 leading-tight`,children:n.title}),t[19]=n.title,t[20]=w);let T;t[21]!==c||t[22]!==n.isDiff?(T=n.isDiff&&(0,z.jsx)(A,{mode:c,onModeChange:l,className:`mr-8 flex-shrink-0`}),t[21]=c,t[22]=n.isDiff,t[23]=T):T=t[23];let O;t[24]!==T||t[25]!==te||t[26]!==w?(O=(0,z.jsx)(`div`,{className:`flex-shrink-0 pb-1`,children:(0,z.jsxs)(`div`,{className:`flex items-start gap-2 text-foreground typography-ui-header font-semibold`,children:[te,w,T]})}),t[24]=T,t[25]=te,t[26]=w,t[27]=O):O=t[27];let M;t[28]!==h||t[29]!==n.metadata?(M=n.metadata?.input&&typeof n.metadata.input==`object`&&Object.keys(n.metadata.input).length>0&&n.metadata?.tool!==`todowrite`&&n.metadata?.tool!==`todoread`&&n.metadata?.tool!==`apply_patch`?(()=>{let e=n.metadata,t=e.input,r=e=>{let n=t[e];return typeof n==`string`?n:typeof n==`number`?String(n):null};return(0,z.jsxs)(`div`,{className:`border-b border-border/20 p-4 -mx-3`,children:[(0,z.jsx)(`div`,{className:`typography-markdown font-medium text-muted-foreground mb-2 px-3`,children:e.tool===`bash`?`Command:`:e.tool===`task`?`Task Details:`:`Input:`}),e.tool===`bash`&&r(`command`)?(0,z.jsx)(`div`,{className:`tool-input-surface bg-transparent rounded-xl border border-border/20 mx-3`,children:(0,z.jsx)(D,{language:`bash`,code:r(`command`),style:a.getPopupStyles(),codeStyle:Ee.style,wrap:!0})}):e.tool===`task`&&r(`prompt`)?(0,z.jsxs)(`div`,{className:`tool-input-surface bg-transparent rounded-xl border border-border/20 font-mono whitespace-pre-wrap text-foreground/90 mx-3`,style:a.getPopupStyles(),children:[r(`description`)?`Task: ${r(`description`)}\n`:``,r(`subagent_type`)?`Agent Type: ${r(`subagent_type`)}\n`:``,`Instructions:\n${r(`prompt`)}`]}):e.tool===`write`&&r(`content`)?(0,z.jsx)(`div`,{className:`tool-input-surface bg-transparent rounded-xl border border-border/20 mx-3`,children:(0,z.jsx)(s,{file:{name:r(`filePath`)||r(`file_path`)||`new-file`,contents:r(`content`),lang:C(r(`filePath`)||r(`file_path`)||``)||void 0},options:{disableFileHeader:!0,overflow:`wrap`,theme:h.theme,themeType:h.themeType},className:`block w-full`})}):(0,z.jsx)(`div`,{className:`tool-input-surface bg-transparent rounded-xl border border-border/20 font-mono whitespace-pre-wrap text-foreground/90 mx-3`,style:a.getPopupStyles(),children:N(t,e.tool)})]})})():null,t[28]=h,t[29]=n.metadata,t[30]=M):M=t[30];let P;t[31]!==c||t[32]!==i||t[33]!==h||t[34]!==n||t[35]!==o?(P=n.isDiff?(0,z.jsx)(Re,{popup:n,diffViewMode:c,pierreThemeConfig:h}):n.content?(0,z.jsx)(`div`,{className:`p-4`,children:(()=>{let e=n.metadata?.tool;return e===`todowrite`||e===`todoread`?j(n.content)||(0,z.jsx)(D,{language:`json`,code:n.content,style:a.getPopupContainerStyles(),codeStyle:Ee.style,wrap:!0}):e===`list`?ne(n.content)||(0,z.jsx)(`pre`,{className:`typography-markdown bg-muted/30 p-2 rounded-xl border border-border/20 font-mono whitespace-pre-wrap`,children:n.content}):e===`grep`?E(n.content,i)||(0,z.jsx)(`pre`,{className:`typography-code bg-muted/30 p-2 rounded-xl border border-border/20 font-mono whitespace-pre-wrap`,children:n.content}):e===`glob`?F(n.content,i)||(0,z.jsx)(`pre`,{className:`typography-code bg-muted/30 p-2 rounded-xl border border-border/20 font-mono whitespace-pre-wrap`,children:n.content}):e===`task`||e===`reasoning`?(0,z.jsx)(`div`,{className:e===`reasoning`?`text-muted-foreground/70`:``,children:(0,z.jsx)(ee,{content:n.content,variant:`tool`})}):e===`web-search`||e===`websearch`||e===`search_web`?k(n.content)||(0,z.jsx)(D,{language:`text`,code:n.content,style:a.getPopupContainerStyles(),codeStyle:Ee.style,wrap:!0}):e===`read`?(0,z.jsx)(ze,{popup:n,pierreThemeConfig:h}):(n.content?re(n.content):{data:null,isJson:!1}).isJson?(0,z.jsx)(G,{jsonString:n.content,initiallyExpandedDepth:3,maxHeight:`70vh`}):(0,z.jsx)(D,{language:n.language||`text`,code:n.content,style:a.getPopupContainerStyles(),codeStyle:Ee.style,wrap:!0})})()}):(0,z.jsxs)(`div`,{className:`p-8 text-muted-foreground typography-ui-header`,children:[(0,z.jsx)(`div`,{className:`mb-2`,children:o(`chat.toolOutputDialog.commandCompleted`)}),(0,z.jsx)(`div`,{className:`typography-meta`,children:o(`chat.toolOutputDialog.noOutputProduced`)})]}),t[31]=c,t[32]=i,t[33]=h,t[34]=n,t[35]=o,t[36]=P):P=t[36];let I;t[37]!==M||t[38]!==P?(I=(0,z.jsx)(`div`,{className:`flex-1 min-h-0 rounded-xl border border-border/30 bg-muted/10 overflow-hidden`,children:(0,z.jsxs)(`div`,{className:`tool-output-surface h-full max-h-[75vh] overflow-y-auto px-3 pr-4`,children:[M,P]})}),t[37]=M,t[38]=P,t[39]=I):I=t[39];let ie;t[40]!==O||t[41]!==I||t[42]!==x?(ie=(0,z.jsxs)(d,{className:x,style:S,children:[O,I]}),t[40]=O,t[41]=I,t[42]=x,t[43]=ie):ie=t[43];let B;return t[44]!==r||t[45]!==n.open||t[46]!==ie?(B=(0,z.jsx)(f,{open:v,onOpenChange:r,children:ie}),t[44]=r,t[45]=n.open,t[46]=ie,t[47]=B):B=t[47],B};function He(e){return e.text}function Ue(e){return e.lineNumber!==null}function We(e){if(!e||/[\0\r\n]/.test(e))return!1;let t=e.replace(/\\/g,`/`);return t.split(`/`).filter(Boolean).includes(`..`)?!1:t.startsWith(`/`)?!0:/^[A-Za-z]:\//.test(t)}function Ge(e,t){let n=Number.parseInt(t,16);return Number.isFinite(n)?String.fromCharCode(n):`%${t}`}function Ke(e){return e.replace(/%([0-9A-Fa-f]{2})/g,Ge)}function qe(e){let t=e.trim();if(!t.toLowerCase().startsWith(`file://`))return null;let n=We,r=Ke;if(typeof URL.canParse==`function`&&URL.canParse(t)){let e=r(new URL(t).pathname||``);return/^\/[A-Za-z]:\//.test(e)&&(e=e.slice(1)),n(e)?e:null}let i=t.replace(/^file:\/\//i,``),a=r(i);return n(a)?a:n(i)?i:null}function Je(e){return e.ok?e.text():Promise.reject(be(`chat.toolOutputDialog.mermaid.readFileFailedWithStatus`,{status:e.status}))}function Ye(e){return e.ok?e.text():Promise.reject(be(`chat.toolOutputDialog.mermaid.loadFailedWithStatus`,{status:e.status}))}function Xe(e){return e.stopPropagation()}export{Ve as default};
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{a as t}from"./vendor-zustand-B4dlGEM2.js";import{rt as n}from"./vendor-base-ui-CnHfUmDN.js";import{n as r,t as i}from"./platform-B4KKLnZ5.js";import{a,n as o}from"./vendor-aparajita-capacitor-secure-storage-CjQdwfjS.js";import{n as s}from"./vendor-react-DLPElpoQ.js";import{r as c}from"./vendor-pierre-diffs-DX7XTPG3.js";import{n as l}from"./vendor-reactuses-core-DDoDDyM9.js";import{r as u}from"./useMobileNavigationStore-C8_J-qTp.js";import{c as d,l as f}from"./dialog-CgbV5ljg.js";var p=e(n(),1),m=s(),h=`openchamber.iosNativeUi`,g=()=>{if(typeof window>`u`)return!1;try{return window.localStorage.getItem(h)===`1`}catch{return!1}},_=e=>{if(!(typeof window>`u`))try{e?window.localStorage.setItem(h,`1`):window.localStorage.removeItem(h)}catch{}},v=t(e=>({enabled:g(),setEnabled:t=>{_(t),e({enabled:t})}})),y=()=>v.getState().enabled,ee=()=>v(ne),te=()=>r()&&i()===`ios`;function ne(e){return e.enabled}var re=`oc-native-ios-composer`,b=`--oc-native-composer-height`,x=`--oc-native-composer-accessory`,ie=33554432,S=`OpenChamberComposer`,C=`#22c55e`,w=32,T=()=>({open:!1,highlightedIndex:0,rows:[]}),ae=()=>({text:``,placeholder:``,modelLabel:``,modelVariantLabel:``,modelIcon:``,canSend:!1,canAbort:!1,attachmentCount:0,attachmentPreviews:[],citationRanges:[],chipRanges:[],appearance:`dark`,attachAria:``,attachTitle:``,attachPhotosLabel:``,attachFilesLabel:``,attachCancelLabel:``,sendAria:``,queueAria:``,stopAria:``,modelAria:``,agentAria:``,agentLabel:``,agentColor:C,agentIdenticon:Array.from({length:25},()=>0),suppressed:!0,showScrollToBottom:!1,scrollAria:``,autocomplete:T()}),oe=a(S),se=e=>e.isCapacitor&&e.platform===`ios`&&e.pluginAvailable&&e.isMobile&&e.nativeUiEnabled!==!1;function ce(e){return typeof window>`u`?!1:se({isCapacitor:r(),platform:i(),pluginAvailable:o.isPluginAvailable(S),isMobile:e,nativeUiEnabled:y()})}var le=e=>e.classList.contains(`dark`)?`dark`:`light`,ue=e=>{let t=e?.height;return typeof t!=`number`||!Number.isFinite(t)||t<0?0:t},de=(e,t)=>{if(!(t>0)){e.style.removeProperty(b);return}e.style.setProperty(b,`${Math.round(t)}px`)},fe=(e,t)=>{if(!(t>0)){e.style.removeProperty(x);return}e.style.setProperty(x,`${Math.round(t)}px`)},E=(e,t)=>{e.classList.toggle(re,t),t||(e.style.removeProperty(b),e.style.removeProperty(x))},pe=e=>d(e).flat().map(e=>+!!e),D=new Map,O=null,k=e=>{let t=D.get(e);if(t!==void 0)return t;if(typeof document>`u`||typeof getComputedStyle>`u`)return C;!O&&typeof MutationObserver<`u`&&(O=new MutationObserver(()=>{D.clear()}),O.observe(document.documentElement,{attributes:!0,attributeFilter:[`class`,`style`]}));let n=getComputedStyle(document.documentElement).getPropertyValue(e).trim(),r=document.createElement(`span`);r.style.color=n||`var(${e})`,document.documentElement.appendChild(r);let i=getComputedStyle(r).color;r.remove();let a=/rgba?\(\s*([\d.]+)(?:\s*,\s*|\s+)([\d.]+)(?:\s*,\s*|\s+)([\d.]+)/.exec(i);if(!a)return D.set(e,C),C;let o=e=>Math.max(0,Math.min(255,Math.round(Number(e)))).toString(16).padStart(2,`0`),s=`#${o(a[1])}${o(a[2])}${o(a[3])}`;return D.set(e,s),s},me=e=>k(f(e).var),A=(e,t)=>e.text===t.text&&e.placeholder===t.placeholder&&e.modelLabel===t.modelLabel&&e.modelVariantLabel===t.modelVariantLabel&&e.modelIcon===t.modelIcon&&e.canSend===t.canSend&&e.canAbort===t.canAbort&&e.attachmentCount===t.attachmentCount&&M(e.attachmentPreviews,t.attachmentPreviews)&&N(e.citationRanges,t.citationRanges)&&P(e.chipRanges,t.chipRanges)&&e.appearance===t.appearance&&e.attachAria===t.attachAria&&e.attachTitle===t.attachTitle&&e.attachPhotosLabel===t.attachPhotosLabel&&e.attachFilesLabel===t.attachFilesLabel&&e.attachCancelLabel===t.attachCancelLabel&&e.sendAria===t.sendAria&&e.queueAria===t.queueAria&&e.stopAria===t.stopAria&&e.modelAria===t.modelAria&&e.agentAria===t.agentAria&&e.agentLabel===t.agentLabel&&e.agentColor===t.agentColor&&e.agentIdenticon.join(``)===t.agentIdenticon.join(``)&&e.suppressed===t.suppressed&&e.showScrollToBottom===t.showScrollToBottom&&e.scrollAria===t.scrollAria&&j(e.autocomplete,t.autocomplete),j=(e,t)=>e.open===t.open&&e.highlightedIndex===t.highlightedIndex&&e.rows.length===t.rows.length&&e.rows.every((e,n)=>{let r=t.rows[n];return!!(r&&e.id===r.id&&e.title===r.title&&e.subtitle===r.subtitle&&e.badge===r.badge&&e.iconBase64===r.iconBase64)}),M=(e,t)=>e.length===t.length&&e.every((e,n)=>{let r=t[n];return!!(r&&e.id===r.id&&e.filename===r.filename&&e.mime===r.mime&&e.thumbnailBase64===r.thumbnailBase64&&e.removeAria===r.removeAria)}),N=(e,t)=>e.length===t.length&&e.every((e,n)=>e.start===t[n]?.start&&e.end===t[n]?.end),P=(e,t)=>e.length===t.length&&e.every((e,n)=>{let r=t[n];return!!(r&&e.start===r.start&&e.end===r.end&&e.triggerLength===r.triggerLength&&e.color===r.color)}),he=(e,t)=>{if(!e||!t||t.length===0)return[];let n=[],r=0;for(let e of t){let t=r;r+=e.text.length;let i=e.visual;if(!i)continue;let a=i.trigger.length;a<1||t+a>r||i.icon&&n.push({start:t,end:r,triggerLength:a,iconName:i.icon})}return n},ge=(e,t)=>e.map(e=>({start:e.start,end:e.end,triggerLength:e.triggerLength,color:t})),_e=e=>e.map(e=>`${e.id}:${e.filename}:${e.mimeType}:${e.dataUrl?.length??0}`).join(`|`),ve=e=>{let t=e?.id;return typeof t==`string`&&t.trim()?t:``},F=e=>{if(typeof e==`number`&&Number.isFinite(e)&&e>=0)return Math.floor(e);if(typeof e==`string`&&e.trim()){let t=Number(e);if(Number.isFinite(t)&&t>=0)return Math.floor(t)}return null},ye=e=>{let t=F(e?.selectionStart);if(t===null)return null;let n=F(e?.selectionEnd);return{start:t,end:n!==null&&n>=t?n:t}},be=e=>F(e?.index)??0,xe=(e,t)=>{let n=Math.max(0,e);return typeof t!=`number`||!Number.isFinite(t)?n:Math.max(0,Math.min(Math.floor(t),n))},Se=e=>e.nextText===e.nativeOwnedText?{omitText:!0,forceText:!1}:e.nextText.length===0&&e.nativeOwnedText.length>0||e.preset?{omitText:!1,forceText:!0}:e.echoingNative?{omitText:!0,forceText:!1}:{omitText:!1,forceText:!0},Ce=e=>e.replacedText!==null&&e.incoming===e.replacedText,we=e=>setTimeout(e,0),Te=e=>{e.applyDocument(e.text),we(e.submit)},I=(e,t)=>e===t,Ee=(e,t,n,r)=>{if(n.omitText&&e&&A(e,t))return null;let i={};if(n.omitText||(i.text=t.text,n.forceText&&(i.forceText=!0),n.forceText&&typeof r?.caret==`number`&&Number.isFinite(r.caret)&&(i.caret=Math.max(0,Math.floor(r.caret)))),!e){let{text:e,...n}=t;return Object.assign(i,n),i}let a=(n,r)=>{r(e[n],t[n])||(i[n]=t[n])};return a(`placeholder`,I),a(`modelLabel`,I),a(`modelVariantLabel`,I),a(`modelIcon`,I),a(`canSend`,I),a(`canAbort`,I),a(`attachmentCount`,I),a(`attachmentPreviews`,M),a(`citationRanges`,N),a(`chipRanges`,P),a(`appearance`,I),a(`attachAria`,I),a(`attachTitle`,I),a(`attachPhotosLabel`,I),a(`attachFilesLabel`,I),a(`attachCancelLabel`,I),a(`sendAria`,I),a(`queueAria`,I),a(`stopAria`,I),a(`modelAria`,I),a(`agentAria`,I),a(`agentLabel`,I),a(`agentColor`,I),a(`agentIdenticon`,(e,t)=>e.join(``)===t.join(``)),a(`suppressed`,I),a(`showScrollToBottom`,I),a(`scrollAria`,I),a(`autocomplete`,j),Object.keys(i).length===0?null:i},De=e=>{let t=Array.isArray(e?.skipped)?e.skipped:[],n=[];for(let e of t){if(!e||typeof e!=`object`)continue;let t=e.name;typeof t==`string`&&t.trim()&&n.push(t)}return n},Oe=e=>{try{let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}catch{return null}},ke=(e,t=ie)=>{let n=Array.isArray(e?.files)?e.files:[],r=[];for(let e of n){if(!e||typeof e!=`object`)continue;let n=e;if(typeof n.dataBase64!=`string`||n.dataBase64.length===0)continue;let i=Oe(n.dataBase64);if(!i||i.byteLength===0||i.byteLength>t)continue;let a=typeof n.name==`string`&&n.name.trim()?n.name:`file`,o=typeof n.mime==`string`&&n.mime.trim()?n.mime:`application/octet-stream`;r.push(new File([new Uint8Array(i)],a,{type:o}))}return r},L=80,Ae=e=>typeof document>`u`||!e||!e.startsWith(`data:image/`)?Promise.resolve(null):new Promise(t=>{let n=new Image;n.decoding=`async`,n.onload=()=>{try{let e=document.createElement(`canvas`);e.width=L,e.height=L;let r=e.getContext(`2d`);if(!r){t(null);return}r.clearRect(0,0,L,L),r.drawImage(n,0,0,L,L);let i=e.toDataURL(`image/jpeg`,.72),a=i.indexOf(`,`);t(a>=0?i.slice(a+1):null)}catch{t(null)}},n.onerror=()=>t(null),n.src=e}),je=e=>typeof document>`u`||!e?Promise.resolve(null):new Promise(t=>{let n=new Image;n.decoding=`async`,n.onload=()=>{try{let e=document.createElement(`canvas`);e.width=w,e.height=w;let r=e.getContext(`2d`);if(!r){t(null);return}r.clearRect(0,0,w,w),r.drawImage(n,0,0,w,w);let i=e.toDataURL(`image/png`),a=i.indexOf(`,`);t(a>=0?i.slice(a+1):null)}catch{t(null)}},n.onerror=()=>t(null),n.src=e}),R=()=>oe,z=((e=R)=>{let t=0,n=null,r=[],i=null,a=``,o=!1,s=!1,c=()=>{n!==null&&(clearTimeout(n),n=null)},l=(e,...t)=>{let n=i;n&&n[e](...t)},u=async()=>{if(r.length>0)return;let t=e(),n=await Promise.all([t.addListener(`textChanged`,e=>{let t=typeof e.text==`string`?e.text:``;a=t,l(`onText`,t,e.composing===!0,ye(e))}),t.addListener(`send`,e=>{let t=typeof e.text==`string`?e.text:a;a=t,l(`onSend`,t)}),t.addListener(`abort`,()=>{l(`onAbort`)}),t.addListener(`attach`,()=>{l(`onAttach`)}),t.addListener(`filesPicked`,t=>{l(`onFiles`,ke(t),De(t)),e().focus()}),t.addListener(`removeAttachment`,e=>{let t=ve(e);t&&l(`onRemoveAttachment`,t)}),t.addListener(`openModel`,()=>{l(`onOpenModel`)}),t.addListener(`cycleAgent`,()=>{l(`onCycleAgent`)}),t.addListener(`openAgent`,()=>{l(`onOpenAgent`)}),t.addListener(`heightChanged`,e=>{l(`onHeight`,ue(e))}),t.addListener(`scrollToBottom`,()=>{l(`onScrollToBottom`)}),t.addListener(`autocompleteAccept`,e=>{l(`onAutocompleteAccept`,be(e))}),t.addListener(`autocompleteDismiss`,()=>{l(`onAutocompleteDismiss`)})]);if(r.length>0){for(let e of n)e.remove();return}r=n},d=n=>{t>0||(i=null,o=!1,E(n,!1),e().dismiss())};return{bind(e){i=e},rememberText(e){a=e},rememberState(e){a=e.text},conceal(){o||t===0||(o=!0,e().hide())},reveal(){!o||t===0||(o=!1,e().show())},async warm(){s||t>0||(s=!0,await e().present(ae()))},async retain(n,i){c(),t+=1,o=!1,s=!0,a=i.text,E(n,!0),r.length===0&&await u(),await e().present(i)},release(e){t=Math.max(0,t-1),!(t>0)&&(c(),n=setTimeout(()=>{n=null,d(e)},0))},shutdown(n=document.documentElement){c(),t=0,s=!1,o=!1,i=null,E(n,!1),e().dismiss()},snapshot(){return{retainCount:t,listenerCount:r.length,hidePending:n!==null,concealed:o,warmed:s}}}})(),Me=()=>a(`OpenChamberNavigation`),B=e=>e?.kind===`chat`||e?.kind===`draft`,V=e=>e?e.kind===`draft`||e.kind===`chat`&&e.routes.length<=1:!1,Ne=(e,t)=>B(e)&&!B(t),Pe=(e=z)=>{V(u.getState().secondary)&&e.conceal()},Fe=(e=z)=>{let t=u.subscribe((t,n)=>{Ne(n.secondary,t.secondary)&&e.conceal()}),n=[],r=!1;return o.getPlatform()===`ios`&&(async()=>{let t=Me(),i=await t.addListener(`backStarted`,()=>{V(u.getState().secondary)&&e.conceal()}),a=await t.addListener(`backCancelled`,()=>{e.reveal()});if(r){i.remove(),a.remove();return}n=[i,a]})(),()=>{r=!0,t();for(let e of n)e.remove();n=[]}},H=`__openchamberMobileBackRoute`,Ie=()=>typeof window>`u`||r()?null:{currentState:()=>window.history.state&&typeof window.history.state==`object`?window.history.state:null,pushState:e=>window.history.pushState(e,``,window.location.href),back:()=>window.history.back(),subscribe:e=>{let t=t=>e(t.state&&typeof t.state==`object`?t.state:null);return window.addEventListener(`popstate`,t),()=>window.removeEventListener(`popstate`,t)}},U=e=>{let t=e?.[H];return typeof t==`number`&&Number.isFinite(t)?t:null},W=new class{routes=[];listeners=new Set;nextToken=1;history;removeHistoryListener=null;programmaticHistoryBackToken=null;pendingHistoryRemovals=new Map;animatedBackDriver=null;presentationCancelDriver=null;constructor(e=Ie()){this.history=e}subscribe=e=>(this.listeners.add(e),()=>this.listeners.delete(e));getTopRoute=()=>this.routes.at(-1)??null;register=e=>{let t=this.pendingHistoryRemovals.get(e.id);this.pendingHistoryRemovals.delete(e.id);let n=!!(this.history&&t!==void 0&&U(this.history.currentState())===t),r={...e,token:n&&t!==void 0?t:this.nextToken++};this.routes.push(r),this.ensureHistoryListener(),this.history&&!n&&this.history.pushState({...this.history.currentState()??{},[H]:r.token}),this.notify();let i=!0;return()=>{if(!i)return;i=!1;let e=this.routes.indexOf(r);e<0||(this.routes.splice(e,1),this.history&&U(this.history.currentState())===r.token?(this.pendingHistoryRemovals.set(r.id,r.token),queueMicrotask(()=>{if(this.pendingHistoryRemovals.get(r.id)===r.token){if(this.pendingHistoryRemovals.delete(r.id),!this.history||U(this.history.currentState())!==r.token){this.routes.length===0&&this.pendingHistoryRemovals.size===0&&this.disposeHistoryListener();return}this.programmaticHistoryBackToken=r.token,this.history.back(),this.routes.length===0&&this.pendingHistoryRemovals.size===0&&this.disposeHistoryListener()}})):this.routes.length===0&&this.pendingHistoryRemovals.size===0&&this.disposeHistoryListener(),this.notify())}};backImmediately=e=>{let t=this.getTopRoute();return!t||e&&t.layer!==e?!1:t.onBack()!==!1};requestAnimatedBack=e=>{let t=this.getTopRoute();return!t||e&&t.layer!==e?!1:this.animatedBackDriver?.(t)?!0:this.backImmediately(e)};setAnimatedBackDriver=e=>(this.animatedBackDriver=e,()=>{this.animatedBackDriver===e&&(this.animatedBackDriver=null)});setPresentationCancelDriver=e=>(this.presentationCancelDriver=e,()=>{this.presentationCancelDriver===e&&(this.presentationCancelDriver=null)});cancelPresentation=()=>{this.presentationCancelDriver?.()};requestBrowserBack=()=>{let e=this.getTopRoute();return e?this.history&&U(this.history.currentState())===e.token?(this.history.back(),!0):e.onBack()!==!1:!1};ensureHistoryListener(){!this.history||this.removeHistoryListener||(this.removeHistoryListener=this.history.subscribe(e=>{if(this.programmaticHistoryBackToken!==null){this.programmaticHistoryBackToken=null;return}let t=this.getTopRoute();t&&U(e)!==t.token&&t.onBack()===!1&&this.history&&this.history.pushState({...this.history.currentState()??{},[H]:t.token})}))}disposeHistoryListener(){this.removeHistoryListener?.(),this.removeHistoryListener=null,this.programmaticHistoryBackToken=null,this.pendingHistoryRemovals.clear()}notify(){this.listeners.forEach(e=>e())}},Le=e=>{let t=(0,m.c)(8),{id:n,active:r,layer:i,onBack:a,surfaceRef:o,underlayRef:s}=e,c=i===void 0?`root`:i,u=l(a),d,f;t[0]!==r||t[1]!==u||t[2]!==n||t[3]!==c||t[4]!==o||t[5]!==s?(d=()=>{if(r)return W.register({id:n,layer:c,onBack:u,getSurface:()=>o.current,getUnderlay:()=>s?.current??null})},f=[r,u,n,c,o,s],t[0]=r,t[1]=u,t[2]=n,t[3]=c,t[4]=o,t[5]=s,t[6]=d,t[7]=f):(d=t[6],f=t[7]),p.useEffect(d,f)},G=a(`OpenChamberNavigation`),K=e=>Math.min(1,Math.max(0,Number.isFinite(e)?e:0)),Re=(e,t)=>!e||!t?!1:e.onBack()!==!1,q=e=>{let t=K(e.progress),n=e.commit?1-t:t;if(n<=.001)return 0;let r=Math.max(1,e.viewportWidth??390),i=Math.abs(e.velocityX??0)/r,a=n/Math.max(e.commit?2.4:2.8,i)*1e3,o=e.commit?90:100,s=e.commit?320:260;return Math.round(Math.min(s,Math.max(o,a)))},J=e=>{let{surface:t,underlay:n,surfaceTransition:r,surfaceAnimation:i,underlayTransition:a,underlayAnimation:o}=e;t.style.removeProperty(`transform`),t.style.removeProperty(`opacity`),t.style.removeProperty(`will-change`),t.style.removeProperty(`box-shadow`),t.style.transition=r,t.style.animation=i,n&&(n.style.removeProperty(`transform`),n.style.removeProperty(`opacity`),n.style.removeProperty(`will-change`),n.style.transition=a??``,n.style.animation=o??``)},Y=(e,t)=>{let n=K(t),{surface:r}=e;r.style.transform=`translate3d(${n*100}%, 0, 0)`},ze=e=>!e.surfaceConnected||e.topRouteToken!==e.routeToken||e.routeSurface!==e.outgoingSurface,Be=async(e,t,n,r)=>{if(!r&&typeof e.animate==`function`){let r=e.style.transform||`translate3d(0%, 0, 0)`,i=`translate3d(${t}%, 0, 0)`,a=e.animate([{transform:r},{transform:i}],{duration:n,easing:`cubic-bezier(0.22, 1, 0.36, 1)`,fill:`forwards`}),o=!1;try{await a.finished,o=!0}catch{}finally{o&&(e.style.transform=i),a.cancel()}return}e.style.transform=`translate3d(${t}%, 0, 0)`},Ve=async(e,t,n=typeof window<`u`&&window.matchMedia?.(`(prefers-reduced-motion: reduce)`).matches,r=q({progress:Number.parseFloat(e.style.transform.match(/translate3d\(([-\d.]+)%/)?.[1]??`0`)/100,commit:t}))=>Be(e,t?100:0,r,n),He=class{pending=0;enqueue(){this.pending+=1}take(){return this.pending!==0&&(--this.pending,!0)}clear(){this.pending=0}},Ue=e=>{let t=(0,m.c)(4),{enabled:n,rootRoutesBlocked:i}=e,a,s;t[0]!==n||t[1]!==i?(a=()=>{if(!n||!r()||o.getPlatform()===`web`)return;let e=!1,t=null,a=null,s=0,c=0,l=0,u=new He,d=[],f=e=>!!e&&(!i||e?.layer===`overlay`),p=()=>{let e=f(W.getTopRoute());G.setEnabled({enabled:e}).catch(We)},m=()=>{if(W.cancelPresentation(),a)return;let e=W.getTopRoute();if(!f(e))return;let n=e.getSurface();if(!n)return;n.getAnimations().forEach(Ge),a=null;let r=e.layer===`root`?e.getUnderlay():null,i=n.style.transition,o=n.style.animation,s=r?.style.transition??null,c=r?.style.animation??null;r?.getAnimations().forEach(Ke),n.style.transition=`none`,n.style.animation=`none`,n.style.willChange=`transform`,r&&(r.style.removeProperty(`transform`),r.style.removeProperty(`will-change`)),l+=1,t={route:e,surface:n,underlay:r,surfaceTransition:i,surfaceAnimation:o,underlayTransition:s,underlayAnimation:c},Y(t,0)},h=e=>{c=K(e),!s&&(s=window.requestAnimationFrame(()=>{s=0,t&&Y(t,c)}))},g=qe,_=(n,r,i)=>{if(n&&Pe(),a)return n&&f(W.getTopRoute())?(u.enqueue(),!0):!1;s&&=(window.cancelAnimationFrame(s),0),t||m(),t&&r!==void 0&&Y(t,r);let o=t,d=l;if(t=null,!o){if(!n)return!1;let e=W.getTopRoute();return Re(e,f(e))}a=o;let p=window.matchMedia?.(`(prefers-reduced-motion: reduce)`).matches??!1,h=q({progress:K(r??c),commit:n,velocityX:i,viewportWidth:window.innerWidth});return Ve(o.surface,n,p,h).then(async()=>{d===l&&(!e&&n&&(o.route.onBack(),await g(o)),d===l&&(J(o),a===o&&(a=null),!e&&u.take()&&_(!0,0,0)))}),!0},v=W.setAnimatedBackDriver(e=>e!==W.getTopRoute()||!f(e)?!1:_(!0,0,0)),y=W.subscribe(p);return(async()=>{let t=await G.addListener(`backStarted`,m),n=await G.addListener(`backProgressed`,e=>h(e.progress??0)),r=await G.addListener(`backCancelled`,e=>_(!1,e.progress,e.velocityX)),i=await G.addListener(`backInvoked`,e=>_(!0,e.progress,e.velocityX));if(e){await Promise.all([t.remove(),n.remove(),r.remove(),i.remove()]);return}d.push(t,n,r,i),p()})().catch(Je),p(),()=>{e=!0,l+=1,u.clear(),y(),v(),s&&window.cancelAnimationFrame(s),t&&J(t),a&&(a.surface.getAnimations().forEach(Ye),a.underlay?.getAnimations().forEach(Xe),J(a)),t=null,a=null,G.setEnabled({enabled:!1}).catch(Ze),d.forEach(Qe)}},s=[n,i],t[0]=n,t[1]=i,t[2]=a,t[3]=s):(a=t[2],s=t[3]),p.useEffect(a,s)};function We(){}function Ge(e){return e.cancel()}function Ke(e){return e.cancel()}function qe(e){return new Promise(t=>{let n=0,r=12,i=!1,a=()=>{i||(i=!0,c(),n&&window.cancelAnimationFrame(n),t())},o=()=>{let t=W.getTopRoute();return ze({surfaceConnected:e.surface.isConnected,routeToken:e.route.token,topRouteToken:t?.token??null,routeSurface:e.route.getSurface(),outgoingSurface:e.surface})},s=()=>{if(o()||r<=0){a();return}--r,n=window.requestAnimationFrame(s)},c=W.subscribe(()=>{o()&&a()});s()})}function Je(){}function Ye(e){return e.cancel()}function Xe(e){return e.cancel()}function Ze(){}function Qe(e){e.remove()}var $e=e=>/^#[0-9a-fA-F]{6}$/.test(e),et=e=>/^#[0-9a-fA-F]{8}$/.test(e),tt=(e,t)=>/^[0-9a-fA-F]{2}$/.test(t)?$e(e)?`${e}${t}`:et(e)?`${e.slice(0,7)}${t}`:e:e,X=(e,t)=>typeof e==`string`&&e.trim().length>0?e:t,nt=e=>{let t=e.colors.syntax.base,n=e.colors.syntax.tokens??{},r=(e,t)=>X(n[e],t);return[{name:`plain`,scope:[`source`,`support.type.property-name.css`],settings:{foreground:t.foreground}},{name:`classes`,scope:[`entity.name.type.class`],settings:{foreground:r(`className`,r(`class`,t.function))}},{name:`interfaces`,scope:[`entity.name.type.interface`,`entity.name.type`],settings:{foreground:r(`interface`,t.type)}},{name:`structs`,scope:[`entity.name.type.struct`],settings:{foreground:r(`struct`,t.function)}},{name:`enums`,scope:[`entity.name.type.enum`],settings:{foreground:r(`enum`,t.function)}},{name:`keys`,scope:[`meta.object-literal.key`,`support.type.property-name`],settings:{foreground:r(`key`,t.function)}},{name:`methods`,scope:[`entity.name.function.method`,`meta.function.method`],settings:{foreground:r(`method`,e.colors.status.success)}},{name:`functions`,scope:[`entity.name.function`,`support.function`,`meta.function-call.generic`],settings:{foreground:t.function,fontStyle:`bold`}},{name:`variables`,scope:[`variable`,`meta.variable`,`variable.other.object.property`],settings:{foreground:t.variable}},{name:`variablesOther`,scope:[`variable.other.object`,`variable.other.readwrite.alias`],settings:{foreground:r(`variableOther`,r(`method`,e.colors.status.success))}},{name:`globalVariables`,scope:[`variable.other.global`,`variable.language.this`],settings:{foreground:r(`variableGlobal`,t.number)}},{name:`localVariables`,scope:[`variable.other.local`],settings:{foreground:r(`variableLocal`,e.colors.surface.elevated)}},{name:`parameters`,scope:[`variable.parameter`,`meta.parameter`],settings:{foreground:r(`parameter`,t.foreground)}},{name:`properties`,scope:[`variable.other.property`,`meta.property`],settings:{foreground:r(`variableProperty`,e.colors.status.info)}},{name:`strings`,scope:[`string`,`string.other.link`,`markup.inline.raw.string.markdown`],settings:{foreground:t.string}},{name:`stringEscapeSequences`,scope:[`constant.character.escape`,`constant.other.placeholder`],settings:{foreground:r(`stringEscape`,t.foreground)}},{name:`keywords`,scope:[`keyword`],settings:{foreground:t.keyword}},{name:`keywordsControl`,scope:[`keyword.control.import`,`keyword.control.from`,`keyword.import`],settings:{foreground:r(`keywordImport`,t.operator)}},{name:`storageModifiers`,scope:[`storage.modifier`,`keyword.modifier`,`storage.type`],settings:{foreground:r(`storageModifier`,t.keyword)}},{name:`comments`,scope:[`comment`,`punctuation.definition.comment`],settings:{foreground:t.comment}},{name:`docComments`,scope:[`comment.documentation`,`comment.line.documentation`],settings:{foreground:r(`commentDoc`,e.colors.surface.mutedForeground)}},{name:`numbers`,scope:[`constant.numeric`],settings:{foreground:t.number}},{name:`booleans`,scope:[`constant.language`],settings:{foreground:r(`boolean`,t.type)}},{name:`operators`,scope:[`keyword.operator`],settings:{foreground:t.operator}},{name:`macros`,scope:[`entity.name.function.preprocessor`,`meta.preprocessor`],settings:{foreground:r(`macro`,t.keyword)}},{name:`preprocessor`,scope:[`meta.preprocessor`],settings:{foreground:r(`preprocessor`,r(`label`,t.number))}},{name:`urls`,scope:[`markup.underline.link`],settings:{foreground:r(`url`,e.colors.status.info)}},{name:`tags`,scope:[`entity.name.tag`],settings:{foreground:r(`tag`,t.keyword)}},{name:`jsxTags`,scope:[`support.class.component`],settings:{foreground:r(`jsxTag`,r(`label`,t.number))}},{name:`attributes`,scope:[`entity.other.attribute-name`,`meta.attribute`],settings:{foreground:r(`tagAttribute`,t.type)}},{name:`types`,scope:[`support.type`],settings:{foreground:t.type}},{name:`constants`,scope:[`variable.other.constant`,`variable.readonly`],settings:{foreground:r(`constant`,t.foreground)}},{name:`labels`,scope:[`entity.name.label`,`punctuation.definition.label`],settings:{foreground:r(`label`,r(`variableGlobal`,t.number))}},{name:`namespaces`,scope:[`entity.name.namespace`,`storage.modifier.namespace`,`markup.bold.markdown`],settings:{foreground:r(`namespace`,t.type)}},{name:`modules`,scope:[`entity.name.module`,`storage.modifier.module`],settings:{foreground:r(`module`,t.operator)}},{name:`typeParameters`,scope:[`variable.type.parameter`,`variable.parameter.type`],settings:{foreground:r(`typeParameter`,t.function)}},{name:`exceptions`,scope:[`keyword.control.exception`,`keyword.control.trycatch`],settings:{foreground:r(`exception`,r(`label`,t.number))}},{name:`decorators`,scope:[`meta.decorator`,`punctuation.decorator`,`entity.name.function.decorator`],settings:{foreground:r(`decorator`,t.type)}},{name:`calls`,scope:[`variable.function`],settings:{foreground:t.foreground}},{name:`punctuation`,scope:[`punctuation`,`punctuation.terminator`,`punctuation.definition.tag`,`punctuation.separator`,`punctuation.definition.string`,`punctuation.section.block`],settings:{foreground:r(`punctuation`,t.comment)}},{name:`yellow`,scope:[`storage.type.numeric.go`,`storage.type.byte.go`,`storage.type.boolean.go`,`storage.type.string.go`,`storage.type.uintptr.go`,`storage.type.error.go`,`storage.type.rune.go`,`constant.language.go`,`support.class.dart`,`keyword.other.documentation`,`storage.modifier.import.java`,`punctuation.definition.list.begin.markdown`,`punctuation.definition.quote.begin.markdown`,`meta.separator.markdown`,`entity.name.section.markdown`],settings:{foreground:t.type}},{name:`green`,scope:[],settings:{foreground:r(`method`,e.colors.status.success)}},{name:`cyan`,scope:[`markup.italic.markdown`,`support.type.python`,`variable.legacy.builtin.python`,`support.constant.property-value.css`,`storage.modifier.attribute.swift`],settings:{foreground:t.string}},{name:`blue`,scope:[],settings:{foreground:t.keyword}},{name:`purple`,scope:[`keyword.channel.go`,`keyword.other.platform.os.swift`],settings:{foreground:t.number}},{name:`magenta`,scope:[`punctuation.definition.heading.markdown`],settings:{foreground:r(`label`,r(`variableGlobal`,t.number))}},{name:`red`,scope:[],settings:{foreground:t.operator}},{name:`orange`,scope:[],settings:{foreground:t.function}}]},rt=e=>{let t=e.colors.surface,n=e.colors.interactive,r=e.colors.status,i=e.colors.syntax.base,a=e.colors.syntax.highlights??{},o=X(a.diffAddedBackground,r.successBackground),s=X(a.diffRemovedBackground,r.errorBackground);return{"editor.background":t.background,"editor.foreground":t.foreground,"editor.hoverHighlightBackground":X(n.hover,t.subtle),"editor.lineHighlightBackground":t.muted,"editor.selectionBackground":n.selection,"editor.selectionHighlightBackground":n.selection,"editor.findMatchBackground":i.type,"editor.findMatchHighlightBackground":tt(i.type,`cc`),"editor.findRangeHighlightBackground":t.muted,"editor.inactiveSelectionBackground":t.elevated,"editor.lineHighlightBorder":t.elevated,"editor.rangeHighlightBackground":X(n.active,n.borderHover),"notifications.background":t.elevated,"editorInlayHint.typeBackground":t.subtle,"editorInlayHint.typeForeground":t.foreground,"editorWhitespace.foreground":n.borderHover,"editorIndentGuide.background1":t.subtle,"editorHoverWidget.background":t.elevated,"editorLineNumber.activeForeground":X(a.lineNumberActive,t.foreground),"editorLineNumber.foreground":X(a.lineNumber,t.mutedForeground),"editorGutter.background":t.background,"editorGutter.modifiedBackground":r.info,"editorGutter.addedBackground":r.success,"editorGutter.deletedBackground":r.error,"editorBracketMatch.background":t.elevated,"editorBracketMatch.border":t.subtle,"editorError.foreground":r.error,"editorWarning.foreground":r.warning,"editorInfo.foreground":r.info,"diffEditor.insertedTextBackground":o,"diffEditor.removedTextBackground":s,"editorGroupHeader.tabsBackground":t.background,"editorGroup.border":n.border,"tab.activeBackground":t.background,"tab.inactiveBackground":t.muted,"tab.inactiveForeground":t.mutedForeground,"tab.activeForeground":t.foreground,"tab.hoverBackground":t.subtle,"tab.unfocusedHoverBackground":t.subtle,"tab.border":n.border,"tab.activeModifiedBorder":i.type,"tab.inactiveModifiedBorder":r.info,"tab.unfocusedActiveModifiedBorder":i.type,"tab.unfocusedInactiveModifiedBorder":r.info,"editorWidget.background":t.muted,"editorWidget.border":n.border,"editorSuggestWidget.background":t.background,"editorSuggestWidget.border":n.border,"editorSuggestWidget.foreground":t.foreground,"editorSuggestWidget.highlightForeground":t.mutedForeground,"editorSuggestWidget.selectedBackground":t.subtle,"peekView.border":n.border,"peekViewEditor.background":t.background,"peekViewEditor.matchHighlightBackground":t.subtle,"peekViewResult.background":t.muted,"peekViewResult.fileForeground":t.foreground,"peekViewResult.lineForeground":t.mutedForeground,"peekViewResult.matchHighlightBackground":t.subtle,"peekViewResult.selectionBackground":t.elevated,"peekViewResult.selectionForeground":t.mutedForeground,"peekViewTitle.background":t.subtle,"peekViewTitleDescription.foreground":t.mutedForeground,"peekViewTitleLabel.foreground":t.foreground,"merge.currentHeaderBackground":r.success,"merge.currentContentBackground":X(a.diffAdded,r.success),"merge.incomingHeaderBackground":r.info,"merge.incomingContentBackground":X(a.diffModified,r.info),"merge.border":n.border,"merge.commonContentBackground":t.subtle,"merge.commonHeaderBackground":t.muted,"panel.background":t.background,"panel.border":n.border,"panelTitle.activeBorder":n.borderHover,"panelTitle.activeForeground":t.foreground,"panelTitle.inactiveForeground":t.mutedForeground,"statusBar.background":t.background,"statusBar.foreground":t.foreground,"statusBar.border":n.border,"statusBar.debuggingBackground":r.error,"statusBar.debuggingForeground":r.errorForeground,"statusBar.noFolderBackground":t.subtle,"statusBar.noFolderForeground":t.mutedForeground,"titleBar.activeBackground":t.background,"titleBar.activeForeground":t.foreground,"titleBar.inactiveBackground":t.muted,"titleBar.inactiveForeground":t.mutedForeground,"titleBar.border":n.border,"menu.foreground":t.foreground,"menu.background":t.background,"menu.selectionForeground":t.foreground,"menu.selectionBackground":t.subtle,"menu.border":n.border,"editorInlayHint.foreground":t.mutedForeground,"editorInlayHint.background":t.subtle,"terminal.foreground":t.foreground,"terminal.background":t.background,"terminalCursor.foreground":t.foreground,"terminalCursor.background":t.background,"terminal.ansiRed":X(a.diffRemoved,r.error),"terminal.ansiGreen":X(a.diffAdded,r.success),"terminal.ansiYellow":r.warning,"terminal.ansiBlue":X(a.diffModified,r.info),"terminal.ansiMagenta":i.keyword,"terminal.ansiCyan":i.type,"activityBar.background":t.background,"activityBar.foreground":t.foreground,"activityBar.inactiveForeground":t.mutedForeground,"activityBar.activeBorder":t.foreground,"activityBar.border":n.border,"sideBar.background":t.background,"sideBar.foreground":t.foreground,"sideBar.border":n.border,"sideBarTitle.foreground":t.foreground,"sideBarSectionHeader.background":t.muted,"sideBarSectionHeader.foreground":t.foreground,"sideBarSectionHeader.border":n.border,"sideBar.activeBackground":t.subtle,"sideBar.activeForeground":t.foreground,"sideBar.hoverBackground":t.muted,"sideBar.hoverForeground":t.foreground,"list.warningForeground":r.warning,"list.errorForeground":r.error,"list.inactiveSelectionBackground":t.subtle,"list.activeSelectionBackground":t.elevated,"list.inactiveSelectionForeground":t.foreground,"list.activeSelectionForeground":t.foreground,"list.hoverForeground":t.foreground,"list.hoverBackground":t.muted,"input.background":t.muted,"input.foreground":t.foreground,"input.border":n.border,"input.placeholderForeground":t.mutedForeground,"inputOption.activeBorder":n.border,"inputOption.activeBackground":t.elevated,"inputOption.activeForeground":t.foreground,"inputValidation.infoBackground":r.infoBackground,"inputValidation.infoBorder":r.infoBorder,"inputValidation.warningBackground":r.warningBackground,"inputValidation.warningBorder":r.warningBorder,"inputValidation.errorBackground":r.errorBackground,"inputValidation.errorBorder":r.errorBorder,"dropdown.background":t.muted,"dropdown.foreground":t.foreground,"dropdown.border":n.border,"dropdown.listBackground":t.background,"badge.background":e.colors.primary.base,"activityBarBadge.background":e.colors.primary.base,"button.background":e.colors.primary.base,"button.foreground":X(e.colors.primary.foreground,t.background),"badge.foreground":X(e.colors.primary.foreground,t.background),"activityBarBadge.foreground":X(e.colors.primary.foreground,t.background)}};function it(e){return{name:e.metadata.name,type:e.metadata.variant,colors:rt(e),tokenColors:nt(e)}}var at=e=>/^#[0-9a-fA-F]{8}$/.test(e),Z=e=>at(e)?e.slice(0,7):e;function ot(e,t){return Object.defineProperty(e,"toString",{value:()=>t,enumerable:!1,configurable:!0}),Object.defineProperty(e,Symbol.toPrimitive,{value:()=>t,enumerable:!1,configurable:!0}),e}var Q=new Map,$=new Set,st=(e,t)=>{let n=e.colors?.[`editor.background`],r=e.colors?.[`editor.foreground`],i=n?Z(n):void 0,a=r?Z(r):void 0;if(!i||!a)throw Error(`Theme "${t}" is missing editor.background/editor.foreground`);let o=e.tokenColors??[];return ot({...e,name:t,fg:a,bg:i,settings:o},t)},ct=e=>it(e),lt=e=>{let t=Q.get(e.metadata.id);if(t)return t;let n=st(ct(e),e.metadata.id);return Q.set(e.metadata.id,n),n},ut=e=>{let t=e.metadata.id;if($.has(t))return;let n=lt(e);c(t,async()=>n),$.add(t)};export{te as A,Ae as C,Se as D,k as E,ee as M,v as N,E as O,pe as S,xe as T,j as _,Ue as a,me as b,fe as c,ge as d,Ee as f,Te as g,R as h,Le as i,y as j,Ce as k,de as l,T as m,lt as n,Fe as o,ce as p,W as r,z as s,ut as t,_e as u,he as v,je as w,le as x,A as y};
1
+ import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{a as t}from"./vendor-zustand-B4dlGEM2.js";import{rt as n}from"./vendor-base-ui-CnHfUmDN.js";import{n as r,t as i}from"./platform-DzsGqlGW.js";import{a,n as o}from"./vendor-aparajita-capacitor-secure-storage-CjQdwfjS.js";import{n as s}from"./vendor-react-DLPElpoQ.js";import{r as c}from"./vendor-pierre-diffs-DX7XTPG3.js";import{n as l}from"./vendor-reactuses-core-DDoDDyM9.js";import{r as u}from"./useMobileNavigationStore-C1NJGAik.js";import{c as d,l as f}from"./dialog-BwQ3rY_x.js";var p=e(n(),1),m=s(),h=`openchamber.iosNativeUi`,g=()=>{if(typeof window>`u`)return!1;try{return window.localStorage.getItem(h)===`1`}catch{return!1}},_=e=>{if(!(typeof window>`u`))try{e?window.localStorage.setItem(h,`1`):window.localStorage.removeItem(h)}catch{}},v=t(e=>({enabled:g(),setEnabled:t=>{_(t),e({enabled:t})}})),y=()=>v.getState().enabled,ee=()=>v(ne),te=()=>r()&&i()===`ios`;function ne(e){return e.enabled}var re=`oc-native-ios-composer`,b=`--oc-native-composer-height`,x=`--oc-native-composer-accessory`,ie=33554432,S=`OpenChamberComposer`,C=`#22c55e`,w=32,T=()=>({open:!1,highlightedIndex:0,rows:[]}),ae=()=>({text:``,placeholder:``,modelLabel:``,modelVariantLabel:``,modelIcon:``,canSend:!1,canAbort:!1,attachmentCount:0,attachmentPreviews:[],citationRanges:[],chipRanges:[],appearance:`dark`,attachAria:``,attachTitle:``,attachPhotosLabel:``,attachFilesLabel:``,attachCancelLabel:``,sendAria:``,queueAria:``,stopAria:``,modelAria:``,agentAria:``,agentLabel:``,agentColor:C,agentIdenticon:Array.from({length:25},()=>0),suppressed:!0,showScrollToBottom:!1,scrollAria:``,autocomplete:T()}),oe=a(S),se=e=>e.isCapacitor&&e.platform===`ios`&&e.pluginAvailable&&e.isMobile&&e.nativeUiEnabled!==!1;function ce(e){return typeof window>`u`?!1:se({isCapacitor:r(),platform:i(),pluginAvailable:o.isPluginAvailable(S),isMobile:e,nativeUiEnabled:y()})}var le=e=>e.classList.contains(`dark`)?`dark`:`light`,ue=e=>{let t=e?.height;return typeof t!=`number`||!Number.isFinite(t)||t<0?0:t},de=(e,t)=>{if(!(t>0)){e.style.removeProperty(b);return}e.style.setProperty(b,`${Math.round(t)}px`)},fe=(e,t)=>{if(!(t>0)){e.style.removeProperty(x);return}e.style.setProperty(x,`${Math.round(t)}px`)},E=(e,t)=>{e.classList.toggle(re,t),t||(e.style.removeProperty(b),e.style.removeProperty(x))},pe=e=>d(e).flat().map(e=>+!!e),D=new Map,O=null,k=e=>{let t=D.get(e);if(t!==void 0)return t;if(typeof document>`u`||typeof getComputedStyle>`u`)return C;!O&&typeof MutationObserver<`u`&&(O=new MutationObserver(()=>{D.clear()}),O.observe(document.documentElement,{attributes:!0,attributeFilter:[`class`,`style`]}));let n=getComputedStyle(document.documentElement).getPropertyValue(e).trim(),r=document.createElement(`span`);r.style.color=n||`var(${e})`,document.documentElement.appendChild(r);let i=getComputedStyle(r).color;r.remove();let a=/rgba?\(\s*([\d.]+)(?:\s*,\s*|\s+)([\d.]+)(?:\s*,\s*|\s+)([\d.]+)/.exec(i);if(!a)return D.set(e,C),C;let o=e=>Math.max(0,Math.min(255,Math.round(Number(e)))).toString(16).padStart(2,`0`),s=`#${o(a[1])}${o(a[2])}${o(a[3])}`;return D.set(e,s),s},me=e=>k(f(e).var),A=(e,t)=>e.text===t.text&&e.placeholder===t.placeholder&&e.modelLabel===t.modelLabel&&e.modelVariantLabel===t.modelVariantLabel&&e.modelIcon===t.modelIcon&&e.canSend===t.canSend&&e.canAbort===t.canAbort&&e.attachmentCount===t.attachmentCount&&M(e.attachmentPreviews,t.attachmentPreviews)&&N(e.citationRanges,t.citationRanges)&&P(e.chipRanges,t.chipRanges)&&e.appearance===t.appearance&&e.attachAria===t.attachAria&&e.attachTitle===t.attachTitle&&e.attachPhotosLabel===t.attachPhotosLabel&&e.attachFilesLabel===t.attachFilesLabel&&e.attachCancelLabel===t.attachCancelLabel&&e.sendAria===t.sendAria&&e.queueAria===t.queueAria&&e.stopAria===t.stopAria&&e.modelAria===t.modelAria&&e.agentAria===t.agentAria&&e.agentLabel===t.agentLabel&&e.agentColor===t.agentColor&&e.agentIdenticon.join(``)===t.agentIdenticon.join(``)&&e.suppressed===t.suppressed&&e.showScrollToBottom===t.showScrollToBottom&&e.scrollAria===t.scrollAria&&j(e.autocomplete,t.autocomplete),j=(e,t)=>e.open===t.open&&e.highlightedIndex===t.highlightedIndex&&e.rows.length===t.rows.length&&e.rows.every((e,n)=>{let r=t.rows[n];return!!(r&&e.id===r.id&&e.title===r.title&&e.subtitle===r.subtitle&&e.badge===r.badge&&e.iconBase64===r.iconBase64)}),M=(e,t)=>e.length===t.length&&e.every((e,n)=>{let r=t[n];return!!(r&&e.id===r.id&&e.filename===r.filename&&e.mime===r.mime&&e.thumbnailBase64===r.thumbnailBase64&&e.removeAria===r.removeAria)}),N=(e,t)=>e.length===t.length&&e.every((e,n)=>e.start===t[n]?.start&&e.end===t[n]?.end),P=(e,t)=>e.length===t.length&&e.every((e,n)=>{let r=t[n];return!!(r&&e.start===r.start&&e.end===r.end&&e.triggerLength===r.triggerLength&&e.color===r.color)}),he=(e,t)=>{if(!e||!t||t.length===0)return[];let n=[],r=0;for(let e of t){let t=r;r+=e.text.length;let i=e.visual;if(!i)continue;let a=i.trigger.length;a<1||t+a>r||i.icon&&n.push({start:t,end:r,triggerLength:a,iconName:i.icon})}return n},ge=(e,t)=>e.map(e=>({start:e.start,end:e.end,triggerLength:e.triggerLength,color:t})),_e=e=>e.map(e=>`${e.id}:${e.filename}:${e.mimeType}:${e.dataUrl?.length??0}`).join(`|`),ve=e=>{let t=e?.id;return typeof t==`string`&&t.trim()?t:``},F=e=>{if(typeof e==`number`&&Number.isFinite(e)&&e>=0)return Math.floor(e);if(typeof e==`string`&&e.trim()){let t=Number(e);if(Number.isFinite(t)&&t>=0)return Math.floor(t)}return null},ye=e=>{let t=F(e?.selectionStart);if(t===null)return null;let n=F(e?.selectionEnd);return{start:t,end:n!==null&&n>=t?n:t}},be=e=>F(e?.index)??0,xe=(e,t)=>{let n=Math.max(0,e);return typeof t!=`number`||!Number.isFinite(t)?n:Math.max(0,Math.min(Math.floor(t),n))},Se=e=>e.nextText===e.nativeOwnedText?{omitText:!0,forceText:!1}:e.nextText.length===0&&e.nativeOwnedText.length>0||e.preset?{omitText:!1,forceText:!0}:e.echoingNative?{omitText:!0,forceText:!1}:{omitText:!1,forceText:!0},Ce=e=>e.replacedText!==null&&e.incoming===e.replacedText,we=e=>setTimeout(e,0),Te=e=>{e.applyDocument(e.text),we(e.submit)},I=(e,t)=>e===t,Ee=(e,t,n,r)=>{if(n.omitText&&e&&A(e,t))return null;let i={};if(n.omitText||(i.text=t.text,n.forceText&&(i.forceText=!0),n.forceText&&typeof r?.caret==`number`&&Number.isFinite(r.caret)&&(i.caret=Math.max(0,Math.floor(r.caret)))),!e){let{text:e,...n}=t;return Object.assign(i,n),i}let a=(n,r)=>{r(e[n],t[n])||(i[n]=t[n])};return a(`placeholder`,I),a(`modelLabel`,I),a(`modelVariantLabel`,I),a(`modelIcon`,I),a(`canSend`,I),a(`canAbort`,I),a(`attachmentCount`,I),a(`attachmentPreviews`,M),a(`citationRanges`,N),a(`chipRanges`,P),a(`appearance`,I),a(`attachAria`,I),a(`attachTitle`,I),a(`attachPhotosLabel`,I),a(`attachFilesLabel`,I),a(`attachCancelLabel`,I),a(`sendAria`,I),a(`queueAria`,I),a(`stopAria`,I),a(`modelAria`,I),a(`agentAria`,I),a(`agentLabel`,I),a(`agentColor`,I),a(`agentIdenticon`,(e,t)=>e.join(``)===t.join(``)),a(`suppressed`,I),a(`showScrollToBottom`,I),a(`scrollAria`,I),a(`autocomplete`,j),Object.keys(i).length===0?null:i},De=e=>{let t=Array.isArray(e?.skipped)?e.skipped:[],n=[];for(let e of t){if(!e||typeof e!=`object`)continue;let t=e.name;typeof t==`string`&&t.trim()&&n.push(t)}return n},Oe=e=>{try{let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}catch{return null}},ke=(e,t=ie)=>{let n=Array.isArray(e?.files)?e.files:[],r=[];for(let e of n){if(!e||typeof e!=`object`)continue;let n=e;if(typeof n.dataBase64!=`string`||n.dataBase64.length===0)continue;let i=Oe(n.dataBase64);if(!i||i.byteLength===0||i.byteLength>t)continue;let a=typeof n.name==`string`&&n.name.trim()?n.name:`file`,o=typeof n.mime==`string`&&n.mime.trim()?n.mime:`application/octet-stream`;r.push(new File([new Uint8Array(i)],a,{type:o}))}return r},L=80,Ae=e=>typeof document>`u`||!e||!e.startsWith(`data:image/`)?Promise.resolve(null):new Promise(t=>{let n=new Image;n.decoding=`async`,n.onload=()=>{try{let e=document.createElement(`canvas`);e.width=L,e.height=L;let r=e.getContext(`2d`);if(!r){t(null);return}r.clearRect(0,0,L,L),r.drawImage(n,0,0,L,L);let i=e.toDataURL(`image/jpeg`,.72),a=i.indexOf(`,`);t(a>=0?i.slice(a+1):null)}catch{t(null)}},n.onerror=()=>t(null),n.src=e}),je=e=>typeof document>`u`||!e?Promise.resolve(null):new Promise(t=>{let n=new Image;n.decoding=`async`,n.onload=()=>{try{let e=document.createElement(`canvas`);e.width=w,e.height=w;let r=e.getContext(`2d`);if(!r){t(null);return}r.clearRect(0,0,w,w),r.drawImage(n,0,0,w,w);let i=e.toDataURL(`image/png`),a=i.indexOf(`,`);t(a>=0?i.slice(a+1):null)}catch{t(null)}},n.onerror=()=>t(null),n.src=e}),R=()=>oe,z=((e=R)=>{let t=0,n=null,r=[],i=null,a=``,o=!1,s=!1,c=()=>{n!==null&&(clearTimeout(n),n=null)},l=(e,...t)=>{let n=i;n&&n[e](...t)},u=async()=>{if(r.length>0)return;let t=e(),n=await Promise.all([t.addListener(`textChanged`,e=>{let t=typeof e.text==`string`?e.text:``;a=t,l(`onText`,t,e.composing===!0,ye(e))}),t.addListener(`send`,e=>{let t=typeof e.text==`string`?e.text:a;a=t,l(`onSend`,t)}),t.addListener(`abort`,()=>{l(`onAbort`)}),t.addListener(`attach`,()=>{l(`onAttach`)}),t.addListener(`filesPicked`,t=>{l(`onFiles`,ke(t),De(t)),e().focus()}),t.addListener(`removeAttachment`,e=>{let t=ve(e);t&&l(`onRemoveAttachment`,t)}),t.addListener(`openModel`,()=>{l(`onOpenModel`)}),t.addListener(`cycleAgent`,()=>{l(`onCycleAgent`)}),t.addListener(`openAgent`,()=>{l(`onOpenAgent`)}),t.addListener(`heightChanged`,e=>{l(`onHeight`,ue(e))}),t.addListener(`scrollToBottom`,()=>{l(`onScrollToBottom`)}),t.addListener(`autocompleteAccept`,e=>{l(`onAutocompleteAccept`,be(e))}),t.addListener(`autocompleteDismiss`,()=>{l(`onAutocompleteDismiss`)})]);if(r.length>0){for(let e of n)e.remove();return}r=n},d=n=>{t>0||(i=null,o=!1,E(n,!1),e().dismiss())};return{bind(e){i=e},rememberText(e){a=e},rememberState(e){a=e.text},conceal(){o||t===0||(o=!0,e().hide())},reveal(){!o||t===0||(o=!1,e().show())},async warm(){s||t>0||(s=!0,await e().present(ae()))},async retain(n,i){c(),t+=1,o=!1,s=!0,a=i.text,E(n,!0),r.length===0&&await u(),await e().present(i)},release(e){t=Math.max(0,t-1),!(t>0)&&(c(),n=setTimeout(()=>{n=null,d(e)},0))},shutdown(n=document.documentElement){c(),t=0,s=!1,o=!1,i=null,E(n,!1),e().dismiss()},snapshot(){return{retainCount:t,listenerCount:r.length,hidePending:n!==null,concealed:o,warmed:s}}}})(),Me=()=>a(`OpenChamberNavigation`),B=e=>e?.kind===`chat`||e?.kind===`draft`,V=e=>e?e.kind===`draft`||e.kind===`chat`&&e.routes.length<=1:!1,Ne=(e,t)=>B(e)&&!B(t),Pe=(e=z)=>{V(u.getState().secondary)&&e.conceal()},Fe=(e=z)=>{let t=u.subscribe((t,n)=>{Ne(n.secondary,t.secondary)&&e.conceal()}),n=[],r=!1;return o.getPlatform()===`ios`&&(async()=>{let t=Me(),i=await t.addListener(`backStarted`,()=>{V(u.getState().secondary)&&e.conceal()}),a=await t.addListener(`backCancelled`,()=>{e.reveal()});if(r){i.remove(),a.remove();return}n=[i,a]})(),()=>{r=!0,t();for(let e of n)e.remove();n=[]}},H=`__openchamberMobileBackRoute`,Ie=()=>typeof window>`u`||r()?null:{currentState:()=>window.history.state&&typeof window.history.state==`object`?window.history.state:null,pushState:e=>window.history.pushState(e,``,window.location.href),back:()=>window.history.back(),subscribe:e=>{let t=t=>e(t.state&&typeof t.state==`object`?t.state:null);return window.addEventListener(`popstate`,t),()=>window.removeEventListener(`popstate`,t)}},U=e=>{let t=e?.[H];return typeof t==`number`&&Number.isFinite(t)?t:null},W=new class{routes=[];listeners=new Set;nextToken=1;history;removeHistoryListener=null;programmaticHistoryBackToken=null;pendingHistoryRemovals=new Map;animatedBackDriver=null;presentationCancelDriver=null;constructor(e=Ie()){this.history=e}subscribe=e=>(this.listeners.add(e),()=>this.listeners.delete(e));getTopRoute=()=>this.routes.at(-1)??null;register=e=>{let t=this.pendingHistoryRemovals.get(e.id);this.pendingHistoryRemovals.delete(e.id);let n=!!(this.history&&t!==void 0&&U(this.history.currentState())===t),r={...e,token:n&&t!==void 0?t:this.nextToken++};this.routes.push(r),this.ensureHistoryListener(),this.history&&!n&&this.history.pushState({...this.history.currentState()??{},[H]:r.token}),this.notify();let i=!0;return()=>{if(!i)return;i=!1;let e=this.routes.indexOf(r);e<0||(this.routes.splice(e,1),this.history&&U(this.history.currentState())===r.token?(this.pendingHistoryRemovals.set(r.id,r.token),queueMicrotask(()=>{if(this.pendingHistoryRemovals.get(r.id)===r.token){if(this.pendingHistoryRemovals.delete(r.id),!this.history||U(this.history.currentState())!==r.token){this.routes.length===0&&this.pendingHistoryRemovals.size===0&&this.disposeHistoryListener();return}this.programmaticHistoryBackToken=r.token,this.history.back(),this.routes.length===0&&this.pendingHistoryRemovals.size===0&&this.disposeHistoryListener()}})):this.routes.length===0&&this.pendingHistoryRemovals.size===0&&this.disposeHistoryListener(),this.notify())}};backImmediately=e=>{let t=this.getTopRoute();return!t||e&&t.layer!==e?!1:t.onBack()!==!1};requestAnimatedBack=e=>{let t=this.getTopRoute();return!t||e&&t.layer!==e?!1:this.animatedBackDriver?.(t)?!0:this.backImmediately(e)};setAnimatedBackDriver=e=>(this.animatedBackDriver=e,()=>{this.animatedBackDriver===e&&(this.animatedBackDriver=null)});setPresentationCancelDriver=e=>(this.presentationCancelDriver=e,()=>{this.presentationCancelDriver===e&&(this.presentationCancelDriver=null)});cancelPresentation=()=>{this.presentationCancelDriver?.()};requestBrowserBack=()=>{let e=this.getTopRoute();return e?this.history&&U(this.history.currentState())===e.token?(this.history.back(),!0):e.onBack()!==!1:!1};ensureHistoryListener(){!this.history||this.removeHistoryListener||(this.removeHistoryListener=this.history.subscribe(e=>{if(this.programmaticHistoryBackToken!==null){this.programmaticHistoryBackToken=null;return}let t=this.getTopRoute();t&&U(e)!==t.token&&t.onBack()===!1&&this.history&&this.history.pushState({...this.history.currentState()??{},[H]:t.token})}))}disposeHistoryListener(){this.removeHistoryListener?.(),this.removeHistoryListener=null,this.programmaticHistoryBackToken=null,this.pendingHistoryRemovals.clear()}notify(){this.listeners.forEach(e=>e())}},Le=e=>{let t=(0,m.c)(8),{id:n,active:r,layer:i,onBack:a,surfaceRef:o,underlayRef:s}=e,c=i===void 0?`root`:i,u=l(a),d,f;t[0]!==r||t[1]!==u||t[2]!==n||t[3]!==c||t[4]!==o||t[5]!==s?(d=()=>{if(r)return W.register({id:n,layer:c,onBack:u,getSurface:()=>o.current,getUnderlay:()=>s?.current??null})},f=[r,u,n,c,o,s],t[0]=r,t[1]=u,t[2]=n,t[3]=c,t[4]=o,t[5]=s,t[6]=d,t[7]=f):(d=t[6],f=t[7]),p.useEffect(d,f)},G=a(`OpenChamberNavigation`),K=e=>Math.min(1,Math.max(0,Number.isFinite(e)?e:0)),Re=(e,t)=>!e||!t?!1:e.onBack()!==!1,q=e=>{let t=K(e.progress),n=e.commit?1-t:t;if(n<=.001)return 0;let r=Math.max(1,e.viewportWidth??390),i=Math.abs(e.velocityX??0)/r,a=n/Math.max(e.commit?2.4:2.8,i)*1e3,o=e.commit?90:100,s=e.commit?320:260;return Math.round(Math.min(s,Math.max(o,a)))},J=e=>{let{surface:t,underlay:n,surfaceTransition:r,surfaceAnimation:i,underlayTransition:a,underlayAnimation:o}=e;t.style.removeProperty(`transform`),t.style.removeProperty(`opacity`),t.style.removeProperty(`will-change`),t.style.removeProperty(`box-shadow`),t.style.transition=r,t.style.animation=i,n&&(n.style.removeProperty(`transform`),n.style.removeProperty(`opacity`),n.style.removeProperty(`will-change`),n.style.transition=a??``,n.style.animation=o??``)},Y=(e,t)=>{let n=K(t),{surface:r}=e;r.style.transform=`translate3d(${n*100}%, 0, 0)`},ze=e=>!e.surfaceConnected||e.topRouteToken!==e.routeToken||e.routeSurface!==e.outgoingSurface,Be=async(e,t,n,r)=>{if(!r&&typeof e.animate==`function`){let r=e.style.transform||`translate3d(0%, 0, 0)`,i=`translate3d(${t}%, 0, 0)`,a=e.animate([{transform:r},{transform:i}],{duration:n,easing:`cubic-bezier(0.22, 1, 0.36, 1)`,fill:`forwards`}),o=!1;try{await a.finished,o=!0}catch{}finally{o&&(e.style.transform=i),a.cancel()}return}e.style.transform=`translate3d(${t}%, 0, 0)`},Ve=async(e,t,n=typeof window<`u`&&window.matchMedia?.(`(prefers-reduced-motion: reduce)`).matches,r=q({progress:Number.parseFloat(e.style.transform.match(/translate3d\(([-\d.]+)%/)?.[1]??`0`)/100,commit:t}))=>Be(e,t?100:0,r,n),He=class{pending=0;enqueue(){this.pending+=1}take(){return this.pending!==0&&(--this.pending,!0)}clear(){this.pending=0}},Ue=e=>{let t=(0,m.c)(4),{enabled:n,rootRoutesBlocked:i}=e,a,s;t[0]!==n||t[1]!==i?(a=()=>{if(!n||!r()||o.getPlatform()===`web`)return;let e=!1,t=null,a=null,s=0,c=0,l=0,u=new He,d=[],f=e=>!!e&&(!i||e?.layer===`overlay`),p=()=>{let e=f(W.getTopRoute());G.setEnabled({enabled:e}).catch(We)},m=()=>{if(W.cancelPresentation(),a)return;let e=W.getTopRoute();if(!f(e))return;let n=e.getSurface();if(!n)return;n.getAnimations().forEach(Ge),a=null;let r=e.layer===`root`?e.getUnderlay():null,i=n.style.transition,o=n.style.animation,s=r?.style.transition??null,c=r?.style.animation??null;r?.getAnimations().forEach(Ke),n.style.transition=`none`,n.style.animation=`none`,n.style.willChange=`transform`,r&&(r.style.removeProperty(`transform`),r.style.removeProperty(`will-change`)),l+=1,t={route:e,surface:n,underlay:r,surfaceTransition:i,surfaceAnimation:o,underlayTransition:s,underlayAnimation:c},Y(t,0)},h=e=>{c=K(e),!s&&(s=window.requestAnimationFrame(()=>{s=0,t&&Y(t,c)}))},g=qe,_=(n,r,i)=>{if(n&&Pe(),a)return n&&f(W.getTopRoute())?(u.enqueue(),!0):!1;s&&=(window.cancelAnimationFrame(s),0),t||m(),t&&r!==void 0&&Y(t,r);let o=t,d=l;if(t=null,!o){if(!n)return!1;let e=W.getTopRoute();return Re(e,f(e))}a=o;let p=window.matchMedia?.(`(prefers-reduced-motion: reduce)`).matches??!1,h=q({progress:K(r??c),commit:n,velocityX:i,viewportWidth:window.innerWidth});return Ve(o.surface,n,p,h).then(async()=>{d===l&&(!e&&n&&(o.route.onBack(),await g(o)),d===l&&(J(o),a===o&&(a=null),!e&&u.take()&&_(!0,0,0)))}),!0},v=W.setAnimatedBackDriver(e=>e!==W.getTopRoute()||!f(e)?!1:_(!0,0,0)),y=W.subscribe(p);return(async()=>{let t=await G.addListener(`backStarted`,m),n=await G.addListener(`backProgressed`,e=>h(e.progress??0)),r=await G.addListener(`backCancelled`,e=>_(!1,e.progress,e.velocityX)),i=await G.addListener(`backInvoked`,e=>_(!0,e.progress,e.velocityX));if(e){await Promise.all([t.remove(),n.remove(),r.remove(),i.remove()]);return}d.push(t,n,r,i),p()})().catch(Je),p(),()=>{e=!0,l+=1,u.clear(),y(),v(),s&&window.cancelAnimationFrame(s),t&&J(t),a&&(a.surface.getAnimations().forEach(Ye),a.underlay?.getAnimations().forEach(Xe),J(a)),t=null,a=null,G.setEnabled({enabled:!1}).catch(Ze),d.forEach(Qe)}},s=[n,i],t[0]=n,t[1]=i,t[2]=a,t[3]=s):(a=t[2],s=t[3]),p.useEffect(a,s)};function We(){}function Ge(e){return e.cancel()}function Ke(e){return e.cancel()}function qe(e){return new Promise(t=>{let n=0,r=12,i=!1,a=()=>{i||(i=!0,c(),n&&window.cancelAnimationFrame(n),t())},o=()=>{let t=W.getTopRoute();return ze({surfaceConnected:e.surface.isConnected,routeToken:e.route.token,topRouteToken:t?.token??null,routeSurface:e.route.getSurface(),outgoingSurface:e.surface})},s=()=>{if(o()||r<=0){a();return}--r,n=window.requestAnimationFrame(s)},c=W.subscribe(()=>{o()&&a()});s()})}function Je(){}function Ye(e){return e.cancel()}function Xe(e){return e.cancel()}function Ze(){}function Qe(e){e.remove()}var $e=e=>/^#[0-9a-fA-F]{6}$/.test(e),et=e=>/^#[0-9a-fA-F]{8}$/.test(e),tt=(e,t)=>/^[0-9a-fA-F]{2}$/.test(t)?$e(e)?`${e}${t}`:et(e)?`${e.slice(0,7)}${t}`:e:e,X=(e,t)=>typeof e==`string`&&e.trim().length>0?e:t,nt=e=>{let t=e.colors.syntax.base,n=e.colors.syntax.tokens??{},r=(e,t)=>X(n[e],t);return[{name:`plain`,scope:[`source`,`support.type.property-name.css`],settings:{foreground:t.foreground}},{name:`classes`,scope:[`entity.name.type.class`],settings:{foreground:r(`className`,r(`class`,t.function))}},{name:`interfaces`,scope:[`entity.name.type.interface`,`entity.name.type`],settings:{foreground:r(`interface`,t.type)}},{name:`structs`,scope:[`entity.name.type.struct`],settings:{foreground:r(`struct`,t.function)}},{name:`enums`,scope:[`entity.name.type.enum`],settings:{foreground:r(`enum`,t.function)}},{name:`keys`,scope:[`meta.object-literal.key`,`support.type.property-name`],settings:{foreground:r(`key`,t.function)}},{name:`methods`,scope:[`entity.name.function.method`,`meta.function.method`],settings:{foreground:r(`method`,e.colors.status.success)}},{name:`functions`,scope:[`entity.name.function`,`support.function`,`meta.function-call.generic`],settings:{foreground:t.function,fontStyle:`bold`}},{name:`variables`,scope:[`variable`,`meta.variable`,`variable.other.object.property`],settings:{foreground:t.variable}},{name:`variablesOther`,scope:[`variable.other.object`,`variable.other.readwrite.alias`],settings:{foreground:r(`variableOther`,r(`method`,e.colors.status.success))}},{name:`globalVariables`,scope:[`variable.other.global`,`variable.language.this`],settings:{foreground:r(`variableGlobal`,t.number)}},{name:`localVariables`,scope:[`variable.other.local`],settings:{foreground:r(`variableLocal`,e.colors.surface.elevated)}},{name:`parameters`,scope:[`variable.parameter`,`meta.parameter`],settings:{foreground:r(`parameter`,t.foreground)}},{name:`properties`,scope:[`variable.other.property`,`meta.property`],settings:{foreground:r(`variableProperty`,e.colors.status.info)}},{name:`strings`,scope:[`string`,`string.other.link`,`markup.inline.raw.string.markdown`],settings:{foreground:t.string}},{name:`stringEscapeSequences`,scope:[`constant.character.escape`,`constant.other.placeholder`],settings:{foreground:r(`stringEscape`,t.foreground)}},{name:`keywords`,scope:[`keyword`],settings:{foreground:t.keyword}},{name:`keywordsControl`,scope:[`keyword.control.import`,`keyword.control.from`,`keyword.import`],settings:{foreground:r(`keywordImport`,t.operator)}},{name:`storageModifiers`,scope:[`storage.modifier`,`keyword.modifier`,`storage.type`],settings:{foreground:r(`storageModifier`,t.keyword)}},{name:`comments`,scope:[`comment`,`punctuation.definition.comment`],settings:{foreground:t.comment}},{name:`docComments`,scope:[`comment.documentation`,`comment.line.documentation`],settings:{foreground:r(`commentDoc`,e.colors.surface.mutedForeground)}},{name:`numbers`,scope:[`constant.numeric`],settings:{foreground:t.number}},{name:`booleans`,scope:[`constant.language`],settings:{foreground:r(`boolean`,t.type)}},{name:`operators`,scope:[`keyword.operator`],settings:{foreground:t.operator}},{name:`macros`,scope:[`entity.name.function.preprocessor`,`meta.preprocessor`],settings:{foreground:r(`macro`,t.keyword)}},{name:`preprocessor`,scope:[`meta.preprocessor`],settings:{foreground:r(`preprocessor`,r(`label`,t.number))}},{name:`urls`,scope:[`markup.underline.link`],settings:{foreground:r(`url`,e.colors.status.info)}},{name:`tags`,scope:[`entity.name.tag`],settings:{foreground:r(`tag`,t.keyword)}},{name:`jsxTags`,scope:[`support.class.component`],settings:{foreground:r(`jsxTag`,r(`label`,t.number))}},{name:`attributes`,scope:[`entity.other.attribute-name`,`meta.attribute`],settings:{foreground:r(`tagAttribute`,t.type)}},{name:`types`,scope:[`support.type`],settings:{foreground:t.type}},{name:`constants`,scope:[`variable.other.constant`,`variable.readonly`],settings:{foreground:r(`constant`,t.foreground)}},{name:`labels`,scope:[`entity.name.label`,`punctuation.definition.label`],settings:{foreground:r(`label`,r(`variableGlobal`,t.number))}},{name:`namespaces`,scope:[`entity.name.namespace`,`storage.modifier.namespace`,`markup.bold.markdown`],settings:{foreground:r(`namespace`,t.type)}},{name:`modules`,scope:[`entity.name.module`,`storage.modifier.module`],settings:{foreground:r(`module`,t.operator)}},{name:`typeParameters`,scope:[`variable.type.parameter`,`variable.parameter.type`],settings:{foreground:r(`typeParameter`,t.function)}},{name:`exceptions`,scope:[`keyword.control.exception`,`keyword.control.trycatch`],settings:{foreground:r(`exception`,r(`label`,t.number))}},{name:`decorators`,scope:[`meta.decorator`,`punctuation.decorator`,`entity.name.function.decorator`],settings:{foreground:r(`decorator`,t.type)}},{name:`calls`,scope:[`variable.function`],settings:{foreground:t.foreground}},{name:`punctuation`,scope:[`punctuation`,`punctuation.terminator`,`punctuation.definition.tag`,`punctuation.separator`,`punctuation.definition.string`,`punctuation.section.block`],settings:{foreground:r(`punctuation`,t.comment)}},{name:`yellow`,scope:[`storage.type.numeric.go`,`storage.type.byte.go`,`storage.type.boolean.go`,`storage.type.string.go`,`storage.type.uintptr.go`,`storage.type.error.go`,`storage.type.rune.go`,`constant.language.go`,`support.class.dart`,`keyword.other.documentation`,`storage.modifier.import.java`,`punctuation.definition.list.begin.markdown`,`punctuation.definition.quote.begin.markdown`,`meta.separator.markdown`,`entity.name.section.markdown`],settings:{foreground:t.type}},{name:`green`,scope:[],settings:{foreground:r(`method`,e.colors.status.success)}},{name:`cyan`,scope:[`markup.italic.markdown`,`support.type.python`,`variable.legacy.builtin.python`,`support.constant.property-value.css`,`storage.modifier.attribute.swift`],settings:{foreground:t.string}},{name:`blue`,scope:[],settings:{foreground:t.keyword}},{name:`purple`,scope:[`keyword.channel.go`,`keyword.other.platform.os.swift`],settings:{foreground:t.number}},{name:`magenta`,scope:[`punctuation.definition.heading.markdown`],settings:{foreground:r(`label`,r(`variableGlobal`,t.number))}},{name:`red`,scope:[],settings:{foreground:t.operator}},{name:`orange`,scope:[],settings:{foreground:t.function}}]},rt=e=>{let t=e.colors.surface,n=e.colors.interactive,r=e.colors.status,i=e.colors.syntax.base,a=e.colors.syntax.highlights??{},o=X(a.diffAddedBackground,r.successBackground),s=X(a.diffRemovedBackground,r.errorBackground);return{"editor.background":t.background,"editor.foreground":t.foreground,"editor.hoverHighlightBackground":X(n.hover,t.subtle),"editor.lineHighlightBackground":t.muted,"editor.selectionBackground":n.selection,"editor.selectionHighlightBackground":n.selection,"editor.findMatchBackground":i.type,"editor.findMatchHighlightBackground":tt(i.type,`cc`),"editor.findRangeHighlightBackground":t.muted,"editor.inactiveSelectionBackground":t.elevated,"editor.lineHighlightBorder":t.elevated,"editor.rangeHighlightBackground":X(n.active,n.borderHover),"notifications.background":t.elevated,"editorInlayHint.typeBackground":t.subtle,"editorInlayHint.typeForeground":t.foreground,"editorWhitespace.foreground":n.borderHover,"editorIndentGuide.background1":t.subtle,"editorHoverWidget.background":t.elevated,"editorLineNumber.activeForeground":X(a.lineNumberActive,t.foreground),"editorLineNumber.foreground":X(a.lineNumber,t.mutedForeground),"editorGutter.background":t.background,"editorGutter.modifiedBackground":r.info,"editorGutter.addedBackground":r.success,"editorGutter.deletedBackground":r.error,"editorBracketMatch.background":t.elevated,"editorBracketMatch.border":t.subtle,"editorError.foreground":r.error,"editorWarning.foreground":r.warning,"editorInfo.foreground":r.info,"diffEditor.insertedTextBackground":o,"diffEditor.removedTextBackground":s,"editorGroupHeader.tabsBackground":t.background,"editorGroup.border":n.border,"tab.activeBackground":t.background,"tab.inactiveBackground":t.muted,"tab.inactiveForeground":t.mutedForeground,"tab.activeForeground":t.foreground,"tab.hoverBackground":t.subtle,"tab.unfocusedHoverBackground":t.subtle,"tab.border":n.border,"tab.activeModifiedBorder":i.type,"tab.inactiveModifiedBorder":r.info,"tab.unfocusedActiveModifiedBorder":i.type,"tab.unfocusedInactiveModifiedBorder":r.info,"editorWidget.background":t.muted,"editorWidget.border":n.border,"editorSuggestWidget.background":t.background,"editorSuggestWidget.border":n.border,"editorSuggestWidget.foreground":t.foreground,"editorSuggestWidget.highlightForeground":t.mutedForeground,"editorSuggestWidget.selectedBackground":t.subtle,"peekView.border":n.border,"peekViewEditor.background":t.background,"peekViewEditor.matchHighlightBackground":t.subtle,"peekViewResult.background":t.muted,"peekViewResult.fileForeground":t.foreground,"peekViewResult.lineForeground":t.mutedForeground,"peekViewResult.matchHighlightBackground":t.subtle,"peekViewResult.selectionBackground":t.elevated,"peekViewResult.selectionForeground":t.mutedForeground,"peekViewTitle.background":t.subtle,"peekViewTitleDescription.foreground":t.mutedForeground,"peekViewTitleLabel.foreground":t.foreground,"merge.currentHeaderBackground":r.success,"merge.currentContentBackground":X(a.diffAdded,r.success),"merge.incomingHeaderBackground":r.info,"merge.incomingContentBackground":X(a.diffModified,r.info),"merge.border":n.border,"merge.commonContentBackground":t.subtle,"merge.commonHeaderBackground":t.muted,"panel.background":t.background,"panel.border":n.border,"panelTitle.activeBorder":n.borderHover,"panelTitle.activeForeground":t.foreground,"panelTitle.inactiveForeground":t.mutedForeground,"statusBar.background":t.background,"statusBar.foreground":t.foreground,"statusBar.border":n.border,"statusBar.debuggingBackground":r.error,"statusBar.debuggingForeground":r.errorForeground,"statusBar.noFolderBackground":t.subtle,"statusBar.noFolderForeground":t.mutedForeground,"titleBar.activeBackground":t.background,"titleBar.activeForeground":t.foreground,"titleBar.inactiveBackground":t.muted,"titleBar.inactiveForeground":t.mutedForeground,"titleBar.border":n.border,"menu.foreground":t.foreground,"menu.background":t.background,"menu.selectionForeground":t.foreground,"menu.selectionBackground":t.subtle,"menu.border":n.border,"editorInlayHint.foreground":t.mutedForeground,"editorInlayHint.background":t.subtle,"terminal.foreground":t.foreground,"terminal.background":t.background,"terminalCursor.foreground":t.foreground,"terminalCursor.background":t.background,"terminal.ansiRed":X(a.diffRemoved,r.error),"terminal.ansiGreen":X(a.diffAdded,r.success),"terminal.ansiYellow":r.warning,"terminal.ansiBlue":X(a.diffModified,r.info),"terminal.ansiMagenta":i.keyword,"terminal.ansiCyan":i.type,"activityBar.background":t.background,"activityBar.foreground":t.foreground,"activityBar.inactiveForeground":t.mutedForeground,"activityBar.activeBorder":t.foreground,"activityBar.border":n.border,"sideBar.background":t.background,"sideBar.foreground":t.foreground,"sideBar.border":n.border,"sideBarTitle.foreground":t.foreground,"sideBarSectionHeader.background":t.muted,"sideBarSectionHeader.foreground":t.foreground,"sideBarSectionHeader.border":n.border,"sideBar.activeBackground":t.subtle,"sideBar.activeForeground":t.foreground,"sideBar.hoverBackground":t.muted,"sideBar.hoverForeground":t.foreground,"list.warningForeground":r.warning,"list.errorForeground":r.error,"list.inactiveSelectionBackground":t.subtle,"list.activeSelectionBackground":t.elevated,"list.inactiveSelectionForeground":t.foreground,"list.activeSelectionForeground":t.foreground,"list.hoverForeground":t.foreground,"list.hoverBackground":t.muted,"input.background":t.muted,"input.foreground":t.foreground,"input.border":n.border,"input.placeholderForeground":t.mutedForeground,"inputOption.activeBorder":n.border,"inputOption.activeBackground":t.elevated,"inputOption.activeForeground":t.foreground,"inputValidation.infoBackground":r.infoBackground,"inputValidation.infoBorder":r.infoBorder,"inputValidation.warningBackground":r.warningBackground,"inputValidation.warningBorder":r.warningBorder,"inputValidation.errorBackground":r.errorBackground,"inputValidation.errorBorder":r.errorBorder,"dropdown.background":t.muted,"dropdown.foreground":t.foreground,"dropdown.border":n.border,"dropdown.listBackground":t.background,"badge.background":e.colors.primary.base,"activityBarBadge.background":e.colors.primary.base,"button.background":e.colors.primary.base,"button.foreground":X(e.colors.primary.foreground,t.background),"badge.foreground":X(e.colors.primary.foreground,t.background),"activityBarBadge.foreground":X(e.colors.primary.foreground,t.background)}};function it(e){return{name:e.metadata.name,type:e.metadata.variant,colors:rt(e),tokenColors:nt(e)}}var at=e=>/^#[0-9a-fA-F]{8}$/.test(e),Z=e=>at(e)?e.slice(0,7):e;function ot(e,t){return Object.defineProperty(e,"toString",{value:()=>t,enumerable:!1,configurable:!0}),Object.defineProperty(e,Symbol.toPrimitive,{value:()=>t,enumerable:!1,configurable:!0}),e}var Q=new Map,$=new Set,st=(e,t)=>{let n=e.colors?.[`editor.background`],r=e.colors?.[`editor.foreground`],i=n?Z(n):void 0,a=r?Z(r):void 0;if(!i||!a)throw Error(`Theme "${t}" is missing editor.background/editor.foreground`);let o=e.tokenColors??[];return ot({...e,name:t,fg:a,bg:i,settings:o},t)},ct=e=>it(e),lt=e=>{let t=Q.get(e.metadata.id);if(t)return t;let n=st(ct(e),e.metadata.id);return Q.set(e.metadata.id,n),n},ut=e=>{let t=e.metadata.id;if($.has(t))return;let n=lt(e);c(t,async()=>n),$.add(t)};export{te as A,Ae as C,Se as D,k as E,ee as M,v as N,E as O,pe as S,xe as T,j as _,Ue as a,me as b,fe as c,ge as d,Ee as f,Te as g,R as h,Le as i,y as j,Ce as k,de as l,T as m,lt as n,Fe as o,ce as p,W as r,z as s,ut as t,_e as u,he as v,je as w,le as x,A as y};
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-C0FnF6B9.js";import{_ as t,c as n,d as r,s as i}from"./runtime-auth-D66yq6ie.js";import{c as a,i as o}from"./runtime-switch-LvWDU-SL.js";import{n as s}from"./runtime-fetch-zIalUnbb.js";import{a as c,i as l,n as u,r as d,s as f,t as p}from"./relay-image-stream-DM7atqJs.js";import{t as m}from"./dualLimitLru-D8Sphgua.js";var h=26214400,g=class extends Error{status;code;constructor(e,t,n=`Failed to upload assistant attachment`){super(n),this.name=`AssistantAttachmentUploadError`,this.status=e,this.code=t}},_=e=>typeof e==`object`&&!!e&&!Array.isArray(e),v=e=>[...new Uint8Array(e)].map(e=>e.toString(16).padStart(2,`0`)).join(``),y=async e=>{let t;if(e instanceof ArrayBuffer)t=e;else if(ArrayBuffer.isView(e)){let n=e;t=n.buffer.slice(n.byteOffset,n.byteOffset+n.byteLength)}else t=await e.arrayBuffer();return v(await crypto.subtle.digest(`SHA-256`,t))},b=e=>typeof e==`string`?e.split(`;`)[0]?.trim().toLowerCase():``,x=e=>{if(!Number.isSafeInteger(e)||e<0)throw new g(0,`rejected`,`Invalid attachment size`);if(e>26214400)throw new g(413,`too-large`)},ee=(e,t,n={})=>{if(!_(e))throw new g(0,`integrity`,`Attachment response was not a JSON object`);if(e.type!==`file`)throw new g(0,`integrity`,`Attachment response type must be file`);let r=typeof e.attachmentID==`string`?e.attachmentID.trim():``,i=typeof e.sha256==`string`?e.sha256.trim().toLowerCase():``,a=typeof e.size==`number`&&Number.isSafeInteger(e.size)?e.size:NaN,o=b(typeof e.mime==`string`?e.mime:``),s=typeof e.filename==`string`&&e.filename.trim()?e.filename.trim():void 0;if(!r)throw new g(0,`integrity`,`Attachment response missing attachmentID`);if(!/^[a-f0-9]{64}$/i.test(i))throw new g(0,`integrity`,`Attachment response missing sha256`);if(!Number.isSafeInteger(a)||a<0)throw new g(0,`integrity`,`Attachment response missing size`);if(!o)throw new g(0,`integrity`,`Attachment response missing mime`);if((n.enforceUploadLimit===!0||t)&&x(a),t){if(i!==t.sha256.toLowerCase())throw new g(0,`integrity`,`Attachment SHA-256 mismatch`);if(a!==t.size)throw new g(0,`integrity`,`Attachment size mismatch`);if(o!==t.mime)throw new g(0,`integrity`,`Attachment mime mismatch`)}return{type:`file`,attachmentID:r,sha256:i,size:a,mime:o,...s?{filename:s}:{}}},te=async(e,t,n,r)=>{let i=typeof e==`string`?e.trim():``,a=typeof n==`string`?n.trim():``;if(!i||!a)throw new g(0,`rejected`,`assistantID and uploadID are required`);if(!(t instanceof Blob))throw new g(0,`rejected`,`file must be a File or Blob`);let o=b(t.type||t.type)||`application/octet-stream`,c=t.type===o?t:new Blob([t],{type:o});x(c.size);let l=await y(c),u=typeof t.name==`string`&&t.name.trim()?t.name.trim():void 0,d;try{d=await s(`/api/openchamber/assistants/${encodeURIComponent(i)}/contact/attachments/${encodeURIComponent(a)}`,{method:`PUT`,headers:{"Content-Type":o,"X-Content-SHA256":l,"X-Content-Size":String(c.size),...u?{"X-Attachment-Filename":encodeURIComponent(u)}:{}},body:c,signal:r})}catch{throw new g(0,`unavailable`)}if(d.status===204||d.status===205)throw new g(d.status,`integrity`,`Attachment upload returned empty status`);if(d.status===413)throw new g(413,`too-large`);if(!d.ok)throw new g(d.status,d.status>=500||d.status===0?`unavailable`:`rejected`);let f=d.headers.get(`content-type`)?.toLowerCase()??``;if(f.includes(`text/html`)||f.includes(`text/plain`))throw new g(d.status,`integrity`,`Attachment upload returned non-JSON body`);let p;try{let e=await d.text();if(!e.trim())throw new g(d.status,`integrity`,`Attachment upload returned empty body`);if(!f.includes(`application/json`)&&!e.trim().startsWith(`{`))throw new g(d.status,`integrity`,`Attachment upload returned non-JSON body`);p=JSON.parse(e)}catch(e){throw e instanceof g?e:new g(d.status,`integrity`,`Attachment upload response was not valid JSON`)}return ee(p,{sha256:l,size:c.size,mime:o})},ne=e=>{try{return ee(e,void 0,{enforceUploadLimit:!1}),!0}catch{return!1}},re=e({ASSISTANT_ATTACHMENT_CACHE_MAX_BYTES:()=>S,ASSISTANT_ATTACHMENT_CACHE_MAX_ENTRIES:()=>200,ASSISTANT_ATTACHMENT_DISPLAY_MAX_BYTES:()=>C,AssistantAttachmentCacheError:()=>E,clearAssistantAttachmentCacheAll:()=>Te,clearAssistantAttachmentCacheForBearer:()=>we,clearAssistantAttachmentCacheScope:()=>Ce,getAssistantAttachmentBlob:()=>Oe,getAssistantAttachmentDisplay:()=>$,resolveAssistantAttachmentCacheScope:()=>R}),S=104857600,C=p,ie=`openchamber-assistant-attachments`,ae=2,w=`meta`,T=`data`,E=class extends Error{status;code;constructor(e,t,n=`Assistant attachment cache error`){super(n),this.name=`AssistantAttachmentCacheError`,this.status=e,this.code=t}},D=new m({maxEntries:200,maxBytes:S}),O=new Map,k=new Map,A=new Map,oe=null,se=null,j=0,M=null,N=!1,ce=Promise.resolve(),le=e=>[...new Uint8Array(e)].map(e=>e.toString(16).padStart(2,`0`)).join(``),P=async e=>{let t=new TextEncoder().encode(e);return le(await crypto.subtle.digest(`SHA-256`,t))},F=async e=>{let t=ce,n;ce=new Promise(e=>{n=e}),await t.catch(()=>void 0);try{return await e()}finally{n()}},I=()=>(j+=1,j),ue=(e,t)=>e.transportIdentity===t.transportIdentity&&e.authScope===t.authScope&&e.authScopeKind===t.authScopeKind,L=(e,t)=>{if(e!==j)throw new E(0,`stale`,`Attachment cache epoch changed`)},R=async(e={})=>{let t=e.transportIdentity??o(),r=e.authGeneration??i(),a=(e.bearer??n()).trim();return a?{transportIdentity:t,authScope:`b:${await P(a)}`,authScopeKind:`bearer-hash`,authGeneration:r}:{transportIdentity:t,authScope:`m:${r}`,authScopeKind:`memory-ephemeral`,authGeneration:r}},z=(e,t,n)=>[e.transportIdentity,e.authScope,t.trim(),n.attachmentID.trim(),n.sha256.toLowerCase()].join(`\0`),de=(e,t)=>{let n={...t,lastAccess:Date.now()};return D.set(e,n,n.size),n},fe=()=>{try{if(typeof globalThis<`u`&&globalThis.indexedDB)return globalThis.indexedDB}catch{}return null},B=()=>N?Promise.resolve(null):M||(M=new Promise(e=>{let t=fe();if(!t){N=!0,e(null);return}try{let n=t.open(ie,ae);n.onerror=()=>{N=!0,M=null,e(null)},n.onupgradeneeded=()=>{let e=n.result;if(e.objectStoreNames.contains(`blobs`)&&e.deleteObjectStore(`blobs`),!e.objectStoreNames.contains(w)){let t=e.createObjectStore(w,{keyPath:`key`});t.createIndex(`lastAccess`,`lastAccess`),t.createIndex(`authScope`,`authScope`),t.createIndex(`transportIdentity`,`transportIdentity`)}e.objectStoreNames.contains(T)||e.createObjectStore(T,{keyPath:`key`})},n.onsuccess=()=>{let t=n.result;t.onversionchange=()=>{try{t.close()}catch{}M=null},e(t)}}catch{N=!0,M=null,e(null)}}),M),V=e=>new Promise((t,n)=>{e.onsuccess=()=>t(e.result),e.onerror=()=>n(e.error??Error(`idb-request-failed`))}),H=e=>new Promise((t,n)=>{e.oncomplete=()=>t(),e.onerror=()=>n(e.error??Error(`idb-tx-failed`)),e.onabort=()=>n(e.error??Error(`idb-tx-aborted`))}),pe=async e=>{let t=await B();if(!t)return null;try{return await V(t.transaction(w,`readonly`).objectStore(w).get(e))??null}catch{return null}},me=async e=>{let t=await B();if(!t)return null;try{return await V(t.transaction(T,`readonly`).objectStore(T).get(e))??null}catch{return null}},U=async(e,t)=>{await F(async()=>{let n=await B();if(n)try{let r=n.transaction(w,`readwrite`),i=r.objectStore(w),a=await V(i.get(e));if(!a)return;i.put({...a,lastAccess:t}),await H(r)}catch{}})},W=async(e,t)=>{let n=e.transaction([w,T],`readwrite`),r=n.objectStore(w),i=n.objectStore(T),a=r.index(`lastAccess`),o=[];await new Promise((e,t)=>{let n=a.openCursor();n.onerror=()=>t(n.error??Error(`idb-cursor-failed`)),n.onsuccess=()=>{let t=n.result;if(!t){e();return}o.push(t.value),t.continue()}});let s=o.reduce((e,t)=>e+(t.size||0),0),c=o.length,l=Math.max(0,t.needBytes??0),u=Math.max(0,t.maxBytes-l);for(let e of o){if(c<=t.maxEntries&&s<=u)break;r.delete(e.key),i.delete(e.key),s-=e.size||0,--c}await H(n)},he=async(e,t,n,r)=>{if(n!==j)return!1;let i=await R();return n!==j||i.authScope!==r.authScope||i.transportIdentity!==r.transportIdentity?!1:F(async()=>{if(n!==j)return!1;let r=await B();if(!r)return!1;let i=async()=>{if(n!==j||(await W(r,{maxEntries:199,maxBytes:S,needBytes:e.size}),n!==j))return!1;let i=r.transaction([w,T],`readwrite`);return i.objectStore(w).put(e),i.objectStore(T).put({key:e.key,bytes:t}),await H(i),!0};try{return await i()}catch(t){if(!(t instanceof DOMException&&t.name===`QuotaExceededError`))return!1;try{return await W(r,{maxEntries:199,maxBytes:S,needBytes:e.size}),n===j&&await i()}catch{return!1}}})},G=async e=>{await F(async()=>{let t=await B();if(t)try{let n=t.transaction([w,T],`readwrite`),r=n.objectStore(w),i=n.objectStore(T),a=await V(r.getAllKeys());for(let t of a){if(typeof t!=`string`)continue;let n=await V(r.get(t));n&&e(n)&&(r.delete(t),i.delete(t))}await H(n)}catch{}})},K=async(e,t,n,r,i)=>{if(i!==j)return;let a={blob:t,sha256:n.sha256,size:n.size,mime:n.mime,lastAccess:Date.now()};if(D.set(e,a,a.size),r.authScopeKind!==`bearer-hash`||i!==j)return;let o=await t.arrayBuffer();i===j&&await he({key:e,sha256:n.sha256,size:n.size,mime:n.mime,lastAccess:a.lastAccess,transportIdentity:r.transportIdentity,authScope:r.authScope},o,i,r)},q=async(e,t,n,r)=>{L(r,n);let i=D.get(e);if(i&&i.sha256===t&&i.blob.size===i.size)return de(e,i),n.authScopeKind===`bearer-hash`&&U(e,Date.now()),i.blob;if(n.authScopeKind!==`bearer-hash`)return null;let a=await pe(e);if(L(r,n),!a||a.sha256!==t||a.size<=0||a.authScope!==n.authScope||a.transportIdentity!==n.transportIdentity)return null;let o=await me(e);if(L(r,n),!o||!(o.bytes instanceof ArrayBuffer)||o.bytes.byteLength!==a.size)return null;let s=await y(o.bytes);if(L(r,n),s!==t)return G(t=>t.key===e),null;let c={blob:new Blob([o.bytes],{type:a.mime||`application/octet-stream`}),sha256:a.sha256,size:a.size,mime:a.mime,lastAccess:Date.now()};return D.set(e,c,c.size),U(e,c.lastAccess),c.blob},J=e=>{if(e?.aborted)throw e.reason instanceof Error?e.reason:new E(0,`aborted`,`aborted`)},ge=(e,t)=>`/api/openchamber/assistants/${encodeURIComponent(e)}/contact/attachments/${encodeURIComponent(t)}`,_e=async(e,t,n,a,o,c)=>{J(n),L(o,a);let l;try{l=await s(ge(e,t.attachmentID),{method:`GET`,cache:`no-store`,signal:n})}catch(e){throw n.aborted?e instanceof Error?e:new E(0,`aborted`):new E(0,`unavailable`)}if(L(o,a),l.status===401||l.status===403)throw await Ce(a,`unauthorized`),i()===a.authGeneration&&r(),new E(l.status,`unauthorized`);if(l.status===413)throw new E(413,`too-large`);if(!l.ok)throw new E(l.status,l.status>=500?`unavailable`:`rejected`);let u=l.headers.get(`content-type`)?.split(`;`)[0]?.trim().toLowerCase()||t.mime||`application/octet-stream`,d=l.body,f=async(e,t)=>{try{await t?.cancel(e.message)}catch{}throw n.aborted,e};if(!d||typeof d.getReader!=`function`){let e=await l.blob();if(J(n),L(o,a),e.size>c)throw new E(413,`too-large`);if(e.size!==t.size)throw new E(0,`integrity`,`Attachment size failed verification`);let r=await y(e);if(L(o,a),r!==t.sha256.toLowerCase())throw new E(0,`integrity`,`Attachment SHA-256 mismatch`);return e.type===u?e:new Blob([e],{type:u})}let p=d.getReader(),m=[],h=0;try{for(;;){J(n),L(o,a);let{done:e,value:r}=await p.read();if(e)break;!r||r.byteLength===0||(h+=r.byteLength,h>c&&await f(new E(413,`too-large`),p),h>t.size&&await f(new E(0,`integrity`,`Attachment exceeded declared size`),p),m.push(r))}}catch(e){try{await p.cancel(e instanceof Error?e.message:`aborted`)}catch{}throw e}finally{try{p.releaseLock()}catch{}}if(L(o,a),h!==t.size)throw new E(0,`integrity`,`Attachment size mismatch`);let g=new Uint8Array(h),_=0;for(let e of m)g.set(e,_),_+=e.byteLength;let v=await y(g);if(L(o,a),v!==t.sha256.toLowerCase())throw new E(0,`integrity`,`Attachment SHA-256 mismatch`);return new Blob([g],{type:u})},Y=(e,t,n,r,i,a,o)=>{let s=O.get(e);if(!s||s.epoch!==i||!ue(s.scope,r)){let o=new AbortController;s={promise:_e(t,n,o.signal,r,i,a).finally(()=>{O.get(e)?.controller===o&&O.delete(e)}),controller:o,subscribers:0,scope:r,epoch:i},O.set(e,s)}return s.subscribers+=1,new Promise((t,n)=>{let r=!1,i=t=>{r||(r=!0,s.subscribers=Math.max(0,s.subscribers-1),t&&s.subscribers===0&&O.get(e)===s&&(s.controller.abort(o?.reason??Error(`aborted`)),O.delete(e)))},a=()=>{i(!0),n(o?.reason instanceof Error?o.reason:new E(0,`aborted`))};if(o?.aborted){a();return}o?.addEventListener(`abort`,a,{once:!0}),s.promise.then(e=>{o?.removeEventListener(`abort`,a),!r&&(r=!0,s.subscribers=Math.max(0,s.subscribers-1),t(e))},e=>{o?.removeEventListener(`abort`,a),!r&&(r=!0,s.subscribers=Math.max(0,s.subscribers-1),n(e))})})},ve=e=>{D.clear()},ye=(e,t)=>{for(let[n,r]of[...O.entries()])e(r,n)&&(r.controller.abort(Error(t)),O.delete(n))},be=e=>{for(let[t,n]of[...k.entries()])e(n,t)&&(d(n.url),l(n.url),k.delete(t));for(let[t]of[...A.entries()])e({url:``,refs:0,cacheKey:t,epoch:0},t)&&A.delete(t)},xe=()=>{for(let e of k.values())d(e.url),l(e.url);k.clear(),A.clear()},Se=e=>{for(let t of O.values())t.controller.abort(Error(e));O.clear()},Ce=async(e,t=`scope-cleared`)=>{let n=typeof e==`object`&&e?e:await R(),r=typeof e==`string`?e:t;I(),ye(e=>e.scope.authScope===n.authScope&&e.scope.transportIdentity===n.transportIdentity,r),be(e=>{let t=e.cacheKey.split(`\0`);return t[0]===n.transportIdentity&&t[1]===n.authScope}),ve(()=>!0),await G(e=>e.authScope===n.authScope&&e.transportIdentity===n.transportIdentity)},we=async(e,t=`forget-bearer`)=>{let n=e.trim();if(!n)return;let r=`b:${await P(n)}`;I(),ye(e=>e.scope.authScope===r,t),be(e=>e.cacheKey.split(`\0`)[1]===r),ve(()=>!0),await G(e=>e.authScope===r)},Te=async(e=`cleared`)=>{I(),Se(e),xe(),D.clear(),await F(async()=>{let e=await B();if(e)try{let t=e.transaction([w,T],`readwrite`);t.objectStore(w).clear(),t.objectStore(T).clear(),await H(t)}catch{}})},X=e=>{I(),Se(e),xe(),D.clear()},Ee=e=>{if(e.reason===`endpoint-switch`){X(`endpoint-switch`);return}if(X(e.reason===`invalidate`?`auth-invalidate`:`auth-credential`),e.previousBearerDigest){let t=`b:${e.previousBearerDigest}`;G(e=>e.authScope===t);return}let t=o();G(e=>e.transportIdentity===t)},De=()=>{typeof window>`u`||(oe||=a(()=>{X(`transport-changed`)}),se||=t(e=>{Ee(e)}))},Z=(e,t)=>{if(!ne(e))throw new E(0,`rejected`,`Invalid attachment descriptor`);if(e.size>t)throw new E(413,`too-large`);return{...e,sha256:e.sha256.toLowerCase()}},Oe=async(e,t,n={})=>{De(),J(n.signal);let r=typeof e==`string`?e.trim():``;if(!r)throw new E(0,`rejected`,`assistantID is required`);let i=Z(t,h),a=j,o=await R();L(a,o);let s=z(o,r,i),c=await q(s,i.sha256,o,a);if(c)return J(n.signal),L(a,o),c;let l=await Y(s,r,i,o,a,h,n.signal);return J(n.signal),L(a,o),await K(s,l,{sha256:i.sha256,size:i.size,mime:i.mime||l.type},o,a),L(a,o),l},ke=(e,t,n)=>{if(!u(t)||!c(t))throw l(t),new E(0,`unavailable`,`Display URL is not live`);let r=k.get(e);(!r||r.url!==t||r.epoch!==n)&&(r&&r.url!==t&&l(r.url),r={url:t,refs:0,cacheKey:e,epoch:n},k.set(e,r)),r.refs+=1;let i=!1;return{url:t,release:()=>{if(i)return;i=!0;let n=k.get(e);if(d(t),!n||n.url!==t){l(t);return}--n.refs,n.refs<=0&&(k.delete(e),l(n.url))}}},Ae=async(e,t,n,r,i,a)=>{let o=k.get(e);if(o&&o.epoch===i&&u(o.url))return o.url;let s=Z(n,C),c=z(a,t.trim(),s),l=await q(c,s.sha256,a,i);J(r),L(i,a),l||(l=await Y(c,t.trim(),s,a,i,s.size>26214400?C:h,r),L(i,a),J(r),s.size>26214400?D.set(c,{blob:l,sha256:s.sha256,size:s.size,mime:s.mime||l.type,lastAccess:Date.now()},s.size):(await K(c,l,{sha256:s.sha256,size:s.size,mime:s.mime||l.type},a,i),L(i,a))),J(r),L(i,a);let d=await f(l,r,{mimeType:s.mime||l.type});return J(r),L(i,a),d},Q=(e,t)=>{e.releasedOrphan||e.subscribers>0||(e.releasedOrphan=!0,e.url&&=(l(e.url),null),A.get(t)===e&&A.delete(t))},$=async(e,t,n={})=>{De(),J(n.signal);let r=typeof e==`string`?e.trim():``;if(!r)throw new E(0,`rejected`,`assistantID is required`);let i=Z(t,C),a=j,o=await R();L(a,o);let s=z(o,r,i),c=A.get(s);if(!c||c.epoch!==a){c&&c.epoch!==a&&(c.controller.abort(Error(`stale-epoch`)),Q(c,s));let e=new AbortController,t={promise:Promise.resolve(``),controller:e,subscribers:0,epoch:a,url:null,releasedOrphan:!1};t.promise=Ae(s,r,i,e.signal,a,o).then(e=>{if(t.url=e,t.subscribers===0||t.epoch!==j||t.releasedOrphan)throw l(e),t.url=null,t.releasedOrphan=!0,A.get(s)===t&&A.delete(s),new E(0,`stale`,`Display URL orphaned before lease`);return e}).catch(e=>{throw A.get(s)===t&&A.delete(s),t.url&&=(l(t.url),null),t.releasedOrphan=!0,e}).finally(()=>{A.get(s)===t&&t.subscribers===0&&Q(t,s)}),c=t,A.set(s,c)}return c.subscribers+=1,new Promise((e,t)=>{let r=!1,i=e=>{c.subscribers=Math.max(0,c.subscribers-1),c.subscribers===0&&(e&&c.controller.abort(n.signal?.reason??Error(`aborted`)),Q(c,s),A.get(s)===c&&A.delete(s))},o=()=>{r||(r=!0,i(!0),t(n.signal?.reason instanceof Error?n.signal.reason:new E(0,`aborted`)))};if(n.signal?.aborted){o();return}n.signal?.addEventListener(`abort`,o,{once:!0}),c.promise.then(i=>{if(n.signal?.removeEventListener(`abort`,o),!r){r=!0,c.subscribers=Math.max(0,c.subscribers-1),c.subscribers===0&&A.get(s)===c&&A.delete(s);try{if(c.epoch!==j)throw l(i),new E(0,`stale`,`Display epoch changed`);e(ke(s,i,a))}catch(e){t(e)}}},e=>{n.signal?.removeEventListener(`abort`,o),!r&&(r=!0,i(!1),t(e))})})};export{te as i,Oe as n,$ as r,re as t};
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{nt as t,rt as n}from"./vendor-base-ui-CnHfUmDN.js";import{n as r}from"./vendor-react-DLPElpoQ.js";import{t as i}from"./vendor-class-variance-authority-BLUaYARZ.js";import{t as a}from"./utils-BiK3tBGM.js";var o=r(),s=e(n(),1);function c(e,t){let n=(0,o.c)(3),r;return n[0]!==e||n[1]!==t?(r=n=>{for(let r of[e,t])r&&(typeof r==`function`?r(n):r.current=n)},n[0]=e,n[1]=t,n[2]=r):r=n[2],r}function l(e,t){let n={...t};for(let r in e){let i=t[r],a=e[r];n[r]=/^on[A-Z]/.test(r)&&typeof i==`function`&&typeof a==`function`?(...e)=>{a(...e),i(...e)}:r===`className`&&typeof i==`string`&&typeof a==`string`?`${a} ${i}`:r===`style`&&typeof i==`object`&&typeof a==`object`?{...a,...i}:a}return n}var u=s.forwardRef(function(e,t){let n=(0,o.c)(3),{children:r,...i}=e,a=s.isValidElement(r)?r:null,u=c(t,a?a.ref:void 0);if(!a)return null;let d=l(a.props,i),f;return n[0]!==u||n[1]!==d?(f={...d,ref:u},n[0]=u,n[1]=d,n[2]=f):f=n[2],s.cloneElement(a,f)}),d=t(),f=[`bg-[color-mix(in_srgb,var(--primary-base)_10%,var(--background))]`,`text-[var(--primary-base)]`,`border border-[color-mix(in_srgb,var(--primary-base)_12%,transparent)]`,`hover:bg-[color-mix(in_srgb,var(--primary-base)_16%,var(--background))]`,`active:bg-[color-mix(in_srgb,var(--primary-base)_22%,var(--background))]`,`dark:bg-[color-mix(in_srgb,var(--primary-base)_16%,transparent)]`,`dark:border-[color-mix(in_srgb,var(--primary-base)_20%,transparent)]`,`dark:hover:bg-[color-mix(in_srgb,var(--primary-base)_22%,transparent)]`,`dark:active:bg-[color-mix(in_srgb,var(--primary-base)_30%,transparent)]`].join(` `),p=[`bg-[color-mix(in_srgb,var(--status-error)_7%,var(--background))]`,`text-[var(--status-error)]`,`border border-[color-mix(in_srgb,var(--status-error)_9%,transparent)]`,`hover:bg-[color-mix(in_srgb,var(--status-error)_11%,var(--background))]`,`active:bg-[color-mix(in_srgb,var(--status-error)_16%,var(--background))]`,`dark:bg-[color-mix(in_srgb,var(--status-error)_9%,transparent)]`,`dark:border-[color-mix(in_srgb,var(--status-error)_14%,transparent)]`,`dark:hover:bg-[color-mix(in_srgb,var(--status-error)_14%,transparent)]`,`dark:active:bg-[color-mix(in_srgb,var(--status-error)_20%,transparent)]`].join(` `),m=i([`group relative inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-[10px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px] typography-ui-label font-medium tracking-[0.01em] shrink-0 select-none`,`transition-[background-color,border-color,color,opacity,filter,transform] duration-150 ease-out outline-none`,`focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]`,`aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive`,`disabled:pointer-events-none disabled:opacity-50`,`[&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`],{variants:{variant:{default:f,destructive:a(p,`focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40`),neutral:`bg-interactive-hover text-foreground border border-border/60 hover:bg-interactive-active`,outline:`bg-[var(--surface-elevated)] text-foreground border border-border/60 hover:bg-interactive-hover hover:text-foreground`,mobileGlass:`oc-mobile-floating-action text-foreground hover:brightness-105 active:bg-interactive-active focus-visible:border-transparent focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]`,chip:a(`border border-border/60 bg-transparent text-foreground hover:bg-interactive-hover hover:text-foreground`,`aria-pressed:bg-[color-mix(in_srgb,var(--primary-base)_10%,var(--background))]`,`aria-pressed:text-[var(--primary-base)]`,`aria-pressed:border-[color-mix(in_srgb,var(--primary-base)_12%,transparent)]`,`aria-pressed:hover:bg-[color-mix(in_srgb,var(--primary-base)_16%,var(--background))]`,`aria-pressed:hover:text-[var(--primary-base)]`,`dark:aria-pressed:bg-[color-mix(in_srgb,var(--primary-base)_16%,transparent)]`,`dark:aria-pressed:border-[color-mix(in_srgb,var(--primary-base)_20%,transparent)]`,`dark:aria-pressed:hover:bg-[color-mix(in_srgb,var(--primary-base)_22%,transparent)]`),secondary:`bg-interactive-hover text-foreground hover:bg-interactive-active`,ghost:`text-foreground hover:bg-interactive-hover hover:text-foreground active:bg-interactive-active`,link:`text-primary underline-offset-4 hover:underline`},size:{default:`h-9 px-3.5 has-[>svg]:px-3`,sm:`h-8 gap-1.5 px-2.5 has-[>svg]:px-2 rounded-[9px] supports-[corner-shape:squircle]:rounded-[50px]`,xs:`h-6 gap-1 px-2 typography-micro has-[>svg]:px-1.5 rounded-[7px] supports-[corner-shape:squircle]:rounded-[50px]`,lg:`h-10 px-4 has-[>svg]:px-3.5 rounded-[12px] supports-[corner-shape:squircle]:rounded-[50px]`,icon:`size-9`,mobileIcon:`size-10 min-h-10 min-w-10 rounded-full`}},defaultVariants:{variant:`default`,size:`default`}}),h=new Set([`icon`,`mobileIcon`,`xs`]);function g(e){let t=(0,o.c)(20),n,r,i,s,c,l;t[0]===e?(n=t[1],r=t[2],i=t[3],s=t[4],c=t[5],l=t[6]):({className:n,variant:l,size:i,asChild:s,type:c,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=s,t[5]=c,t[6]=l);let f=s!==void 0&&s,p=f?u:`button`,g;t[7]!==f||t[8]!==c?(g=f?c===void 0?{}:{type:c}:{type:c??`button`},t[7]=f,t[8]=c,t[9]=g):g=t[9];let _=g,v=i!=null&&h.has(i)?`compact`:void 0,y;t[10]!==n||t[11]!==i||t[12]!==l?(y=a(m({variant:l,size:i,className:n})),t[10]=n,t[11]=i,t[12]=l,t[13]=y):y=t[13];let b;return t[14]!==p||t[15]!==v||t[16]!==r||t[17]!==y||t[18]!==_?(b=(0,d.jsx)(p,{"data-slot":`button`,"data-mobile-press-feedback":v,className:y,..._,...r}),t[14]=p,t[15]=v,t[16]=r,t[17]=y,t[18]=_,t[19]=b):b=t[19],b}export{u as n,g as t};
1
+ import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{nt as t,rt as n}from"./vendor-base-ui-CnHfUmDN.js";import{n as r}from"./vendor-react-DLPElpoQ.js";import{t as i}from"./vendor-class-variance-authority-BLUaYARZ.js";import{t as a}from"./utils-BHTVlVov.js";var o=r(),s=e(n(),1);function c(e,t){let n=(0,o.c)(3),r;return n[0]!==e||n[1]!==t?(r=n=>{for(let r of[e,t])r&&(typeof r==`function`?r(n):r.current=n)},n[0]=e,n[1]=t,n[2]=r):r=n[2],r}function l(e,t){let n={...t};for(let r in e){let i=t[r],a=e[r];n[r]=/^on[A-Z]/.test(r)&&typeof i==`function`&&typeof a==`function`?(...e)=>{a(...e),i(...e)}:r===`className`&&typeof i==`string`&&typeof a==`string`?`${a} ${i}`:r===`style`&&typeof i==`object`&&typeof a==`object`?{...a,...i}:a}return n}var u=s.forwardRef(function(e,t){let n=(0,o.c)(3),{children:r,...i}=e,a=s.isValidElement(r)?r:null,u=c(t,a?a.ref:void 0);if(!a)return null;let d=l(a.props,i),f;return n[0]!==u||n[1]!==d?(f={...d,ref:u},n[0]=u,n[1]=d,n[2]=f):f=n[2],s.cloneElement(a,f)}),d=t(),f=[`bg-[color-mix(in_srgb,var(--primary-base)_10%,var(--background))]`,`text-[var(--primary-base)]`,`border border-[color-mix(in_srgb,var(--primary-base)_12%,transparent)]`,`hover:bg-[color-mix(in_srgb,var(--primary-base)_16%,var(--background))]`,`active:bg-[color-mix(in_srgb,var(--primary-base)_22%,var(--background))]`,`dark:bg-[color-mix(in_srgb,var(--primary-base)_16%,transparent)]`,`dark:border-[color-mix(in_srgb,var(--primary-base)_20%,transparent)]`,`dark:hover:bg-[color-mix(in_srgb,var(--primary-base)_22%,transparent)]`,`dark:active:bg-[color-mix(in_srgb,var(--primary-base)_30%,transparent)]`].join(` `),p=[`bg-[color-mix(in_srgb,var(--status-error)_7%,var(--background))]`,`text-[var(--status-error)]`,`border border-[color-mix(in_srgb,var(--status-error)_9%,transparent)]`,`hover:bg-[color-mix(in_srgb,var(--status-error)_11%,var(--background))]`,`active:bg-[color-mix(in_srgb,var(--status-error)_16%,var(--background))]`,`dark:bg-[color-mix(in_srgb,var(--status-error)_9%,transparent)]`,`dark:border-[color-mix(in_srgb,var(--status-error)_14%,transparent)]`,`dark:hover:bg-[color-mix(in_srgb,var(--status-error)_14%,transparent)]`,`dark:active:bg-[color-mix(in_srgb,var(--status-error)_20%,transparent)]`].join(` `),m=i([`group relative inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-[10px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px] typography-ui-label font-medium tracking-[0.01em] shrink-0 select-none`,`transition-[background-color,border-color,color,opacity,filter,transform] duration-150 ease-out outline-none`,`focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]`,`aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive`,`disabled:pointer-events-none disabled:opacity-50`,`[&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`],{variants:{variant:{default:f,destructive:a(p,`focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40`),neutral:`bg-interactive-hover text-foreground border border-border/60 hover:bg-interactive-active`,outline:`bg-[var(--surface-elevated)] text-foreground border border-border/60 hover:bg-interactive-hover hover:text-foreground`,mobileGlass:`oc-mobile-floating-action text-foreground hover:brightness-105 active:bg-interactive-active focus-visible:border-transparent focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]`,chip:a(`border border-border/60 bg-transparent text-foreground hover:bg-interactive-hover hover:text-foreground`,`aria-pressed:bg-[color-mix(in_srgb,var(--primary-base)_10%,var(--background))]`,`aria-pressed:text-[var(--primary-base)]`,`aria-pressed:border-[color-mix(in_srgb,var(--primary-base)_12%,transparent)]`,`aria-pressed:hover:bg-[color-mix(in_srgb,var(--primary-base)_16%,var(--background))]`,`aria-pressed:hover:text-[var(--primary-base)]`,`dark:aria-pressed:bg-[color-mix(in_srgb,var(--primary-base)_16%,transparent)]`,`dark:aria-pressed:border-[color-mix(in_srgb,var(--primary-base)_20%,transparent)]`,`dark:aria-pressed:hover:bg-[color-mix(in_srgb,var(--primary-base)_22%,transparent)]`),secondary:`bg-interactive-hover text-foreground hover:bg-interactive-active`,ghost:`text-foreground hover:bg-interactive-hover hover:text-foreground active:bg-interactive-active`,link:`text-primary underline-offset-4 hover:underline`},size:{default:`h-9 px-3.5 has-[>svg]:px-3`,sm:`h-8 gap-1.5 px-2.5 has-[>svg]:px-2 rounded-[9px] supports-[corner-shape:squircle]:rounded-[50px]`,xs:`h-6 gap-1 px-2 typography-micro has-[>svg]:px-1.5 rounded-[7px] supports-[corner-shape:squircle]:rounded-[50px]`,lg:`h-10 px-4 has-[>svg]:px-3.5 rounded-[12px] supports-[corner-shape:squircle]:rounded-[50px]`,icon:`size-9`,mobileIcon:`size-10 min-h-10 min-w-10 rounded-full`}},defaultVariants:{variant:`default`,size:`default`}}),h=new Set([`icon`,`mobileIcon`,`xs`]);function g(e){let t=(0,o.c)(20),n,r,i,s,c,l;t[0]===e?(n=t[1],r=t[2],i=t[3],s=t[4],c=t[5],l=t[6]):({className:n,variant:l,size:i,asChild:s,type:c,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=s,t[5]=c,t[6]=l);let f=s!==void 0&&s,p=f?u:`button`,g;t[7]!==f||t[8]!==c?(g=f?c===void 0?{}:{type:c}:{type:c??`button`},t[7]=f,t[8]=c,t[9]=g):g=t[9];let _=g,v=i!=null&&h.has(i)?`compact`:void 0,y;t[10]!==n||t[11]!==i||t[12]!==l?(y=a(m({variant:l,size:i,className:n})),t[10]=n,t[11]=i,t[12]=l,t[13]=y):y=t[13];let b;return t[14]!==p||t[15]!==v||t[16]!==r||t[17]!==y||t[18]!==_?(b=(0,d.jsx)(p,{"data-slot":`button`,"data-mobile-press-feedback":v,className:y,..._,...r}),t[14]=p,t[15]=v,t[16]=r,t[17]=y,t[18]=_,t[19]=b):b=t[19],b}export{u as n,g as t};
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{Kt as t,Xt as n,qt as r}from"./persistence-DdUac14I.js";import{nt as i,rt as a}from"./vendor-base-ui-CnHfUmDN.js";import{n as o}from"./vendor-react-DLPElpoQ.js";import{a as s,i as c,o as l,t as u}from"./store-BDFdnk6l.js";var d=e(a(),1),f=o(),p=async(e,n)=>{if(!t())throw Error(`Desktop runtime is not available`);return r(e,n)},m=async()=>{if(n())try{await p(`desktop_start_window_drag`)}catch{}},h=async e=>{if(n())try{await p(`desktop_set_window_title`,{title:e})}catch{}},g=async(e,t)=>{if(n())try{await p(`desktop_set_window_theme`,{themeMode:e,themeVariant:t})}catch{}},_=async e=>{if(n())try{await p(`desktop_set_menu_locale`,{locale:e})}catch{}},v=async()=>{if(!n())return null;try{let e=await p(`desktop_get_app_version`);return typeof e==`string`&&e.trim().length>0?e:null}catch{return null}},y=d.createContext(null),b=i(),x=e=>{let t=(0,f.c)(19),{children:n}=e,r=c(S),i=c(C),a=c(w),o=c(T),p,m;t[0]===r?(p=t[1],m=t[2]):(p=()=>{typeof document>`u`||(document.documentElement.lang=r)},m=[r],t[0]=r,t[1]=p,t[2]=m),d.useEffect(p,m);let h,g;t[3]!==a||t[4]!==r?(h=()=>{a===null&&_(r)},g=[r,a],t[3]=a,t[4]=r,t[5]=h,t[6]=g):(h=t[5],g=t[6]),d.useEffect(h,g);let v;t[7]===i?v=t[8]:(v=(e,t)=>u(i,e,t),t[7]=i,t[8]=v);let x=v,E;t[9]===x?E=t[10]:(E=e=>x(l[e]),t[9]=x,t[10]=E);let D;t[11]!==r||t[12]!==o||t[13]!==x||t[14]!==E?(D={locale:r,locales:s,setLocale:o,label:E,t:x},t[11]=r,t[12]=o,t[13]=x,t[14]=E,t[15]=D):D=t[15];let O=D,k;return t[16]!==n||t[17]!==O?(k=(0,b.jsx)(y.Provider,{value:O,children:n}),t[16]=n,t[17]=O,t[18]=k):k=t[18],k};function S(e){return e.locale}function C(e){return e.dictionary}function w(e){return e.loadingLocale}function T(e){return e.setLocale}var E={en:`en-US`,fr:`fr-FR`,"zh-CN":`zh-CN`,"zh-TW":`zh-TW`,uk:`uk-UA`,es:`es-ES`,"pt-BR":`pt-BR`,ko:`ko-KR`,pl:`pl-PL`,ja:`ja-JP`},D=e=>E[e]??`en-US`,O=()=>D(c.getState().locale);function k(){let e=d.useContext(y);if(!e)throw Error(`useI18n must be used within I18nProvider`);return e}async function A(e){let t=null;if(typeof navigator<`u`&&navigator.clipboard?.writeText)try{return await navigator.clipboard.writeText(e),{ok:!0,method:`clipboard`}}catch(e){t=e instanceof Error?e.message:String(e)}if(typeof document<`u`&&document.body){let t=document.createElement(`textarea`);t.value=e,t.setAttribute(`readonly`,``),t.style.position=`fixed`,t.style.top=`-1000px`,t.style.left=`-1000px`,document.body.appendChild(t),t.select(),t.setSelectionRange(0,t.value.length);let n=document.execCommand(`copy`);if(document.body.removeChild(t),n)return{ok:!0,method:`execCommand`}}return{ok:!1,error:t??`Clipboard access denied in current context`}}export{v as a,h as c,x as i,m as l,k as n,p as o,O as r,g as s,A as t};
1
+ import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{Kt as t,Xt as n,qt as r}from"./persistence-YbQKzHUQ.js";import{nt as i,rt as a}from"./vendor-base-ui-CnHfUmDN.js";import{n as o}from"./vendor-react-DLPElpoQ.js";import{a as s,i as c,o as l,t as u}from"./store-CSnH_QXM.js";var d=e(a(),1),f=o(),p=async(e,n)=>{if(!t())throw Error(`Desktop runtime is not available`);return r(e,n)},m=async()=>{if(n())try{await p(`desktop_start_window_drag`)}catch{}},h=async e=>{if(n())try{await p(`desktop_set_window_title`,{title:e})}catch{}},g=async(e,t)=>{if(n())try{await p(`desktop_set_window_theme`,{themeMode:e,themeVariant:t})}catch{}},_=async e=>{if(n())try{await p(`desktop_set_menu_locale`,{locale:e})}catch{}},v=async()=>{if(!n())return null;try{let e=await p(`desktop_get_app_version`);return typeof e==`string`&&e.trim().length>0?e:null}catch{return null}},y=d.createContext(null),b=i(),x=e=>{let t=(0,f.c)(19),{children:n}=e,r=c(S),i=c(C),a=c(w),o=c(T),p,m;t[0]===r?(p=t[1],m=t[2]):(p=()=>{typeof document>`u`||(document.documentElement.lang=r)},m=[r],t[0]=r,t[1]=p,t[2]=m),d.useEffect(p,m);let h,g;t[3]!==a||t[4]!==r?(h=()=>{a===null&&_(r)},g=[r,a],t[3]=a,t[4]=r,t[5]=h,t[6]=g):(h=t[5],g=t[6]),d.useEffect(h,g);let v;t[7]===i?v=t[8]:(v=(e,t)=>u(i,e,t),t[7]=i,t[8]=v);let x=v,E;t[9]===x?E=t[10]:(E=e=>x(l[e]),t[9]=x,t[10]=E);let D;t[11]!==r||t[12]!==o||t[13]!==x||t[14]!==E?(D={locale:r,locales:s,setLocale:o,label:E,t:x},t[11]=r,t[12]=o,t[13]=x,t[14]=E,t[15]=D):D=t[15];let O=D,k;return t[16]!==n||t[17]!==O?(k=(0,b.jsx)(y.Provider,{value:O,children:n}),t[16]=n,t[17]=O,t[18]=k):k=t[18],k};function S(e){return e.locale}function C(e){return e.dictionary}function w(e){return e.loadingLocale}function T(e){return e.setLocale}var E={en:`en-US`,fr:`fr-FR`,"zh-CN":`zh-CN`,"zh-TW":`zh-TW`,uk:`uk-UA`,es:`es-ES`,"pt-BR":`pt-BR`,ko:`ko-KR`,pl:`pl-PL`,ja:`ja-JP`},D=e=>E[e]??`en-US`,O=()=>D(c.getState().locale);function k(){let e=d.useContext(y);if(!e)throw Error(`useI18n must be used within I18nProvider`);return e}async function A(e){let t=null;if(typeof navigator<`u`&&navigator.clipboard?.writeText)try{return await navigator.clipboard.writeText(e),{ok:!0,method:`clipboard`}}catch(e){t=e instanceof Error?e.message:String(e)}if(typeof document<`u`&&document.body){let t=document.createElement(`textarea`);t.value=e,t.setAttribute(`readonly`,``),t.style.position=`fixed`,t.style.top=`-1000px`,t.style.left=`-1000px`,document.body.appendChild(t),t.select(),t.setSelectionRange(0,t.value.length);let n=document.execCommand(`copy`);if(document.body.removeChild(t),n)return{ok:!0,method:`execCommand`}}return{ok:!1,error:t??`Clipboard access denied in current context`}}export{v as a,h as c,x as i,m as l,k as n,p as o,O as r,g as s,A as t};
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{n as t,nt as n,r,rt as i,t as a}from"./vendor-base-ui-CnHfUmDN.js";import{n as o}from"./vendor-react-DLPElpoQ.js";import{t as s}from"./utils-BiK3tBGM.js";var c=o(),l=e(i(),1),u=n(),d=r,f=e=>{let n=(0,c.c)(14),r,i,a,o;n[0]===e?(r=n[1],i=n[2],a=n[3],o=n[4]):({className:a,asChild:r,children:i,...o}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a,n[4]=o);let d;n[5]!==r||n[6]!==i?(d=r&&l.isValidElement(i)?{render:i}:{children:i},n[5]=r,n[6]=i,n[7]=d):d=n[7];let f=d,p;n[8]===a?p=n[9]:(p=s(`flex w-full items-center justify-between rounded-lg px-2 py-1.5 text-left text-foreground hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,a),n[8]=a,n[9]=p);let m;return n[10]!==o||n[11]!==f||n[12]!==p?(m=(0,u.jsx)(t,{className:p,...o,...f}),n[10]=o,n[11]=f,n[12]=p,n[13]=m):m=n[13],m},p=e=>{let t=(0,c.c)(8),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]===n?i=t[4]:(i=s(`overflow-hidden data-[closed]:animate-collapsible-up data-[open]:animate-collapsible-down`,n),t[3]=n,t[4]=i);let o;return t[5]!==r||t[6]!==i?(o=(0,u.jsx)(a,{className:i,...r}),t[5]=r,t[6]=i,t[7]=o):o=t[7],o};export{p as n,f as r,d as t};
1
+ import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{n as t,nt as n,r,rt as i,t as a}from"./vendor-base-ui-CnHfUmDN.js";import{n as o}from"./vendor-react-DLPElpoQ.js";import{t as s}from"./utils-BHTVlVov.js";var c=o(),l=e(i(),1),u=n(),d=r,f=e=>{let n=(0,c.c)(14),r,i,a,o;n[0]===e?(r=n[1],i=n[2],a=n[3],o=n[4]):({className:a,asChild:r,children:i,...o}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a,n[4]=o);let d;n[5]!==r||n[6]!==i?(d=r&&l.isValidElement(i)?{render:i}:{children:i},n[5]=r,n[6]=i,n[7]=d):d=n[7];let f=d,p;n[8]===a?p=n[9]:(p=s(`flex w-full items-center justify-between rounded-lg px-2 py-1.5 text-left text-foreground hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,a),n[8]=a,n[9]=p);let m;return n[10]!==o||n[11]!==f||n[12]!==p?(m=(0,u.jsx)(t,{className:p,...o,...f}),n[10]=o,n[11]=f,n[12]=p,n[13]=m):m=n[13],m},p=e=>{let t=(0,c.c)(8),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]===n?i=t[4]:(i=s(`overflow-hidden data-[closed]:animate-collapsible-up data-[open]:animate-collapsible-down`,n),t[3]=n,t[4]=i);let o;return t[5]!==r||t[6]!==i?(o=(0,u.jsx)(a,{className:i,...r}),t[5]=r,t[6]=i,t[7]=o):o=t[7],o};export{p as n,f as r,d as t};
@@ -1 +1 @@
1
- import"./rolldown-runtime-C0FnF6B9.js";import{E as e,F as t,I as n,N as r,P as i,a,i as o,nt as s,rt as c}from"./vendor-base-ui-CnHfUmDN.js";import{n as l}from"./vendor-react-DLPElpoQ.js";import{t as u}from"./utils-BiK3tBGM.js";import{n as d,r as f,t as p}from"./dropdown-menu.styles-Bzo6L3FH.js";var m=l();c();var h=s();function g(e){let t=(0,m.c)(4),n;t[0]===e?n=t[1]:({...n}=e,t[0]=e,t[1]=n);let r;return t[2]===n?r=t[3]:(r=(0,h.jsx)(a,{...n}),t[2]=n,t[3]=r),r}function _(e){let t=(0,m.c)(4),n;t[0]===e?n=t[1]:({...n}=e,t[0]=e,t[1]=n);let r;return t[2]===n?r=t[3]:(r=(0,h.jsx)(o,{...n}),t[2]=n,t[3]=r),r}function v(e){let n=(0,m.c)(20),a,o,s,c,l;n[0]===e?(a=n[1],o=n[2],s=n[3],c=n[4],l=n[5]):({className:o,positionerClassName:s,children:a,style:l,...c}=e,n[0]=e,n[1]=a,n[2]=o,n[3]=s,n[4]=c,n[5]=l);let f;n[6]===s?f=n[7]:(f=u(`app-region-no-drag z-50`,s),n[6]=s,n[7]=f);let p;n[8]===l?p=n[9]:(p={backgroundColor:`var(--surface-elevated)`,color:`var(--surface-elevated-foreground)`,...l},n[8]=l,n[9]=p);let g;n[10]===o?g=n[11]:(g=u(d,o),n[10]=o,n[11]=g);let _;n[12]!==a||n[13]!==c||n[14]!==p||n[15]!==g?(_=(0,h.jsx)(t,{"data-slot":`dropdown-menu-content`,style:p,className:g,...c,children:a}),n[12]=a,n[13]=c,n[14]=p,n[15]=g,n[16]=_):_=n[16];let v;return n[17]!==f||n[18]!==_?(v=(0,h.jsx)(i,{children:(0,h.jsx)(r,{className:f,children:_})}),n[17]=f,n[18]=_,n[19]=v):v=n[19],v}function y(e){let t=(0,m.c)(8),r,i;t[0]===e?(r=t[1],i=t[2]):({className:r,...i}=e,t[0]=e,t[1]=r,t[2]=i);let a;t[3]===r?a=t[4]:(a=u(p,r),t[3]=r,t[4]=a);let o;return t[5]!==i||t[6]!==a?(o=(0,h.jsx)(n,{className:a,...i}),t[5]=i,t[6]=a,t[7]=o):o=t[7],o}function b(t){let n=(0,m.c)(8),r,i;n[0]===t?(r=n[1],i=n[2]):({className:r,...i}=t,n[0]=t,n[1]=r,n[2]=i);let a;n[3]===r?a=n[4]:(a=u(f,r),n[3]=r,n[4]=a);let o;return n[5]!==i||n[6]!==a?(o=(0,h.jsx)(e,{className:a,...i}),n[5]=i,n[6]=a,n[7]=o):o=n[7],o}export{_ as a,b as i,v as n,y as r,g as t};
1
+ import"./rolldown-runtime-C0FnF6B9.js";import{E as e,F as t,I as n,N as r,P as i,a,i as o,nt as s,rt as c}from"./vendor-base-ui-CnHfUmDN.js";import{n as l}from"./vendor-react-DLPElpoQ.js";import{t as u}from"./utils-BHTVlVov.js";import{n as d,r as f,t as p}from"./dropdown-menu.styles-Bzo6L3FH.js";var m=l();c();var h=s();function g(e){let t=(0,m.c)(4),n;t[0]===e?n=t[1]:({...n}=e,t[0]=e,t[1]=n);let r;return t[2]===n?r=t[3]:(r=(0,h.jsx)(a,{...n}),t[2]=n,t[3]=r),r}function _(e){let t=(0,m.c)(4),n;t[0]===e?n=t[1]:({...n}=e,t[0]=e,t[1]=n);let r;return t[2]===n?r=t[3]:(r=(0,h.jsx)(o,{...n}),t[2]=n,t[3]=r),r}function v(e){let n=(0,m.c)(20),a,o,s,c,l;n[0]===e?(a=n[1],o=n[2],s=n[3],c=n[4],l=n[5]):({className:o,positionerClassName:s,children:a,style:l,...c}=e,n[0]=e,n[1]=a,n[2]=o,n[3]=s,n[4]=c,n[5]=l);let f;n[6]===s?f=n[7]:(f=u(`app-region-no-drag z-50`,s),n[6]=s,n[7]=f);let p;n[8]===l?p=n[9]:(p={backgroundColor:`var(--surface-elevated)`,color:`var(--surface-elevated-foreground)`,...l},n[8]=l,n[9]=p);let g;n[10]===o?g=n[11]:(g=u(d,o),n[10]=o,n[11]=g);let _;n[12]!==a||n[13]!==c||n[14]!==p||n[15]!==g?(_=(0,h.jsx)(t,{"data-slot":`dropdown-menu-content`,style:p,className:g,...c,children:a}),n[12]=a,n[13]=c,n[14]=p,n[15]=g,n[16]=_):_=n[16];let v;return n[17]!==f||n[18]!==_?(v=(0,h.jsx)(i,{children:(0,h.jsx)(r,{className:f,children:_})}),n[17]=f,n[18]=_,n[19]=v):v=n[19],v}function y(e){let t=(0,m.c)(8),r,i;t[0]===e?(r=t[1],i=t[2]):({className:r,...i}=e,t[0]=e,t[1]=r,t[2]=i);let a;t[3]===r?a=t[4]:(a=u(p,r),t[3]=r,t[4]=a);let o;return t[5]!==i||t[6]!==a?(o=(0,h.jsx)(n,{className:a,...i}),t[5]=i,t[6]=a,t[7]=o):o=t[7],o}function b(t){let n=(0,m.c)(8),r,i;n[0]===t?(r=n[1],i=n[2]):({className:r,...i}=t,n[0]=t,n[1]=r,n[2]=i);let a;n[3]===r?a=n[4]:(a=u(f,r),n[3]=r,n[4]=a);let o;return n[5]!==i||n[6]!==a?(o=(0,h.jsx)(e,{className:a,...i}),n[5]=i,n[6]=a,n[7]=o):o=n[7],o}export{_ as a,b as i,v as n,y as r,g as t};
@@ -0,0 +1 @@
1
+ import{E as e}from"./runtime-auth-D66yq6ie.js";import{Kt as t,qt as n}from"./persistence-YbQKzHUQ.js";var r=e=>typeof e==`object`&&!!e,i=e=>e.trim().toLowerCase()===`authorization`,a=e=>{if(!r(e))return;let t={};for(let[n,r]of Object.entries(e)){let e=n.trim(),a=typeof r==`string`?r.trim():``;!e||!a||/[\r\n:]/.test(e)||/[\r\n]/.test(a)||i(e)||(t[e]=a)}return Object.keys(t).length>0?t:void 0},o=`connect-link`,s=(e,t)=>e.source===`connect-link`||e.relay?!0:t.has(e.id),c=(e,t)=>!!(e&&!e.relay&&t.has(e.id)),l=(e,t)=>!t.has(e.id)&&s(e,t),u=e=>`relay://${e}`,d=e=>{if(!r(e))return null;let t=_(e,`relayUrl`)||_(e,`relay_url`),n=_(e,`serverId`)||_(e,`server_id`),i=e.hostEncPubJwk??e.host_enc_pub_jwk;return!t||!n||!r(i)?null:{relayUrl:t,serverId:n,hostEncPubJwk:i}},f=/^(t|.*(?:token|auth|secret|api).*)$/i,p=e=>{let t=e.trim();if(!t)return null;try{let e=new URL(t);return e.protocol!==`http:`&&e.protocol!==`https:`?null:t.split(`#`)[0]||null}catch{return null}},m=e=>{let t=p(e);if(!t)return null;try{let e=new URL(t);if((e.pathname.replace(/\/+$/,``)||`/`)===`/connect`&&e.searchParams.has(`t`))return{persistedUrl:e.origin,redeemUrl:e.toString(),kind:`tunnel-connect-link`}}catch{return null}return{persistedUrl:t,redeemUrl:null,kind:`normal-host`}},h=e=>{let t=p(e);if(!t)return e;try{let e=new URL(t);(e.username||e.password)&&(e.username=``,e.password=``);let n=Array.from(new Set(Array.from(e.searchParams.keys())));for(let t of n)f.test(t)&&e.searchParams.set(t,`[REDACTED]`);return e.toString()}catch{return t}},g=(e,t)=>{let n=p(e),r=p(t);if(!n||!r)return!1;try{let e=new URL(n),t=new URL(r);if(e.origin!==t.origin||t.search&&e.search!==t.search)return!1;let i=t.pathname.length>1?t.pathname.replace(/\/+$/,``):t.pathname,a=e.pathname.length>1?e.pathname.replace(/\/+$/,``):e.pathname;return i===`/`||a===i||a.startsWith(`${i}/`)}catch{return!1}},_=(e,t)=>{let n=e[t];return typeof n==`string`?n:null},v=(e,t)=>{let n=e[t];return typeof n==`number`&&Number.isFinite(n)?n:null},y=e=>{if(!r(e))return null;let t=_(e,`id`),n=_(e,`label`),i=_(e,`url`),s=_(e,`apiUrl`)||_(e,`api_url`),c=_(e,`clientToken`)||_(e,`client_token`),l=a(e.requestHeaders),u=d(e.relay),f=_(e,`source`)===`connect-link`?o:void 0;return!t||!n||!i&&!u?null:{id:t,label:n,url:i||``,...s?{apiUrl:s}:{},...c?{clientToken:c}:{},...l?{requestHeaders:l}:{},...u?{relay:u}:{},...f?{source:f}:{}}},b=e=>p(e.apiUrl||e.url)||e.apiUrl||e.url,x=()=>t()?(e,t)=>n(e,t):null,S=async()=>{let e=x();if(!e)return{hosts:[],defaultHostId:null,initialHostChoiceCompleted:!1};let t=await e(`desktop_hosts_get`);if(!r(t))return{hosts:[],defaultHostId:null,initialHostChoiceCompleted:!1};let n=t.hosts;return{hosts:Array.isArray(n)?n.map(y).filter(e=>!!e):[],defaultHostId:_(t,`defaultHostId`)||_(t,`default_host_id`)||_(t,`defaultHostID`),initialHostChoiceCompleted:t.initialHostChoiceCompleted===!0||t.initial_host_choice_completed===!0,localOrigin:_(t,`localOrigin`)||_(t,`local_origin`)}},C=async e=>{let t=x();if(!t)return;let n={hosts:e.hosts,defaultHostId:e.defaultHostId,initialHostChoiceCompleted:e.initialHostChoiceCompleted};e.localClientToken!==void 0&&(n.localClientToken=e.localClientToken),await t(`desktop_hosts_set`,{input:n})},w=async()=>{let e=x();if(!e)return``;let t=await e(`desktop_local_client_token_get`).catch(()=>null);return typeof t==`string`?t.trim():``},T=async()=>{let e=x();if(!e)return``;let t=await e(`desktop_install_id_get`).catch(()=>null);return typeof t==`string`?t.trim():``},E=8e3,D=async(t,n)=>{let r=e({relayUrl:t.relayUrl,serverId:t.serverId,hostEncPubJwk:t.hostEncPubJwk}),i=Date.now(),a=!1,o;try{let e=await Promise.race([(async()=>{let e=await r.fetch(`/auth/session`,{headers:n?.clientToken?{Authorization:`Bearer ${n.clientToken}`}:{}});return{response:e,payload:e.ok?await e.json().catch(()=>null):null}})(),new Promise(e=>{o=setTimeout(()=>e(null),E)})]),t=e?.response;return t?.status===401||t?.status===403?{status:`auth`,latencyMs:Math.max(0,Date.now()-i)}:t?.ok?e?.payload?.authenticated===!0?(a=n?.keepTunnel===!0,{status:`ok`,latencyMs:Math.max(0,Date.now()-i),...a?{tunnel:r}:{}}):{status:`auth`,latencyMs:Math.max(0,Date.now()-i)}:{status:`unreachable`,latencyMs:0}}catch{return{status:`unreachable`,latencyMs:0}}finally{o!==void 0&&clearTimeout(o),a||r.close()}},O=async(e,t)=>{let n=x();if(!n)return{status:`unreachable`,latencyMs:0};let i=await n(`desktop_host_probe`,{url:e,clientToken:t?.clientToken||void 0,requestHeaders:t?.requestHeaders||void 0,expectedServerId:t?.expectedServerId||void 0});if(!r(i))return{status:`unreachable`,latencyMs:0};let a=i.status;return{status:a===`ok`||a===`auth`||a===`update-recommended`||a===`incompatible`||a===`wrong-service`||a===`unreachable`?a:`unreachable`,latencyMs:v(i,`latencyMs`)??v(i,`latency_ms`)??0}},k=async(e,t)=>{let n=x();n&&await n(`desktop_new_window_at_url`,{url:e,clientToken:t?.clientToken||void 0,requestHeaders:t?.requestHeaders||void 0})},A=async e=>{let t=x();t&&await t(`desktop_new_window_for_host`,{hostId:e})};export{m as _,T as a,A as c,s as d,g as f,u as g,h,C as i,b as l,D as m,O as n,w as o,p,S as r,k as s,o as t,l as u,c as v};
@@ -0,0 +1 @@
1
+ import{b as e}from"./runtime-auth-D66yq6ie.js";import{l as t,r as n}from"./runtime-switch-LvWDU-SL.js";import{n as r}from"./runtime-fetch-zIalUnbb.js";import{Zt as i}from"./persistence-YbQKzHUQ.js";import{i as a,l as o,m as s,n as c,p as l,r as u}from"./desktopHosts-DILvrAok.js";var d=e=>e!==`ok`&&e!==`update-recommended`,f=e=>e.id===`local`?`local`:`host:${e.id}`,p=e=>n()===f(e),m=async(n,r)=>{if(!i())return{ok:!1,status:{status:`unreachable`,latencyMs:0},reason:`unsupported`};let a=l(o(n))||``;if(!a&&!n.relay)return{ok:!1,status:{status:`unreachable`,latencyMs:0},reason:`unreachable`};let u=(r,i)=>{i&&e({relayUrl:r.relayUrl,serverId:r.serverId,hostEncPubJwk:r.hostEncPubJwk},i),t({apiBaseUrl:typeof window<`u`?window.location.origin:``,clientToken:n.clientToken||null,runtimeKey:f(n),relay:r}),b(n.id)},p=e=>{t({apiBaseUrl:e,clientToken:n.clientToken||null,requestHeaders:n.requestHeaders||null,runtimeKey:f(n)})},m={status:`unreachable`,latencyMs:0},h=null,g;if(a){let e=await c(a,{clientToken:n.clientToken||null,requestHeaders:n.requestHeaders||null,expectedServerId:n.relay?.serverId||null}).catch(()=>({status:`unreachable`,latencyMs:0}));m={status:e.status,latencyMs:e.latencyMs},d(e.status)||(h=`direct`)}if(!h&&n.relay){let e=await s(n.relay,{keepTunnel:!0,clientToken:n.clientToken||null}).catch(()=>({status:`unreachable`,latencyMs:0}));e.status===`ok`?(m={status:e.status,latencyMs:e.latencyMs,via:`relay`},h=`relay`,g=`tunnel`in e?e.tunnel:void 0):(!a||e.status===`auth`)&&(m={status:e.status,latencyMs:e.latencyMs})}return h?h===`relay`&&n.relay?(u(n.relay,g),{ok:!0,via:`relay`,status:m}):(p(a),{ok:!0,via:`direct`,status:m}):{ok:!1,status:m,reason:`unreachable`}},h=5e3,g=1500,_=e=>e===`ok`||e===`update-recommended`,v=!1,y=async e=>{if(!i()||v)return;let o=`host:${e}`;if(n()===o){v=!0;try{let i=await u().catch(()=>null),s=i?.hosts.find(t=>t.id===e);if(!i||!s?.relay)return;let d=s.apiUrl?l(s.apiUrl):null;if(d&&d.startsWith(`https://`))return;let f=await r(`/api/client-auth/connection/candidates`).catch(()=>null);if(!f?.ok)return;let p=await f.json().catch(()=>null);if(!p||p.serverId!==s.relay.serverId)return;let m=Array.isArray(p.candidates)?p.candidates:[],h=[];for(let e of m){if(!e||typeof e!=`object`)continue;let t=e;if(t.type!==`lan`||typeof t.url!=`string`)continue;let n=l(t.url);n&&!h.includes(n)&&h.push(n)}if(h.length===0)return;let g=d&&h.includes(d)?d:h[0];if(g!==d&&await a({hosts:i.hosts.map(t=>t.id===e?{...t,apiUrl:g}:t),defaultHostId:i.defaultHostId,initialHostChoiceCompleted:i.initialHostChoiceCompleted}).catch(()=>void 0),!_((await c(g,{clientToken:s.clientToken||null,requestHeaders:s.requestHeaders||null,expectedServerId:s.relay.serverId}).catch(()=>({status:`unreachable`,latencyMs:0}))).status)||n()!==o)return;t({apiBaseUrl:g,clientToken:s.clientToken||null,requestHeaders:s.requestHeaders||null,runtimeKey:o})}finally{v=!1}}},b=e=>{typeof window>`u`||window.setTimeout(()=>{y(e).catch(()=>void 0)},h)},x=async e=>{if(!i())return;let r=await u().catch(()=>null);if(!r)return;let a=e||(r.defaultHostId===`local`?null:r.defaultHostId);if(!a)return;let s=r.hosts.find(e=>e.id===a);if(!s?.relay)return;let d=f(s);if(n()===d)return;let p=e=>{t({apiBaseUrl:e,clientToken:s.clientToken||null,requestHeaders:s.requestHeaders||null,runtimeKey:d})},m=()=>{t({apiBaseUrl:typeof window<`u`?window.location.origin:``,clientToken:s.clientToken||null,runtimeKey:d,relay:s.relay??void 0}),b(s.id)},h=s.apiUrl?l(o(s)):null;if(!h){m();return}let v=e=>_(e.status),y=c(h,{clientToken:s.clientToken||null,requestHeaders:s.requestHeaders||null,expectedServerId:s.relay.serverId}).catch(()=>({status:`unreachable`,latencyMs:0})),x=await Promise.race([y,new Promise(e=>setTimeout(()=>e(null),g))]);if(x){if(v(x)){p(h);return}m();return}m(),y.then(e=>{v(e)&&n()===d&&p(h)})};export{m as i,p as n,f as r,x as t};
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{nt as t,rt as n}from"./vendor-base-ui-CnHfUmDN.js";import{t as r}from"./utils-BiK3tBGM.js";import{t as i}from"./vendor-react-drawio-ECtEwvbc.js";var a=e(n(),1),o=t(),s=`<mxfile><diagram id="new" name="Page-1"><mxGraphModel dx="0" dy="0" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="827" pageHeight="1169" math="0" shadow="0"><root><mxCell id="0"/><mxCell id="1" parent="0"/></root></mxGraphModel></diagram></mxfile>`;function c(){if(typeof document>`u`)return!1;let e=document.documentElement.getAttribute(`data-theme`);return e===`dark`||!e&&window.matchMedia(`(prefers-color-scheme: dark)`).matches}var l=a.forwardRef(function({xml:e,readOnly:t,className:n,onChange:l},u){let d=a.useRef(e),f=a.useRef(null),p=a.useRef(!1),[m,h]=a.useState(c),g=a.useRef(e),_=a.useRef(e);_.current!==e&&(_.current=e,g.current=e,d.current=e);let v=a.useRef(m);v.current!==m&&(v.current=m,g.current=d.current);let y=a.useRef(null);a.useEffect(()=>{let e=()=>h(c());e();let t=new MutationObserver(e);return t.observe(document.documentElement,{attributes:!0,attributeFilter:[`data-theme`]}),()=>t.disconnect()},[]),a.useEffect(()=>{let e=setTimeout(()=>{y.current?.querySelector(`.diagrams-iframe`)?.focus()},600);return()=>clearTimeout(e)},[]),a.useImperativeHandle(u,()=>({getXml:()=>d.current}));let b=a.useCallback(()=>{!e&&!p.current&&(p.current=!0,setTimeout(()=>{f.current?.template({})},500))},[e]),x=a.useCallback(e=>{d.current=e.xml,l?.(e.xml)},[l]);return(0,o.jsx)(`div`,{ref:y,className:r(`h-full w-full`,n),children:(0,o.jsx)(i,{ref:f,xml:g.current||s,autosave:!0,urlParameters:{ui:t?`simple`:m?`dark`:`kennedy`,spin:!0,libraries:!t,chrome:t,nav:t,layers:t,noSaveBtn:!0,noExitBtn:!0,saveAndExit:!1},onLoad:b,onAutoSave:x},m?`dark`:`light`)})});export{l as t};
1
+ import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{nt as t,rt as n}from"./vendor-base-ui-CnHfUmDN.js";import{t as r}from"./utils-BHTVlVov.js";import{t as i}from"./vendor-react-drawio-ECtEwvbc.js";var a=e(n(),1),o=t(),s=`<mxfile><diagram id="new" name="Page-1"><mxGraphModel dx="0" dy="0" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="827" pageHeight="1169" math="0" shadow="0"><root><mxCell id="0"/><mxCell id="1" parent="0"/></root></mxGraphModel></diagram></mxfile>`;function c(){if(typeof document>`u`)return!1;let e=document.documentElement.getAttribute(`data-theme`);return e===`dark`||!e&&window.matchMedia(`(prefers-color-scheme: dark)`).matches}var l=a.forwardRef(function({xml:e,readOnly:t,className:n,onChange:l},u){let d=a.useRef(e),f=a.useRef(null),p=a.useRef(!1),[m,h]=a.useState(c),g=a.useRef(e),_=a.useRef(e);_.current!==e&&(_.current=e,g.current=e,d.current=e);let v=a.useRef(m);v.current!==m&&(v.current=m,g.current=d.current);let y=a.useRef(null);a.useEffect(()=>{let e=()=>h(c());e();let t=new MutationObserver(e);return t.observe(document.documentElement,{attributes:!0,attributeFilter:[`data-theme`]}),()=>t.disconnect()},[]),a.useEffect(()=>{let e=setTimeout(()=>{y.current?.querySelector(`.diagrams-iframe`)?.focus()},600);return()=>clearTimeout(e)},[]),a.useImperativeHandle(u,()=>({getXml:()=>d.current}));let b=a.useCallback(()=>{!e&&!p.current&&(p.current=!0,setTimeout(()=>{f.current?.template({})},500))},[e]),x=a.useCallback(e=>{d.current=e.xml,l?.(e.xml)},[l]);return(0,o.jsx)(`div`,{ref:y,className:r(`h-full w-full`,n),children:(0,o.jsx)(i,{ref:f,xml:g.current||s,autosave:!0,urlParameters:{ui:t?`simple`:m?`dark`:`kennedy`,spin:!0,libraries:!t,chrome:t,nav:t,layers:t,noSaveBtn:!0,noExitBtn:!0,saveAndExit:!1},onLoad:b,onAutoSave:x},m?`dark`:`light`)})});export{l as t};