@alivault/pico 0.14.0 → 0.16.1

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 (703) hide show
  1. package/.output/public/_shell.html +19 -0
  2. package/.output/public/assets/PatchDiff-SN-mXa3p.js +343 -0
  3. package/.output/public/assets/{angular-html-BZNntD0J.js → angular-html-B9LEBPKs.js} +1 -1
  4. package/.output/public/assets/{angular-ts-SQQMYL2C.js → angular-ts-CD6u-Ij9.js} +1 -1
  5. package/.output/public/assets/{apl-D5V6uPDr.js → apl-VeDHIFIx.js} +1 -1
  6. package/.output/public/assets/app-shell-common-0xa28gDm.js +1 -0
  7. package/.output/public/assets/{astro-DeXKSaFP.js → astro-Dd8L1z6M.js} +1 -1
  8. package/.output/public/assets/{blade-Bu5re0Vg.js → blade-BNxrbiva.js} +1 -1
  9. package/.output/public/assets/{bsl-B1qbqNES.js → bsl-B0twaj2j.js} +1 -1
  10. package/.output/public/assets/{cairo-BDj8wWhy.js → cairo-DASKFAWI.js} +1 -1
  11. package/.output/public/assets/{cobol-nvZDS9LT.js → cobol-D_qN8j4K.js} +1 -1
  12. package/.output/public/assets/{coffee-BKLOTq4e.js → coffee-60nIQewd.js} +1 -1
  13. package/.output/public/assets/{cpp-D6g1DVNt.js → cpp-e1j1tDCV.js} +1 -1
  14. package/.output/public/assets/{crystal-DfoZI57w.js → crystal-brDfRjQ_.js} +1 -1
  15. package/.output/public/assets/{edge-DwocGnOF.js → edge-DadfRK3Q.js} +1 -1
  16. package/.output/public/assets/{elixir-Dtbfds1r.js → elixir-CsoHPmz3.js} +1 -1
  17. package/.output/public/assets/{elm-CpPtm471.js → elm-BLTa0sZG.js} +1 -1
  18. package/.output/public/assets/{erb--z3IM9Cb.js → erb-DIR2QRkp.js} +1 -1
  19. package/.output/public/assets/{erlang-Bc4hQuqa.js → erlang-DnbJbitJ.js} +1 -1
  20. package/.output/public/assets/{fortran-fixed-form-B02FOYI-.js → fortran-fixed-form-Bse4XUyD.js} +1 -1
  21. package/.output/public/assets/{fsharp-DhdR18vN.js → fsharp-Dy8OnZ0O.js} +1 -1
  22. package/.output/public/assets/{gdresource-DgnrMPIx.js → gdresource-BD_7yRHA.js} +1 -1
  23. package/.output/public/assets/{git-commit-DGJi7qBD.js → git-commit-CIMjlyHf.js} +1 -1
  24. package/.output/public/assets/{git-rebase-Ce47xoa6.js → git-rebase-DV2DyQK7.js} +1 -1
  25. package/.output/public/assets/{glimmer-js-C0BuzxQC.js → glimmer-js-DVG5pFvd.js} +1 -1
  26. package/.output/public/assets/{glimmer-ts-irOZ-cAQ.js → glimmer-ts-BeWaLARz.js} +1 -1
  27. package/.output/public/assets/{glsl-JAhLUe0P.js → glsl-BrOWUUEh.js} +1 -1
  28. package/.output/public/assets/{graphql-D2ba3BkR.js → graphql-B_3o81z5.js} +1 -1
  29. package/.output/public/assets/{hack-CgzUpY8l.js → hack-BW-0PxQy.js} +1 -1
  30. package/.output/public/assets/{haml-C-oIZcDo.js → haml-DnNXiHAO.js} +1 -1
  31. package/.output/public/assets/{handlebars-CbP-Mhzf.js → handlebars-CftcPtku.js} +1 -1
  32. package/.output/public/assets/{html-ddqpqPg0.js → html-D5IqfVuz.js} +1 -1
  33. package/.output/public/assets/{html-derivative-DWGxf_At.js → html-derivative-QNqmMkaY.js} +1 -1
  34. package/.output/public/assets/{http-Bg1nG1nG.js → http-Dd7eRKUa.js} +1 -1
  35. package/.output/public/assets/{hurl-zm47Pi1n.js → hurl-kBs5Ibg1.js} +1 -1
  36. package/.output/public/assets/{hxml-adC65L_J.js → hxml-CGx66ebi.js} +1 -1
  37. package/.output/public/assets/index-C-mxWGZ5.css +2 -0
  38. package/.output/public/assets/index-FOqZaR4L.js +48 -0
  39. package/.output/public/assets/{jinja-Bnj4awH5.js → jinja-BPoCSjyd.js} +1 -1
  40. package/.output/public/assets/{jison-CuCNs9Q3.js → jison-WHPVy3Jl.js} +1 -1
  41. package/.output/public/assets/{julia-DNYHzXlE.js → julia-BaKiQMPf.js} +1 -1
  42. package/.output/public/assets/{just-BlWkkmf2.js → just-BKMc7tVT.js} +1 -1
  43. package/.output/public/assets/{latex-DqPzjMIt.js → latex-Cczzu1HI.js} +1 -1
  44. package/.output/public/assets/{liquid-BURJK16h.js → liquid-DrJZrMEf.js} +1 -1
  45. package/.output/public/assets/{lua-31hdJClp.js → lua-CFIwCMnP.js} +1 -1
  46. package/.output/public/assets/{marko-C2ZcdSLh.js → marko-BreagErn.js} +1 -1
  47. package/.output/public/assets/{mdc-N1ii9pk5.js → mdc-CBcMHZUq.js} +1 -1
  48. package/.output/public/assets/{nextflow-JEyYUlIq.js → nextflow-CZbrTmS2.js} +1 -1
  49. package/.output/public/assets/{nginx-BuomO0W8.js → nginx-CMOi8dTH.js} +1 -1
  50. package/.output/public/assets/{nim-hKoEPsYL.js → nim-DbDZ9Wa-.js} +1 -1
  51. package/.output/public/assets/{perl-CAGVW6Ra.js → perl-DyRCGnKu.js} +1 -1
  52. package/.output/public/assets/{php-BycclmzS.js → php-Ciarv7b4.js} +1 -1
  53. package/.output/public/assets/plus-B1rJPgNv.js +1 -0
  54. package/.output/public/assets/preload-helper-Csz9R64u.js +5 -0
  55. package/.output/public/assets/{pug-4maJHz9G.js → pug-CVCqbfEm.js} +1 -1
  56. package/.output/public/assets/{qml-JLIQfzyb.js → qml-DechmdFA.js} +1 -1
  57. package/.output/public/assets/query-keys-C9jMaRnO.js +1 -0
  58. package/.output/public/assets/{razor-P8rbooCh.js → razor-bgzHke67.js} +1 -1
  59. package/.output/public/assets/right-sidebar-CWvXcZzC.js +1831 -0
  60. package/.output/public/assets/routes-CXlaorp4.js +23 -0
  61. package/.output/public/assets/{rst-C6GHyL-N.js → rst-Ce6_XwFd.js} +1 -1
  62. package/.output/public/assets/{ruby-Cl8PVkbY.js → ruby-BtLKlt8E.js} +1 -1
  63. package/.output/public/assets/{sas-CXoVwlZN.js → sas-Bco5tnse.js} +1 -1
  64. package/.output/public/assets/{scss-DNczJ95n.js → scss-KPCA05M8.js} +1 -1
  65. package/.output/public/assets/{shaderlab-DZ3Lsiak.js → shaderlab-uUHiM5Mm.js} +1 -1
  66. package/.output/public/assets/{shellsession-COm1V40U.js → shellsession-BnUZVYXU.js} +1 -1
  67. package/.output/public/assets/{soy-DwewhJ_3.js → soy-Dsrg4bVI.js} +1 -1
  68. package/.output/public/assets/{sparql-B9c85a_o.js → sparql-D5zsvcbT.js} +1 -1
  69. package/.output/public/assets/{stata-Bl--TAbZ.js → stata-BdK5CFUf.js} +1 -1
  70. package/.output/public/assets/{surrealql-BW79EE-U.js → surrealql-Blm5wp47.js} +1 -1
  71. package/.output/public/assets/{svelte-ziMErdPi.js → svelte-DZrj_gMz.js} +1 -1
  72. package/.output/public/assets/{templ-C_9I6ncv.js → templ-CJ7sDrtu.js} +1 -1
  73. package/.output/public/assets/terminal-panel-YGR6v-ZH.js +1 -0
  74. package/.output/public/assets/{tex-D8LVuLf5.js → tex-CvSRdXZA.js} +1 -1
  75. package/.output/public/assets/{ts-tags-DKuFCGsc.js → ts-tags-DgGFCSef.js} +1 -1
  76. package/.output/public/assets/{twig-Bs1kcsO6.js → twig-D8_PS89g.js} +1 -1
  77. package/.output/public/assets/{vue-Dnf0y5RU.js → vue-KvGEuYod.js} +1 -1
  78. package/.output/public/assets/{vue-html-CRtKS76J.js → vue-html-qAt9D-IF.js} +1 -1
  79. package/.output/public/assets/{vue-vine-BxjPqU7T.js → vue-vine-j1nOqxMu.js} +1 -1
  80. package/.output/public/assets/{xml-eU7M3iZJ.js → xml-BrFkMwfd.js} +1 -1
  81. package/.output/public/assets/{xsl-DSqe4nTO.js → xsl-OmCo2PyZ.js} +1 -1
  82. package/.output/public/index.html +19 -0
  83. package/README.md +171 -46
  84. package/bin/native-runtime.mjs +265 -0
  85. package/bin/pico.mjs +289 -222
  86. package/package.json +34 -31
  87. package/.output/nitro.json +0 -17
  88. package/.output/public/assets/index-DBVxXDtw.js +0 -54
  89. package/.output/public/assets/routes-yUxD2q-l.js +0 -2194
  90. package/.output/public/assets/styles-CUVz7jV9.css +0 -2
  91. package/.output/server/__23tanstack-start-plugin-adapters-y_fshQDY.mjs +0 -5
  92. package/.output/server/_chunks/ssr-renderer.mjs +0 -15
  93. package/.output/server/_libs/@base-ui/react+[...].mjs +0 -14512
  94. package/.output/server/_libs/@dnd-kit/core+[...].mjs +0 -2748
  95. package/.output/server/_libs/@pierre/diffs+[...].mjs +0 -19314
  96. package/.output/server/_libs/@pierre/trees+[...].mjs +0 -9236
  97. package/.output/server/_libs/@radix-ui/react-dialog+[...].mjs +0 -1789
  98. package/.output/server/_libs/@radix-ui/react-primitive+[...].mjs +0 -136
  99. package/.output/server/_libs/@tanstack/devtools-event-client+[...].mjs +0 -196
  100. package/.output/server/_libs/@tanstack/hotkeys+[...].mjs +0 -1607
  101. package/.output/server/_libs/@tanstack/react-router+[...].mjs +0 -13950
  102. package/.output/server/_libs/@tanstack/react-router-ssr-query+[...].mjs +0 -90
  103. package/.output/server/_libs/bail.mjs +0 -13
  104. package/.output/server/_libs/character-entities.mjs +0 -2135
  105. package/.output/server/_libs/class-variance-authority+clsx.mjs +0 -69
  106. package/.output/server/_libs/cmdk.mjs +0 -473
  107. package/.output/server/_libs/crossws.mjs +0 -2929
  108. package/.output/server/_libs/decode-named-character-reference+[...].mjs +0 -19
  109. package/.output/server/_libs/devlop.mjs +0 -5
  110. package/.output/server/_libs/diff.mjs +0 -732
  111. package/.output/server/_libs/dnd-kit__accessibility.mjs +0 -46
  112. package/.output/server/_libs/dnd-kit__sortable.mjs +0 -400
  113. package/.output/server/_libs/entities.mjs +0 -372
  114. package/.output/server/_libs/escape-string-regexp.mjs +0 -7
  115. package/.output/server/_libs/estree-util-is-identifier-name.mjs +0 -20
  116. package/.output/server/_libs/extend.mjs +0 -75
  117. package/.output/server/_libs/h3+rou3+srvx.mjs +0 -1216
  118. package/.output/server/_libs/hast-util-from-parse5+[...].mjs +0 -741
  119. package/.output/server/_libs/hast-util-raw+[...].mjs +0 -7897
  120. package/.output/server/_libs/hast-util-sanitize.mjs +0 -780
  121. package/.output/server/_libs/hast-util-to-jsx-runtime+[...].mjs +0 -1165
  122. package/.output/server/_libs/hookable.mjs +0 -41
  123. package/.output/server/_libs/html-url-attributes.mjs +0 -44
  124. package/.output/server/_libs/is-plain-obj.mjs +0 -8
  125. package/.output/server/_libs/longest-streak.mjs +0 -29
  126. package/.output/server/_libs/lucide-react.mjs +0 -788
  127. package/.output/server/_libs/markdown-table.mjs +0 -289
  128. package/.output/server/_libs/mdast-util-find-and-replace.mjs +0 -198
  129. package/.output/server/_libs/mdast-util-from-markdown+[...].mjs +0 -8409
  130. package/.output/server/_libs/mdast-util-gfm+[...].mjs +0 -2062
  131. package/.output/server/_libs/mdast-util-to-hast+[...].mjs +0 -1771
  132. package/.output/server/_libs/micromark-extension-gfm+[...].mjs +0 -2234
  133. package/.output/server/_libs/next-themes.mjs +0 -124
  134. package/.output/server/_libs/pierre__theme.mjs +0 -10
  135. package/.output/server/_libs/radix-ui__primitive.mjs +0 -9
  136. package/.output/server/_libs/radix-ui__react-compose-refs.mjs +0 -30
  137. package/.output/server/_libs/radix-ui__react-context.mjs +0 -88
  138. package/.output/server/_libs/react-markdown+[...].mjs +0 -2316
  139. package/.output/server/_libs/rehype-raw.mjs +0 -37
  140. package/.output/server/_libs/rehype-sanitize.mjs +0 -27
  141. package/.output/server/_libs/remark-gfm.mjs +0 -34
  142. package/.output/server/_libs/shiki.mjs +0 -16
  143. package/.output/server/_libs/shikijs__langs.mjs +0 -1355
  144. package/.output/server/_libs/shikijs__themes.mjs +0 -262
  145. package/.output/server/_libs/sonner.mjs +0 -908
  146. package/.output/server/_libs/tailwind-merge.mjs +0 -1962
  147. package/.output/server/_libs/tanstack__history.mjs +0 -342
  148. package/.output/server/_libs/tanstack__pacer.mjs +0 -1111
  149. package/.output/server/_libs/tanstack__query-core.mjs +0 -2202
  150. package/.output/server/_libs/tanstack__react-hotkeys.mjs +0 -152
  151. package/.output/server/_libs/tanstack__react-query.mjs +0 -180
  152. package/.output/server/_libs/tanstack__react-store.mjs +0 -39
  153. package/.output/server/_libs/tanstack__router-core.mjs +0 -6
  154. package/.output/server/_libs/tanstack__store.mjs +0 -28
  155. package/.output/server/_libs/ufo.mjs +0 -64
  156. package/.output/server/_libs/unctx.mjs +0 -82
  157. package/.output/server/_libs/ungap__structured-clone.mjs +0 -197
  158. package/.output/server/_libs/vaul.mjs +0 -1250
  159. package/.output/server/_libs/xterm__addon-fit.mjs +0 -44
  160. package/.output/server/_libs/xterm__xterm.mjs +0 -10234
  161. package/.output/server/_libs/zod.mjs +0 -3341
  162. package/.output/server/_routes/api/terminal/[id]/ws.mjs +0 -8874
  163. package/.output/server/_runtime.mjs +0 -35
  164. package/.output/server/_ssr/router-CN4JMm2A.mjs +0 -9733
  165. package/.output/server/_ssr/routes-BsQ26pbY.mjs +0 -29306
  166. package/.output/server/_ssr/routes-DbjuMLFI.mjs +0 -3400
  167. package/.output/server/_ssr/ssr.mjs +0 -5176
  168. package/.output/server/_ssr/start-jIczsXlR.mjs +0 -4
  169. package/.output/server/_tanstack-start-manifest_v-Bs4g_j1_.mjs +0 -77
  170. package/.output/server/index.mjs +0 -2670
  171. package/.output/server/node_modules/node-pty/LICENSE +0 -69
  172. package/.output/server/node_modules/node-pty/README.md +0 -165
  173. package/.output/server/node_modules/node-pty/binding.gyp +0 -111
  174. package/.output/server/node_modules/node-pty/build/Makefile +0 -369
  175. package/.output/server/node_modules/node-pty/build/Release/pty.node +0 -0
  176. package/.output/server/node_modules/node-pty/build/binding.Makefile +0 -6
  177. package/.output/server/node_modules/node-pty/build/pty.target.mk +0 -168
  178. package/.output/server/node_modules/node-pty/deps/.editorconfig +0 -2
  179. package/.output/server/node_modules/node-pty/deps/winpty/.drone.yml +0 -17
  180. package/.output/server/node_modules/node-pty/deps/winpty/.gitattributes +0 -19
  181. package/.output/server/node_modules/node-pty/deps/winpty/LICENSE +0 -21
  182. package/.output/server/node_modules/node-pty/deps/winpty/Makefile +0 -166
  183. package/.output/server/node_modules/node-pty/deps/winpty/README.md +0 -151
  184. package/.output/server/node_modules/node-pty/deps/winpty/RELEASES.md +0 -280
  185. package/.output/server/node_modules/node-pty/deps/winpty/VERSION.txt +0 -1
  186. package/.output/server/node_modules/node-pty/deps/winpty/configure +0 -167
  187. package/.output/server/node_modules/node-pty/deps/winpty/misc/BufferResizeTests.cc +0 -90
  188. package/.output/server/node_modules/node-pty/deps/winpty/misc/ChangeScreenBuffer.cc +0 -53
  189. package/.output/server/node_modules/node-pty/deps/winpty/misc/ClearConsole.cc +0 -72
  190. package/.output/server/node_modules/node-pty/deps/winpty/misc/ConinMode.cc +0 -117
  191. package/.output/server/node_modules/node-pty/deps/winpty/misc/ConinMode.ps1 +0 -116
  192. package/.output/server/node_modules/node-pty/deps/winpty/misc/ConoutMode.cc +0 -113
  193. package/.output/server/node_modules/node-pty/deps/winpty/misc/DebugClient.py +0 -42
  194. package/.output/server/node_modules/node-pty/deps/winpty/misc/DebugServer.py +0 -63
  195. package/.output/server/node_modules/node-pty/deps/winpty/misc/DumpLines.py +0 -5
  196. package/.output/server/node_modules/node-pty/deps/winpty/misc/EnableExtendedFlags.txt +0 -46
  197. package/.output/server/node_modules/node-pty/deps/winpty/misc/Font-Report-June2016/CP437-Consolas.txt +0 -528
  198. package/.output/server/node_modules/node-pty/deps/winpty/misc/Font-Report-June2016/CP437-Lucida.txt +0 -633
  199. package/.output/server/node_modules/node-pty/deps/winpty/misc/Font-Report-June2016/CP932.txt +0 -630
  200. package/.output/server/node_modules/node-pty/deps/winpty/misc/Font-Report-June2016/CP936.txt +0 -630
  201. package/.output/server/node_modules/node-pty/deps/winpty/misc/Font-Report-June2016/CP949.txt +0 -630
  202. package/.output/server/node_modules/node-pty/deps/winpty/misc/Font-Report-June2016/CP950.txt +0 -630
  203. package/.output/server/node_modules/node-pty/deps/winpty/misc/Font-Report-June2016/MinimumWindowWidths.txt +0 -16
  204. package/.output/server/node_modules/node-pty/deps/winpty/misc/Font-Report-June2016/Results.txt +0 -4
  205. package/.output/server/node_modules/node-pty/deps/winpty/misc/Font-Report-June2016/Windows10SetFontBugginess.txt +0 -144
  206. package/.output/server/node_modules/node-pty/deps/winpty/misc/FontSurvey.cc +0 -100
  207. package/.output/server/node_modules/node-pty/deps/winpty/misc/FormatChar.h +0 -21
  208. package/.output/server/node_modules/node-pty/deps/winpty/misc/FreezePerfTest.cc +0 -62
  209. package/.output/server/node_modules/node-pty/deps/winpty/misc/GetCh.cc +0 -20
  210. package/.output/server/node_modules/node-pty/deps/winpty/misc/GetConsolePos.cc +0 -41
  211. package/.output/server/node_modules/node-pty/deps/winpty/misc/GetFont.cc +0 -261
  212. package/.output/server/node_modules/node-pty/deps/winpty/misc/IdentifyConsoleWindow.ps1 +0 -51
  213. package/.output/server/node_modules/node-pty/deps/winpty/misc/IsNewConsole.cc +0 -87
  214. package/.output/server/node_modules/node-pty/deps/winpty/misc/MouseInputNotes.txt +0 -90
  215. package/.output/server/node_modules/node-pty/deps/winpty/misc/MoveConsoleWindow.cc +0 -34
  216. package/.output/server/node_modules/node-pty/deps/winpty/misc/Notes.txt +0 -219
  217. package/.output/server/node_modules/node-pty/deps/winpty/misc/OSVersion.cc +0 -27
  218. package/.output/server/node_modules/node-pty/deps/winpty/misc/ScreenBufferFreezeInactive.cc +0 -101
  219. package/.output/server/node_modules/node-pty/deps/winpty/misc/ScreenBufferTest.cc +0 -671
  220. package/.output/server/node_modules/node-pty/deps/winpty/misc/ScreenBufferTest2.cc +0 -151
  221. package/.output/server/node_modules/node-pty/deps/winpty/misc/SelectAllTest.cc +0 -45
  222. package/.output/server/node_modules/node-pty/deps/winpty/misc/SetBufferSize.cc +0 -32
  223. package/.output/server/node_modules/node-pty/deps/winpty/misc/SetCursorPos.cc +0 -10
  224. package/.output/server/node_modules/node-pty/deps/winpty/misc/SetFont.cc +0 -145
  225. package/.output/server/node_modules/node-pty/deps/winpty/misc/SetWindowRect.cc +0 -36
  226. package/.output/server/node_modules/node-pty/deps/winpty/misc/ShowArgv.cc +0 -12
  227. package/.output/server/node_modules/node-pty/deps/winpty/misc/ShowConsoleInput.cc +0 -40
  228. package/.output/server/node_modules/node-pty/deps/winpty/misc/Spew.py +0 -5
  229. package/.output/server/node_modules/node-pty/deps/winpty/misc/TestUtil.cc +0 -172
  230. package/.output/server/node_modules/node-pty/deps/winpty/misc/UnicodeDoubleWidthTest.cc +0 -102
  231. package/.output/server/node_modules/node-pty/deps/winpty/misc/UnicodeWideTest1.cc +0 -246
  232. package/.output/server/node_modules/node-pty/deps/winpty/misc/UnicodeWideTest2.cc +0 -130
  233. package/.output/server/node_modules/node-pty/deps/winpty/misc/UnixEcho.cc +0 -89
  234. package/.output/server/node_modules/node-pty/deps/winpty/misc/Utf16Echo.cc +0 -46
  235. package/.output/server/node_modules/node-pty/deps/winpty/misc/VeryLargeRead.cc +0 -122
  236. package/.output/server/node_modules/node-pty/deps/winpty/misc/VkEscapeTest.cc +0 -56
  237. package/.output/server/node_modules/node-pty/deps/winpty/misc/Win10ResizeWhileFrozen.cc +0 -52
  238. package/.output/server/node_modules/node-pty/deps/winpty/misc/Win10WrapTest1.cc +0 -57
  239. package/.output/server/node_modules/node-pty/deps/winpty/misc/Win10WrapTest2.cc +0 -30
  240. package/.output/server/node_modules/node-pty/deps/winpty/misc/Win32Echo1.cc +0 -26
  241. package/.output/server/node_modules/node-pty/deps/winpty/misc/Win32Echo2.cc +0 -19
  242. package/.output/server/node_modules/node-pty/deps/winpty/misc/Win32Test1.cc +0 -46
  243. package/.output/server/node_modules/node-pty/deps/winpty/misc/Win32Test2.cc +0 -70
  244. package/.output/server/node_modules/node-pty/deps/winpty/misc/Win32Test3.cc +0 -78
  245. package/.output/server/node_modules/node-pty/deps/winpty/misc/Win32Write1.cc +0 -44
  246. package/.output/server/node_modules/node-pty/deps/winpty/misc/WindowsBugCrashReader.cc +0 -27
  247. package/.output/server/node_modules/node-pty/deps/winpty/misc/WriteConsole.cc +0 -106
  248. package/.output/server/node_modules/node-pty/deps/winpty/misc/build32.sh +0 -9
  249. package/.output/server/node_modules/node-pty/deps/winpty/misc/build64.sh +0 -9
  250. package/.output/server/node_modules/node-pty/deps/winpty/misc/color-test.sh +0 -212
  251. package/.output/server/node_modules/node-pty/deps/winpty/misc/font-notes.txt +0 -300
  252. package/.output/server/node_modules/node-pty/deps/winpty/misc/winbug-15048.cc +0 -201
  253. package/.output/server/node_modules/node-pty/deps/winpty/ship/build-pty4j-libpty.bat +0 -36
  254. package/.output/server/node_modules/node-pty/deps/winpty/ship/common_ship.py +0 -53
  255. package/.output/server/node_modules/node-pty/deps/winpty/ship/make_msvc_package.py +0 -165
  256. package/.output/server/node_modules/node-pty/deps/winpty/ship/ship.py +0 -108
  257. package/.output/server/node_modules/node-pty/deps/winpty/src/agent/Agent.cc +0 -613
  258. package/.output/server/node_modules/node-pty/deps/winpty/src/agent/Agent.h +0 -103
  259. package/.output/server/node_modules/node-pty/deps/winpty/src/agent/AgentCreateDesktop.cc +0 -84
  260. package/.output/server/node_modules/node-pty/deps/winpty/src/agent/AgentCreateDesktop.h +0 -28
  261. package/.output/server/node_modules/node-pty/deps/winpty/src/agent/ConsoleFont.cc +0 -632
  262. package/.output/server/node_modules/node-pty/deps/winpty/src/agent/ConsoleFont.h +0 -28
  263. package/.output/server/node_modules/node-pty/deps/winpty/src/agent/ConsoleInput.cc +0 -852
  264. package/.output/server/node_modules/node-pty/deps/winpty/src/agent/ConsoleInput.h +0 -109
  265. package/.output/server/node_modules/node-pty/deps/winpty/src/agent/ConsoleInputReencoding.cc +0 -121
  266. package/.output/server/node_modules/node-pty/deps/winpty/src/agent/ConsoleInputReencoding.h +0 -36
  267. package/.output/server/node_modules/node-pty/deps/winpty/src/agent/ConsoleLine.cc +0 -152
  268. package/.output/server/node_modules/node-pty/deps/winpty/src/agent/ConsoleLine.h +0 -41
  269. package/.output/server/node_modules/node-pty/deps/winpty/src/agent/Coord.h +0 -87
  270. package/.output/server/node_modules/node-pty/deps/winpty/src/agent/DebugShowInput.cc +0 -239
  271. package/.output/server/node_modules/node-pty/deps/winpty/src/agent/DebugShowInput.h +0 -32
  272. package/.output/server/node_modules/node-pty/deps/winpty/src/agent/DefaultInputMap.cc +0 -422
  273. package/.output/server/node_modules/node-pty/deps/winpty/src/agent/DefaultInputMap.h +0 -28
  274. package/.output/server/node_modules/node-pty/deps/winpty/src/agent/DsrSender.h +0 -30
  275. package/.output/server/node_modules/node-pty/deps/winpty/src/agent/EventLoop.cc +0 -99
  276. package/.output/server/node_modules/node-pty/deps/winpty/src/agent/EventLoop.h +0 -47
  277. package/.output/server/node_modules/node-pty/deps/winpty/src/agent/InputMap.cc +0 -246
  278. package/.output/server/node_modules/node-pty/deps/winpty/src/agent/InputMap.h +0 -114
  279. package/.output/server/node_modules/node-pty/deps/winpty/src/agent/LargeConsoleRead.cc +0 -71
  280. package/.output/server/node_modules/node-pty/deps/winpty/src/agent/LargeConsoleRead.h +0 -68
  281. package/.output/server/node_modules/node-pty/deps/winpty/src/agent/NamedPipe.cc +0 -378
  282. package/.output/server/node_modules/node-pty/deps/winpty/src/agent/NamedPipe.h +0 -125
  283. package/.output/server/node_modules/node-pty/deps/winpty/src/agent/Scraper.cc +0 -699
  284. package/.output/server/node_modules/node-pty/deps/winpty/src/agent/Scraper.h +0 -103
  285. package/.output/server/node_modules/node-pty/deps/winpty/src/agent/SimplePool.h +0 -75
  286. package/.output/server/node_modules/node-pty/deps/winpty/src/agent/SmallRect.h +0 -143
  287. package/.output/server/node_modules/node-pty/deps/winpty/src/agent/Terminal.cc +0 -535
  288. package/.output/server/node_modules/node-pty/deps/winpty/src/agent/Terminal.h +0 -69
  289. package/.output/server/node_modules/node-pty/deps/winpty/src/agent/UnicodeEncoding.h +0 -157
  290. package/.output/server/node_modules/node-pty/deps/winpty/src/agent/UnicodeEncodingTest.cc +0 -189
  291. package/.output/server/node_modules/node-pty/deps/winpty/src/agent/Win32Console.cc +0 -107
  292. package/.output/server/node_modules/node-pty/deps/winpty/src/agent/Win32Console.h +0 -67
  293. package/.output/server/node_modules/node-pty/deps/winpty/src/agent/Win32ConsoleBuffer.cc +0 -193
  294. package/.output/server/node_modules/node-pty/deps/winpty/src/agent/Win32ConsoleBuffer.h +0 -99
  295. package/.output/server/node_modules/node-pty/deps/winpty/src/agent/main.cc +0 -114
  296. package/.output/server/node_modules/node-pty/deps/winpty/src/agent/subdir.mk +0 -61
  297. package/.output/server/node_modules/node-pty/deps/winpty/src/configurations.gypi +0 -60
  298. package/.output/server/node_modules/node-pty/deps/winpty/src/debugserver/DebugServer.cc +0 -117
  299. package/.output/server/node_modules/node-pty/deps/winpty/src/debugserver/subdir.mk +0 -41
  300. package/.output/server/node_modules/node-pty/deps/winpty/src/include/winpty.h +0 -242
  301. package/.output/server/node_modules/node-pty/deps/winpty/src/include/winpty_constants.h +0 -131
  302. package/.output/server/node_modules/node-pty/deps/winpty/src/libwinpty/AgentLocation.cc +0 -75
  303. package/.output/server/node_modules/node-pty/deps/winpty/src/libwinpty/AgentLocation.h +0 -28
  304. package/.output/server/node_modules/node-pty/deps/winpty/src/libwinpty/LibWinptyException.h +0 -54
  305. package/.output/server/node_modules/node-pty/deps/winpty/src/libwinpty/WinptyInternal.h +0 -72
  306. package/.output/server/node_modules/node-pty/deps/winpty/src/libwinpty/subdir.mk +0 -46
  307. package/.output/server/node_modules/node-pty/deps/winpty/src/libwinpty/winpty.cc +0 -970
  308. package/.output/server/node_modules/node-pty/deps/winpty/src/shared/AgentMsg.h +0 -38
  309. package/.output/server/node_modules/node-pty/deps/winpty/src/shared/BackgroundDesktop.cc +0 -122
  310. package/.output/server/node_modules/node-pty/deps/winpty/src/shared/BackgroundDesktop.h +0 -73
  311. package/.output/server/node_modules/node-pty/deps/winpty/src/shared/Buffer.cc +0 -103
  312. package/.output/server/node_modules/node-pty/deps/winpty/src/shared/Buffer.h +0 -102
  313. package/.output/server/node_modules/node-pty/deps/winpty/src/shared/DebugClient.cc +0 -187
  314. package/.output/server/node_modules/node-pty/deps/winpty/src/shared/DebugClient.h +0 -38
  315. package/.output/server/node_modules/node-pty/deps/winpty/src/shared/GenRandom.cc +0 -138
  316. package/.output/server/node_modules/node-pty/deps/winpty/src/shared/GenRandom.h +0 -55
  317. package/.output/server/node_modules/node-pty/deps/winpty/src/shared/GetCommitHash.bat +0 -13
  318. package/.output/server/node_modules/node-pty/deps/winpty/src/shared/Mutex.h +0 -54
  319. package/.output/server/node_modules/node-pty/deps/winpty/src/shared/OsModule.h +0 -63
  320. package/.output/server/node_modules/node-pty/deps/winpty/src/shared/OwnedHandle.cc +0 -36
  321. package/.output/server/node_modules/node-pty/deps/winpty/src/shared/OwnedHandle.h +0 -45
  322. package/.output/server/node_modules/node-pty/deps/winpty/src/shared/PrecompiledHeader.h +0 -43
  323. package/.output/server/node_modules/node-pty/deps/winpty/src/shared/StringBuilder.h +0 -227
  324. package/.output/server/node_modules/node-pty/deps/winpty/src/shared/StringBuilderTest.cc +0 -114
  325. package/.output/server/node_modules/node-pty/deps/winpty/src/shared/StringUtil.cc +0 -55
  326. package/.output/server/node_modules/node-pty/deps/winpty/src/shared/StringUtil.h +0 -80
  327. package/.output/server/node_modules/node-pty/deps/winpty/src/shared/TimeMeasurement.h +0 -63
  328. package/.output/server/node_modules/node-pty/deps/winpty/src/shared/UnixCtrlChars.h +0 -45
  329. package/.output/server/node_modules/node-pty/deps/winpty/src/shared/UpdateGenVersion.bat +0 -20
  330. package/.output/server/node_modules/node-pty/deps/winpty/src/shared/WindowsSecurity.cc +0 -460
  331. package/.output/server/node_modules/node-pty/deps/winpty/src/shared/WindowsSecurity.h +0 -104
  332. package/.output/server/node_modules/node-pty/deps/winpty/src/shared/WindowsVersion.cc +0 -252
  333. package/.output/server/node_modules/node-pty/deps/winpty/src/shared/WindowsVersion.h +0 -29
  334. package/.output/server/node_modules/node-pty/deps/winpty/src/shared/WinptyAssert.cc +0 -55
  335. package/.output/server/node_modules/node-pty/deps/winpty/src/shared/WinptyAssert.h +0 -64
  336. package/.output/server/node_modules/node-pty/deps/winpty/src/shared/WinptyException.cc +0 -57
  337. package/.output/server/node_modules/node-pty/deps/winpty/src/shared/WinptyException.h +0 -43
  338. package/.output/server/node_modules/node-pty/deps/winpty/src/shared/WinptyVersion.cc +0 -42
  339. package/.output/server/node_modules/node-pty/deps/winpty/src/shared/WinptyVersion.h +0 -27
  340. package/.output/server/node_modules/node-pty/deps/winpty/src/shared/winpty_snprintf.h +0 -99
  341. package/.output/server/node_modules/node-pty/deps/winpty/src/subdir.mk +0 -5
  342. package/.output/server/node_modules/node-pty/deps/winpty/src/tests/subdir.mk +0 -28
  343. package/.output/server/node_modules/node-pty/deps/winpty/src/tests/trivial_test.cc +0 -158
  344. package/.output/server/node_modules/node-pty/deps/winpty/src/unix-adapter/InputHandler.cc +0 -114
  345. package/.output/server/node_modules/node-pty/deps/winpty/src/unix-adapter/InputHandler.h +0 -56
  346. package/.output/server/node_modules/node-pty/deps/winpty/src/unix-adapter/OutputHandler.cc +0 -80
  347. package/.output/server/node_modules/node-pty/deps/winpty/src/unix-adapter/OutputHandler.h +0 -53
  348. package/.output/server/node_modules/node-pty/deps/winpty/src/unix-adapter/Util.cc +0 -86
  349. package/.output/server/node_modules/node-pty/deps/winpty/src/unix-adapter/Util.h +0 -31
  350. package/.output/server/node_modules/node-pty/deps/winpty/src/unix-adapter/WakeupFd.cc +0 -70
  351. package/.output/server/node_modules/node-pty/deps/winpty/src/unix-adapter/WakeupFd.h +0 -42
  352. package/.output/server/node_modules/node-pty/deps/winpty/src/unix-adapter/main.cc +0 -729
  353. package/.output/server/node_modules/node-pty/deps/winpty/src/unix-adapter/subdir.mk +0 -41
  354. package/.output/server/node_modules/node-pty/deps/winpty/src/winpty.gyp +0 -234
  355. package/.output/server/node_modules/node-pty/deps/winpty/vcbuild.bat +0 -83
  356. package/.output/server/node_modules/node-pty/lib/conpty_console_list_agent.js +0 -16
  357. package/.output/server/node_modules/node-pty/lib/conpty_console_list_agent.js.map +0 -1
  358. package/.output/server/node_modules/node-pty/lib/eventEmitter2.js +0 -47
  359. package/.output/server/node_modules/node-pty/lib/eventEmitter2.js.map +0 -1
  360. package/.output/server/node_modules/node-pty/lib/eventEmitter2.test.js +0 -30
  361. package/.output/server/node_modules/node-pty/lib/eventEmitter2.test.js.map +0 -1
  362. package/.output/server/node_modules/node-pty/lib/index.js +0 -52
  363. package/.output/server/node_modules/node-pty/lib/index.js.map +0 -1
  364. package/.output/server/node_modules/node-pty/lib/interfaces.js +0 -7
  365. package/.output/server/node_modules/node-pty/lib/interfaces.js.map +0 -1
  366. package/.output/server/node_modules/node-pty/lib/shared/conout.js +0 -11
  367. package/.output/server/node_modules/node-pty/lib/shared/conout.js.map +0 -1
  368. package/.output/server/node_modules/node-pty/lib/terminal.js +0 -190
  369. package/.output/server/node_modules/node-pty/lib/terminal.js.map +0 -1
  370. package/.output/server/node_modules/node-pty/lib/terminal.test.js +0 -139
  371. package/.output/server/node_modules/node-pty/lib/terminal.test.js.map +0 -1
  372. package/.output/server/node_modules/node-pty/lib/testUtils.test.js +0 -28
  373. package/.output/server/node_modules/node-pty/lib/testUtils.test.js.map +0 -1
  374. package/.output/server/node_modules/node-pty/lib/types.js +0 -7
  375. package/.output/server/node_modules/node-pty/lib/types.js.map +0 -1
  376. package/.output/server/node_modules/node-pty/lib/unixTerminal.js +0 -346
  377. package/.output/server/node_modules/node-pty/lib/unixTerminal.js.map +0 -1
  378. package/.output/server/node_modules/node-pty/lib/unixTerminal.test.js +0 -351
  379. package/.output/server/node_modules/node-pty/lib/unixTerminal.test.js.map +0 -1
  380. package/.output/server/node_modules/node-pty/lib/utils.js +0 -39
  381. package/.output/server/node_modules/node-pty/lib/utils.js.map +0 -1
  382. package/.output/server/node_modules/node-pty/lib/windowsConoutConnection.js +0 -125
  383. package/.output/server/node_modules/node-pty/lib/windowsConoutConnection.js.map +0 -1
  384. package/.output/server/node_modules/node-pty/lib/windowsPtyAgent.js +0 -320
  385. package/.output/server/node_modules/node-pty/lib/windowsPtyAgent.js.map +0 -1
  386. package/.output/server/node_modules/node-pty/lib/windowsPtyAgent.test.js +0 -90
  387. package/.output/server/node_modules/node-pty/lib/windowsPtyAgent.test.js.map +0 -1
  388. package/.output/server/node_modules/node-pty/lib/windowsTerminal.js +0 -199
  389. package/.output/server/node_modules/node-pty/lib/windowsTerminal.js.map +0 -1
  390. package/.output/server/node_modules/node-pty/lib/windowsTerminal.test.js +0 -219
  391. package/.output/server/node_modules/node-pty/lib/windowsTerminal.test.js.map +0 -1
  392. package/.output/server/node_modules/node-pty/lib/worker/conoutSocketWorker.js +0 -22
  393. package/.output/server/node_modules/node-pty/lib/worker/conoutSocketWorker.js.map +0 -1
  394. package/.output/server/node_modules/node-pty/package.json +0 -64
  395. package/.output/server/node_modules/node-pty/prebuilds/darwin-arm64/pty.node +0 -0
  396. package/.output/server/node_modules/node-pty/prebuilds/darwin-arm64/spawn-helper +0 -0
  397. package/.output/server/node_modules/node-pty/prebuilds/darwin-x64/pty.node +0 -0
  398. package/.output/server/node_modules/node-pty/prebuilds/darwin-x64/spawn-helper +0 -0
  399. package/.output/server/node_modules/node-pty/prebuilds/win32-arm64/conpty/OpenConsole.exe +0 -0
  400. package/.output/server/node_modules/node-pty/prebuilds/win32-arm64/conpty/conpty.dll +0 -0
  401. package/.output/server/node_modules/node-pty/prebuilds/win32-arm64/conpty.node +0 -0
  402. package/.output/server/node_modules/node-pty/prebuilds/win32-arm64/conpty.pdb +0 -0
  403. package/.output/server/node_modules/node-pty/prebuilds/win32-arm64/conpty_console_list.node +0 -0
  404. package/.output/server/node_modules/node-pty/prebuilds/win32-arm64/conpty_console_list.pdb +0 -0
  405. package/.output/server/node_modules/node-pty/prebuilds/win32-arm64/pty.node +0 -0
  406. package/.output/server/node_modules/node-pty/prebuilds/win32-arm64/pty.pdb +0 -0
  407. package/.output/server/node_modules/node-pty/prebuilds/win32-arm64/winpty-agent.exe +0 -0
  408. package/.output/server/node_modules/node-pty/prebuilds/win32-arm64/winpty-agent.pdb +0 -0
  409. package/.output/server/node_modules/node-pty/prebuilds/win32-arm64/winpty.dll +0 -0
  410. package/.output/server/node_modules/node-pty/prebuilds/win32-arm64/winpty.pdb +0 -0
  411. package/.output/server/node_modules/node-pty/prebuilds/win32-x64/conpty/OpenConsole.exe +0 -0
  412. package/.output/server/node_modules/node-pty/prebuilds/win32-x64/conpty/conpty.dll +0 -0
  413. package/.output/server/node_modules/node-pty/prebuilds/win32-x64/conpty.node +0 -0
  414. package/.output/server/node_modules/node-pty/prebuilds/win32-x64/conpty.pdb +0 -0
  415. package/.output/server/node_modules/node-pty/prebuilds/win32-x64/conpty_console_list.node +0 -0
  416. package/.output/server/node_modules/node-pty/prebuilds/win32-x64/conpty_console_list.pdb +0 -0
  417. package/.output/server/node_modules/node-pty/prebuilds/win32-x64/pty.node +0 -0
  418. package/.output/server/node_modules/node-pty/prebuilds/win32-x64/pty.pdb +0 -0
  419. package/.output/server/node_modules/node-pty/prebuilds/win32-x64/winpty-agent.exe +0 -0
  420. package/.output/server/node_modules/node-pty/prebuilds/win32-x64/winpty-agent.pdb +0 -0
  421. package/.output/server/node_modules/node-pty/prebuilds/win32-x64/winpty.dll +0 -0
  422. package/.output/server/node_modules/node-pty/prebuilds/win32-x64/winpty.pdb +0 -0
  423. package/.output/server/node_modules/node-pty/scripts/gen-compile-commands.js +0 -8
  424. package/.output/server/node_modules/node-pty/scripts/increment-version.js +0 -54
  425. package/.output/server/node_modules/node-pty/scripts/post-install.js +0 -80
  426. package/.output/server/node_modules/node-pty/scripts/prebuild.js +0 -34
  427. package/.output/server/node_modules/node-pty/src/conpty_console_list_agent.ts +0 -15
  428. package/.output/server/node_modules/node-pty/src/eventEmitter2.test.ts +0 -30
  429. package/.output/server/node_modules/node-pty/src/eventEmitter2.ts +0 -48
  430. package/.output/server/node_modules/node-pty/src/index.ts +0 -52
  431. package/.output/server/node_modules/node-pty/src/interfaces.ts +0 -130
  432. package/.output/server/node_modules/node-pty/src/native.d.ts +0 -54
  433. package/.output/server/node_modules/node-pty/src/shared/conout.ts +0 -15
  434. package/.output/server/node_modules/node-pty/src/terminal.test.ts +0 -119
  435. package/.output/server/node_modules/node-pty/src/terminal.ts +0 -211
  436. package/.output/server/node_modules/node-pty/src/testUtils.test.ts +0 -23
  437. package/.output/server/node_modules/node-pty/src/tsconfig.json +0 -22
  438. package/.output/server/node_modules/node-pty/src/types.ts +0 -15
  439. package/.output/server/node_modules/node-pty/src/unix/pty.cc +0 -799
  440. package/.output/server/node_modules/node-pty/src/unix/spawn-helper.cc +0 -23
  441. package/.output/server/node_modules/node-pty/src/unixTerminal.test.ts +0 -367
  442. package/.output/server/node_modules/node-pty/src/unixTerminal.ts +0 -388
  443. package/.output/server/node_modules/node-pty/src/utils.ts +0 -29
  444. package/.output/server/node_modules/node-pty/src/win/conpty.cc +0 -583
  445. package/.output/server/node_modules/node-pty/src/win/conpty.h +0 -41
  446. package/.output/server/node_modules/node-pty/src/win/conpty_console_list.cc +0 -44
  447. package/.output/server/node_modules/node-pty/src/win/path_util.cc +0 -95
  448. package/.output/server/node_modules/node-pty/src/win/path_util.h +0 -26
  449. package/.output/server/node_modules/node-pty/src/win/winpty.cc +0 -333
  450. package/.output/server/node_modules/node-pty/src/windowsConoutConnection.ts +0 -82
  451. package/.output/server/node_modules/node-pty/src/windowsPtyAgent.test.ts +0 -94
  452. package/.output/server/node_modules/node-pty/src/windowsPtyAgent.ts +0 -321
  453. package/.output/server/node_modules/node-pty/src/windowsTerminal.test.ts +0 -229
  454. package/.output/server/node_modules/node-pty/src/windowsTerminal.ts +0 -203
  455. package/.output/server/node_modules/node-pty/src/worker/conoutSocketWorker.ts +0 -22
  456. package/.output/server/node_modules/node-pty/third_party/conpty/1.23.251008001/win10-arm64/OpenConsole.exe +0 -0
  457. package/.output/server/node_modules/node-pty/third_party/conpty/1.23.251008001/win10-arm64/conpty.dll +0 -0
  458. package/.output/server/node_modules/node-pty/third_party/conpty/1.23.251008001/win10-x64/OpenConsole.exe +0 -0
  459. package/.output/server/node_modules/node-pty/third_party/conpty/1.23.251008001/win10-x64/conpty.dll +0 -0
  460. package/.output/server/node_modules/node-pty/typings/node-pty.d.ts +0 -211
  461. package/.output/server/node_modules/tslib/modules/index.js +0 -70
  462. package/.output/server/node_modules/tslib/modules/package.json +0 -3
  463. package/.output/server/node_modules/tslib/package.json +0 -47
  464. package/.output/server/node_modules/tslib/tslib.js +0 -484
  465. package/.output/server/package.json +0 -10
  466. package/scripts/release.mjs +0 -173
  467. package/vendor/node-domexception/index.js +0 -3
  468. package/vendor/node-domexception/package.json +0 -10
  469. /package/.output/public/assets/{abap-smLpETzL.js → abap-CglpPUUh.js} +0 -0
  470. /package/.output/public/assets/{actionscript-3-o-aRvjY5.js → actionscript-3-CGv72Q9E.js} +0 -0
  471. /package/.output/public/assets/{ada-D5RRX1i4.js → ada-CfxXaXwr.js} +0 -0
  472. /package/.output/public/assets/{addon-fit-CMMXLNsg.js → addon-fit-C9RD8ot3.js} +0 -0
  473. /package/.output/public/assets/{andromeeda-N4z3YzmR.js → andromeeda-DXsn6mTE.js} +0 -0
  474. /package/.output/public/assets/{apache-DttKlSqg.js → apache-D5xAQKSB.js} +0 -0
  475. /package/.output/public/assets/{apex-DL7j-a2n.js → apex-qgfedJV2.js} +0 -0
  476. /package/.output/public/assets/{applescript-DCbL_2FX.js → applescript-DqumQxTt.js} +0 -0
  477. /package/.output/public/assets/{ara-DqheWJCe.js → ara-Ditv3ow6.js} +0 -0
  478. /package/.output/public/assets/{asciidoc-BH2sf2K4.js → asciidoc-DL8QwiT7.js} +0 -0
  479. /package/.output/public/assets/{asm-rfjOMz3U.js → asm-K6TMxl3o.js} +0 -0
  480. /package/.output/public/assets/{aurora-x-CND-FqEb.js → aurora-x-DGv-xZaa.js} +0 -0
  481. /package/.output/public/assets/{awk-CMV5n9Z7.js → awk-CYSfQSDT.js} +0 -0
  482. /package/.output/public/assets/{ayu-dark-on7xzq_B.js → ayu-dark-DGBaJbpH.js} +0 -0
  483. /package/.output/public/assets/{ayu-light-DnGeGGc2.js → ayu-light-BQrGPVs2.js} +0 -0
  484. /package/.output/public/assets/{ayu-mirage-DG3LlYC_.js → ayu-mirage-Do-5o2VL.js} +0 -0
  485. /package/.output/public/assets/{ballerina-BjMqJjlr.js → ballerina-BE-8n54s.js} +0 -0
  486. /package/.output/public/assets/{bat-BaVbo_qw.js → bat-B1zTc1QZ.js} +0 -0
  487. /package/.output/public/assets/{beancount-DBt5Mbc_.js → beancount-DhObrvif.js} +0 -0
  488. /package/.output/public/assets/{berry-Cyjuxiss.js → berry-Cnbvthv1.js} +0 -0
  489. /package/.output/public/assets/{bibtex-BV_0nsPq.js → bibtex-pp5SrwZy.js} +0 -0
  490. /package/.output/public/assets/{bicep-C2gEwu4J.js → bicep-BL6eYxbs.js} +0 -0
  491. /package/.output/public/assets/{bird2-BRyaEJd0.js → bird2-BQaXYY9n.js} +0 -0
  492. /package/.output/public/assets/{c-Nc9zJT78.js → c-BHFJ4Jk3.js} +0 -0
  493. /package/.output/public/assets/{c3-DTTbp5N2.js → c3-BHTco5Hb.js} +0 -0
  494. /package/.output/public/assets/{cadence-CPz83cmI.js → cadence-CoPxW0qb.js} +0 -0
  495. /package/.output/public/assets/{catppuccin-frappe-Dr22sraq.js → catppuccin-frappe-9fYwMJCf.js} +0 -0
  496. /package/.output/public/assets/{catppuccin-latte-C57EeX8c.js → catppuccin-latte-BUiKH1yZ.js} +0 -0
  497. /package/.output/public/assets/{catppuccin-macchiato-CpheI4uD.js → catppuccin-macchiato-ZmO2e0M_.js} +0 -0
  498. /package/.output/public/assets/{catppuccin-mocha-D8Lmdks_.js → catppuccin-mocha-CFwbXQfO.js} +0 -0
  499. /package/.output/public/assets/{clarity-CFJ2Yc3q.js → clarity-DVUGm1xP.js} +0 -0
  500. /package/.output/public/assets/{clojure-6R01QgJC.js → clojure-BgXJG6FG.js} +0 -0
  501. /package/.output/public/assets/{cmake-D5rSbMir.js → cmake-CZndsvm6.js} +0 -0
  502. /package/.output/public/assets/{codeowners-_3A-ClkN.js → codeowners-Dd7a447M.js} +0 -0
  503. /package/.output/public/assets/{codeql-DlIhJTR7.js → codeql-XJR6llG-.js} +0 -0
  504. /package/.output/public/assets/{common-lisp-BvQzz173.js → common-lisp-BOMbLvgT.js} +0 -0
  505. /package/.output/public/assets/{coq-DTNXReIC.js → coq-DnhmQYDa.js} +0 -0
  506. /package/.output/public/assets/{csharp-BDKQY1K9.js → csharp-BdEyRqBm.js} +0 -0
  507. /package/.output/public/assets/{css-DRmnABqB.js → css-CsTDDTLq.js} +0 -0
  508. /package/.output/public/assets/{csv-DNUpVBxl.js → csv-CXchYFbz.js} +0 -0
  509. /package/.output/public/assets/{cue-DDdBc2s3.js → cue-D7YpBZvd.js} +0 -0
  510. /package/.output/public/assets/{cypher-CguaznO2.js → cypher-XIm1N8YJ.js} +0 -0
  511. /package/.output/public/assets/{d-CHcoyjv3.js → d-DvB0pbZH.js} +0 -0
  512. /package/.output/public/assets/{dark-plus-CqeW_0kH.js → dark-plus-BUdpMFIA.js} +0 -0
  513. /package/.output/public/assets/{dart-RM3aRphk.js → dart-CwpSKTMB.js} +0 -0
  514. /package/.output/public/assets/{dax-nbnY1d79.js → dax-CEynWJsU.js} +0 -0
  515. /package/.output/public/assets/{desktop-BD76cvxT.js → desktop-Dk-YiYS_.js} +0 -0
  516. /package/.output/public/assets/{diff-CdkWtnkL.js → diff-abLZ-xM1.js} +0 -0
  517. /package/.output/public/assets/{docker-ZyPHc6zB.js → docker-BT48KsRJ.js} +0 -0
  518. /package/.output/public/assets/{dotenv-BdJZEwA6.js → dotenv-NOMQQbM0.js} +0 -0
  519. /package/.output/public/assets/{dracula-CtqCPLGa.js → dracula-BUW0ZyNO.js} +0 -0
  520. /package/.output/public/assets/{dracula-soft-DmBpwRAy.js → dracula-soft-BMjAt1_u.js} +0 -0
  521. /package/.output/public/assets/{dream-maker-BJL4qlg3.js → dream-maker-D26TP1Q3.js} +0 -0
  522. /package/.output/public/assets/{emacs-lisp-_LyYa2Ky.js → emacs-lisp-C2EvfotR.js} +0 -0
  523. /package/.output/public/assets/{everforest-dark-CrbyKk4n.js → everforest-dark-hC6a272f.js} +0 -0
  524. /package/.output/public/assets/{everforest-light-DRbSh8Tm.js → everforest-light-BTpbYY5G.js} +0 -0
  525. /package/.output/public/assets/{fennel-CC2BkRsS.js → fennel-DWOL-Ewx.js} +0 -0
  526. /package/.output/public/assets/{fish-D2ZCzqcE.js → fish-CQPQq0pQ.js} +0 -0
  527. /package/.output/public/assets/{fluent-DKAm3m7q.js → fluent-BYdsr2M8.js} +0 -0
  528. /package/.output/public/assets/{fortran-free-form-BPTf0lbT.js → fortran-free-form-C_EtY4F9.js} +0 -0
  529. /package/.output/public/assets/{gdscript-CsadCSaZ.js → gdscript-CH_tD-VB.js} +0 -0
  530. /package/.output/public/assets/{gdshader-PfnN_8tR.js → gdshader-BemFblFP.js} +0 -0
  531. /package/.output/public/assets/{genie-Bj-orPAV.js → genie-hCPg_eq7.js} +0 -0
  532. /package/.output/public/assets/{gherkin-COVWpJ-Q.js → gherkin-CO0ypD1P.js} +0 -0
  533. /package/.output/public/assets/{github-dark-ipGuFGYC.js → github-dark-cA72fqmI.js} +0 -0
  534. /package/.output/public/assets/{github-dark-default-DX3IG_X0.js → github-dark-default-DiYTFvY5.js} +0 -0
  535. /package/.output/public/assets/{github-dark-dimmed-CH6p_7ez.js → github-dark-dimmed-D-uBHzyG.js} +0 -0
  536. /package/.output/public/assets/{github-dark-high-contrast-Bg2sSao5.js → github-dark-high-contrast-BrUSkckI.js} +0 -0
  537. /package/.output/public/assets/{github-light-default-DwpDd1IQ.js → github-light-default-BT-6Vf7C.js} +0 -0
  538. /package/.output/public/assets/{github-light-high-contrast-C0QeixPf.js → github-light-high-contrast-DqmEyTTc.js} +0 -0
  539. /package/.output/public/assets/{github-light-BxjqOQl0.js → github-light-piFPqU8R.js} +0 -0
  540. /package/.output/public/assets/{gleam-BF2NigGj.js → gleam-CWJA_H5i.js} +0 -0
  541. /package/.output/public/assets/{gn-CMIt9roj.js → gn-nlTwLSjP.js} +0 -0
  542. /package/.output/public/assets/{gnuplot-DgWlRTEj.js → gnuplot-wYV0MbPl.js} +0 -0
  543. /package/.output/public/assets/{go-DLnOLj8q.js → go-BUPBDRDo.js} +0 -0
  544. /package/.output/public/assets/{groovy-B9qLWIkE.js → groovy-BusafOA8.js} +0 -0
  545. /package/.output/public/assets/{gruvbox-dark-hard-BIMX9ePb.js → gruvbox-dark-hard-BrrZYoPF.js} +0 -0
  546. /package/.output/public/assets/{gruvbox-dark-medium-DxuwyVzM.js → gruvbox-dark-medium-DsxcLuUs.js} +0 -0
  547. /package/.output/public/assets/{gruvbox-dark-soft-ba2fjht0.js → gruvbox-dark-soft-DQXOs_GH.js} +0 -0
  548. /package/.output/public/assets/{gruvbox-light-hard-DAJK2PqC.js → gruvbox-light-hard-CtHwj_cB.js} +0 -0
  549. /package/.output/public/assets/{gruvbox-light-medium-WRifDAJD.js → gruvbox-light-medium-CPJMdgXQ.js} +0 -0
  550. /package/.output/public/assets/{gruvbox-light-soft-B0dBOoVB.js → gruvbox-light-soft-C4Xh9Hc-.js} +0 -0
  551. /package/.output/public/assets/{haskell-BaGpmm_c.js → haskell-CaDqJkn4.js} +0 -0
  552. /package/.output/public/assets/{haxe-DfXTCEOz.js → haxe-Dxg-8_J7.js} +0 -0
  553. /package/.output/public/assets/{hcl-CbCtpSbi.js → hcl-Bjg-rMJ0.js} +0 -0
  554. /package/.output/public/assets/{hjson-_4-w-pHU.js → hjson-BMbeOOMg.js} +0 -0
  555. /package/.output/public/assets/{hlsl-DpuYn7pp.js → hlsl-D-cuwCFV.js} +0 -0
  556. /package/.output/public/assets/{horizon-C5RtD1fY.js → horizon-BofYY9of.js} +0 -0
  557. /package/.output/public/assets/{horizon-bright-pEOice34.js → horizon-bright-CFOVQsf2.js} +0 -0
  558. /package/.output/public/assets/{houston-A0zg9vNP.js → houston-BIBYxFpQ.js} +0 -0
  559. /package/.output/public/assets/{hy-t9zDXBje.js → hy-Cye3Jt7O.js} +0 -0
  560. /package/.output/public/assets/{imba-Bxu-TDfw.js → imba-CjkQtgD2.js} +0 -0
  561. /package/.output/public/assets/{ini-D-v34c8N.js → ini-BvMtfDNl.js} +0 -0
  562. /package/.output/public/assets/{java-DVLnIrqC.js → java-BYO3uQJZ.js} +0 -0
  563. /package/.output/public/assets/{javascript-Cop1kpy_.js → javascript-BsdGTPv_.js} +0 -0
  564. /package/.output/public/assets/{json-CTw4n7kn.js → json-Kp2u6f_f.js} +0 -0
  565. /package/.output/public/assets/{json5-D0XL1D5m.js → json5-BCxDPjxU.js} +0 -0
  566. /package/.output/public/assets/{jsonc-BBgf3TX3.js → jsonc-BV8VFjqO.js} +0 -0
  567. /package/.output/public/assets/{jsonl-KrKLbtB7.js → jsonl-DHrr7c-M.js} +0 -0
  568. /package/.output/public/assets/{jsonnet-B2ZwWMOt.js → jsonnet-xURar8mu.js} +0 -0
  569. /package/.output/public/assets/{jssm-ByRpI9-B.js → jssm-DtoLUQAt.js} +0 -0
  570. /package/.output/public/assets/{jsx-0oMUGqZj.js → jsx-CyrO086S.js} +0 -0
  571. /package/.output/public/assets/{kanagawa-dragon-CtPmcCMp.js → kanagawa-dragon-COwlYgQB.js} +0 -0
  572. /package/.output/public/assets/{kanagawa-lotus-DpOXEGCa.js → kanagawa-lotus-GZWqyq_E.js} +0 -0
  573. /package/.output/public/assets/{kanagawa-wave-CLVCyc-n.js → kanagawa-wave-CP4uw3DX.js} +0 -0
  574. /package/.output/public/assets/{kdl-6FPPEH4H.js → kdl-DGo2N7N5.js} +0 -0
  575. /package/.output/public/assets/{kotlin-D4L3Nd2D.js → kotlin-Cm4W8Bbs.js} +0 -0
  576. /package/.output/public/assets/{kusto-D-mmc07O.js → kusto-DQ22_tcT.js} +0 -0
  577. /package/.output/public/assets/{laserwave-7fEj4XGb.js → laserwave-DfABGYsD.js} +0 -0
  578. /package/.output/public/assets/{lean-BMVMuP2E.js → lean-D-8a6Wwv.js} +0 -0
  579. /package/.output/public/assets/{less-C95PyOu0.js → less-B-qZzFKw.js} +0 -0
  580. /package/.output/public/assets/{light-plus-DHI2dh3p.js → light-plus-DS_rmE1N.js} +0 -0
  581. /package/.output/public/assets/{llvm-Dy3qORTl.js → llvm-Ch-k6TUk.js} +0 -0
  582. /package/.output/public/assets/{log-BQop7fzg.js → log-BGwbCG2S.js} +0 -0
  583. /package/.output/public/assets/{logo-DKtnYmrp.js → logo-DHGHbFWy.js} +0 -0
  584. /package/.output/public/assets/{luau-Dha4KG0q.js → luau-qsvm_nYh.js} +0 -0
  585. /package/.output/public/assets/{make-DfmS6buu.js → make-Dlfjp_Q8.js} +0 -0
  586. /package/.output/public/assets/{markdown-BaI9LyM4.js → markdown-COh4ruD_.js} +0 -0
  587. /package/.output/public/assets/{material-theme-Dm6ETY8i.js → material-theme-Ccrl1jie.js} +0 -0
  588. /package/.output/public/assets/{material-theme-darker-BeyjmM5Z.js → material-theme-darker-CcOH0iHe.js} +0 -0
  589. /package/.output/public/assets/{material-theme-lighter-CCOYYzKL.js → material-theme-lighter-DoKpC7NM.js} +0 -0
  590. /package/.output/public/assets/{material-theme-ocean-CUtPiiX3.js → material-theme-ocean-BcvBZHgH.js} +0 -0
  591. /package/.output/public/assets/{material-theme-palenight-2L4zMwIM.js → material-theme-palenight-DIL4EAzl.js} +0 -0
  592. /package/.output/public/assets/{matlab-BT79Cq_j.js → matlab-CBqMuw7w.js} +0 -0
  593. /package/.output/public/assets/{mdx-CxGBwLNt.js → mdx-BjoJxHxW.js} +0 -0
  594. /package/.output/public/assets/{mermaid-DLf3axBN.js → mermaid-DjAh2yR5.js} +0 -0
  595. /package/.output/public/assets/{min-dark-B8TUPGHg.js → min-dark-CbwghdE5.js} +0 -0
  596. /package/.output/public/assets/{min-light-BDOoBxcA.js → min-light-_F39d_94.js} +0 -0
  597. /package/.output/public/assets/{mipsasm-DXuU_0cI.js → mipsasm-DA1H0O78.js} +0 -0
  598. /package/.output/public/assets/{mojo-1Omp2pIo.js → mojo-BVgjRjTn.js} +0 -0
  599. /package/.output/public/assets/{monokai-E_VBmXGZ.js → monokai-CxgvaWkX.js} +0 -0
  600. /package/.output/public/assets/{moonbit-DZzq699o.js → moonbit-tKY94ZOM.js} +0 -0
  601. /package/.output/public/assets/{move-DxDAOJVd.js → move-B5WspEjG.js} +0 -0
  602. /package/.output/public/assets/{narrat-CxDcPPb9.js → narrat-CDPRStf_.js} +0 -0
  603. /package/.output/public/assets/{nextflow-groovy-wvmJO4hi.js → nextflow-groovy-1GYTZoD5.js} +0 -0
  604. /package/.output/public/assets/{night-owl-DefhalNX.js → night-owl-CCydx7ZR.js} +0 -0
  605. /package/.output/public/assets/{night-owl-light-byb3AbEn.js → night-owl-light-CLM7UUPY.js} +0 -0
  606. /package/.output/public/assets/{nix-DsFTDHWT.js → nix-DXFN4IwW.js} +0 -0
  607. /package/.output/public/assets/{nord-D5rQzHT-.js → nord-CiCWZ1de.js} +0 -0
  608. /package/.output/public/assets/{nushell-BQ_rO0AM.js → nushell-Ck9o2qOx.js} +0 -0
  609. /package/.output/public/assets/{objective-c-BMq6JT_m.js → objective-c-4koxci9E.js} +0 -0
  610. /package/.output/public/assets/{objective-cpp-DRwojuGv.js → objective-cpp-BPFAgSN9.js} +0 -0
  611. /package/.output/public/assets/{ocaml-e4_gKO6E.js → ocaml-BdlBLhZV.js} +0 -0
  612. /package/.output/public/assets/{odin-mdTPwYOg.js → odin-BcGOLCqZ.js} +0 -0
  613. /package/.output/public/assets/{one-dark-pro-DxXww9jg.js → one-dark-pro-DEMdTgiO.js} +0 -0
  614. /package/.output/public/assets/{one-light-D9c03w7t.js → one-light-Cmpe9X1u.js} +0 -0
  615. /package/.output/public/assets/{openscad-D2aTdNfr.js → openscad-DBveSHYE.js} +0 -0
  616. /package/.output/public/assets/{pascal-D4n_G8vj.js → pascal-DxOVE99u.js} +0 -0
  617. /package/.output/public/assets/{pierre-dark-CizZ1Z5z.js → pierre-dark-DIUCKU6U.js} +0 -0
  618. /package/.output/public/assets/{pierre-light-CHMWfAMe.js → pierre-light-DVO2KPlh.js} +0 -0
  619. /package/.output/public/assets/{pkl-DcjhAp0L.js → pkl-pIvtf7Vu.js} +0 -0
  620. /package/.output/public/assets/{plastic-uOsw7z1x.js → plastic-Dvdf8qVN.js} +0 -0
  621. /package/.output/public/assets/{plsql-BSy3Ag0J.js → plsql-d50MFTFK.js} +0 -0
  622. /package/.output/public/assets/{po-Be96RYkA.js → po-CboxWwYg.js} +0 -0
  623. /package/.output/public/assets/{poimandres-CyO4HORD.js → poimandres-DHgQGH4M.js} +0 -0
  624. /package/.output/public/assets/{polar-BmhMKWum.js → polar-DNp7Oek8.js} +0 -0
  625. /package/.output/public/assets/{postcss-BTQso3H9.js → postcss-LpmI6XQv.js} +0 -0
  626. /package/.output/public/assets/{powerquery-DVyQv3M2.js → powerquery-BNCl8Uwz.js} +0 -0
  627. /package/.output/public/assets/{powershell-BmtCGJVD.js → powershell-CZ9J0XuS.js} +0 -0
  628. /package/.output/public/assets/{prisma-CCFA9rEj.js → prisma-AELUiJCl.js} +0 -0
  629. /package/.output/public/assets/{prolog-DWGEEo78.js → prolog-BlqwejRD.js} +0 -0
  630. /package/.output/public/assets/{proto-C3eop1kM.js → proto-DRQC3swD.js} +0 -0
  631. /package/.output/public/assets/{puppet-C0_7Nv5A.js → puppet-DBKR8MlH.js} +0 -0
  632. /package/.output/public/assets/{purescript-Bv-B8yRw.js → purescript-DItLzxZS.js} +0 -0
  633. /package/.output/public/assets/{python-CKg5r0C3.js → python-D9t_ETu8.js} +0 -0
  634. /package/.output/public/assets/{qmldir-Cqfb4Lox.js → qmldir-DP_KD1nk.js} +0 -0
  635. /package/.output/public/assets/{qss-Csho9BH8.js → qss-CL02opOd.js} +0 -0
  636. /package/.output/public/assets/{r-UcxRcvcA.js → r-DmmrCFmB.js} +0 -0
  637. /package/.output/public/assets/{racket-D8-uWeQH.js → racket-K0frLTWj.js} +0 -0
  638. /package/.output/public/assets/{raku-Cj4JSa8p.js → raku-DwgLlPg9.js} +0 -0
  639. /package/.output/public/assets/{red-z4H4llUY.js → red-DzDu-aXc.js} +0 -0
  640. /package/.output/public/assets/{reg-DXGFiJSl.js → reg-B_y3c7di.js} +0 -0
  641. /package/.output/public/assets/{regexp-3-A0406L.js → regexp--eMB47Xx.js} +0 -0
  642. /package/.output/public/assets/{rel-CunnVTBK.js → rel-CT65ywJp.js} +0 -0
  643. /package/.output/public/assets/{riscv-C8BcOCkS.js → riscv-Qv5W2vIg.js} +0 -0
  644. /package/.output/public/assets/{ron-DiDyR9oa.js → ron-cRHu9zPp.js} +0 -0
  645. /package/.output/public/assets/{rose-pine-BADquuIH.js → rose-pine-DFmTJHIJ.js} +0 -0
  646. /package/.output/public/assets/{rose-pine-dawn-BLcEeBoh.js → rose-pine-dawn-YIuK9wUm.js} +0 -0
  647. /package/.output/public/assets/{rose-pine-moon-BK_tLY1Y.js → rose-pine-moon-BYEHfkUB.js} +0 -0
  648. /package/.output/public/assets/{rosmsg-CHmL1Uyj.js → rosmsg-_L1z4wrx.js} +0 -0
  649. /package/.output/public/assets/{rust-DjJFInu3.js → rust-BA5wQ_EY.js} +0 -0
  650. /package/.output/public/assets/{sass-D3xZ5o-v.js → sass-sd__ov8V.js} +0 -0
  651. /package/.output/public/assets/{scala-B0IRml5w.js → scala--cVG4U7H.js} +0 -0
  652. /package/.output/public/assets/{scheme-BhwcV3Av.js → scheme-D6Q1O-kY.js} +0 -0
  653. /package/.output/public/assets/{sdbl-BmWYR-pI.js → sdbl-jB0DUrL_.js} +0 -0
  654. /package/.output/public/assets/{shellscript-DaVPunOM.js → shellscript-DyWRuzkj.js} +0 -0
  655. /package/.output/public/assets/{slack-dark-DOnVms5P.js → slack-dark-DHhAlQBa.js} +0 -0
  656. /package/.output/public/assets/{slack-ochin-DcRTft4q.js → slack-ochin-PZXbcZaN.js} +0 -0
  657. /package/.output/public/assets/{smalltalk-DVQuUMII.js → smalltalk-C7VkdTlv.js} +0 -0
  658. /package/.output/public/assets/{snazzy-light-x9CLJ1W9.js → snazzy-light-CPc_Qts9.js} +0 -0
  659. /package/.output/public/assets/{solarized-dark-BB1sh-pe.js → solarized-dark-DCCfKtTh.js} +0 -0
  660. /package/.output/public/assets/{solarized-light-9-RPS998.js → solarized-light-B84T-R9X.js} +0 -0
  661. /package/.output/public/assets/{solidity-gQ4WXILB.js → solidity-DVsDPpDS.js} +0 -0
  662. /package/.output/public/assets/{splunk-OB48_RcD.js → splunk-A-BwP6Va.js} +0 -0
  663. /package/.output/public/assets/{sql-CrTmZCMa.js → sql-CRzu7iKx.js} +0 -0
  664. /package/.output/public/assets/{ssh-config-DA9YMRGV.js → ssh-config-CFPv6mTy.js} +0 -0
  665. /package/.output/public/assets/{stylus-sKwvsUaC.js → stylus-CUf3IESt.js} +0 -0
  666. /package/.output/public/assets/{swift-C72NbAtg.js → swift-CSiiYB_Q.js} +0 -0
  667. /package/.output/public/assets/{synthwave-84-eJ9uRN_S.js → synthwave-84-uJp1j2Jd.js} +0 -0
  668. /package/.output/public/assets/{system-verilog-CnWMF7Nq.js → system-verilog-rMjKy-O9.js} +0 -0
  669. /package/.output/public/assets/{systemd-DMzItW5N.js → systemd-R-KDM4-t.js} +0 -0
  670. /package/.output/public/assets/{talonscript-DopQCWDL.js → talonscript-D666vCtm.js} +0 -0
  671. /package/.output/public/assets/{tasl-C28SYKbq.js → tasl-68cbBocU.js} +0 -0
  672. /package/.output/public/assets/{tcl-DHq7zmoF.js → tcl-Y39dJ_pX.js} +0 -0
  673. /package/.output/public/assets/{terraform-CogS1YKX.js → terraform-BF7wAo-b.js} +0 -0
  674. /package/.output/public/assets/{tokyo-night-B9N7LyrF.js → tokyo-night-EeABtN82.js} +0 -0
  675. /package/.output/public/assets/{toml-BH_iPsgK.js → toml-BrMFN1JF.js} +0 -0
  676. /package/.output/public/assets/{tsv-BIkdBZX1.js → tsv-Dp2l5v7f.js} +0 -0
  677. /package/.output/public/assets/{tsx-BjkCKOtw.js → tsx-CQqypS0k.js} +0 -0
  678. /package/.output/public/assets/{turtle-CqNXyJWZ.js → turtle-_N1aDtpV.js} +0 -0
  679. /package/.output/public/assets/{typescript-BoHeP9q1.js → typescript-CPmDkqmE.js} +0 -0
  680. /package/.output/public/assets/{typespec-CQ9LYD_e.js → typespec-ghgF2GAI.js} +0 -0
  681. /package/.output/public/assets/{typst-T-Fsk-Sv.js → typst-DP_izaNK.js} +0 -0
  682. /package/.output/public/assets/{v-BhMEOw9x.js → v-CdNC_Wok.js} +0 -0
  683. /package/.output/public/assets/{vala-DzajMnwt.js → vala-Bu4pYkLC.js} +0 -0
  684. /package/.output/public/assets/{vb-7Xr8dEYW.js → vb-u84IyWSS.js} +0 -0
  685. /package/.output/public/assets/{verilog-AvXtwZir.js → verilog-BC33pi7Z.js} +0 -0
  686. /package/.output/public/assets/{vesper-CtgQQ2sf.js → vesper-7-XtS0Kg.js} +0 -0
  687. /package/.output/public/assets/{vhdl-BHu0zg1P.js → vhdl-BBxTOQe0.js} +0 -0
  688. /package/.output/public/assets/{viml-Di0QpLfC.js → viml-X_r-ivXA.js} +0 -0
  689. /package/.output/public/assets/{vitesse-black-jXdfyqgD.js → vitesse-black-DRdlY-cW.js} +0 -0
  690. /package/.output/public/assets/{vitesse-dark-B88PxG1r.js → vitesse-dark-Bz0hOFHJ.js} +0 -0
  691. /package/.output/public/assets/{vitesse-light-BXxZh2iV.js → vitesse-light-7kCLd0yn.js} +0 -0
  692. /package/.output/public/assets/{vyper-C3R5yXgx.js → vyper-E7qIwMXy.js} +0 -0
  693. /package/.output/public/assets/{wasm-D_MQmneJ.js → wasm-BqG9CUph.js} +0 -0
  694. /package/.output/public/assets/{wasm-Chsuwt1A.js → wasm-C18OEcCL.js} +0 -0
  695. /package/.output/public/assets/{wenyan-BonVcr2i.js → wenyan-siXAC4el.js} +0 -0
  696. /package/.output/public/assets/{wgsl-D59WYmNq.js → wgsl-BJQt8Uld.js} +0 -0
  697. /package/.output/public/assets/{wikitext-ariTI2Wk.js → wikitext-Ci0ePJmf.js} +0 -0
  698. /package/.output/public/assets/{wit-EA4fa3Dt.js → wit-BdDJ7geN.js} +0 -0
  699. /package/.output/public/assets/{wolfram-DDp7LhyU.js → wolfram-Bi-O1IUM.js} +0 -0
  700. /package/.output/public/assets/{xterm-CCMwI7sy.js → xterm-TTe2Bv9Z.js} +0 -0
  701. /package/.output/public/assets/{yaml-BTD1XHJG.js → yaml-DgkO7CC2.js} +0 -0
  702. /package/.output/public/assets/{zenscript-4WaROUyc.js → zenscript-CnkrxCBw.js} +0 -0
  703. /package/.output/public/assets/{zig-CJoLJGwV.js → zig-CgMsxF9-.js} +0 -0
@@ -0,0 +1,23 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/right-sidebar-CWvXcZzC.js","assets/rolldown-runtime-S-ySWqyJ.js","assets/index-FOqZaR4L.js","assets/preload-helper-Csz9R64u.js","assets/index-C-mxWGZ5.css","assets/PatchDiff-SN-mXa3p.js","assets/query-keys-C9jMaRnO.js","assets/plus-B1rJPgNv.js","assets/terminal-panel-YGR6v-ZH.js","assets/app-shell-common-0xa28gDm.js"])))=>i.map(i=>d[i]);
2
+ import{r as e}from"./rolldown-runtime-S-ySWqyJ.js";import{$ as t,A as n,At as r,B as i,Br as a,Bt as o,C as s,Cn as c,Ct as l,Dn as u,Dt as d,Et as f,F as p,Ft as m,G as h,H as g,Ht as _,I as v,Ir as y,It as b,J as x,Jt as S,K as C,Kt as w,L as T,Lt as E,M as D,Mr as O,Mt as k,N as A,Nt as j,O as M,P as N,Pt as P,Q as F,Qr as I,Qt as L,R,Rr as z,S as B,St as V,Tn as H,Tt as U,U as W,V as ee,Vr as te,Vt as ne,W as G,Wt as K,X as re,Xt as q,Y as ie,Yt as J,Z as ae,Zt as oe,_ as se,_n as ce,_t as le,an as ue,at as de,b as fe,bn as pe,br as me,bt as he,ci as ge,cn as _e,cr as ve,ct as ye,d as be,di as xe,dn as Se,dr as Ce,ei as we,en as Te,er as Ee,et as De,f as Oe,g as ke,gt as Ae,h as je,hn as Me,ht as Ne,i as Pe,in as Fe,it as Ie,j as Le,k as Re,kr as ze,kt as Be,l as Ve,li as He,ln as Ue,lt as We,m as Ge,mn as Ke,mt as qe,n as Je,ni as Ye,nn as Xe,o as Ze,oi as Qe,on as $e,p as et,pn as tt,pt as nt,q as rt,qt as it,r as at,ri as ot,rn as st,rt as ct,s as lt,si as ut,sr as dt,st as ft,t as pt,ti as mt,tn as ht,tr as gt,tt as _t,ui as vt,v as yt,vn as bt,vt as xt,w as St,wr as Ct,wt,x as Tt,xt as Et,y as Dt,yn as Ot,yt as kt,z as At,zt as jt}from"./preload-helper-Csz9R64u.js";import{$ as Mt,$t as Nt,An as Pt,At as Ft,Bn as It,Bt as Lt,C as Rt,Ct as zt,D as Bt,Dn as Vt,Dt as Ht,E as Ut,En as Wt,Et as Gt,F as Kt,Fn as qt,Ft as Jt,Gn as Yt,Gt as Xt,Hn as Zt,Ht as Qt,I as $t,In as en,It as tn,Jn as nn,Jt as rn,Kn as an,Kt as on,L as sn,Ln as cn,Lt as ln,Mn as un,Mt as dn,Nn as fn,Nt as pn,O as mn,On as hn,Pn as gn,Pt as _n,Q as vn,Qt as yn,Rn as bn,Rt as xn,S as Sn,St as Cn,T as wn,Tn,Tt as En,Un as Dn,Ut as On,Vn as kn,Vt as An,Wn as jn,Wt as Mn,Yt as Nn,Zt as Pn,_ as Fn,_n as In,_t as Ln,a as Rn,an as zn,b as Bn,bn as Vn,c as Hn,cn as Un,ct as Wn,dn as Gn,en as Kn,et as qn,f as Jn,ft as Yn,g as Xn,gn as Zn,gt as Qn,h as $n,hn as er,ht as tr,in as nr,jn as rr,jt as ir,k as ar,kn as or,kt as sr,ln as cr,lt as lr,m as ur,mn as dr,mt as fr,nn as pr,nt as mr,o as hr,on as gr,ot as _r,p as vr,pt as yr,qn as br,qt as xr,rn as Sr,rt as Cr,s as wr,sn as Tr,st as Er,t as Dr,tn as Or,u as kr,un as Ar,ut as jr,v as Mr,vn as Nr,w as Pr,wt as Fr,x as Ir,y as Lr,yn as Rr,yt as zr,zn as Br,zt as Vr}from"./PatchDiff-SN-mXa3p.js";import{A as Hr,C as Ur,F as Wr,K as Gr,M as Kr,N as qr,O as Jr,P as Yr,R as Y,S as Xr,_ as Zr,a as Qr,at as $r,b as ei,c as ti,d as ni,f as ri,g as ii,h as ai,i as oi,it as si,j as ci,l as li,m as ui,n as di,o as fi,ot as pi,p as mi,r as hi,s as gi,st as _i,t as vi,tt as yi,u as bi,v as xi,w as Si,x as Ci,y as wi,z as Ti}from"./query-keys-C9jMaRnO.js";import{a as Ei,i as Di,n as X,o as Oi,s as ki,t as Ai}from"./index-FOqZaR4L.js";import{a as ji,c as Mi,d as Ni,f as Pi,i as Fi,l as Ii,n as Li,o as Ri,p as zi,r as Bi,s as Vi,t as Hi,u as Ui}from"./app-shell-common-0xa28gDm.js";function Wi(e){return typeof e==`object`&&!!e&&`current`in e}var Gi={preventDefault:!0,stopPropagation:!0,eventType:`keydown`,enabled:!0,ignoreInputs:!0,conflictBehavior:`warn`};function Ki(e){return!(e.ctrl||e.meta||e.key===`Escape`)}function qi(e){if(!e)return!1;if(e instanceof HTMLInputElement){let t=e.type.toLowerCase();return!(t===`button`||t===`submit`||t===`reset`)}return!!(e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement||e instanceof HTMLElement&&e.isContentEditable)}function Ji(e){return typeof document>`u`?null:typeof Document<`u`&&e instanceof Document||typeof Node<`u`&&e.nodeType===Node.DOCUMENT_NODE?e.activeElement:typeof HTMLElement<`u`&&e instanceof HTMLElement?e.ownerDocument.activeElement??null:e.document.activeElement??null}function Yi(e,t,n){let r=Ji(t);return r&&qi(r)&&r!==n||e.composedPath().some(e=>qi(e)&&e!==n)?!0:qi(e.target)&&e.target!==n}function Xi(e,t){return t===document||t===window?e.currentTarget===t||e.currentTarget===document.documentElement:t===window?e.currentTarget===window||e.currentTarget===document||e.currentTarget===document.documentElement:!!(t instanceof HTMLElement&&(e.currentTarget===t||e.target instanceof Node&&t.contains(e.target)))}function Zi(e,t,n,r){if(n!==`allow`){if(n===`warn`){console.warn(`'${t}' is already registered. Multiple handlers will be triggered. Use conflictBehavior: 'replace' to replace the existing handler, or conflictBehavior: 'allow' to suppress this warning.`);return}if(n===`error`)throw Error(`'${t}' is already registered. Use conflictBehavior: 'replace' to replace the existing handler, or conflictBehavior: 'allow' to allow multiple registrations.`);r(e)}}var Qi=function(e){return e[e.None=0]=`None`,e[e.Mutable=1]=`Mutable`,e[e.Watching=2]=`Watching`,e[e.RecursedCheck=4]=`RecursedCheck`,e[e.Recursed=8]=`Recursed`,e[e.Dirty=16]=`Dirty`,e[e.Pending=32]=`Pending`,e}({});function $i({update:e,notify:t,unwatched:n}){return{link:r,unlink:i,propagate:a,checkDirty:o,shallowPropagate:s};function r(e,t,n){let r=t.depsTail;if(r!==void 0&&r.dep===e)return;let i=r===void 0?t.deps:r.nextDep;if(i!==void 0&&i.dep===e){i.version=n,t.depsTail=i;return}let a=e.subsTail;if(a!==void 0&&a.version===n&&a.sub===t)return;let o=t.depsTail=e.subsTail={version:n,dep:e,sub:t,prevDep:r,nextDep:i,prevSub:a,nextSub:void 0};i!==void 0&&(i.prevDep=o),r===void 0?t.deps=o:r.nextDep=o,a===void 0?e.subs=o:a.nextSub=o}function i(e,t=e.sub){let r=e.dep,i=e.prevDep,a=e.nextDep,o=e.nextSub,s=e.prevSub;return a===void 0?t.depsTail=i:a.prevDep=i,i===void 0?t.deps=a:i.nextDep=a,o===void 0?r.subsTail=s:o.prevSub=s,s===void 0?(r.subs=o)===void 0&&n(r):s.nextSub=o,a}function a(e){let n=e.nextSub,r;top:do{let i=e.sub,a=i.flags;if(a&(Qi.RecursedCheck|Qi.Recursed|Qi.Dirty|Qi.Pending)?a&(Qi.RecursedCheck|Qi.Recursed)?a&Qi.RecursedCheck?!(a&(Qi.Dirty|Qi.Pending))&&c(e,i)?(i.flags=a|(Qi.Recursed|Qi.Pending),a&=Qi.Mutable):a=Qi.None:i.flags=a&~Qi.Recursed|Qi.Pending:a=Qi.None:i.flags=a|Qi.Pending,a&Qi.Watching&&t(i),a&Qi.Mutable){let t=i.subs;if(t!==void 0){let i=(e=t).nextSub;i!==void 0&&(r={value:n,prev:r},n=i);continue}}if((e=n)!==void 0){n=e.nextSub;continue}for(;r!==void 0;)if(e=r.value,r=r.prev,e!==void 0){n=e.nextSub;continue top}break}while(!0)}function o(t,n){let r,i=0,a=!1;top:do{let o=t.dep,c=o.flags;if(n.flags&Qi.Dirty)a=!0;else if((c&(Qi.Mutable|Qi.Dirty))===(Qi.Mutable|Qi.Dirty)){if(e(o)){let e=o.subs;e.nextSub!==void 0&&s(e),a=!0}}else if((c&(Qi.Mutable|Qi.Pending))===(Qi.Mutable|Qi.Pending)){(t.nextSub!==void 0||t.prevSub!==void 0)&&(r={value:t,prev:r}),t=o.deps,n=o,++i;continue}if(!a){let e=t.nextDep;if(e!==void 0){t=e;continue}}for(;i--;){let i=n.subs,o=i.nextSub!==void 0;if(o?(t=r.value,r=r.prev):t=i,a){if(e(n)){o&&s(i),n=t.sub;continue}a=!1}else n.flags&=~Qi.Pending;n=t.sub;let c=t.nextDep;if(c!==void 0){t=c;continue top}}return a}while(!0)}function s(e){do{let n=e.sub,r=n.flags;(r&(Qi.Pending|Qi.Dirty))===Qi.Pending&&(n.flags=r|Qi.Dirty,(r&(Qi.Watching|Qi.RecursedCheck))===Qi.Watching&&t(n))}while((e=e.nextSub)!==void 0)}function c(e,t){let n=t.depsTail;for(;n!==void 0;){if(n===e)return!0;n=n.prevDep}return!1}}function ea(e,t,n){let r=typeof e==`object`,i=r?e:void 0;return{next:(r?e.next:e)?.bind(i),error:(r?e.error:t)?.bind(i),complete:(r?e.complete:n)?.bind(i)}}var ta=[],na=0,{link:ra,unlink:ia,propagate:aa,checkDirty:oa,shallowPropagate:sa}=$i({update(e){return e._update()},notify(e){ta[la++]=e,e.flags&=~Qi.Watching},unwatched(e){e.depsTail!==void 0&&(e.depsTail=void 0,e.flags=Qi.Mutable|Qi.Dirty,pa(e))}}),ca=0,la=0,ua,da=0;function fa(e){try{++da,e()}finally{--da||ma()}}function pa(e){let t=e.depsTail,n=t===void 0?e.deps:t.nextDep;for(;n!==void 0;)n=ia(n,e)}function ma(){if(!(da>0)){for(;ca<la;){let e=ta[ca];ta[ca++]=void 0,e.notify()}ca=0,la=0}}function ha(e,t){let n=typeof e==`function`,r=e,i={_snapshot:n?void 0:e,subs:void 0,subsTail:void 0,deps:void 0,depsTail:void 0,flags:n?Qi.None:Qi.Mutable,get(){return ua!==void 0&&ra(i,ua,na),i._snapshot},subscribe(e){let t=ea(e),n={current:!1},r=ga(()=>{i.get(),n.current?t.next?.(i._snapshot):n.current=!0});return{unsubscribe:()=>{r.stop()}}},_update(e){let a=ua,o=t?.compare??Object.is;if(n)ua=i,++na,i.depsTail=void 0;else if(e===void 0)return!1;n&&(i.flags=Qi.Mutable|Qi.RecursedCheck);try{let t=i._snapshot,a=typeof e==`function`?e(t):e===void 0&&n?r(t):e;return t===void 0||!o(t,a)?(i._snapshot=a,!0):!1}finally{ua=a,n&&(i.flags&=~Qi.RecursedCheck),pa(i)}}};return n?(i.flags=Qi.Mutable|Qi.Dirty,i.get=function(){let e=i.flags;if(e&Qi.Dirty||e&Qi.Pending&&oa(i.deps,i)){if(i._update()){let e=i.subs;e!==void 0&&sa(e)}}else e&Qi.Pending&&(i.flags=e&~Qi.Pending);return ua!==void 0&&ra(i,ua,na),i._snapshot}):i.set=function(e){if(i._update(e)){let e=i.subs;e!==void 0&&(aa(e),sa(e),ma())}},i}function ga(e){let t=()=>{let t=ua;ua=n,++na,n.depsTail=void 0,n.flags=Qi.Watching|Qi.RecursedCheck;try{return e()}finally{ua=t,n.flags&=~Qi.RecursedCheck,pa(n)}},n={deps:void 0,depsTail:void 0,subs:void 0,subsTail:void 0,flags:Qi.Watching|Qi.RecursedCheck,notify(){let e=this.flags;e&Qi.Dirty||e&Qi.Pending&&oa(this.deps,this)?t():this.flags=Qi.Watching},stop(){this.flags=Qi.None,this.depsTail=void 0,pa(this)}};return t(),n}var _a=class{constructor(e,t){this.atom=ha(e),this.get=this.get.bind(this),this.setState=this.setState.bind(this),this.subscribe=this.subscribe.bind(this),t&&(this.actions=t(this))}setState(e){this.atom.set(e)}get state(){return this.atom.get()}get(){return this.state}subscribe(e){return this.atom.subscribe(ea(e))}},va=class{constructor(e){this.atom=ha(e)}get state(){return this.atom.get()}get(){return this.state}subscribe(e){return this.atom.subscribe(ea(e))}};function ya(e,t){return typeof e==`function`?new va(e):t?new _a(e,t):new _a(e)}function ba(e,t){if(Object.is(e,t))return!0;if(typeof e!=`object`||!e||typeof t!=`object`||!t)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(let[n,r]of e)if(!t.has(n)||!Object.is(r,t.get(n)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}if(e instanceof Date&&t instanceof Date)return e.getTime()===t.getTime();let n=xa(e);if(n.length!==xa(t).length)return!1;for(let r=0;r<n.length;r++)if(!Object.prototype.hasOwnProperty.call(t,n[r])||!Object.is(e[n[r]],t[n[r]]))return!1;return!0}function xa(e){return Object.keys(e).concat(Object.getOwnPropertySymbols(e))}var Sa=0;function Ca(){return`hotkey_${++Sa}`}var wa=class e{static#e=null;#t;#n=new Map;#r=new Map;constructor(){this.registrations=new _a(new Map),this.#t=jn()}static getInstance(){return e.#e||=new e,e.#e}static resetInstance(){e.#e&&=(e.#e.destroy(),null)}register(e,t,n={}){if(typeof document>`u`&&!n.target){let e=t;return{id:Ca(),unregister:()=>{},get callback(){return e},set callback(t){e=t},setOptions:()=>{},get isActive(){return!1}}}let r=Ca(),i=n.platform??this.#t,a=typeof e==`string`?Zt(e,i):Dn(e,i),o=typeof e==`string`?e:It(a),s=n.target??document,c=n.conflictBehavior??`warn`,l=this.#d(o,s);l&&Zi(l.id,o,c,e=>this.#i(e));let u=n.ignoreInputs??Ki(a),d={id:r,hotkey:o,parsedHotkey:a,callback:t,options:{...Gi,requireReset:!1,...n,platform:i,ignoreInputs:u},hasFired:!1,triggerCount:0,target:s};this.registrations.setState(e=>new Map(e).set(r,d)),this.#r.has(s)||this.#r.set(s,new Set),this.#r.get(s).add(r),this.#a(s);let f=this;return{get id(){return r},unregister:()=>{f.#i(r)},get callback(){return f.registrations.state.get(r)?.callback??t},set callback(e){let t=f.registrations.state.get(r);t&&(t.callback=e)},setOptions:e=>{f.registrations.setState(t=>{let n=t.get(r);if(n){let i=new Map(t);return i.set(r,{...n,options:{...n.options,...e}}),i}return t})},get isActive(){return f.registrations.state.has(r)}}}#i(e){let t=this.registrations.state.get(e);if(!t)return;let n=t.target;this.registrations.setState(t=>{let n=new Map(t);return n.delete(e),n});let r=this.#r.get(n);r&&(r.delete(e),r.size===0&&this.#o(n))}#a(e){if(typeof document>`u`||this.#n.has(e))return;let t=this.#l(e),n=this.#u(e);e.addEventListener(`keydown`,t),e.addEventListener(`keyup`,n),this.#n.set(e,{keydown:t,keyup:n})}#o(e){if(typeof document>`u`)return;let t=this.#n.get(e);t&&(e.removeEventListener(`keydown`,t.keydown),e.removeEventListener(`keyup`,t.keyup),this.#n.delete(e),this.#r.delete(e))}#s(e,t,n){let r=this.#r.get(t);if(r)for(let i of r){let r=this.registrations.state.get(i);if(r&&Xi(e,t)&&r.options.enabled&&!(r.options.ignoreInputs!==!1&&Yi(e,t,r.target)))if(n===`keydown`){if(r.options.eventType!==`keydown`)continue;Br(e,r.parsedHotkey,r.options.platform)&&(r.options.preventDefault&&e.preventDefault(),r.options.stopPropagation&&e.stopPropagation(),(!r.options.requireReset||!r.hasFired)&&(this.#c(r,e),r.options.requireReset&&(r.hasFired=!0)))}else r.options.eventType===`keyup`&&Br(e,r.parsedHotkey,r.options.platform)&&this.#c(r,e),r.options.requireReset&&r.hasFired&&this.#f(r,e)&&(r.hasFired=!1)}}#c(e,t){e.options.preventDefault&&t.preventDefault(),e.options.stopPropagation&&t.stopPropagation(),e.triggerCount++,this.registrations.setState(e=>new Map(e));let n={hotkey:e.hotkey,parsedHotkey:e.parsedHotkey};e.callback(t,n)}#l(e){return t=>{this.#s(t,e,`keydown`)}}#u(e){return t=>{this.#s(t,e,`keyup`)}}#d(e,t){for(let n of this.registrations.state.values())if(n.hotkey===e&&n.target===t)return n;return null}#f(e,t){let n=e.parsedHotkey,r=Yt(t.key),i=n.key.length===1?n.key.toUpperCase():n.key;return!!((r.length===1?r.toUpperCase():r)===i||n.ctrl&&r===`Control`||n.shift&&r===`Shift`||n.alt&&r===`Alt`||n.meta&&r===`Meta`)}triggerRegistration(e){let t=this.registrations.state.get(e);if(!t)return!1;let n=t.parsedHotkey,r=new KeyboardEvent(t.options.eventType??`keydown`,{key:n.key,ctrlKey:n.ctrl,shiftKey:n.shift,altKey:n.alt,metaKey:n.meta,bubbles:!0,cancelable:!0});return t.triggerCount++,this.registrations.setState(e=>new Map(e)),t.callback(r,{hotkey:t.hotkey,parsedHotkey:t.parsedHotkey}),!0}getRegistrationCount(){return this.registrations.state.size}isRegistered(e,t){for(let n of this.registrations.state.values())if(n.hotkey===e&&(t===void 0||n.target===t))return!0;return!1}destroy(){for(let e of this.#n.keys())this.#o(e);this.registrations.setState(()=>new Map),this.#n.clear(),this.#r.clear()}};function Ta(){return wa.getInstance()}var Z=e(xe(),1);function Ea(e,t={}){let n=Oi().hotkey,r=Ta(),i=t.platform??n?.platform??jn(),a=(0,Z.useRef)(new Map),o=(0,Z.useRef)(e),s=(0,Z.useRef)([]),c=(0,Z.useRef)(t),l=(0,Z.useRef)(n),u=(0,Z.useRef)(r),d=e.map(e=>kn(e.hotkey,i));o.current=e,s.current=d,c.current=t,l.current=n,u.current=r,(0,Z.useEffect)(()=>{let e=a.current,t=new Map,n=[];for(let e=0;e<o.current.length;e++){let t=o.current[e],r=s.current[e],i={...l.current,...c.current,...t.options},a=Wi(i.target)?i.target.current:i.target??(typeof document<`u`?document:null);if(!a)continue;let u=`${e}:${r}`;n.push({registrationKey:u,def:t,hotkeyStr:r,mergedOptions:i,resolvedTarget:a})}let r=new Set(n.map(e=>e.registrationKey));for(let[t,n]of e)!r.has(t)&&n.handle.isActive&&n.handle.unregister();for(let r of n){let{registrationKey:n,def:i,hotkeyStr:a,mergedOptions:o,resolvedTarget:s}=r,c=e.get(n);if(c?.handle.isActive&&c.target===s){t.set(n,c);continue}c?.handle.isActive&&c.handle.unregister();let l=u.current.register(a,i.callback,{...o,target:s});t.set(n,{handle:l,target:s})}a.current=t}),(0,Z.useEffect)(()=>()=>{for(let{handle:e}of a.current.values())e.isActive&&e.unregister();a.current=new Map},[]);for(let r=0;r<e.length;r++){let i=e[r],o=d[r],s=`${r}:${o}`,c=a.current.get(s)?.handle;if(c?.isActive){c.callback=i.callback;let{target:e,...r}={...n,...t,...i.options};c.setOptions(r)}}}var Da=ge();function Oa(e,t){return e===t}function ka(e,t=e=>e,n){let r=n?.compare??Oa,i=(0,Z.useCallback)(t=>{let{unsubscribe:n}=e.subscribe(t);return n},[e]),a=(0,Z.useCallback)(()=>e.get(),[e]);return(0,Da.useSyncExternalStoreWithSelector)(i,a,a,t,r)}var Aa=b(`arrow-up-to-line`,[[`path`,{d:`M5 3h14`,key:`7usisc`}],[`path`,{d:`m18 13-6-6-6 6`,key:`1kf1n9`}],[`path`,{d:`M12 7v14`,key:`1akyts`}]]),ja=b(`ellipsis-vertical`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`12`,cy:`5`,r:`1`,key:`gxeob9`}],[`circle`,{cx:`12`,cy:`19`,r:`1`,key:`lyex9k`}]]),Ma=b(`folder-plus`,[[`path`,{d:`M12 10v6`,key:`1bos4e`}],[`path`,{d:`M9 13h6`,key:`1uhe8q`}],[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}]]),Na=b(`folder`,[[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}]]),Pa=b(`git-pull-request-arrow`,[[`circle`,{cx:`5`,cy:`6`,r:`3`,key:`1qnov2`}],[`path`,{d:`M5 9v12`,key:`ih889a`}],[`circle`,{cx:`19`,cy:`18`,r:`3`,key:`1qljk2`}],[`path`,{d:`m15 9-3-3 3-3`,key:`1lwv8l`}],[`path`,{d:`M12 6h5a2 2 0 0 1 2 2v7`,key:`1yj91y`}]]),Fa=b(`image-plus`,[[`path`,{d:`M16 5h6`,key:`1vod17`}],[`path`,{d:`M19 2v6`,key:`4bpg5p`}],[`path`,{d:`M21 11.5V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7.5`,key:`1ue2ih`}],[`path`,{d:`m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21`,key:`1xmnt7`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}]]),Ia=b(`list-end`,[[`path`,{d:`M16 5H3`,key:`m91uny`}],[`path`,{d:`M16 12H3`,key:`1a2rj7`}],[`path`,{d:`M9 19H3`,key:`s61nz1`}],[`path`,{d:`m16 16-3 3 3 3`,key:`117b85`}],[`path`,{d:`M21 5v12a2 2 0 0 1-2 2h-6`,key:`hey24a`}]]),La=b(`list-start`,[[`path`,{d:`M3 5h6`,key:`1ltk0q`}],[`path`,{d:`M3 12h13`,key:`ppymz1`}],[`path`,{d:`M3 19h13`,key:`bpdczq`}],[`path`,{d:`m16 8-3-3 3-3`,key:`1pjpp6`}],[`path`,{d:`M21 19V7a2 2 0 0 0-2-2h-6`,key:`4zzq67`}]]),Ra=b(`panel-left`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}]]),za=b(`panel-right`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M15 3v18`,key:`14nvp0`}]]),Ba=b(`settings-2`,[[`path`,{d:`M14 17H5`,key:`gfn3mx`}],[`path`,{d:`M19 7h-9`,key:`6i9tg`}],[`circle`,{cx:`17`,cy:`17`,r:`3`,key:`18b49y`}],[`circle`,{cx:`7`,cy:`7`,r:`3`,key:`dfmy0x`}]]),Va=b(`square-pen`,[[`path`,{d:`M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7`,key:`1m0v6g`}],[`path`,{d:`M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z`,key:`ohrbg2`}]]),Ha=b(`square-terminal`,[[`path`,{d:`m7 11 2-2-2-2`,key:`1lz0vl`}],[`path`,{d:`M11 13h4`,key:`1p7l4v`}],[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}]]),Ua=b(`square`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]);function Wa(e){return H(e.defaultTagName??`div`,e,e)}function Ga(e){return typeof e==`function`}function Ka(e,...t){return Ga(e)?e(...t):e}var qa=class{#e=!0;#t;#n;#r;#i;#a;#o;#s;#c=0;#l=5;#u=!1;#d=!1;#f=null;#p=()=>{this.debugLog(`Connected to event bus`),this.#a=!0,this.#u=!1,this.debugLog(`Emitting queued events`,this.#i),this.#i.forEach(e=>this.emitEventToBus(e)),this.#i=[],this.stopConnectLoop(),this.#n().removeEventListener(`tanstack-connect-success`,this.#p)};#m=()=>{if(this.#c<this.#l){this.#c++,this.dispatchCustomEvent(`tanstack-connect`,{});return}this.#n().removeEventListener(`tanstack-connect`,this.#m),this.#d=!0,this.debugLog(`Max retries reached, giving up on connection`),this.stopConnectLoop()};#h=()=>{this.#u||(this.#u=!0,this.#n().addEventListener(`tanstack-connect-success`,this.#p),this.#m())};constructor({pluginId:e,debug:t=!1,enabled:n=!0,reconnectEveryMs:r=300}){this.#t=e,this.#e=n,this.#n=this.getGlobalTarget,this.#r=t,this.debugLog(` Initializing event subscription for plugin`,this.#t),this.#i=[],this.#a=!1,this.#d=!1,this.#o=null,this.#s=r}startConnectLoop(){this.#o!==null||this.#a||(this.debugLog(`Starting connect loop (every ${this.#s}ms)`),this.#o=setInterval(this.#m,this.#s))}stopConnectLoop(){this.#u=!1,this.#o!==null&&(clearInterval(this.#o),this.#o=null,this.#i=[],this.debugLog(`Stopped connect loop`))}debugLog(...e){this.#r&&console.log(`🌴 [tanstack-devtools:${this.#t}-plugin]`,...e)}getGlobalTarget(){if(typeof globalThis<`u`&&globalThis.__TANSTACK_EVENT_TARGET__)return this.debugLog(`Using global event target`),globalThis.__TANSTACK_EVENT_TARGET__;if(typeof window<`u`&&window.addEventListener!==void 0)return this.debugLog(`Using window as event target`),window;let e=typeof EventTarget<`u`?new EventTarget:void 0;return e===void 0||e.addEventListener===void 0?(this.debugLog(`No event mechanism available, running in non-web environment`),{addEventListener:()=>{},removeEventListener:()=>{},dispatchEvent:()=>!1}):(this.debugLog(`Using new EventTarget as fallback`),e)}getPluginId(){return this.#t}dispatchCustomEventShim(e,t){try{let n=new Event(e,{detail:t});this.#n().dispatchEvent(n)}catch{this.debugLog(`Failed to dispatch shim event`)}}dispatchCustomEvent(e,t){try{this.#n().dispatchEvent(new CustomEvent(e,{detail:t}))}catch{this.dispatchCustomEventShim(e,t)}}emitEventToBus(e){this.debugLog(`Emitting event to client bus`,e),this.dispatchCustomEvent(`tanstack-dispatch-event`,e)}createEventPayload(e,t){return{type:`${this.#t}:${e}`,payload:t,pluginId:this.#t}}emit(e,t){if(!this.#e){this.debugLog(`Event bus client is disabled, not emitting event`,e,t);return}if(this.#f&&(this.debugLog(`Emitting event to internal event target`,e,t),this.#f.dispatchEvent(new CustomEvent(`${this.#t}:${e}`,{detail:this.createEventPayload(e,t)}))),this.#d){this.debugLog(`Previously failed to connect, not emitting to bus`);return}if(!this.#a){this.debugLog(`Bus not available, will be pushed as soon as connected`),this.#i.push(this.createEventPayload(e,t)),typeof CustomEvent<`u`&&!this.#u&&(this.#h(),this.startConnectLoop());return}return this.emitEventToBus(this.createEventPayload(e,t))}on(e,t,n){let r=n?.withEventTarget??!1,i=`${this.#t}:${e}`;if(r&&(this.#f||=new EventTarget,this.#f.addEventListener(i,e=>{t(e.detail)})),!this.#e)return this.debugLog(`Event bus client is disabled, not registering event`,i),()=>{};let a=e=>{this.debugLog(`Received event from bus`,e.detail),t(e.detail)};return this.#n().addEventListener(i,a),this.debugLog(`Registered event to bus`,i),()=>{r&&this.#f?.removeEventListener(i,a),this.#n().removeEventListener(i,a)}}onAll(e){if(!this.#e)return this.debugLog(`Event bus client is disabled, not registering event`),()=>{};let t=t=>{let n=t.detail;e(n)};return this.#n().addEventListener(`tanstack-devtools-global`,t),()=>this.#n().removeEventListener(`tanstack-devtools-global`,t)}onAllPluginEvents(e){if(!this.#e)return this.debugLog(`Event bus client is disabled, not registering event`),()=>{};let t=t=>{let n=t.detail;this.#t&&n.pluginId!==this.#t||e(n)};return this.#n().addEventListener(`tanstack-devtools-global`,t),()=>this.#n().removeEventListener(`tanstack-devtools-global`,t)}},Ja=new Map;function Ya(e,t){Ja.set(e,t)}function Xa(e){if(e!==void 0)try{return JSON.parse(JSON.stringify(e))}catch{return null}}function Za(e){return typeof e.get==`function`?e.get():e.state}function Qa(e){return{key:e.key,store:{state:Xa(Za(e.store))},options:Xa(e.options)}}var $a=class extends qa{constructor(e){super({pluginId:`pacer`,debug:e?.debug,reconnectEveryMs:1e3})}},eo=(e,t)=>{let n=t.key;n&&(Ya(n,t),to.emit(e,Qa({...t,key:n})))},to=new $a;function no(){return{currentAttempt:0,executionCount:0,isExecuting:!1,lastError:void 0,lastExecutionTime:0,lastResult:void 0,status:`idle`,totalExecutionTime:0}}var ro={backoff:`exponential`,baseWait:1e3,maxWait:1/0,enabled:!0,jitter:0,maxAttempts:3,maxExecutionTime:1/0,maxTotalExecutionTime:1/0,throwOnError:`last`},io=class{#e;constructor(e,t={}){this.fn=e,this.store=new _a(no()),this.#e=null,this.setOptions=e=>{this.options={...this.options,...e}},this.#t=e=>{this.store.setState(t=>{let n={...t,...e},{isExecuting:r,currentAttempt:i}=n;return{...n,status:this.#n()?r&&i===1?`executing`:r&&i>1?`retrying`:`idle`:`disabled`}}),eo(`AsyncRetryer`,this)},this.#n=()=>!!Ka(this.options.enabled,this),this.#r=()=>Ka(this.options.maxAttempts,this),this.#i=()=>Ka(this.options.baseWait,this),this.#a=()=>Ka(this.options.maxWait,this),this.#o=e=>{let t=this.options.jitter;if(t<=0)return 0;try{let n=typeof globalThis<`u`?globalThis.crypto:void 0;if(n?.getRandomValues){let r=new Uint32Array(1);n.getRandomValues(r);let i=r[0]/4294967295*2-1;return Math.floor(e*t*i)}}catch{}return 0},this.#s=e=>{let t=this.#i(),n;switch(this.options.backoff){case`linear`:n=t*e;break;case`exponential`:n=t*2**(e-1);break;default:n=t;break}n=Math.min(n,this.#a());let r=this.#o(n);return Math.max(0,n+r)},this.execute=async(...e)=>{if(!this.#n())return;this.abort(`new-execution`);let t=Date.now(),n,r;this.#e=new AbortController;let i=this.#e.signal;this.#t({isExecuting:!0,currentAttempt:0,lastError:void 0});let a;this.options.maxTotalExecutionTime!==1/0&&(a=setTimeout(()=>{this.options.onTotalExecutionTimeout?.(this),this.abort(`total-timeout`)},this.options.maxTotalExecutionTime));let o=!1;for(let a=1;a<=this.#r();a++){o=a===this.#r(),this.#t({currentAttempt:a});try{if(i.aborted)return;let n=Date.now()-t;if(this.options.maxTotalExecutionTime!==1/0&&n>=this.options.maxTotalExecutionTime){this.options.onTotalExecutionTimeout?.(this),this.abort(`total-timeout`);return}if(r=this.options.maxExecutionTime===1/0?await this.fn(...e):await Promise.race([this.fn(...e),new Promise((e,t)=>{let n=setTimeout(()=>{this.options.onExecutionTimeout?.(this),this.abort(`execution-timeout`),t(Error(`Execution timeout: ${this.options.maxExecutionTime}ms exceeded`))},this.options.maxExecutionTime);i.addEventListener(`abort`,()=>{clearTimeout(n),t(Error(`Aborted`))},{once:!0})})]),i.aborted)return;let a=Date.now()-t;return this.#t({executionCount:this.store.state.executionCount+1,isExecuting:!1,lastExecutionTime:Date.now(),totalExecutionTime:a,currentAttempt:0,lastResult:r}),this.options.onSuccess?.(r,e,this),r}catch(t){if(t&&typeof t==`object`&&`name`in t&&t.name===`AbortError`)return;if(n=t instanceof Error?t:Error(String(t)),this.#t({lastError:n}),this.options.onError?.(n,e,this),a<this.#r()){this.options.onRetry?.(a,n,this);let e=this.#s(a);if(e>0&&(this.#t({isExecuting:!0,currentAttempt:a+1}),await new Promise(t=>{let n=setTimeout(()=>{i.removeEventListener(`abort`,r),t()},e),r=()=>{clearTimeout(n),i.removeEventListener(`abort`,r),t()};i.addEventListener(`abort`,r)}),i.aborted))return}}finally{this.options.onSettled?.(e,this)}}if(a&&clearTimeout(a),this.#t({isExecuting:!1}),this.options.onLastError?.(n,this),this.options.onSettled?.(e,this),this.options.throwOnError===`last`&&o||this.options.throwOnError===!0)throw n},this.getAbortSignal=()=>this.#e?.signal??null,this.abort=(e=`manual`)=>{this.#e&&(this.#e.abort(),this.#e=null,this.#t({isExecuting:!1}),this.options.onAbort?.(e,this))},this.reset=()=>{this.#t(no())},this.key=t.key,this.options={...ro,...t,throwOnError:t.throwOnError??(t.onError?!1:ro.throwOnError)},this.#t(this.options.initialState??{}),this.key&&to.on(`d-AsyncRetryer`,e=>{e.payload.key===this.key&&(this.#t(e.payload.store.state),this.setOptions(e.payload.options))})}#t;#n;#r;#i;#a;#o;#s};function ao(){return{canLeadingExecute:!0,errorCount:0,isExecuting:!1,isPending:!1,lastArgs:void 0,lastResult:void 0,maybeExecuteCount:0,settleCount:0,status:`idle`,successCount:0}}var oo={asyncRetryerOptions:{maxAttempts:1},enabled:!0,leading:!1,trailing:!0,wait:0},so=class{#e;#t;constructor(e,t){this.fn=e,this.store=new _a(ao()),this.asyncRetryers=new Map,this.#e=null,this.#t=null,this.setOptions=e=>{this.options={...this.options,...e},this.#r()||this.cancel()},this.#n=e=>{this.store.setState(t=>{let n={...t,...e},{isPending:r,isExecuting:i,settleCount:a}=n;return{...n,status:this.#r()?r?`pending`:i?`executing`:a>0?`settled`:`idle`:`disabled`}}),eo(`AsyncDebouncer`,this)},this.#r=()=>!!Ka(this.options.enabled,this),this.#i=()=>Ka(this.options.wait,this),this.maybeExecute=async(...e)=>{if(this.#r())return this.#c(),this.#n({lastArgs:e,maybeExecuteCount:this.store.state.maybeExecuteCount+1}),this.options.leading&&this.store.state.canLeadingExecute?(this.#n({canLeadingExecute:!1}),await this.#a(...e),this.store.state.lastResult):(this.options.trailing&&this.#r()&&this.#n({isPending:!0}),new Promise((e,t)=>{this.#t=e,this.#e=setTimeout(async()=>{if(this.options.trailing&&this.store.state.lastArgs)try{await this.#a(...this.store.state.lastArgs)}catch(e){t(e)}this.#n({canLeadingExecute:!0}),this.#t=null,e(this.store.state.lastResult)},this.#i())}))},this.#a=async(...e)=>{if(!this.#r())return;let t=this.store.state.maybeExecuteCount+1;try{this.#n({isExecuting:!0});let n=new io(this.fn,{...this.options.asyncRetryerOptions,key:`${this.key}-retryer-${t}`});this.asyncRetryers.set(t,n);let r=await n.execute(...e);this.#n({lastResult:r,successCount:this.store.state.successCount+1}),this.options.onSuccess?.(r,e,this)}catch(t){if(this.#n({errorCount:this.store.state.errorCount+1}),this.options.onError?.(t,e,this),this.options.throwOnError)throw t}finally{this.asyncRetryers.delete(t),this.#n({isExecuting:!1,isPending:!1,lastArgs:void 0,settleCount:this.store.state.settleCount+1}),this.options.onSettled?.(e,this)}return this.store.state.lastResult},this.flush=async()=>{if(this.store.state.isPending&&this.store.state.lastArgs){let{lastArgs:e}=this.store.state;return this.#c(),await this.#a(...e)}},this.#o=()=>{this.#t&&=(this.#t(this.store.state.lastResult),null)},this.#s=()=>{this.#e&&=(clearTimeout(this.#e),null)},this.#c=()=>{this.#s(),this.#o(),this.#n({isPending:!1,lastArgs:void 0})},this.getAbortSignal=e=>{let t=e??this.store.state.maybeExecuteCount;return this.asyncRetryers.get(t)?.getAbortSignal()??null},this.abort=()=>{this.asyncRetryers.forEach(e=>e.abort()),this.asyncRetryers.clear(),this.#n({isExecuting:!1})},this.cancel=()=>{this.#c(),this.#n({canLeadingExecute:!0})},this.reset=()=>{this.#n(ao()),this.asyncRetryers.forEach(e=>e.reset())},this.key=t.key,this.options={...oo,...t,throwOnError:t.throwOnError??!t.onError},this.#n(this.options.initialState??{}),this.key&&to.on(`d-AsyncDebouncer`,e=>{e.payload.key===this.key&&(this.#n(e.payload.store.state),this.setOptions(e.payload.options))})}#n;#r;#i;#a;#o;#s;#c};function co(){return{executionCount:0,isEmpty:!0,isPending:!1,totalItemsProcessed:0,items:[],size:0,status:`idle`}}var lo={getShouldExecute:()=>!1,maxSize:1/0,started:!0,wait:1/0},uo=class{#e;constructor(e,t){this.fn=e,this.store=new _a(co()),this.#e=null,this.setOptions=e=>{this.options={...this.options,...e}},this.#t=e=>{this.store.setState(t=>{let n={...t,...e},{isPending:r,items:i}=n,a=i.length,o=a===0;return{...n,isEmpty:o,size:a,status:r?`pending`:`idle`}}),eo(`Batcher`,this)},this.#n=()=>Ka(this.options.wait,this),this.addItem=e=>{this.#t({items:[...this.store.state.items,e],isPending:this.options.wait!==1/0}),this.options.onItemsChange?.(this),this.store.state.items.length>=this.options.maxSize||this.options.getShouldExecute(this.store.state.items,this)?this.#r():this.options.wait!==1/0&&(this.#i(),this.#e=setTimeout(()=>this.#r(),this.#n()))},this.#r=()=>{if(this.store.state.items.length===0)return;let e=this.peekAllItems();this.clear(),this.options.onItemsChange?.(this),this.fn(e),this.#t({executionCount:this.store.state.executionCount+1,totalItemsProcessed:this.store.state.totalItemsProcessed+e.length}),this.options.onExecute?.(e,this)},this.flush=()=>{this.#i(),this.#r()},this.peekAllItems=()=>[...this.store.state.items],this.#i=()=>{this.#e&&=(clearTimeout(this.#e),null)},this.clear=()=>{this.#t({items:[],isPending:!1})},this.cancel=()=>{this.#i(),this.#t({isPending:!1})},this.reset=()=>{this.#t(co()),this.options.onItemsChange?.(this)},this.key=t.key,this.options={...lo,...t},this.#t(this.options.initialState??{}),this.key&&to.on(`d-Batcher`,e=>{e.payload.key===this.key&&(this.#t(e.payload.store.state),this.setOptions(e.payload.options))})}#t;#n;#r;#i};function fo(){return{executionCount:0,isPending:!1,lastArgs:void 0,lastExecutionTime:0,nextExecutionTime:0,status:`idle`,maybeExecuteCount:0}}var po={enabled:!0,leading:!0,trailing:!0,wait:0},mo=class{#e;constructor(e,t){this.fn=e,this.store=new _a(fo()),this.setOptions=e=>{this.options={...this.options,...e},this.#n()||this.cancel()},this.#t=e=>{this.store.setState(t=>{let n={...t,...e},{isPending:r}=n;return{...n,status:this.#n()?r?`pending`:`idle`:`disabled`}}),eo(`Throttler`,this)},this.#n=()=>!!Ka(this.options.enabled,this),this.#r=()=>Ka(this.options.wait,this),this.maybeExecute=(...e)=>{this.#t({maybeExecuteCount:this.store.state.maybeExecuteCount+1});let t=Date.now(),n=t-this.store.state.lastExecutionTime,r=this.#r();if(this.options.leading&&n>=r)this.#i(...e);else if(this.#t({lastArgs:e}),!this.#e&&this.options.trailing){let e=r-(this.store.state.lastExecutionTime?t-this.store.state.lastExecutionTime:0);this.#t({isPending:!0}),this.#e=setTimeout(()=>{let{lastArgs:e}=this.store.state;e!==void 0&&this.#i(...e)},e)}},this.#i=(...e)=>{if(!this.#n())return;this.fn(...e);let t=Date.now(),n=t+this.#r();this.#a(),this.#t({executionCount:this.store.state.executionCount+1,lastExecutionTime:t,nextExecutionTime:n,isPending:!1,lastArgs:void 0}),this.options.onExecute?.(e,this),setTimeout(()=>{this.store.state.isPending||this.#t({nextExecutionTime:void 0})},this.#r())},this.flush=()=>{this.store.state.isPending&&this.store.state.lastArgs&&this.#i(...this.store.state.lastArgs)},this.#a=()=>{this.#e&&=(clearTimeout(this.#e),void 0)},this.cancel=()=>{this.#a(),this.#t({lastArgs:void 0,isPending:!1})},this.reset=()=>{this.#t(fo())},this.key=t.key,this.options={...po,...t},this.#t(this.options.initialState??{}),this.key&&to.on(`d-Throttler`,e=>{e.payload.key===this.key&&(this.#t(e.payload.store.state),this.setOptions(e.payload.options))})}#t;#n;#r;#i;#a},Q=ut(),$=He();function ho(e){let t=(0,Q.c)(10),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,orientation:i,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a=i===void 0?`horizontal`:i,o;t[4]===n?o=t[5]:(o=E(`shrink-0 bg-border data-horizontal:h-px data-horizontal:w-full data-vertical:w-px data-vertical:self-stretch`,n),t[4]=n,t[5]=o);let s;return t[6]!==a||t[7]!==r||t[8]!==o?(s=(0,$.jsx)(Gt,{"data-slot":`separator`,orientation:a,className:o,...r}),t[6]=a,t[7]=r,t[8]=o,t[9]=s):s=t[9],s}function go(e){let t=(0,Q.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,$.jsx)(Si,{"data-slot":`sheet`,...n}),t[2]=n,t[3]=r),r}function _o(e){let t=(0,Q.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,$.jsx)(Hr,{"data-slot":`sheet-portal`,...n}),t[2]=n,t[3]=r),r}function vo(e){let t=(0,Q.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=E(`fixed inset-0 z-50 bg-black/10 transition-opacity duration-150 data-ending-style:opacity-0 data-starting-style:opacity-0 supports-backdrop-filter:backdrop-blur-xs`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,$.jsx)(Wr,{"data-slot":`sheet-overlay`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function yo(e){let t=(0,Q.c)(17),n,r,i,a,o;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5]):({className:r,children:n,side:a,showCloseButton:o,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o);let s=a===void 0?`right`:a,c=o===void 0?!0:o,l;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(vo,{}),t[6]=l):l=t[6];let u;t[7]===r?u=t[8]:(u=E(`fixed z-50 flex flex-col gap-4 bg-popover bg-clip-padding text-sm text-popover-foreground shadow-lg transition duration-200 ease-in-out data-ending-style:opacity-0 data-starting-style:opacity-0 data-[side=bottom]:inset-x-0 data-[side=bottom]:bottom-0 data-[side=bottom]:h-auto data-[side=bottom]:border-t data-[side=bottom]:data-ending-style:translate-y-[2.5rem] data-[side=bottom]:data-starting-style:translate-y-[2.5rem] data-[side=left]:inset-y-0 data-[side=left]:left-0 data-[side=left]:h-full data-[side=left]:w-3/4 data-[side=left]:border-r data-[side=left]:data-ending-style:translate-x-[-2.5rem] data-[side=left]:data-starting-style:translate-x-[-2.5rem] data-[side=right]:inset-y-0 data-[side=right]:right-0 data-[side=right]:h-full data-[side=right]:w-3/4 data-[side=right]:border-l data-[side=right]:data-ending-style:translate-x-[2.5rem] data-[side=right]:data-starting-style:translate-x-[2.5rem] data-[side=top]:inset-x-0 data-[side=top]:top-0 data-[side=top]:h-auto data-[side=top]:border-b data-[side=top]:data-ending-style:translate-y-[-2.5rem] data-[side=top]:data-starting-style:translate-y-[-2.5rem] data-[side=left]:sm:max-w-sm data-[side=right]:sm:max-w-sm`,r),t[7]=r,t[8]=u);let d;t[9]===c?d=t[10]:(d=c&&(0,$.jsxs)(Yr,{"data-slot":`sheet-close`,render:(0,$.jsx)(Y,{variant:`ghost`,className:`absolute top-3 right-3`,size:`icon-sm`}),children:[(0,$.jsx)(si,{}),(0,$.jsx)(`span`,{className:`sr-only`,children:`Close`})]}),t[9]=c,t[10]=d);let f;return t[11]!==n||t[12]!==i||t[13]!==s||t[14]!==u||t[15]!==d?(f=(0,$.jsxs)(_o,{children:[l,(0,$.jsxs)(Kr,{"data-slot":`sheet-content`,"data-side":s,className:u,...i,children:[n,d]})]}),t[11]=n,t[12]=i,t[13]=s,t[14]=u,t[15]=d,t[16]=f):f=t[16],f}function bo(e){let t=(0,Q.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=E(`flex flex-col gap-0.5 p-4`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,$.jsx)(`div`,{"data-slot":`sheet-header`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function xo(e){let t=(0,Q.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=E(`font-heading text-base font-medium text-foreground`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,$.jsx)(Ur,{"data-slot":`sheet-title`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function So(e){let t=(0,Q.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=E(`text-sm text-muted-foreground`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,$.jsx)(qr,{"data-slot":`sheet-description`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}var Co=`sidebar_state`,wo=3600*24*7,To=`20rem`,Eo=`16rem`,Do=`32rem`,Oo=`pico-sidebar-width`,ko=`sidebar_width`,Ao=`20rem`,jo=`3rem`,Mo=`b`,No=Z.createContext(null);function Po(e,t){let n=e.trim(),r=Number.parseFloat(n);return Number.isFinite(r)?n.endsWith(`rem`)?r*(typeof window>`u`?16:Number.parseFloat(window.getComputedStyle(document.documentElement).fontSize)||16):r:t}function Fo(e){let t=Po(To,320),n=Po(Eo,256),r=Po(Do,512),i=Po(e??``,t);return`${Math.round(Math.min(Math.max(i,n),r))}px`}function Io(){if(typeof window>`u`)return Fo(To);try{return Fo(window.localStorage.getItem(Oo)??window.localStorage.getItem(ko))}catch{return Fo(To)}}function Lo(e){try{window.localStorage.setItem(Oo,e)}catch{}}function Ro(e){let t=Z.useRef(e);return t.current=e,t}function zo(){let e=Z.use(No);if(!e)throw Error(`useSidebar must be used within a SidebarProvider.`);return e}function Bo(e){return{open:e,openMobile:!1,openMobileSettled:!1,sidebarResizing:!1,sidebarWidth:Fo(To)}}function Vo(e,t){switch(t.type){case`openChanged`:return e.open===t.open?e:{...e,open:t.open};case`openMobileChanged`:return e.openMobile===t.openMobile?e:{...e,openMobile:t.openMobile};case`openMobileSettledChanged`:return e.openMobileSettled===t.openMobileSettled?e:{...e,openMobileSettled:t.openMobileSettled};case`sidebarResizingChanged`:return e.sidebarResizing===t.sidebarResizing?e:{...e,sidebarResizing:t.sidebarResizing};case`sidebarWidthChanged`:return e.sidebarWidth===t.sidebarWidth?e:{...e,sidebarWidth:t.sidebarWidth};default:return e}}function Ho({defaultOpen:e=!0,open:t,onOpenChange:n,className:r,style:i,children:a,...o}){let s=ar(),[c,l]=Z.useReducer(Vo,e,Bo),{open:u,openMobile:d,openMobileSettled:f,sidebarResizing:p,sidebarWidth:m}=c,h=Z.useRef(m);h.current=m,Z.useEffect(()=>{let e=Io();h.current!==e&&(h.current=e,l({type:`sidebarWidthChanged`,sidebarWidth:e}))},[]);let g=e=>{let t=Fo(e);h.current!==t&&(h.current=t,l({type:`sidebarWidthChanged`,sidebarWidth:t}),Lo(t))},_=t??u,v=e=>{let t=typeof e==`function`?e(_):e;n?n(t):l({type:`openChanged`,open:t}),document.cookie=`${Co}=${t}; path=/; max-age=${wo}`},y=e=>{l({type:`openMobileChanged`,openMobile:e})},b=e=>{l({type:`openMobileSettledChanged`,openMobileSettled:e})},x=e=>{l({type:`sidebarResizingChanged`,sidebarResizing:e})},S=()=>s?y(!d):v(e=>!e),C=Ro(S);Z.useEffect(()=>{let e=e=>{e.key.toLowerCase()===Mo&&(e.metaKey||e.ctrlKey)&&!(e.metaKey&&e.ctrlKey)&&!e.shiftKey&&!e.altKey&&(e.preventDefault(),C.current())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[C]);let w=_?`expanded`:`collapsed`,T={state:w,open:_,setOpen:v,isMobile:s,openMobile:d,openMobileSettled:f,setOpenMobile:y,setOpenMobileSettled:b,sidebarResizing:p,setSidebarResizing:x,sidebarWidth:m,setSidebarWidth:g,toggleSidebar:S};return(0,$.jsx)(No.Provider,{value:T,children:(0,$.jsx)(`div`,{"data-slot":`sidebar-wrapper`,"data-sidebar-state":w,style:{...i,"--sidebar-width":m,"--sidebar-width-icon":jo},className:E(`group/sidebar-wrapper flex min-h-svh w-full has-data-[variant=inset]:bg-sidebar`,r),...o,children:a})})}function Uo(e){let t=(0,Q.c)(50),n,r,i,a,o,s,c;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6],c=t[7]):({side:o,variant:s,collapsible:c,className:r,children:n,dir:i,...a}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s,t[7]=c);let l=o===void 0?`left`:o,u=s===void 0?`sidebar`:s,d=c===void 0?`offcanvas`:c,{isMobile:f,state:p,openMobile:m,setOpenMobile:h,setOpenMobileSettled:g,sidebarResizing:_}=zo();if(d===`none`){let e;t[8]===r?e=t[9]:(e=E(`flex h-full w-(--sidebar-width) flex-col bg-sidebar text-sidebar-foreground`,r),t[8]=r,t[9]=e);let i;return t[10]!==n||t[11]!==a||t[12]!==e?(i=(0,$.jsx)(`div`,{"data-slot":`sidebar`,className:e,...a,children:n}),t[10]=n,t[11]=a,t[12]=e,t[13]=i):i=t[13],i}if(f){let e;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(e={"--sidebar-width":Ao},t[14]=e):e=t[14];let r;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsxs)(bo,{className:`sr-only`,children:[(0,$.jsx)(xo,{children:`Sidebar`}),(0,$.jsx)(So,{children:`Displays the mobile sidebar.`})]}),t[15]=r):r=t[15];let o;t[16]===n?o=t[17]:(o=(0,$.jsx)(`div`,{className:`flex h-full w-full flex-col`,children:n}),t[16]=n,t[17]=o);let s;t[18]!==i||t[19]!==l||t[20]!==o?(s=(0,$.jsxs)(yo,{dir:i,"data-sidebar":`sidebar`,"data-slot":`sidebar`,"data-mobile":`true`,className:`w-(--sidebar-width) bg-sidebar p-0 text-sidebar-foreground [&>button]:hidden`,style:e,side:l,children:[r,o]}),t[18]=i,t[19]=l,t[20]=o,t[21]=s):s=t[21];let c;return t[22]!==m||t[23]!==a||t[24]!==h||t[25]!==g||t[26]!==s?(c=(0,$.jsx)(go,{open:m,onOpenChange:h,onOpenChangeComplete:g,...a,children:s}),t[22]=m,t[23]=a,t[24]=h,t[25]=g,t[26]=s,t[27]=c):c=t[27],c}let v=p===`collapsed`?d:``,y=_?`true`:void 0,b=u===`floating`||u===`inset`?`group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4)))]`:`group-data-[collapsible=icon]:w-(--sidebar-width-icon)`,x;t[28]===b?x=t[29]:(x=E(`relative w-(--sidebar-width) bg-transparent transition-[width] duration-200 ease-linear group-data-[resizing=true]:transition-none`,`group-data-[collapsible=offcanvas]:w-0`,`group-data-[side=right]:rotate-180`,b),t[28]=b,t[29]=x);let S;t[30]===x?S=t[31]:(S=(0,$.jsx)(`div`,{"data-slot":`sidebar-gap`,className:x}),t[30]=x,t[31]=S);let C=u===`floating`||u===`inset`?`p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4))+2px)]`:`border-sidebar-border/70 group-data-[collapsible=icon]:w-(--sidebar-width-icon) group-data-[side=left]:border-r group-data-[side=right]:border-l`,w;t[32]!==r||t[33]!==C?(w=E(`fixed inset-y-0 z-30 hidden h-svh w-(--sidebar-width) transition-[left,right,width] duration-200 ease-linear group-data-[resizing=true]:transition-none data-[side=left]:left-0 data-[side=left]:group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)] data-[side=right]:right-0 data-[side=right]:group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)] md:flex`,C,r),t[32]=r,t[33]=C,t[34]=w):w=t[34];let T;t[35]===n?T=t[36]:(T=(0,$.jsx)(`div`,{"data-sidebar":`sidebar`,"data-slot":`sidebar-inner`,className:`flex size-full flex-col bg-sidebar group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:shadow-sm group-data-[variant=floating]:ring-1 group-data-[variant=floating]:ring-sidebar-border`,children:n}),t[35]=n,t[36]=T);let D;t[37]!==a||t[38]!==l||t[39]!==w||t[40]!==T?(D=(0,$.jsx)(`div`,{"data-slot":`sidebar-container`,"data-side":l,className:w,...a,children:T}),t[37]=a,t[38]=l,t[39]=w,t[40]=T,t[41]=D):D=t[41];let O;return t[42]!==l||t[43]!==p||t[44]!==D||t[45]!==v||t[46]!==y||t[47]!==S||t[48]!==u?(O=(0,$.jsxs)(`div`,{className:`group peer hidden text-sidebar-foreground md:block`,"data-state":p,"data-collapsible":v,"data-resizing":y,"data-variant":u,"data-side":l,"data-slot":`sidebar`,children:[S,D]}),t[42]=l,t[43]=p,t[44]=D,t[45]=v,t[46]=y,t[47]=S,t[48]=u,t[49]=O):O=t[49],O}function Wo(e){let t=(0,Q.c)(15),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,onClick:r,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let{toggleSidebar:a}=zo(),o;t[4]===n?o=t[5]:(o=E(n),t[4]=n,t[5]=o);let s;t[6]!==r||t[7]!==a?(s=e=>{r?.(e),a()},t[6]=r,t[7]=a,t[8]=s):s=t[8];let c,l;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,$.jsx)(Ra,{}),l=(0,$.jsx)(`span`,{className:`sr-only`,children:`Toggle Sidebar`}),t[9]=c,t[10]=l):(c=t[9],l=t[10]);let u;return t[11]!==i||t[12]!==o||t[13]!==s?(u=(0,$.jsx)(U,{title:`Toggle sidebar`,kbd:`⌃ B`,children:(0,$.jsxs)(Y,{"data-sidebar":`trigger`,"data-slot":`sidebar-trigger`,variant:`ghost`,size:`icon`,className:o,onClick:s,...i,children:[c,l]})}),t[11]=i,t[12]=o,t[13]=s,t[14]=u):u=t[14],u}function Go(e){let t=(0,Q.c)(34),n,r,i,a,o;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5]):({className:n,onClick:r,onPointerDown:i,style:o,...a}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o);let{isMobile:s,setOpen:c,setSidebarResizing:l,setSidebarWidth:u,sidebarWidth:d,state:f}=zo(),p;t[6]!==s||t[7]!==c||t[8]!==l||t[9]!==u||t[10]!==d||t[11]!==f?(p={isMobile:s,maxWidth:Do,minWidth:Eo,state:f,width:d,onOpenChange:c,onResize:u,onResizeActiveChange:l},t[6]=s,t[7]=c,t[8]=l,t[9]=u,t[10]=d,t[11]=f,t[12]=p):p=t[12];let{handleClick:m,handlePointerDown:h}=mn(p),[g,_]=Z.useState(`col-resize`),[v,y]=Z.useState(10),b,x;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(b=()=>{let e=()=>{y(wn())},t=window.matchMedia(`(pointer:coarse)`);return _(Pr()),e(),t.addEventListener(`change`,e),()=>{t.removeEventListener(`change`,e)}},x=[],t[13]=b,t[14]=x):(b=t[13],x=t[14]),Z.useEffect(b,x);let S=g===`ew-resize`?`cursor-ew-resize group-data-[side=left]:cursor-ew-resize group-data-[side=right]:cursor-ew-resize [[data-side=left][data-state=collapsed]_&]:cursor-ew-resize [[data-side=right][data-state=collapsed]_&]:cursor-ew-resize`:`cursor-col-resize group-data-[side=left]:cursor-col-resize group-data-[side=right]:cursor-col-resize [[data-side=left][data-state=collapsed]_&]:cursor-col-resize [[data-side=right][data-state=collapsed]_&]:cursor-col-resize`,C;t[15]!==m||t[16]!==r?(C=e=>{r?.(e),!e.defaultPrevented&&m(e)},t[15]=m,t[16]=r,t[17]=C):C=t[17];let w;t[18]!==h||t[19]!==i?(w=e=>{i?.(e),!e.defaultPrevented&&h(e)},t[18]=h,t[19]=i,t[20]=w):w=t[20];let T=`${v}px`,D;t[21]!==g||t[22]!==o||t[23]!==T?(D={...o,"--sidebar-rail-width":T,cursor:g},t[21]=g,t[22]=o,t[23]=T,t[24]=D):D=t[24];let O=D,k;t[25]!==n||t[26]!==S?(k=E(`absolute inset-y-0 z-40 hidden w-(--sidebar-rail-width) touch-none bg-transparent transition-all ease-linear select-none group-data-[side=left]:right-[calc(var(--sidebar-rail-width)*-1)] group-data-[side=right]:left-0 after:absolute after:inset-y-0 after:start-1/2 after:w-px after:bg-transparent sm:flex ltr:-translate-x-1/2 rtl:-translate-x-1/2`,fr,S,`group-data-[collapsible=offcanvas]:translate-x-0 group-data-[collapsible=offcanvas]:after:left-full`,tr,`[[data-side=left][data-collapsible=offcanvas]_&]:-right-2`,`[[data-side=right][data-collapsible=offcanvas]_&]:-left-2`,n),t[25]=n,t[26]=S,t[27]=k):k=t[27];let A;return t[28]!==a||t[29]!==C||t[30]!==w||t[31]!==O||t[32]!==k?(A=(0,$.jsx)(`button`,{"data-sidebar":`rail`,"data-slot":`sidebar-rail`,"aria-label":`Toggle or resize Sidebar`,tabIndex:-1,onClick:C,onPointerDown:w,title:`Toggle or resize Sidebar`,style:O,className:k,...a}),t[28]=a,t[29]=C,t[30]=w,t[31]=O,t[32]=k,t[33]=A):A=t[33],A}function Ko(e){let t=(0,Q.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=E(`relative flex w-full flex-1 flex-col bg-background md:peer-data-[variant=inset]:m-2 md:peer-data-[variant=inset]:ml-0 md:peer-data-[variant=inset]:rounded-xl md:peer-data-[variant=inset]:shadow-sm md:peer-data-[variant=inset]:peer-data-[state=collapsed]:ml-2`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,$.jsx)(`main`,{"data-slot":`sidebar-inset`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function qo(e){let t=(0,Q.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=E(`flex flex-col gap-2 p-2`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,$.jsx)(`div`,{"data-slot":`sidebar-header`,"data-sidebar":`header`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Jo(e){let t=(0,Q.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=E(`flex flex-col gap-2 p-2`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,$.jsx)(`div`,{"data-slot":`sidebar-footer`,"data-sidebar":`footer`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Yo(e){let t=(0,Q.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=E(`no-scrollbar flex min-h-0 flex-1 flex-col gap-0 overflow-auto group-data-[collapsible=icon]:overflow-hidden`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,$.jsx)(`div`,{"data-slot":`sidebar-content`,"data-sidebar":`content`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Xo(e){let t=(0,Q.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=E(`relative flex w-full min-w-0 flex-col p-2`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,$.jsx)(`div`,{"data-slot":`sidebar-group`,"data-sidebar":`group`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Zo(e){let t=(0,Q.c)(10),n,r,i,a;if(t[0]!==e){let{className:o,render:s,...c}=e;n=s,a=Wa,r=`div`,i=u({className:E(`flex h-8 shrink-0 items-center rounded-md px-2 text-xs font-medium text-sidebar-foreground/70 ring-sidebar-ring outline-hidden transition-[margin,opacity] duration-200 ease-linear group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:opacity-0 focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0`,o)},c),t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a}else n=t[1],r=t[2],i=t[3],a=t[4];let o;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(o={slot:`sidebar-group-label`,sidebar:`group-label`},t[5]=o):o=t[5];let s;return t[6]!==n||t[7]!==r||t[8]!==i?(s={defaultTagName:r,props:i,render:n,state:o},t[6]=n,t[7]=r,t[8]=i,t[9]=s):s=t[9],a(s)}function Qo(e){let t=(0,Q.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=E(`w-full text-sm`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,$.jsx)(`div`,{"data-slot":`sidebar-group-content`,"data-sidebar":`group-content`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function $o(e){let t=(0,Q.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=E(`flex w-full min-w-0 flex-col gap-0`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,$.jsx)(`ul`,{"data-slot":`sidebar-menu`,"data-sidebar":`menu`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function es(e){let t=(0,Q.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=E(`group/menu-item relative`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,$.jsx)(`li`,{"data-slot":`sidebar-menu-item`,"data-sidebar":`menu-item`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}var ts=Ti(`peer/menu-button group/menu-button flex w-full items-center gap-2 overflow-hidden rounded-md p-2 text-left text-sm ring-sidebar-ring outline-hidden transition-[width,height,padding] group-has-data-[sidebar=menu-action]/menu-item:pr-8 group-data-[collapsible=icon]:size-8! group-data-[collapsible=icon]:p-2! hover:text-sidebar-accent-foreground not-data-active:hover:bg-sidebar-accent/50 focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-open:hover:bg-sidebar-accent/50 data-open:hover:text-sidebar-accent-foreground data-active:bg-sidebar-accent data-active:text-sidebar-accent-foreground [&_svg]:shrink-0 [&>span:last-child]:truncate [&>svg]:size-4`,{variants:{variant:{default:`hover:text-sidebar-accent-foreground not-data-active:hover:bg-sidebar-accent/50`,outline:`bg-background shadow-[0_0_0_1px_hsl(var(--sidebar-border))] hover:text-sidebar-accent-foreground hover:shadow-[0_0_0_1px_hsl(var(--sidebar-accent))] not-data-active:hover:bg-sidebar-accent/50`},size:{default:`h-8 text-sm`,sm:`h-7 text-xs`,lg:`h-12 text-sm group-data-[collapsible=icon]:p-0!`}},defaultVariants:{variant:`default`,size:`default`}});function ns(e){let t=(0,Q.c)(18),{render:n,isActive:r,variant:i,size:a,tooltip:o,className:s,...c}=e,l=r===void 0?!1:r,p=i===void 0?`default`:i,m=a===void 0?`default`:a,{isMobile:h,state:g}=zo(),_=u({className:E(ts({variant:p,size:m}),s)},c),v;t[0]!==n||t[1]!==o?(v=o?(0,$.jsx)(Be,{render:n}):n,t[0]=n,t[1]=o,t[2]=v):v=t[2];let y;t[3]!==l||t[4]!==m?(y={slot:`sidebar-menu-button`,sidebar:`menu-button`,size:m,active:l},t[3]=l,t[4]=m,t[5]=y):y=t[5];let b;t[6]!==_||t[7]!==v||t[8]!==y?(b={defaultTagName:`button`,props:_,render:v,state:y},t[6]=_,t[7]=v,t[8]=y,t[9]=b):b=t[9];let x=Wa(b);if(!o)return x;if(typeof o==`string`){let e;t[10]===o?e=t[11]:(e={children:o},t[10]=o,t[11]=e),o=e}let S=g!==`collapsed`||h,C;t[12]!==S||t[13]!==o?(C=(0,$.jsx)(d,{side:`right`,align:`center`,hidden:S,...o}),t[12]=S,t[13]=o,t[14]=C):C=t[14];let w;return t[15]!==x||t[16]!==C?(w=(0,$.jsxs)(f,{children:[x,C]}),t[15]=x,t[16]=C,t[17]=w):w=t[17],w}function rs(e){let t=e.trim();if(!t)return e;let n=t.replace(/^\/Users\/[^/]+(?=\/|$)/,`~`).replace(/^\/home\/[^/]+(?=\/|$)/,`~`);return n===`~`?`~/`:n}function is(e){return e.trim().toLowerCase().replace(/[^\p{L}\p{N}]+/gu,` `).replace(/\s+/g,` `)}function as(e,t){let n=t.trim().toLowerCase();if(!n)return!0;let r=rs(e),i=is(t);return e.toLowerCase().includes(n)||r.toLowerCase().includes(n)||is(e).includes(i)||is(r).includes(i)}function os(e,t){return t?e.some(e=>{let n=e.trim().toLowerCase(),r=rs(e).trim().toLowerCase();return n===t||r===t}):!1}function ss(e){if(!e)return{leading:``,trailing:``};let t=e.replace(/[\\/]+$/,``);if(!t)return{leading:``,trailing:e};let n=e.slice(t.length),r=Math.max(t.lastIndexOf(`/`),t.lastIndexOf(`\\`));return r<0||r===t.length-1?{leading:``,trailing:`${t}${n}`}:{leading:t.slice(0,r+1),trailing:`${t.slice(r+1)}${n}`}}function cs(e){let t=(0,Q.c)(13),{path:n,prefix:r}=e,i,a;t[0]===n?(i=t[1],a=t[2]):(i=rs(n),a=ss(i),t[0]=n,t[1]=i,t[2]=a);let{leading:o,trailing:s}=a,c;t[3]===r?c=t[4]:(c=r?(0,$.jsx)(`span`,{className:`shrink-0 font-medium`,children:r}):null,t[3]=r,t[4]=c);let l;t[5]===o?l=t[6]:(l=o?(0,$.jsx)(`span`,{className:`truncate text-muted-foreground`,children:o}):null,t[5]=o,t[6]=l);let u=s||i,d;t[7]===u?d=t[8]:(d=(0,$.jsx)(`span`,{className:`shrink-0 font-medium`,children:u}),t[7]=u,t[8]=d);let f;return t[9]!==c||t[10]!==l||t[11]!==d?(f=(0,$.jsxs)(`span`,{className:`flex min-w-0 items-center text-foreground`,children:[c,l,d]}),t[9]=c,t[10]=l,t[11]=d,t[12]=f):f=t[12],f}function ls(e){let t=(0,Q.c)(2),{children:n}=e,i;return t[0]===n?i=t[1]:(i=(0,$.jsx)(r,{children:n}),t[0]=n,t[1]=i),i}function us(e,t){return`path-completion:${t}:${e.value}`}function ds(e,t){return`directory-search:${t}:${e.value}`}function fs(e){let t=e.trim();return t.startsWith(`~`)||t.startsWith(`.`)||t.startsWith(`/`)||t.includes(`/`)||t.includes(`\\`)}function ps(e){let t=rs(e.value);return t.endsWith(`/`)?t:`${t}/`}var ms={pathCompletionItems:[],pathCompletionLoading:!1,directorySearchItems:[],directorySearchLoading:!1,selectedCommandValue:``};function hs(e,t){switch(t.type){case`pathCompletionsStarted`:return{...e,pathCompletionLoading:!0,pathCompletionItems:[]};case`pathCompletionsFinished`:return{...e,pathCompletionLoading:!1,pathCompletionItems:t.items};case`pathCompletionsReset`:return!e.pathCompletionLoading&&e.pathCompletionItems.length===0?e:{...e,pathCompletionLoading:!1,pathCompletionItems:[]};case`directorySearchStarted`:return{...e,directorySearchLoading:!0,directorySearchItems:[]};case`directorySearchFinished`:return{...e,directorySearchLoading:!1,directorySearchItems:t.items};case`directorySearchReset`:return!e.directorySearchLoading&&e.directorySearchItems.length===0?e:{...e,directorySearchLoading:!1,directorySearchItems:[]};case`selectedCommandValueChanged`:return e.selectedCommandValue===t.value?e:{...e,selectedCommandValue:t.value};default:return e}}function gs(e){return _s(e)}function _s({open:e,onOpenChange:t,directoryInput:n,onDirectoryInputChange:r,openedDirectories:i,currentDirectory:a,recentDirectories:o,knownDirectories:s,useForNewSession:c=!1,useForMoveSession:l=!1,onAddDirectoryPath:u,onRequestPathCompletions:d,onSearchDirectories:f}){let p=ar(),m=Z.useRef(n),h=Z.useRef(0),g=Z.useRef(0),_=Z.useRef(d),v=Z.useRef(f),[y,b]=Z.useReducer(hs,ms),{pathCompletionItems:x,pathCompletionLoading:S,directorySearchItems:C,directorySearchLoading:w,selectedCommandValue:T}=y;m.current=n,_.current=d,v.current=f;let E=Z.useRef(null);E.current||=new so(async e=>{let t=_.current;return t?await t(e):[]},{key:`pico.add-directory.path-completions`,wait:80});let D=E.current,O=Z.useRef(null);O.current||=new so(async e=>{let t=v.current;return t?await t(e):[]},{key:`pico.add-directory.directory-search`,wait:120});let k=O.current,A=n.trim(),j=A.toLowerCase(),M=new Set(i),N=new Set(o),P=A?i.filter(e=>as(e,A)):[],F=a&&!M.has(a)&&as(a,A)?[a]:[],I=o.filter(e=>!M.has(e)&&as(e,A)),L=s.filter(e=>!M.has(e)&&e!==a&&!N.has(e)&&as(e,A)),R=A&&!os([...i,...o,...s],j)?A:``,z=P.length>0||F.length>0||I.length>0||L.length>0,B=fs(A),V=!!(A&&d&&!z&&B),H=!!(A&&f&&!z&&!B),U=V&&(S||x.length>0),W=H&&(w||C.length>0),ee=!!R||z||U||W,te=l?`Resolve and move this session to this directory.`:c?`Add to sidebar and use for this new session.`:`Resolve and add this path to the sidebar.`,ne=l?`Move this session here.`:c?`Use for this new session.`:`Expand and show it in the sidebar.`,G=l?`Move this session to the current Pico working directory.`:c?`Use the current Pico working directory for this new session.`:`Use the current Pico working directory.`,K=l?`Move this session here.`:c?`Add to sidebar and use for this new session.`:``,re=l?`Move to path`:`Add path`,q=l?`Move to`:`Add`,ie=l?`Move session`:`Add directory`,J=l?`Search recent and known directories or paste any path to move this session.`:`Search recent and known directories or add a new path to the sidebar.`;Z.useEffect(()=>{if(!V){h.current+=1,D.cancel(),b({type:`pathCompletionsReset`});return}let e=A,t=h.current+1;h.current=t,b({type:`pathCompletionsStarted`}),(async()=>{try{let n=await D.maybeExecute(e);if(t!==h.current||m.current.trim()!==e)return;b({type:`pathCompletionsFinished`,items:(n??[]).filter(t=>t.isDirectory&&t.value.trim()!==e)})}catch{t===h.current&&b({type:`pathCompletionsReset`})}})()},[A,D,V]),Z.useEffect(()=>{if(!H){g.current+=1,k.cancel(),b({type:`directorySearchReset`});return}let e=A,t=g.current+1;g.current=t,b({type:`directorySearchStarted`}),(async()=>{try{let n=await k.maybeExecute(e);if(t!==g.current||m.current.trim()!==e)return;b({type:`directorySearchFinished`,items:(n??[]).filter(e=>e.isDirectory)})}catch{t===g.current&&b({type:`directorySearchReset`})}})()},[A,k,H]),Z.useEffect(()=>()=>{D.cancel(),D.abort(),k.cancel(),k.abort()},[k,D]);let ae=[...x.map(us),...C.map(ds),...R?[`add ${R}`]:[],...P.map(e=>`opened ${e}`),...F.map(e=>`current ${e}`),...I.map(e=>`recent ${e}`),...L.map(e=>`known ${e}`)];Z.useEffect(()=>{T&&ae.includes(T)||b({type:`selectedCommandValueChanged`,value:ae[0]||``})},[ae,T]);let oe=x.find((e,t)=>us(e,t)===T),se=C.find((e,t)=>ds(e,t)===T),ce=e=>(r(e.value),!0),le=e=>(r(ps(e)),!0),ue=async()=>{let e=oe;if(e)return ce(e);let t=se;if(t)return le(t);let n=m.current.trim();if(!n)return!1;if(!fs(n)&&f){let e=g.current+1;g.current=e;try{let t=await f(n);if(e!==g.current||m.current.trim()!==n)return!0;let r=t.find(e=>e.isDirectory);return r?le(r):!1}catch{return!1}}if(!d)return!1;let r=h.current+1;h.current=r;try{let e=await d(n);if(r!==h.current||m.current.trim()!==n)return!0;let t=e.find(e=>e.isDirectory&&e.value.trim()!==n);return t?ce(t):!1}catch{return!1}},de=(0,$.jsxs)(xn,{shouldFilter:!1,loop:!0,value:T,onValueChange:e=>{b({type:`selectedCommandValueChanged`,value:e})},className:`min-h-0 flex-1 rounded-lg`,children:[(0,$.jsx)(Qt,{value:n,onValueChange:r,onKeyDown:e=>{e.key!==`Tab`||e.shiftKey||e.altKey||e.ctrlKey||e.metaKey||!d&&!f||!n.trim()||(e.preventDefault(),ue())},placeholder:`Search or paste a path`,className:`text-base md:text-sm`}),(0,$.jsxs)(Mn,{className:`max-h-none min-h-0 flex-1 md:max-h-[min(70vh,32rem)]`,children:[ee?null:(0,$.jsx)(Lt,{children:A?`No directories found. Type or paste a path to add it.`:`No recent or discovered directories yet.`}),V&&(S||x.length>0)?(0,$.jsxs)(An,{heading:`Path completions`,children:[S&&x.length===0?(0,$.jsx)(On,{value:`path-completion:loading`,disabled:!0,children:`Loading directories…`}):null,x.map((e,t)=>(0,$.jsx)(On,{value:us(e,t),onSelect:()=>u(e.value),children:(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,$.jsx)(cs,{path:e.value}),(0,$.jsx)(`span`,{className:`truncate text-xs text-muted-foreground`,children:`Press Tab to complete this path instead.`})]})},`path-completion:${e.value}`))]}):null,H&&(w||C.length>0)?(0,$.jsxs)(An,{heading:`Matching folders`,children:[w&&C.length===0?(0,$.jsx)(On,{value:`directory-search:loading`,disabled:!0,children:`Searching directories…`}):null,C.map((e,t)=>(0,$.jsx)(On,{value:ds(e,t),onSelect:()=>u(e.value),children:(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,$.jsx)(cs,{path:e.value}),(0,$.jsx)(`span`,{className:`truncate text-xs text-muted-foreground`,children:e.description||`Found on disk`})]})},`directory-search:${e.value}`))]}):null,R?(0,$.jsx)(An,{heading:re,children:(0,$.jsx)(On,{value:`add ${R}`,onSelect:()=>u(R),children:(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,$.jsx)(cs,{path:R,prefix:(0,$.jsxs)($.Fragment,{children:[q,`\xA0`]})}),(0,$.jsx)(`span`,{className:`truncate text-xs text-muted-foreground`,children:te})]})})}):null,P.length>0?(0,$.jsx)(An,{heading:`Already added`,children:P.map(e=>(0,$.jsx)(On,{value:`opened ${e}`,onSelect:()=>u(e),children:(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,$.jsx)(cs,{path:e}),(0,$.jsx)(`span`,{className:`truncate text-xs text-muted-foreground`,children:ne})]})},`opened:${e}`))}):null,F.length>0?(0,$.jsx)(An,{heading:`Current directory`,children:F.map(e=>(0,$.jsx)(On,{value:`current ${e}`,onSelect:()=>u(e),children:(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,$.jsx)(cs,{path:e}),(0,$.jsx)(`span`,{className:`truncate text-xs text-muted-foreground`,children:G})]})},`current:${e}`))}):null,I.length>0?(0,$.jsx)(An,{heading:`Recent directories`,children:I.map(e=>(0,$.jsx)(On,{value:`recent ${e}`,onSelect:()=>u(e),children:(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,$.jsx)(cs,{path:e}),K?(0,$.jsx)(`span`,{className:`truncate text-xs text-muted-foreground`,children:K}):null]})},`recent:${e}`))}):null,L.length>0?(0,$.jsx)(An,{heading:A?`Matching directories`:`Known directories`,children:L.map(e=>(0,$.jsx)(On,{value:`known ${e}`,onSelect:()=>u(e),children:(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,$.jsx)(cs,{path:e}),K?(0,$.jsx)(`span`,{className:`truncate text-xs text-muted-foreground`,children:K}):null]})},`known:${e}`))}):null]}),(0,$.jsxs)(`div`,{className:`hidden flex-wrap items-center gap-x-3 gap-y-1 border-t border-border/70 px-3 py-2 text-xs text-muted-foreground md:flex`,children:[(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,$.jsx)(ls,{children:`↑↓`}),` Navigate`]}),(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,$.jsx)(ls,{children:`Enter`}),` Select`]}),d||f?(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,$.jsx)(ls,{children:`Tab`}),` Complete`]}):null,(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,$.jsx)(ls,{children:`Esc`}),` Close`]})]})]});return p?(0,$.jsx)(dn,{open:e,onOpenChange:t,autoFocus:!1,children:(0,$.jsxs)(pn,{className:`max-h-[90svh] overflow-hidden`,children:[(0,$.jsxs)(tn,{children:[(0,$.jsx)(ln,{children:ie}),(0,$.jsx)(_n,{children:J})]}),(0,$.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden px-4 pb-4`,children:de})]})}):(0,$.jsx)(Vr,{open:e,onOpenChange:t,title:ie,description:J,className:`sm:max-w-2xl`,initialFocus:!0,children:de})}function vs(e){let t=(0,Q.c)(23),{ref:n,openStateRef:r,openedDirectories:i,currentDirectory:a,recentDirectories:o,knownDirectories:s,useForNewSession:c,useForMoveSession:l,onAddDirectoryPath:u,onRequestPathCompletions:d,onSearchDirectories:f}=e,[p,m]=Z.useState(!1),[h,g]=Z.useState(``),_=Z.useRef(p),v;t[0]===r?v=t[1]:(v=e=>{_.current=e,r&&(r.current=e),m(e)},t[0]=r,t[1]=v);let y=v,b;t[2]!==u||t[3]!==y?(b=async e=>{await u(e)!==!1&&(g(``),y(!1))},t[2]=u,t[3]=y,t[4]=b):b=t[4];let x=b,S;t[5]===y?S=t[6]:(S=()=>({open:()=>{g(``),y(!0)},close:()=>{y(!1)},isOpen:()=>_.current}),t[5]=y,t[6]=S);let C;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(C=[],t[7]=C):C=t[7],Z.useImperativeHandle(n,S,C);let w;t[8]===x?w=t[9]:(w=e=>{x(e)},t[8]=x,t[9]=w);let T;return t[10]!==a||t[11]!==h||t[12]!==s||t[13]!==d||t[14]!==f||t[15]!==p||t[16]!==i||t[17]!==o||t[18]!==y||t[19]!==w||t[20]!==l||t[21]!==c?(T=(0,$.jsx)(gs,{open:p,onOpenChange:y,directoryInput:h,onDirectoryInputChange:g,openedDirectories:i,currentDirectory:a,recentDirectories:o,knownDirectories:s,useForNewSession:c,useForMoveSession:l,onAddDirectoryPath:w,onRequestPathCompletions:d,onSearchDirectories:f}),t[10]=a,t[11]=h,t[12]=s,t[13]=d,t[14]=f,t[15]=p,t[16]=i,t[17]=o,t[18]=y,t[19]=w,t[20]=l,t[21]=c,t[22]=T):T=t[22],T}var ys=Ti(`group/badge inline-flex h-5 w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-4xl border border-transparent px-2 py-0.5 text-xs font-medium whitespace-nowrap transition-all focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&>svg]:pointer-events-none [&>svg]:size-3!`,{variants:{variant:{default:`bg-primary text-primary-foreground [a]:hover:bg-primary/80`,secondary:`bg-secondary text-secondary-foreground [a]:hover:bg-secondary/80`,destructive:`bg-destructive/10 text-destructive focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:focus-visible:ring-destructive/40 [a]:hover:bg-destructive/20`,outline:`border-border text-foreground [a]:hover:bg-muted [a]:hover:text-muted-foreground`,ghost:`hover:bg-muted hover:text-muted-foreground dark:hover:bg-muted/50`,link:`text-primary underline-offset-4 hover:underline`}},defaultVariants:{variant:`default`}});function bs(e){let t=(0,Q.c)(13),n,r,i,a,o;if(t[0]!==e){let{className:s,variant:c,render:l,...d}=e;n=l,o=c===void 0?`default`:c,a=Wa,r=`span`,i=u({className:E(ys({variant:o}),s)},d),t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o}else n=t[1],r=t[2],i=t[3],a=t[4],o=t[5];let s;t[6]===o?s=t[7]:(s={slot:`badge`,variant:o},t[6]=o,t[7]=s);let c;return t[8]!==n||t[9]!==r||t[10]!==i||t[11]!==s?(c={defaultTagName:r,props:i,render:n,state:s},t[8]=n,t[9]=r,t[10]=i,t[11]=s,t[12]=c):c=t[12],a(c)}function xs(e){return`${e.authType}:${e.id}`}function Ss(e){return[e.id,e.name,e.authType===`oauth`?`oauth subscription login`:`api key`,e.configured?`saved configured`:``,e.source||``].filter(Boolean)}function Cs(e){let t=e.authType===`oauth`?`Subscription / OAuth`:`API key`;return e.source?`${t} · ${e.source}`:t}function ws(e){let t=(0,Q.c)(22),{open:n,isMobile:r,title:i,description:a,children:o,onOpenChange:s}=e;if(r){let e;t[0]===i?e=t[1]:(e=(0,$.jsx)(ln,{children:i}),t[0]=i,t[1]=e);let r;t[2]===a?r=t[3]:(r=(0,$.jsx)(_n,{children:a}),t[2]=a,t[3]=r);let c;t[4]!==e||t[5]!==r?(c=(0,$.jsxs)(tn,{children:[e,r]}),t[4]=e,t[5]=r,t[6]=c):c=t[6];let l;t[7]===o?l=t[8]:(l=(0,$.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden px-4 pb-4`,children:o}),t[7]=o,t[8]=l);let u;t[9]!==c||t[10]!==l?(u=(0,$.jsxs)(pn,{className:`max-h-[90svh] overflow-hidden`,children:[c,l]}),t[9]=c,t[10]=l,t[11]=u):u=t[11];let d;return t[12]!==s||t[13]!==n||t[14]!==u?(d=(0,$.jsx)(dn,{open:n,onOpenChange:s,autoFocus:!1,children:u}),t[12]=s,t[13]=n,t[14]=u,t[15]=d):d=t[15],d}let c;return t[16]!==o||t[17]!==a||t[18]!==s||t[19]!==n||t[20]!==i?(c=(0,$.jsx)(Vr,{open:n,onOpenChange:s,title:i,description:a,className:`sm:max-w-xl`,initialFocus:!0,children:o}),t[16]=o,t[17]=a,t[18]=s,t[19]=n,t[20]=i,t[21]=c):c=t[21],c}function Ts(e){let t=(0,Q.c)(23),{provider:n,actionLabel:r,disabled:i,onSelect:a}=e,o;t[0]===n?o=t[1]:(o=xs(n),t[0]=n,t[1]=o);let s;t[2]===n?s=t[3]:(s=Ss(n),t[2]=n,t[3]=s);let c;t[4]===n.name?c=t[5]:(c=(0,$.jsx)(`span`,{className:`truncate font-medium`,children:n.name}),t[4]=n.name,t[5]=c);let l;t[6]===n?l=t[7]:(l=Cs(n),t[6]=n,t[7]=l);let u;t[8]===l?u=t[9]:(u=(0,$.jsx)(`span`,{className:`line-clamp-2 text-xs text-muted-foreground`,children:l}),t[8]=l,t[9]=u);let d;t[10]!==c||t[11]!==u?(d=(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[c,u]}),t[10]=c,t[11]=u,t[12]=d):d=t[12];let f;t[13]!==r||t[14]!==n.configured?(f=n.configured?(0,$.jsx)(bs,{variant:`secondary`,className:`shrink-0`,children:`Saved`}):(0,$.jsx)(Xt,{className:`inline shrink-0 tracking-normal normal-case`,children:r}),t[13]=r,t[14]=n.configured,t[15]=f):f=t[15];let p;return t[16]!==i||t[17]!==a||t[18]!==o||t[19]!==s||t[20]!==d||t[21]!==f?(p=(0,$.jsxs)(On,{value:o,keywords:s,disabled:i,onSelect:a,className:`items-start py-2`,children:[d,f]}),t[16]=i,t[17]=a,t[18]=o,t[19]=s,t[20]=d,t[21]=f,t[22]=p):p=t[22],p}var Es={mode:`closed`,selectedApiKeyProvider:null,apiKey:``};function Ds(e,t){switch(t.type){case`loginOpened`:return{mode:`login`,selectedApiKeyProvider:null,apiKey:``};case`logoutOpened`:return{mode:`logout`,selectedApiKeyProvider:null,apiKey:``};case`apiKeyOpened`:return{mode:`apiKey`,selectedApiKeyProvider:t.provider,apiKey:``};case`apiKeyChanged`:return e.apiKey===t.apiKey?e:{...e,apiKey:t.apiKey};case`closed`:return e.mode===`closed`&&!e.selectedApiKeyProvider&&!e.apiKey?e:Es;default:return e}}function Os(e){return ks(e)}function ks({ref:e,openStateRef:t,viewerContextId:n,sessionId:i}){let a=ar(),o=ki(),[s,c]=Z.useReducer(Ds,Es),{apiKey:l,selectedApiKeyProvider:u}=s,d=s.mode===`login`,f=s.mode===`logout`,p=s.mode===`apiKey`,m=Z.useRef(!1),h=Z.useRef(null),g=d||f||p;Z.useLayoutEffect(()=>{m.current=g,t&&(t.current=g)},[g,t]);let _=()=>{c({type:`loginOpened`})},v=e=>{c({type:`closed`});let t=h.current;h.current=null,e?.returnToOrigin&&t&&t()},y=()=>{v({returnToOrigin:!0})},b=nn({queryKey:[`pico`,`auth`,`providers`,n,i],enabled:g&&!!n,queryFn:async()=>await oi(hi(`/api/auth/providers`,{contextId:n,sessionId:i}))}),x=an({mutationFn:async({provider:e,key:t})=>await oi(hi(`/api/auth/api-key`,{contextId:n,sessionId:i}),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({provider:e,key:t})}),onSuccess:async(e,t)=>{X.success(`Saved API key for ${t.provider}`),await o.invalidateQueries({queryKey:[`pico`,`auth`,`providers`,n,i]}),v()},onError:e=>{X.error(e instanceof Error?e.message:`Failed to save API key`)}}),S=an({mutationFn:async({provider:e})=>await oi(hi(`/api/auth/oauth`,{contextId:n,sessionId:i}),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({provider:e})}),onSuccess:async(e,t)=>{X.success(`Logged in to ${t.provider}`),await o.invalidateQueries({queryKey:[`pico`,`auth`,`providers`,n,i]}),v()},onError:e=>{let t=e instanceof Error?e.message:`Login failed`;t!==`Login cancelled`&&X.error(t)}}),C=an({mutationFn:async({provider:e})=>await oi(hi(`/api/auth/logout`,{contextId:n,sessionId:i}),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({provider:e})}),onSuccess:async(e,t)=>{X.success(`Logged out of ${t.provider}`),await o.invalidateQueries({queryKey:[`pico`,`auth`,`providers`,n,i]}),v()},onError:e=>{X.error(e instanceof Error?e.message:`Logout failed`)}});Z.useImperativeHandle(e,()=>({open:(e=`login`,t)=>{t?.returnOnClose&&(h.current=t.returnOnClose),c({type:e===`logout`?`logoutOpened`:`loginOpened`})},close:()=>v(),isOpen:()=>m.current}),[]);let w=b.data?.ok?b.data:void 0,T=w?.oauthProviders??[],E=w?.apiKeyProviders??[],D=w?.loggedInProviders??[],O=e=>{if(e.authType===`oauth`){c({type:`closed`}),S.mutate({provider:e.id});return}c({type:`apiKeyOpened`,provider:e})},k=e=>{e.preventDefault(),!(!u||!l.trim())&&x.mutate({provider:u.id,key:l})},A=(0,$.jsxs)(xn,{loop:!0,shouldFilter:!0,className:`min-h-0 flex-1`,children:[(0,$.jsx)(Qt,{placeholder:`Search login providers`,className:`text-base md:text-sm`}),(0,$.jsxs)(Mn,{className:`max-h-none min-h-0 flex-1 md:max-h-[min(70vh,32rem)]`,children:[(0,$.jsx)(Lt,{children:b.isLoading?`Loading providers…`:b.isError?b.error instanceof Error?b.error.message:`Failed to load providers`:`No auth providers found.`}),T.length>0&&(0,$.jsx)(An,{heading:`Subscriptions / OAuth`,children:T.map(e=>(0,$.jsx)(Ts,{provider:e,actionLabel:`Login`,onSelect:()=>O(e)},xs(e)))}),E.length>0&&(0,$.jsx)(An,{heading:`API keys`,children:E.map(e=>(0,$.jsx)(Ts,{provider:e,actionLabel:`Set key`,onSelect:()=>O(e)},xs(e)))})]}),a?(0,$.jsx)(`div`,{className:`border-t border-border/70 p-3`,children:(0,$.jsx)(Y,{type:`button`,variant:`outline`,className:`w-full`,onClick:y,children:`Cancel`})}):(0,$.jsxs)(`div`,{className:`hidden border-t border-border/70 px-3 py-2 text-xs text-muted-foreground md:block`,children:[`Use ↑/↓ to select, Enter to start login or enter an API key, and Esc to `,h.current?`go back`:`close`,`.`]})]}),j=(0,$.jsxs)(xn,{loop:!0,shouldFilter:!0,className:`min-h-0 flex-1`,children:[(0,$.jsx)(Qt,{placeholder:`Search logged-in providers`,className:`text-base md:text-sm`}),(0,$.jsxs)(Mn,{className:`max-h-none min-h-0 flex-1 md:max-h-[min(70vh,32rem)]`,children:[(0,$.jsx)(Lt,{children:b.isLoading?`Loading providers…`:b.isError?b.error instanceof Error?b.error.message:`Failed to load providers`:`No providers are currently logged in.`}),D.length>0&&(0,$.jsx)(An,{heading:`Logged in providers`,children:D.map(e=>(0,$.jsx)(Ts,{provider:e,actionLabel:`Logout`,disabled:C.isPending,onSelect:()=>{C.isPending||(c({type:`closed`}),C.mutate({provider:e.id}))}},xs(e)))})]}),a?(0,$.jsx)(`div`,{className:`border-t border-border/70 p-3`,children:(0,$.jsx)(Y,{type:`button`,variant:`outline`,className:`w-full`,onClick:y,children:`Cancel`})}):(0,$.jsxs)(`div`,{className:`hidden border-t border-border/70 px-3 py-2 text-xs text-muted-foreground md:block`,children:[`Use ↑/↓ to select, Enter to remove credentials, and Esc to`,` `,h.current?`go back`:`close`,`.`]})]}),M=(0,$.jsxs)(`form`,{onSubmit:k,className:`flex min-h-0 flex-1 flex-col`,onKeyDown:e=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),_())},children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border/70 px-3 py-2`,children:[(0,$.jsx)(Y,{type:`button`,variant:`ghost`,size:`icon-sm`,onClick:_,"aria-label":`Back to login providers`,children:(0,$.jsx)(P,{})}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`div`,{className:`truncate text-sm font-medium`,children:u?`Set ${u.name} API key`:`Set provider API key`}),(0,$.jsx)(`div`,{className:`truncate text-xs text-muted-foreground`,children:`The key is saved to pi auth storage, not the browser.`})]})]}),(0,$.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center p-3`,children:(0,$.jsx)(xr,{type:`password`,value:l,onChange:e=>{c({type:`apiKeyChanged`,apiKey:e.target.value})},placeholder:u?`Enter ${u.name} API key`:`Enter API key`,autoComplete:`off`,className:`min-w-0 flex-1`})}),a?(0,$.jsx)(`div`,{className:`border-t border-border/70 p-3`,children:(0,$.jsx)(Y,{type:`submit`,className:`w-full`,disabled:x.isPending||!l.trim(),children:x.isPending?`Saving…`:`Save API key`})}):(0,$.jsxs)(`div`,{className:`hidden flex-wrap items-center gap-x-3 gap-y-1 border-t border-border/70 px-3 py-2 text-xs text-muted-foreground md:flex`,children:[(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,$.jsx)(r,{children:`Enter`}),`Save`]}),(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,$.jsx)(r,{children:`Esc`}),`Back`]})]})]});return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(ws,{open:d,isMobile:a,onOpenChange:e=>{e?c({type:`loginOpened`}):y()},title:`Login to provider`,description:`Search providers and press Enter to configure authentication.`,children:A}),(0,$.jsx)(ws,{open:f,isMobile:a,onOpenChange:e=>{e?c({type:`logoutOpened`}):y()},title:`Logout from provider`,description:`Search saved provider credentials and press Enter to remove them.`,children:j}),(0,$.jsx)(ws,{open:p,isMobile:a,onOpenChange:e=>{e?u&&c({type:`apiKeyOpened`,provider:u}):_()},title:u?`Set ${u.name} API key`:`Set provider API key`,description:`Enter an API key to save it to pi auth storage.`,children:M})]})}function As(e){return[e.title,e.description,...e.keywords??[]].join(` `)}function js(e){let t=(0,Q.c)(29),{open:n,onOpenChange:r,commands:i,onCommandError:a}=e,[o,s]=Z.useState(``),c=ar(),l;if(t[0]!==i){let e=new Map;for(let t of i){let n=e.get(t.group);n?n.push(t):e.set(t.group,[t])}l=Array.from(e.entries()),t[0]=i,t[1]=l}else l=t[1];let u=l,d,f;t[2]!==n||t[3]!==o?(d=()=>{!n&&o&&s(``)},f=[n,o],t[2]=n,t[3]=o,t[4]=d,t[5]=f):(d=t[4],f=t[5]),Z.useEffect(d,f);let p;t[6]!==a||t[7]!==r?(p=e=>{r(!1),Promise.resolve(e.onSelect()).catch(e=>{a?.(e)})},t[6]=a,t[7]=r,t[8]=p):p=t[8];let m=p,h;t[9]===o?h=t[10]:(h=(0,$.jsx)(Qt,{value:o,onValueChange:s,placeholder:`Search commands`,className:`text-base md:text-sm`}),t[9]=o,t[10]=h);let g;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,$.jsx)(Lt,{children:`No commands found.`}),t[11]=g):g=t[11];let _;t[12]!==u||t[13]!==m?(_=(0,$.jsxs)(Mn,{className:`max-h-none min-h-0 flex-1 md:max-h-[min(70vh,32rem)]`,children:[g,u.map(e=>{let[t,n]=e;return(0,$.jsx)(An,{heading:t,children:n.map(e=>(0,$.jsxs)(On,{value:As(e),onSelect:()=>m(e),children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,$.jsx)(`span`,{className:`truncate font-medium`,children:e.title}),(0,$.jsx)(`span`,{className:`truncate text-xs text-muted-foreground`,children:e.description})]}),e.shortcut?(0,$.jsx)(Xt,{children:e.shortcut}):null]},e.id))},t)})]}),t[12]=u,t[13]=m,t[14]=_):_=t[14];let v;t[15]!==h||t[16]!==_?(v=(0,$.jsxs)(xn,{shouldFilter:!0,loop:!0,className:`min-h-0 flex-1`,children:[h,_]}),t[15]=h,t[16]=_,t[17]=v):v=t[17];let y=v;if(c){let e;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsxs)(tn,{children:[(0,$.jsx)(ln,{children:`Command palette`}),(0,$.jsx)(_n,{children:`Search for commands and session actions.`})]}),t[18]=e):e=t[18];let i;t[19]===y?i=t[20]:(i=(0,$.jsxs)(pn,{className:`max-h-[90svh] overflow-hidden`,children:[e,(0,$.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden px-4 pb-4`,children:y})]}),t[19]=y,t[20]=i);let a;return t[21]!==r||t[22]!==n||t[23]!==i?(a=(0,$.jsx)(dn,{open:n,onOpenChange:r,children:i}),t[21]=r,t[22]=n,t[23]=i,t[24]=a):a=t[24],a}let b;return t[25]!==y||t[26]!==r||t[27]!==n?(b=(0,$.jsx)(Vr,{open:n,onOpenChange:r,title:`Command palette`,description:`Search for commands and session actions.`,className:`sm:max-w-2xl`,initialFocus:!0,children:y}),t[25]=y,t[26]=r,t[27]=n,t[28]=b):b=t[28],b}function Ms(e){let t=(0,Q.c)(25),n,r,i,a,o;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5]):({ref:o,openStateRef:i,commands:n,getCommandsRef:r,...a}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o);let[s,c]=Z.useState(!1),l;t[6]===n?l=t[7]:(l=()=>n??[],t[6]=n,t[7]=l);let[u,d]=Z.useState(l),f=Z.useRef(s),p;t[8]!==n||t[9]!==r?(p=()=>r?.current()??n??[],t[8]=n,t[9]=r,t[10]=p):p=t[10];let m=p,h;t[11]!==i||t[12]!==m?(h=e=>{f.current=e,i&&(i.current=e),e&&d(m()),c(e)},t[11]=i,t[12]=m,t[13]=h):h=t[13];let g=h,_;t[14]===g?_=t[15]:(_=()=>({open:()=>{g(!0)},close:()=>{g(!1)},isOpen:()=>f.current}),t[14]=g,t[15]=_);let v;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(v=[],t[16]=v):v=t[16],Z.useImperativeHandle(o,_,v);let y;t[17]!==s||t[18]!==u?(y=s?u:[],t[17]=s,t[18]=u,t[19]=y):y=t[19];let b;return t[20]!==s||t[21]!==a||t[22]!==g||t[23]!==y?(b=(0,$.jsx)(js,{open:s,onOpenChange:g,commands:y,...a}),t[20]=s,t[21]=a,t[22]=g,t[23]=y,t[24]=b):b=t[24],b}function Ns(e){return e.replace(/^\/Users\/[^/]+(?=\/|$)/,`~`).replace(/^\/home\/[^/]+(?=\/|$)/,`~`)}function Ps(e){let t=new Set,n=[];for(let r of e){let e=r.trim();!e||t.has(e)||(t.add(e),n.push(e))}return n}function Fs(e,t=Date.now()){if(!e)return``;let n=new Date(e).getTime();if(Number.isNaN(n))return``;let r=t-n,i=r>=0,a=Math.max(1,Math.floor(Math.abs(r)/1e3)),o=i?`ago`:`from now`;if(a<60)return`${a}s ${o}`;let s=Math.floor(a/60);if(s<60)return`${s}m ${o}`;let c=Math.floor(s/60);if(c<24)return`${c}h ${o}`;let l=Math.floor(c/24);if(l<7)return`${l}d ${o}`;let u=Math.floor(l/7);if(u<5)return`${u}w ${o}`;let d=Math.floor(l/30);if(d<12)return`${Math.max(1,d)}mo ${o}`;let f=Math.floor(l/365);return`${Math.max(1,f)}y ${o}`}function Is(e){let t=e.lastUserMessageAt||e.modified;if(!t)return 0;let n=new Date(t).getTime();return Number.isNaN(n)?0:n}function Ls(e,t){let n=e.path?`path:${e.path}`:``,r=e.id?`id:${e.id}`:``;return(n?t[n]:void 0)||(r?t[r]:void 0)}function Rs(e,t){let n=e.path?t[e.path]:void 0;return!n||e.title===n?e:{...e,name:n,title:n}}function zs(e,t){if(!t)return e;let n=typeof t.streaming==`boolean`?t.streaming:e.streaming,r=typeof t.unread==`boolean`?t.unread:e.unread;return!!e.streaming==!!n&&!!e.unread==!!r?e:{...e,streaming:n,unread:r}}function Bs(e,t){return[e.title,e.name,e.path,e.cwd,t].filter(Boolean)}function Vs(e,t,n){return!!(e.id&&t&&e.id===t||e.path&&n&&e.path===n)}function Hs(e,t){return oi(hi(`/api/directory-sessions-indexes`,{contextId:e,searchParams:{directory:t}}))}function Us(e){let t=(0,Q.c)(2),{children:n}=e,i;return t[0]===n?i=t[1]:(i=(0,$.jsx)(r,{children:n}),t[0]=n,t[1]=i),i}var Ws={query:``,scope:`current`,stage:`browse`,selectedSessionKey:``,renameValue:``,localSessionNames:{},loadedSessionsByPath:{},loadingByPath:{}};function Gs(e,t){switch(t.type){case`closed`:return e.query===``&&e.scope===`current`&&e.stage===`browse`&&e.renameValue===``?e:{...e,query:``,scope:`current`,stage:`browse`,renameValue:``};case`queryChanged`:return e.query===t.query?e:{...e,query:t.query};case`scopeToggled`:return{...e,scope:e.scope===`current`?`all`:`current`};case`selectedSessionChanged`:return e.selectedSessionKey===t.key?e:{...e,selectedSessionKey:t.key};case`browseRequested`:return e.stage===`browse`?e:{...e,stage:`browse`};case`renameRequested`:return{...e,renameValue:t.value,stage:`rename`};case`renameValueChanged`:return e.renameValue===t.value?e:{...e,renameValue:t.value};case`renameSaved`:return{...e,localSessionNames:{...e.localSessionNames,[t.path]:t.name},stage:`browse`};case`deleteRequested`:return e.stage===`delete`?e:{...e,stage:`delete`};case`deleteSaved`:{let n={},r=!1;for(let[i,a]of Object.entries(e.loadedSessionsByPath)){let e=a.filter(e=>e.path!==t.path);n[i]=e,e.length!==a.length&&(r=!0)}let i=e.localSessionNames;return Object.prototype.hasOwnProperty.call(e.localSessionNames,t.path)&&(i={...e.localSessionNames},delete i[t.path]),{...e,loadedSessionsByPath:r?n:e.loadedSessionsByPath,localSessionNames:i,selectedSessionKey:``,stage:`browse`}}case`directoriesLoadingStarted`:{let n=!1,r={...e.loadingByPath};for(let e of t.directories)r[e]||(r[e]=!0,n=!0);return n?{...e,loadingByPath:r}:e}case`directoriesLoadingFinished`:{let n=!1,r={...e.loadingByPath};for(let e of t.directories)Object.prototype.hasOwnProperty.call(r,e)&&(delete r[e],n=!0);let i=e.loadedSessionsByPath;if(t.directoryIndexes){i={...e.loadedSessionsByPath};for(let e of t.directories)i[e]=t.directoryIndexes[e]?.sessions||[]}return!n&&i===e.loadedSessionsByPath?e:{...e,loadingByPath:n?r:e.loadingByPath,loadedSessionsByPath:i}}case`visibleSelectionChanged`:{let n=e.stage===`browse`?e.renameValue:``;return e.selectedSessionKey===t.key&&e.stage===`browse`&&e.renameValue===n?e:{...e,selectedSessionKey:t.key,stage:`browse`,renameValue:n}}default:return e}}function Ks(e){return qs(e)}function qs({open:e,onOpenChange:t,viewerContextId:n,currentDirectory:r,knownDirectories:i,directorySessionsByPath:a,sessionStatusByKey:o,activeSessionId:s,activeSessionPath:c,onSelectSession:l,onRenameSession:u,onDeleteSession:d,onError:f}){let p=ar(),[m,h]=Z.useState(!1),[g,_]=Z.useState(``),[v,y]=Z.useReducer(Gs,Ws),{query:b,scope:x,stage:S,selectedSessionKey:C,renameValue:w,localSessionNames:T,loadedSessionsByPath:D,loadingByPath:O}=v,k=r.trim(),A=Ps([k,...i,...Object.keys(a)]),j=k?[k]:A.slice(0,1),M=x===`all`?A:j,N={...D,...a},F=M.map(e=>({directory:e,sessions:(N[e]||[]).map(e=>Rs(zs(e,Ls(e,o)),T)),loading:!!O[e]})),I=F.flatMap(e=>e.sessions.map(t=>({directory:e.directory,entry:t,key:We(t)}))),L=I.toSorted((e,t)=>Is(t.entry)-Is(e.entry)),R=C?I.find(e=>e.key===C)?.entry:void 0,z=!!(R?.path&&!R.name?.trim()&&g!==R.path),B=F.some(e=>e.loading),V=Z.useRef(null),H=Z.useRef(null),U=Z.useRef(S);Z.useEffect(()=>{e||y({type:`closed`})},[e]),Z.useEffect(()=>{if(!e||!n||M.length===0)return;let t=M.filter(e=>!Object.prototype.hasOwnProperty.call(N,e)&&!O[e]);t.length!==0&&(y({type:`directoriesLoadingStarted`,directories:t}),Hs(n,t).then(e=>{y({type:`directoriesLoadingFinished`,directories:t,directoryIndexes:e.ok?e.directoryIndexes:void 0})}).catch(e=>{f?.(e),y({type:`directoriesLoadingFinished`,directories:t})}))},[O,N,f,e,M,n]),Z.useEffect(()=>{e&&(I.some(e=>e.key===C)||y({type:`visibleSelectionChanged`,key:I.find(e=>Vs(e.entry,s,c))?.key||I[0]?.key||``}))},[s,c,I,e,C]),Z.useEffect(()=>{let t=U.current;if(U.current=S,!e||S!==`browse`||t===`browse`)return;let n=window.requestAnimationFrame(()=>{V.current?.focus()});return()=>{window.cancelAnimationFrame(n)}},[e,S]),Z.useEffect(()=>{if(!e||S!==`delete`)return;let t=window.requestAnimationFrame(()=>{H.current?.focus()});return()=>{window.cancelAnimationFrame(t)}},[e,S]);let W=()=>{y({type:`scopeToggled`})},ee=e=>{e.id&&(t(!1),l(e.id,{sessionPath:e.path}))},te=()=>{R?.path&&(_(``),y({type:`renameRequested`,value:R.title}))},ne=async()=>{let e=R?.path,t=w.trim();e&&await Promise.resolve(u(e,t))!==!1&&y({type:`renameSaved`,path:e,name:t})},G=async()=>{let e=R?.path;if(!(!e||m||!z)){h(!0);try{let t=await oi(hi(`/api/session/name`,{contextId:n}),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({path:e})});y({type:`renameValueChanged`,value:t.name}),_(e),t.source===`heuristic`&&t.reason&&X.info(`Using heuristic session name`,{description:t.reason})}catch(e){f?.(e)}finally{h(!1)}}},K=()=>{R?.path&&y({type:`deleteRequested`})},re=async()=>{let e=R?.path;if(!R||!e)return;let t={...R,path:e};await Promise.resolve(d([t]))!==!1&&y({type:`deleteSaved`,path:e})};Z.useEffect(()=>{if(!e||S!==`delete`)return;let t=e=>{if(e.key===`Escape`){e.preventDefault(),e.stopPropagation(),y({type:`browseRequested`});return}e.key!==`Enter`||e.isComposing||(e.preventDefault(),e.stopPropagation(),re())};return window.addEventListener(`keydown`,t,!0),()=>{window.removeEventListener(`keydown`,t,!0)}},[re,e,S]);let q=(0,$.jsxs)(xn,{shouldFilter:!0,loop:!0,value:C,onValueChange:e=>{y({type:`selectedSessionChanged`,key:e})},onKeyDown:e=>{if(e.key.toLowerCase()===`tab`){e.preventDefault(),W();return}if(Sn(e.nativeEvent,`Control+R`)){e.preventDefault(),te();return}Sn(e.nativeEvent,`Control+D`)&&(e.preventDefault(),K())},className:`min-h-0 flex-1`,children:[(0,$.jsx)(Qt,{ref:V,value:b,onValueChange:e=>{y({type:`queryChanged`,query:e})},placeholder:x===`all`?`Search all sessions`:`Search sessions`,className:`text-base md:text-sm`}),(0,$.jsxs)(Mn,{className:`max-h-none min-h-0 flex-1 md:max-h-[min(70vh,32rem)]`,children:[(0,$.jsx)(Lt,{children:B?`Loading sessions…`:`No sessions found.`}),(0,$.jsxs)(An,{heading:`${x===`all`?`All sessions`:`Current directory: ${Ns(j[0]||``)}`}${B?` · loading`:``}`,children:[B&&L.length===0?(0,$.jsxs)(On,{value:`loading:sessions`,disabled:!0,children:[(0,$.jsx)(wt,{className:`text-primary`}),(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:`Loading sessions…`})]}):null,L.map(({directory:e,entry:t})=>{let n=We(t),r=Fs(t.lastUserMessageAt||t.modified),i=Vs(t,s,c),a=!!t.unread&&!t.streaming;return(0,$.jsxs)(On,{value:n,keywords:Bs(t,e),onSelect:()=>ee(t),className:`items-start py-2`,children:[(0,$.jsx)(`span`,{className:`mt-0.5 flex size-4 shrink-0 items-center justify-center`,children:t.streaming?(0,$.jsx)(wt,{className:`text-primary`,"aria-label":`Session streaming`}):a?(0,$.jsx)(`span`,{className:`size-2 rounded-full bg-primary`,"aria-label":`Session done`}):null}),(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,$.jsx)(`span`,{className:`truncate font-medium`,children:t.title}),(0,$.jsx)(`span`,{className:`line-clamp-1 text-xs text-muted-foreground`,children:Ns(t.cwd||e)})]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 flex-col items-end gap-1`,children:[r?(0,$.jsx)(`span`,{className:`truncate text-[11px] text-muted-foreground/70`,children:r}):null,(0,$.jsx)(Xt,{className:E(`ml-0 shrink-0 tracking-normal normal-case`,!i&&`opacity-0`),children:`Current`})]})]},n)})]})]}),p?null:(0,$.jsxs)(`div`,{className:`hidden flex-wrap items-center gap-x-3 gap-y-1 border-t border-border/70 px-3 py-2 text-xs text-muted-foreground md:flex`,children:[(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,$.jsx)(Us,{children:`Tab`}),x===`all`?`Current directory`:`All sessions`]}),(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,$.jsx)(Us,{children:`Enter`}),` Switch`]}),(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,$.jsx)(Us,{children:Ir(`Control+R`)}),` Rename`]}),(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,$.jsx)(Us,{children:Ir(`Control+D`)}),` Delete`]}),(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,$.jsx)(Us,{children:`Esc`}),` Close`]})]})]}),ie=(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border/70 px-3 py-2`,children:[(0,$.jsx)(Y,{type:`button`,variant:`ghost`,size:`icon-sm`,onClick:()=>{y({type:`browseRequested`})},"aria-label":`Back to sessions`,children:(0,$.jsx)(P,{})}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`div`,{className:`truncate text-sm font-medium`,children:`Rename session`}),(0,$.jsx)(`div`,{className:`truncate text-xs text-muted-foreground`,children:R?.title||`Selected session`})]}),(0,$.jsxs)(Y,{type:`button`,variant:`ghost`,disabled:m||!z,onClick:()=>{G()},children:[m?(0,$.jsx)(wt,{}):(0,$.jsx)(Tn,{}),`Generate`]})]}),(0,$.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center p-3`,children:(0,$.jsx)(xr,{value:w,onChange:e=>{y({type:`renameValueChanged`,value:e.target.value})},onKeyDown:e=>{if(e.key===`Escape`){e.preventDefault(),e.stopPropagation(),y({type:`browseRequested`});return}if(Sn(e.nativeEvent,`Control+G`)){e.preventDefault(),e.stopPropagation(),G();return}e.key!==`Enter`||e.nativeEvent.isComposing||(e.preventDefault(),e.stopPropagation(),ne())},placeholder:`Session name`,className:`min-w-0 flex-1`})}),p?null:(0,$.jsxs)(`div`,{className:`hidden flex-wrap items-center gap-x-3 gap-y-1 border-t border-border/70 px-3 py-2 text-xs text-muted-foreground md:flex`,children:[(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,$.jsx)(Us,{children:Ir(`Control+G`)}),` Generate`]}),(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,$.jsx)(Us,{children:`Enter`}),` Save`]}),(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,$.jsx)(Us,{children:`Esc`}),` Back`]})]})]}),J=(0,$.jsxs)(`div`,{ref:H,role:`presentation`,tabIndex:-1,className:`flex min-h-0 flex-1 flex-col outline-none`,onKeyDown:e=>{if(e.key===`Escape`){e.preventDefault(),e.stopPropagation(),y({type:`browseRequested`});return}e.key!==`Enter`||e.nativeEvent.isComposing||(e.preventDefault(),e.stopPropagation(),re())},children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border/70 px-3 py-2`,children:[(0,$.jsx)(Y,{type:`button`,variant:`ghost`,size:`icon-sm`,onClick:()=>{y({type:`browseRequested`})},"aria-label":`Back to sessions`,children:(0,$.jsx)(P,{})}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`div`,{className:`truncate text-sm font-medium`,children:`Delete session`}),(0,$.jsx)(`div`,{className:`truncate text-xs text-muted-foreground`,children:R?.title||`Selected session`})]})]}),(0,$.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center p-3`,children:(0,$.jsxs)(`p`,{className:`min-w-0 flex-1 truncate text-sm text-muted-foreground`,children:[`Delete "`,R?.title||`New session`,`" from disk?`]})}),p?null:(0,$.jsxs)(`div`,{className:`hidden flex-wrap items-center gap-x-3 gap-y-1 border-t border-border/70 px-3 py-2 text-xs text-muted-foreground md:flex`,children:[(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,$.jsx)(Us,{children:`Enter`}),` Delete`]}),(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,$.jsx)(Us,{children:`Esc`}),` Back`]})]})]}),ae=S===`rename`?ie:S===`delete`?J:q;return p?(0,$.jsx)(dn,{open:e,onOpenChange:t,children:(0,$.jsxs)(pn,{className:`max-h-[90svh] overflow-hidden`,children:[(0,$.jsxs)(tn,{children:[(0,$.jsx)(ln,{children:`Sessions`}),(0,$.jsx)(_n,{children:`Search and switch sessions.`})]}),(0,$.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden px-4 pb-4`,children:ae})]})}):(0,$.jsx)(Vr,{open:e,onOpenChange:t,title:`Sessions`,description:`Search and switch sessions. Press Tab to toggle current directory and all sessions.`,className:`sm:max-w-2xl`,initialFocus:!0,children:ae})}function Js(e){let t=(0,Q.c)(13),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({ref:i,openStateRef:n,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let[a,o]=Z.useState(!1),s=Z.useRef(a),c;t[4]===n?c=t[5]:(c=e=>{s.current=e,n&&(n.current=e),o(e)},t[4]=n,t[5]=c);let l=c,u;t[6]===l?u=t[7]:(u=()=>({open:()=>{l(!0)},close:()=>{l(!1)},isOpen:()=>s.current}),t[6]=l,t[7]=u);let d;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(d=[],t[8]=d):d=t[8],Z.useImperativeHandle(i,u,d);let f;return t[9]!==a||t[10]!==r||t[11]!==l?(f=(0,$.jsx)(Ks,{open:a,onOpenChange:l,...r}),t[9]=a,t[10]=r,t[11]=l,t[12]=f):f=t[12],f}var Ys=[...nt],Xs=[`auto`,`websocket-cached`,`websocket`,`sse`],Zs=[{heading:`Auto`,colorMode:`auto`},{heading:`Dark`,colorMode:`dark`},{heading:`Light`,colorMode:`light`}].map(e=>({...e,themes:Ys.filter(t=>l(t,e.colorMode))})),Qs=`(min-width: 768px)`;function $s(){return typeof window<`u`&&window.matchMedia(Qs).matches}function ec(e){return e===`auto`||e===`light`||e===`dark`}function tc(e){return`${e.colorMode}:${e.theme}`}function nc(e){let t=e.indexOf(`:`);if(t<0)return;let n=e.slice(0,t),r=e.slice(t+1);if(!ec(n)||!Ys.includes(r))return;let i=r;if(l(i,n))return{theme:i,colorMode:n}}function rc(e,t){return{theme:e,colorMode:he(e)??t}}function ic(e,t){return e.colorMode===`auto`?xt(e.colorMode,t):e.colorMode===`light`?`Light`:`Dark`}function ac(e,t){return`${V(e.theme)} · ${ic(e,t)}`}function oc(e){return e.colorMode===`auto`?`Auto: ${kt(e.theme)}`:he(e.theme)?`${ic(e)} only: ${kt(e.theme)}`:kt(e.theme)}function sc(e){return[e.colorMode,ic(e),...Et(e.theme)]}function cc(e,t){return{query:``,themeQuery:``,stage:`browse`,selectedCommandId:`theme`,selectedTheme:rc(e,t)}}function lc(e,t){switch(t.type){case`reset`:return cc(t.currentTheme,t.currentThemeColorMode);case`set-query`:return{...e,query:t.query};case`set-theme-query`:return{...e,themeQuery:t.themeQuery};case`set-selected-command-id`:return{...e,selectedCommandId:t.selectedCommandId};case`open-theme`:return{...e,stage:`theme`,selectedTheme:rc(t.currentTheme,t.currentThemeColorMode)};case`close-theme`:return{...e,stage:`browse`,selectedTheme:t.selectedTheme};case`preview-theme`:return{...e,selectedTheme:t.selectedTheme}}}function uc(e){return e===`unsupported`?`Desktop notifications are unavailable in this browser.`:e===`granted`?`Desktop notifications are enabled for this origin.`:e===`denied`?`Desktop notifications are blocked in this browser.`:`Desktop notifications will ask for browser permission when enabled.`}function dc(e){return e?`On`:`Off`}function fc(e){return[e.title,e.description,e.valueLabel,...e.keywords]}function pc(e,t,n){let r=t.trim().toLowerCase();return r?+!![e,...n??[]].join(` `).toLowerCase().includes(r):1}function mc(e){switch(e){case`websocket-cached`:return`Cached WebSocket`;case`websocket`:return`WebSocket`;case`sse`:return`SSE`;default:return`Auto`}}function hc({currentTheme:e,currentThemeColorMode:t,systemTheme:n,hideThinkingBlocks:r,onHideThinkingBlocksChange:i,hideToolBlocks:a,onHideToolBlocksChange:o,centerMessages:s,onCenterMessagesChange:c,autoScrollEnabled:l,onAutoScrollEnabledChange:u,sessionDoneSoundEnabled:d,onSessionDoneSoundEnabledChange:f,sessionDoneDesktopNotificationsEnabled:p,onSessionDoneDesktopNotificationsEnabledChange:m,desktopNotificationPermission:h,onLoginProviders:g,onLogoutProviders:_,onThemeCommand:v,piTransport:y,piCacheRetention:b,onPiTransportChange:x,onPiCacheRetentionChange:S}){let C=uc(h);return[{heading:`Appearance`,commands:[{id:`theme`,title:`Theme`,description:`Choose an auto, dark, or light color palette.`,valueLabel:ac(rc(e,t),n),keywords:[`auto`,`system`,`light`,`dark`,`color`,`mode`,`palette`,...Ys.flatMap(e=>Et(e))],onSelect:v}]},{heading:`Conversation display`,commands:[{id:`hide-thinking-blocks`,title:`Hide thinking blocks`,description:`Collapse assistant reasoning into the short hidden-thinking preview.`,valueLabel:dc(r),keywords:[`reasoning`,`thinking`,`display`,`collapse`],onSelect:()=>i(!r)},{id:`hide-tool-calls`,title:`Hide tool calls`,description:`Hide assistant tool execution cards in the conversation view.`,valueLabel:dc(a),keywords:[`tools`,`calls`,`display`,`cards`],onSelect:()=>o(!a)},{id:`center-messages`,title:`Center messages at 80ch`,description:`Constrain each message to a centered 80 character column.`,valueLabel:dc(s),keywords:[`center`,`messages`,`width`,`80`,`column`],onSelect:()=>c(!s)},{id:`auto-scroll-latest`,title:`Auto-scroll to latest messages`,description:`Follow new messages and streaming output automatically.`,valueLabel:dc(l),keywords:[`auto`,`scroll`,`latest`,`follow`,`streaming`],onSelect:()=>u(!l)}]},{heading:`Pi performance`,commands:[{id:`pi-transport`,title:`Provider transport`,description:`Choose how Pi streams provider responses. Auto uses the best supported transport.`,valueLabel:mc(y),keywords:[`pi`,`transport`,`sse`,`websocket`,`performance`],onSelect:()=>x(Xs[(Xs.indexOf(y)+1)%Xs.length])},{id:`pi-cache-retention`,title:`Long prompt cache retention`,description:`Keep supported provider prompt caches longer for sessions with pauses between turns.`,valueLabel:dc(b===`long`),keywords:[`pi`,`prompt`,`cache`,`retention`,`performance`],onSelect:()=>S(b===`long`?`standard`:`long`)}]},{heading:`Provider authentication`,commands:[{id:`login-providers`,title:`Login to provider`,description:`Authenticate a subscription provider or save a provider API key.`,valueLabel:`Open`,keywords:[`auth`,`authentication`,`login`,`provider`,`api key`],onSelect:g},{id:`logout-providers`,title:`Logout from provider`,description:`Remove saved provider credentials from pi auth storage.`,valueLabel:`Open`,keywords:[`auth`,`authentication`,`logout`,`provider`,`remove`],onSelect:_}]},{heading:`Session completion notifications`,commands:[{id:`desktop-notifications`,title:`Desktop notifications`,description:C,valueLabel:dc(p),keywords:[`desktop`,`browser`,`notifications`,`permission`,h],onSelect:()=>m(!p)},{id:`completion-sound`,title:`Completion sound`,description:`Play a short confirmation sound when a session finishes.`,valueLabel:dc(d),keywords:[`sound`,`audio`,`completion`,`notifications`],onSelect:()=>f(!d)}]}]}function gc(e){let t=(0,Q.c)(19),{query:n,selectedCommandId:r,settingGroups:i,onQueryChange:a,onSelectedCommandIdChange:o,onSelectCommand:s}=e,c=Z.useRef(null),l,u;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(l=()=>{$s()&&c.current?.focus()},u=[],t[0]=l,t[1]=u):(l=t[0],u=t[1]),Z.useEffect(l,u);let d;t[2]!==a||t[3]!==n?(d=(0,$.jsx)(Qt,{ref:c,value:n,onValueChange:a,placeholder:`Search settings`,className:`text-base md:text-sm`}),t[2]=a,t[3]=n,t[4]=d):d=t[4];let f;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,$.jsx)(Lt,{children:`No settings found.`}),t[5]=f):f=t[5];let p;if(t[6]!==s||t[7]!==i){let e;t[9]===s?e=t[10]:(e=e=>(0,$.jsx)(An,{heading:e.heading,children:e.commands.map(e=>(0,$.jsxs)(On,{value:e.id,keywords:fc(e),onSelect:()=>s(e),className:`items-start py-2`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,$.jsx)(`span`,{className:`truncate font-medium`,children:e.title}),(0,$.jsx)(`span`,{className:`line-clamp-2 text-xs text-muted-foreground`,children:e.description})]}),(0,$.jsx)(Xt,{className:`inline shrink-0 tracking-normal normal-case`,children:e.valueLabel})]},e.id))},e.heading),t[9]=s,t[10]=e),p=i.map(e),t[6]=s,t[7]=i,t[8]=p}else p=t[8];let m;t[11]===p?m=t[12]:(m=(0,$.jsxs)(Mn,{className:`max-h-none min-h-0 flex-1 md:max-h-[min(70vh,32rem)]`,children:[f,p]}),t[11]=p,t[12]=m);let h;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,$.jsx)(`div`,{className:`hidden border-t border-border/70 px-3 py-2 text-xs text-muted-foreground md:block`,children:`Use ↑/↓ to select, Enter to open or toggle, and Esc to close.`}),t[13]=h):h=t[13];let g;return t[14]!==o||t[15]!==r||t[16]!==d||t[17]!==m?(g=(0,$.jsxs)(xn,{shouldFilter:!0,filter:pc,loop:!0,value:r,onValueChange:o,className:`min-h-0 flex-1`,children:[d,m,h]}),t[14]=o,t[15]=r,t[16]=d,t[17]=m,t[18]=g):g=t[18],g}function _c(e){let t=(0,Q.c)(41),{currentTheme:n,currentThemeColorMode:r,selectedTheme:i,systemTheme:a,themeQuery:o,onThemeQueryChange:s,onThemePreview:c,onThemeSelect:l,onCancelThemePreview:u}=e,d=Z.useRef(null),f,p;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(f=()=>{$s()&&d.current?.focus()},p=[],t[0]=f,t[1]=p):(f=t[0],p=t[1]),Z.useEffect(f,p);let m;t[2]===u?m=t[3]:(m=e=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),u())},t[2]=u,t[3]=m);let h;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,$.jsx)(P,{}),t[4]=h):h=t[4];let g;t[5]===u?g=t[6]:(g=(0,$.jsx)(Y,{type:`button`,variant:`ghost`,size:`icon-sm`,onClick:u,"aria-label":`Back to settings`,children:h}),t[5]=u,t[6]=g);let _;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,$.jsx)(`div`,{className:`truncate text-sm font-medium`,children:`Choose theme`}),t[7]=_):_=t[7];let v;t[8]!==n||t[9]!==r||t[10]!==a?(v=ac(rc(n,r),a),t[8]=n,t[9]=r,t[10]=a,t[11]=v):v=t[11];let y;t[12]===v?y=t[13]:(y=(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[_,(0,$.jsxs)(`div`,{className:`truncate text-xs text-muted-foreground`,children:[`Current:`,` `,v]})]}),t[12]=v,t[13]=y);let b;t[14]!==g||t[15]!==y?(b=(0,$.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border/70 px-3 py-2`,children:[g,y]}),t[14]=g,t[15]=y,t[16]=b):b=t[16];let x;t[17]===i?x=t[18]:(x=tc(i),t[17]=i,t[18]=x);let S;t[19]===c?S=t[20]:(S=e=>{let t=nc(e);t&&c(t)},t[19]=c,t[20]=S);let C;t[21]!==s||t[22]!==o?(C=(0,$.jsx)(Qt,{ref:d,value:o,onValueChange:s,placeholder:`Search themes`,className:`text-base md:text-sm`}),t[21]=s,t[22]=o,t[23]=C):C=t[23];let w;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,$.jsx)(Lt,{children:`No themes found.`}),t[24]=w):w=t[24];let T;t[25]!==n||t[26]!==r||t[27]!==l?(T=Zs.map(e=>(0,$.jsx)(An,{heading:e.heading,className:`**:[[cmdk-group-heading]]:sticky **:[[cmdk-group-heading]]:top-0 **:[[cmdk-group-heading]]:z-10 **:[[cmdk-group-heading]]:bg-popover`,children:e.themes.map(t=>{let i={theme:t,colorMode:e.colorMode},a=tc(i),o=rc(n,r);return(0,$.jsx)(On,{value:a,keywords:sc(i),onSelect:()=>l(i),"data-checked":a===tc(o)?!0:void 0,className:`items-start py-2`,children:(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,$.jsx)(`span`,{className:`truncate font-medium`,children:V(t)}),(0,$.jsx)(`span`,{className:`line-clamp-2 text-xs text-muted-foreground`,children:oc(i)})]})},a)})},e.colorMode)),t[25]=n,t[26]=r,t[27]=l,t[28]=T):T=t[28];let E;t[29]===T?E=t[30]:(E=(0,$.jsxs)(Mn,{className:`max-h-none min-h-0 flex-1 md:max-h-[min(70vh,28rem)]`,children:[w,T]}),t[29]=T,t[30]=E);let D;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(D=(0,$.jsx)(`div`,{className:`hidden border-t border-border/70 px-3 py-2 text-xs text-muted-foreground md:block`,children:`Use ↑/↓ to select, Enter to choose, and Esc to go back.`}),t[31]=D):D=t[31];let O;t[32]!==x||t[33]!==S||t[34]!==C||t[35]!==E?(O=(0,$.jsxs)(xn,{shouldFilter:!0,loop:!0,value:x,onValueChange:S,className:`min-h-0 flex-1 rounded-none!`,children:[C,E,D]}),t[32]=x,t[33]=S,t[34]=C,t[35]=E,t[36]=O):O=t[36];let k;return t[37]!==O||t[38]!==m||t[39]!==b?(k=(0,$.jsxs)(`div`,{role:`presentation`,className:`flex min-h-0 flex-1 flex-col`,onKeyDown:m,children:[b,O]}),t[37]=O,t[38]=m,t[39]=b,t[40]=k):k=t[40],k}function vc(e){let t=(0,Q.c)(4),{stage:n,browseBodyProps:r,themeBodyProps:i}=e;if(n===`theme`){let e;return t[0]===i?e=t[1]:(e=(0,$.jsx)(_c,{...i}),t[0]=i,t[1]=e),e}let a;return t[2]===r?a=t[3]:(a=(0,$.jsx)(gc,{...r}),t[2]=r,t[3]=a),a}function yc({open:e,onOpenChange:t,viewerContextId:n,currentTheme:r,currentThemeColorMode:i,onThemeChange:a,onThemeColorModeChange:o,onThemePreviewChange:s,systemTheme:c,hideThinkingBlocks:u,onHideThinkingBlocksChange:d,hideToolBlocks:f,onHideToolBlocksChange:p,centerMessages:m,onCenterMessagesChange:h,autoScrollEnabled:g,onAutoScrollEnabledChange:_,sessionDoneSoundEnabled:v,onSessionDoneSoundEnabledChange:y,sessionDoneDesktopNotificationsEnabled:b,onSessionDoneDesktopNotificationsEnabledChange:x,desktopNotificationPermission:S,onLoginProviders:C,onLogoutProviders:w}){let T=ki(),E=nn({queryKey:vi.piPerformance(n),queryFn:()=>oi(hi(`/api/settings/performance`,{contextId:n})),enabled:e&&!!n,staleTime:3e4}),D=E.data?.ok?E.data:void 0,O=an({mutationFn:async e=>await oi(hi(`/api/settings/performance`,{contextId:n}),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(e)}),onSuccess:e=>{e.ok&&(T.setQueryData(vi.piPerformance(n),e),e.appliesToActiveSessionAfterRestart&&X.info(`Pi performance setting saved`,{description:`The active session will use it after its next restart.`}))},onError:e=>{X.error(`Could not update Pi performance`,{description:e instanceof Error?e.message:String(e)})}}),[k,A]=Z.useReducer(lc,{currentTheme:r,currentThemeColorMode:i},({currentTheme:e,currentThemeColorMode:t})=>cc(e,t)),j=Z.useRef(rc(r,i)),M=ar();Z.useEffect(()=>{e||(k.stage===`theme`&&s(j.current.theme,j.current.colorMode),A({type:`reset`,currentTheme:r,currentThemeColorMode:i}))},[r,i,s,e,k.stage]);let N=e=>{Promise.resolve(e.onSelect()).catch(e=>{console.error(e)})},P=e=>{Ys.includes(e.theme)&&l(e.theme,e.colorMode)&&(A({type:`preview-theme`,selectedTheme:e}),s(e.theme,e.colorMode))},F=e=>{A({type:`preview-theme`,selectedTheme:e}),j.current=e,o(e.colorMode),a(e.theme),t(!1)},I=()=>{let e=j.current;A({type:`close-theme`,selectedTheme:e}),s(e.theme,e.colorMode)},L=hc({currentTheme:r,currentThemeColorMode:i,systemTheme:c,hideThinkingBlocks:u,onHideThinkingBlocksChange:d,hideToolBlocks:f,onHideToolBlocksChange:p,centerMessages:m,onCenterMessagesChange:h,autoScrollEnabled:g,onAutoScrollEnabledChange:_,sessionDoneSoundEnabled:v,onSessionDoneSoundEnabledChange:y,sessionDoneDesktopNotificationsEnabled:b,onSessionDoneDesktopNotificationsEnabledChange:x,desktopNotificationPermission:S,onLoginProviders:C,onLogoutProviders:w,piTransport:D?.transport??`auto`,piCacheRetention:D?.cacheRetention??`standard`,onPiTransportChange:async e=>{await O.mutateAsync({transport:e,cacheRetention:D?.cacheRetention??`standard`})},onPiCacheRetentionChange:async e=>{await O.mutateAsync({transport:D?.transport??`auto`,cacheRetention:e})},onThemeCommand:()=>{j.current=rc(r,i),A({type:`open-theme`,currentTheme:r,currentThemeColorMode:i})}}),R=(0,$.jsx)(vc,{stage:k.stage,browseBodyProps:{query:k.query,selectedCommandId:k.selectedCommandId,settingGroups:L,onQueryChange:e=>A({type:`set-query`,query:e}),onSelectedCommandIdChange:e=>A({type:`set-selected-command-id`,selectedCommandId:e}),onSelectCommand:N},themeBodyProps:{currentTheme:r,currentThemeColorMode:i,selectedTheme:k.selectedTheme,systemTheme:c,themeQuery:k.themeQuery,onThemeQueryChange:e=>A({type:`set-theme-query`,themeQuery:e}),onThemePreview:P,onThemeSelect:F,onCancelThemePreview:I}});return M?(0,$.jsx)(dn,{open:e,onOpenChange:t,autoFocus:!1,children:(0,$.jsxs)(pn,{className:`max-h-[90svh] overflow-hidden`,children:[(0,$.jsxs)(tn,{children:[(0,$.jsx)(ln,{children:`Settings`}),(0,$.jsx)(_n,{children:`Search and update settings.`})]}),(0,$.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden px-4 pb-4`,children:R})]})}):(0,$.jsx)(Vr,{open:e,onOpenChange:t,title:`Settings`,description:`Search settings. Press Enter on a setting to open or toggle it.`,className:`sm:max-w-2xl`,initialFocus:!0,children:R})}function bc(e){let t=(0,Q.c)(13),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({ref:i,openStateRef:n,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let[a,o]=Z.useState(!1),s=Z.useRef(a),c;t[4]===n?c=t[5]:(c=e=>{s.current=e,n&&(n.current=e),o(e)},t[4]=n,t[5]=c);let l=c,u;t[6]===l?u=t[7]:(u=()=>({open:()=>{l(!0)},close:()=>{l(!1)},isOpen:()=>s.current}),t[6]=l,t[7]=u);let d;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(d=[],t[8]=d):d=t[8],Z.useImperativeHandle(i,u,d);let f;return t[9]!==a||t[10]!==r||t[11]!==l?(f=(0,$.jsx)(yc,{open:a,onOpenChange:l,...r}),t[9]=a,t[10]=r,t[11]=l,t[12]=f):f=t[12],f}var xc=[{mode:`default`,label:`Default`,shortcut:`Control+D`},{mode:`no-tools`,label:`No tools`,shortcut:`Control+T`},{mode:`user-only`,label:`User only`,shortcut:`Control+U`},{mode:`labeled-only`,label:`Labeled`,shortcut:`Control+L`},{mode:`all`,label:`All`,shortcut:`Control+A`}];function Sc(e,t){return t===`default`||e===t?`default`:t}function Cc(e){let t=(0,Q.c)(3),{children:n,active:i}=e,a=i!==void 0&&i?`true`:void 0,o;return t[0]!==n||t[1]!==a?(o=(0,$.jsx)(r,{"data-active":a,children:n}),t[0]=n,t[1]=a,t[2]=o):o=t[2],o}function wc(e){let t=(0,Q.c)(6),{kbd:n,active:r,children:i}=e,a;t[0]!==r||t[1]!==n?(a=(0,$.jsx)(Cc,{active:r,children:n}),t[0]=r,t[1]=n,t[2]=a):a=t[2];let o;return t[3]!==i||t[4]!==a?(o=(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[a,i]}),t[3]=i,t[4]=a,t[5]=o):o=t[5],o}function Tc(e){return typeof e==`string`?e.replace(/[\n\t]/g,` `).trim():``}function Ec(e){let t=e.node.entry;if(t.type===`message`)switch(t.message?.role){case`user`:return`User`;case`assistant`:return`Assistant`;case`toolResult`:return`Tool`;case`bashExecution`:return`Bash`;default:return t.message?.role||`Message`}switch(t.type){case`compaction`:return`Compaction`;case`branch_summary`:return`Summary`;case`custom_message`:return`Custom`;case`model_change`:return`Model`;case`thinking_level_change`:return`Thinking`;case`session_info`:return`Title`;case`label`:return`Label`;case`custom`:return`Custom`;default:return t.type||`Entry`}}function Dc(e){let t=e.node.entry,n=t.message||{};if(t.type===`message`)switch(n.role){case`user`:return Tc(n.text)||`(no content)`;case`assistant`:return Tc(n.text)||(n.stopReason===`aborted`?`(aborted)`:n.errorMessage?Tc(n.errorMessage):`(no content)`);case`toolResult`:return Tc(n.text)||n.toolName||`Tool result`;case`bashExecution`:return Tc(n.command)||`Bash command`;default:return Tc(n.text)||`Message`}switch(t.type){case`branch_summary`:return Tc(t.summary)||`Branch summary`;case`compaction`:return`Compaction event`;case`session_info`:return Tc(t.name)||`Session title`;case`model_change`:return Tc(t.modelId)||`Model changed`;case`thinking_level_change`:return Tc(t.thinkingLevel)||`Thinking level changed`;case`label`:return Tc(t.label)||`Label updated`;case`custom_message`:case`custom`:return Tc(t.text)||Tc(t.customType)||`Custom entry`;default:return Tc(e.text)||Ec(e)}}function Oc(e){let t=e.node.entry,n=[e.label||``,Dc(e)];if(t.type===`message`){n.push(t.message?.role||``),n.push(t.message?.command||``),n.push(t.message?.errorMessage||``);for(let e of t.message?.toolCalls||[])n.push(e.preview||e.name||``)}return n.push(t.type||``),n.push(t.customType||``),n.push(t.summary||``),n.push(t.modelId||``),n.push(t.thinkingLevel||``),n.push(t.name||``),n.push(t.label||``),n.join(` `).toLowerCase()}function kc(e){let t=e.node.entry.type;return t===`label`||t===`custom`||t===`model_change`||t===`thinking_level_change`||t===`session_info`}function Ac(e,t,n,r){let i=e.node.entry,a=i.message||{};if(e.id!==n&&i.type===`message`&&a.role===`assistant`){let e=!!Tc(a.text),t=typeof a.stopReason==`string`?a.stopReason:``;if(!e&&!(t&&t!==`stop`&&t!==`toolUse`))return!1}switch(t){case`user-only`:if(!(i.type===`message`&&a.role===`user`))return!1;break;case`no-tools`:if(kc(e)||i.type===`message`&&a.role===`toolResult`)return!1;break;case`labeled-only`:if(!e.label)return!1;break;case`all`:break;default:if(kc(e))return!1;break}if(r.length>0){let t=Oc(e);if(!r.every(e=>t.includes(e)))return!1}return!0}function jc(e){let t=new Map(e.map(e=>[e.id,e]));return e.flatMap(e=>{let n=e.parentId??null;return n===null||!t.has(n)?[e.node]:[]})}function Mc(e,t){let n=new Set,r=t;for(;r;)n.add(r),r=e.get(r)?.parentId??null;return n}function Nc({flatTree:e,currentLeafId:t}){let n=new Map(e.map(e=>[e.id,e])),r=jc(e),i=[],a=r.length>1,o=new Map,s=[],c=[...r];for(;c.length>0;){let e=c.pop();if(e?.entry?.id){s.push(e);for(let t=e.children.length-1;t>=0;--t)c.push(e.children[t])}}for(let e=s.length-1;e>=0;--e){let n=s[e],r=t!==null&&n.entry.id===t;for(let e of n.children)if(o.get(e)){r=!0;break}o.set(n,r)}let l=r.toSorted((e,t)=>Number(!!o.get(t))-Number(!!o.get(e))),u=[];for(let e=l.length-1;e>=0;--e){let t=e===l.length-1;u.push([l[e],+!!a,a,a,t,[],a])}for(;u.length>0;){let[e,t,r,s,c,l,d]=u.pop(),f=n.get(e.entry.id);if(!f)continue;i.push({...f,indent:t,showConnector:s,isLast:c,gutters:l,isVirtualRootChild:d,multipleRoots:a});let p=e.children,m=p.length>1,h=[],g=[];for(let e of p)o.get(e)?h.push(e):g.push(e);let _=[...h,...g],v;v=m||r&&t>0?t+1:t;let y=s&&!d,b=a?Math.max(0,t-1):t,x=Math.max(0,b-1),S=y?[...l,{position:x,show:!c}]:l;for(let e=_.length-1;e>=0;--e){let t=e===_.length-1;u.push([_[e],v,m,m,t,S,!1])}}return i}function Pc(e,t){let n=new Map,r=new Map([[null,[]]]);if(e.length===0)return{visibleParentById:n,visibleChildrenById:r};let i=new Set(e.map(e=>e.id)),a=new Map(t.map(e=>[e.id,e])),o=e=>{let t=a.get(e)?.parentId??null;for(;t!==null;){if(i.has(t))return t;t=a.get(t)?.parentId??null}return null};for(let t of e){let e=o(t.id);n.set(t.id,e);let i=r.get(e)??[];i.push(t.id),r.set(e,i)}let s=r.get(null)??[],c=s.length>1,l=new Map(e.map(e=>[e.id,e])),u=[];for(let e=s.length-1;e>=0;--e){let t=e===s.length-1;u.push([s[e],+!!c,c,c,t,[],c])}for(;u.length>0;){let[e,t,n,i,a,o,s]=u.pop(),d=l.get(e);if(!d)continue;d.indent=t,d.showConnector=i,d.isLast=a,d.gutters=o,d.isVirtualRootChild=s,d.multipleRoots=c;let f=r.get(e)??[],p=f.length>1,m;m=p||n&&t>0?t+1:t;let h=i&&!s,g=c?Math.max(0,t-1):t,_=Math.max(0,g-1),v=h?[...o,{position:_,show:!a}]:o;for(let e=f.length-1;e>=0;--e){let t=e===f.length-1;u.push([f[e],m,p,p,t,v,!1])}}return{visibleParentById:n,visibleChildrenById:r}}function Fc({flatTree:e,currentLeafId:t,query:n,filterMode:r,foldedEntryIds:i}){let a=new Map(e.map(e=>[e.id,e])),o=Mc(a,t),s=Nc({flatTree:e,currentLeafId:t}),c=n.trim().toLowerCase().split(/\s+/).filter(Boolean),l=s.filter(e=>Ac(e,r,t,c)),{visibleParentById:u,visibleChildrenById:d}=Pc(l,s),f=new Set;if(i.size>0)for(let e of s){let t=e.parentId??null;t!==null&&(i.has(t)||f.has(t))&&f.add(e.id)}let p=l.filter(e=>!f.has(e.id)),{visibleParentById:m,visibleChildrenById:h}=Pc(p,s);return{nodeById:a,visibleParentById:m,visibleChildrenById:h,orderedVisibleNodes:p.map(e=>{let n=d.get(e.id)??[],r=u.get(e.id),a=d.get(r??null)??[],s=n.length>0&&(r==null||a.length>1);return{...e,hasVisibleChildren:(h.get(e.id)?.length??0)>0,isCurrentLeaf:e.id===t,isActivePath:o.has(e.id),isFoldable:s,isFolded:i.has(e.id)}})}}function Ic(e,t,n){if(t.length===0)return null;if(!e)return t[0]?.id??null;let r=new Set(t.map(e=>e.id)),i=e;for(;i;){if(r.has(i))return i;i=n.get(i)?.parentId??null}return t[0]?.id??null}function Lc(e,t){let n=e.visibleChildrenById.get(t);if(!n||n.length===0)return!1;let r=e.visibleParentById.get(t);if(r==null)return!0;let i=e.visibleChildrenById.get(r);return Array.isArray(i)&&i.length>1}function Rc(e,t,n){let r=new Map(e.orderedVisibleNodes.map((e,t)=>[e.id,t])),i=t;if(n===`down`)for(;;){let t=e.visibleChildrenById.get(i)??[];if(t.length===0)return i;if(t.length>1)return t[0]??i;i=t[0]??i}for(;;){let n=e.visibleParentById.get(i)??null;if(n===null)return i;if((e.visibleChildrenById.get(n)??[]).length>1){let e=r.get(i),n=r.get(t);if(typeof e==`number`&&typeof n==`number`&&e<n)return i}i=n}}function zc(e){let t=(0,Q.c)(24),{name:n,className:r}=e,i;t[0]===r?i=t[1]:(i=E(`block h-6 w-2.5`,r),t[0]=r,t[1]=i);let a;t[2]===n?a=t[3]:(a=n===`gutter`?(0,$.jsx)(`path`,{d:`M5 0V24`,stroke:`currentColor`,strokeWidth:1}):null,t[2]=n,t[3]=a);let o;t[4]===n?o=t[5]:(o=n===`connector-tee`?(0,$.jsx)(`path`,{d:`M5 0V24M5 12H10`,stroke:`currentColor`,strokeWidth:1}):null,t[4]=n,t[5]=o);let s;t[6]===n?s=t[7]:(s=n===`connector-elbow`?(0,$.jsx)(`path`,{d:`M5 0V12M5 12H10`,stroke:`currentColor`,strokeWidth:1}):null,t[6]=n,t[7]=s);let c;t[8]===n?c=t[9]:(c=n===`leaf-line`?(0,$.jsx)(`path`,{d:`M0 12H10`,stroke:`currentColor`,strokeWidth:1}):null,t[8]=n,t[9]=c);let l;t[10]===n?l=t[11]:(l=n===`fold-open`||n===`fold-closed`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`rect`,{x:`0.5`,y:`7.5`,width:`9`,height:`9`,rx:`1.5`,stroke:`currentColor`,strokeWidth:1}),(0,$.jsx)(`path`,{d:n===`fold-closed`?`M2.5 12H7.5M5 9.5V14.5`:`M2.5 12H7.5`,stroke:`currentColor`,strokeWidth:1})]}):null,t[10]=n,t[11]=l);let u;t[12]===n?u=t[13]:(u=n===`active-path`?(0,$.jsx)(`circle`,{cx:`5`,cy:`12`,r:`2.25`,fill:`currentColor`}):null,t[12]=n,t[13]=u);let d;t[14]!==a||t[15]!==o||t[16]!==s||t[17]!==c||t[18]!==l||t[19]!==u?(d=(0,$.jsxs)(`svg`,{className:`block size-full`,viewBox:`0 0 10 24`,fill:`none`,children:[a,o,s,c,l,u]}),t[14]=a,t[15]=o,t[16]=s,t[17]=c,t[18]=l,t[19]=u,t[20]=d):d=t[20];let f;return t[21]!==i||t[22]!==d?(f=(0,$.jsx)(`span`,{"aria-hidden":`true`,className:i,children:d}),t[21]=i,t[22]=d,t[23]=f):f=t[23],f}function Bc(e){let t=(0,Q.c)(21),{node:n,viewModel:r}=e,i=n.multipleRoots?Math.max(0,n.indent-1):n.indent,a=n.showConnector&&!n.isVirtualRootChild,o=a?i-1:-1,s;t[0]!==n.id||t[1]!==r?(s=Lc(r,n.id),t[0]=n.id,t[1]=r,t[2]=s):s=t[2];let c=s,l=i*3;if(l<=0){let e;return t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(`span`,{className:`block h-6 w-0 shrink-0`,"aria-hidden":`true`}),t[3]=e):e=t[3],e}let u;if(t[4]!==c||t[5]!==a||t[6]!==o||t[7]!==n.gutters||t[8]!==n.id||t[9]!==n.isFolded||t[10]!==n.isLast||t[11]!==l){let e;t[13]!==c||t[14]!==a||t[15]!==o||t[16]!==n.gutters||t[17]!==n.id||t[18]!==n.isFolded||t[19]!==n.isLast?(e=(e,t)=>{let r=Math.floor(t/3),i=t%3,s=n.gutters.find(e=>e.position===r);if(s)return(0,$.jsx)(`span`,{className:`flex h-6 w-2.5 items-center justify-center`,children:i===0&&s.show?(0,$.jsx)(zc,{name:`gutter`}):null},`${n.id}-gutter-${r}-${i}`);if(a&&r===o){if(i===0)return(0,$.jsx)(`span`,{className:`flex h-6 w-2.5 items-center justify-center`,children:(0,$.jsx)(zc,{name:n.isLast?`connector-elbow`:`connector-tee`})},`${n.id}-connector-${r}-${i}`);if(i===1)return(0,$.jsx)(`span`,{className:`flex h-6 w-2.5 items-center justify-center`,children:(0,$.jsx)(zc,{name:n.isFolded?`fold-closed`:c?`fold-open`:`leaf-line`})},`${n.id}-marker-${r}-${i}`)}return(0,$.jsx)(`span`,{className:`block h-6 w-2.5 shrink-0`},`${n.id}-empty-${r}-${i}`)},t[13]=c,t[14]=a,t[15]=o,t[16]=n.gutters,t[17]=n.id,t[18]=n.isFolded,t[19]=n.isLast,t[20]=e):e=t[20],u=(0,$.jsx)(`span`,{className:`inline-flex h-6 shrink-0 items-stretch text-muted-foreground`,children:Array.from({length:l},e)}),t[4]=c,t[5]=a,t[6]=o,t[7]=n.gutters,t[8]=n.id,t[9]=n.isFolded,t[10]=n.isLast,t[11]=l,t[12]=u}else u=t[12];return u}function Vc(e){let t=e.node.entry,n=t.message||{};if(t.type===`message`)switch(n.role){case`user`:return`user: ${Tc(n.text)||`(no content)`}`;case`assistant`:{let e=Tc(n.text);return e?`assistant: ${e}`:n.stopReason===`aborted`?`assistant: (aborted)`:n.errorMessage?`assistant: ${Tc(n.errorMessage)}`:`assistant: (no content)`}case`toolResult`:return Dc(e);case`bashExecution`:return`[bash]: ${Tc(n.command)}`;default:return Dc(e)}switch(t.type){case`compaction`:return`[compaction: ${Math.round((Number(t.tokensBefore)||0)/1e3)}k tokens]`;case`branch_summary`:return`[branch summary]: ${Tc(t.summary)||`Branch summary`}`;case`custom_message`:return`[${t.customType||`custom`}]: ${Tc(t.text)||`Custom message`}`;case`model_change`:return`[model: ${t.modelId||``}]`;case`thinking_level_change`:return`[thinking: ${t.thinkingLevel||``}]`;case`session_info`:return t.name?`[title: ${t.name}]`:`[title: empty]`;case`label`:return`[label: ${t.label??`(cleared)`}]`;case`custom`:return`[custom: ${t.customType||`custom`}]`;default:return`[${t.type||`entry`}]`}}function Hc(e){let t=(0,Q.c)(55),{node:n}=e,r=n.node.entry,i;t[0]===r.message?i=t[1]:(i=r.message||{},t[0]=r.message,t[1]=i);let a=i;if(r.type===`message`)switch(a.role){case`user`:{let e;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(`span`,{className:`font-semibold text-primary`,children:`user:`}),t[2]=e):e=t[2];let n;t[3]===a.text?n=t[4]:(n=Tc(a.text)||`(no content)`,t[3]=a.text,t[4]=n);let r;return t[5]===n?r=t[6]:(r=(0,$.jsxs)(`div`,{className:`min-w-0 truncate text-sm leading-6 text-foreground`,children:[e,` `,n]}),t[5]=n,t[6]=r),r}case`assistant`:{let e;t[7]===a.text?e=t[8]:(e=Tc(a.text),t[7]=a.text,t[8]=e);let n=e,r;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsx)(`span`,{className:`font-semibold text-[var(--success)]`,children:`assistant:`}),t[9]=r):r=t[9];let i;t[10]!==a.errorMessage||t[11]!==a.stopReason||t[12]!==n?(i=n||(a.stopReason===`aborted`?(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:`(aborted)`}):a.errorMessage?(0,$.jsx)(`span`,{className:`text-[var(--danger)]`,children:Tc(a.errorMessage)}):(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:`(no content)`})),t[10]=a.errorMessage,t[11]=a.stopReason,t[12]=n,t[13]=i):i=t[13];let o;return t[14]===i?o=t[15]:(o=(0,$.jsxs)(`div`,{className:`min-w-0 truncate text-sm leading-6 text-foreground`,children:[r,` `,i]}),t[14]=i,t[15]=o),o}case`toolResult`:{let e;t[16]===n?e=t[17]:(e=Dc(n),t[16]=n,t[17]=e);let r;return t[18]===e?r=t[19]:(r=(0,$.jsx)(`div`,{className:`min-w-0 truncate text-sm leading-6 text-muted-foreground`,children:e}),t[18]=e,t[19]=r),r}case`bashExecution`:{let e;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:`[bash]:`}),t[20]=e):e=t[20];let n;t[21]===a.command?n=t[22]:(n=Tc(a.command)||`Bash command`,t[21]=a.command,t[22]=n);let r;return t[23]===n?r=t[24]:(r=(0,$.jsxs)(`div`,{className:`min-w-0 truncate text-sm leading-6 text-foreground`,children:[e,` `,n]}),t[23]=n,t[24]=r),r}default:{let e;t[25]===n?e=t[26]:(e=Dc(n),t[25]=n,t[26]=e);let r;return t[27]===e?r=t[28]:(r=(0,$.jsx)(`div`,{className:`min-w-0 truncate text-sm leading-6 text-muted-foreground`,children:e}),t[27]=e,t[28]=r),r}}switch(r.type){case`compaction`:{let e;t[29]===r.tokensBefore?e=t[30]:(e=Math.round((Number(r.tokensBefore)||0)/1e3),t[29]=r.tokensBefore,t[30]=e);let n=e,i;return t[31]===n?i=t[32]:(i=(0,$.jsxs)(`div`,{className:`min-w-0 truncate text-sm leading-6 text-[var(--warning)]`,children:[`[compaction: `,n,`k tokens]`]}),t[31]=n,t[32]=i),i}case`branch_summary`:{let e;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(`span`,{className:`font-semibold`,children:`[branch summary]:`}),t[33]=e):e=t[33];let n;t[34]===r.summary?n=t[35]:(n=Tc(r.summary)||`Branch summary`,t[34]=r.summary,t[35]=n);let i;return t[36]===n?i=t[37]:(i=(0,$.jsxs)(`div`,{className:`min-w-0 truncate text-sm leading-6 text-[var(--warning)]`,children:[e,` `,n]}),t[36]=n,t[37]=i),i}case`custom_message`:{let e=r.customType||`custom`,n;t[38]===r.text?n=t[39]:(n=Tc(r.text)||`Custom message`,t[38]=r.text,t[39]=n);let i;return t[40]!==e||t[41]!==n?(i=(0,$.jsxs)(`div`,{className:`min-w-0 truncate text-sm leading-6 text-[var(--warning)]`,children:[`[`,e,`]:`,` `,n]}),t[40]=e,t[41]=n,t[42]=i):i=t[42],i}case`model_change`:{let e=r.modelId||``,n;return t[43]===e?n=t[44]:(n=(0,$.jsxs)(`div`,{className:`min-w-0 truncate text-sm leading-6 text-muted-foreground`,children:[`[model: `,e,`]`]}),t[43]=e,t[44]=n),n}case`thinking_level_change`:{let e=r.thinkingLevel||``,n;return t[45]===e?n=t[46]:(n=(0,$.jsxs)(`div`,{className:`min-w-0 truncate text-sm leading-6 text-muted-foreground`,children:[`[thinking: `,e,`]`]}),t[45]=e,t[46]=n),n}case`session_info`:{let e=r.name?`[title: ${r.name}]`:`[title: empty]`,n;return t[47]===e?n=t[48]:(n=(0,$.jsx)(`div`,{className:`min-w-0 truncate text-sm leading-6 text-muted-foreground`,children:e}),t[47]=e,t[48]=n),n}case`label`:{let e=r.label??`(cleared)`,n;return t[49]===e?n=t[50]:(n=(0,$.jsxs)(`div`,{className:`min-w-0 truncate text-sm leading-6 text-muted-foreground`,children:[`[label: `,e,`]`]}),t[49]=e,t[50]=n),n}case`custom`:{let e=r.customType||`custom`,n;return t[51]===e?n=t[52]:(n=(0,$.jsxs)(`div`,{className:`min-w-0 truncate text-sm leading-6 text-muted-foreground`,children:[`[custom: `,e,`]`]}),t[51]=e,t[52]=n),n}default:{let e=r.type||`entry`,n;return t[53]===e?n=t[54]:(n=(0,$.jsxs)(`div`,{className:`min-w-0 truncate text-sm leading-6 text-muted-foreground`,children:[`[`,e,`]`]}),t[53]=e,t[54]=n),n}}}function Uc(e){return Wc(e)}function Wc(e){let t=(0,Q.c)(116),{isMobile:n,treeFilterMode:r,onTreeFilterModeChange:i,treeLoading:a,treeSubmitting:o,treeLeafId:s,treeStreamingEntryId:c,treeQuery:l,onTreeQueryChange:u,treeViewModel:d,foldedTreeNodeIds:f,onFoldedTreeNodeIdsChange:p,selectedTreeNodeId:m,onSelectTreeNode:h,onLabelTreeNode:g}=e,[_,v]=Z.useState(m||s||null),y=Z.useRef(null),b=Z.useRef(null),x;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(x=new Map,t[0]=x):x=t[0];let S=Z.useRef(x),C=Z.useRef(!1),w;t[1]!==_||t[2]!==d.orderedVisibleNodes?(w=_==null?null:d.orderedVisibleNodes.find(e=>e.id===_)??null,t[1]=_,t[2]=d.orderedVisibleNodes,t[3]=w):w=t[3];let T=w,D;t[4]!==_||t[5]!==d.orderedVisibleNodes?(D=_?d.orderedVisibleNodes.findIndex(e=>e.id===_):-1,t[4]=_,t[5]=d.orderedVisibleNodes,t[6]=D):D=t[6];let O=D,k=d.orderedVisibleNodes.length,A=Math.max(1,String(k).length),j=String(Math.max(0,O+1)),M;t[7]!==j||t[8]!==A?(M=j.padStart(A,`0`),t[7]=j,t[8]=A,t[9]=M):M=t[9];let N=M,P,F;t[10]!==m||t[11]!==_||t[12]!==s||t[13]!==d.nodeById||t[14]!==d.orderedVisibleNodes?(P=()=>{let e=Ic(_||m||s,d.orderedVisibleNodes,d.nodeById);e!==_&&v(e)},F=[m,_,s,d.nodeById,d.orderedVisibleNodes],t[10]=m,t[11]=_,t[12]=s,t[13]=d.nodeById,t[14]=d.orderedVisibleNodes,t[15]=P,t[16]=F):(P=t[15],F=t[16]),Z.useEffect(P,F);let I,L;t[17]===n?(I=t[18],L=t[19]):(I=()=>{if(n)return;let e=window.requestAnimationFrame(()=>{y.current?.focus()});return()=>{window.cancelAnimationFrame(e)}},L=[n],t[17]=n,t[18]=I,t[19]=L),Z.useEffect(I,L);let R,z;t[20]===_?(R=t[21],z=t[22]):(R=()=>{if(!_)return;let e=window.requestAnimationFrame(()=>{S.current.get(_)?.scrollIntoView({block:`nearest`})});return()=>{window.cancelAnimationFrame(e)}},z=[_],t[20]=_,t[21]=R,t[22]=z),Z.useEffect(R,z);let B,V,H,W,ee,te,ne,G,K,re,q,ie,J,ae,oe;if(t[23]!==O||t[24]!==T||t[25]!==f||t[26]!==n||t[27]!==p||t[28]!==g||t[29]!==h||t[30]!==i||t[31]!==u||t[32]!==_||t[33]!==r||t[34]!==s||t[35]!==a||t[36]!==l||t[37]!==c||t[38]!==o||t[39]!==d){let e=(e,t)=>e===0&&t===0?!1:(C.current=!0,!0),m;t[55]===_?m=t[56]:(m=e=>{_!==e&&v(e)},t[55]=_,t[56]=m);let x=m,w;t[57]!==O||t[58]!==d.orderedVisibleNodes?(w=e=>{let t=d.orderedVisibleNodes;if(t.length===0)return;let n=t[(((O>=0?O:e>0?-1:0)+e)%t.length+t.length)%t.length];n&&v(n.id)},t[57]=O,t[58]=d.orderedVisibleNodes,t[59]=w):w=t[59];let D=w,k;t[60]!==T||t[61]!==f||t[62]!==p||t[63]!==d?(k=e=>{if(!T)return;let t=new Set(f),n=T.id;e?T.isFolded?t.delete(T.id):n=Rc(d,T.id,`down`):T.isFoldable&&!T.isFolded?t.add(T.id):n=Rc(d,T.id,`up`),p(t),v(n)},t[60]=T,t[61]=f,t[62]=p,t[63]=d,t[64]=k):k=t[64];let A=k,j;t[65]===d.orderedVisibleNodes?j=t[66]:(j=()=>{let e=b.current,t=d.orderedVisibleNodes;if(!e||t.length===0)return 1;let n=e.getBoundingClientRect();return Math.max(1,t.filter(e=>{let t=S.current.get(e.id);if(!t)return!1;let r=t.getBoundingClientRect();return r.bottom>n.top&&r.top<n.bottom}).length)},t[65]=d.orderedVisibleNodes,t[66]=j);let M=j,N;t[67]!==D||t[68]!==M?(N=(e,t)=>{let n=M();D((t===`half`?Math.max(1,Math.floor(n/2)):n)*e)},t[67]=D,t[68]=M,t[69]=N):N=t[69];let P=N;ae=`flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden`,t[70]!==n||t[71]!==i||t[72]!==r?(oe=n?(0,$.jsx)(`div`,{className:`flex flex-wrap items-center gap-2 border-b border-border/70 px-1 pb-3`,children:xc.map(e=>(0,$.jsx)(Y,{size:`sm`,variant:r===e.mode?`default`:`outline`,onClick:()=>i(e.mode),children:e.label},e.mode))}):null,t[70]=n,t[71]=i,t[72]=r,t[73]=oe):oe=t[73],V=xn,ne=!1,G=!0,K=T?.id??void 0,t[74]!==_||t[75]!==d.nodeById?(re=e=>{!e||e===_||d.nodeById.has(e)&&C.current&&v(e)},t[74]=_,t[75]=d.nodeById,t[76]=re):re=t[76],t[77]!==T||t[78]!==D||t[79]!==P||t[80]!==g||t[81]!==A||t[82]!==c||t[83]!==o?(q=e=>{let t=e.key.toLowerCase();if(e.shiftKey&&!e.ctrlKey&&!e.metaKey&&!e.altKey&&t===`l`&&T&&!o&&!c){e.preventDefault(),e.stopPropagation(),g(T.id);return}if(!e.shiftKey&&!e.ctrlKey&&!e.metaKey&&!e.altKey){if(e.key===`ArrowUp`||e.key===`ArrowDown`){e.preventDefault(),e.stopPropagation(),D(e.key===`ArrowDown`?1:-1);return}if(e.key===`ArrowLeft`||e.key===`ArrowRight`){e.preventDefault(),e.stopPropagation(),P(e.key===`ArrowRight`?1:-1,`full`);return}}if(Sn(e.nativeEvent,`Control+ArrowLeft`)||Sn(e.nativeEvent,`Control+ArrowRight`)){e.preventDefault(),e.stopPropagation(),A(e.key===`ArrowRight`);return}},t[77]=T,t[78]=D,t[79]=P,t[80]=g,t[81]=A,t[82]=c,t[83]=o,t[84]=q):q=t[84],ie=`min-h-0 w-full max-w-full min-w-0 flex-1`,t[85]!==u||t[86]!==l?(J=(0,$.jsx)(Qt,{ref:y,value:l,onValueChange:u,placeholder:`Search tree`,className:`text-base md:text-sm`}),t[85]=u,t[86]=l,t[87]=J):J=t[87],B=Mn,H=b,W=`max-h-none min-h-0 flex-1 md:max-h-[min(calc(80vh_-_9rem),32rem)]`,ee=t=>{e(t.movementX,t.movementY)},te=a?(0,$.jsxs)(`div`,{className:`flex items-center gap-2 p-4 text-sm text-muted-foreground`,children:[(0,$.jsx)(wt,{}),` Loading tree…`]}):d.orderedVisibleNodes.length>0?d.orderedVisibleNodes.map(t=>(0,$.jsx)(U,{title:Vc(t),children:(0,$.jsxs)(On,{value:t.id,disabled:o||t.id===s,onMouseEnter:()=>{C.current&&x(t.id)},onMouseMove:n=>{!C.current&&!e(n.movementX,n.movementY)||x(t.id)},onClick:()=>h(t.id),onSelect:()=>h(t.id),ref:e=>{e?S.current.set(t.id,e):S.current.delete(t.id)},className:`h-6 min-w-0 items-stretch gap-2 overflow-hidden px-2 py-0`,children:[(0,$.jsxs)(`div`,{className:`flex shrink-0 items-stretch gap-1 text-muted-foreground`,children:[(0,$.jsx)(Bc,{node:t,viewModel:d}),(0,$.jsx)(`span`,{className:`flex h-6 w-2.5 items-center justify-center`,children:t.streaming||t.id===c?(0,$.jsx)(wt,{size:`xs`,className:`text-[var(--success)]`,"aria-label":`Streaming`}):t.isActivePath?(0,$.jsx)(zc,{name:`active-path`,className:E(t.isActivePath?`text-[var(--success)]`:`text-muted-foreground`)}):null})]}),(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-1.5 overflow-hidden`,children:[t.label?(0,$.jsxs)(`span`,{className:`inline-flex h-5 shrink-0 items-center rounded-full border border-border/90 bg-background/20 px-2 text-[11px] font-semibold text-muted-foreground`,children:[`[`,t.label,`]`]}):null,(0,$.jsx)(`div`,{className:`min-w-0 flex-1 overflow-hidden`,children:(0,$.jsx)(Hc,{node:t})})]})]})},t.id)):(0,$.jsx)(`div`,{className:`p-4 text-sm text-muted-foreground`,children:l.trim()?`No tree entries match the current search.`:`No tree entries match the current filter.`}),t[23]=O,t[24]=T,t[25]=f,t[26]=n,t[27]=p,t[28]=g,t[29]=h,t[30]=i,t[31]=u,t[32]=_,t[33]=r,t[34]=s,t[35]=a,t[36]=l,t[37]=c,t[38]=o,t[39]=d,t[40]=B,t[41]=V,t[42]=H,t[43]=W,t[44]=ee,t[45]=te,t[46]=ne,t[47]=G,t[48]=K,t[49]=re,t[50]=q,t[51]=ie,t[52]=J,t[53]=ae,t[54]=oe}else B=t[40],V=t[41],H=t[42],W=t[43],ee=t[44],te=t[45],ne=t[46],G=t[47],K=t[48],re=t[49],q=t[50],ie=t[51],J=t[52],ae=t[53],oe=t[54];let se;t[88]!==B||t[89]!==H||t[90]!==W||t[91]!==ee||t[92]!==te?(se=(0,$.jsx)(B,{ref:H,className:W,onPointerMoveCapture:ee,children:te}),t[88]=B,t[89]=H,t[90]=W,t[91]=ee,t[92]=te,t[93]=se):se=t[93];let ce;t[94]!==N||t[95]!==n||t[96]!==r||t[97]!==a||t[98]!==c||t[99]!==k?(ce=n?null:(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 border-t border-border/70 px-3 py-2 text-xs text-muted-foreground`,children:[(0,$.jsx)(`span`,{className:`tabular-nums`,children:a?`Loading tree…`:`${N}/${k}`}),(0,$.jsx)(wc,{kbd:`↑/↓`,children:`Move`}),(0,$.jsx)(wc,{kbd:`←/→`,children:`Page`}),(0,$.jsx)(wc,{kbd:`${Ir(`Control+ArrowLeft`)}/${Ir(`Control+ArrowRight`)}`,children:`Fold`}),xc.map(e=>(0,$.jsx)(wc,{kbd:Ir(e.shortcut),active:r===e.mode,children:e.label},e.mode)),c?null:(0,$.jsx)(wc,{kbd:`Shift+L`,children:`Label`}),(0,$.jsx)(wc,{kbd:`Esc`,children:`Close`})]}),t[94]=N,t[95]=n,t[96]=r,t[97]=a,t[98]=c,t[99]=k,t[100]=ce):ce=t[100];let le;t[101]!==V||t[102]!==ne||t[103]!==G||t[104]!==K||t[105]!==re||t[106]!==q||t[107]!==ie||t[108]!==J||t[109]!==se||t[110]!==ce?(le=(0,$.jsxs)(V,{shouldFilter:ne,loop:G,value:K,onValueChange:re,onKeyDownCapture:q,className:ie,children:[J,se,ce]}),t[101]=V,t[102]=ne,t[103]=G,t[104]=K,t[105]=re,t[106]=q,t[107]=ie,t[108]=J,t[109]=se,t[110]=ce,t[111]=le):le=t[111];let ue;return t[112]!==ae||t[113]!==oe||t[114]!==le?(ue=(0,$.jsxs)(`div`,{className:ae,children:[oe,le]}),t[112]=ae,t[113]=oe,t[114]=le,t[115]=ue):ue=t[115],ue}function Gc(e){let t=(0,Q.c)(74),{isMobile:n,canNavigateSelectedNode:r,treeSummaryAvailable:i,treeSubmitting:a,activeSessionStreaming:o,selectedTreeNodeId:s,onNavigateTreeNode:c,onCustomPrompt:l}=e,[u,d]=Z.useState(`No summary`),f=!r||a||o,p;t[0]===f?p=t[1]:(p={value:`No summary`,disabled:f},t[0]=f,t[1]=p);let m=!r||!i||a||o,h;t[2]===m?h=t[3]:(h={value:`Summarize`,disabled:m},t[2]=m,t[3]=h);let g=!r||!i||a||o,_;t[4]===g?_=t[5]:(_={value:`Summarize with custom prompt`,disabled:g},t[4]=g,t[5]=_);let v;t[6]!==p||t[7]!==h||t[8]!==_?(v=[p,h,_],t[6]=p,t[7]=h,t[8]=_,t[9]=v):v=t[9];let y=v,b;t[10]===y?b=t[11]:(b=y.filter(Kc),t[10]=y,t[11]=b);let x=b,S,C;t[12]!==x||t[13]!==u?(C=()=>{x.length!==0&&(x.some(e=>e.value===u)||d(x[0]?.value??`No summary`))},S=[x,u],t[12]=x,t[13]=u,t[14]=S,t[15]=C):(S=t[14],C=t[15]),Z.useEffect(C,S);let w;t[16]!==x||t[17]!==u?(w=e=>{if(x.length===0)return;let t=x[(Math.max(0,x.findIndex(e=>e.value===u))+e+x.length)%x.length];t&&d(t.value)},t[16]=x,t[17]=u,t[18]=w):w=t[18];let T=w,E;t[19]!==y||t[20]!==l||t[21]!==c||t[22]!==u||t[23]!==s?(E=()=>{if(!s)return;let e=y.find(e=>e.value===u);if(!(!e||e.disabled)){if(u===`Summarize with custom prompt`){l();return}c(s,u===`Summarize`?{summarize:!0}:void 0)}},t[19]=y,t[20]=l,t[21]=c,t[22]=u,t[23]=s,t[24]=E):E=t[24];let D=E,O;t[25]!==T||t[26]!==D?(O=()=>{let e=e=>{let t=Sn(e,`Control+J`)||!e.metaKey&&!e.ctrlKey&&!e.altKey&&!e.shiftKey&&e.key===`ArrowDown`,n=Sn(e,`Control+K`)||!e.metaKey&&!e.ctrlKey&&!e.altKey&&!e.shiftKey&&e.key===`ArrowUp`;if(t||n){e.preventDefault(),e.stopPropagation(),T(t?1:-1);return}e.key===`Enter`&&!e.metaKey&&!e.altKey&&!e.ctrlKey&&!e.shiftKey&&(e.preventDefault(),e.stopPropagation(),D())};return window.addEventListener(`keydown`,e,!0),()=>{window.removeEventListener(`keydown`,e,!0)}},t[25]=T,t[26]=D,t[27]=O):O=t[27];let k;t[28]!==o||t[29]!==r||t[30]!==x||t[31]!==l||t[32]!==c||t[33]!==u||t[34]!==s||t[35]!==a||t[36]!==i?(k=[o,r,x,l,c,u,s,a,i],t[28]=o,t[29]=r,t[30]=x,t[31]=l,t[32]=c,t[33]=u,t[34]=s,t[35]=a,t[36]=i,t[37]=k):k=t[37],Z.useEffect(O,k);let A;t[38]===y?A=t[39]:(A=e=>{y.some(t=>t.value===e)&&d(e)},t[38]=y,t[39]=A);let j;t[40]===T?j=t[41]:(j=e=>{!e.metaKey&&!e.altKey&&!e.shiftKey&&!e.ctrlKey&&(e.key===`ArrowDown`||e.key===`ArrowUp`)&&(e.preventDefault(),e.stopPropagation(),T(e.key===`ArrowDown`?1:-1))},t[40]=T,t[41]=j);let M=!r||a||o,N;t[42]!==c||t[43]!==s?(N=()=>{s&&c(s)},t[42]=c,t[43]=s,t[44]=N):N=t[44];let P;t[45]===Symbol.for(`react.memo_cache_sentinel`)?(P=(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,$.jsx)(`span`,{className:`font-medium`,children:`No summary`}),(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Continue from this point immediately.`})]}),t[45]=P):P=t[45];let F;t[46]!==M||t[47]!==N?(F=(0,$.jsx)(On,{value:`No summary`,disabled:M,onSelect:N,children:P}),t[46]=M,t[47]=N,t[48]=F):F=t[48];let I=!r||!i||a||o,L;t[49]!==c||t[50]!==s?(L=()=>{s&&c(s,{summarize:!0})},t[49]=c,t[50]=s,t[51]=L):L=t[51];let R;t[52]===Symbol.for(`react.memo_cache_sentinel`)?(R=(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,$.jsx)(`span`,{className:`font-medium`,children:`Summarize`}),(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Summarize the branch you are leaving first.`})]}),t[52]=R):R=t[52];let z;t[53]!==I||t[54]!==L?(z=(0,$.jsx)(On,{value:`Summarize`,disabled:I,onSelect:L,children:R}),t[53]=I,t[54]=L,t[55]=z):z=t[55];let B=!r||!i||a||o,V;t[56]===Symbol.for(`react.memo_cache_sentinel`)?(V=(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,$.jsx)(`span`,{className:`font-medium`,children:`Summarize with custom prompt`}),(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Add extra instructions before continuing.`})]}),t[56]=V):V=t[56];let H;t[57]!==l||t[58]!==B?(H=(0,$.jsx)(On,{value:`Summarize with custom prompt`,disabled:B,onSelect:l,children:V}),t[57]=l,t[58]=B,t[59]=H):H=t[59];let U;t[60]!==F||t[61]!==z||t[62]!==H?(U=(0,$.jsx)(Mn,{className:`max-h-none min-h-0 flex-1 md:max-h-[min(calc(80vh_-_7rem),32rem)]`,children:(0,$.jsxs)(An,{children:[F,z,H]})}),t[60]=F,t[61]=z,t[62]=H,t[63]=U):U=t[63];let W;t[64]!==o||t[65]!==n||t[66]!==i?(W=n?null:(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 border-t border-border/70 px-3 py-2 text-xs text-muted-foreground`,children:[(0,$.jsx)(wc,{kbd:`↑/↓`,children:`Move`}),(0,$.jsx)(wc,{kbd:`Enter`,children:`Select`}),(0,$.jsx)(wc,{kbd:`Esc`,children:`Back`}),o?(0,$.jsx)(`span`,{children:`Summary actions require the response to finish.`}):i?null:(0,$.jsx)(`span`,{children:`Summary actions require a selected model.`})]}),t[64]=o,t[65]=n,t[66]=i,t[67]=W):W=t[67];let ee;return t[68]!==u||t[69]!==A||t[70]!==j||t[71]!==U||t[72]!==W?(ee=(0,$.jsxs)(xn,{loop:!0,value:u,onValueChange:A,onKeyDownCapture:j,className:`min-h-0 flex-1`,children:[U,W]}),t[68]=u,t[69]=A,t[70]=j,t[71]=U,t[72]=W,t[73]=ee):ee=t[73],ee}function Kc(e){return!e.disabled}function qc(e){let t=(0,Q.c)(11),{isMobile:n,defaultLabel:r,disabled:i,onSave:a}=e,o=Z.useRef(null),s;t[0]===a?s=t[1]:(s=e=>{e.key===`Enter`&&(e.preventDefault(),a(e.currentTarget.value))},t[0]=a,t[1]=s);let c;t[2]!==r||t[3]!==i||t[4]!==s?(c=(0,$.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center p-3`,children:(0,$.jsx)(xr,{ref:o,defaultValue:r,placeholder:`Optional label (empty to remove)`,disabled:i,onKeyDown:s,className:`min-w-0 flex-1`},r)}),t[2]=r,t[3]=i,t[4]=s,t[5]=c):c=t[5];let l;t[6]===n?l=t[7]:(l=n?null:(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 border-t border-border/70 px-3 py-2 text-xs text-muted-foreground`,children:[(0,$.jsx)(wc,{kbd:`Enter`,children:`Save`}),(0,$.jsx)(wc,{kbd:`Esc`,children:`Back`})]}),t[6]=n,t[7]=l);let u;return t[8]!==c||t[9]!==l?(u=(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[c,l]}),t[8]=c,t[9]=l,t[10]=u):u=t[10],u}var Jc={filterMode:`no-tools`,stage:`browse`,foldedNodeIds:new Set};function Yc(e,t){switch(t.type){case`opened`:return{filterMode:`no-tools`,stage:`browse`,foldedNodeIds:new Set};case`filterModeChanged`:return e.filterMode===t.filterMode?e:{...e,filterMode:t.filterMode,foldedNodeIds:new Set};case`filterModeToggled`:{let n=Sc(e.filterMode,t.filterMode);return e.filterMode===n?e:{...e,filterMode:n,foldedNodeIds:new Set}}case`foldedNodeIdsChanged`:return e.foldedNodeIds===t.foldedNodeIds?e:{...e,foldedNodeIds:t.foldedNodeIds};case`foldsReset`:return e.foldedNodeIds.size===0?e:{...e,foldedNodeIds:new Set};case`stageChanged`:return e.stage===t.stage?e:{...e,stage:t.stage};case`nodeSelected`:return e.stage===t.stage?e:{...e,stage:t.stage};case`selectedNodeMissing`:return e.stage===`browse`?e:{...e,stage:`browse`};case`abortCompleted`:return e.stage===`abort`?{...e,stage:`actions`}:e;case`backRequested`:return{...e,stage:e.stage===`custom`?`actions`:`browse`};default:return e}}function Xc(e){return Zc(e)}function Zc(e){let t=(0,Q.c)(77),{open:n,onOpenChange:r,treeLoading:i,treeSubmitting:a,treeAborting:o,treeLeafId:s,treeStreamingEntryId:c,treeSummaryAvailable:l,treeQuery:u,onTreeQueryChange:d,flatTree:f,selectedTreeNodeId:p,onSelectedTreeNodeIdChange:m,selectedTreeNodeLabel:h,onSelectedTreeNodeLabelChange:g,onNavigateTreeNode:_,onAbortStreamingSession:v,onSaveTreeLabel:y}=e,[b,x]=Z.useReducer(Yc,Jc),{filterMode:S,stage:C,foldedNodeIds:w}=b,T=Z.useRef(null),E=Z.useRef(!1),D=Z.useRef(u),O=ar(),k;t[0]!==f||t[1]!==w||t[2]!==S||t[3]!==s||t[4]!==u?(k=Fc({flatTree:f,currentLeafId:s,query:u,filterMode:S,foldedEntryIds:w}),t[0]=f,t[1]=w,t[2]=S,t[3]=s,t[4]=u,t[5]=k):k=t[5];let A=k,j=p==null?null:A.nodeById.get(p)??null,M=!!c,N;t[6]===n?N=t[7]:(N=()=>{let e=E.current;E.current=n,!(!n||e)&&x({type:`opened`})},t[6]=n,t[7]=N);let F;t[8]!==n||t[9]!==p||t[10]!==s?(F=[n,p,s],t[8]=n,t[9]=p,t[10]=s,t[11]=F):F=t[11],Z.useEffect(N,F);let I,L;t[12]===u?(I=t[13],L=t[14]):(I=()=>{let e=D.current;D.current=u,e!==u&&x({type:`foldsReset`})},L=[u],t[12]=u,t[13]=I,t[14]=L),Z.useEffect(I,L),Z.useEffect(()=>{n&&C!==`browse`&&!j&&x({type:`selectedNodeMissing`})},[n,j,C]);let R=Z.useEffectEvent(_),z;t[15]!==M||t[16]!==R||t[17]!==n||t[18]!==p||t[19]!==s||t[20]!==C||t[21]!==a?(z=()=>{if(!n)return;let e=e=>{let t=e.key.toLowerCase();if(C===`browse`){let n={d:`default`,t:`no-tools`,u:`user-only`,l:`labeled-only`,a:`all`}[t];if(n&&Sn(e,`Control+${t.toUpperCase()}`)){e.preventDefault(),e.stopPropagation(),x({type:`filterModeToggled`,filterMode:n});return}}if(e.key!==`Escape`){C===`custom`&&Sn(e,`Control+Enter`)&&p&&p!==s&&!a&&!M&&(e.preventDefault(),e.stopPropagation(),R(p,{summarize:!0,customInstructions:T.current?.value??``}));return}if(C===`custom`||C===`label`){e.preventDefault(),e.stopPropagation(),x({type:`backRequested`});return}C===`actions`&&(e.preventDefault(),e.stopPropagation(),x({type:`stageChanged`,stage:`browse`}))};return window.addEventListener(`keydown`,e,!0),()=>{window.removeEventListener(`keydown`,e,!0)}},t[15]=M,t[16]=R,t[17]=n,t[18]=p,t[19]=s,t[20]=C,t[21]=a,t[22]=z):z=t[22];let B;t[23]!==M||t[24]!==n||t[25]!==p||t[26]!==S||t[27]!==s||t[28]!==C||t[29]!==a?(B=[n,p,S,s,C,M,a],t[23]=M,t[24]=n,t[25]=p,t[26]=S,t[27]=s,t[28]=C,t[29]=a,t[30]=B):B=t[30],Z.useEffect(z,B);let V,H;t[31]!==n||t[32]!==C?(V=()=>{if(!n||C!==`custom`)return;let e=window.requestAnimationFrame(()=>{T.current?.focus()});return()=>{window.cancelAnimationFrame(e)}},H=[n,C],t[31]=n,t[32]=C,t[33]=V,t[34]=H):(V=t[33],H=t[34]),Z.useEffect(V,H);let U,W;t[35]!==M||t[36]!==n||t[37]!==C?(U=()=>{!n||C!==`abort`||M||x({type:`abortCompleted`})},W=[M,n,C],t[35]=M,t[36]=n,t[37]=C,t[38]=U,t[39]=W):(U=t[38],W=t[39]),Z.useEffect(U,W);let ee;t[40]!==M||t[41]!==m||t[42]!==g||t[43]!==A.nodeById?(ee=e=>{let t=A.nodeById.get(e);t&&(m(e),g(t.label||``),x({type:`nodeSelected`,stage:M?`abort`:`actions`}))},t[40]=M,t[41]=m,t[42]=g,t[43]=A.nodeById,t[44]=ee):ee=t[44];let te=ee,ne;t[45]!==M||t[46]!==m||t[47]!==g||t[48]!==A.nodeById?(ne=e=>{if(M)return;let t=A.nodeById.get(e);t&&(m(e),g(t.label||``),x({type:`stageChanged`,stage:`label`}))},t[45]=M,t[46]=m,t[47]=g,t[48]=A.nodeById,t[49]=ne):ne=t[49];let G=ne,K=!!(p&&p!==s&&j),re;t[50]!==M||t[51]!==_||t[52]!==p?(re=()=>{!p||M||_(p,{summarize:!0,customInstructions:T.current?.value??``})},t[50]=M,t[51]=_,t[52]=p,t[53]=re):re=t[53];let q=re,ie=C===`custom`?`Summarize with custom prompt`:C===`label`?`Label selected node`:C===`abort`?`Abort response?`:C===`actions`?`Summarize branch?`:`Session tree`,J=C===`browse`?`Browse branches, search the tree, and continue from an older point.`:C===`custom`?`Add summary instructions before continuing from the selected node.`:C===`label`?`Add or update the selected node label.`:C===`abort`?`Abort the current response before continuing from this point.`:`Choose how to continue from the selected node.`,ae=C===`browse`?(0,$.jsx)(Uc,{isMobile:O,treeFilterMode:S,onTreeFilterModeChange:e=>{x({type:`filterModeChanged`,filterMode:e})},treeLoading:i,treeSubmitting:a,treeLeafId:s,treeStreamingEntryId:c,treeQuery:u,onTreeQueryChange:d,treeViewModel:A,foldedTreeNodeIds:w,onFoldedTreeNodeIdsChange:e=>{x({type:`foldedNodeIdsChanged`,foldedNodeIds:e})},selectedTreeNodeId:p,onSelectTreeNode:te,onLabelTreeNode:G},n?`open`:`closed`):j?(0,$.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border/70 px-3 py-2`,children:[(0,$.jsx)(Y,{size:`icon-sm`,variant:`ghost`,onClick:()=>{x({type:`backRequested`})},disabled:a||o,"aria-label":C===`custom`?`Back`:`Back to tree`,children:(0,$.jsx)(P,{})}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`div`,{className:`truncate text-sm font-medium`,children:C===`custom`?`Summarize with custom prompt`:C===`label`?`Label selected node`:C===`abort`?`Abort response?`:`Summarize branch?`}),(0,$.jsx)(`div`,{className:`truncate text-xs text-muted-foreground`,children:Vc(j)})]})]}),C===`actions`?(0,$.jsx)(Gc,{isMobile:O,canNavigateSelectedNode:K,treeSummaryAvailable:l,treeSubmitting:a,activeSessionStreaming:M,selectedTreeNodeId:p,onNavigateTreeNode:_,onCustomPrompt:()=>{x({type:`stageChanged`,stage:`custom`})}}):C===`abort`?(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-3 p-3 text-sm`,children:[(0,$.jsx)(`div`,{className:`rounded-lg border border-border/70 bg-muted/30 p-3 text-muted-foreground`,children:`Tree navigation changes the active branch. Abort the current response before continuing from the selected point.`}),(0,$.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`The streaming node is marked with the spinner in the tree.`})]}),(0,$.jsxs)(`div`,{className:`flex flex-col-reverse gap-2 border-t border-border/70 p-3 sm:flex-row sm:justify-end`,children:[(0,$.jsx)(Y,{variant:`outline`,onClick:()=>{x({type:`stageChanged`,stage:`browse`})},disabled:o,children:`Back`}),(0,$.jsxs)(Y,{variant:`destructive`,disabled:o||!M,onClick:()=>{Promise.resolve(v()).then(()=>{x({type:`stageChanged`,stage:`actions`})}).catch(Qc)},children:[o?(0,$.jsx)(wt,{}):null,`Abort response`]})]})]}):C===`label`?(0,$.jsx)(qc,{isMobile:O,defaultLabel:h,disabled:!p||a||M,onSave:e=>{g(e),Promise.resolve(y(e)).then(()=>{x({type:`stageChanged`,stage:`browse`})})}}):(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,$.jsx)(`div`,{className:`flex min-h-0 flex-1 p-3`,children:(0,$.jsx)(on,{ref:T,placeholder:`Add summary instructions before continuing`,className:`min-h-32 resize-none`,disabled:!K||a||M})}),O?(0,$.jsxs)(`div`,{className:`flex flex-col-reverse gap-2 border-t border-border/70 p-3 sm:flex-row sm:justify-end`,children:[(0,$.jsx)(Y,{variant:`outline`,onClick:()=>{x({type:`stageChanged`,stage:`actions`})},disabled:a,children:`Back`}),(0,$.jsxs)(Y,{disabled:!K||a||M,onClick:q,children:[a?(0,$.jsx)(wt,{}):null,`Summarize & continue`]})]}):(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 border-t border-border/70 px-3 py-2 text-xs text-muted-foreground`,children:[(0,$.jsx)(wc,{kbd:Ir(`Control+Enter`),children:`Summarize`}),(0,$.jsx)(wc,{kbd:`Esc`,children:`Back`})]})]})]}):(0,$.jsx)(`div`,{className:`rounded-lg border border-dashed p-4 text-sm text-muted-foreground`,children:`Select a tree node first.`});if(O){let e=C===`browse`?void 0:`sr-only`,i;t[54]===ie?i=t[55]:(i=(0,$.jsx)(ln,{children:ie}),t[54]=ie,t[55]=i);let a;t[56]===J?a=t[57]:(a=(0,$.jsx)(_n,{children:J}),t[56]=J,t[57]=a);let o;t[58]!==e||t[59]!==i||t[60]!==a?(o=(0,$.jsxs)(tn,{className:e,children:[i,a]}),t[58]=e,t[59]=i,t[60]=a,t[61]=o):o=t[61];let s;t[62]===ae?s=t[63]:(s=(0,$.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden px-4 pb-4`,children:ae}),t[62]=ae,t[63]=s);let c;t[64]!==o||t[65]!==s?(c=(0,$.jsxs)(pn,{className:`max-h-[90svh] overflow-hidden`,children:[o,s]}),t[64]=o,t[65]=s,t[66]=c):c=t[66];let l;return t[67]!==r||t[68]!==n||t[69]!==c?(l=(0,$.jsx)(dn,{open:n,onOpenChange:r,autoFocus:!1,children:c}),t[67]=r,t[68]=n,t[69]=c,t[70]=l):l=t[70],l}let oe;return t[71]!==r||t[72]!==n||t[73]!==ae||t[74]!==J||t[75]!==ie?(oe=(0,$.jsx)(Vr,{open:n,onOpenChange:r,title:ie,description:J,className:`flex! flex-col sm:max-w-2xl`,initialFocus:!0,children:ae}),t[71]=r,t[72]=n,t[73]=ae,t[74]=J,t[75]=ie,t[76]=oe):oe=t[76],oe}function Qc(){}function $c({ref:e,openStateRef:t,viewerContextId:n,sessionScopeKey:r,sessionId:i,treeSummaryAvailable:a,activeSessionStreaming:o}){let[s,c]=Z.useState(!1),[l,u]=Z.useState(``),[d,f]=Z.useState(null),[p,m]=Z.useState(``),h=Z.useRef(s),g=ki(),_=vi.sessionTree(n,r),v=e=>{h.current=e,t&&(t.current=e),c(e)},y=nn({queryKey:_,queryFn:()=>oi(hi(`/api/session/tree`,{contextId:n,sessionId:i})),staleTime:0,gcTime:1e3*60*10,enabled:!!(n&&s&&r)}),b=an({mutationFn:async({entryId:e,label:t})=>{if(!n)throw Error(`Viewer context unavailable`);return await oi(hi(`/api/session/tree/label`,{contextId:n,sessionId:i}),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({entryId:e,label:t})})},onSuccess:e=>{g.setQueryData(_,e)}}),x=an({mutationFn:async()=>{if(!n)throw Error(`Viewer context unavailable`);return await oi(hi(`/api/abort`,{contextId:n,sessionId:i}),{method:`POST`})},onSuccess:async()=>{await g.invalidateQueries({queryKey:_,exact:!0,refetchType:`active`})}}),S=an({mutationFn:async({targetId:e,summarize:t,customInstructions:r})=>{if(!n)throw Error(`Viewer context unavailable`);return await oi(hi(`/api/session/tree`,{contextId:n,sessionId:i}),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({targetId:e,summarize:!!t,customInstructions:r})})},onSuccess:()=>{g.invalidateQueries({queryKey:_,exact:!0,refetchType:`active`})}}),C=async()=>{n&&(u(``),v(!0),await g.invalidateQueries({queryKey:_,exact:!0,refetchType:`active`}))},w=async(e=p)=>{if(!(!n||!d)){m(e);try{await b.mutateAsync({entryId:d,label:e})}catch(e){X.error(e instanceof Error?e.message:`Failed to save label`)}}},T=async(e,t)=>{if(n){v(!1);try{let n=await S.mutateAsync({targetId:e,summarize:t?.summarize,customInstructions:t?.customInstructions});if(n.aborted){X.info(`Branch summarization cancelled`);return}if(n.cancelled){X.info(`Tree navigation cancelled`);return}X.success(t?.summarize?`Continued from summarized branch`:`Moved session tree cursor`)}catch(e){X.error(e instanceof Error?e.message:`Failed to navigate tree`)}}},E=async()=>{if(n)try{await x.mutateAsync(),X.info(`Response aborted`)}catch(e){throw X.error(e instanceof Error?e.message:`Failed to abort response`),e}};Z.useEffect(()=>{!s||!y.error||X.error(y.error instanceof Error?y.error.message:`Failed to load tree`)},[s,y.error,y.errorUpdatedAt]);let D=y.data??null,O=D?at(D.tree):[],k=D?.leafId??null,A=D&&`streamingEntryId`in D?D.streamingEntryId??null:o?k:null;Z.useEffect(()=>{if(!s||!D)return;let e=at(D.tree),t=(d?e.find(e=>e.id===d):void 0)??e.find(e=>e.id===D.leafId),n=t?.id??D.leafId;f(e=>e===n?e:n),m(t?.label||``)},[d,D,s]),Z.useImperativeHandle(e,()=>({open:C,close:()=>{v(!1)},isOpen:()=>h.current}),[_,n]);let j=!!(y.isPending&&!y.data),M=b.isPending||S.isPending,N=x.isPending;return(0,$.jsx)(Xc,{open:s,onOpenChange:v,treeLoading:j,treeSubmitting:M,treeAborting:N,treeLeafId:k,treeStreamingEntryId:A,treeSummaryAvailable:a,treeQuery:l,onTreeQueryChange:u,flatTree:O,selectedTreeNodeId:d,onSelectedTreeNodeIdChange:f,selectedTreeNodeLabel:p,onSelectedTreeNodeLabelChange:m,onNavigateTreeNode:(e,t)=>{T(e,t)},onAbortStreamingSession:E,onSaveTreeLabel:e=>w(e)})}function el(e){return typeof e==`string`?e:e.value}function tl(e){return typeof e==`string`?e:e.label||e.value}function nl(e){let t=(0,Q.c)(22),{open:n,isMobile:r,title:i,description:a,children:o,onOpenChange:s}=e;if(r){let e;t[0]===i?e=t[1]:(e=(0,$.jsx)(ln,{children:i}),t[0]=i,t[1]=e);let r;t[2]===a?r=t[3]:(r=(0,$.jsx)(_n,{children:a}),t[2]=a,t[3]=r);let c;t[4]!==e||t[5]!==r?(c=(0,$.jsxs)(tn,{children:[e,r]}),t[4]=e,t[5]=r,t[6]=c):c=t[6];let l;t[7]===o?l=t[8]:(l=(0,$.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden px-4 pb-4`,children:o}),t[7]=o,t[8]=l);let u;t[9]!==c||t[10]!==l?(u=(0,$.jsxs)(pn,{className:`max-h-[90svh] overflow-hidden`,children:[c,l]}),t[9]=c,t[10]=l,t[11]=u):u=t[11];let d;return t[12]!==s||t[13]!==n||t[14]!==u?(d=(0,$.jsx)(dn,{open:n,onOpenChange:s,autoFocus:!1,children:u}),t[12]=s,t[13]=n,t[14]=u,t[15]=d):d=t[15],d}let c;return t[16]!==o||t[17]!==a||t[18]!==s||t[19]!==n||t[20]!==i?(c=(0,$.jsx)(Vr,{open:n,onOpenChange:s,title:i,description:a,className:`sm:max-w-xl`,initialFocus:!0,children:o}),t[16]=o,t[17]=a,t[18]=s,t[19]=n,t[20]=i,t[21]=c):c=t[21],c}function rl(e){let t=(0,Q.c)(25),{isMobile:n,pendingUiValue:i,onPendingUiValueChange:a,onBack:o,onSubmit:s}=e,c;t[0]!==s||t[1]!==i?(c=()=>{i.trim()&&s()},t[0]=s,t[1]=i,t[2]=c):c=t[2];let l;t[3]===o?l=t[4]:(l=e=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),o())},t[3]=o,t[4]=l);let u;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,$.jsx)(P,{}),t[5]=u):u=t[5];let d;t[6]===o?d=t[7]:(d=(0,$.jsx)(Y,{type:`button`,variant:`ghost`,size:`icon-sm`,onClick:o,"aria-label":`Back to login actions`,children:u}),t[6]=o,t[7]=d);let f;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`div`,{className:`truncate text-sm font-medium`,children:`Paste redirect URL`}),(0,$.jsx)(`div`,{className:`truncate text-xs text-muted-foreground`,children:`Fallback only: paste the full localhost callback URL.`})]}),t[8]=f):f=t[8];let p;t[9]===d?p=t[10]:(p=(0,$.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border/70 px-3 py-2`,children:[d,f]}),t[9]=d,t[10]=p);let m;t[11]===a?m=t[12]:(m=e=>a(e.target.value),t[11]=a,t[12]=m);let h;t[13]!==i||t[14]!==m?(h=(0,$.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center p-3`,children:(0,$.jsx)(xr,{value:i,onChange:m,placeholder:`Final redirected URL`,className:`min-w-0 flex-1`})}),t[13]=i,t[14]=m,t[15]=h):h=t[15];let g;t[16]!==n||t[17]!==i?(g=n?(0,$.jsx)(`div`,{className:`border-t border-border/70 p-3`,children:(0,$.jsx)(Y,{type:`submit`,className:`w-full`,disabled:!i.trim(),children:`Submit URL`})}):(0,$.jsxs)(`div`,{className:`hidden flex-wrap items-center gap-x-3 gap-y-1 border-t border-border/70 px-3 py-2 text-xs text-muted-foreground md:flex`,children:[(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,$.jsx)(r,{children:`Enter`}),`Submit URL`]}),(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,$.jsx)(r,{children:`Esc`}),`Back`]})]}),t[16]=n,t[17]=i,t[18]=g):g=t[18];let _;return t[19]!==c||t[20]!==l||t[21]!==p||t[22]!==h||t[23]!==g?(_=(0,$.jsxs)(`form`,{className:`flex min-h-0 flex-1 flex-col`,action:c,onKeyDown:l,children:[p,h,g]}),t[19]=c,t[20]=l,t[21]=p,t[22]=h,t[23]=g,t[24]=_):_=t[24],_}function il(e){let t=(0,Q.c)(2),{children:n}=e,r;return t[0]===n?r=t[1]:(r=(0,$.jsx)(`div`,{className:`hidden border-t border-border/70 px-3 py-2 text-xs text-muted-foreground md:block`,children:n}),t[0]=n,t[1]=r),r}function al(e){let t=(0,Q.c)(2),{onCancel:n}=e,r;return t[0]===n?r=t[1]:(r=(0,$.jsx)(`div`,{className:`border-t border-border/70 p-3`,children:(0,$.jsx)(Y,{type:`button`,variant:`outline`,className:`w-full`,onClick:n,children:`Cancel login`})}),t[0]=n,t[1]=r),r}function ol(e){let t=(0,Q.c)(28),{request:n,isMobile:r,onManualMode:i,onCancel:a}=e,o;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,$.jsx)(Qt,{placeholder:`Choose login action`,className:`text-base md:text-sm`}),t[0]=o):o=t[0];let s=n.title||`Provider login`,c;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(c=[`open`,`browser`,`login`,`page`],t[1]=c):c=t[1];let l;t[2]===n.authUrl?l=t[3]:(l=()=>{window.open(n.authUrl,`_blank`,`noopener,noreferrer`)},t[2]=n.authUrl,t[3]=l);let u,d;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,$.jsx)(`span`,{className:`truncate font-medium`,children:`Open login page`}),(0,$.jsx)(`span`,{className:`line-clamp-2 text-xs text-muted-foreground`,children:`Continue OAuth in your browser. Keep Pico open while the provider redirects back.`})]}),d=(0,$.jsx)(Xt,{className:`inline shrink-0 tracking-normal normal-case`,children:`Enter`}),t[4]=u,t[5]=d):(u=t[4],d=t[5]);let f;t[6]===l?f=t[7]:(f=(0,$.jsxs)(On,{value:`open-login-page`,keywords:c,onSelect:l,children:[u,d]}),t[6]=l,t[7]=f);let p;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(p=[`copy`,`link`,`url`,`login`],t[8]=p):p=t[8];let m;t[9]===n.authUrl?m=t[10]:(m=()=>{navigator.clipboard.writeText(n.authUrl),X.success(`Login link copied`)},t[9]=n.authUrl,t[10]=m);let h;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,$.jsx)(`span`,{className:`truncate font-medium`,children:`Copy login link`}),(0,$.jsx)(`span`,{className:`line-clamp-2 text-xs text-muted-foreground`,children:`Copy the browser login link without showing the full URL.`})]}),t[11]=h):h=t[11];let g;t[12]===m?g=t[13]:(g=(0,$.jsx)(On,{value:`copy-login-link`,keywords:p,onSelect:m,children:h}),t[12]=m,t[13]=g);let _;t[14]!==i||t[15]!==n.authManualAllowed?(_=n.authManualAllowed?(0,$.jsx)(On,{value:`paste-redirect-url`,keywords:[`paste`,`redirect`,`manual`,`fallback`],onSelect:i,children:(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,$.jsx)(`span`,{className:`truncate font-medium`,children:`Paste redirect URL manually`}),(0,$.jsx)(`span`,{className:`line-clamp-2 text-xs text-muted-foreground`,children:`Fallback only: use this if the browser reaches a localhost callback URL but cannot connect.`})]})}):null,t[14]=i,t[15]=n.authManualAllowed,t[16]=_):_=t[16];let v;t[17]!==g||t[18]!==_||t[19]!==s||t[20]!==f?(v=(0,$.jsx)(Mn,{children:(0,$.jsxs)(An,{heading:s,children:[f,g,_]})}),t[17]=g,t[18]=_,t[19]=s,t[20]=f,t[21]=v):v=t[21];let y;t[22]!==r||t[23]!==a?(y=r?(0,$.jsx)(al,{onCancel:a}):(0,$.jsx)(il,{children:`Use ↑/↓ to select, Enter to run an action, and Esc to go back.`}),t[22]=r,t[23]=a,t[24]=y):y=t[24];let b;return t[25]!==v||t[26]!==y?(b=(0,$.jsxs)(xn,{loop:!0,shouldFilter:!0,children:[o,v,y]}),t[25]=v,t[26]=y,t[27]=b):b=t[27],b}function sl(e){let t=(0,Q.c)(17),{request:n,isMobile:r,onCancel:i,onResolveUiRequest:a}=e,o;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,$.jsx)(Qt,{placeholder:`Choose login option`,className:`text-base md:text-sm`}),t[0]=o):o=t[0];let s=n.message||`Login options`,c;t[1]===n.options?c=t[2]:(c=n.options??[],t[1]=n.options,t[2]=c);let l;if(t[3]!==a||t[4]!==c){let e;t[6]===a?e=t[7]:(e=e=>{let t=el(e),n=tl(e);return(0,$.jsx)(On,{value:t,keywords:[n],onSelect:()=>a({value:t}),children:(0,$.jsx)(`span`,{className:`truncate font-medium`,children:n})},t)},t[6]=a,t[7]=e),l=c.map(e),t[3]=a,t[4]=c,t[5]=l}else l=t[5];let u;t[8]!==s||t[9]!==l?(u=(0,$.jsx)(Mn,{children:(0,$.jsx)(An,{heading:s,children:l})}),t[8]=s,t[9]=l,t[10]=u):u=t[10];let d;t[11]!==r||t[12]!==i?(d=r?(0,$.jsx)(al,{onCancel:i}):(0,$.jsx)(il,{children:`Use ↑/↓ to select, Enter to continue, and Esc to go back.`}),t[11]=r,t[12]=i,t[13]=d):d=t[13];let f;return t[14]!==u||t[15]!==d?(f=(0,$.jsxs)(xn,{loop:!0,shouldFilter:!0,children:[o,u,d]}),t[14]=u,t[15]=d,t[16]=f):f=t[16],f}function cl(e){let t=(0,Q.c)(36),{request:n,isMobile:i,pendingUiValue:a,onPendingUiValueChange:o,onCancel:s,onResolveUiRequest:c}=e,l=!!n.allowEmpty,u;t[0]!==l||t[1]!==c||t[2]!==a?(u=()=>{!l&&!a.trim()||c({value:a})},t[0]=l,t[1]=c,t[2]=a,t[3]=u):u=t[3];let d;t[4]===s?d=t[5]:(d=e=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),s())},t[4]=s,t[5]=d);let f;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,$.jsx)(P,{}),t[6]=f):f=t[6];let p;t[7]===s?p=t[8]:(p=(0,$.jsx)(Y,{type:`button`,variant:`ghost`,size:`icon-sm`,onClick:s,"aria-label":`Back to login providers`,children:f}),t[7]=s,t[8]=p);let m=n.title||`Log in to provider`,h;t[9]===m?h=t[10]:(h=(0,$.jsx)(`div`,{className:`truncate text-sm font-medium`,children:m}),t[9]=m,t[10]=h);let g=n.message||`Enter the requested login information.`,_;t[11]===g?_=t[12]:(_=(0,$.jsx)(`div`,{className:`truncate text-xs text-muted-foreground`,children:g}),t[11]=g,t[12]=_);let v;t[13]!==h||t[14]!==_?(v=(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[h,_]}),t[13]=h,t[14]=_,t[15]=v):v=t[15];let y;t[16]!==p||t[17]!==v?(y=(0,$.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border/70 px-3 py-2`,children:[p,v]}),t[16]=p,t[17]=v,t[18]=y):y=t[18];let b;t[19]===o?b=t[20]:(b=e=>o(e.target.value),t[19]=o,t[20]=b);let x;t[21]!==a||t[22]!==n.placeholder||t[23]!==b?(x=(0,$.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center p-3`,children:(0,$.jsx)(xr,{value:a,onChange:b,placeholder:n.placeholder,className:`min-w-0 flex-1`})}),t[21]=a,t[22]=n.placeholder,t[23]=b,t[24]=x):x=t[24];let S;t[25]!==l||t[26]!==i||t[27]!==s||t[28]!==a?(S=i?(0,$.jsxs)(`div`,{className:`space-y-2 border-t border-border/70 p-3`,children:[(0,$.jsx)(Y,{type:`submit`,className:`w-full`,disabled:!l&&!a.trim(),children:`Continue login`}),(0,$.jsx)(Y,{type:`button`,variant:`outline`,className:`w-full`,onClick:s,children:`Cancel login`})]}):(0,$.jsxs)(`div`,{className:`hidden flex-wrap items-center gap-x-3 gap-y-1 border-t border-border/70 px-3 py-2 text-xs text-muted-foreground md:flex`,children:[(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,$.jsx)(r,{children:`Enter`}),`Continue login`]}),(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,$.jsx)(r,{children:`Esc`}),`Back`]})]}),t[25]=l,t[26]=i,t[27]=s,t[28]=a,t[29]=S):S=t[29];let C;return t[30]!==u||t[31]!==y||t[32]!==x||t[33]!==S||t[34]!==d?(C=(0,$.jsxs)(`form`,{className:`flex min-h-0 flex-1 flex-col`,action:u,onKeyDown:d,children:[y,x,S]}),t[30]=u,t[31]=y,t[32]=x,t[33]=S,t[34]=d,t[35]=C):C=t[35],C}function ll(e){let t=(0,Q.c)(36),{pendingUiRequest:n,pendingUiValue:r,onPendingUiValueChange:i,onResolveUiRequest:a}=e,o=!!n,s;t[0]!==a||t[1]!==n?(s=e=>{!e&&n&&a({cancelled:!0})},t[0]=a,t[1]=n,t[2]=s):s=t[2];let c=n?.title||`Pico request`,l;t[3]===c?l=t[4]:(l=(0,$.jsx)(Xr,{children:c}),t[3]=c,t[4]=l);let u;t[5]===n?u=t[6]:(u=n?.message?(0,$.jsx)(wi,{children:n.message}):null,t[5]=n,t[6]=u);let d;t[7]!==l||t[8]!==u?(d=(0,$.jsxs)(Ci,{children:[l,u]}),t[7]=l,t[8]=u,t[9]=d):d=t[9];let f;t[10]!==i||t[11]!==a||t[12]!==n||t[13]!==r?(f=(0,$.jsx)(ul,{pendingUiRequest:n,pendingUiValue:r,onPendingUiValueChange:i,onResolveUiRequest:a}),t[10]=i,t[11]=a,t[12]=n,t[13]=r,t[14]=f):f=t[14];let p;t[15]===a?p=t[16]:(p=(0,$.jsx)(Y,{variant:`outline`,onClick:()=>a({cancelled:!0}),children:`Cancel`}),t[15]=a,t[16]=p);let m;t[17]!==a||t[18]!==n?.method?(m=n?.method===`confirm`?(0,$.jsx)(Y,{onClick:()=>a({confirmed:!0}),children:`Confirm`}):null,t[17]=a,t[18]=n?.method,t[19]=m):m=t[19];let h;t[20]!==a||t[21]!==n?.method||t[22]!==r?(h=n?.method===`input`||n?.method===`editor`?(0,$.jsx)(Y,{onClick:()=>a({value:r}),children:`Submit response`}):null,t[20]=a,t[21]=n?.method,t[22]=r,t[23]=h):h=t[23];let g;t[24]!==h||t[25]!==p||t[26]!==m?(g=(0,$.jsxs)(ei,{children:[p,m,h]}),t[24]=h,t[25]=p,t[26]=m,t[27]=g):g=t[27];let _;t[28]!==g||t[29]!==d||t[30]!==f?(_=(0,$.jsxs)(xi,{children:[d,f,g]}),t[28]=g,t[29]=d,t[30]=f,t[31]=_):_=t[31];let v;return t[32]!==o||t[33]!==_||t[34]!==s?(v=(0,$.jsx)(ii,{open:o,onOpenChange:s,children:_}),t[32]=o,t[33]=_,t[34]=s,t[35]=v):v=t[35],v}function ul(e){let t=(0,Q.c)(12),{pendingUiRequest:n,pendingUiValue:r,onPendingUiValueChange:i,onResolveUiRequest:a}=e;if(n?.method===`input`||n?.method===`editor`){let e=n.method===`editor`?on:xr,a;t[0]===i?a=t[1]:(a=e=>i(e.target.value),t[0]=i,t[1]=a);let o;return t[2]!==e||t[3]!==n.placeholder||t[4]!==r||t[5]!==a?(o=(0,$.jsx)(e,{value:r,onChange:a,placeholder:n.placeholder}),t[2]=e,t[3]=n.placeholder,t[4]=r,t[5]=a,t[6]=o):o=t[6],o}if(n?.method===`select`){let e;t[7]!==a||t[8]!==n.options?(e=n.options?.map(e=>{let t=el(e);return(0,$.jsx)(Y,{variant:`outline`,className:`w-full justify-start`,onClick:()=>a({value:t}),children:tl(e)},t)}),t[7]=a,t[8]=n.options,t[9]=e):e=t[9];let r;return t[10]===e?r=t[11]:(r=(0,$.jsx)(`div`,{className:`space-y-2`,children:e}),t[10]=e,t[11]=r),r}return null}function dl(e){let t=(0,Q.c)(67),{pendingUiRequest:n,pendingUiValue:r,onPendingUiValueChange:i,onResolveUiRequest:a,onAuthBack:o}=e,s=ar(),[c,l]=Z.useReducer(fl,!1),u;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u=()=>{l(!1)},t[0]=u):u=t[0];let d=n?.id,f;t[1]===d?f=t[2]:(f=[d],t[1]=d,t[2]=f),Z.useEffect(u,f);let p;t[3]!==o||t[4]!==a?(p=()=>{a({cancelled:!0}),o?.()},t[3]=o,t[4]=a,t[5]=p):p=t[5];let m=p;if(n?.method===`auth`&&n.authUrl){let e=n;if(c){let e;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(e=e=>{e||l(!1)},t[6]=e):e=t[6];let n;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(n=()=>l(!1),t[7]=n):n=t[7];let o;t[8]!==a||t[9]!==r?(o=()=>a({value:r}),t[8]=a,t[9]=r,t[10]=o):o=t[10];let c;t[11]!==s||t[12]!==i||t[13]!==r||t[14]!==o?(c=(0,$.jsx)(rl,{isMobile:s,pendingUiValue:r,onPendingUiValueChange:i,onBack:n,onSubmit:o}),t[11]=s,t[12]=i,t[13]=r,t[14]=o,t[15]=c):c=t[15];let u;return t[16]!==s||t[17]!==c?(u=(0,$.jsx)(nl,{open:!0,isMobile:s,onOpenChange:e,title:`Paste redirect URL`,description:`Paste the final redirected URL from the browser address bar.`,children:c}),t[16]=s,t[17]=c,t[18]=u):u=t[18],u}let o;t[19]===m?o=t[20]:(o=e=>{e||m()},t[19]=m,t[20]=o);let u=e.title||`Log in to provider`,d=e.message||`Open the login page, then complete login in your browser.`,f;t[21]===i?f=t[22]:(f=()=>{i(``),l(!0)},t[21]=i,t[22]=f);let p;t[23]!==e||t[24]!==m||t[25]!==s||t[26]!==f?(p=(0,$.jsx)(ol,{request:e,isMobile:s,onManualMode:f,onCancel:m}),t[23]=e,t[24]=m,t[25]=s,t[26]=f,t[27]=p):p=t[27];let h;return t[28]!==s||t[29]!==o||t[30]!==u||t[31]!==d||t[32]!==p?(h=(0,$.jsx)(nl,{open:!0,isMobile:s,onOpenChange:o,title:u,description:d,children:p}),t[28]=s,t[29]=o,t[30]=u,t[31]=d,t[32]=p,t[33]=h):h=t[33],h}if(n?.method===`auth_select`){let e=n,r;t[34]===m?r=t[35]:(r=e=>{e||m()},t[34]=m,t[35]=r);let i=e.title||`Log in to provider`,o=e.message||`Choose how to continue login.`,c;t[36]!==e||t[37]!==m||t[38]!==s||t[39]!==a?(c=(0,$.jsx)(sl,{request:e,isMobile:s,onCancel:m,onResolveUiRequest:a}),t[36]=e,t[37]=m,t[38]=s,t[39]=a,t[40]=c):c=t[40];let l;return t[41]!==s||t[42]!==r||t[43]!==i||t[44]!==o||t[45]!==c?(l=(0,$.jsx)(nl,{open:!0,isMobile:s,onOpenChange:r,title:i,description:o,children:c}),t[41]=s,t[42]=r,t[43]=i,t[44]=o,t[45]=c,t[46]=l):l=t[46],l}if(n?.method===`auth_input`){let e=n,o;t[47]===m?o=t[48]:(o=e=>{e||m()},t[47]=m,t[48]=o);let c=e.title||`Log in to provider`,l=e.message||`Enter the requested login information.`,u;t[49]!==e||t[50]!==m||t[51]!==s||t[52]!==i||t[53]!==a||t[54]!==r?(u=(0,$.jsx)(cl,{request:e,isMobile:s,pendingUiValue:r,onPendingUiValueChange:i,onCancel:m,onResolveUiRequest:a}),t[49]=e,t[50]=m,t[51]=s,t[52]=i,t[53]=a,t[54]=r,t[55]=u):u=t[55];let d;return t[56]!==s||t[57]!==o||t[58]!==c||t[59]!==l||t[60]!==u?(d=(0,$.jsx)(nl,{open:!0,isMobile:s,onOpenChange:o,title:c,description:l,children:u}),t[56]=s,t[57]=o,t[58]=c,t[59]=l,t[60]=u,t[61]=d):d=t[61],d}let h;return t[62]!==i||t[63]!==a||t[64]!==n||t[65]!==r?(h=(0,$.jsx)(ll,{pendingUiRequest:n,pendingUiValue:r,onPendingUiValueChange:i,onResolveUiRequest:a}),t[62]=i,t[63]=a,t[64]=n,t[65]=r,t[66]=h):h=t[66],h}function fl(e,t){return t}function pl(e){let t=(0,Q.c)(24),{ref:n,openStateRef:r,viewerContextId:i,sessionId:a,onAuthBack:o}=e,[s,c]=Z.useState(null),[l,u]=Z.useState(``),d=Z.useRef(!1),f=Z.useRef(null),p;t[0]===r?p=t[1]:(p=e=>{d.current=e,r&&(r.current=e)},t[0]=r,t[1]=p);let m=p,h;t[2]!==a||t[3]!==i?(h=async e=>{let{requestId:t,body:n}=e;if(!i)throw Error(`Viewer context unavailable`);return await oi(hi(`/api/ui/${encodeURIComponent(t)}`,{contextId:i,sessionId:a}),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(n)})},t[2]=a,t[3]=i,t[4]=h):h=t[4];let g=h,_;t[5]===m?_=t[6]:(_=e=>{e&&f.current?.id!==e||(f.current=null,c(null),u(``),m(!1))},t[5]=m,t[6]=_);let v=_,y;t[7]!==v||t[8]!==s||t[9]!==g||t[10]!==i?(y=async e=>{if(!i||!s)return;let t=s.id;try{await g({requestId:t,body:e}),v(t)}catch(e){let t=e;X.error(t instanceof Error?t.message:`Failed to resolve UI request`)}},t[7]=v,t[8]=s,t[9]=g,t[10]=i,t[11]=y):y=t[11];let b=y,x;t[12]!==v||t[13]!==m?(x=()=>({open:e=>{f.current=e,c(e),u(e.prefill||``),m(!0)},close:()=>{v()},isOpen:()=>d.current}),t[12]=v,t[13]=m,t[14]=x):x=t[14];let S;t[15]===s?S=t[16]:(S=[s],t[15]=s,t[16]=S),Z.useImperativeHandle(n,x,S);let C;t[17]===b?C=t[18]:(C=e=>{b(e)},t[17]=b,t[18]=C);let w;return t[19]!==o||t[20]!==s||t[21]!==l||t[22]!==C?(w=(0,$.jsx)(dl,{pendingUiRequest:s,pendingUiValue:l,onPendingUiValueChange:u,onResolveUiRequest:C,onAuthBack:o}),t[19]=o,t[20]=s,t[21]=l,t[22]=C,t[23]=w):w=t[23],w}var ml=new WeakMap;function hl(e,t=Object.is){let n=ya(e);return ml.set(n,t),n}function gl(e,t){return typeof t==`function`?t(e):t}function _l(e,t,n){let r=e.state,i=gl(r,t);(n??ml.get(e)??Object.is)(r,i)||e.setState(()=>i)}function vl(e,t,n,r=Object.is){_l(e,e=>{let i=gl(e[t],n);return r(e[t],i)?e:{...e,[t]:i}})}function yl(e,t){return e.indexOf(t)>=0}function bl(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1)if(e[n]!==t[n])return!1;return!0}function xl(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1)if(e[n]!==t[n])return!1;return!0}async function Sl(e){let t=i(e.directories);return t.length===0?{ok:!0,directories:[],directoryIndexes:{}}:await oi(hi(`/api/directory-sessions-indexes`,{contextId:e.viewerContextId,searchParams:{directory:t}}))}function Cl(e,t){let n=!1,r={...e};for(let[i,a]of Object.entries(t))JSON.stringify(e[i])!==JSON.stringify(a)&&(r[i]=a,n=!0);return n?r:e}function wl(e,t){let n=Object.keys(e).sort();if(!bl(n,Object.keys(t).sort()))return!1;for(let r of n)if(JSON.stringify(e[r])!==JSON.stringify(t[r]))return!1;return!0}function Tl(e,t,n){let r=!1,i={...e};for(let a of t)!!e[a]!==n&&(i[a]=n,r=!0);return r?i:e}function El(e){let t=e.replace(/\s+/g,` `).trim();return t?t.length<=240?t:`${t.slice(0,239).trimEnd()}…`:``}function Dl(e,t){let n=t.sessionId?.trim()||``,r=t.sessionPath?.trim()||``;return!!(r&&e.path===r||n&&e.id===n)}function Ol(e,t){let n=t.cwd.trim(),r=t.id.trim();if(!n||!r)return e;let i=e[n],a=i?.sessions||[],o=a.find(e=>e.id===r),s=[{...o,...t,id:r,cwd:n,optimistic:!0},...a.filter(e=>e.id!==r)],c=Math.max(i?.totalCount??0,a.length);return{...e,[n]:{directory:n,totalCount:o?c:c+1,revision:`optimistic:${r}:${i?.revision||`initial`}:${t.modified||``}`,sessions:s}}}function kl(e,t){let n=El(t.preview);if(!n)return e;let r=!1,i={...e};for(let[a,o]of Object.entries(e)){let e=[],s=!1,c=o.sessions.map(r=>{if(!Dl(r,t))return r;let i={...r,modified:t.modified,lastUserMessageAt:t.modified,lastMessageAt:t.modified,lastMessagePreview:n,streaming:!0,unread:!1};return e.push(i),s||=i!==r,i});if(!s)continue;let l=new Set(e.map(We));i[a]={...o,revision:`optimistic-preview:${t.modified}:${o.revision}`,sessions:[...e,...c.filter(e=>!l.has(We(e)))]},r=!0}return r?i:e}function Al(e,t){let n=t?.trim()||``;if(!n)return e;let r=!1,i={...e};for(let[t,a]of Object.entries(e)){let e=a.sessions.filter(e=>e.id!==n);e.length!==a.sessions.length&&(r=!0,i[t]={...a,totalCount:Math.max(0,a.totalCount-1),revision:`remove-optimistic:${n}:${a.revision}`,sessions:e})}return r?i:e}function jl(e){return!!(e.optimistic||e.id?.startsWith(`optimistic:`)&&!e.path)}function Ml(e,t){let n=Cl(e,t);for(let[t,r]of Object.entries(e)){let e=r.sessions.filter(jl);if(e.length===0)continue;let i=n[t];if(!i)continue;let a=new Set(i.sessions.flatMap(e=>e.id?[e.id]:[])),o=e.filter(e=>e.id&&!a.has(e.id));o.length!==0&&(n={...n,[t]:{...i,totalCount:i.totalCount+o.length,revision:`preserve-optimistic:${i.revision}`,sessions:[...o,...i.sessions]}})}return n}function Nl(e,t){let n=Object.keys(e),r=Object.keys(t);if(!bl(n.sort(),r.sort()))return!1;for(let r of n)if(!xl(e[r]||[],t[r]||[]))return!1;return!0}function Pl(){return typeof document>`u`?[]:Array.from(document.querySelectorAll(`[data-sidebar-session-item]`)).flatMap(e=>{let t=e.dataset.sessionKey?.trim()||``;return t.length>0?[t]:[]})}function Fl(e,t){let n=t.sessionId?.trim()||``,r=t.sessionPath?.trim()||``;if(!n&&!r)return e;let i=!1,a={...e};for(let[t,o]of Object.entries(e)){let e=!1,s=o.sessions.map(t=>!(n&&t.id===n||r&&t.path===r)||!t.unread?t:(e=!0,i=!0,{...t,unread:!1}));e&&(a[t]={...o,sessions:s})}return i?a:e}function Il(e){let t=[],n=e.sessionPath?.trim()||``,r=e.sessionId?.trim()||``,i=e.sessionKey?.trim()||``;return n&&t.push(`path:${n}`),r&&t.push(`id:${r}`),i&&t.push(`key:${i}`),t}function Ll(e,t){return e?.sessionKey===t.sessionKey&&e?.sessionId===t.sessionId&&e?.sessionPath===t.sessionPath&&e?.streaming===t.streaming&&e?.unread===t.unread}function Rl(e,t){let n=Il(t);if(n.length===0)return e;let r=!1,i={...e};for(let a of n){let n=e[a],o={sessionKey:t.sessionKey??n?.sessionKey,sessionId:t.sessionId??n?.sessionId,sessionPath:t.sessionPath??n?.sessionPath,streaming:typeof t.streaming==`boolean`?t.streaming:n?.streaming,unread:typeof t.unread==`boolean`?t.unread:n?.unread};Ll(n,o)||(i[a]=o,r=!0)}return r?i:e}function zl(e,t){let n=e.path?`path:${e.path}`:``,r=e.id?`id:${e.id}`:``;return(n?t[n]:void 0)||(r?t[r]:void 0)}function Bl(e,t){if(!t)return e;let n=typeof t.streaming==`boolean`?t.streaming:e.streaming,r=typeof t.unread==`boolean`?t.unread:e.unread;return!!e.streaming==!!n&&!!e.unread==!!r?e:{...e,streaming:n,unread:r}}function Vl(e,t){if(Object.keys(t).length===0)return e;let n=!1,r={};for(let[i,a]of Object.entries(e)){let e=!1,o=a.map(r=>{let i=Bl(r,zl(r,t));return i!==r&&(e=!0,n=!0),i});r[i]=e?o:a}return n?r:e}function Hl(){return{sessionsEvent:null,activeSidebarSessionId:``,activeSidebarSessionKey:``,activeSidebarSessionPath:``,sidebarDirectories:[],initialSidebarBootstrapDirectories:[],directoryIndexDataByPath:{},directoryIndexLoading:{},sidebarSessionStatusByKey:{},sidebarDeferredDirectoryLoadingReady:!1,sessionSearch:``,pinnedSidebarSessionKeys:[],selectedSidebarSessionKeys:[],sidebarSessionSelectionAnchor:``}}function Ul(e){let t=e.sessionsEvent?.directoryStates||[],n=new Map(t.map(e=>[e.path,e])),r=i(e.sidebarDirectories),a={};for(let t of r)a[t]=e.directoryIndexDataByPath[t]?.sessions||[];let o=Vl(a,e.sidebarSessionStatusByKey),s=e.sessionSearch.trim().toLowerCase(),c=s?r.some(t=>{let r=n.get(t)?.totalCount??0,i=Object.prototype.hasOwnProperty.call(a,t)?a[t].length:0;return!!e.directoryIndexLoading[t]||!i&&r>0}):!1,l=[],u={};for(let e of r){let t=Object.prototype.hasOwnProperty.call(o,e)?o[e]:[];if(!s){l.push(e),u[e]=t;continue}let n=yl(e.toLowerCase(),s),r=n?t:t.filter(e=>yl([e.title,e.name,e.path,e.cwd].filter(Boolean).join(` `).toLowerCase(),s));(n||r.length>0)&&(l.push(e),u[e]=r)}let d=new Map;for(let e of r){let t=Object.prototype.hasOwnProperty.call(o,e)?o[e]:[];for(let e of t){let t=We(e);!t||d.has(t)||d.set(t,e)}}let f=Array.from(d.values()),p=e.pinnedSidebarSessionKeys.flatMap(e=>{let t=d.get(e);return t?.path||t?.id&&!jl(t)?[t]:[]}),m=e.selectedSidebarSessionKeys.flatMap(e=>{let t=d.get(e);return t?.path||t?.id&&!jl(t)?[t]:[]}),h=[r.join(`
3
+ `),e.pinnedSidebarSessionKeys.join(`
4
+ `),e.selectedSidebarSessionKeys.join(`
5
+ `)].join(`\0`);return{baseSidebarDirectories:r,directoryStateByPath:n,directoryIndexes:o,sidebarDirectoryIndexes:o,sidebarSessions:f,pinnedSidebarSessions:p,selectedSidebarSessions:m,sidebarSessionEntriesByKey:d,visibleDirectories:l,filteredDirectorySessions:u,emptySidebarStateText:s?c?`Searching sessions…`:`No sessions or directories match your search.`:r.length>0?`No directories match this view.`:`No directories added yet.`,workspaceVersion:h}}function Wl(){let e=Hl(),t=hl({state:e,derived:Ul(e),revision:0}),n=e=>{let n=t.state.state,r=typeof e==`function`?e(n):e;if(r===n||Object.entries(r).every(([e,t])=>Object.is(n[e],t)))return;let i={...n,...r};t.setState(e=>({state:i,derived:Ul(i),revision:e.revision+1}))};return Object.assign(t,{getWorkspaceSnapshot:()=>t.state.derived,getWorkspaceVersion:()=>t.state.derived.workspaceVersion,setSidebarState:n,setSessionsEvent:e=>{let r=gl(t.state.state.sessionsEvent,e);r!==t.state.state.sessionsEvent&&n({sessionsEvent:r})},setSidebarDirectories:e=>{let r=gl(t.state.state.sidebarDirectories,e);r!==t.state.state.sidebarDirectories&&n({sidebarDirectories:r})},setDirectoryIndexDataByPath:e=>{let r=gl(t.state.state.directoryIndexDataByPath,e);r!==t.state.state.directoryIndexDataByPath&&n({directoryIndexDataByPath:r})},setDirectoryIndexLoading:e=>{let r=gl(t.state.state.directoryIndexLoading,e);r!==t.state.state.directoryIndexLoading&&n({directoryIndexLoading:r})},setSidebarSessionStatusByKey:e=>{let r=gl(t.state.state.sidebarSessionStatusByKey,e);r!==t.state.state.sidebarSessionStatusByKey&&n({sidebarSessionStatusByKey:r})},setSidebarDeferredDirectoryLoadingReady:e=>{let r=gl(t.state.state.sidebarDeferredDirectoryLoadingReady,e);r!==t.state.state.sidebarDeferredDirectoryLoadingReady&&n({sidebarDeferredDirectoryLoadingReady:r})},setSessionSearch:e=>{let r=gl(t.state.state.sessionSearch,e);r!==t.state.state.sessionSearch&&n({sessionSearch:r})},setPinnedSidebarSessionKeys:e=>{let r=gl(t.state.state.pinnedSidebarSessionKeys,e);r!==t.state.state.pinnedSidebarSessionKeys&&n({pinnedSidebarSessionKeys:r})},setSelectedSidebarSessionKeys:e=>{let r=gl(t.state.state.selectedSidebarSessionKeys,e);r!==t.state.state.selectedSidebarSessionKeys&&n({selectedSidebarSessionKeys:r})},setSidebarSessionSelectionAnchor:e=>{let r=gl(t.state.state.sidebarSessionSelectionAnchor,e);r!==t.state.state.sidebarSessionSelectionAnchor&&n({sidebarSessionSelectionAnchor:r})}}),t}function Gl(e,t,n){let r=(0,Q.c)(2),i=n===void 0?Object.is:n,a;return r[0]===i?a=r[1]:(a={compare:i},r[0]=i,r[1]=a),ka(e,t,a)}function Kl(e){let t=(0,Q.c)(2),{children:n}=e,i;return t[0]===n?i=t[1]:(i=(0,$.jsx)(r,{children:n}),t[0]=n,t[1]=i),i}function ql(e){let t=(0,Q.c)(57),{open:n,onOpenChange:r,renameValue:i,generatingName:a,canGenerateName:o,onRenameValueChange:s,onGenerateSessionName:c,onRenameSession:l}=e,u=ar(),d=Z.useRef(null),f,p;t[0]===n?(f=t[1],p=t[2]):(f=()=>{if(!n)return;let e=window.requestAnimationFrame(()=>{d.current?.focus(),d.current?.select()});return()=>{window.cancelAnimationFrame(e)}},p=[n],t[0]=n,t[1]=f,t[2]=p),Z.useEffect(f,p);let m;t[3]===s?m=t[4]:(m=e=>s(e.target.value),t[3]=s,t[4]=m);let h;t[5]!==c||t[6]!==r||t[7]!==l?(h=e=>{if(e.key===`Escape`){e.preventDefault(),e.stopPropagation(),r(!1);return}if(e.ctrlKey&&e.key.toLowerCase()===`g`){e.preventDefault(),e.stopPropagation(),c();return}e.key!==`Enter`||e.nativeEvent.isComposing||(e.preventDefault(),e.stopPropagation(),l())},t[5]=c,t[6]=r,t[7]=l,t[8]=h):h=t[8];let g;t[9]!==i||t[10]!==m||t[11]!==h?(g=(0,$.jsx)(xr,{ref:d,value:i,onChange:m,onKeyDown:h,placeholder:`Session name`,className:`min-w-0 flex-1`}),t[9]=i,t[10]=m,t[11]=h,t[12]=g):g=t[12];let _=g,v;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`div`,{className:`truncate text-sm font-medium`,children:`Rename session`}),(0,$.jsx)(`div`,{className:`truncate text-xs text-muted-foreground`,children:`Update the display name shown in the sidebar.`})]}),t[13]=v):v=t[13];let y;t[14]!==o||t[15]!==a||t[16]!==u||t[17]!==c?(y=u?null:(0,$.jsxs)(Y,{type:`button`,variant:`ghost`,disabled:a||!o,onClick:c,children:[a?(0,$.jsx)(wt,{}):(0,$.jsx)(Tn,{}),`Generate`]}),t[14]=o,t[15]=a,t[16]=u,t[17]=c,t[18]=y):y=t[18];let b;t[19]===y?b=t[20]:(b=(0,$.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border/70 px-3 py-2`,children:[v,y]}),t[19]=y,t[20]=b);let x;t[21]===_?x=t[22]:(x=(0,$.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center p-3`,children:_}),t[21]=_,t[22]=x);let S;t[23]===u?S=t[24]:(S=u?null:(0,$.jsxs)(`div`,{className:`hidden flex-wrap items-center gap-x-3 gap-y-1 border-t border-border/70 px-3 py-2 text-xs text-muted-foreground md:flex`,children:[(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,$.jsx)(Kl,{children:`Ctrl`}),(0,$.jsx)(Kl,{children:`G`}),` Generate`]}),(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,$.jsx)(Kl,{children:`Enter`}),` Save`]}),(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,$.jsx)(Kl,{children:`Esc`}),` Cancel`]})]}),t[23]=u,t[24]=S);let C;t[25]!==S||t[26]!==b||t[27]!==x?(C=(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[b,x,S]}),t[25]=S,t[26]=b,t[27]=x,t[28]=C):C=t[28];let w=C;if(u){let e;t[29]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsxs)(tn,{children:[(0,$.jsx)(ln,{children:`Rename session`}),(0,$.jsx)(_n,{children:`Update the display name shown in the sidebar.`})]}),t[29]=e):e=t[29];let i;t[30]===w?i=t[31]:(i=(0,$.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden px-4 pb-4`,children:w}),t[30]=w,t[31]=i);let s=a||!o,u;t[32]===a?u=t[33]:(u=a?(0,$.jsx)(wt,{}):(0,$.jsx)(Tn,{}),t[32]=a,t[33]=u);let d;t[34]!==c||t[35]!==s||t[36]!==u?(d=(0,$.jsxs)(Y,{variant:`outline`,disabled:s,onClick:c,children:[u,`Generate`]}),t[34]=c,t[35]=s,t[36]=u,t[37]=d):d=t[37];let f;t[38]===r?f=t[39]:(f=(0,$.jsx)(Y,{variant:`outline`,onClick:()=>r(!1),children:`Cancel`}),t[38]=r,t[39]=f);let p;t[40]===l?p=t[41]:(p=(0,$.jsx)(Y,{onClick:l,children:`Save`}),t[40]=l,t[41]=p);let m;t[42]!==d||t[43]!==f||t[44]!==p?(m=(0,$.jsxs)(Jt,{className:`border-t border-border/70`,children:[d,f,p]}),t[42]=d,t[43]=f,t[44]=p,t[45]=m):m=t[45];let h;t[46]!==i||t[47]!==m?(h=(0,$.jsxs)(pn,{className:`max-h-[90svh] overflow-hidden`,children:[e,i,m]}),t[46]=i,t[47]=m,t[48]=h):h=t[48];let g;return t[49]!==r||t[50]!==n||t[51]!==h?(g=(0,$.jsx)(dn,{open:n,onOpenChange:r,autoFocus:!1,children:h}),t[49]=r,t[50]=n,t[51]=h,t[52]=g):g=t[52],g}let T;return t[53]!==w||t[54]!==r||t[55]!==n?(T=(0,$.jsx)(Vr,{open:n,onOpenChange:r,title:`Rename session`,description:`Update the display name shown in the sidebar.`,className:`sm:max-w-md`,initialFocus:!0,children:w}),t[53]=w,t[54]=r,t[55]=n,t[56]=T):T=t[56],T}function Jl({ref:e,openStateRef:t,viewerContextId:n,onRenameSession:r}){let[i,a]=Z.useState(!1),[o,s]=Z.useState(``),[c,l]=Z.useState(!1),[u,d]=Z.useState(!1),f=Z.useRef(``),p=Z.useRef(i),m=e=>{p.current=e,t&&(t.current=e),a(e)},h=e=>{let t=e.path.trim();t&&(f.current=t,s(e.title),d(!e.hasGeneratedName),m(!0))},g=async()=>{if(!(!n||!f.current||c||!u)){l(!0);try{let e=await oi(hi(`/api/session/name`,{contextId:n}),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({path:f.current})});s(e.name),d(!1),e.source===`heuristic`&&e.reason&&X.info(`Using heuristic session name`,{description:e.reason})}catch(e){X.error(e instanceof Error?e.message:`Failed to generate session name`)}finally{l(!1)}}},_=async()=>{await r(f.current,o)!==!1&&m(!1)};return Z.useImperativeHandle(e,()=>({open:h,openForEntry:e=>{e.path&&h({path:e.path,title:e.title||``,hasGeneratedName:!!e.name?.trim()})},close:()=>{m(!1)},isOpen:()=>p.current}),[o]),(0,$.jsx)(ql,{open:i,onOpenChange:e=>{m(e)},renameValue:o,generatingName:c,canGenerateName:u&&!!(n&&f.current),onRenameValueChange:s,onGenerateSessionName:()=>{g()},onRenameSession:()=>{_()}})}function Yl(e){let t=(0,Q.c)(80),{open:n,onOpenChange:r,title:i,description:a,targets:o,onDeleteSession:s}=e,c=ar(),l=Z.useRef(null),u,d;t[0]!==c||t[1]!==n?(u=()=>{if(!n||c)return;let e=window.requestAnimationFrame(()=>{l.current?.focus()});return()=>{window.cancelAnimationFrame(e)}},d=[c,n],t[0]=c,t[1]=n,t[2]=u,t[3]=d):(u=t[2],d=t[3]),Z.useEffect(u,d);let f,p;t[4]!==c||t[5]!==s||t[6]!==r||t[7]!==n?(f=()=>{if(!n||c)return;let e=e=>{if(e.key===`Escape`){e.preventDefault(),e.stopPropagation(),r(!1);return}e.key!==`Enter`||e.isComposing||(e.preventDefault(),e.stopPropagation(),s())};return window.addEventListener(`keydown`,e,!0),()=>{window.removeEventListener(`keydown`,e,!0)}},p=[c,s,r,n],t[4]=c,t[5]=s,t[6]=r,t[7]=n,t[8]=f,t[9]=p):(f=t[8],p=t[9]),Z.useEffect(f,p);let m,h,g,_,v,y,b,x,S;if(t[10]!==a||t[11]!==s||t[12]!==r||t[13]!==o||t[14]!==i){let e=o.slice(0,8),n=Math.max(0,o.length-e.length);x=l,S=`presentation`,m=-1,h=`flex min-h-0 flex-1 flex-col outline-none`,t[24]!==s||t[25]!==r?(g=e=>{if(e.key===`Escape`){e.preventDefault(),e.stopPropagation(),r(!1);return}e.key!==`Enter`||e.nativeEvent.isComposing||(e.preventDefault(),e.stopPropagation(),s())},t[24]=s,t[25]=r,t[26]=g):g=t[26];let c;t[27]===i?c=t[28]:(c=(0,$.jsx)(`div`,{className:`truncate text-sm font-medium`,children:i}),t[27]=i,t[28]=c);let u;t[29]===a?u=t[30]:(u=(0,$.jsx)(`div`,{className:`truncate text-xs text-muted-foreground`,children:a}),t[29]=a,t[30]=u),t[31]!==c||t[32]!==u?(_=(0,$.jsxs)(`div`,{className:`border-b border-border/70 px-3 py-2`,children:[c,u]}),t[31]=c,t[32]=u,t[33]=_):_=t[33],v=`flex min-h-0 flex-1 flex-col gap-3 p-3`,t[34]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`This cannot be undone.`}),t[34]=y):y=t[34],b=o.length>1?(0,$.jsxs)(`div`,{className:`max-h-48 space-y-1 overflow-y-auto rounded-lg border bg-muted/30 p-2 text-sm`,children:[e.map(Xl),n>0?(0,$.jsxs)(`div`,{className:`text-muted-foreground`,children:[`…and `,n,` more`]}):null]}):null,t[10]=a,t[11]=s,t[12]=r,t[13]=o,t[14]=i,t[15]=m,t[16]=h,t[17]=g,t[18]=_,t[19]=v,t[20]=y,t[21]=b,t[22]=x,t[23]=S}else m=t[15],h=t[16],g=t[17],_=t[18],v=t[19],y=t[20],b=t[21],x=t[22],S=t[23];let C;t[35]!==v||t[36]!==y||t[37]!==b?(C=(0,$.jsxs)(`div`,{className:v,children:[y,b]}),t[35]=v,t[36]=y,t[37]=b,t[38]=C):C=t[38];let w;t[39]===c?w=t[40]:(w=c?null:(0,$.jsxs)(`div`,{className:`hidden flex-wrap items-center gap-x-3 gap-y-1 border-t border-border/70 px-3 py-2 text-xs text-muted-foreground md:flex`,children:[(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,$.jsx)(Kl,{children:`Enter`}),` Delete`]}),(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,$.jsx)(Kl,{children:`Esc`}),` Cancel`]})]}),t[39]=c,t[40]=w);let T;t[41]!==m||t[42]!==h||t[43]!==g||t[44]!==_||t[45]!==C||t[46]!==w||t[47]!==x||t[48]!==S?(T=(0,$.jsxs)(`div`,{ref:x,role:S,tabIndex:m,className:h,onKeyDown:g,children:[_,C,w]}),t[41]=m,t[42]=h,t[43]=g,t[44]=_,t[45]=C,t[46]=w,t[47]=x,t[48]=S,t[49]=T):T=t[49];let E=T;if(c){let e;t[50]===i?e=t[51]:(e=(0,$.jsx)(Xr,{children:i}),t[50]=i,t[51]=e);let o;t[52]===a?o=t[53]:(o=(0,$.jsx)(wi,{children:a}),t[52]=a,t[53]=o);let c;t[54]!==e||t[55]!==o?(c=(0,$.jsxs)(Ci,{className:`sr-only`,children:[e,o]}),t[54]=e,t[55]=o,t[56]=c):c=t[56];let l;t[57]===E?l=t[58]:(l=(0,$.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden`,children:E}),t[57]=E,t[58]=l);let u;t[59]===r?u=t[60]:(u=(0,$.jsx)(Y,{variant:`outline`,onClick:()=>r(!1),children:`Cancel`}),t[59]=r,t[60]=u);let d;t[61]===s?d=t[62]:(d=(0,$.jsx)(Y,{variant:`destructive`,onClick:s,children:`Delete`}),t[61]=s,t[62]=d);let f;t[63]!==u||t[64]!==d?(f=(0,$.jsxs)(ei,{className:`flex-col-reverse gap-2 border-t border-border/70 p-3 sm:flex-row`,children:[u,d]}),t[63]=u,t[64]=d,t[65]=f):f=t[65];let p;t[66]!==c||t[67]!==l||t[68]!==f?(p=(0,$.jsxs)(xi,{className:`max-h-[90svh] overflow-hidden p-0`,children:[c,l,f]}),t[66]=c,t[67]=l,t[68]=f,t[69]=p):p=t[69];let m;return t[70]!==r||t[71]!==n||t[72]!==p?(m=(0,$.jsx)(ii,{open:n,onOpenChange:r,children:p}),t[70]=r,t[71]=n,t[72]=p,t[73]=m):m=t[73],m}let D;return t[74]!==E||t[75]!==a||t[76]!==r||t[77]!==n||t[78]!==i?(D=(0,$.jsx)(Vr,{open:n,onOpenChange:r,title:i,description:a,className:`sm:max-w-md`,initialFocus:!0,children:E}),t[74]=E,t[75]=a,t[76]=r,t[77]=n,t[78]=i,t[79]=D):D=t[79],D}function Xl(e){return(0,$.jsx)(`div`,{className:`truncate`,children:e.title||`New session`},e.path||e.id)}function Zl(e){let t=(0,Q.c)(58),{open:n,onOpenChange:r,directory:i,daysValue:a,preview:o,previewLoading:s,deleteLoading:c,onDaysValueChange:l,onPreview:u,onDelete:d}=e,f=ar(),p=o?.matchingSessions.length??0,m=!!o&&p>0&&!c,h;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,$.jsx)(`label`,{className:`text-sm font-medium`,htmlFor:`old-session-days`,children:`Older than days`}),t[0]=h):h=t[0];let g;t[1]===l?g=t[2]:(g=e=>l(e.target.value),t[1]=l,t[2]=g);let _;t[3]!==a||t[4]!==g?(_=(0,$.jsxs)(`div`,{className:`space-y-2`,children:[h,(0,$.jsx)(xr,{id:`old-session-days`,inputMode:`numeric`,value:a,onChange:g,placeholder:`30`})]}),t[3]=a,t[4]=g,t[5]=_):_=t[5];let v=_,y;t[6]!==p||t[7]!==o?(y=o?(0,$.jsx)(`div`,{className:`rounded-lg border bg-muted/30 p-3 text-sm`,children:p>0?(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsxs)(`p`,{className:`font-medium`,children:[p,` session`,p===1?``:`s`,` will be deleted.`]}),(0,$.jsxs)(`div`,{className:`max-h-48 space-y-1 overflow-y-auto text-muted-foreground`,children:[o.matchingSessions.slice(0,20).map(Ql),p>20?(0,$.jsxs)(`div`,{children:[`…and `,p-20,` more`]}):null]})]}):(0,$.jsx)(`p`,{className:`text-muted-foreground`,children:`No old sessions found.`})}):null,t[6]=p,t[7]=o,t[8]=y):y=t[8];let b=y,x;t[9]===i?x=t[10]:(x=(0,$.jsx)(`p`,{className:`text-sm break-all text-muted-foreground`,children:i}),t[9]=i,t[10]=x);let S;t[11]!==v||t[12]!==b||t[13]!==x?(S=(0,$.jsxs)(`div`,{className:`space-y-4`,children:[x,v,b]}),t[11]=v,t[12]=b,t[13]=x,t[14]=S):S=t[14];let C=S,w;t[15]===r?w=t[16]:(w=()=>r(!1),t[15]=r,t[16]=w);let T;t[17]!==c||t[18]!==w?(T=(0,$.jsx)(Y,{variant:`outline`,onClick:w,disabled:c,children:`Cancel`}),t[17]=c,t[18]=w,t[19]=T):T=t[19];let E;t[20]===s?E=t[21]:(E=s?(0,$.jsx)(wt,{}):null,t[20]=s,t[21]=E);let D;t[22]!==u||t[23]!==s||t[24]!==E?(D=(0,$.jsxs)(Y,{variant:`outline`,onClick:u,disabled:s,children:[E,`Preview`]}),t[22]=u,t[23]=s,t[24]=E,t[25]=D):D=t[25];let O=!m,k;t[26]===c?k=t[27]:(k=c?(0,$.jsx)(wt,{}):null,t[26]=c,t[27]=k);let A;t[28]!==d||t[29]!==O||t[30]!==k?(A=(0,$.jsxs)(Y,{variant:`destructive`,onClick:d,disabled:O,children:[k,`Delete`]}),t[28]=d,t[29]=O,t[30]=k,t[31]=A):A=t[31];let j;t[32]!==D||t[33]!==A||t[34]!==T?(j=(0,$.jsxs)($.Fragment,{children:[T,D,A]}),t[32]=D,t[33]=A,t[34]=T,t[35]=j):j=t[35];let M=j;if(f){let e;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsxs)(tn,{children:[(0,$.jsx)(ln,{children:`Delete old sessions`}),(0,$.jsx)(_n,{children:`Preview and delete inactive sessions in this directory.`})]}),t[36]=e):e=t[36];let i;t[37]===C?i=t[38]:(i=(0,$.jsx)(`div`,{className:`px-4 pb-2`,children:C}),t[37]=C,t[38]=i);let a;t[39]===M?a=t[40]:(a=(0,$.jsx)(Jt,{className:`border-t border-border/70`,children:M}),t[39]=M,t[40]=a);let o;t[41]!==i||t[42]!==a?(o=(0,$.jsxs)(pn,{children:[e,i,a]}),t[41]=i,t[42]=a,t[43]=o):o=t[43];let s;return t[44]!==r||t[45]!==n||t[46]!==o?(s=(0,$.jsx)(dn,{open:n,onOpenChange:r,autoFocus:!1,children:o}),t[44]=r,t[45]=n,t[46]=o,t[47]=s):s=t[47],s}let N;t[48]===Symbol.for(`react.memo_cache_sentinel`)?(N=(0,$.jsxs)(Ci,{children:[(0,$.jsx)(Xr,{children:`Delete old sessions`}),(0,$.jsx)(wi,{children:`Preview and delete inactive sessions in this directory.`})]}),t[48]=N):N=t[48];let P;t[49]===M?P=t[50]:(P=(0,$.jsx)(ei,{children:M}),t[49]=M,t[50]=P);let F;t[51]!==C||t[52]!==P?(F=(0,$.jsxs)(xi,{children:[N,C,P]}),t[51]=C,t[52]=P,t[53]=F):F=t[53];let I;return t[54]!==r||t[55]!==n||t[56]!==F?(I=(0,$.jsx)(ii,{open:n,onOpenChange:r,children:F}),t[54]=r,t[55]=n,t[56]=F,t[57]=I):I=t[57],I}function Ql(e){return(0,$.jsx)(`div`,{className:`truncate`,children:e.title},e.path||e.id)}function $l({ref:e,openStateRef:t,viewerContextId:n}){let r=ki(),[i,a]=Z.useState(!1),[o,s]=Z.useState(``),[c,l]=Z.useState(`30`),[u,d]=Z.useState(null),f=Z.useRef(i),p=e=>{f.current=e,t&&(t.current=e),a(e),e||d(null)},m=()=>{let e=Number(c);if(!Number.isFinite(e)||e<=0)throw Error(`Enter a positive number of days`);return e*24*60*60*1e3},h=an({mutationFn:async e=>await oi(hi(`/api/directory-sessions/cleanup`,{contextId:n}),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({directory:o,olderThanMs:m(),dryRun:e})}),onSuccess:async(e,t)=>{t||await r.invalidateQueries({queryKey:vi.directorySessionsIndex(n,o)})}}),g=async()=>{try{d(await h.mutateAsync(!0))}catch(e){X.error(e instanceof Error?e.message:`Failed to preview sessions`)}},_=async()=>{try{let e=await h.mutateAsync(!1);d(e),await r.invalidateQueries({queryKey:vi.directorySessionsIndex(n,o)}),X.success(`Deleted ${e.deletedSessionIds.length} old session${e.deletedSessionIds.length===1?``:`s`}`),p(!1)}catch(e){X.error(e instanceof Error?e.message:`Failed to delete sessions`)}},v=e=>{let t=e.trim();t&&(s(t),l(`30`),d(null),p(!0))};return Z.useImperativeHandle(e,()=>({open:v,close:()=>{p(!1)},isOpen:()=>f.current}),[c,o,n]),(0,$.jsx)(Zl,{open:i,onOpenChange:p,directory:o,daysValue:c,preview:u,previewLoading:h.isPending&&!u,deleteLoading:h.isPending&&!!u,onDaysValueChange:e=>{l(e),d(null)},onPreview:()=>{g()},onDelete:()=>{_()}})}function eu(e){let t=[],n=new Set;for(let r of e){if(!r.path)continue;let e=`${r.path}:${r.id||``}`;n.has(e)||(n.add(e),t.push(r))}return t}function tu(e){let t=(0,Q.c)(23),{ref:n,openStateRef:r,onDeleteSession:i}=e,[a,o]=Z.useState(!1),s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=[],t[0]=s):s=t[0];let[c,l]=Z.useState(s),u=Z.useRef(a),d;t[1]===r?d=t[2]:(d=e=>{u.current=e,r&&(r.current=e),o(e),e||l([])},t[1]=r,t[2]=d);let f=d,p;t[3]===f?p=t[4]:(p=e=>{let t=eu(e);t.length!==0&&(l(t),f(!0))},t[3]=f,t[4]=p);let m=p,h;t[5]!==i||t[6]!==f||t[7]!==c?(h=async()=>{await i(c)!==!1&&f(!1)},t[5]=i,t[6]=f,t[7]=c,t[8]=h):h=t[8];let g=h,_;t[9]!==m||t[10]!==f?(_=()=>({open:m,close:()=>{f(!1)},isOpen:()=>u.current}),t[9]=m,t[10]=f,t[11]=_):_=t[11];let v;t[12]===c?v=t[13]:(v=[c],t[12]=c,t[13]=v),Z.useImperativeHandle(n,_,v);let y=c.length===1?`Delete session`:`Delete sessions`,b=c.length===1?`Delete "${c[0]?.title||`New session`}" from disk?`:`Delete ${c.length} selected sessions from disk?`,x;t[14]===g?x=t[15]:(x=()=>{g()},t[14]=g,t[15]=x);let S;return t[16]!==b||t[17]!==a||t[18]!==f||t[19]!==x||t[20]!==c||t[21]!==y?(S=(0,$.jsx)(Yl,{open:a,onOpenChange:f,title:y,description:b,targets:c,onDeleteSession:x}),t[16]=b,t[17]=a,t[18]=f,t[19]=x,t[20]=c,t[21]=y,t[22]=S):S=t[22],S}function nu(e){let t=(0,Q.c)(45),{open:n,onOpenChange:r,forkLoading:i,forkMessages:a,onForkFromMessage:o}=e,[s,c]=Z.useState(``),l=ar(),u,d;t[0]!==s||t[1]!==n?(u=()=>{!n&&s&&c(``)},d=[n,s],t[0]=s,t[1]=n,t[2]=u,t[3]=d):(u=t[2],d=t[3]),Z.useEffect(u,d);let f,p,m,h,g,_,v,y;if(t[4]!==i||t[5]!==a||t[6]!==s||t[7]!==o){let e;t[16]===s?e=t[17]:(e=e=>e.text.toLowerCase().includes(s.trim().toLowerCase()),t[16]=s,t[17]=e);let n=(a??[]).filter(e);p=xn,g=!1,_=!0,v=`min-h-0 flex-1 rounded-lg`,t[18]===s?y=t[19]:(y=(0,$.jsx)(Qt,{value:s,onValueChange:c,placeholder:`Search fork points`,className:`text-base md:text-sm`}),t[18]=s,t[19]=y),f=Mn,m=`max-h-none min-h-0 flex-1 md:max-h-[min(70vh,32rem)]`,h=i?(0,$.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-6 text-sm text-muted-foreground`,children:[(0,$.jsx)(wt,{}),` Loading fork points…`]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Lt,{children:a&&a.length>0?`No fork points match your search.`:`No forkable prompts found.`}),n.length>0?(0,$.jsx)(An,{heading:`Fork points`,children:n.map(e=>(0,$.jsx)(On,{value:e.text,onSelect:()=>o(e.entryId),children:(0,$.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,$.jsx)(`div`,{className:`line-clamp-3 text-sm whitespace-pre-wrap text-foreground`,children:e.text})})},e.entryId))}):null]}),t[4]=i,t[5]=a,t[6]=s,t[7]=o,t[8]=f,t[9]=p,t[10]=m,t[11]=h,t[12]=g,t[13]=_,t[14]=v,t[15]=y}else f=t[8],p=t[9],m=t[10],h=t[11],g=t[12],_=t[13],v=t[14],y=t[15];let b;t[20]!==f||t[21]!==m||t[22]!==h?(b=(0,$.jsx)(f,{className:m,children:h}),t[20]=f,t[21]=m,t[22]=h,t[23]=b):b=t[23];let x;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,$.jsx)(Kl,{children:`↑↓`}),` Navigate`]}),t[24]=x):x=t[24];let S;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,$.jsx)(Kl,{children:`Enter`}),` Fork`]}),t[25]=S):S=t[25];let C;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(C=(0,$.jsxs)(`div`,{className:`hidden flex-wrap items-center gap-x-3 gap-y-1 border-t border-border/70 px-3 py-2 text-xs text-muted-foreground md:flex`,children:[x,S,(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,$.jsx)(Kl,{children:`Esc`}),` Close`]})]}),t[26]=C):C=t[26];let w;t[27]!==p||t[28]!==g||t[29]!==_||t[30]!==v||t[31]!==y||t[32]!==b?(w=(0,$.jsxs)(p,{shouldFilter:g,loop:_,className:v,children:[y,b,C]}),t[27]=p,t[28]=g,t[29]=_,t[30]=v,t[31]=y,t[32]=b,t[33]=w):w=t[33];let T=w;if(l){let e;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsxs)(tn,{children:[(0,$.jsx)(ln,{children:`Fork session`}),(0,$.jsx)(_n,{children:`Search earlier user prompts and branch from a specific point.`})]}),t[34]=e):e=t[34];let i;t[35]===T?i=t[36]:(i=(0,$.jsxs)(pn,{className:`max-h-[90svh] overflow-hidden`,children:[e,(0,$.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden px-4 pb-4`,children:T})]}),t[35]=T,t[36]=i);let a;return t[37]!==r||t[38]!==n||t[39]!==i?(a=(0,$.jsx)(dn,{open:n,onOpenChange:r,children:i}),t[37]=r,t[38]=n,t[39]=i,t[40]=a):a=t[40],a}let E;return t[41]!==T||t[42]!==r||t[43]!==n?(E=(0,$.jsx)(Vr,{open:n,onOpenChange:r,title:`Fork session`,description:`Search earlier user prompts and branch from a specific point.`,className:`sm:max-w-2xl`,initialFocus:!0,children:T}),t[41]=T,t[42]=r,t[43]=n,t[44]=E):E=t[44],E}function ru(e){let t=(0,Q.c)(52),{ref:n,openStateRef:r,viewerContextId:i,sessionScopeKey:a,sessionId:o}=e,[s,c]=Z.useState(!1),l=Z.useRef(s),u=ki(),d;t[0]!==a||t[1]!==i?(d=vi.forkableMessages(i,a),t[0]=a,t[1]=i,t[2]=d):d=t[2];let f=d,p;t[3]===r?p=t[4]:(p=e=>{l.current=e,r&&(r.current=e),c(e)},t[3]=r,t[4]=p);let m=p,h;t[5]!==o||t[6]!==i?(h=()=>oi(hi(`/api/session/fork`,{contextId:i,sessionId:o})),t[5]=o,t[6]=i,t[7]=h):h=t[7];let g=!!(i&&s&&a),_;t[8]!==f||t[9]!==h||t[10]!==g?(_={queryKey:f,queryFn:h,staleTime:0,gcTime:6e5,enabled:g},t[8]=f,t[9]=h,t[10]=g,t[11]=_):_=t[11];let v=nn(_),y;t[12]!==o||t[13]!==i?(y=async e=>{if(!i)throw Error(`Viewer context unavailable`);return await oi(hi(`/api/session/fork`,{contextId:i,sessionId:o}),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({entryId:e})})},t[12]=o,t[13]=i,t[14]=y):y=t[14];let b;t[15]!==u||t[16]!==f?(b=async()=>{await u.invalidateQueries({queryKey:f,exact:!0,refetchType:`active`})},t[15]=u,t[16]=f,t[17]=b):b=t[17];let x;t[18]!==y||t[19]!==b?(x={mutationFn:y,onSuccess:b},t[18]=y,t[19]=b,t[20]=x):x=t[20];let S=an(x),C;t[21]!==u||t[22]!==f||t[23]!==m||t[24]!==i?(C=async()=>{i&&(m(!0),await u.invalidateQueries({queryKey:f,exact:!0,refetchType:`active`}))},t[21]=u,t[22]=f,t[23]=m,t[24]=i,t[25]=C):C=t[25];let w=C,T;t[26]!==S||t[27]!==m||t[28]!==i?(T=async e=>{if(i)try{await S.mutateAsync(e),m(!1),X.success(`Forked session`)}catch(e){let t=e;X.error(t instanceof Error?t.message:`Failed to fork session`)}},t[26]=S,t[27]=m,t[28]=i,t[29]=T):T=t[29];let E=T,D;t[30]!==v.error||t[31]!==s||t[32]!==m?(D=()=>{!s||!v.error||(X.error(v.error instanceof Error?v.error.message:`Failed to load fork points`),m(!1))},t[30]=v.error,t[31]=s,t[32]=m,t[33]=D):D=t[33];let O;t[34]!==v.error||t[35]!==v.errorUpdatedAt||t[36]!==s?(O=[v.error,v.errorUpdatedAt,s],t[34]=v.error,t[35]=v.errorUpdatedAt,t[36]=s,t[37]=O):O=t[37],Z.useEffect(D,O);let k;t[38]!==w||t[39]!==m?(k=()=>({open:w,close:()=>{m(!1)},isOpen:()=>l.current}),t[38]=w,t[39]=m,t[40]=k):k=t[40];let A;t[41]!==f||t[42]!==i?(A=[f,i],t[41]=f,t[42]=i,t[43]=A):A=t[43],Z.useImperativeHandle(n,k,A);let j=!!(v.isPending&&!v.data||S.isPending),M=v.data?.messages??null,N;t[44]===E?N=t[45]:(N=e=>{E(e)},t[44]=E,t[45]=N);let P;return t[46]!==j||t[47]!==s||t[48]!==m||t[49]!==M||t[50]!==N?(P=(0,$.jsx)(nu,{open:s,onOpenChange:m,forkLoading:j,forkMessages:M,onForkFromMessage:N}),t[46]=j,t[47]=s,t[48]=m,t[49]=M,t[50]=N,t[51]=P):P=t[51],P}var iu=Z.memo(function(e){let t=(0,Q.c)(4),{commandPaletteCommandsRef:n,commandPaletteOpenRef:r,commandPaletteRef:i}=e,a;return t[0]!==n||t[1]!==r||t[2]!==i?(a=(0,$.jsx)(Ms,{ref:i,openStateRef:r,getCommandsRef:n,onCommandError:gu}),t[0]=n,t[1]=r,t[2]=i,t[3]=a):a=t[3],a}),au=Z.memo(function(e){let t=(0,Q.c)(15),{activeSessionId:n,knownDirectories:r,sessionsDialogDirectory:i,sessionsDialogRef:a,sessionsOpenRef:o,sidebarStore:s,viewerContextId:c,deleteSessions:l,onSessionDialogSelect:u,renameSessionPath:d}=e,f;t[0]===n?f=t[1]:(f=e=>({activeSessionId:e.state.sessionsEvent?.activeSessionId||n,activeSessionPath:e.state.sessionsEvent?.activeSessionPath||``,directorySessionsByPath:e.derived.sidebarDirectoryIndexes,sessionStatusByKey:e.state.sidebarSessionStatusByKey}),t[0]=n,t[1]=f);let p=Gl(s,f),m;return t[2]!==l||t[3]!==r||t[4]!==u||t[5]!==d||t[6]!==i||t[7]!==a||t[8]!==p.activeSessionId||t[9]!==p.activeSessionPath||t[10]!==p.directorySessionsByPath||t[11]!==p.sessionStatusByKey||t[12]!==o||t[13]!==c?(m=(0,$.jsx)(Js,{ref:a,openStateRef:o,viewerContextId:c,currentDirectory:i,knownDirectories:r,directorySessionsByPath:p.directorySessionsByPath,sessionStatusByKey:p.sessionStatusByKey,activeSessionId:p.activeSessionId,activeSessionPath:p.activeSessionPath,onSelectSession:u,onRenameSession:d,onDeleteSession:l,onError:_u}),t[2]=l,t[3]=r,t[4]=u,t[5]=d,t[6]=i,t[7]=a,t[8]=p.activeSessionId,t[9]=p.activeSessionPath,t[10]=p.directorySessionsByPath,t[11]=p.sessionStatusByKey,t[12]=o,t[13]=c,t[14]=m):m=t[14],m}),ou=Z.memo(function(e){let t=(0,Q.c)(17),{addDirectoryDialogRef:n,addDirectoryOpenRef:r,activeSessionId:i,addDirectoryPath:a,baseSidebarDirectories:o,knownDirectories:s,recentDirectoriesStore:c,sessionCwd:l,sessionStore:u,viewerContextId:d}=e,f=ka(c),p=ka(u,vu),m;t[0]!==i||t[1]!==d?(m=async e=>{if(!d)return[];let t=await oi(hi(`/api/path-completions`,{contextId:d,sessionId:i}),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({prefix:e})});return ti(t)?[]:t.items},t[0]=i,t[1]=d,t[2]=m):m=t[2];let h=zi(m),g;t[3]!==i||t[4]!==d?(g=async e=>{if(!d)return[];let t=await oi(hi(`/api/directory-search`,{contextId:d,sessionId:i}),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({query:e})});return ti(t)?[]:t.items},t[3]=i,t[4]=d,t[5]=g):g=t[5];let _=zi(g),v;return t[6]!==n||t[7]!==r||t[8]!==a||t[9]!==o||t[10]!==s||t[11]!==f||t[12]!==h||t[13]!==_||t[14]!==l||t[15]!==p?(v=(0,$.jsx)(vs,{ref:n,openStateRef:r,openedDirectories:o,currentDirectory:l,recentDirectories:f,knownDirectories:s,useForNewSession:p,onAddDirectoryPath:a,onRequestPathCompletions:h,onSearchDirectories:_}),t[6]=n,t[7]=r,t[8]=a,t[9]=o,t[10]=s,t[11]=f,t[12]=h,t[13]=_,t[14]=l,t[15]=p,t[16]=v):v=t[16],v}),su=Z.memo(function(e){let t=(0,Q.c)(16),{activeSessionId:n,baseSidebarDirectories:r,knownDirectories:i,moveSessionDirectoryDialogRef:a,moveSessionDirectoryOpenRef:o,moveSessionDirectoryTargetToPath:s,recentDirectoriesStore:c,sessionCwd:l,viewerContextId:u}=e,d=ka(c),f;t[0]!==n||t[1]!==u?(f=async e=>{if(!u)return[];let t=await oi(hi(`/api/path-completions`,{contextId:u,sessionId:n}),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({prefix:e})});return ti(t)?[]:t.items},t[0]=n,t[1]=u,t[2]=f):f=t[2];let p=zi(f),m;t[3]!==n||t[4]!==u?(m=async e=>{if(!u)return[];let t=await oi(hi(`/api/directory-search`,{contextId:u,sessionId:n}),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({query:e})});return ti(t)?[]:t.items},t[3]=n,t[4]=u,t[5]=m):m=t[5];let h=zi(m),g;return t[6]!==r||t[7]!==i||t[8]!==a||t[9]!==o||t[10]!==s||t[11]!==d||t[12]!==p||t[13]!==h||t[14]!==l?(g=(0,$.jsx)(vs,{ref:a,openStateRef:o,openedDirectories:r,currentDirectory:l,recentDirectories:d,knownDirectories:i,useForMoveSession:!0,onAddDirectoryPath:s,onRequestPathCompletions:p,onSearchDirectories:h}),t[6]=r,t[7]=i,t[8]=a,t[9]=o,t[10]=s,t[11]=d,t[12]=p,t[13]=h,t[14]=l,t[15]=g):g=t[15],g}),cu=Z.memo(function(e){let t=(0,Q.c)(5),{renameDialogRef:n,renameOpenRef:r,renameSessionPath:i,viewerContextId:a}=e,o;return t[0]!==n||t[1]!==r||t[2]!==i||t[3]!==a?(o=(0,$.jsx)(Jl,{ref:n,openStateRef:r,viewerContextId:a,onRenameSession:i}),t[0]=n,t[1]=r,t[2]=i,t[3]=a,t[4]=o):o=t[4],o}),lu=Z.memo(function(e){let t=(0,Q.c)(4),{deleteDialogRef:n,deleteOpenRef:r,deleteSessions:i}=e,a;return t[0]!==n||t[1]!==r||t[2]!==i?(a=(0,$.jsx)(tu,{ref:n,openStateRef:r,onDeleteSession:i}),t[0]=n,t[1]=r,t[2]=i,t[3]=a):a=t[3],a}),uu=Z.memo(function(e){let t=(0,Q.c)(4),{deleteOldDirectorySessionsDialogRef:n,deleteOldDirectorySessionsOpenRef:r,viewerContextId:i}=e,a;return t[0]!==n||t[1]!==r||t[2]!==i?(a=(0,$.jsx)($l,{ref:n,openStateRef:r,viewerContextId:i}),t[0]=n,t[1]=r,t[2]=i,t[3]=a):a=t[3],a}),du=Z.memo(function(e){let t=(0,Q.c)(6),{activeSessionId:n,currentSessionQueryScope:r,forkDialogRef:i,forkOpenRef:a,viewerContextId:o}=e,s;return t[0]!==n||t[1]!==r||t[2]!==i||t[3]!==a||t[4]!==o?(s=(0,$.jsx)(ru,{ref:i,openStateRef:a,viewerContextId:o,sessionScopeKey:r,sessionId:n}),t[0]=n,t[1]=r,t[2]=i,t[3]=a,t[4]=o,t[5]=s):s=t[5],s}),fu=Z.memo(function(e){let t=(0,Q.c)(8),{activeSessionId:n,currentSessionQueryScope:r,sessionStore:i,treeDialogRef:a,treeOpenRef:o,viewerContextId:s}=e,c=ka(i,yu),l=ka(i,bu),u;return t[0]!==n||t[1]!==l||t[2]!==r||t[3]!==a||t[4]!==o||t[5]!==c||t[6]!==s?(u=(0,$.jsx)($c,{ref:a,openStateRef:o,viewerContextId:s,sessionScopeKey:r,sessionId:n,treeSummaryAvailable:c,activeSessionStreaming:l}),t[0]=n,t[1]=l,t[2]=r,t[3]=a,t[4]=o,t[5]=c,t[6]=s,t[7]=u):u=t[7],u}),pu=Z.memo(function(e){let t=(0,Q.c)(32),{authDialogRef:n,currentTheme:r,currentThemeColorMode:i,displaySettingsStore:a,notificationStore:o,onAutoScrollEnabledChange:s,onCenterMessagesChange:c,onHideThinkingBlocksChange:l,onHideToolBlocksChange:u,onSessionDoneDesktopNotificationsEnabledChange:d,onSessionDoneSoundEnabledChange:f,onThemeChange:p,onThemeColorModeChange:m,onThemePreviewChange:h,sessionStore:g,settingsDialogRef:_,settingsOpenRef:v,systemTheme:y,viewerContextId:b}=e,x=ka(g,xu),{autoScrollEnabled:S,centerMessages:C,hideToolBlocks:w}=ka(a),T;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(T={compare:Ni},t[0]=T):T=t[0];let{desktopNotificationPermission:E,sessionDoneDesktopNotificationsEnabled:D,sessionDoneSoundEnabled:O}=ka(o,Su,T),k;t[1]!==n||t[2]!==_?(k=e=>{_.current?.close(),n.current?.open(e,{returnOnClose:()=>_.current?.open()})},t[1]=n,t[2]=_,t[3]=k):k=t[3];let A=k,j,M;t[4]===A?(j=t[5],M=t[6]):(j=()=>A(`login`),M=()=>A(`logout`),t[4]=A,t[5]=j,t[6]=M);let N;return t[7]!==S||t[8]!==C||t[9]!==r||t[10]!==i||t[11]!==E||t[12]!==x||t[13]!==w||t[14]!==s||t[15]!==c||t[16]!==l||t[17]!==u||t[18]!==d||t[19]!==f||t[20]!==p||t[21]!==m||t[22]!==h||t[23]!==D||t[24]!==O||t[25]!==_||t[26]!==v||t[27]!==y||t[28]!==j||t[29]!==M||t[30]!==b?(N=(0,$.jsx)(bc,{ref:_,openStateRef:v,viewerContextId:b,currentTheme:r,currentThemeColorMode:i,onThemeChange:p,onThemeColorModeChange:m,onThemePreviewChange:h,systemTheme:y,hideThinkingBlocks:x,onHideThinkingBlocksChange:l,hideToolBlocks:w,onHideToolBlocksChange:u,centerMessages:C,onCenterMessagesChange:c,autoScrollEnabled:S,onAutoScrollEnabledChange:s,sessionDoneSoundEnabled:O,onSessionDoneSoundEnabledChange:f,sessionDoneDesktopNotificationsEnabled:D,onSessionDoneDesktopNotificationsEnabledChange:d,desktopNotificationPermission:E,onLoginProviders:j,onLogoutProviders:M}),t[7]=S,t[8]=C,t[9]=r,t[10]=i,t[11]=E,t[12]=x,t[13]=w,t[14]=s,t[15]=c,t[16]=l,t[17]=u,t[18]=d,t[19]=f,t[20]=p,t[21]=m,t[22]=h,t[23]=D,t[24]=O,t[25]=_,t[26]=v,t[27]=y,t[28]=j,t[29]=M,t[30]=b,t[31]=N):N=t[31],N}),mu=Z.memo(function(e){let t=(0,Q.c)(8),{activeSessionId:n,authDialogRef:r,uiRequestDialogRef:i,uiRequestOpenRef:a,viewerContextId:o}=e,s;t[0]===r?s=t[1]:(s=()=>r.current?.open(`login`),t[0]=r,t[1]=s);let c;return t[2]!==n||t[3]!==s||t[4]!==i||t[5]!==a||t[6]!==o?(c=(0,$.jsx)(pl,{ref:i,openStateRef:a,viewerContextId:o,sessionId:n,onAuthBack:s}),t[2]=n,t[3]=s,t[4]=i,t[5]=a,t[6]=o,t[7]=c):c=t[7],c}),hu=Z.memo(function(e){let t=(0,Q.c)(112),{activeSessionId:n,addDirectoryDialogRef:r,addDirectoryOpenRef:i,addDirectoryPath:a,baseSidebarDirectories:o,commandPaletteCommandsRef:s,commandPaletteOpenRef:c,commandPaletteRef:l,currentSessionQueryScope:u,currentTheme:d,currentThemeColorMode:f,authDialogRef:p,authOpenRef:m,deleteDialogRef:h,deleteOpenRef:g,deleteSessions:_,deleteOldDirectorySessionsDialogRef:v,deleteOldDirectorySessionsOpenRef:y,notificationStore:b,forkDialogRef:x,forkOpenRef:S,gitCommitDialogRef:C,gitCommitOpenRef:w,displaySettingsStore:T,knownDirectories:E,moveSessionDirectoryDialogRef:D,moveSessionDirectoryOpenRef:O,moveSessionDirectoryTargetToPath:k,onAutoScrollEnabledChange:A,onCenterMessagesChange:j,onHideThinkingBlocksChange:M,onHideToolBlocksChange:N,onSessionDoneDesktopNotificationsEnabledChange:P,onSessionDoneSoundEnabledChange:F,onSessionDialogSelect:I,onThemeChange:L,onThemeColorModeChange:R,onThemePreviewChange:z,recentDirectoriesStore:B,renameDialogRef:V,renameOpenRef:H,renameSessionPath:U,sessionCwd:W,sessionsDialogDirectory:ee,sessionsDialogRef:te,sessionsOpenRef:ne,sessionStore:G,settingsDialogRef:K,settingsOpenRef:re,sidebarStore:q,treeDialogRef:ie,treeOpenRef:J,uiRequestDialogRef:ae,uiRequestOpenRef:oe,viewerContextId:se,systemTheme:ce}=e,le;t[0]!==s||t[1]!==c||t[2]!==l?(le=(0,$.jsx)(iu,{commandPaletteCommandsRef:s,commandPaletteOpenRef:c,commandPaletteRef:l}),t[0]=s,t[1]=c,t[2]=l,t[3]=le):le=t[3];let ue;t[4]!==C||t[5]!==w||t[6]!==W||t[7]!==se?(ue=(0,$.jsx)(Bn,{ref:C,openStateRef:w,viewerContextId:se,cwd:W}),t[4]=C,t[5]=w,t[6]=W,t[7]=se,t[8]=ue):ue=t[8];let de;t[9]!==n||t[10]!==p||t[11]!==m||t[12]!==se?(de=(0,$.jsx)(Os,{ref:p,openStateRef:m,viewerContextId:se,sessionId:n}),t[9]=n,t[10]=p,t[11]=m,t[12]=se,t[13]=de):de=t[13];let fe;t[14]!==n||t[15]!==_||t[16]!==E||t[17]!==I||t[18]!==U||t[19]!==ee||t[20]!==te||t[21]!==ne||t[22]!==q||t[23]!==se?(fe=(0,$.jsx)(au,{activeSessionId:n,knownDirectories:E,sessionsDialogDirectory:ee,sessionsDialogRef:te,sessionsOpenRef:ne,sidebarStore:q,viewerContextId:se,deleteSessions:_,onSessionDialogSelect:I,renameSessionPath:U}),t[14]=n,t[15]=_,t[16]=E,t[17]=I,t[18]=U,t[19]=ee,t[20]=te,t[21]=ne,t[22]=q,t[23]=se,t[24]=fe):fe=t[24];let pe;t[25]!==n||t[26]!==r||t[27]!==i||t[28]!==a||t[29]!==o||t[30]!==E||t[31]!==B||t[32]!==W||t[33]!==G||t[34]!==se?(pe=(0,$.jsx)(ou,{activeSessionId:n,addDirectoryDialogRef:r,addDirectoryOpenRef:i,addDirectoryPath:a,baseSidebarDirectories:o,knownDirectories:E,recentDirectoriesStore:B,sessionCwd:W,sessionStore:G,viewerContextId:se}),t[25]=n,t[26]=r,t[27]=i,t[28]=a,t[29]=o,t[30]=E,t[31]=B,t[32]=W,t[33]=G,t[34]=se,t[35]=pe):pe=t[35];let me;t[36]!==n||t[37]!==o||t[38]!==E||t[39]!==D||t[40]!==O||t[41]!==k||t[42]!==B||t[43]!==W||t[44]!==se?(me=(0,$.jsx)(su,{activeSessionId:n,baseSidebarDirectories:o,knownDirectories:E,moveSessionDirectoryDialogRef:D,moveSessionDirectoryOpenRef:O,moveSessionDirectoryTargetToPath:k,recentDirectoriesStore:B,sessionCwd:W,viewerContextId:se}),t[36]=n,t[37]=o,t[38]=E,t[39]=D,t[40]=O,t[41]=k,t[42]=B,t[43]=W,t[44]=se,t[45]=me):me=t[45];let he;t[46]!==V||t[47]!==H||t[48]!==U||t[49]!==se?(he=(0,$.jsx)(cu,{renameDialogRef:V,renameOpenRef:H,renameSessionPath:U,viewerContextId:se}),t[46]=V,t[47]=H,t[48]=U,t[49]=se,t[50]=he):he=t[50];let ge;t[51]!==h||t[52]!==g||t[53]!==_?(ge=(0,$.jsx)(lu,{deleteDialogRef:h,deleteOpenRef:g,deleteSessions:_}),t[51]=h,t[52]=g,t[53]=_,t[54]=ge):ge=t[54];let _e;t[55]!==v||t[56]!==y||t[57]!==se?(_e=(0,$.jsx)(uu,{deleteOldDirectorySessionsDialogRef:v,deleteOldDirectorySessionsOpenRef:y,viewerContextId:se}),t[55]=v,t[56]=y,t[57]=se,t[58]=_e):_e=t[58];let ve;t[59]!==n||t[60]!==u||t[61]!==x||t[62]!==S||t[63]!==se?(ve=(0,$.jsx)(du,{activeSessionId:n,currentSessionQueryScope:u,forkDialogRef:x,forkOpenRef:S,viewerContextId:se}),t[59]=n,t[60]=u,t[61]=x,t[62]=S,t[63]=se,t[64]=ve):ve=t[64];let ye;t[65]!==n||t[66]!==u||t[67]!==G||t[68]!==ie||t[69]!==J||t[70]!==se?(ye=(0,$.jsx)(fu,{activeSessionId:n,currentSessionQueryScope:u,sessionStore:G,treeDialogRef:ie,treeOpenRef:J,viewerContextId:se}),t[65]=n,t[66]=u,t[67]=G,t[68]=ie,t[69]=J,t[70]=se,t[71]=ye):ye=t[71];let be;t[72]!==p||t[73]!==d||t[74]!==f||t[75]!==T||t[76]!==b||t[77]!==A||t[78]!==j||t[79]!==M||t[80]!==N||t[81]!==P||t[82]!==F||t[83]!==L||t[84]!==R||t[85]!==z||t[86]!==G||t[87]!==K||t[88]!==re||t[89]!==ce||t[90]!==se?(be=(0,$.jsx)(pu,{authDialogRef:p,currentTheme:d,currentThemeColorMode:f,displaySettingsStore:T,notificationStore:b,onAutoScrollEnabledChange:A,onCenterMessagesChange:j,onHideThinkingBlocksChange:M,onHideToolBlocksChange:N,onSessionDoneDesktopNotificationsEnabledChange:P,onSessionDoneSoundEnabledChange:F,onThemeChange:L,onThemeColorModeChange:R,onThemePreviewChange:z,sessionStore:G,settingsDialogRef:K,settingsOpenRef:re,systemTheme:ce,viewerContextId:se}),t[72]=p,t[73]=d,t[74]=f,t[75]=T,t[76]=b,t[77]=A,t[78]=j,t[79]=M,t[80]=N,t[81]=P,t[82]=F,t[83]=L,t[84]=R,t[85]=z,t[86]=G,t[87]=K,t[88]=re,t[89]=ce,t[90]=se,t[91]=be):be=t[91];let xe;t[92]!==n||t[93]!==p||t[94]!==ae||t[95]!==oe||t[96]!==se?(xe=(0,$.jsx)(mu,{activeSessionId:n,authDialogRef:p,uiRequestDialogRef:ae,uiRequestOpenRef:oe,viewerContextId:se}),t[92]=n,t[93]=p,t[94]=ae,t[95]=oe,t[96]=se,t[97]=xe):xe=t[97];let Se;return t[98]!==le||t[99]!==ve||t[100]!==ye||t[101]!==be||t[102]!==xe||t[103]!==ue||t[104]!==de||t[105]!==fe||t[106]!==pe||t[107]!==me||t[108]!==he||t[109]!==ge||t[110]!==_e?(Se=(0,$.jsxs)($.Fragment,{children:[le,ue,de,fe,pe,me,he,ge,_e,ve,ye,be,xe]}),t[98]=le,t[99]=ve,t[100]=ye,t[101]=be,t[102]=xe,t[103]=ue,t[104]=de,t[105]=fe,t[106]=pe,t[107]=me,t[108]=he,t[109]=ge,t[110]=_e,t[111]=Se):Se=t[111],Se});function gu(e){X.error(e instanceof Error?e.message:`Failed to run command`)}function _u(e){X.error(e instanceof Error?e.message:`Failed to load sessions`)}function vu(e){return e.draft&&e.items.length===0}function yu(e){return e.availableModels.length>0}function bu(e){return e.streaming}function xu(e){return e.hideThinkingBlock}function Su(e){return{desktopNotificationPermission:e.desktopNotificationPermission,sessionDoneDesktopNotificationsEnabled:e.sessionDoneDesktopNotificationsEnabled,sessionDoneSoundEnabled:e.sessionDoneSoundEnabled}}var Cu=Z.createContext(void 0);function wu(){let e=Z.useContext(Cu);if(e===void 0)throw Error(mt(64));return e}var Tu=function(e){return e.activationDirection=`data-activation-direction`,e.orientation=`data-orientation`,e}({}),Eu={tabActivationDirection:e=>({[Tu.activationDirection]:e})},Du=Z.forwardRef(function(e,t){let{className:n,defaultValue:r=0,onValueChange:i,orientation:a=`horizontal`,render:o,value:s,style:c,...l}=e,u=Object.hasOwn(e,`defaultValue`),d=Z.useRef([]),[f,p]=Z.useState(()=>new Map),[m,h]=Vn({controlled:s,default:r,name:`Tabs`,state:`value`}),g=s!==void 0,[_,v]=Z.useState(()=>new Map),y=Z.useCallback(e=>{if(e===void 0)return null;for(let[t,n]of _.entries())if(n!=null&&e===(n.value??n.index))return t;return null},[_]),[b,x]=Z.useState(()=>({previousValue:m,tabActivationDirection:`none`})),{previousValue:S,tabActivationDirection:C}=b,w=C,T=!1;S!==m&&(w=Ou(S,m,a,_),T=S!=null&&m!=null&&y(m)==null);let E=T?S:m,D=S!==E||C!==w;Ye(()=>{D&&x({previousValue:E,tabActivationDirection:w})},[E,D,w]);let O=Ce((e,t)=>{t.activationDirection=Ou(m,e,a,_),i?.(e,t),!t.isCanceled&&h(e)}),k=Ce((e,t)=>{p(n=>{if(n.get(e)===t)return n;let r=new Map(n);return r.set(e,t),r})}),A=Ce((e,t)=>{p(n=>{if(!n.has(e)||n.get(e)!==t)return n;let r=new Map(n);return r.delete(e),r})}),j=Z.useCallback(e=>f.get(e),[f]),M=Z.useCallback(e=>{for(let t of _.values())if(e===t?.value)return t?.id},[_]),N=Z.useMemo(()=>({getTabElementBySelectedValue:y,getTabIdByPanelValue:M,getTabPanelIdByValue:j,onValueChange:O,orientation:a,registerMountedTabPanel:k,setTabMap:v,unregisterMountedTabPanel:A,tabActivationDirection:w,value:m}),[y,M,j,O,a,k,v,A,w,m]),P=Z.useMemo(()=>{for(let e of _.values())if(e!=null&&e.value===m)return e},[_,m]),F=Z.useMemo(()=>{for(let e of _.values())if(e!=null&&!e.disabled)return e.value},[_]);Ye(()=>{if(g||_.size===0)return;let e=P?.disabled;if(u&&e&&m===r||!e&&!(P==null&&m!==null))return;let t=F??null;m!==t&&(h(t),x(e=>e.tabActivationDirection===`none`?e:{...e,tabActivationDirection:`none`}))},[r,F,u,g,P,h,_,m]);let I=H(`div`,e,{state:{orientation:a,tabActivationDirection:w},ref:t,props:l,stateAttributesMapping:Eu});return(0,$.jsx)(Cu.Provider,{value:N,children:(0,$.jsx)(Rr,{elementsRef:d,children:I})})});function Ou(e,t,n,r){if(e==null||t==null)return`none`;let i=null,a=null;for(let[n,o]of r.entries()){if(o==null)continue;let r=o.value??o.index;if(e===r&&(i=n),t===r&&(a=n),i!=null&&a!=null)break}if(i==null||a==null)return i!==a&&(typeof e==`number`||typeof e==`string`)&&typeof e==typeof t?n===`horizontal`?t>e?`right`:`left`:t>e?`down`:`up`:`none`;let o=i.getBoundingClientRect(),s=a.getBoundingClientRect();if(n===`horizontal`){if(s.left<o.left)return`left`;if(s.left>o.left)return`right`}else{if(s.top<o.top)return`up`;if(s.top>o.top)return`down`}return`none`}var ku=Z.createContext(void 0);function Au(){let e=Z.useContext(ku);if(e===void 0)throw Error(mt(65));return e}var ju=Z.forwardRef(function(e,t){let{className:n,disabled:r=!1,render:i,value:a,id:o,nativeButton:s=!0,style:c,...l}=e,{value:u,getTabPanelIdByValue:d,orientation:f}=wu(),{activateOnFocus:p,highlightedTabIndex:m,onTabActivation:h,registerTabResizeObserverElement:g,setHighlightedTabIndex:_,tabsListElement:v}=Au(),y=K(o),{compositeProps:b,compositeRef:x,index:S}=sr({metadata:Z.useMemo(()=>({disabled:r,id:y,value:a}),[r,y,a])}),C=a===u,w=Z.useRef(!1),T=Z.useRef(null);Z.useEffect(()=>{let e=T.current;if(e)return g(e)},[g]),Ye(()=>{if(w.current){w.current=!1;return}if(!(C&&S>-1&&m!==S))return;let e=v;if(e!=null){let t=Ee(ve(e));if(t&&gt(e,t))return}r||_(S)},[C,S,m,_,r,v]);let{getButtonProps:E,buttonRef:D}=yi({disabled:r,native:s,focusableWhenDisabled:!0}),k=d(a),A=Z.useRef(!1),j=Z.useRef(!1);function M(e){C||r||h(a,Ct(O,e.nativeEvent,void 0,{activationDirection:`none`}))}function N(e){C||(S>-1&&!r&&_(S),!r&&p&&(!A.current||A.current&&j.current)&&h(a,Ct(O,e.nativeEvent,void 0,{activationDirection:`none`})))}function P(e){if(C||r)return;A.current=!0;function t(){A.current=!1,j.current=!1}(!e.button||e.button===0)&&(j.current=!0,ve(e.currentTarget).addEventListener(`pointerup`,t,{once:!0}))}return H(`button`,e,{state:{disabled:r,active:C,orientation:f},ref:[t,D,x,T],props:[b,{role:`tab`,"aria-controls":k,"aria-selected":C,id:y,onClick:M,onFocus:N,onPointerDown:P,[yr]:C?``:void 0,onKeyDownCapture(){w.current=!0}},l,E]})}),Mu=Z.forwardRef(function(e,t){let{activateOnFocus:n=!1,className:r,loopFocus:i=!0,render:a,style:o,...s}=e,{onValueChange:c,orientation:l,value:u,setTabMap:d,tabActivationDirection:f}=wu(),[p,m]=Z.useState(0),[h,g]=Z.useState(null),_=Z.useRef(new Set),v=Z.useRef(new Set),y=Z.useRef(null),b=Ce(()=>{_.current.forEach(e=>{e()})});Z.useEffect(()=>{if(typeof ResizeObserver>`u`)return;let e=new ResizeObserver(()=>{_.current.size&&b()});return y.current=e,h&&e.observe(h),v.current.forEach(t=>{e.observe(t)}),()=>{e.disconnect(),y.current=null}},[h,b]);let x=Ce(e=>(_.current.add(e),()=>{_.current.delete(e)})),S=Ce(e=>(v.current.add(e),y.current?.observe(e),()=>{v.current.delete(e),y.current?.unobserve(e)})),C=Ce((e,t)=>{e!==u&&c(e,t)}),w={orientation:l,tabActivationDirection:f},T={"aria-orientation":l===`vertical`?`vertical`:void 0,role:`tablist`},E=Z.useMemo(()=>({activateOnFocus:n,highlightedTabIndex:p,registerIndicatorUpdateListener:x,registerTabResizeObserverElement:S,onTabActivation:C,setHighlightedTabIndex:m,tabsListElement:h}),[n,p,x,S,C,m,h]);return(0,$.jsx)(ku.Provider,{value:E,children:(0,$.jsx)(Yn,{render:a,className:r,style:o,state:w,refs:[t,g],props:[T,s],stateAttributesMapping:Eu,highlightedIndex:p,enableHomeAndEndKeys:!0,loopFocus:i,orientation:l,onHighlightedIndexChange:m,onMapChange:d,disabledIndices:te})})});function Nu(e){let t=(0,Q.c)(10),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,orientation:i,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a=i===void 0?`horizontal`:i,o;t[4]===n?o=t[5]:(o=E(`group/tabs flex gap-2 data-horizontal:flex-col`,n),t[4]=n,t[5]=o);let s;return t[6]!==a||t[7]!==r||t[8]!==o?(s=(0,$.jsx)(Du,{"data-slot":`tabs`,"data-orientation":a,className:o,...r}),t[6]=a,t[7]=r,t[8]=o,t[9]=s):s=t[9],s}var Pu=Ti(`group/tabs-list inline-flex w-fit items-center justify-center rounded-lg p-[3px] text-muted-foreground group-data-horizontal/tabs:h-8 group-data-vertical/tabs:h-fit group-data-vertical/tabs:flex-col data-[variant=line]:rounded-none`,{variants:{variant:{default:`bg-muted`,line:`gap-1 bg-transparent`}},defaultVariants:{variant:`default`}});function Fu(e){let t=(0,Q.c)(11),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,variant:i,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a=i===void 0?`default`:i,o;t[4]!==n||t[5]!==a?(o=E(Pu({variant:a}),n),t[4]=n,t[5]=a,t[6]=o):o=t[6];let s;return t[7]!==r||t[8]!==o||t[9]!==a?(s=(0,$.jsx)(Mu,{"data-slot":`tabs-list`,"data-variant":a,className:o,...r}),t[7]=r,t[8]=o,t[9]=a,t[10]=s):s=t[10],s}function Iu(e){let t=(0,Q.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=E(`relative inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-1.5 py-0.5 text-sm font-medium whitespace-nowrap text-foreground/60 transition-all group-data-vertical/tabs:w-full group-data-vertical/tabs:justify-start hover:text-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1 focus-visible:outline-ring disabled:pointer-events-none disabled:opacity-50 has-data-[icon=inline-end]:pr-1 has-data-[icon=inline-start]:pl-1 aria-disabled:pointer-events-none aria-disabled:opacity-50 dark:text-muted-foreground dark:hover:text-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,`group-data-[variant=line]/tabs-list:bg-transparent group-data-[variant=line]/tabs-list:data-active:bg-transparent dark:group-data-[variant=line]/tabs-list:data-active:border-transparent dark:group-data-[variant=line]/tabs-list:data-active:bg-transparent`,`data-active:border-transparent data-active:bg-background data-active:text-foreground dark:data-active:border-transparent dark:data-active:bg-input/30 dark:data-active:text-foreground`,`after:absolute after:bg-foreground after:opacity-0 after:transition-opacity group-data-horizontal/tabs:after:inset-x-0 group-data-horizontal/tabs:after:bottom-[-5px] group-data-horizontal/tabs:after:h-0.5 group-data-vertical/tabs:after:inset-y-0 group-data-vertical/tabs:after:-right-1 group-data-vertical/tabs:after:w-0.5 group-data-[variant=line]/tabs-list:data-active:after:opacity-100`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,$.jsx)(ju,{"data-slot":`tabs-trigger`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Lu(e){return e.label||e.value}function Ru(e){let t=(0,Q.c)(18),{visibleCompletion:n,slashMenuState:r,slashSelectionStore:i,pointerSelectionSuppressed:a,onHoverCompletion:o,onMoveCompletion:s,onApplyCompletion:c,onHoverSlashCommand:l,onMoveSlashCommand:u,onApplySlashSuggestion:d}=e,f=Z.useRef(null),p=Z.useSyncExternalStore(i.subscribe,i.getSnapshot,i.getSnapshot),m=n?n.selectedIndex:p,h;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(h=()=>{(f.current?.querySelector(`[data-composer-assist-selected='true']`))?.scrollIntoView({block:`nearest`})},t[0]=h):h=t[0];let g;if(t[1]!==m||t[2]!==r||t[3]!==n?(g=[m,n,r],t[1]=m,t[2]=r,t[3]=n,t[4]=g):g=t[4],Z.useEffect(h,g),!n&&!r)return null;let _;t[5]!==c||t[6]!==d||t[7]!==o||t[8]!==l||t[9]!==s||t[10]!==u||t[11]!==a||t[12]!==r||t[13]!==p||t[14]!==n?(_=n?(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[n.items.map((e,t)=>{let r=t===n.selectedIndex;return(0,$.jsx)(`button`,{type:`button`,"data-composer-assist-selected":r?`true`:void 0,className:E(`flex w-full items-start gap-2 rounded-md px-2 py-1.5 text-left text-sm`,r?`bg-muted`:a?``:`hover:bg-muted/70`),onMouseEnter:()=>{o(t)},onMouseMove:()=>{s(t)},onClick:()=>{c(e)},children:(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`span`,{className:`block truncate font-medium`,children:Lu(e)}),e.description?(0,$.jsx)(`span`,{className:`block truncate text-xs text-muted-foreground`,children:e.description}):null]})},`${e.value}:${e.description||e.label}`)}),(0,$.jsx)(ho,{}),(0,$.jsx)(`div`,{className:`px-2 py-1 text-xs text-muted-foreground`,children:n.query.kind===`file-reference`?`@ file references`:`Path suggestions`})]}):r?(0,$.jsx)(`div`,{className:`flex flex-col gap-1`,children:r.commands.map((e,t)=>{let n=t===p;return(0,$.jsx)(`button`,{type:`button`,"data-composer-assist-selected":n?`true`:void 0,className:E(`flex w-full items-start gap-2 rounded-md px-2 py-1.5 text-left text-sm`,n?`bg-muted`:a?``:`hover:bg-muted/70`),onMouseEnter:()=>{l(t)},onMouseMove:()=>{u(t)},onClick:()=>{d(e)},children:(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,$.jsxs)(`span`,{className:`block truncate font-medium`,children:[`/`,e.name]}),e.description?(0,$.jsx)(`span`,{className:`block truncate text-xs text-muted-foreground`,children:e.description}):null]})},e.name)})}):null,t[5]=c,t[6]=d,t[7]=o,t[8]=l,t[9]=s,t[10]=u,t[11]=a,t[12]=r,t[13]=p,t[14]=n,t[15]=_):_=t[15];let v;return t[16]===_?v=t[17]:(v=(0,$.jsx)(`div`,{className:`absolute inset-x-0 bottom-full z-20 mb-2 rounded-lg border bg-popover p-1 shadow-lg ring-1 ring-foreground/10`,children:(0,$.jsx)(`div`,{ref:f,className:`max-h-64 overflow-y-auto`,children:_})}),t[16]=_,t[17]=v),v}function zu(e){return[{title:`Steer`,items:e.filter(e=>e.streamingBehavior===`steer`),emptyLabel:`Steer prompts will interrupt the current response.`},{title:`Follow-up`,items:e.filter(e=>e.streamingBehavior!==`steer`),emptyLabel:`Follow-up prompts will run after the current response.`}]}var Bu={editingPendingId:null,editText:``,editError:null};function Vu(e,t){switch(t.type){case`begin`:return{editingPendingId:t.message.pendingId,editText:t.message.text,editError:null};case`cancel`:return Bu;case`text`:return{...e,editText:t.text,editError:e.editError?null:e.editError};case`error`:return{...e,editError:t.error}}}var Hu=Z.memo(function(e){let t=(0,Q.c)(45),{currentPendingMessages:n,canStartQueue:r,onEditPendingMessage:i,onRemovePendingMessage:a,onReorderPending:o,onStartPendingQueue:s}=e,[c,l]=Z.useReducer(Vu,Bu),u;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u=[],t[0]=u):u=t[0];let[d,f]=Z.useState(u),{editingPendingId:p,editText:m,editError:h}=c,g;t[1]!==n||t[2]!==p?(g=p?n.find(e=>e.pendingId===p):void 0,t[1]=n,t[2]=p,t[3]=g):g=t[3];let _=g,v,y;if(t[4]!==_||t[5]!==p?(v=()=>{p&&(_||l({type:`cancel`}))},y=[_,p],t[4]=_,t[5]=p,t[6]=v,t[7]=y):(v=t[6],y=t[7]),Z.useEffect(v,y),n.length===0)return null;let b;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(b=e=>{l({type:`begin`,message:e})},t[8]=b):b=t[8];let x=b,S;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(S=()=>{l({type:`cancel`})},t[9]=S):S=t[9];let C=S,w;t[10]!==m||t[11]!==i?(w=e=>{if(!m.trim()&&e.images.length===0){l({type:`error`,error:`Enter a message or keep at least one image.`});return}i(e.pendingId,m),C()},t[10]=m,t[11]=i,t[12]=w):w=t[12];let T=w,E;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,$.jsx)(`span`,{className:`truncate`,children:`Queue`}),t[13]=E):E=t[13];let D;t[14]===n.length?D=t[15]:(D=(0,$.jsx)(Ar,{className:`min-h-0 flex-1 p-0 hover:no-underline`,children:(0,$.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2 text-sm font-medium`,children:[E,(0,$.jsx)(bs,{variant:`outline`,className:`shrink-0`,children:n.length})]})}),t[14]=n.length,t[15]=D);let O;t[16]!==r||t[17]!==s?(O=r?(0,$.jsx)(Y,{size:`sm`,onClick:s,children:`Start`}):null,t[16]=r,t[17]=s,t[18]=O):O=t[18];let k;t[19]!==O||t[20]!==D?(k=(0,$.jsxs)(`div`,{className:`flex min-h-10 items-center gap-2 px-3 py-2`,children:[D,O]}),t[19]=O,t[20]=D,t[21]=k):k=t[21];let A;if(t[22]!==n||t[23]!==h||t[24]!==m||t[25]!==p||t[26]!==a||t[27]!==o||t[28]!==T){let e;t[30]!==h||t[31]!==m||t[32]!==p||t[33]!==a||t[34]!==o||t[35]!==T?(e=e=>(0,$.jsxs)(`section`,{className:`border-border/70 not-first:border-t`,children:[(0,$.jsxs)(`div`,{className:`sticky top-0 z-10 flex items-center justify-between gap-3 bg-card px-3 pt-3 pb-2 text-xs font-medium tracking-wide text-muted-foreground uppercase`,children:[(0,$.jsx)(`span`,{children:e.title}),(0,$.jsx)(`span`,{children:e.items.length})]}),(0,$.jsx)(`div`,{className:`flex flex-col gap-2 px-3 pb-3`,children:e.items.length>0?e.items.map((t,n)=>{let r=t.streamingBehavior===`steer`,i=r&&n===0,s=!r&&n===e.items.length-1;return(0,$.jsx)(`div`,{className:`rounded-xl border bg-muted/25 p-2.5`,children:p===t.pendingId?(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(on,{value:m,className:`min-h-20 resize-none text-base md:text-base`,placeholder:t.images.length>0?`Optional text for this image prompt`:`Edit queued message`,"aria-invalid":!!h,onChange:e=>{l({type:`text`,text:e.target.value})},onKeyDown:e=>{(e.metaKey||e.ctrlKey)&&e.key===`Enter`&&(e.preventDefault(),T(t)),e.key===`Escape`&&(e.preventDefault(),C())}}),h?(0,$.jsx)(`div`,{className:`text-xs text-destructive`,children:h}):null,t.images.length>0?(0,$.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[t.images.length,` image`,t.images.length===1?``:`s`,` `,`kept`]}):null,(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(Y,{size:`sm`,onClick:()=>T(t),children:`Save`}),(0,$.jsx)(Y,{size:`sm`,variant:`ghost`,onClick:C,children:`Cancel`})]})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`line-clamp-3 text-sm`,children:t.text||(r?`Steer image prompt`:`Follow-up image prompt`)}),t.images.length>0?(0,$.jsxs)(`div`,{className:`mt-2 text-xs text-muted-foreground`,children:[t.images.length,` image`,t.images.length===1?``:`s`]}):null,(0,$.jsxs)(`div`,{className:`mt-2 flex items-center gap-1`,children:[(0,$.jsx)(Y,{size:`sm`,variant:`ghost`,disabled:i,title:r?`Move up`:`Move up or promote to steer`,onClick:()=>o(t.pendingId,-1),children:`↑`}),(0,$.jsx)(Y,{size:`sm`,variant:`ghost`,disabled:s,title:r?`Move down or demote to follow-up`:`Move down`,onClick:()=>o(t.pendingId,1),children:`↓`}),(0,$.jsx)(Y,{size:`sm`,variant:`ghost`,onClick:()=>x(t),children:`Edit`}),(0,$.jsx)(Y,{size:`sm`,variant:`ghost`,onClick:()=>a(t.pendingId),children:`Remove`})]})]})},t.pendingId)}):(0,$.jsx)(`div`,{className:`rounded-md border border-dashed px-3 py-4 text-sm text-muted-foreground`,children:e.emptyLabel})})]},e.title),t[30]=h,t[31]=m,t[32]=p,t[33]=a,t[34]=o,t[35]=T,t[36]=e):e=t[36],A=zu(n).map(e),t[22]=n,t[23]=h,t[24]=m,t[25]=p,t[26]=a,t[27]=o,t[28]=T,t[29]=A}else A=t[29];let j;t[37]===A?j=t[38]:(j=(0,$.jsx)(Un,{className:`p-0`,children:(0,$.jsx)(`div`,{className:`max-h-[min(34vh,320px)] overflow-y-auto border-t`,children:A})}),t[37]=A,t[38]=j);let M;t[39]!==k||t[40]!==j?(M=(0,$.jsxs)(cr,{value:`pending-prompts`,className:`border-0`,children:[k,j]}),t[39]=k,t[40]=j,t[41]=M):M=t[41];let N;return t[42]!==d||t[43]!==M?(N=(0,$.jsx)(Tr,{multiple:!0,value:d,onValueChange:f,className:`rounded-2xl border bg-card`,children:M}),t[42]=d,t[43]=M,t[44]=N):N=t[44],N}),Uu=Z.createContext(void 0);function Wu(e){let t=Z.useContext(Uu);if(t===void 0&&!e)throw Error(mt(47));return t}var Gu=e(vt());function Ku(){return{...ht(),disabled:!1,modal:!1,focusManagerModal:!1,instantType:void 0,openMethod:null,openChangeReason:null,titleElementId:void 0,descriptionElementId:void 0,stickIfOpen:!0,nested:!1,openOnHover:!1,closeDelay:0,hasViewport:!1}}var qu={...Xe,disabled:Ke(e=>e.disabled),instantType:Ke(e=>e.instantType),openMethod:Ke(e=>e.openMethod),openChangeReason:Ke(e=>e.openChangeReason),modal:Ke(e=>e.modal),focusManagerModal:Ke(e=>e.focusManagerModal),stickIfOpen:Ke(e=>e.stickIfOpen),titleElementId:Ke(e=>e.titleElementId),descriptionElementId:Ke(e=>e.descriptionElementId),openOnHover:Ke(e=>e.openOnHover),closeDelay:Ke(e=>e.closeDelay),hasViewport:Ke(e=>e.hasViewport)},Ju=class e extends tt{constructor(e){let t={...Ku(),...e};t.open&&e?.mounted===void 0&&(t.mounted=!0),super(t,{popupRef:Z.createRef(),backdropRef:Z.createRef(),internalBackdropRef:Z.createRef(),onOpenChange:void 0,onOpenChangeComplete:void 0,triggerFocusTargetRef:Z.createRef(),beforeContentFocusGuardRef:Z.createRef(),stickIfOpenTimeout:new I,triggerElements:new st},qu)}setOpen=(e,t)=>{let n=t.reason===y,r=t.reason===`trigger-press`&&t.event.detail===0,i=!e&&(t.reason===`escape-key`||t.reason==null);if(t.preventUnmountOnClose=()=>{this.set(`preventUnmountingOnClose`,!0)},this.context.onOpenChange?.(e,t),t.isCanceled)return;this.state.floatingRootContext.dispatchOpenChange(e,t);let a=()=>{let n={open:e,openChangeReason:t.reason},r=t.trigger?.id??null;(r||e)&&(n.activeTriggerId=r,n.activeTriggerElement=t.trigger??null),this.update(n)};n?(this.set(`stickIfOpen`,!0),this.context.stickIfOpenTimeout.start(500,()=>{this.set(`stickIfOpen`,!1)}),Gu.flushSync(a)):a(),r||i?this.set(`instantType`,r?`click`:`dismiss`):t.reason===`focus-out`?this.set(`instantType`,`focus`):this.set(`instantType`,void 0)};static useStore(t,n){let r=Qe(()=>new e(n)).current,i=t??r;return we(r.disposeEffect),i}disposeEffect=()=>this.context.stickIfOpenTimeout.disposeEffect()};function Yu({props:e}){let{children:t,open:n,defaultOpen:r=!1,onOpenChange:i,onOpenChangeComplete:a,modal:o=!1,handle:s,triggerId:c,defaultTriggerId:l=null}=e,u=Ju.useStore(s?.store,{modal:o,open:r,openProp:n,activeTriggerId:l,triggerIdProp:c});ot(()=>{n===void 0&&u.state.open===!1&&r===!0&&u.update({open:!0,activeTriggerId:l})}),u.useControlledProp(`openProp`,n),u.useControlledProp(`triggerIdProp`,c);let d=u.useState(`open`),f=u.useState(`payload`);u.useContextCallback(`onOpenChange`,i),u.useContextCallback(`onOpenChangeComplete`,a);let{openMethod:p,triggerProps:m}=Jr(d);Fe(u);let{forceUnmount:h}=ue(d,u,()=>{u.update({stickIfOpen:!0,openChangeReason:null})});Z.useEffect(()=>{d||u.context.stickIfOpenTimeout.clear()},[u,d]);let g=Z.useCallback(e=>{let t=Ct(e);return t.preventUnmountOnClose=()=>{u.set(`preventUnmountingOnClose`,!0)},t},[u]),_=Z.useCallback(()=>{u.setOpen(!1,g(ze))},[u,g]);Z.useImperativeHandle(e.actionsRef,()=>({unmount:h,close:_}),[h,_]);let v=Te({popupStore:u,onOpenChange:u.setOpen}),{getReferenceProps:y,getFloatingProps:b,getTriggerProps:x}=q([Me(v,{outsidePressEvent:{mouse:o===`trap-focus`?`sloppy`:`intentional`,touch:`sloppy`}}),pi(v)]),S=Z.useMemo(()=>y(m),[y,m]),C=Z.useMemo(()=>x(m),[x,m]),w=Z.useMemo(()=>b(),[b]);u.useSyncedValues({modal:o,openMethod:p,activeTriggerProps:S,inactiveTriggerProps:C,popupProps:w,floatingRootContext:v,nested:pe()!=null});let T=Z.useMemo(()=>({store:u}),[u]);return(0,$.jsx)(Uu.Provider,{value:T,children:typeof t==`function`?t({payload:f}):t})}function Xu(e){return Wu(!0)?(0,$.jsx)(Yu,{props:e}):(0,$.jsx)(bt,{children:(0,$.jsx)(Yu,{props:e})})}var Zu=Z.forwardRef(function(e,t){let{render:n,className:r,disabled:i=!1,nativeButton:a=!0,handle:o,payload:s,openOnHover:c=!1,delay:l=300,closeDelay:u=0,id:d,style:f,...p}=e,m=Wu(!0),h=o?.store??m?.store;if(!h)throw Error(mt(74));let g=K(d),_=h.useState(`isTriggerActive`,g),v=h.useState(`floatingRootContext`),y=h.useState(`isOpenedByTrigger`,g),b=Z.useRef(null),{registerTrigger:x,isMountedByThisTrigger:C}=$e(g,b,h,{payload:s,disabled:i,openOnHover:c,closeDelay:u}),w=h.useState(`openChangeReason`),T=h.useState(`stickIfOpen`),E=h.useState(`openMethod`),D=h.useState(`focusManagerModal`),O=oe(v,{enabled:v!=null&&c&&(E!==`touch`||w!==`trigger-press`),mouseOnly:!0,move:!1,handleClose:J(),restMs:l,delay:{close:u},triggerElementRef:b,isActiveTrigger:_,isClosing:()=>h.select(`transitionStatus`)===`ending`}),k=q([bn(v,{enabled:v!=null,stickIfOpen:T})]),A=h.useState(`triggerProps`,C),j={disabled:i,open:y},{getButtonProps:M,buttonRef:N}=yi({disabled:i,native:a}),P=Z.useMemo(()=>({open(e){return e&&w===`trigger-press`?it.open(e):S.open(e)}}),[w]),F=H(`button`,e,{state:j,ref:[N,t,x,b],props:[k.getReferenceProps(),O,A,{[z]:``,id:g},p,M],stateAttributesMapping:P}),{preFocusGuardRef:I,handlePreFocusGuardFocus:L,handleFocusTargetFocus:R}=Ht(h,b);return _&&!D?(0,$.jsxs)(Z.Fragment,{children:[(0,$.jsx)(dt,{ref:I,onFocus:L}),(0,$.jsx)(Z.Fragment,{children:F},g),(0,$.jsx)(dt,{ref:h.context.triggerFocusTargetRef,onFocus:R})]}):(0,$.jsx)(Z.Fragment,{children:F},g)}),Qu=Z.createContext(void 0);function $u(){let e=Z.useContext(Qu);if(e===void 0)throw Error(mt(45));return e}var ed=Z.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e,{store:i}=Wu();return i.useState(`mounted`)||n?(0,$.jsx)(Qu.Provider,{value:n,children:(0,$.jsx)(c,{ref:t,...r})}):null}),td=Z.createContext(void 0);function nd(){let e=Z.useContext(td);if(!e)throw Error(mt(46));return e}var rd=Z.forwardRef(function(e,t){let{render:n,className:r,anchor:i,positionMethod:o=`absolute`,side:s=`bottom`,align:c=`center`,sideOffset:l=0,alignOffset:u=0,collisionBoundary:d=`clipping-ancestors`,collisionPadding:f=5,arrowPadding:p=5,sticky:m=!1,disableAnchorTracking:h=!1,collisionAvoidance:g=a,style:v,...y}=e,{store:b}=Wu(),x=$u(),S=Ot(),C=b.useState(`floatingRootContext`),w=b.useState(`mounted`),T=b.useState(`open`),E=b.useState(`openChangeReason`),D=b.useState(`activeTriggerElement`),O=b.useState(`modal`),k=b.useState(`openMethod`),A=b.useState(`positionerElement`),j=b.useState(`instantType`),M=b.useState(`transitionStatus`),N=b.useState(`hasViewport`),P=Z.useRef(null),F=Ue(A,!1,!1),I=ne({anchor:i,floatingRootContext:C,positionMethod:o,mounted:w,side:s,sideOffset:l,align:c,alignOffset:u,arrowPadding:p,collisionBoundary:d,collisionPadding:f,sticky:m,disableAnchorTracking:h,keepMounted:x,nodeId:S,collisionAvoidance:g,adaptiveOrigin:N?_:void 0}),L=C.useState(`domReferenceElement`);Ye(()=>{let e=L,t=P.current;if(e&&(P.current=e),t&&e&&e!==t){b.set(`instantType`,void 0);let e=new AbortController;return F(()=>{b.set(`instantType`,`trigger-change`)},e.signal),()=>{e.abort()}}},[L,F,b]);let R={open:T,side:I.side,align:I.align,anchorHidden:I.anchorHidden,instant:j};Ft(T&&O===!0&&E!==`trigger-hover`,k===`touch`,A,D);let z=Z.useCallback(e=>{b.set(`positionerElement`,e)},[b]),B=jt(e,R,{styles:I.positionerStyles,transitionStatus:M,props:y,refs:[t,z],hidden:!w,inert:!T});return(0,$.jsxs)(td.Provider,{value:I,children:[w&&O===!0&&E!==`trigger-hover`&&(0,$.jsx)(ci,{ref:b.context.internalBackdropRef,inert:$r(!T),cutout:D}),(0,$.jsx)(ce,{id:S,children:B})]})}),id=Z.createContext(void 0);function ad(){let[e,t]=Z.useState(0),n=Ce(()=>(t(e=>e+1),()=>{t(e=>Math.max(0,e-1))}));return{context:Z.useMemo(()=>({register:n}),[n]),hasClosePart:e>0}}function od(e){let{value:t,children:n}=e;return(0,$.jsx)(id.Provider,{value:t,children:n})}var sd={...w,...Se},cd=Z.forwardRef(function(e,t){let{className:n,render:r,initialFocus:i,finalFocus:a,style:s,...c}=e,{store:l}=Wu(),u=nd(),d=ir(!0)!=null,{context:f,hasClosePart:p}=ad(),m=l.useState(`open`),h=l.useState(`openMethod`),g=l.useState(`instantType`),_=l.useState(`transitionStatus`),v=l.useState(`popupProps`),y=l.useState(`titleElementId`),b=l.useState(`descriptionElementId`),x=l.useState(`modal`),S=l.useState(`mounted`),C=l.useState(`openChangeReason`),w=l.useState(`activeTriggerElement`),T=l.useState(`floatingRootContext`);_e({open:m,ref:l.context.popupRef,onComplete(){m&&l.context.onOpenChangeComplete?.(!0)}});let E=l.useState(`disabled`),D=l.useState(`openOnHover`),O=l.useState(`closeDelay`);L(T,{enabled:D&&!E,closeDelay:O});function k(e){return e===`touch`?l.context.popupRef.current:!0}let A=i===void 0?k:i,j={open:m,side:u.side,align:u.align,instant:g,transitionStatus:_},M=x!==!1&&p;l.useSyncedValue(`focusManagerModal`,M);let N=Z.useCallback(e=>{l.set(`popupElement`,e)},[l]),P=H(`div`,e,{state:j,ref:[t,l.context.popupRef,N],props:[v,{"aria-labelledby":y,"aria-describedby":b,onKeyDown(e){d&&Gr.has(e.key)&&e.stopPropagation()}},o(_),c],stateAttributesMapping:sd});return(0,$.jsx)(_i,{context:T,openInteractionType:h,modal:M,disabled:!S||C===`trigger-hover`,initialFocus:A,returnFocus:a,restoreFocus:`popup`,previousFocusableElement:me(w)?w:void 0,nextFocusableElement:l.context.triggerFocusTargetRef,beforeContentFocusGuardRef:l.context.beforeContentFocusGuardRef,children:(0,$.jsx)(od,{value:f,children:P})})});function ld(e){let t=(0,Q.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,$.jsx)(Xu,{"data-slot":`popover`,...n}),t[2]=n,t[3]=r),r}function ud(e){let t=(0,Q.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,$.jsx)(Zu,{"data-slot":`popover-trigger`,...n}),t[2]=n,t[3]=r),r}function dd(e){let t=(0,Q.c)(18),n,r,i,a,o,s;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6]):({className:n,align:i,alignOffset:a,side:o,sideOffset:s,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s);let c=i===void 0?`center`:i,l=a===void 0?0:a,u=o===void 0?`bottom`:o,d=s===void 0?4:s,f;t[7]===n?f=t[8]:(f=E(`z-50 flex w-72 origin-(--transform-origin) flex-col gap-2.5 rounded-lg bg-popover p-2.5 text-sm text-popover-foreground shadow-md ring-1 ring-foreground/10 outline-hidden duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,n),t[7]=n,t[8]=f);let p;t[9]!==r||t[10]!==f?(p=(0,$.jsx)(cd,{"data-slot":`popover-content`,className:f,...r}),t[9]=r,t[10]=f,t[11]=p):p=t[11];let m;return t[12]!==c||t[13]!==l||t[14]!==u||t[15]!==d||t[16]!==p?(m=(0,$.jsx)(ed,{children:(0,$.jsx)(rd,{align:c,alignOffset:l,side:u,sideOffset:d,className:`isolate z-50`,children:p})}),t[12]=c,t[13]=l,t[14]=u,t[15]=d,t[16]=p,t[17]=m):m=t[17],m}var fd=new Intl.NumberFormat(`en-US`),pd=`(hover: none), (pointer: coarse)`,md=14,hd=10.5,gd=2.2,_d={1:[{radius:hd,strokeWidth:3}],2:[{radius:11,strokeWidth:2.6},{radius:7.2,strokeWidth:2.6}],3:[{radius:11.5,strokeWidth:gd},{radius:8,strokeWidth:gd},{radius:4.5,strokeWidth:gd}]};function vd(e){return fd.format(e)}function yd(e){return e>=1e6?`${(e/1e6).toFixed(e>=1e7?0:1).replace(/\.0$/,``)}M`:e>=1e3?`${(e/1e3).toFixed(e>=1e5?0:1).replace(/\.0$/,``)}k`:vd(e)}function bd(e){return String(Math.round(e))}function xd(){let e=(0,Q.c)(2),[t,n]=Z.useState(!1),r,i;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=()=>{let e=window.matchMedia(pd),t=()=>n(e.matches);return t(),e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},i=[],e[0]=r,e[1]=i):(r=e[0],i=e[1]),Z.useEffect(r,i),t}function Sd(e){return e>=90?`var(--destructive)`:e>=80?`var(--warning)`:`var(--primary)`}var Cd=new Set([`used`,`tokens`,`usage`,`limit`,`total`,`max`,`percent`,`percentage`,`timeLeft`,`remaining`,`resetAt`,`resetsAt`,`expiresAt`]),wd=hl(void 0);function Td(e){return!!e&&typeof e==`object`}function Ed(e){return typeof e==`number`&&Number.isFinite(e)?e:null}function Dd(e,t){for(let n of t){let t=Ed(e[n]);if(t!=null)return t}return null}function Od(e,t){for(let n of t){let t=e[n];if(typeof t==`string`&&t.trim())return t}return null}function kd(e,t){for(let n of t){let t=e[n];if(Td(t))return t}return null}function Ad(e,t){return t?e:e.filter(e=>!Cd.has(e))}function jd(e){let t=Math.max(0,Math.ceil(e/6e4)),n=Math.floor(t/60),r=t%60;return n>0&&r>0?`${n}h ${r}m`:n>0?`${n}h`:`${r}m`}function Md(e){if(typeof e==`number`&&Number.isFinite(e))return e<1e10?e*1e3:e;if(typeof e!=`string`||!e.trim())return null;let t=Number(e);if(Number.isFinite(t))return t<1e10?t*1e3:t;let n=new Date(e).getTime();return Number.isNaN(n)?null:n}function Nd(e,t,n){let r=Od(e,t);if(r)return r;let i=n.map(t=>Md(e[t])).find(e=>e!=null);if(i==null)return null;let a=i-Date.now();return a<=0?`0m`:jd(a)}function Pd(e,t,n,r,i,a,o,s){let c=kd(e,n),l=!!c,u=c??e,d=Dd(u,Ad(r,l)),f=Dd(u,Ad(i,l)),p=Dd(u,Ad(a,l))??(d!=null&&f!=null&&f>0?d/f*100:null),m=Nd(u,Ad(o,l),Ad(s,l));return d==null&&f==null&&p==null&&m==null?null:{label:t,used:d,limit:f,percent:p==null?null:Math.max(0,Math.min(100,p)),timeLeft:m}}function Fd(e){if(!e?.contextWindow)return;let t=typeof e.tokens==`number`?e.tokens:null,n=typeof e.percent==`number`?e.percent:t!=null&&e.contextWindow>0?t/e.contextWindow*100:null,r=n==null?null:Math.max(0,Math.min(100,n)),i=r==null?null:Math.max(0,Math.min(100,Math.round(r))),a=Pd(e,`5h usage`,[`fiveHourUsage`,`fiveHour`,`usage5h`,`5h`,`fiveHourLimit`],[`used`,`tokens`,`usage`,`fiveHourUsed`,`fiveHourTokens`,`usage5h`],[`limit`,`total`,`max`,`fiveHourLimit`,`limit5h`],[`percent`,`percentage`,`fiveHourPercent`,`percent5h`],[`timeLeft`,`remaining`,`fiveHourTimeLeft`,`timeLeft5h`],[`resetAt`,`resetsAt`,`expiresAt`,`fiveHourResetAt`,`resetAt5h`]),o=Pd(e,`Weekly usage`,[`weeklyUsage`,`weekly`,`usageWeekly`,`week`,`weeklyLimit`],[`used`,`tokens`,`usage`,`weeklyUsed`,`weeklyTokens`,`usageWeekly`],[`limit`,`total`,`max`,`weeklyLimit`,`limitWeekly`],[`percent`,`percentage`,`weeklyPercent`,`percentWeekly`],[`timeLeft`,`remaining`,`weeklyTimeLeft`,`timeLeftWeekly`],[`resetAt`,`resetsAt`,`expiresAt`,`weeklyResetAt`,`resetAtWeekly`]);return{contextWindow:e.contextWindow,tokens:t,percent:i,roundedPercent:i,fiveHourUsage:a,weeklyUsage:o}}function Id(e,t){return e?.label===t?.label&&e?.used===t?.used&&e?.limit===t?.limit&&e?.percent===t?.percent&&e?.timeLeft===t?.timeLeft}function Ld(e,t){return e?.contextWindow===t?.contextWindow&&e?.tokens===t?.tokens&&e?.roundedPercent===t?.roundedPercent&&Id(e?.fiveHourUsage,t?.fiveHourUsage)&&Id(e?.weeklyUsage,t?.weeklyUsage)}function Rd(e){let t=(0,Q.c)(1),n;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n={compare:Ld},t[0]=n):n=t[0],ka(e,Fd,n)}function zd(e){return e==null?null:`${bd(e)}%`}function Bd(e){return e==null?null:yd(e)}function Vd(e){let t=(0,Q.c)(5),{percent:n}=e,r=Math.max(0,Math.min(100,n)),i=`${r}%`,a;t[0]===r?a=t[1]:(a=Sd(r),t[0]=r,t[1]=a);let o;return t[2]!==i||t[3]!==a?(o=(0,$.jsx)(`div`,{className:`mt-2 h-1.5 overflow-hidden rounded-full bg-muted`,children:(0,$.jsx)(`div`,{className:`h-full rounded-full`,style:{width:i,backgroundColor:a}})}),t[2]=i,t[3]=a,t[4]=o):o=t[4],o}function Hd(e){let t=(0,Q.c)(22),{quota:n}=e,r;t[0]===n.percent?r=t[1]:(r=zd(n.percent),t[0]=n.percent,t[1]=r);let i=r,a;t[2]===n.used?a=t[3]:(a=Bd(n.used),t[2]=n.used,t[3]=a);let o=a,s;t[4]===n.limit?s=t[5]:(s=Bd(n.limit),t[4]=n.limit,t[5]=s);let c=s,l=o!=null&&c!=null?`${o} / ${c}`:o??c??`Available`,u;t[6]===n.label?u=t[7]:(u=(0,$.jsx)(`span`,{className:`font-medium text-muted-foreground`,children:n.label}),t[6]=n.label,t[7]=u);let d=i?`${i} `:null,f;t[8]!==d||t[9]!==l?(f=(0,$.jsxs)(`span`,{className:`font-semibold text-foreground`,children:[d,l]}),t[8]=d,t[9]=l,t[10]=f):f=t[10];let p;t[11]!==u||t[12]!==f?(p=(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-6`,children:[u,f]}),t[11]=u,t[12]=f,t[13]=p):p=t[13];let m;t[14]===n.percent?m=t[15]:(m=n.percent==null?null:(0,$.jsx)(Vd,{percent:n.percent}),t[14]=n.percent,t[15]=m);let h;t[16]===n.timeLeft?h=t[17]:(h=n.timeLeft?(0,$.jsxs)(`div`,{className:`mt-1 text-xs text-muted-foreground`,children:[`Resets in `,n.timeLeft]}):null,t[16]=n.timeLeft,t[17]=h);let g;return t[18]!==p||t[19]!==m||t[20]!==h?(g=(0,$.jsxs)(`div`,{className:`rounded-lg bg-background/70 px-2.5 py-2`,children:[p,m,h]}),t[18]=p,t[19]=m,t[20]=h,t[21]=g):g=t[21],g}function Ud(e){let t=(0,Q.c)(17),{window:n}=e,r;t[0]===n.usedPercent?r=t[1]:(r=bd(n.usedPercent),t[0]=n.usedPercent,t[1]=r);let i=`${r}%`,a=n.label===`Week`?`Weekly usage`:`${n.label} usage`,o;t[2]===a?o=t[3]:(o=(0,$.jsx)(`span`,{className:`font-medium text-muted-foreground`,children:a}),t[2]=a,t[3]=o);let s;t[4]===i?s=t[5]:(s=(0,$.jsx)(`span`,{className:`font-semibold text-foreground`,children:i}),t[4]=i,t[5]=s);let c;t[6]!==o||t[7]!==s?(c=(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-6`,children:[o,s]}),t[6]=o,t[7]=s,t[8]=c):c=t[8];let l;t[9]===n.usedPercent?l=t[10]:(l=(0,$.jsx)(Vd,{percent:n.usedPercent}),t[9]=n.usedPercent,t[10]=l);let u;t[11]===n.resetsIn?u=t[12]:(u=n.resetsIn?(0,$.jsxs)(`div`,{className:`mt-1 text-xs text-muted-foreground`,children:[`Resets in `,n.resetsIn]}):null,t[11]=n.resetsIn,t[12]=u);let d;return t[13]!==c||t[14]!==l||t[15]!==u?(d=(0,$.jsxs)(`div`,{className:`rounded-lg bg-background/70 px-2.5 py-2`,children:[c,l,u]}),t[13]=c,t[14]=l,t[15]=u,t[16]=d):d=t[16],d}function Wd(e){return Math.max(0,Math.min(100,e))}function Gd(e){let t=e.label.trim().toLowerCase().replace(/\s+/g,``);return t===`5h`||t===`5hr`||t.includes(`five`)}function Kd(e){let t=e.label.trim().toLowerCase().replace(/\s+/g,``);return t===`week`||t===`weekly`||t===`7d`||t.includes(`seven`)}function qd(e,t,n,r){let i=r.find(Gd),a=r.find(Kd),o=i?.usedPercent??t?.percent??null,s=a?.usedPercent??n?.percent??null,c=[{key:`context`,label:`Context window`,percent:e==null?null:Wd(e)}];return o!=null&&c.push({key:`five-hour`,label:i?`${i.label} usage`:t?.label??`5h usage`,percent:Wd(o)}),s!=null&&c.push({key:`weekly`,label:a?.label===`Week`?`Weekly usage`:a?`${a.label} usage`:n?.label??`Weekly usage`,percent:Wd(s)}),c.slice(0,3)}function Jd(e){return e>=3?_d[3]:e===2?_d[2]:_d[1]}function Yd(e){let t=(0,Q.c)(88),{activeSessionId:n,contextUsageStore:r,disabled:i,modelProvider:a,viewerContextId:o}=e,s=r===void 0?wd:r,c=i===void 0?!1:i,l=Rd(s),u=xd(),p=!!(a&&o),m;t[0]!==n||t[1]!==a||t[2]!==o?(m=vi.providerUsage(o,n||``,a||``),t[0]=n,t[1]=a,t[2]=o,t[3]=m):m=t[3];let h;t[4]!==n||t[5]!==a||t[6]!==o?(h=async()=>a?(await oi(hi(`/api/provider-usage`,{contextId:o,sessionId:n,searchParams:{provider:a}}))).usage?.windows??[]:[],t[4]=n,t[5]=a,t[6]=o,t[7]=h):h=t[7];let g;t[8]!==p||t[9]!==m||t[10]!==h?(g={enabled:p,queryKey:m,queryFn:h},t[8]=p,t[9]=m,t[10]=h,t[11]=g):g=t[11];let _=nn(g),v,y,b,x,S,C,w,T,E,D,O,k,A,j,M,N,P,F,I,L;if(t[12]!==l||t[13]!==c||t[14]!==_.data){N=Symbol.for(`react.early_return_sentinel`);bb0:{if(w=_.data??[],c){N=null;break bb0}if(!l){N=null;break bb0}let{contextWindow:e,fiveHourUsage:n,percent:r,roundedPercent:i,tokens:a,weeklyUsage:o}=l;S=n,C=r,L=o;let s;t[35]===i?s=t[36]:(s=i==null?`Pending`:`${bd(i)}%`,t[35]=i,t[36]=s),x=s;let u;t[37]===e?u=t[38]:(u=yd(e),t[37]=e,t[38]=u),y=u;let d;t[39]===a?d=t[40]:(d=a==null?null:yd(a),t[39]=a,t[40]=d),b=d;let f=qd(C,S,L,w),p=Jd(f.length),m=f.slice(1).map(Zd).join(` `),h=`${i==null?`Context window. Usage estimate pending. ${y} token window.`:a==null?`Context window. ${x} used. ${y} tokens available.`:`Context window. ${x} used. ${b} / ${y} tokens used.`}${m?` ${m}`:``}`;v=Y,O=`button`,k=`ghost`,A=`icon`,j=`relative ml-auto shrink-0`,M=h,P=`pointer-events-none absolute top-1/2 left-1/2 size-7 -translate-x-1/2 -translate-y-1/2`,F=`0 0 28 28`,I=`none`,T=`true`,E=f.map((e,t)=>{let n=p[t];return n?(0,$.jsx)(`circle`,{cx:md,cy:md,r:n.radius,stroke:`var(--border)`,strokeWidth:n.strokeWidth,strokeOpacity:`0.75`,vectorEffect:`non-scaling-stroke`},`${e.key}-track`):null}),D=f.map((e,t)=>{let n=p[t];return!n||e.percent==null?null:(0,$.jsx)(`circle`,{cx:md,cy:md,r:n.radius,pathLength:100,stroke:Sd(e.percent),strokeWidth:n.strokeWidth,strokeDasharray:`${e.percent.toFixed(1)} 100`,strokeLinecap:`round`,vectorEffect:`non-scaling-stroke`,className:`origin-center -rotate-90`},e.key)})}t[12]=l,t[13]=c,t[14]=_.data,t[15]=v,t[16]=y,t[17]=b,t[18]=x,t[19]=S,t[20]=C,t[21]=w,t[22]=T,t[23]=E,t[24]=D,t[25]=O,t[26]=k,t[27]=A,t[28]=j,t[29]=M,t[30]=N,t[31]=P,t[32]=F,t[33]=I,t[34]=L}else v=t[15],y=t[16],b=t[17],x=t[18],S=t[19],C=t[20],w=t[21],T=t[22],E=t[23],D=t[24],O=t[25],k=t[26],A=t[27],j=t[28],M=t[29],N=t[30],P=t[31],F=t[32],I=t[33],L=t[34];if(N!==Symbol.for(`react.early_return_sentinel`))return N;let R;t[41]!==T||t[42]!==E||t[43]!==D||t[44]!==P||t[45]!==F||t[46]!==I?(R=(0,$.jsxs)(`svg`,{className:P,viewBox:F,fill:I,"aria-hidden":T,children:[E,D]}),t[41]=T,t[42]=E,t[43]=D,t[44]=P,t[45]=F,t[46]=I,t[47]=R):R=t[47];let z;t[48]!==v||t[49]!==O||t[50]!==k||t[51]!==A||t[52]!==j||t[53]!==M||t[54]!==R?(z=(0,$.jsx)(v,{type:O,variant:k,size:A,className:j,"aria-label":M,children:R}),t[48]=v,t[49]=O,t[50]=k,t[51]=A,t[52]=j,t[53]=M,t[54]=R,t[55]=z):z=t[55];let B=z,V;t[56]===Symbol.for(`react.memo_cache_sentinel`)?(V=(0,$.jsx)(`span`,{className:`font-medium text-muted-foreground`,children:`Context window`}),t[56]=V):V=t[56];let H;t[57]===x?H=t[58]:(H=(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-6`,children:[V,(0,$.jsx)(`span`,{className:`font-semibold text-foreground`,children:x})]}),t[57]=x,t[58]=H);let U;t[59]===C?U=t[60]:(U=C==null?null:(0,$.jsx)(Vd,{percent:C}),t[59]=C,t[60]=U);let W=b==null?`Usage estimate pending · ${y} token window`:`${b} / ${y} tokens used`,ee;t[61]===W?ee=t[62]:(ee=(0,$.jsx)(`div`,{className:`mt-1 text-xs text-muted-foreground`,children:W}),t[61]=W,t[62]=ee);let te;t[63]!==H||t[64]!==U||t[65]!==ee?(te=(0,$.jsxs)(`div`,{className:`rounded-lg bg-background/70 px-2.5 py-2`,children:[H,U,ee]}),t[63]=H,t[64]=U,t[65]=ee,t[66]=te):te=t[66];let ne;t[67]!==S||t[68]!==w||t[69]!==L?(ne=w.length>0?w.map(Xd):(0,$.jsxs)($.Fragment,{children:[S?(0,$.jsx)(Hd,{quota:S}):null,L?(0,$.jsx)(Hd,{quota:L}):null]}),t[67]=S,t[68]=w,t[69]=L,t[70]=ne):ne=t[70];let G;t[71]!==te||t[72]!==ne?(G=(0,$.jsxs)($.Fragment,{children:[te,ne]}),t[71]=te,t[72]=ne,t[73]=G):G=t[73];let K=G;if(u){let e;t[74]===B?e=t[75]:(e=(0,$.jsx)(ud,{render:B}),t[74]=B,t[75]=e);let n;t[76]===K?n=t[77]:(n=(0,$.jsx)(dd,{side:`top`,align:`end`,sideOffset:8,className:`w-72 max-w-none items-stretch gap-2 rounded-xl bg-secondary p-3 text-sm text-secondary-foreground`,children:K}),t[76]=K,t[77]=n);let r;return t[78]!==e||t[79]!==n?(r=(0,$.jsxs)(ld,{children:[e,n]}),t[78]=e,t[79]=n,t[80]=r):r=t[80],r}let re;t[81]===B?re=t[82]:(re=(0,$.jsx)(Be,{render:B}),t[81]=B,t[82]=re);let q;t[83]===K?q=t[84]:(q=(0,$.jsx)(d,{side:`top`,align:`end`,sideOffset:8,className:`w-72 max-w-none flex-col items-stretch gap-2 rounded-xl p-3 text-sm`,children:K}),t[83]=K,t[84]=q);let ie;return t[85]!==re||t[86]!==q?(ie=(0,$.jsxs)(f,{children:[re,q]}),t[85]=re,t[86]=q,t[87]=ie):ie=t[87],ie}function Xd(e){return(0,$.jsx)(Ud,{window:e},e.label)}function Zd(e){return e.percent==null?`${e.label}. Usage estimate unavailable.`:`${e.label}. ${bd(e.percent)}% used.`}function Qd(e,t){if(!e)return`Select model`;let n=t.find(t=>t.id===e.id&&t.provider===e.provider);return e.name||n?.name||e.id}function $d(e){switch(e){case`off`:return`Off`;case`minimal`:return`Minimal`;case`low`:return`Low`;case`medium`:return`Medium`;case`high`:return`High`;case`xhigh`:return`Extra High`;default:return e}}function ef(e){return e?`${e.provider}/${e.id}`:``}function tf(e,t){return e.model===t.model&&e.availableModels===t.availableModels}function nf(e,t){return e.thinkingLevel===t.thinkingLevel&&e.availableThinkingLevels===t.availableThinkingLevels}function rf(e){let t=(0,Q.c)(1),n;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n={compare:tf},t[0]=n):n=t[0],ka(e,af,n)}function af(e){return{availableModels:e.availableModels,model:e.model}}function of(e){let t=(0,Q.c)(1),n;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n={compare:nf},t[0]=n):n=t[0],ka(e,sf,n)}function sf(e){return{availableThinkingLevels:e.availableThinkingLevels,thinkingLevel:e.thinkingLevel}}var cf=Z.memo(function({disabled:e,modelQuery:t,onModelQueryChange:n,onOpenChange:r,onSelectModel:i,open:a,sessionStore:o}){let{availableModels:s,model:c}=rf(o),l=(()=>{let e=t.trim().toLowerCase(),n=(s.length>0?s:c?[c]:[]).toSorted((e,t)=>(e.provider||``).localeCompare(t.provider||``)||(e.name||e.id).localeCompare(t.name||t.id));return e?n.filter(t=>`${t.provider||``} ${t.name||``} ${t.id}`.toLowerCase().includes(e)):n})(),u=(()=>{let e=new Map;for(let t of l){let n=t.provider||`Models`,r=e.get(n)??[];r.push(t),e.set(n,r)}return[...e.entries()]})(),d=Qd(c,s);return(0,$.jsxs)(ld,{open:!e&&a,onOpenChange:r,children:[(0,$.jsx)(U,{title:`Model`,kbd:Ir(`Control+M`),children:(0,$.jsxs)(ud,{render:(0,$.jsx)(Y,{variant:`ghost`,className:`max-w-full`,disabled:e}),children:[(0,$.jsx)(`span`,{className:`truncate`,children:d}),(0,$.jsx)(en,{"data-icon":`inline-end`})]})}),(0,$.jsx)(dd,{className:`w-88 p-0`,side:`top`,align:`start`,children:(0,$.jsxs)(xn,{shouldFilter:!1,children:[(0,$.jsx)(Qt,{value:t,onValueChange:n,placeholder:`Search models`}),(0,$.jsxs)(Mn,{children:[(0,$.jsx)(Lt,{children:`No models match your search.`}),u.map(([t,n])=>(0,$.jsx)(An,{heading:t,children:n.map(t=>{let n=`${t.provider}/${t.id}`,a=n===ef(c);return(0,$.jsxs)(On,{value:`${t.provider||``} ${t.name||t.id} ${t.id}`,onSelect:()=>{e||(i(n),r(!1))},children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,$.jsx)(`span`,{className:`truncate font-medium`,children:t.name||t.id}),(0,$.jsxs)(`span`,{className:`truncate text-xs text-muted-foreground`,children:[t.provider,`/`,t.id]})]}),a?(0,$.jsx)(cn,{}):null]},n)})},t))]})]})})]})}),lf=Z.memo(function(e){let t=(0,Q.c)(6),{activeSessionId:n,contextUsageStore:r,disabled:i,sessionStore:a,viewerContextId:o}=e,s=ka(a,ff),c;return t[0]!==n||t[1]!==r||t[2]!==i||t[3]!==s||t[4]!==o?(c=(0,$.jsx)(Yd,{activeSessionId:n,contextUsageStore:r,disabled:i,modelProvider:s,viewerContextId:o}),t[0]=n,t[1]=r,t[2]=i,t[3]=s,t[4]=o,t[5]=c):c=t[5],c}),uf=Z.memo(function(e){let t=(0,Q.c)(30),{disabled:n,onOpenChange:r,onSelectThinkingLevel:i,open:a,sessionStore:o}=e,{availableThinkingLevels:s,thinkingLevel:c}=of(o),l;t[0]===c?l=t[1]:(l=$d(c),t[0]=c,t[1]=l);let u=l,d=!n&&a,f,p;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(f=Ir(`Control+R`),p=Ir(`Control+Shift+R`),t[2]=f,t[3]=p):(f=t[2],p=t[3]);let m;t[4]===n?m=t[5]:(m=(0,$.jsx)(Y,{variant:`ghost`,className:`max-w-full`,disabled:n}),t[4]=n,t[5]=m);let h;t[6]===u?h=t[7]:(h=(0,$.jsx)(`span`,{className:`truncate`,children:u}),t[6]=u,t[7]=h);let g;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,$.jsx)(en,{"data-icon":`inline-end`}),t[8]=g):g=t[8];let _;t[9]!==m||t[10]!==h?(_=(0,$.jsx)(U,{title:`Reasoning`,kbd:`${f} / ${p}`,children:(0,$.jsxs)(ud,{render:m,children:[h,g]})}),t[9]=m,t[10]=h,t[11]=_):_=t[11];let v;if(t[12]!==s||t[13]!==n||t[14]!==r||t[15]!==i||t[16]!==c){let e;t[18]!==n||t[19]!==r||t[20]!==i||t[21]!==c?(e=e=>(0,$.jsxs)(On,{value:e,onSelect:()=>{n||(i(e),r(!1))},children:[(0,$.jsx)(`span`,{className:`flex-1`,children:$d(e)}),c===e?(0,$.jsx)(cn,{}):null]},e),t[18]=n,t[19]=r,t[20]=i,t[21]=c,t[22]=e):e=t[22],v=s.map(e),t[12]=s,t[13]=n,t[14]=r,t[15]=i,t[16]=c,t[17]=v}else v=t[17];let y;t[23]===v?y=t[24]:(y=(0,$.jsx)(dd,{className:`w-64 p-0`,side:`top`,align:`start`,children:(0,$.jsx)(xn,{children:(0,$.jsx)(Mn,{children:(0,$.jsx)(An,{heading:`Reasoning`,children:v})})})}),t[23]=v,t[24]=y);let b;return t[25]!==r||t[26]!==y||t[27]!==d||t[28]!==_?(b=(0,$.jsxs)(ld,{open:d,onOpenChange:r,children:[_,y]}),t[25]=r,t[26]=y,t[27]=d,t[28]=_,t[29]=b):b=t[29],b}),df=Z.memo(function(e){let t=(0,Q.c)(32),{activeSessionId:n,modelPickerOpen:r,onModelPickerOpenChange:i,thinkingPickerOpen:a,onThinkingPickerOpenChange:o,modelQuery:s,onModelQueryChange:c,contextUsageStore:l,sessionStore:u,disabled:d,viewerContextId:f,onSelectModel:p,onSelectThinkingLevel:m}=e,h=d===void 0?!1:d,g;t[0]!==h||t[1]!==i?(g=e=>{h&&e||i(e)},t[0]=h,t[1]=i,t[2]=g):g=t[2];let _=g,v;t[3]!==h||t[4]!==o?(v=e=>{h&&e||o(e)},t[3]=h,t[4]=o,t[5]=v):v=t[5];let y=v,b;t[6]!==h||t[7]!==_||t[8]!==r||t[9]!==s||t[10]!==c||t[11]!==p||t[12]!==u?(b=(0,$.jsx)(cf,{disabled:h,modelQuery:s,onModelQueryChange:c,onOpenChange:_,onSelectModel:p,open:r,sessionStore:u}),t[6]=h,t[7]=_,t[8]=r,t[9]=s,t[10]=c,t[11]=p,t[12]=u,t[13]=b):b=t[13];let x;t[14]!==h||t[15]!==y||t[16]!==m||t[17]!==u||t[18]!==a?(x=(0,$.jsx)(uf,{disabled:h,onOpenChange:y,onSelectThinkingLevel:m,open:a,sessionStore:u}),t[14]=h,t[15]=y,t[16]=m,t[17]=u,t[18]=a,t[19]=x):x=t[19];let S;t[20]!==b||t[21]!==x?(S=(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-1.5`,children:[b,x]}),t[20]=b,t[21]=x,t[22]=S):S=t[22];let C;t[23]!==n||t[24]!==l||t[25]!==h||t[26]!==u||t[27]!==f?(C=(0,$.jsx)(lf,{activeSessionId:n,contextUsageStore:l,disabled:h,sessionStore:u,viewerContextId:f}),t[23]=n,t[24]=l,t[25]=h,t[26]=u,t[27]=f,t[28]=C):C=t[28];let w;return t[29]!==S||t[30]!==C?(w=(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 rounded-b-[18px] bg-muted/15 p-1.5`,children:[S,C]}),t[29]=S,t[30]=C,t[31]=w):w=t[31],w});function ff(e){return e.model?.provider}var pf=new Set([` `,` `,`
6
+ `,`"`,`'`,`=`]);function mf(e=``){let t=typeof e==`string`?e:``,n=t.match(/^\/skill:([^\s]+)(?:\s+([\s\S]*))?$/);return n?{matched:!0,skillName:n[1]||void 0,text:n[2]||``}:{matched:!1,skillName:void 0,text:t}}function hf({text:e=``,skillName:t}){let n=typeof e==`string`?e:``,r=typeof t==`string`?t.trim():``;return r?n?`/skill:${r} ${n}`:`/skill:${r}`:n}function gf(e=``){return e.split(/[-_]+/).flatMap(e=>e?e.length<=3?[e.toUpperCase()]:[`${e.charAt(0).toUpperCase()}${e.slice(1)}`]:[]).join(` `)}function _f(e){let t=e.side===`deletions`?`old`:`new`;return`${e.path}:L${e.lineNumber} (${t})`}function vf(e){let t=e.commit===`working-tree`?`working tree changes`:e.shortHash;return`- ${_f(e)} in ${t}: ${e.text}`}function yf({diffLineComments:e,skillName:t,text:n}){let r=hf({text:n,skillName:t}).trim(),i=e?.filter(e=>e.text.trim().length>0);if(!i||i.length===0)return r;let a=`Diff comments:\n${i.map(vf).join(`
7
+ `)}`;return r?`${r}\n\n${a}`:a}function bf(e=``){let t=typeof e==`string`?e:``,n=t.trimStart();if(!n.startsWith(`/`))return null;let r=n.slice(1),i=r.search(/\s/);return{rawValue:t,trimmedStart:n,name:i>=0?r.slice(0,i):r,args:i>=0?r.slice(i).trim():``,hasArguments:i>=0}}function xf(e=``){return String(e).toLowerCase().replace(/[^a-z0-9]+/g,``)}function Sf(e,t){if(!e)return!0;let n=0;for(let r of t)if(r===e[n]&&(n+=1,n>=e.length))return!0;return!1}function Cf(e){let t=[e.name,e.description||``];return e.kind===`skill`&&t.push(e.skillName||``,`skill${e.skillName||``}`,`skills ${e.skillName||``}`,gf(e.skillName||``)),t.filter(Boolean)}function wf(e,t){return e.indexOf(t)>=0}function Tf(e,t){let n=typeof t==`string`?t.trim().toLowerCase():``;if(!n)return e.kind===`builtin`?0:10;let r=xf(n),i=1/0;for(let t of Cf(e)){let e=String(t).toLowerCase(),a=xf(e);if(e===n){i=Math.min(i,0);continue}if(e.startsWith(n)){i=Math.min(i,1);continue}if(r&&a.startsWith(r)){i=Math.min(i,2);continue}if(wf(e,n)){i=Math.min(i,3);continue}if(r&&wf(a,r)){i=Math.min(i,4);continue}r&&Sf(r,a)&&(i=Math.min(i,5))}return Number.isFinite(i)?i+(e.kind===`builtin`?0:.1):1/0}function Ef(e,t){return e.flatMap(e=>{let n=Tf(e,t);return Number.isFinite(n)?[{command:e,rank:n}]:[]}).sort((e,t)=>e.rank-t.rank||e.command.name.localeCompare(t.command.name)).map(e=>e.command)}function Df(e=``){for(let t=e.length-1;t>=0;--t)if(pf.has(e[t]||``))return t;return-1}function Of(e=``,t=0){for(let n=Math.max(0,t);n<e.length;n+=1)if(pf.has(e[n]||``))return n;return e.length}function kf(e=``){let t=!1,n=-1;for(let r=0;r<e.length;r+=1)e[r]===`"`&&(t=!t,t&&(n=r));return t?n:null}function Af(e=``,t=0){return t===0||pf.has(e[t-1]||``)}function jf(e=``){let t=kf(e);return t===null?null:t>0&&e[t-1]===`@`?Af(e,t-1)?e.slice(t-1):null:Af(e,t)?e.slice(t):null}function Mf(e=``){let t=jf(e);if(t?.startsWith(`@"`))return t;let n=Df(e),r=n===-1?0:n+1;return e[r]===`@`?e.slice(r):null}function Nf(e=``){return e.startsWith(`@"`)?{rawPrefix:e.slice(2),isQuotedPrefix:!0}:e.startsWith(`@`)?{rawPrefix:e.slice(1),isQuotedPrefix:!1}:{rawPrefix:e,isQuotedPrefix:!1}}function Pf(e=``,t=0){let n=e.lastIndexOf(`
8
+ `,Math.max(0,t-1));return e.slice(n+1,t)}function Ff({value:e,selectionStart:t,selectionEnd:n,force:r=!1}){if(t!==n)return null;let i=Pf(e,t).trimStart();if(i.startsWith(`/`)&&!i.includes(` `))return null;let a=e.slice(0,t),o=jf(a);if(o&&!o.startsWith(`@`)){let i=o.slice(1);if(!r&&!i)return null;let a=t-o.length,s=e.slice(t).indexOf(`"`),c=s>=0?t+s+1:t;return{kind:`path`,value:e,selectionStart:t,selectionEnd:n,start:a,end:c,prefix:o,rawPrefix:i,isQuotedPrefix:!0,token:e.slice(a,c)}}let s=Df(a)+1,c=Of(e,t),l=e.slice(s,t);return!r&&!(l.includes(`/`)||l.startsWith(`.`)||l.startsWith(`~`))?null:{kind:`path`,value:e,selectionStart:t,selectionEnd:n,start:s,end:c,prefix:l,rawPrefix:l,isQuotedPrefix:!1,token:e.slice(s,c)}}function If({value:e,selectionStart:t,selectionEnd:n}){if(t!==n)return null;let r=Mf(e.slice(0,t));if(!r)return null;let i=t-r.length,a=e.slice(t),o=r.startsWith(`@"`)?(()=>{let e=a.indexOf(`"`);return e>=0?t+e+1:t})():Of(e,t),s=Nf(r);return{kind:`file-reference`,value:e,selectionStart:t,selectionEnd:n,start:i,end:o,prefix:r,rawPrefix:s.rawPrefix,isQuotedPrefix:s.isQuotedPrefix,token:e.slice(i,o)}}function Lf(e,t){return!e||!t?!1:e.kind===t.kind&&e.start===t.start&&e.end===t.end&&e.prefix===t.prefix}function Rf(e,t){let n=e.value.replace(/\\/g,`/`);return!(t.isQuotedPrefix||n.includes(` `))||n.startsWith(`"`)?n:`"${n}"`}function zf({value:e,query:t,item:n}){let r=e.slice(0,t.start),i=e.slice(t.end),a=t.kind===`path`?Rf(n,t):n.value,o=t.kind===`file-reference`&&!n.isDirectory?` `:``,s=`${r}${a}${o}${i}`,c=a.endsWith(`"`),l=n.isDirectory&&c?a.length-1:a.length,u=r.length+l+o.length;return{value:s,selectionStart:u,selectionEnd:u}}var Bf=1,Vf=5,Hf={scale:1,x:0,y:0};function Uf(e,t,n){return Math.min(n,Math.max(t,e))}function Wf(e,t){return Math.hypot(e.x-t.x,e.y-t.y)}function Gf(e,t){return{x:(e.x+t.x)/2,y:(e.y+t.y)/2}}function Kf(e){let t=(0,Q.c)(51),{open:n,onOpenChange:r,imageSrc:i,imageAlt:a,title:o,description:s,emptyState:c,className:l}=e,u=Z.useRef(null),d=Z.useRef(null),f;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(f=new Map,t[0]=f):f=t[0];let p=Z.useRef(f),m=Z.useRef(!1),h=Z.useRef(null),g=Z.useRef(Hf),[_,v]=Z.useState(Hf),y;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(y=()=>{p.current.clear(),h.current=null,g.current=Hf,v(Hf)},t[1]=y):y=t[1];let b;t[2]!==i||t[3]!==n?(b=[i,n],t[2]=i,t[3]=n,t[4]=b):b=t[4],Z.useEffect(y,b);let x;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(x=function(e){return{x:e.clientX,y:e.clientY}},t[5]=x):x=t[5];let S=x,C;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(C=function(e){let t=u.current;if(!t)return e;let n=t.getBoundingClientRect();return{x:e.x-n.left-n.width/2,y:e.y-n.top-n.height/2}},t[6]=C):C=t[6];let w=C,T;if(t[7]===Symbol.for(`react.memo_cache_sentinel`)){let e=function(e){let t=Uf(e.scale,Bf,Vf);if(t<=Bf)return Hf;let n=u.current,r=d.current;if(!n||!r)return{scale:t,x:e.x,y:e.y};let i=Math.max(0,(r.offsetWidth*t-n.clientWidth)/2),a=Math.max(0,(r.offsetHeight*t-n.clientHeight)/2);return{scale:t,x:Uf(e.x,-i,i),y:Uf(e.y,-a,a)}};T=function(t){let n=e(t);g.current=n,v(n)},t[7]=T}else T=t[7];let D=T,O;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(O=function(e,t){let n=g.current,r=w(t),i=Uf(e,Bf,Vf);if(i<=Bf){D(Hf);return}let a={x:(r.x-n.x)/n.scale,y:(r.y-n.y)/n.scale};D({scale:i,x:r.x-a.x*i,y:r.y-a.y*i})},t[8]=O):O=t[8];let k=O,A;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(A=function(){let e=[...p.current.values()],t=e[0],n=e[1];!t||!n||(h.current={type:`pinch`,startDistance:Wf(t,n),startMidpoint:Gf(t,n),startTransform:g.current})},t[9]=A):A=t[9];let j=A,M;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(M=function(e,t){h.current={type:`pan`,pointerId:e,startPoint:t,startTransform:g.current}},t[10]=M):M=t[10];let N=M,P;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(P=function(e){p.current.delete(e);let t=[...p.current.entries()][0];p.current.size>=2?j():t?N(t[0],t[1]):h.current=null},t[11]=P):P=t[11];let F=P,I;t[12]===i?I=t[13]:(I=function(e){if(m.current=e.target===e.currentTarget,!i)return;e.currentTarget.setPointerCapture(e.pointerId);let t=S(e);p.current.set(e.pointerId,t),p.current.size>=2?j():N(e.pointerId,t)},t[12]=i,t[13]=I);let L=I,R;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(R=function(e){if(!p.current.has(e.pointerId))return;let t=S(e);p.current.set(e.pointerId,t);let n=h.current,r=[...p.current.values()];if(n?.type===`pinch`&&r.length>=2){let e=r[0],t=r[1];if(!e||!t||n.startDistance<=0)return;let i=Wf(e,t),a=Gf(e,t),o=n.startTransform.scale*(i/n.startDistance),s=w(n.startMidpoint),c=w(a),l={x:(s.x-n.startTransform.x)/n.startTransform.scale,y:(s.y-n.startTransform.y)/n.startTransform.scale},u=Uf(o,Bf,Vf);D({scale:u,x:c.x-l.x*u,y:c.y-l.y*u});return}n?.type===`pan`&&n.pointerId===e.pointerId&&D({scale:n.startTransform.scale,x:n.startTransform.x+t.x-n.startPoint.x,y:n.startTransform.y+t.y-n.startPoint.y})},t[14]=R):R=t[14];let z=R,B;t[15]===i?B=t[16]:(B=function(e){if(!i)return;e.preventDefault();let t=Math.exp(-e.deltaY*.0015);k(g.current.scale*t,S(e))},t[15]=i,t[16]=B);let V=B,H;t[17]===i?H=t[18]:(H=function(e){i&&(g.current.scale>Bf?D(Hf):k(2,S(e)))},t[17]=i,t[18]=H);let U=H,W;t[19]===l?W=t[20]:(W=E(`top-0 left-0 h-dvh max-h-dvh w-dvw max-w-none translate-x-0 translate-y-0 overflow-hidden rounded-none bg-transparent p-0 shadow-none ring-0 sm:max-h-dvh sm:max-w-none dark:ring-0`,l),t[19]=l,t[20]=W);let ee;t[21]===o?ee=t[22]:(ee=(0,$.jsx)(Xr,{className:`sr-only`,children:o}),t[21]=o,t[22]=ee);let te;t[23]===s?te=t[24]:(te=s?(0,$.jsx)(wi,{className:`sr-only`,children:s}):null,t[23]=s,t[24]=te);let ne;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(ne=(0,$.jsx)(`div`,{className:`absolute top-4 right-4 z-10 flex items-center gap-2`,children:(0,$.jsxs)(Zr,{render:(0,$.jsx)(Y,{variant:`ghost`,size:`icon`,className:`border border-white/15 bg-black/55 text-white hover:bg-black/80 hover:text-white`}),children:[(0,$.jsx)(si,{}),(0,$.jsx)(`span`,{className:`sr-only`,children:`Close`})]})}),t[25]=ne):ne=t[25];let G,K,re;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(G=e=>F(e.pointerId),K=e=>F(e.pointerId),re=e=>F(e.pointerId),t[26]=G,t[27]=K,t[28]=re):(G=t[26],K=t[27],re=t[28]);let q;t[29]===r?q=t[30]:(q=e=>{m.current&&e.target===e.currentTarget&&r(!1),m.current=!1},t[29]=r,t[30]=q);let ie;t[31]!==c||t[32]!==a||t[33]!==i||t[34]!==_?(ie=i?(0,$.jsx)(`img`,{ref:d,src:i,alt:a,draggable:!1,className:`block max-h-full max-w-full cursor-grab object-contain active:cursor-grabbing`,style:{transform:`translate3d(${_.x}px, ${_.y}px, 0) scale(${_.scale})`}}):(0,$.jsx)(`div`,{className:`rounded-3xl border border-dashed border-border/70 bg-background/95 px-6 py-10 text-sm text-muted-foreground`,children:c||`Unable to load the image preview.`}),t[31]=c,t[32]=a,t[33]=i,t[34]=_,t[35]=ie):ie=t[35];let J;t[36]!==U||t[37]!==L||t[38]!==V||t[39]!==q||t[40]!==ie?(J=(0,$.jsx)(`div`,{ref:u,className:`flex h-full w-full touch-none items-center justify-center overflow-hidden p-4`,onPointerDown:L,onPointerMove:z,onPointerUp:G,onPointerCancel:K,onLostPointerCapture:re,onWheel:V,onDoubleClick:U,onClick:q,children:ie}),t[36]=U,t[37]=L,t[38]=V,t[39]=q,t[40]=ie,t[41]=J):J=t[41];let ae;t[42]!==W||t[43]!==ee||t[44]!==te||t[45]!==J?(ae=(0,$.jsxs)(xi,{showCloseButton:!1,className:W,children:[ee,te,ne,J]}),t[42]=W,t[43]=ee,t[44]=te,t[45]=J,t[46]=ae):ae=t[46];let oe;return t[47]!==r||t[48]!==n||t[49]!==ae?(oe=(0,$.jsx)(ii,{open:n,onOpenChange:r,children:ae}),t[47]=r,t[48]=n,t[49]=ae,t[50]=oe):oe=t[50],oe}var qf={...dr,...Se},Jf=Z.forwardRef(function(e,t){let{render:n,className:r,defaultOpen:i=!1,disabled:a=!1,onOpenChange:o,open:s,style:c,...l}=e,u=Ce(o),d=Nr({open:s,defaultOpen:i,onOpenChange:u,disabled:a}),f=Z.useMemo(()=>({open:d.open,disabled:d.disabled,transitionStatus:d.transitionStatus}),[d.open,d.disabled,d.transitionStatus]),p=Z.useMemo(()=>({...d,onOpenChange:u,state:f}),[d,u,f]),m=H(`div`,e,{state:f,ref:t,props:l,stateAttributesMapping:qf});return(0,$.jsx)(Zn.Provider,{value:p,children:m})}),Yf={...er,...Se},Xf=Z.forwardRef(function(e,t){let{panelId:n,open:r,handleTrigger:i,state:a,disabled:o}=In(),{className:s,disabled:c=o,id:l,render:u,nativeButton:d=!0,style:f,...p}=e,{getButtonProps:m,buttonRef:h}=yi({disabled:c,focusableWhenDisabled:!0,native:d}),g=Z.useMemo(()=>({"aria-controls":r?n:void 0,"aria-expanded":r,onClick:i}),[n,r,i]);return H(`button`,e,{state:a,ref:[t,h],props:[g,p,m],stateAttributesMapping:Yf})}),Zf=function(e){return e.collapsiblePanelHeight=`--collapsible-panel-height`,e.collapsiblePanelWidth=`--collapsible-panel-width`,e}({}),Qf=Z.forwardRef(function(e,t){let{className:n,hiddenUntilFound:r,keepMounted:i,render:a,id:o,style:s,...c}=e,{abortControllerRef:l,animationTypeRef:u,height:d,mounted:f,onOpenChange:p,open:m,panelId:h,panelRef:g,runOnceAnimationsFinish:_,setDimensions:v,setHiddenUntilFound:y,setKeepMounted:b,setMounted:x,setPanelIdState:S,setOpen:C,setVisible:w,state:T,transitionDimensionRef:E,visible:D,width:O,transitionStatus:k}=In(),A=r??!1,j=i??!1;Ye(()=>{if(o)return S(o),()=>{S(void 0)}},[o,S]),Ye(()=>{y(A)},[y,A]),Ye(()=>{b(j)},[b,j]);let{props:M}=Gn({abortControllerRef:l,animationTypeRef:u,externalRef:t,height:d,hiddenUntilFound:A,id:h,keepMounted:j,mounted:f,onOpenChange:p,open:m,panelRef:g,runOnceAnimationsFinish:_,setDimensions:v,setMounted:x,setOpen:C,setVisible:w,transitionDimensionRef:E,visible:D,width:O});_e({open:m&&k===`idle`,ref:g,onComplete(){m&&v({height:void 0,width:void 0})}});let N=H(`div`,e,{state:Z.useMemo(()=>({...T,transitionStatus:k}),[T,k]),ref:[t,g],props:[M,{style:{[Zf.collapsiblePanelHeight]:d===void 0?`auto`:`${d}px`,[Zf.collapsiblePanelWidth]:O===void 0?`auto`:`${O}px`}},c],stateAttributesMapping:qf});return j||A||f?N:null});function $f(e){let t=(0,Q.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,$.jsx)(Jf,{"data-slot":`collapsible`,...n}),t[2]=n,t[3]=r),r}function ep(e){let t=(0,Q.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,$.jsx)(Xf,{"data-slot":`collapsible-trigger`,...n}),t[2]=n,t[3]=r),r}function tp(e){let t=(0,Q.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,$.jsx)(Qf,{"data-slot":`collapsible-content`,...n}),t[2]=n,t[3]=r),r}function np(e){return`${e.previewUrl}:${e.data.slice(0,24)}`}function rp(e){if(typeof e==`string`)return e;if(e==null)return``;try{return JSON.stringify(e)}catch{return``}}function ip(e){switch(e.type){case`text`:return`text:${e.text}`;case`thinking`:return`thinking:${e.text}`;case`tool`:return`tool:${e.callId||e.name||`tool`}:${rp(e.args)}`;case`compaction`:return`compaction:${e.tokensBefore}:${e.estimatedTokensAfter??``}:${e.summary}`;default:return`block`}}function ap(e){return e.streamingBehavior===`steer`?`Steer`:e.queued||e.streamingBehavior===`followUp`?`Queue`:``}function op(e){switch(e){case`bash`:return`Bash`;case`read`:return`Read`;case`write`:return`Write`;case`edit`:return`Edit`;case`grep`:return`Grep`;case`glob`:return`Glob`;case`find`:return`Find`;case`rg`:return`Ripgrep`;case`ls`:case`list`:return`List`;default:return e||`Tool`}}function sp(e){if(e){if(typeof e==`object`)return e;if(typeof e==`string`)try{let t=JSON.parse(e);return t&&typeof t==`object`?t:void 0}catch{return}}}function cp(e,t){let n=e?.[t];return typeof n==`string`&&n.trim()?n.trim():``}function lp(e){if(e.type!==`tool`)return``;if(typeof e.args==`string`&&e.args.trim())return e.args.trim();let t=sp(e.args);return cp(t,`description`)||cp(t,`command`)||cp(t,`path`)||cp(t,`filePath`)||cp(t,`file_path`)}function up(e){if(e.type!==`tool`)return``;let t=sp(e.args),n=cp(t,`path`)||cp(t,`filePath`)||cp(t,`file_path`),r=t?.offset,i=t?.limit;return typeof r==`number`&&typeof i==`number`&&i>0?`${n}:${r}-${r+i-1}`:typeof r==`number`?`${n}:${r}`:typeof i==`number`&&i>0?`${n} limit=${i}`.trim():n}function dp(e){return e.replace(/\s+/g,` `).trim()}function fp(e){return e?e.split(`
9
+ `).length:0}function pp(e,t,n=`${t}s`){return`${e} ${e===1?t:n}`}function mp(e){if(e.type!==`tool`||e.name!==`write`)return;let t=sp(e.args);if(!t)return;let n=cp(t,`path`)||cp(t,`filePath`)||cp(t,`file_path`),r=t.content;return{content:typeof r==`string`?r:void 0,path:n}}function hp(e){let t=mp(e);return t?.path?t.content===void 0?t.path:`${t.path} · ${pp(fp(t.content),`line`)}`:``}function gp(e){if(e.type!==`tool`)return``;let t=e.name===`read`?up(e):e.name===`write`?hp(e):lp(e);return t?dp(t):e.running?`Running`:e.isError?`Failed`:`Done`}function _p(e){let t=e.trim();if(!t)return``;try{let e=JSON.parse(t);if(e&&typeof e==`object`)return JSON.stringify(e,null,2)}catch{}return t}function vp(e){return e.type===`tool`?Oe(e.name,e.args):``}function yp(e){if(e.type!==`tool`)return``;if(e.name===`bash`){let t=vp(e);return t?`$ ${t}`:``}if(typeof e.args==`string`)return _p(e.args);if(e.args==null)return``;try{return JSON.stringify(e.args,null,2)||``}catch{return``}}function bp(e){if(e.type!==`tool`||e.name!==`edit`||!e.details||typeof e.details!=`object`)return``;let t=e.details;return typeof t.patch==`string`?t.patch.trimEnd():``}function xp(e){if(e.type!==`tool`)return``;let t=[],n=bp(e),r=e.output.trimEnd();return n&&t.push(n),r&&(!n||r!==n)&&t.push(r),t.length>0?t.join(`
10
+
11
+ `):e.running?`Running…`:e.isError?`Tool failed with no output.`:`No output available.`}function Sp(e){return e.type===`tool`?be(e.name,e.args):``}function Cp(e){return e.type===`tool`?e.category===`explore`||Ge(e.name,e.args)===`explore`:!1}function wp(e){return Cp(e)}function Tp(e){if(e.type!==`tool`||!e.running||Cp(e))return!1;if(!e.name)return!0;if(e.name===`bash`){let t=Ge(e.name,e.args);return!vp(e)||t!==`explore`&&(et(e.args)||je(e.name,e.args))}return!1}function Ep(e,t){let n=e?.[t],r=typeof n==`number`?n:typeof n==`string`&&n.trim()?Number(n):NaN;return Number.isFinite(r)?r:void 0}function Dp(e){let t=e.replace(/\\/g,`/`).trim();if(!t)return``;let n=t.split(`/`);return n[n.length-1]||t}function Op(e,t){if(t==null)return``;let n=typeof t==`number`?String(t):dp(t);return n?`${e}=${n}`:``}function kp(e,t,n=`${t}s`){return`${e} ${e===1?t:n}`}function Ap(e){let t=0,n=0,r=0;for(let i of e){if(i.name===`read`){t+=1;continue}let e=Sp(i);if(i.name===`ls`||i.name===`list`||e===`ls`){r+=1;continue}n+=1}return[t>0?kp(t,`read`):``,n>0?kp(n,`search`,`searches`):``,r>0?kp(r,`list`):``].filter(Boolean).join(`, `)}function jp(){return`Explore`}function Mp(e){let t=sp(e.args),n=cp(t,`path`)||cp(t,`filePath`)||`/`,r=e.running?`Running`:e.isError?`Failed`:``;switch(e.name){case`read`:return{label:`Read`,details:[Dp(n)||n,Op(`offset`,Ep(t,`offset`)),Op(`limit`,Ep(t,`limit`)),r].filter(Boolean).join(` `)};case`grep`:case`rg`:return{label:e.name===`rg`?`Ripgrep`:`Grep`,details:[n,Op(`pattern`,cp(t,`pattern`)||cp(t,`query`)),Op(`include`,cp(t,`include`)),r].filter(Boolean).join(` `)};case`glob`:return{label:`Glob`,details:[n,Op(`pattern`,cp(t,`pattern`)),r].filter(Boolean).join(` `)};case`find`:return{label:`Find`,details:[n,Op(`pattern`,cp(t,`pattern`)||cp(t,`query`)||cp(t,`name`)),Op(`limit`,Ep(t,`limit`)),r].filter(Boolean).join(` `)};case`ls`:case`list`:return{label:`List`,details:[n,Op(`limit`,Ep(t,`limit`)),r].filter(Boolean).join(` `)};case`bash`:{let t=Sp(e);return{label:t===`rg`?`Ripgrep`:t===`ls`?`List`:t?`${t[0]?.toUpperCase()}${t.slice(1)}`:`Bash`,details:[dp(vp(e)),r].filter(Boolean).join(` `)}}default:return{label:op(e.name),details:gp(e)}}}function Np(e,t){return`${e.renderKey||e.blockKey||ip(e)}:${t}`}function Pp(e,t){if(Object.is(e,t))return!0;if(typeof e!=typeof t||!e||!t||typeof e!=`object`)return!1;if(Array.isArray(e)||Array.isArray(t)){if(!Array.isArray(e)||!Array.isArray(t)||e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1)if(!Pp(e[n],t[n]))return!1;return!0}let n=e,r=t,i=Object.keys(n),a=Object.keys(r);if(i.length!==a.length)return!1;for(let e of i)if(!Object.hasOwn(r,e)||!Pp(n[e],r[e]))return!1;return!0}function Fp(e,t){if(e===t)return!0;if(e.type!==t.type||e.blockKey!==t.blockKey||e.renderKey!==t.renderKey)return!1;switch(e.type){case`text`:return t.type===`text`?e.text===t.text&&!!e.isError==!!t.isError:!1;case`thinking`:return t.type===`thinking`?e.text===t.text&&e.summaryLabel===t.summaryLabel:!1;case`tool`:return t.type===`tool`?e.callId===t.callId&&e.name===t.name&&e.category===t.category&&e.output===t.output&&e.isError===t.isError&&e.running===t.running&&Pp(e.args,t.args)&&Pp(e.details,t.details):!1;case`compaction`:return t.type===`compaction`?e.summary===t.summary&&e.tokensBefore===t.tokensBefore&&e.estimatedTokensAfter===t.estimatedTokensAfter:!1;default:return!1}}function Ip(e){let t=[],n=-1,r=r=>{if(n<0||r<n)return;let i=e.slice(n,r+1).filter(wp),a=i[0];if(!a){n=-1;return}t.push({type:`explore`,key:`explore:${Np(a,n)}`,blocks:i}),n=-1};return e.forEach((e,i)=>{if(wp(e)){n<0&&(n=i);return}r(i-1),t.push({type:`block`,key:Np(e,i),block:e})}),r(e.length-1),t}function Lp(e,t){if(e.type!==t.type||e.key!==t.key)return!1;if(e.type===`block`&&t.type===`block`)return e.blockKey===t.blockKey&&e.blockType===t.blockType;if(e.type!==`explore`||t.type!==`explore`||e.blockKeys.length!==t.blockKeys.length)return!1;for(let n=0;n<e.blockKeys.length;n+=1)if(e.blockKeys[n]!==t.blockKeys[n])return!1;return!0}function Rp(e,t){if(e.length===0)return t;let n=e.length!==t.length,r=[];for(let i=0;i<t.length;i+=1){let a=e[i],o=t[i];if(a&&o&&Lp(a,o)){r.push(a);continue}n=!0,r.push(o)}return n?r:e}function zp(e,t){let n=new Map,r=Ip(e);e.forEach((e,r)=>{let i=Np(e,r),a=t?.blockByKey.get(i);n.set(i,a&&Fp(a,e)?a:e)});let i=r.map(t=>t.type===`block`?{type:`block`,key:t.key,blockKey:t.key,blockType:t.block.type}:{type:`explore`,key:t.key,blockKeys:t.blocks.map(t=>Np(t,e.indexOf(t)))});return{blockByKey:n,groups:t?Rp(t.groups,i):i,revision:(t?.revision??0)+1}}function Bp(e,t){return e.anchorBlockKey===t.anchorBlockKey&&e.hasBlocks===t.hasBlocks&&e.hasFooter===t.hasFooter&&e.streaming===t.streaming&&e.working===t.working&&e.copyText===t.copyText&&e.modelLabel===t.modelLabel}function Vp(e){let t=e,n=new Set;return{getSnapshot:()=>t,setSnapshot:e=>{if(!Bp(t,e)){t=e;for(let e of n)e()}},subscribe:e=>(n.add(e),()=>{n.delete(e)})}}function Hp(e){return e.items.flatMap(t=>t.blocks.filter(t=>oh({block:t,hideThinking:e.hideThinking,hideToolBlocks:e.hideToolBlocks})))}function Up(e){return e.type===`text`||e.type===`compaction`}function Wp(e){return e.flatMap(e=>e.blocks.flatMap(e=>{let t=e.type===`text`?e.text:e.type===`compaction`?e.summary:``;return t.trim()?[t]:[]})).join(`
12
+
13
+ `).trim()}function Gp(e){return e.replace(/^gpt/i,`GPT`)}function Kp(e){let t=e?.model;return t?(t.name||Gp(t.id)).trim():``}function qp(e){for(let t=e.length-1;t>=0;--t){let n=Kp(e[t]);if(n)return n}return``}function Jp(e){return!!e.streaming||e.done===!1||e.blocks.some(e=>e.type===`tool`&&e.running)}function Yp(e){return!!e.streaming}function Xp(e,t){let n=t.findIndex(Up),r=n>=0?t[n]:void 0,i=Wp(e.items),a=qp(e.items),o=e.items.some(Yp),s=e.items.some(Jp),c=!!(i.trim()||a);return{...r?{anchorBlockKey:Np(r,n)}:{},hasBlocks:t.length>0,hasFooter:c,streaming:o,working:s,copyText:i,modelLabel:a}}function Zp(e){let t=zp(e),n=new Set,r=new Map,i=e=>{let t=r.get(e);if(t)for(let e of t)e()};return{getBlock:e=>t.blockByKey.get(e),getBlocks:e=>e.flatMap(e=>{let n=t.blockByKey.get(e);return n?[n]:[]}),getGroups:()=>t.groups,setBlocks:e=>{let r=t,a=zp(e,r),o=r.blockByKey.size!==a.blockByKey.size,s=new Set;for(let e of r.blockByKey.keys())r.blockByKey.get(e)!==a.blockByKey.get(e)&&(s.add(e),o=!0);for(let e of a.blockByKey.keys())r.blockByKey.get(e)!==a.blockByKey.get(e)&&(s.add(e),o=!0);if(!(!o&&r.groups===a.groups)){if(t=a,r.groups!==a.groups)for(let e of n)e();for(let e of s)i(e)}},subscribe:e=>(n.add(e),()=>{n.delete(e)}),subscribeBlocks:(e,t)=>{let n=[...new Set(e)];for(let e of n){let n=r.get(e)??new Set;n.add(t),r.set(e,n)}return()=>{for(let e of n){let n=r.get(e);n&&(n.delete(t),n.size===0&&r.delete(e))}}}}}function Qp(e){return Z.useSyncExternalStore(e.subscribe,e.getGroups,e.getGroups)}function $p(e,t){let n=(0,Q.c)(7),r;n[0]!==t||n[1]!==e?(r=n=>e.subscribeBlocks([t],n),n[0]=t,n[1]=e,n[2]=r):r=n[2];let i,a;return n[3]!==t||n[4]!==e?(i=()=>e.getBlock(t),a=()=>e.getBlock(t),n[3]=t,n[4]=e,n[5]=i,n[6]=a):(i=n[5],a=n[6]),Z.useSyncExternalStore(r,i,a)}var em=[];function tm(e,t){return e===t?!0:!e||!t?!1:e.additions===t.additions&&e.removals===t.removals}function nm(e,t=`tool`){return e?e.type===`tool`&&e.callId?`${t}:call:${e.callId}`:`${t}:block:${e.renderKey||e.blockKey||ip(e)}`:`${t}:missing`}function rm(e){return!e||e.type!==`tool`?null:{name:e.name,running:e.running,isError:e.isError,summary:gp(e),editStats:e.name===`edit`&&!e.running?Mm(bp(e)):null,openStateKey:nm(e)}}function im(e,t){return e===t?!0:!e||!t?!1:e.name===t.name&&e.running===t.running&&e.isError===t.isError&&e.summary===t.summary&&tm(e.editStats,t.editStats)&&e.openStateKey===t.openStateKey}function am(e,t){let n=(0,Q.c)(6),r=Z.useRef(null),i;n[0]!==t||n[1]!==e?(i=()=>{let n=rm(e.getBlock(t)),i=r.current;return im(i,n)?i:(r.current=n,n)},n[0]=t,n[1]=e,n[2]=i):i=n[2];let a=i,o;return n[3]!==t||n[4]!==e?(o=n=>e.subscribeBlocks([t],n),n[3]=t,n[4]=e,n[5]=o):o=n[5],Z.useSyncExternalStore(o,a,a)}function om(e,t,n){let r=(0,Q.c)(8),i;r[0]!==n||r[1]!==t||r[2]!==e?(i=()=>{if(!n)return;let r=e.getBlock(t);return r?.type===`tool`?r:void 0},r[0]=n,r[1]=t,r[2]=e,r[3]=i):i=r[3];let a=i,o;return r[4]!==n||r[5]!==t||r[6]!==e?(o=r=>n?e.subscribeBlocks([t],r):sm,r[4]=n,r[5]=t,r[6]=e,r[7]=o):o=r[7],Z.useSyncExternalStore(o,a,a)}function sm(){}function cm(e,t){return e.getBlocks(t).filter(wp)}function lm(e){return{count:e.length,summary:e.length>0?Ap(e):``,hasRunning:e.some(e=>e.running),hasError:e.some(e=>e.isError),openStateKey:nm(e[0],`explore`)}}function um(e,t){return e.count===t.count&&e.summary===t.summary&&e.hasRunning===t.hasRunning&&e.hasError===t.hasError&&e.openStateKey===t.openStateKey}function dm(e,t){let n=(0,Q.c)(7),r;n[0]===Symbol.for(`react.memo_cache_sentinel`)?(r={count:0,summary:``,hasRunning:!1,hasError:!1,openStateKey:`explore:missing`},n[0]=r):r=n[0];let i=Z.useRef(r),a;n[1]!==t||n[2]!==e?(a=()=>{let n=lm(cm(e,t)),r=i.current;return um(r,n)?r:(i.current=n,n)},n[1]=t,n[2]=e,n[3]=a):a=n[3];let o=a,s;return n[4]!==t||n[5]!==e?(s=n=>e.subscribeBlocks(t,n),n[4]=t,n[5]=e,n[6]=s):s=n[6],Z.useSyncExternalStore(s,o,o)}function fm(e,t){return e.length===t.length&&e.every((e,n)=>e===t[n])}function pm(e,t,n){let r=(0,Q.c)(9),i;r[0]===Symbol.for(`react.memo_cache_sentinel`)?(i={keys:[],blocks:em},r[0]=i):i=r[0];let a=Z.useRef(i),o;r[1]!==n||r[2]!==t||r[3]!==e?(o=()=>{if(!n)return em;let r=cm(e,t),i=a.current;return fm(i.keys,t)&&fm(i.blocks,r)?i.blocks:(a.current={keys:t,blocks:r},r)},r[1]=n,r[2]=t,r[3]=e,r[4]=o):o=r[4];let s=o,c;return r[5]!==n||r[6]!==t||r[7]!==e?(c=r=>n?e.subscribeBlocks(t,r):mm,r[5]=n,r[6]=t,r[7]=e,r[8]=c):c=r[8],Z.useSyncExternalStore(c,s,s)}function mm(){}function hm(e){return e.type!==`compaction`||e.tokensBefore<=0?`Compaction`:e.estimatedTokensAfter&&e.estimatedTokensAfter>0?`Compaction: ${e.tokensBefore.toLocaleString()} → ~${e.estimatedTokensAfter.toLocaleString()} tokens`:`Compaction: Compacted from ${e.tokensBefore.toLocaleString()} tokens`}var gm=[`#3f3f46`,`#ef4444`,`#22c55e`,`#eab308`,`#3b82f6`,`#d946ef`,`#06b6d4`,`#e4e4e7`,`#71717a`,`#f87171`,`#4ade80`,`#facc15`,`#60a5fa`,`#e879f9`,`#22d3ee`,`#fafafa`];function _m(){return{bold:!1,dim:!1,italic:!1,underline:!1}}function vm(e){if(!(!e.bold&&!e.dim&&!e.italic&&!e.underline&&!e.foreground&&!e.background))return{...e}}function ym(e){return e?[e.bold?`1`:`0`,e.dim?`1`:`0`,e.italic?`1`:`0`,e.underline?`1`:`0`,e.foreground||``,e.background||``].join(`;`):``}function bm(e,t,n){if(!t)return;let r=vm(n),i=e[e.length-1];if(i&&ym(i.style)===ym(r)){i.text+=t;return}e.push({text:t,style:r})}function xm(e,t){let n=e.charCodeAt(t),r=n===27,i=n===155;if(!r&&!i)return null;if(i)return Sm(e,t,t+1);let a=e[t+1];if(a===`[`)return Sm(e,t,t+2);if(a===`]`){let n=e.indexOf(`\x07`,t+2),r=e.indexOf(`\x1B\\`,t+2),i=[n,r].filter(e=>e>=0),a=i.length>0?Math.min(...i):-1;return a<0?{kind:`control`,end:t+2}:{kind:`control`,end:a===r?a+2:a+1}}return{kind:`control`,end:Math.min(e.length,t+2)}}function Sm(e,t,n){for(let t=n;t<e.length;t+=1){let r=e.charCodeAt(t);if(r>=64&&r<=126)return{kind:e[t]===`m`?`sgr`:`control`,end:t+1,params:e.slice(n,t)}}return{kind:`control`,end:t+1}}function Cm(e=``){return e?e.replace(/:/g,`;`).split(`;`).map(e=>{if(!e||e.startsWith(`?`))return 0;let t=Number(e);return Number.isFinite(t)?t:0}):[0]}function wm(e){if(typeof e==`number`){if(e>=0&&e<16)return gm[e];if(e>=16&&e<=231){let t=e-16,n=Math.floor(t/36),r=Math.floor(t%36/6),i=t%6,a=e=>e===0?0:55+e*40;return`rgb(${a(n)} ${a(r)} ${a(i)})`}if(e>=232&&e<=255){let t=8+(e-232)*10;return`rgb(${t} ${t} ${t})`}}}function Tm(e,t){let n=e[t+1];if(n===5)return{color:wm(e[t+2]),nextIndex:t+2};if(n===2){let n=e[t+2],r=e[t+3],i=e[t+4];if([n,r,i].every(e=>e>=0&&e<=255))return{color:`rgb(${n} ${r} ${i})`,nextIndex:t+4}}return{color:void 0,nextIndex:t}}function Em(e,t){for(let n=0;n<t.length;n+=1){let r=t[n];if(r===0){Object.assign(e,_m());continue}if(r===1){e.bold=!0;continue}if(r===2){e.dim=!0;continue}if(r===3){e.italic=!0;continue}if(r===4){e.underline=!0;continue}if(r===22){e.bold=!1,e.dim=!1;continue}if(r===23){e.italic=!1;continue}if(r===24){e.underline=!1;continue}if(r===39){e.foreground=void 0;continue}if(r===49){e.background=void 0;continue}if(r>=30&&r<=37){e.foreground=gm[r-30];continue}if(r>=40&&r<=47){e.background=gm[r-40];continue}if(r>=90&&r<=97){e.foreground=gm[8+r-90];continue}if(r>=100&&r<=107){e.background=gm[8+r-100];continue}if(r===38||r===48){let i=Tm(t,n);i.color&&(r===38?e.foreground=i.color:e.background=i.color),n=i.nextIndex}}}function Dm(e,t){for(let n=t;n<e.length;n+=1){let t=e.charCodeAt(n);if(t===27||t===155)return n}return-1}function Om(e){let t=[],n=_m(),r=0;for(;r<e.length;){let i=Dm(e,r);if(i<0){bm(t,e.slice(r),n);break}bm(t,e.slice(r,i),n);let a=xm(e,i);if(!a){r=i+1;continue}a.kind===`sgr`&&Em(n,Cm(a.params)),r=a.end}return t}function km(e){if(e)return{color:e.foreground,backgroundColor:e.background,fontWeight:e.bold?700:void 0,fontStyle:e.italic?`italic`:void 0,opacity:e.dim?.72:void 0,textDecorationLine:e.underline?`underline`:void 0}}function Am(e){let t=(0,Q.c)(4),{text:n}=e,r;t[0]===n?r=t[1]:(r=Om(n).map(jm),t[0]=n,t[1]=r);let i;return t[2]===r?i=t[3]:(i=(0,$.jsx)($.Fragment,{children:r}),t[2]=r,t[3]=i),i}function jm(e){return(0,$.jsx)(`span`,{style:km(e.style),children:e.text},`${e.text}-${JSON.stringify(e.style??{})}`)}function Mm(e){let t={additions:0,removals:0};if(!e)return t;for(let n of e.split(`
14
+ `))n.startsWith(`+++`)||n.startsWith(`---`)||(n.startsWith(`+`)&&(t.additions+=1),n.startsWith(`-`)&&(t.removals+=1));return t}function Nm(e){let t=(0,Q.c)(8),{stats:n}=e;if(!n.additions&&!n.removals)return null;let r=`${n.additions} lines added, ${n.removals} lines removed`,i;t[0]===n.additions?i=t[1]:(i=(0,$.jsxs)(`span`,{className:`text-success`,children:[`+`,n.additions]}),t[0]=n.additions,t[1]=i);let a;t[2]===n.removals?a=t[3]:(a=(0,$.jsxs)(`span`,{className:`text-destructive`,children:[`−`,n.removals]}),t[2]=n.removals,t[3]=a);let o;return t[4]!==r||t[5]!==i||t[6]!==a?(o=(0,$.jsxs)(`span`,{className:`flex shrink-0 items-center gap-2 font-mono text-sm`,"aria-label":r,children:[i,a]}),t[4]=r,t[5]=i,t[6]=a,t[7]=o):o=t[7],o}function Pm(e){let t=(0,Q.c)(11),{isBorderless:n,patch:r}=e,i=n===void 0?!1:n,a=Mr(),o=!i&&`rounded-md border bg-background`,s;t[0]===o?s=t[1]:(s=E(`overflow-hidden text-xs`,o),t[0]=o,t[1]=s);let c;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(c={"--diffs-font-family":`var(--font-mono, ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace)`},t[2]=c):c=t[2];let l;t[3]===a?l=t[4]:(l={...a,diffStyle:`unified`,disableFileHeader:!0,lineDiffType:`word-alt`,maxLineDiffLength:1e3,overflow:`wrap`},t[3]=a,t[4]=l);let u;t[5]!==r||t[6]!==l?(u=(0,$.jsx)(Dr,{patch:r,disableWorkerPool:!0,options:l}),t[5]=r,t[6]=l,t[7]=u):u=t[7];let d;return t[8]!==s||t[9]!==u?(d=(0,$.jsx)(`div`,{className:s,style:c,children:u}),t[8]=s,t[9]=u,t[10]=d):d=t[10],d}function Fm(e){let t=(0,Q.c)(5),{isError:n,text:r}=e,i=(n===void 0?!1:n)&&`text-destructive`,a;t[0]===i?a=t[1]:(a=E(`overflow-x-auto font-mono text-xs leading-5 break-words whitespace-pre-wrap`,i),t[0]=i,t[1]=a);let o;return t[2]!==a||t[3]!==r?(o=(0,$.jsx)(`pre`,{className:a,children:r}),t[2]=a,t[3]=r,t[4]=o):o=t[4],o}function Im(e){return e.scrollHeight-e.clientHeight-e.scrollTop}function Lm(e){e.scrollTop=Math.max(0,e.scrollHeight-e.clientHeight)}function Rm(e){let t=(0,Q.c)(7),{contentKey:n,enabled:r}=e,i=Z.useRef(null),a=Z.useRef(!0),o=Z.useRef(!1),s;t[0]===r?s=t[1]:(s=()=>{let e=i.current;if(!r){o.current=!1;return}o.current||=(a.current=!0,!0),e&&a.current&&Lm(e)},t[0]=r,t[1]=s);let c;t[2]!==n||t[3]!==r?(c=[n,r],t[2]=n,t[3]=r,t[4]=c):c=t[4],Z.useLayoutEffect(s,c);let l;return t[5]===r?l=t[6]:(l={onScroll:e=>{r&&(a.current=Im(e.currentTarget)<1)},ref:i},t[5]=r,t[6]=l),l}var zm=Z.memo(function(e){let t=(0,Q.c)(8),{isError:n,label:r,text:i}=e,a=n===void 0?!1:n,o;t[0]===r?o=t[1]:(o=(0,$.jsx)(`div`,{className:`text-[11px] font-medium tracking-wide text-muted-foreground uppercase`,children:r}),t[0]=r,t[1]=o);let s;t[2]!==a||t[3]!==i?(s=(0,$.jsx)(Fm,{isError:a,text:i}),t[2]=a,t[3]=i,t[4]=s):s=t[4];let c;return t[5]!==o||t[6]!==s?(c=(0,$.jsxs)(`section`,{className:`space-y-1.5`,children:[o,s]}),t[5]=o,t[6]=s,t[7]=c):c=t[7],c});function Bm(e){return e.split(`
15
+ `).filter(e=>!/^Successfully replaced \d+ block\(s\) in .+\.$/.test(e)).join(`
16
+ `).trimEnd()}function Vm(e){return e.split(`
17
+ `).filter(e=>!/^Successfully wrote \d+ bytes to .+$/.test(e)).join(`
18
+ `).trimEnd()}var Hm={bash:`bash`,c:`c`,cc:`c`,cjs:`javascript`,cpp:`c`,css:`css`,cxx:`c`,go:`go`,h:`c`,htm:`html`,html:`html`,java:`java`,js:`javascript`,json:`json`,jsonc:`jsonc`,jsx:`jsx`,mjs:`javascript`,md:`markdown`,mdx:`mdx`,py:`python`,rs:`rust`,sh:`bash`,ts:`typescript`,tsx:`tsx`,txt:`plaintext`,xml:`xml`,yaml:`yaml`,yml:`yaml`,zsh:`bash`},Um={dockerfile:`dockerfile`,makefile:`makefile`};function Wm(e){let t=e.replace(/\\/g,`/`).split(`/`).pop()?.toLowerCase();if(!t)return;let n=Um[t];if(n)return n;if(t.endsWith(`.d.ts`))return`typescript`;let r=t.includes(`.`)?t.split(`.`).pop():``;return r?Hm[r]:void 0}function Gm(e){let t=(0,Q.c)(23),{block:n}=e,r=mp(n),i=r?.content,a;t[0]===n.output?a=t[1]:(a=Vm(n.output.trimEnd()),t[0]=n.output,t[1]=a);let o=a,s=Rm({contentKey:i||``,enabled:n.running&&i!==void 0});if(n.isError){let e;t[2]!==n.output||t[3]!==o?(e=o||n.output.trimEnd()||`Write failed.`,t[2]=n.output,t[3]=o,t[4]=e):e=t[4];let r;return t[5]===e?r=t[6]:(r=(0,$.jsx)(Fm,{isError:!0,text:e}),t[5]=e,t[6]=r),r}if(!r||i===void 0){let e;t[7]===n?e=t[8]:(e=xp(n)||`No content available.`,t[7]=n,t[8]=e);let r;return t[9]===e?r=t[10]:(r=(0,$.jsx)(Fm,{text:e}),t[9]=e,t[10]=r),r}let c=r.path?Wm(r.path):void 0,l;t[11]!==s.onScroll||t[12]!==s.ref||t[13]!==n.running||t[14]!==i||t[15]!==c?(l=(0,$.jsx)(Wn,{className:`flex max-h-96 flex-col rounded-lg`,code:i,language:c,onPreScroll:s.onScroll,preClassName:`min-h-0 overflow-auto`,preRef:s.ref,streaming:n.running}),t[11]=s.onScroll,t[12]=s.ref,t[13]=n.running,t[14]=i,t[15]=c,t[16]=l):l=t[16];let u;t[17]!==n.isError||t[18]!==o?(u=o?(0,$.jsx)(Fm,{isError:n.isError,text:o}):null,t[17]=n.isError,t[18]=o,t[19]=u):u=t[19];let d;return t[20]!==l||t[21]!==u?(d=(0,$.jsxs)(`div`,{className:`space-y-3`,children:[l,u]}),t[20]=l,t[21]=u,t[22]=d):d=t[22],d}function Km(e){let t=(0,Q.c)(18),{block:n}=e,r;t[0]===n?r=t[1]:(r=bp(n),t[0]=n,t[1]=r);let i=r,a;t[2]===n.output?a=t[3]:(a=Bm(n.output.trimEnd()),t[2]=n.output,t[3]=a);let o=a,s=o&&o!==i?o:``,c;t[4]===n?c=t[5]:(c=Bm(xp(n)),t[4]=n,t[5]=c);let l=c,u=!n.running&&!n.isError;if(!i){let e=l||`No output available.`,r;return t[6]!==n.isError||t[7]!==e?(r=(0,$.jsx)(Fm,{isError:n.isError,text:e}),t[6]=n.isError,t[7]=e,t[8]=r):r=t[8],r}let d;t[9]!==u||t[10]!==i?(d=(0,$.jsx)(Pm,{isBorderless:u,patch:i}),t[9]=u,t[10]=i,t[11]=d):d=t[11];let f;t[12]!==n.isError||t[13]!==s?(f=s?(0,$.jsx)(Fm,{isError:n.isError,text:s}):null,t[12]=n.isError,t[13]=s,t[14]=f):f=t[14];let p;return t[15]!==d||t[16]!==f?(p=(0,$.jsxs)(`div`,{className:`space-y-3`,children:[d,f]}),t[15]=d,t[16]=f,t[17]=p):p=t[17],p}function qm(e){let t=(0,Q.c)(30),{block:n}=e,r;t[0]===n?r=t[1]:(r=yp(n),t[0]=n,t[1]=r);let i=r,a;t[2]===n?a=t[3]:(a=xp(n),t[2]=n,t[3]=a);let o=a,s;t[4]!==n.name||t[5]!==n.output||t[6]!==i||t[7]!==o?(s=n.name===`bash`?[i,n.output.trimEnd()].filter(Boolean).join(`
19
+
20
+ `)||i||o:``,t[4]=n.name,t[5]=n.output,t[6]=i,t[7]=o,t[8]=s):s=t[8];let c=s,l=n.name===`bash`&&n.running,u;t[9]!==c||t[10]!==l?(u={contentKey:c,enabled:l},t[9]=c,t[10]=l,t[11]=u):u=t[11];let d=Rm(u),f=n.name===`edit`&&!n.running&&!n.isError,p=n.name===`write`&&!n.isError&&mp(n)?.content!==void 0,m=f||p,h=!f&&`pt-3`,g;t[12]===h?g=t[13]:(g=E(`border-t`,h),t[12]=h,t[13]=g);let _=n.name===`bash`?d.ref:void 0,v=n.name===`bash`?d.onScroll:void 0,y=p?`overflow-hidden rounded-lg`:`max-h-96 overflow-auto`,b=f?`rounded-t-none rounded-b-xl`:m?`rounded-lg`:`rounded-lg border bg-background/80 p-3`,x;t[14]!==y||t[15]!==b?(x=E(y,b),t[14]=y,t[15]=b,t[16]=x):x=t[16];let S;t[17]!==n||t[18]!==i||t[19]!==o||t[20]!==c?(S=n.name===`bash`?(0,$.jsx)(`pre`,{className:E(`overflow-x-auto font-mono text-xs leading-5 break-words whitespace-pre-wrap`,n.isError&&`text-destructive`),children:(0,$.jsx)(Am,{text:c})}):n.name===`write`?(0,$.jsx)(Gm,{block:n}):n.name===`edit`?(0,$.jsx)(Km,{block:n}):(0,$.jsxs)(`div`,{className:`space-y-4`,children:[i?(0,$.jsx)(zm,{label:`Call`,text:i}):null,(0,$.jsx)(zm,{isError:n.isError,label:n.running?`Output (streaming)`:`Output`,text:o})]}),t[17]=n,t[18]=i,t[19]=o,t[20]=c,t[21]=S):S=t[21];let C;t[22]!==x||t[23]!==S||t[24]!==_||t[25]!==v?(C=(0,$.jsx)(`div`,{ref:_,onScroll:v,className:x,children:S}),t[22]=x,t[23]=S,t[24]=_,t[25]=v,t[26]=C):C=t[26];let w;return t[27]!==C||t[28]!==g?(w=(0,$.jsx)(`div`,{className:g,children:C}),t[27]=C,t[28]=g,t[29]=w):w=t[29],w}var Jm=500,Ym=new Map;function Xm(e,t){if(e&&(Ym.delete(e),t))for(Ym.set(e,!0);Ym.size>Jm;){let e=Ym.keys().next().value;if(!e)break;Ym.delete(e)}}function Zm(e){let t=(0,Q.c)(10),n;t[0]===e?n=t[1]:(n=()=>Ym.has(e),t[0]=e,t[1]=n);let[r,i]=Z.useState(n),a,o;t[2]===e?(a=t[3],o=t[4]):(a=()=>{i(Ym.has(e))},o=[e],t[2]=e,t[3]=a,t[4]=o),Z.useEffect(a,o);let s;t[5]===e?s=t[6]:(s=t=>{Xm(e,t),i(t)},t[5]=e,t[6]=s);let c=s,l;return t[7]!==r||t[8]!==c?(l=[r,c],t[7]=r,t[8]=c,t[9]=l):l=t[9],l}var Qm=Z.memo(function(e){let t=(0,Q.c)(4),{blockKey:n,store:r}=e,i=am(r,n);if(!i)return null;let a;return t[0]!==n||t[1]!==i||t[2]!==r?(a=(0,$.jsx)($m,{blockKey:n,header:i,store:r}),t[0]=n,t[1]=i,t[2]=r,t[3]=a):a=t[3],a});function $m(e){let t=(0,Q.c)(33),{blockKey:n,header:r,store:i}=e,[a,o]=Zm(r.openStateKey),s=om(i,n,a),c=r.name===`edit`&&!r.running&&!r.isError,l=r.running&&`border-amber-500/30 bg-amber-500/5`,u=r.isError&&`border-destructive/30 bg-destructive/5`,d=!r.running&&!r.isError&&`bg-muted/20`,f;t[0]!==l||t[1]!==u||t[2]!==d?(f=E(`rounded-xl border text-sm`,l,u,d),t[0]=l,t[1]=u,t[2]=d,t[3]=f):f=t[3];let p;t[4]===r.name?p=t[5]:(p=op(r.name),t[4]=r.name,t[5]=p);let m;t[6]===p?m=t[7]:(m=(0,$.jsx)(`span`,{className:`truncate font-medium whitespace-nowrap text-foreground`,children:p}),t[6]=p,t[7]=m);let h=r.name===`write`&&`tabular-nums`,g;t[8]===h?g=t[9]:(g=E(`truncate text-muted-foreground`,h),t[8]=h,t[9]=g);let _;t[10]!==r.summary||t[11]!==g?(_=(0,$.jsx)(`span`,{className:g,children:r.summary}),t[10]=r.summary,t[11]=g,t[12]=_):_=t[12];let v;t[13]!==m||t[14]!==_?(v=(0,$.jsxs)(`span`,{className:`grid max-w-full min-w-0 flex-1 grid-cols-[auto_minmax(0,1fr)] items-center gap-3 overflow-hidden`,children:[m,_]}),t[13]=m,t[14]=_,t[15]=v):v=t[15];let y;t[16]===r.editStats?y=t[17]:(y=r.editStats?(0,$.jsx)(Nm,{stats:r.editStats}):null,t[16]=r.editStats,t[17]=y);let b,x;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,$.jsx)(qt,{className:`pointer-events-none ml-auto size-4 shrink-0 text-muted-foreground group-aria-expanded/tool-collapsible-trigger:hidden`}),x=(0,$.jsx)(en,{className:`pointer-events-none ml-auto hidden size-4 shrink-0 text-muted-foreground group-aria-expanded/tool-collapsible-trigger:inline`}),t[18]=b,t[19]=x):(b=t[18],x=t[19]);let S;t[20]!==v||t[21]!==y?(S=(0,$.jsxs)(ep,{"data-conversation-tool-collapsible-trigger":`true`,className:`group/tool-collapsible-trigger relative flex w-full min-w-0 items-center justify-between gap-3 overflow-hidden rounded-lg border border-transparent px-3 py-2.5 text-left text-sm font-medium transition-all outline-none hover:no-underline focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 aria-disabled:pointer-events-none aria-disabled:opacity-50`,children:[v,y,b,x]}),t[20]=v,t[21]=y,t[22]=S):S=t[22];let C;t[23]!==s||t[24]!==a||t[25]!==c?(C=a&&s?(0,$.jsx)(tp,{className:`overflow-hidden text-sm data-open:animate-accordion-down data-closed:animate-accordion-up`,children:(0,$.jsx)(`div`,{className:E(`h-(--collapsible-panel-height) data-ending-style:h-0 data-starting-style:h-0`,!c&&`px-3 pt-0 pb-3`),children:(0,$.jsx)(qm,{block:s})})}):null,t[23]=s,t[24]=a,t[25]=c,t[26]=C):C=t[26];let w;return t[27]!==a||t[28]!==o||t[29]!==S||t[30]!==C||t[31]!==f?(w=(0,$.jsxs)($f,{open:a,onOpenChange:o,className:f,children:[S,C]}),t[27]=a,t[28]=o,t[29]=S,t[30]=C,t[31]=f,t[32]=w):w=t[32],w}function eh(e){let t=(0,Q.c)(4),{blocks:n}=e,r;t[0]===n?r=t[1]:(r=n.map(th),t[0]=n,t[1]=r);let i;return t[2]===r?i=t[3]:(i=(0,$.jsx)(`div`,{className:`border-t pt-3`,children:(0,$.jsx)(`div`,{className:`max-h-96 overflow-auto rounded-lg border bg-background/80 p-3`,children:(0,$.jsx)(`div`,{className:`space-y-3`,children:r})})}),t[2]=r,t[3]=i),i}function th(e,t){let n=Mp(e),r=n.details||gp(e);return(0,$.jsxs)(`div`,{className:`grid grid-cols-[auto_minmax(0,1fr)] items-baseline gap-3 text-sm`,children:[(0,$.jsx)(`span`,{className:`truncate font-medium whitespace-nowrap text-foreground`,children:n.label}),(0,$.jsx)(U,{title:r,children:(0,$.jsx)(`span`,{className:E(`truncate text-muted-foreground`,e.isError&&`text-destructive`),children:r})})]},e.blockKey||e.callId||`${e.name||`tool`}:${t}`)}var nh=Z.memo(function(e){let t=(0,Q.c)(21),{blockKeys:n,store:r}=e,i=dm(r,n),[a,o]=Zm(i.openStateKey),s=pm(r,n,a),c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=jp(),t[0]=c):c=t[0];let l=c;if(i.count===0)return null;let u=i.hasRunning&&`border-amber-500/30 bg-amber-500/5`,d=!i.hasRunning&&i.hasError&&`border-destructive/30 bg-destructive/5`,f=!i.hasRunning&&!i.hasError&&`bg-muted/20`,p;t[1]!==u||t[2]!==d||t[3]!==f?(p=E(`rounded-xl border text-sm`,u,d,f),t[1]=u,t[2]=d,t[3]=f,t[4]=p):p=t[4];let m;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,$.jsx)(`span`,{className:`truncate font-medium whitespace-nowrap text-foreground`,children:l}),t[5]=m):m=t[5];let h;t[6]===i.summary?h=t[7]:(h=(0,$.jsxs)(`span`,{className:`grid max-w-full min-w-0 flex-1 grid-cols-[auto_minmax(0,1fr)] items-center gap-3 overflow-hidden`,children:[m,(0,$.jsx)(`span`,{className:`truncate text-muted-foreground`,children:i.summary})]}),t[6]=i.summary,t[7]=h);let g,_;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,$.jsx)(qt,{className:`pointer-events-none ml-auto size-4 shrink-0 text-muted-foreground group-aria-expanded/tool-collapsible-trigger:hidden`}),_=(0,$.jsx)(en,{className:`pointer-events-none ml-auto hidden size-4 shrink-0 text-muted-foreground group-aria-expanded/tool-collapsible-trigger:inline`}),t[8]=g,t[9]=_):(g=t[8],_=t[9]);let v;t[10]===h?v=t[11]:(v=(0,$.jsxs)(ep,{"data-conversation-tool-collapsible-trigger":`true`,className:`group/tool-collapsible-trigger relative flex w-full min-w-0 items-center justify-between gap-3 overflow-hidden rounded-lg border border-transparent px-3 py-2.5 text-left text-sm font-medium transition-all outline-none hover:no-underline focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 aria-disabled:pointer-events-none aria-disabled:opacity-50`,children:[h,g,_]}),t[10]=h,t[11]=v);let y;t[12]!==s||t[13]!==a?(y=a?(0,$.jsx)(tp,{className:`overflow-hidden text-sm data-open:animate-accordion-down data-closed:animate-accordion-up`,children:(0,$.jsx)(`div`,{className:`h-(--collapsible-panel-height) px-3 pt-0 pb-3 data-ending-style:h-0 data-starting-style:h-0`,children:(0,$.jsx)(eh,{blocks:s})})}):null,t[12]=s,t[13]=a,t[14]=y):y=t[14];let b;return t[15]!==a||t[16]!==o||t[17]!==v||t[18]!==y||t[19]!==p?(b=(0,$.jsxs)($f,{open:a,onOpenChange:o,className:p,children:[v,y]}),t[15]=a,t[16]=o,t[17]=v,t[18]=y,t[19]=p,t[20]=b):b=t[20],b}),rh=Z.memo(function(e){let t=(0,Q.c)(10),{block:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsx)(qt,{className:`size-4 text-muted-foreground`}),t[0]=r):r=t[0];let i;t[1]===n?i=t[2]:(i=hm(n),t[1]=n,t[2]=i);let a;t[3]===i?a=t[4]:(a=(0,$.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 text-sm font-medium text-foreground`,children:[r,(0,$.jsx)(`span`,{children:i})]}),t[3]=i,t[4]=a);let o;t[5]===n.summary?o=t[6]:(o=(0,$.jsx)(`div`,{className:`mt-3 border-t pt-3`,children:n.summary.trim()?(0,$.jsx)(lr,{text:n.summary}):(0,$.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:`No compaction summary available.`})}),t[5]=n.summary,t[6]=o);let s;return t[7]!==a||t[8]!==o?(s=(0,$.jsxs)(`details`,{className:`rounded-xl border bg-muted/20 px-3 py-2`,children:[a,o]}),t[7]=a,t[8]=o,t[9]=s):s=t[9],s}),ih=Z.memo(function(e){let t=(0,Q.c)(20),{item:n}=e,r;t[0]===n?r=t[1]:(r=ap(n),t[0]=n,t[1]=r);let i=r,[a,o]=Z.useState(null),s=a===null?null:n.images[a]??null,c;t[2]===i?c=t[3]:(c=i?(0,$.jsx)(`div`,{className:`mb-2 flex items-center gap-2`,children:(0,$.jsx)(bs,{variant:`outline`,className:`border-primary-foreground/35 bg-primary-foreground/10 text-primary-foreground`,children:i})}):null,t[2]=i,t[3]=c);let l;t[4]===n.text?l=t[5]:(l=n.text?(0,$.jsx)(`div`,{className:`text-sm break-words whitespace-pre-wrap text-primary-foreground`,children:n.text}):(0,$.jsx)(`div`,{className:`text-sm text-primary-foreground/80`,children:`Image prompt`}),t[4]=n.text,t[5]=l);let u;t[6]===n.images?u=t[7]:(u=n.images.length>0?(0,$.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-3`,children:n.images.map((e,t)=>(0,$.jsxs)(`button`,{type:`button`,className:`max-w-full cursor-zoom-in overflow-hidden rounded-lg border border-primary-foreground/20 bg-primary-foreground/10 p-0 transition hover:opacity-90 focus-visible:ring-2 focus-visible:ring-primary-foreground/70 focus-visible:ring-offset-2 focus-visible:ring-offset-primary focus-visible:outline-none`,onClick:()=>o(t),children:[(0,$.jsx)(`img`,{src:e.previewUrl,alt:`Prompt upload`,className:`block h-28 max-w-full object-cover`}),(0,$.jsx)(`span`,{className:`sr-only`,children:`Open prompt upload`})]},`${np(e)}:${t}`))}):null,t[6]=n.images,t[7]=u);let d;t[8]!==c||t[9]!==l||t[10]!==u?(d=(0,$.jsxs)(`div`,{className:`relative rounded-3xl bg-primary px-5 py-2.5 text-primary-foreground before:absolute before:-right-1.75 before:bottom-0 before:h-5.5 before:w-4 before:rounded-bl-[16px_14px] before:bg-primary before:content-[''] after:absolute after:-right-6.5 after:bottom-0 after:h-6.25 after:w-6.5 after:rounded-bl-[10px] after:bg-background after:content-['']`,children:[c,l,u]}),t[8]=c,t[9]=l,t[10]=u,t[11]=d):d=t[11];let f;t[12]===n.text?f=t[13]:(f=(0,$.jsx)(ah,{copyText:n.text}),t[12]=n.text,t[13]=f);let p;t[14]===s?p=t[15]:(p=s?(0,$.jsx)(Kf,{open:!0,onOpenChange:e=>{e||o(null)},imageSrc:s.previewUrl,imageAlt:`Prompt upload`,title:`Prompt upload preview`,description:`Expanded preview of an image attached to a user message.`}):null,t[14]=s,t[15]=p);let m;return t[16]!==d||t[17]!==f||t[18]!==p?(m=(0,$.jsxs)(`div`,{className:`mr-2 ml-auto w-fit max-w-[80%]`,children:[d,f,p]}),t[16]=d,t[17]=f,t[18]=p,t[19]=m):m=t[19],m});function ah(e){let t=(0,Q.c)(2),{copyText:n}=e;if(!n.trim())return null;let r;return t[0]===n?r=t[1]:(r=(0,$.jsx)(`div`,{className:`mt-1 flex justify-end gap-1.5 text-xs font-medium text-muted-foreground`,children:(0,$.jsx)(mh,{idleLabel:`Copy user message`,text:n})}),t[0]=n,t[1]=r),r}function oh({block:e,hideThinking:t,hideToolBlocks:n}){switch(e.type){case`text`:return!!e.text.trim();case`compaction`:return!0;case`thinking`:return!t;case`tool`:return!n&&!Tp(e);default:return!1}}function sh({item:e,hideThinking:t,hideToolBlocks:n}){return e.blocks.some(e=>oh({block:e,hideThinking:t,hideToolBlocks:n}))}function ch(e){return!!(e.model||Wp([e]))}var lh=Z.memo(function(e){let t=(0,Q.c)(17),{anchorBlockKey:n,descriptor:r,store:i,streaming:a}=e;if(r.type===`explore`){let e;return t[0]!==r.blockKeys||t[1]!==i?(e=(0,$.jsx)(uh,{blockKeys:r.blockKeys,store:i}),t[0]=r.blockKeys,t[1]=i,t[2]=e):e=t[2],e}let o;t[3]!==r.blockKey||t[4]!==r.blockType||t[5]!==i||t[6]!==a?(o=(0,$.jsx)(dh,{blockKey:r.blockKey,blockType:r.blockType,store:i,streaming:a}),t[3]=r.blockKey,t[4]=r.blockType,t[5]=i,t[6]=a,t[7]=o):o=t[7];let s=o,c;t[8]!==r.blockKey||t[9]!==r.blockType?(c={"data-conversation-assistant-block":`true`,"data-conversation-assistant-block-key":r.blockKey,"data-conversation-assistant-block-type":r.blockType},t[8]=r.blockKey,t[9]=r.blockType,t[10]=c):c=t[10];let l=c;if(r.blockKey!==n){let e;return t[11]!==l||t[12]!==s?(e=(0,$.jsx)(`div`,{...l,children:s}),t[11]=l,t[12]=s,t[13]=e):e=t[13],e}let u;return t[14]!==l||t[15]!==s?(u=(0,$.jsx)(`div`,{"data-message-anchor":`true`,...l,children:s}),t[14]=l,t[15]=s,t[16]=u):u=t[16],u});function uh(e){let t=(0,Q.c)(8),{blockKeys:n,store:r}=e,i;t[0]===n?i=t[1]:(i=n.join(`|`),t[0]=n,t[1]=i);let a=`explore:${i}`,o;t[2]!==n||t[3]!==r?(o=(0,$.jsx)(nh,{blockKeys:n,store:r}),t[2]=n,t[3]=r,t[4]=o):o=t[4];let s;return t[5]!==a||t[6]!==o?(s=(0,$.jsx)(`div`,{"data-conversation-assistant-block":`true`,"data-conversation-assistant-block-key":a,"data-conversation-assistant-block-type":`tool`,children:o}),t[5]=a,t[6]=o,t[7]=s):s=t[7],s}function dh(e){let t=(0,Q.c)(8),{blockKey:n,blockType:r,store:i,streaming:a}=e;if(r===`tool`){let e;return t[0]!==n||t[1]!==i?(e=(0,$.jsx)(Qm,{blockKey:n,store:i}),t[0]=n,t[1]=i,t[2]=e):e=t[2],e}let o;return t[3]!==n||t[4]!==r||t[5]!==i||t[6]!==a?(o=(0,$.jsx)(fh,{blockKey:n,blockType:r,store:i,streaming:a}),t[3]=n,t[4]=r,t[5]=i,t[6]=a,t[7]=o):o=t[7],o}function fh(e){let t=(0,Q.c)(9),{blockKey:n,blockType:r,store:i,streaming:a}=e,o=$p(i,n);if(!o||o.type!==r)return null;switch(o.type){case`text`:{let e;return t[0]!==o.isError||t[1]!==o.text||t[2]!==a?(e=o.isError?(0,$.jsx)(`div`,{className:`text-sm leading-6 wrap-break-word whitespace-pre-wrap text-destructive`,children:o.text}):(0,$.jsx)(lr,{text:o.text,streaming:a}),t[0]=o.isError,t[1]=o.text,t[2]=a,t[3]=e):e=t[3],e}case`thinking`:{let e;return t[4]!==o.text||t[5]!==a?(e=(0,$.jsx)(`section`,{className:`border-l-2 border-amber-500/45 pl-4 text-sm text-muted-foreground`,children:(0,$.jsx)(lr,{text:o.text,streaming:a})}),t[4]=o.text,t[5]=a,t[6]=e):e=t[6],e}case`compaction`:{let e;return t[7]===o?e=t[8]:(e=(0,$.jsx)(rh,{block:o}),t[7]=o,t[8]=e),e}default:return null}}function ph(e){let t=(0,Q.c)(11),{anchorBlockKey:n,store:r,streaming:i}=e,a=Qp(r),o;if(t[0]!==n||t[1]!==a||t[2]!==r||t[3]!==i){let e;t[5]!==n||t[6]!==r||t[7]!==i?(e=e=>(0,$.jsx)(lh,{anchorBlockKey:n,descriptor:e,store:r,streaming:i},e.key),t[5]=n,t[6]=r,t[7]=i,t[8]=e):e=t[8],o=a.map(e),t[0]=n,t[1]=a,t[2]=r,t[3]=i,t[4]=o}else o=t[4];let s;return t[9]===o?s=t[10]:(s=(0,$.jsx)($.Fragment,{children:o}),t[9]=o,t[10]=s),s}function mh(e){let t=(0,Q.c)(18),{className:n,idleLabel:r,text:i}=e,[a,o]=Z.useState(`idle`),s;t[0]===i?s=t[1]:(s=i.trim(),t[0]=i,t[1]=s);let c=!!s,l;t[2]!==c||t[3]!==i?(l=async()=>{if(c)try{await jr(i),o(`copied`),window.setTimeout(()=>o(`idle`),1400)}catch{o(`error`),window.setTimeout(()=>o(`idle`),1400)}},t[2]=c,t[3]=i,t[4]=l):l=t[4];let u=l,d=a===`copied`?`Copied`:a===`error`?`Retry copy`:r,f;t[5]===n?f=t[6]:(f=E(`text-muted-foreground`,n),t[5]=n,t[6]=f);let p=!c,m;t[7]===a?m=t[8]:(m=a===`copied`?(0,$.jsx)(cn,{}):(0,$.jsx)(un,{}),t[7]=a,t[8]=m);let h;t[9]!==u||t[10]!==d||t[11]!==f||t[12]!==p||t[13]!==m?(h=(0,$.jsx)(Y,{variant:`ghost`,size:`icon-xs`,className:f,disabled:p,"aria-label":d,onClick:u,children:m}),t[9]=u,t[10]=d,t[11]=f,t[12]=p,t[13]=m,t[14]=h):h=t[14];let g;return t[15]!==d||t[16]!==h?(g=(0,$.jsx)(U,{title:d,children:h}),t[15]=d,t[16]=h,t[17]=g):g=t[17],g}function hh(e){let t=(0,Q.c)(10),{copyText:n,modelLabel:r,streaming:i}=e;if(i)return null;let a;t[0]===n?a=t[1]:(a=n.trim(),t[0]=n,t[1]=a);let o=!!a;if(!o&&!r)return null;let s;t[2]!==n||t[3]!==o?(s=o?(0,$.jsx)(mh,{className:`-ml-2`,idleLabel:`Copy assistant message`,text:n}):null,t[2]=n,t[3]=o,t[4]=s):s=t[4];let c;t[5]===r?c=t[6]:(c=r?(0,$.jsx)(`span`,{className:`truncate`,children:r}):null,t[5]=r,t[6]=c);let l;return t[7]!==s||t[8]!==c?(l=(0,$.jsxs)(`div`,{className:`-mt-2 flex items-center gap-1.5 text-xs font-medium text-muted-foreground`,children:[s,c]}),t[7]=s,t[8]=c,t[9]=l):l=t[9],l}function gh({className:e,hideFooter:t=!1,store:n}){let r=n.getSnapshot(),i=Hp(r),a=Z.useRef(null);a.current||=Zp(i);let o=a.current,s=Z.useRef(null);s.current||=Vp(Xp(r,i));let c=s.current;Z.useLayoutEffect(()=>{let e=()=>{let e=n.getSnapshot(),t=Hp(e);o.setBlocks(t),c.setSnapshot(Xp(e,t))};return e(),n.subscribe(e)},[o,c,n]);let l=Z.useSyncExternalStore(c.subscribe,c.getSnapshot,c.getSnapshot),u=!!(!t&&!l.working&&l.hasFooter);return!l.hasBlocks&&!u?null:(0,$.jsxs)(`div`,{className:E(`flex flex-col gap-4`,e),"data-conversation-assistant-group":`true`,"data-conversation-streaming":l.streaming?`true`:void 0,children:[l.hasBlocks?(0,$.jsx)(ph,{anchorBlockKey:l.anchorBlockKey,store:o,streaming:l.streaming}):null,u?(0,$.jsx)(hh,{copyText:l.copyText,modelLabel:l.modelLabel,streaming:l.streaming}):null]})}function _h(e=0){let t=e,n=new Set;return{getSnapshot:()=>t,subscribe:e=>(n.add(e),()=>{n.delete(e)}),set:e=>{Object.is(t,e)||(t=e,n.forEach(e=>e()))}}}function vh(e,t){let n=bf(e);if(!n)return null;let r=t.find(e=>e.name===n.name);return r?{command:r,args:n.args}:null}function yh({draftText:e,draftSkill:t,slashCommands:n}){if(t)return null;let r=bf(e);if(!r||r.hasArguments)return null;let i=Ef(n,r.name);return i.length===0?null:{...r,commands:i}}function bh(e,t){return e.start===t.start&&e.end===t.end}function xh(e,t){return e.kind!==t.kind||e.name!==t.name?!1:e.kind===`skill`&&t.kind===`skill`?e.skillName===t.skillName:!0}function Sh(e,t){return e===t?!0:!e||!t||e.rawValue!==t.rawValue||e.name!==t.name||e.args!==t.args||e.hasArguments!==t.hasArguments?!1:e.commands.length===t.commands.length&&e.commands.every((e,n)=>{let r=t.commands[n];return!!(r&&xh(e,r))})}function Ch(e,t){return e===t?!0:!e||!t?!1:Lf(e,t)}function wh(e,t){switch(t.type){case`clear`:return e&&null;case`loaded`:{let n=t.items.filter(e=>!!e.value);if(n.length===0)return e&&null;let r=e&&Lf(e.query,t.query)?e.items[e.selectedIndex]||e.items[0]:null,i=r?Math.max(0,n.findIndex(e=>e.value===r.value)):0;return{query:t.query,items:n,selectedIndex:i>=0?i:0}}case`move-selection`:{if(!e)return e;let n=e.items.length;return{...e,selectedIndex:(e.selectedIndex+t.direction+n)%n}}case`select`:return e&&{...e,selectedIndex:t.index};default:return e}}function Th({draftText:e,selection:t}){return If({value:e,selectionStart:t.start,selectionEnd:t.end})??Ff({value:e,selectionStart:t.start,selectionEnd:t.end})}function Eh({draftTextRef:e,draftSkillRef:t,selectionRef:n,promptRef:r,slashCommands:i,requestPathCompletions:a,requestFileCompletions:o,applyDraft:s}){let[c,l]=Z.useState(null),u=Z.useRef(null),[d,f]=Z.useReducer(wh,null),p=Z.useRef(0),m=Z.useRef({requestFileCompletions:o,requestPathCompletions:a});m.current={requestFileCompletions:o,requestPathCompletions:a};let h=Z.useRef(null);h.current||=new so(async e=>{let{requestFileCompletions:t,requestPathCompletions:n}=m.current;return e.kind===`file-reference`?await t(e.rawPrefix,e.isQuotedPrefix):await n(e.rawPrefix)},{key:`pico.composer.completions`,wait:80});let g=h.current,[_,v]=Z.useState(null),y=Z.useRef(null),b=Z.useRef(0),x=Z.useRef(_h()),S=Z.useCallback(e=>{b.current=e,x.current.set(e)},[]),C=Z.useCallback(()=>{let r=e.current,a=t.current,o=n.current,s=yh({draftText:r,draftSkill:a,slashCommands:i});Sh(y.current,s)||(y.current=s,v(s));let c=Th({draftText:r,selection:o});Ch(u.current,c)||(p.current+=1,u.current=c,l(c),c||f({type:`clear`}))},[t,e,n,i]);Z.useEffect(()=>{C()},[C]),Z.useEffect(()=>{let e=b.current;S(_?Math.max(0,Math.min(_.commands.length-1,e)):0)},[S,_]),Z.useEffect(()=>{if(!c){p.current+=1,g.cancel(),f({type:`clear`});return}let e=++p.current;(async()=>{try{let t=await g.maybeExecute(c);if(e!==p.current)return;f({type:`loaded`,query:c,items:t??[]})}catch{e===p.current&&f({type:`clear`})}})()},[g,c]),Z.useEffect(()=>()=>{g.cancel(),g.abort()},[g]);let w=Z.useCallback(()=>{p.current+=1,g.cancel(),u.current=null,y.current=null,l(e=>e&&null),f({type:`clear`}),v(e=>e&&null),S(0)},[g,S]),T=d?.items.length?d:null,E=T?T.items[T.selectedIndex]||T.items[0]:null,D=Z.useCallback(()=>{let e=y.current;return e&&(e.commands[b.current]||e.commands[0])||null},[]),O=Z.useCallback(()=>{let e=r.current;if(!e)return;let t={start:e.selectionStart,end:e.selectionEnd};bh(n.current,t)||(n.current=t,C())},[r,C,n]),k=Z.useCallback((e,t=e)=>{requestAnimationFrame(()=>{r.current?.focus(),r.current?.setSelectionRange(e,t),n.current={start:e,end:t},C()})},[r,C,n]),A=Z.useCallback((t,n=T?.query)=>{if(!n)return!1;let r=zf({value:e.current,query:n,item:t}),i=mf(r.value);return s(i.matched?i.text:r.value,i.matched?i.skillName:void 0,{selection:{start:r.selectionStart,end:r.selectionEnd}}),w(),k(r.selectionStart,r.selectionEnd),!0},[s,w,e,k,T?.query]),j=Z.useCallback(t=>{if(!t)return!1;if(t.kind===`skill`)return s(``,t.skillName,{immediate:!0,selection:{start:0,end:0}}),w(),requestAnimationFrame(()=>r.current?.focus()),!0;let i=`${e.current.match(/^\s*/)?.[0]||``}/${t.name} `,a=i.length;return s(i,void 0,{selection:{start:a,end:a}}),w(),requestAnimationFrame(()=>{r.current?.focus(),r.current?.setSelectionRange(a,a),n.current={start:a,end:a},C()}),!0},[s,w,e,r,C,n]),M=Z.useCallback(e=>{f({type:`select`,index:e})},[]),N=Z.useCallback(e=>{f({type:`move-selection`,direction:e})},[]),P=Z.useCallback(e=>{let t=y.current?.commands.length||0;if(t===0){S(0);return}S((b.current+e+t)%t)},[S]);return{visibleCompletion:T,selectedCompletionItem:E,slashMenuState:_,slashSelectionStore:x.current,getSelectedSlashCommand:D,syncSelection:O,applyCompletion:A,applySlashSuggestion:j,selectCompletionIndex:M,moveCompletionSelection:N,selectSlashIndex:S,moveSlashSelection:P,dismissMenus:w,refreshAssistState:C}}function Dh(e){if(!e)return!1;let t=e.selectionStart,n=e.selectionEnd;return t===0&&n===0}function Oh({availableSkills:e,hideThinkingBlock:t,hideToolBlocks:n}){return[{kind:`builtin`,name:`login`,description:`Configure provider authentication`},{kind:`builtin`,name:`logout`,description:`Remove provider authentication`},{kind:`builtin`,name:`compact`,description:`Summarize the session to reduce context size`},{kind:`builtin`,name:`clone`,description:`Duplicate the current active branch into a new session`},{kind:`builtin`,name:`delete`,description:`Delete the current session`},{kind:`builtin`,name:`fork`,description:`Create a new session from a previous message`},{kind:`builtin`,name:`tree`,description:`Navigate to an earlier point in the current session tree`},{kind:`builtin`,name:`rename`,description:`Rename the current session`},...t?[{kind:`builtin`,name:`show-thinking`,description:`Show assistant thinking blocks`}]:[{kind:`builtin`,name:`hide-thinking`,description:`Hide assistant thinking blocks`}],...n?[{kind:`builtin`,name:`show-tools`,description:`Show assistant tool calls`}]:[{kind:`builtin`,name:`hide-tools`,description:`Hide assistant tool calls`}],...e.map(e=>({kind:`skill`,name:`skill:${e.name}`,skillName:e.name,description:e.description||`Use this skill`,scope:e.scope,source:e.source}))]}function kh(e){let t=(0,Q.c)(5),{displaySettingsStore:n,sessionStore:r}=e,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i={compare:ba},t[0]=i):i=t[0];let{availableSkills:a,hideThinkingBlock:o}=ka(r,jh,i),s=ka(n,Ah),c;return t[1]!==a||t[2]!==o||t[3]!==s?(c=Oh({availableSkills:a,hideThinkingBlock:o,hideToolBlocks:s}),t[1]=a,t[2]=o,t[3]=s,t[4]=c):c=t[4],c}function Ah(e){return e.hideToolBlocks}function jh(e){return{availableSkills:e.availableSkills,hideThinkingBlock:e.hideThinkingBlock}}var Mh={modelPickerOpen:!1,thinkingPickerOpen:!1,modelQuery:``};function Nh(e,t){switch(t.type){case`openModel`:return{...e,modelPickerOpen:!0,thinkingPickerOpen:!1};case`openThinking`:return{...e,modelPickerOpen:!1,thinkingPickerOpen:!0};case`setModelOpen`:return{...e,modelPickerOpen:t.open,modelQuery:t.open?e.modelQuery:``};case`setThinkingOpen`:return{...e,thinkingPickerOpen:t.open};case`setModelQuery`:return{...e,modelQuery:t.query};case`syncDisabled`:return t.disabled?{...e,modelPickerOpen:!1,thinkingPickerOpen:!1,modelQuery:``}:!e.modelPickerOpen&&e.modelQuery?{...e,modelQuery:``}:e}}function Ph(e){let t=Array.from(e.items).flatMap(e=>{if(e.kind!==`file`||!e.type.startsWith(`image/`))return[];let t=e.getAsFile();return t?.type.startsWith(`image/`)?[t]:[]});return t.length>0?t:Array.from(e.files).filter(e=>e.type.startsWith(`image/`))}function Fh(e){let t=(0,Q.c)(71),{activeSessionId:n,currentPendingMessages:r,composerDiffLineComments:i,composerImages:a,composerText:o,composerSkill:s,composerSyncNonce:c,canStartPendingQueue:l,centerMessages:u,contextUsageStore:d,displaySettingsStore:f,sessionStore:p,isSubmitting:m,isCompacting:h,isStreaming:g,awaitingFirstTurn:_,disabled:v,flush:y,topContent:b,viewerContextId:x,fileInputRef:S,onComposerTextChange:C,onPickImages:w,onRemoveComposerDiffLineComment:T,onRemoveComposerImage:E,onSubmitPrompt:D,onAbort:O,onEditPendingMessage:k,onRemovePendingMessage:A,onReorderPending:j,onStartPendingQueue:M,onRunBuiltinSlashCommand:N,onSelectModel:P,onSelectThinkingLevel:F,requestPathCompletions:I,requestFileCompletions:L,ref:R}=e,z=v===void 0?!1:v,B=y===void 0?!1:y,V=Z.useRef(null),[H,U]=Z.useReducer(Nh,Mh),{modelPickerOpen:W,thinkingPickerOpen:ee,modelQuery:te}=H,ne,G;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(ne=()=>({focusPrompt:e=>{V.current?.focus(e)},openModelPicker:()=>{U({type:`openModel`})},openThinkingPicker:()=>{U({type:`openThinking`})}}),G=[],t[0]=ne,t[1]=G):(ne=t[0],G=t[1]),Z.useImperativeHandle(R,ne,G);let K;t[2]===z?K=t[3]:(K=()=>{U({type:`syncDisabled`,disabled:z})},t[2]=z,t[3]=K);let re;t[4]!==z||t[5]!==W?(re=[z,W],t[4]=z,t[5]=W,t[6]=re):re=t[6],Z.useEffect(K,re);let q=u||B?`mx-auto flex w-full max-w-[80ch] flex-col ${u?`gap-1.5`:`gap-3`}`:`flex w-full flex-col gap-3`,ie;t[7]!==l||t[8]!==r||t[9]!==k||t[10]!==A||t[11]!==j||t[12]!==M?(ie=(0,$.jsx)(Hu,{currentPendingMessages:r,canStartQueue:l,onEditPendingMessage:k,onRemovePendingMessage:A,onReorderPending:j,onStartPendingQueue:M}),t[7]=l,t[8]=r,t[9]=k,t[10]=A,t[11]=j,t[12]=M,t[13]=ie):ie=t[13];let J;t[14]!==_||t[15]!==i||t[16]!==a||t[17]!==s||t[18]!==c||t[19]!==o||t[20]!==z||t[21]!==f||t[22]!==S||t[23]!==h||t[24]!==g||t[25]!==m||t[26]!==O||t[27]!==C||t[28]!==w||t[29]!==T||t[30]!==E||t[31]!==N||t[32]!==D||t[33]!==L||t[34]!==I||t[35]!==p?(J=(0,$.jsx)(Lh,{composerDiffLineComments:i,composerImages:a,composerText:o,composerSkill:s,composerSyncNonce:c,isSubmitting:m,isCompacting:h,isStreaming:g,awaitingFirstTurn:_,disabled:z,fileInputRef:S,promptRef:V,displaySettingsStore:f,sessionStore:p,onComposerTextChange:C,onPickImages:w,onRemoveComposerDiffLineComment:T,onRemoveComposerImage:E,onSubmitPrompt:D,onAbort:O,onRunBuiltinSlashCommand:N,requestPathCompletions:I,requestFileCompletions:L}),t[14]=_,t[15]=i,t[16]=a,t[17]=s,t[18]=c,t[19]=o,t[20]=z,t[21]=f,t[22]=S,t[23]=h,t[24]=g,t[25]=m,t[26]=O,t[27]=C,t[28]=w,t[29]=T,t[30]=E,t[31]=N,t[32]=D,t[33]=L,t[34]=I,t[35]=p,t[36]=J):J=t[36];let ae;t[37]===Symbol.for(`react.memo_cache_sentinel`)?(ae=e=>U({type:`setModelOpen`,open:e}),t[37]=ae):ae=t[37];let oe;t[38]===Symbol.for(`react.memo_cache_sentinel`)?(oe=e=>U({type:`setThinkingOpen`,open:e}),t[38]=oe):oe=t[38];let se;t[39]===Symbol.for(`react.memo_cache_sentinel`)?(se=e=>U({type:`setModelQuery`,query:e}),t[39]=se):se=t[39];let ce;t[40]!==n||t[41]!==d||t[42]!==z||t[43]!==W||t[44]!==te||t[45]!==P||t[46]!==F||t[47]!==p||t[48]!==ee||t[49]!==x?(ce=(0,$.jsx)(df,{activeSessionId:n,modelPickerOpen:W,onModelPickerOpenChange:ae,thinkingPickerOpen:ee,onThinkingPickerOpenChange:oe,modelQuery:te,onModelQueryChange:se,contextUsageStore:d,sessionStore:p,disabled:z,viewerContextId:x,onSelectModel:P,onSelectThinkingLevel:F}),t[40]=n,t[41]=d,t[42]=z,t[43]=W,t[44]=te,t[45]=P,t[46]=F,t[47]=p,t[48]=ee,t[49]=x,t[50]=ce):ce=t[50];let le;t[51]!==ce||t[52]!==J?(le=(0,$.jsxs)(`div`,{className:`overflow-visible rounded-[18px] border bg-card`,children:[J,ce]}),t[51]=ce,t[52]=J,t[53]=le):le=t[53];let ue;t[54]!==q||t[55]!==le||t[56]!==ie||t[57]!==b?(ue=(0,$.jsxs)(`div`,{className:q,children:[b,ie,le]}),t[54]=q,t[55]=le,t[56]=ie,t[57]=b,t[58]=ue):ue=t[58];let de;t[59]!==z||t[60]!==w?(de=e=>{z||w(e.target.files)},t[59]=z,t[60]=w,t[61]=de):de=t[61];let fe;t[62]!==z||t[63]!==S||t[64]!==de?(fe=(0,$.jsx)(`input`,{ref:S,name:`images`,type:`file`,accept:`image/*`,multiple:!0,className:`hidden`,disabled:z,onChange:de}),t[62]=z,t[63]=S,t[64]=de,t[65]=fe):fe=t[65];let pe;t[66]!==ue||t[67]!==fe?(pe=(0,$.jsxs)($.Fragment,{children:[ue,fe]}),t[66]=ue,t[67]=fe,t[68]=pe):pe=t[68];let me=pe;if(B)return me;let he;return t[69]===me?he=t[70]:(he=(0,$.jsx)(`div`,{className:`p-4`,children:me}),t[69]=me,t[70]=he),he}var Ih=Z.memo(function(e){let t=(0,Q.c)(9),{images:n,disabled:r,onRemoveImage:i}=e;if(n.length===0)return null;let a;if(t[0]!==r||t[1]!==n||t[2]!==i){let e;t[4]!==r||t[5]!==i?(e=(e,t)=>(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(`img`,{src:e.previewUrl,alt:`Attachment preview`,className:`h-20 rounded-lg border object-cover`}),(0,$.jsx)(Y,{type:`button`,size:`icon-sm`,variant:`ghost`,className:`absolute top-1 right-1 rounded-full bg-background/90 p-1 shadow-sm disabled:cursor-not-allowed disabled:opacity-60`,disabled:r,onClick:()=>i(t),children:(0,$.jsx)(si,{className:`size-3`})})]},np(e)),t[4]=r,t[5]=i,t[6]=e):e=t[6],a=n.map(e),t[0]=r,t[1]=n,t[2]=i,t[3]=a}else a=t[3];let o;return t[7]===a?o=t[8]:(o=(0,$.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-3`,children:a}),t[7]=a,t[8]=o),o}),Lh=Z.memo(function({composerDiffLineComments:e,composerImages:t,composerText:n,composerSkill:r,composerSyncNonce:i,isSubmitting:a,isCompacting:o,isStreaming:s,awaitingFirstTurn:c,disabled:l=!1,fileInputRef:u,promptRef:d,displaySettingsStore:f,sessionStore:p,onComposerTextChange:m,onPickImages:h,onRemoveComposerDiffLineComment:g,onRemoveComposerImage:_,onSubmitPrompt:v,onAbort:y,onRunBuiltinSlashCommand:b,requestPathCompletions:x,requestFileCompletions:S}){let C=kh({displaySettingsStore:f,sessionStore:p}),w=Z.useRef(n),T=Z.useRef(r),E=Z.useRef({start:n.length,end:n.length}),D=Z.useRef(n.trim().length>0),O=Z.useRef(i),[k,A]=Z.useState(r),[M,N]=Z.useState(D.current),P=Z.useRef(()=>{}),F=Z.useRef(!1),[I,L]=Z.useState(!1),R=(e,t)=>{m(hf({text:e,skillName:t}))},z=(e,t)=>{R(e,t)},B=(e,t,n)=>{let r=T.current,i=e.trim().length>0;if(w.current=e,T.current=t,n?.selection&&(E.current=n.selection),r!==t&&A(t),D.current!==i&&(D.current=i,N(i)),d.current&&d.current.value!==e&&(d.current.value=e),P.current(),n?.immediate){R(e,t);return}z(e,t)},{visibleCompletion:V,selectedCompletionItem:H,slashMenuState:W,slashSelectionStore:ee,getSelectedSlashCommand:te,syncSelection:ne,applyCompletion:G,applySlashSuggestion:K,selectCompletionIndex:re,moveCompletionSelection:q,selectSlashIndex:ie,moveSlashSelection:J,dismissMenus:ae,refreshAssistState:oe}=Eh({draftTextRef:w,draftSkillRef:T,selectionRef:E,promptRef:d,slashCommands:C,requestPathCompletions:x,requestFileCompletions:S,applyDraft:B});Z.useEffect(()=>{P.current=oe},[oe]),Z.useEffect(()=>{let e=n===w.current&&r===T.current,t=i!==O.current;if(O.current=i,e&&!t){P.current();return}let a=n.trim().length>0;w.current=n,T.current=r,E.current={start:n.length,end:n.length},D.current=a,A(r),N(a),d.current&&d.current.value!==n&&(d.current.value=n),ae(),P.current()},[r,i,n,ae,d]);let se=M||e.length>0||t.length>0,ce=s||o||c||a,le=ce,ue=e=>{F.current=e,L(e)},de=a&&!le,fe=e=>{let t=e.target;t instanceof HTMLElement&&(t.closest(`button, textarea, input, [role='button']`)||(e.preventDefault(),d.current?.focus()))},pe=e=>{if(l)return;let t=w.current,n=T.current,r=vh(t,C);if(r){if(r.command.kind===`builtin`){ae(),b(r.command.name,r.args);return}if(!r.args){ae(),B(``,r.command.skillName,{immediate:!0});return}}let i=te();if(W&&i){if(ae(),i.kind===`builtin`){b(i.name,``);return}B(``,i.skillName,{immediate:!0});return}R(t,n),v(e)};return(0,$.jsxs)(`div`,{role:`presentation`,className:`relative min-h-[90px] cursor-text overflow-visible rounded-t-[18px] border-b border-border/70 bg-card px-3 pt-3 pb-14`,onMouseDown:fe,children:[(0,$.jsxs)(`div`,{className:`relative min-w-0`,children:[(0,$.jsx)(Ru,{visibleCompletion:V,slashMenuState:W,slashSelectionStore:ee,pointerSelectionSuppressed:I,onHoverCompletion:e=>{F.current||re(e)},onMoveCompletion:e=>{ue(!1),re(e)},onApplyCompletion:G,onHoverSlashCommand:e=>{F.current||ie(e)},onMoveSlashCommand:e=>{ue(!1),ie(e)},onApplySlashSuggestion:K}),(0,$.jsx)(`div`,{className:`min-w-0`,children:(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-start gap-2`,children:[k?(0,$.jsxs)(`span`,{className:`inline-flex h-7 max-w-[45%] shrink-0 items-center gap-0 overflow-hidden rounded-full bg-primary/10 pr-0.5 pl-2 text-sm font-medium text-primary`,children:[(0,$.jsxs)(`span`,{className:`truncate`,children:[`Skill: `,gf(k)]}),(0,$.jsx)(Y,{size:`icon-sm`,variant:`ghost`,className:`ml-1 rounded-full text-primary hover:bg-primary/10 hover:text-primary`,"aria-label":`Remove skill ${gf(k)}`,disabled:l,onClick:()=>B(w.current,void 0,{immediate:!0}),children:(0,$.jsx)(si,{className:`size-3.5`})})]}):null,e.map(e=>(0,$.jsxs)(`span`,{title:`${_f(e)}: ${e.text}`,className:`inline-flex h-7 max-w-[45%] shrink-0 items-center gap-1 overflow-hidden rounded-full bg-amber-500/10 pr-0.5 pl-2 text-sm font-medium text-amber-700 dark:text-amber-300`,children:[(0,$.jsx)(Pa,{className:`size-3.5 shrink-0`}),(0,$.jsxs)(`span`,{className:`truncate`,children:[`Diff: `,_f(e)]}),(0,$.jsx)(Y,{size:`icon-sm`,variant:`ghost`,className:`ml-1 rounded-full text-amber-700 hover:bg-amber-500/10 hover:text-amber-700 dark:text-amber-300 dark:hover:text-amber-300`,"aria-label":`Remove diff comment for ${_f(e)}`,disabled:l,onClick:()=>g(e.id),children:(0,$.jsx)(si,{className:`size-3.5`})})]},e.id)),(0,$.jsx)(on,{ref:d,name:`prompt`,rows:1,autoComplete:`off`,"data-1p-ignore":`true`,"data-form-type":`other`,"data-lpignore":`true`,defaultValue:n,onChange:e=>{if(l)return;let t=mf(e.target.value),n=t.matched?t.text:e.target.value,r=t.matched?{start:n.length,end:n.length}:{start:e.target.selectionStart,end:e.target.selectionEnd};B(n,t.matched?t.skillName:void 0,{selection:r})},onClick:ne,onKeyUp:ne,onSelect:ne,onKeyDown:t=>{if(l){t.preventDefault();return}let n=w.current,r=T.current,i=Sn(t.nativeEvent,`Control+J`),a=Sn(t.nativeEvent,`Control+K`);if(t.key===`Backspace`&&!n&&r){B(``,void 0,{immediate:!0});return}if(t.key===`Backspace`&&!n&&!r&&e.length>0){let t=e.at(-1);t&&g(t.id);return}if(V&&(t.key===`ArrowDown`||t.key===`ArrowUp`)){t.preventDefault(),ue(!0),q(t.key===`ArrowDown`?1:-1);return}if(W&&!V&&(t.key===`ArrowDown`||t.key===`ArrowUp`)){t.preventDefault(),ue(!0),J(t.key===`ArrowDown`?1:-1);return}if(i||a){let e=i?1:-1;if(V){t.preventDefault(),t.stopPropagation(),ue(!0),q(e);return}W&&(t.preventDefault(),t.stopPropagation(),ue(!0),J(e))}if(t.key===`Tab`){if(V&&H){t.preventDefault(),G(H);return}let e=te();if(W&&e){t.preventDefault(),K(e);return}}if(t.key===`Enter`&&!t.shiftKey&&!t.nativeEvent.isComposing){if(V&&H){t.preventDefault(),G(H);return}t.preventDefault(),pe(t.altKey?`followUp`:le?`steer`:void 0);return}if(t.key===`Escape`&&!t.altKey&&!t.ctrlKey&&!t.metaKey&&!t.shiftKey){if(V||W){t.preventDefault(),t.stopPropagation(),ae();return}if(ce&&!t.repeat){t.preventDefault(),t.stopPropagation(),y();return}}t.key===`ArrowUp`&&!V&&!W&&!n&&r&&Dh(d.current)&&B(``,void 0,{immediate:!0})},onPaste:e=>{if(l)return;let t=Ph(e.clipboardData);t.length!==0&&h(t)},disabled:l,placeholder:le?`Add a message to the queue...`:k?`Ask with ${gf(k)}…`:`Ask anything…`,className:`max-h-[min(40dvh,18rem)] min-h-[22px] max-w-full min-w-0 flex-1 basis-[min(240px,100%)] resize-none overflow-y-auto rounded-none border-0 bg-transparent p-0 text-base shadow-none ring-0 focus-visible:border-transparent focus-visible:ring-0 disabled:cursor-text disabled:bg-transparent disabled:opacity-60 md:text-sm dark:bg-transparent dark:disabled:bg-transparent`})]})})]}),(0,$.jsx)(`div`,{className:`absolute bottom-3 left-3 flex items-center gap-2`,children:(0,$.jsx)(U,{title:`Add images`,children:(0,$.jsx)(Y,{variant:`ghost`,size:`icon`,"aria-label":`Add images`,className:`cursor-pointer`,disabled:l,onClick:()=>u.current?.click(),children:(0,$.jsx)(Fa,{})})})}),(0,$.jsxs)(`div`,{className:`absolute right-3 bottom-3 flex flex-nowrap items-center justify-end gap-2`,children:[le?null:(0,$.jsx)(U,{title:`Send`,rows:[{title:`Send`,kbd:`Enter`},{title:`New line`,kbd:`⇧ Enter`}],children:(0,$.jsx)(Y,{size:`icon`,className:`cursor-pointer`,disabled:l||de||!se&&!s&&!W,"aria-label":`Send`,onClick:()=>{pe(void 0)},children:de?(0,$.jsx)(wt,{}):(0,$.jsx)(j,{})})}),le?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(Y,{variant:`outline`,className:`cursor-pointer`,disabled:l||!se,onClick:()=>pe(`followUp`),children:[(0,$.jsx)(Ia,{"data-icon":`inline-start`}),`Follow-up`]}),(0,$.jsxs)(Y,{variant:`outline`,className:`cursor-pointer`,disabled:l||!se,onClick:()=>pe(`steer`),children:[(0,$.jsx)(La,{"data-icon":`inline-start`}),`Steer`]}),ce?(0,$.jsx)(U,{title:`Abort`,kbd:`Esc`,children:(0,$.jsx)(Y,{variant:`destructive`,size:`icon`,className:`cursor-pointer bg-destructive text-white hover:bg-destructive/90`,"aria-label":`Abort`,disabled:l,onClick:y,children:(0,$.jsx)(Ua,{className:`fill-current text-white`})})}):null]}):null]}),(0,$.jsx)(Ih,{images:t,disabled:l,onRemoveImage:_})]})});function Rh(e){return ka(e)}function zh({cwd:e,viewerContextId:t}){return{queryKey:vi.gitStatus(t,e),queryFn:()=>oi(hi(`/api/git-status?cwd=${encodeURIComponent(e)}`,{contextId:t})),staleTime:3e4,gcTime:6e5}}function Bh({cwd:e,viewerContextId:t}){return{queryKey:vi.gitBranches(t,e),queryFn:()=>oi(hi(`/api/git-changes?cwd=${encodeURIComponent(e)}&gitScope=branches`,{contextId:t})),staleTime:3e4,gcTime:6e5}}function Vh(e){return e.detached?e.revision?`detached ${e.revision}`:`detached`:e.branch?.trim()||``}function Hh(e){if(!e.upstream)return``;if(e.upstreamGone)return`gone`;let t=Number.isInteger(e.ahead)?e.ahead:0,n=Number.isInteger(e.behind)?e.behind:0;return t>0&&n>0?`ahead ${t}, behind ${n}`:t>0?`ahead ${t}`:n>0?`behind ${n}`:`synced`}function Uh(e){let t=(0,Q.c)(56),{cwd:n,defaultNewSessionDirectory:r,directoryOptions:i,onCreateSession:a,onOpenAddDirectoryDialog:o,viewerContextId:s}=e,c=ki(),[l,u]=Z.useState(!1),[d,f]=Z.useState(``),p=n?.trim()||r.trim(),m=new Set,h=[],g=(e,t)=>{let n=e.trim();!n||m.has(n)||(m.add(n),h.push({path:n,label:t}))};g(p,`Selected directory`);for(let e of i)g(e.path,e.label);let _=h,v=Fi(p)||`Select directory`,y=nn({...zh({cwd:p,viewerContextId:s}),enabled:!!(p&&s),select:Kh,notifyOnChangeProps:[`data`,`isPending`,`error`]}).data,b;t[0]===y?b=t[1]:(b=y?Vh(y):``,t[0]=y,t[1]=b);let x=b,S=nn({...Bh({cwd:p,viewerContextId:s}),enabled:!!(p&&s&&y),select:Gh,notifyOnChangeProps:[`data`,`isPending`,`error`]}),C;t[2]===S.data?C=t[3]:(C=S.data||[],t[2]=S.data,t[3]=C);let w=C,T=an({mutationFn:async e=>await oi(hi(`/api/git-checkout`,{contextId:s}),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({cwd:p,...e})}),onSuccess:(e,t)=>{c.invalidateQueries({queryKey:vi.gitStatus(s,p)}),c.invalidateQueries({queryKey:vi.gitBranches(s,p)}),c.invalidateQueries({queryKey:vi.gitFiles(s,p)}),c.invalidateQueries({queryKey:vi.gitCommits(s,p)}),c.invalidateQueries({queryKey:vi.projectFileTree(s,p)}),c.invalidateQueries({queryKey:vi.gitFileReviews(s,p)}),u(!1),f(``),X.success(t.create?`Created and switched to ${t.branch}`:`Switched to ${t.branch}`)},onError:Wh}),E;t[4]!==T||t[5]!==d?(E=()=>{let e=d.trim();!e||T.isPending||T.mutate({branch:e,create:!0})},t[4]=T,t[5]=d,t[6]=E):E=t[6];let D=E,O,k;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,$.jsx)(Y,{type:`button`,variant:`ghost`,"aria-label":`Select new session directory`}),k=(0,$.jsx)(Na,{className:`size-4 shrink-0`,"aria-hidden":`true`}),t[7]=O,t[8]=k):(O=t[7],k=t[8]);let A;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,$.jsx)(en,{className:`size-5 shrink-0`,"aria-hidden":`true`}),t[9]=A):A=t[9];let j;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(j=(0,$.jsx)(Jn,{}),t[10]=j):j=t[10];let M;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(M=(0,$.jsx)(Ma,{className:`size-4 shrink-0`,"aria-hidden":`true`}),t[11]=M):M=t[11];let N;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(N=(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,$.jsx)(`span`,{children:`Add directory…`}),(0,$.jsx)(`span`,{className:`truncate text-xs text-muted-foreground`,children:`Search or paste a path for this new session.`})]}),t[12]=N):N=t[12];let P;t[13]===o?P=t[14]:(P=(0,$.jsxs)(kr,{onClick:o,children:[M,N]}),t[13]=o,t[14]=P);let F;t[15]!==x||t[16]!==S.isPending||t[17]!==T||t[18]!==y||t[19]!==w?(F=y&&x?(0,$.jsxs)(wr,{children:[(0,$.jsxs)(Fn,{render:(0,$.jsx)(Y,{type:`button`,variant:`ghost`,"aria-label":`Select git branch`,disabled:T.isPending}),children:[(0,$.jsx)(hn,{className:`size-4 shrink-0`,"aria-hidden":`true`}),(0,$.jsx)(`span`,{className:`truncate`,children:x}),T.isPending?(0,$.jsx)(wt,{size:`md`,className:`shrink-0`}):(0,$.jsx)(en,{className:`size-5 shrink-0`,"aria-hidden":`true`})]}),(0,$.jsxs)(Hn,{align:`start`,className:`w-80`,children:[(0,$.jsxs)(kr,{disabled:T.isPending,onClick:()=>u(!0),children:[(0,$.jsx)(hn,{className:`size-4 shrink-0`,"aria-hidden":`true`}),(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,$.jsx)(`span`,{children:`Create branch…`}),(0,$.jsx)(`span`,{className:`truncate text-xs text-muted-foreground`,children:`Create and switch from the current HEAD.`})]})]}),(0,$.jsx)(Jn,{}),S.isPending?(0,$.jsxs)(kr,{disabled:!0,children:[(0,$.jsx)(wt,{}),`Loading branches…`]}):w.length>0?w.map(e=>{let t=Hh(e);return(0,$.jsxs)(kr,{disabled:T.isPending,onClick:()=>{e.current||T.mutate({branch:e.name})},children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,$.jsx)(`span`,{className:`truncate`,children:e.name}),t||e.subject?(0,$.jsx)(`span`,{className:`truncate text-xs text-muted-foreground`,children:[t,e.subject].filter(Boolean).join(` · `)}):null]}),e.current?(0,$.jsx)(cn,{className:`ml-2 size-4 shrink-0`}):null]},e.name)}):(0,$.jsx)(kr,{disabled:!0,children:`No local branches.`})]})]}):null,t[15]=x,t[16]=S.isPending,t[17]=T,t[18]=y,t[19]=w,t[20]=F):F=t[20];let I=ii,L;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(L=e=>{u(e),e||f(``)},t[21]=L):L=t[21];let R=xi,z=Ci,B;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(B=(0,$.jsx)(Xr,{children:`Create branch`}),t[22]=B):B=t[22];let V=wi,H=Fi(p),U;t[23]!==V||t[24]!==H?(U=(0,$.jsxs)(V,{children:[`Create a branch in `,H,` and switch to it for the new session.`]}),t[23]=V,t[24]=H,t[25]=U):U=t[25];let W;t[26]!==z||t[27]!==B||t[28]!==U?(W=(0,$.jsxs)(z,{children:[B,U]}),t[26]=z,t[27]=B,t[28]=U,t[29]=W):W=t[29];let ee;t[30]===Symbol.for(`react.memo_cache_sentinel`)?(ee=e=>f(e.target.value),t[30]=ee):ee=t[30];let te;t[31]!==T.isPending||t[32]!==d?(te=(0,$.jsx)(xr,{value:d,onChange:ee,placeholder:`branch-name`,disabled:T.isPending}),t[31]=T.isPending,t[32]=d,t[33]=te):te=t[33];let ne;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(ne=(0,$.jsx)(Y,{type:`button`,variant:`outline`,onClick:()=>u(!1),children:`Cancel`}),t[34]=ne):ne=t[34];let G;t[35]!==T.isPending||t[36]!==d?(G=!d.trim()||T.isPending,t[35]=T.isPending,t[36]=d,t[37]=G):G=t[37];let K;t[38]===T.isPending?K=t[39]:(K=T.isPending?(0,$.jsx)(wt,{}):null,t[38]=T.isPending,t[39]=K);let re;t[40]!==G||t[41]!==K?(re=(0,$.jsxs)(ei,{children:[ne,(0,$.jsxs)(Y,{type:`submit`,disabled:G,children:[K,`Create branch`]})]}),t[40]=G,t[41]=K,t[42]=re):re=t[42];let q;t[43]!==D||t[44]!==te||t[45]!==re?(q=(0,$.jsxs)(`form`,{className:`grid gap-4`,action:D,children:[te,re]}),t[43]=D,t[44]=te,t[45]=re,t[46]=q):q=t[46];let ie;t[47]!==R||t[48]!==W||t[49]!==q?(ie=(0,$.jsxs)(R,{children:[W,q]}),t[47]=R,t[48]=W,t[49]=q,t[50]=ie):ie=t[50];let J;return t[51]!==I||t[52]!==l||t[53]!==L||t[54]!==ie?(J=(0,$.jsx)(I,{open:l,onOpenChange:L,children:ie}),t[51]=I,t[52]=l,t[53]=L,t[54]=ie,t[55]=J):J=t[55],(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center justify-start gap-1.5 text-muted-foreground`,children:[(0,$.jsxs)(wr,{children:[(0,$.jsxs)(Fn,{render:O,children:[k,(0,$.jsx)(`span`,{className:`truncate`,children:v}),A]}),(0,$.jsxs)(Hn,{align:`start`,className:`w-80`,children:[_.map(e=>(0,$.jsxs)(kr,{onClick:()=>a(e.path),children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e.label}),(0,$.jsx)(`span`,{className:`truncate`,children:Bi(e.path)})]}),e.path===p?(0,$.jsx)(cn,{className:`ml-2 size-4 shrink-0`}):null]},e.path)),j,P]})]}),F,J]})}function Wh(e,t){X.error(e instanceof Error?e.message:t.create?`Failed to create branch`:`Failed to switch branch`)}function Gh(e){return e.localBranches}function Kh(e){return e.gitStatus}var qh=Z.memo(function({actionsRef:e,composerPanelRef:t,contextUsageStore:n,displaySettingsStore:r,fileInputRef:i,sessionStore:a,store:o,topContent:s}){let c=Rh(o),l=ka(r,e=>e.centerMessages),u=Pi(c),d=zi(t=>{u.current.disabled||e.current.syncComposerDraft(t)}),f=zi(t=>{u.current.disabled||e.current.onPickImages(t)}),p=zi(t=>{u.current.disabled||e.current.onRemoveComposerImage(t)}),m=zi(t=>{u.current.disabled||e.current.submitPrompt(t)}),h=zi(()=>{u.current.disabled||e.current.abortSession()}),g=zi((t,n)=>{u.current.disabled||e.current.editPendingDraftFollowUp(t,n)||e.current.editPendingMessage(t,n)}),_=zi(t=>{u.current.disabled||e.current.removePendingDraftFollowUp(t)||e.current.removePendingMessage(t)}),v=zi((t,n)=>{u.current.disabled||e.current.reorderPendingDraftFollowUp(t,n)||e.current.reorderPending(t,n)}),y=zi(()=>{u.current.disabled||e.current.startPendingQueue()}),b=zi((t,n)=>{u.current.disabled||e.current.runBuiltinSlashCommand(t,n)}),x=zi(t=>{u.current.disabled||e.current.setModel(t)}),S=zi(t=>{u.current.disabled||e.current.setThinkingLevel(t)}),C=zi(async e=>{let t=u.current;if(t.disabled)return[];let n=await oi(hi(`/api/path-completions`,{contextId:t.viewerContextId,sessionId:t.activeSessionId}),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({prefix:e})});return ti(n)?[]:n.items}),w=zi(async(e,t)=>{let n=u.current;if(n.disabled)return[];let r=await oi(hi(`/api/file-completions`,{contextId:n.viewerContextId,sessionId:n.activeSessionId}),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({query:e,isQuotedPrefix:t})});return ti(r)?[]:r.items});return(0,$.jsx)(Fh,{ref:t,activeSessionId:c.activeSessionId,currentPendingMessages:c.currentPendingMessages,composerDiffLineComments:c.composerDiffLineComments,composerImages:c.composerImages,composerText:c.composerText,composerSkill:c.composerSkill,composerSyncNonce:c.composerSyncNonce,canStartPendingQueue:c.canStartPendingQueue,centerMessages:l,contextUsageStore:n,displaySettingsStore:r,sessionStore:a,isSubmitting:c.isSubmitting,isCompacting:c.isCompacting,isStreaming:c.isStreaming,awaitingFirstTurn:c.awaitingFirstTurn,disabled:c.disabled,flush:!!s,topContent:s,viewerContextId:c.viewerContextId,fileInputRef:i,onComposerTextChange:d,onPickImages:f,onRemoveComposerDiffLineComment:e.current.removeDiffLineComment,onRemoveComposerImage:p,onSubmitPrompt:m,onAbort:h,onEditPendingMessage:g,onRemovePendingMessage:_,onReorderPending:v,onStartPendingQueue:y,onRunBuiltinSlashCommand:b,onSelectModel:x,onSelectThinkingLevel:S,requestPathCompletions:C,requestFileCompletions:w})});function Jh(e){let t=(0,Q.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=E(`flex w-full min-w-0 flex-1 flex-col items-center justify-center gap-4 rounded-xl border-dashed p-6 text-center text-balance`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,$.jsx)(`div`,{"data-slot":`empty`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Yh(e){let t=(0,Q.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=E(`flex max-w-sm flex-col items-center gap-2`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,$.jsx)(`div`,{"data-slot":`empty-header`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}var Xh=Ti(`mb-2 flex shrink-0 items-center justify-center [&_svg]:pointer-events-none [&_svg]:shrink-0`,{variants:{variant:{default:`bg-transparent`,icon:`flex size-8 shrink-0 items-center justify-center rounded-lg bg-muted text-foreground [&_svg:not([class*='size-'])]:size-4`}},defaultVariants:{variant:`default`}});function Zh(e){let t=(0,Q.c)(11),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,variant:i,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a=i===void 0?`default`:i,o;t[4]!==n||t[5]!==a?(o=E(Xh({variant:a,className:n})),t[4]=n,t[5]=a,t[6]=o):o=t[6];let s;return t[7]!==r||t[8]!==o||t[9]!==a?(s=(0,$.jsx)(`div`,{"data-slot":`empty-icon`,"data-variant":a,className:o,...r}),t[7]=r,t[8]=o,t[9]=a,t[10]=s):s=t[10],s}function Qh(e){let t=(0,Q.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=E(`font-heading text-sm font-medium tracking-tight`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,$.jsx)(`div`,{"data-slot":`empty-title`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function $h(e){let t=(0,Q.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=E(`text-sm/relaxed text-muted-foreground [&>a]:underline [&>a]:underline-offset-4 [&>a:hover]:text-primary`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,$.jsx)(`div`,{"data-slot":`empty-description`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function eg(e){let t=(0,Q.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=E(`flex w-full max-w-sm min-w-0 flex-col items-center gap-2.5 text-sm text-balance`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,$.jsx)(`div`,{"data-slot":`empty-content`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function tg(e){let t=(0,Q.c)(11),{viewerContextId:n,cwd:r}=e,i,a,o;t[0]!==r||t[1]!==n?(i=Er(r),o=nn,a=Mt({viewerContextId:n,cwd:i}),t[0]=r,t[1]=n,t[2]=i,t[3]=a,t[4]=o):(i=t[2],a=t[3],o=t[4]);let s=!!(n&&i),c;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(c=[`data`],t[5]=c):c=t[5];let l;t[6]!==a||t[7]!==s?(l={...a,enabled:s,select:ng,notifyOnChangeProps:c},t[6]=a,t[7]=s,t[8]=l):l=t[8];let u=o(l).data||`Changes`,d;return t[9]===u?d=t[10]:(d=(0,$.jsx)(`span`,{className:`max-w-48 truncate`,children:u}),t[9]=u,t[10]=d),d}function ng(e){return e.gitStatus===null?`Files`:Kt(e.gitStatus)||`Changes`}function rg(e){let t=(0,Q.c)(16),{viewerContextId:n,cwd:r}=e,i,a,o;t[0]!==r||t[1]!==n?(i=Er(r),o=nn,a=Mt({viewerContextId:n,cwd:i}),t[0]=r,t[1]=n,t[2]=i,t[3]=a,t[4]=o):(i=t[2],a=t[3],o=t[4]);let s=!!(n&&i),c;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(c=[`data`],t[5]=c):c=t[5];let l;t[6]!==a||t[7]!==s?(l={...a,enabled:s,select:Cr,notifyOnChangeProps:c},t[6]=a,t[7]=s,t[8]=l):l=t[8];let u=o(l),d;t[9]===u.data?d=t[10]:(d=$t(u.data),t[9]=u.data,t[10]=d);let f=d;if(!f)return null;let p=u.data?.title||f,m;t[11]===f?m=t[12]:(m=(0,$.jsx)(`span`,{children:f}),t[11]=f,t[12]=m);let h;return t[13]!==p||t[14]!==m?(h=(0,$.jsx)(`span`,{className:`inline-flex items-center text-xs text-muted-foreground`,title:p,children:m}),t[13]=p,t[14]=m,t[15]=h):h=t[15],h}function ig(e){let t=(0,Q.c)(27),{viewerContextId:n,cwd:r}=e,i=ki(),a=Er(r),o=ar(),[s,c]=Z.useState(!1),l=nn({...Mt({viewerContextId:n,cwd:a}),enabled:!!(n&&a),select:Cr,notifyOnChangeProps:[`data`]}).data,u=!!l,d=!!(n&&a&&l?.dirty),f=!!(n&&a&&u&&!l?.detached&&(l?.ahead||0)>0),p=!!(n&&a)&&vn(l),m=!!(n&&a&&u&&!l?.detached&&(l?.behind||0)>0),h=nn({...sn({viewerContextId:n,cwd:a,scope:`files`}),enabled:!!d,select:mr,notifyOnChangeProps:[`data`]}),g;t[0]===h.data?g=t[1]:(g=Array.isArray(h.data)?h.data:[],t[0]=h.data,t[1]=g);let _=g,v=an({mutationFn:async e=>await oi(hi(e===`pull`?`/api/git-pull`:`/api/git-push`,{contextId:n}),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({cwd:a,force:e===`force-push`})}),onSuccess:async(e,t)=>{await i.invalidateQueries({queryKey:vi.gitStatus(n,a),exact:!0,refetchType:`active`}),await qn({queryClient:i,viewerContextId:n,cwd:a}),t!==`pull`&&Rt({response:e,force:t===`force-push`})},onError:ag}),y=br({mutationKey:vi.gitAction(n,a,`push`)}),b=br({mutationKey:vi.gitAction(n,a,`force-push`)}),x=vi.gitAction(n,a,`pull`),S;t[2]===x?S=t[3]:(S={mutationKey:x},t[2]=x,t[3]=S);let C=br(S),w=v.isPending&&v.variables===`push`||y>0,T=v.isPending&&v.variables===`force-push`||b>0,E=v.isPending&&v.variables===`pull`||C>0,D=v.isPending||w||T||E,O=o&&!d&&f&&(!D||w),k=!o&&f&&(!D||w),A=!o&&p&&(!D||T),j=!o&&m&&(!D||E),M=d||O||k||A||j;if(!M&&!s)return null;let N;t[4]!==d||t[5]!==T||t[6]!==D||t[7]!==v||t[8]!==E||t[9]!==w||t[10]!==c||t[11]!==M||t[12]!==A||t[13]!==O||t[14]!==j||t[15]!==k?(N=M?(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[d?(0,$.jsx)(U,{title:`Commit`,kbd:Ir(`Control+C`),children:(0,$.jsx)(Y,{variant:`ghost`,size:`icon`,className:`md:hidden`,"aria-label":`Commit changes`,onClick:()=>{c(!0)},children:(0,$.jsx)(or,{})})}):null,d?(0,$.jsx)(U,{title:`Commit`,kbd:Ir(`Control+C`),children:(0,$.jsxs)(Y,{variant:`ghost`,className:`hidden md:inline-flex`,onClick:()=>{c(!0)},children:[(0,$.jsx)(or,{}),` Commit…`]})}):null,O?(0,$.jsx)(U,{title:`Push`,kbd:Ir(`Control+P`),children:(0,$.jsx)(Y,{variant:`ghost`,size:`icon`,className:`md:hidden`,"aria-label":`Push changes`,disabled:D,onClick:()=>{v.mutate(`push`)},children:w?(0,$.jsx)(wt,{}):(0,$.jsx)(Wt,{})})}):null,k?(0,$.jsx)(U,{title:`Push`,kbd:Ir(`Control+P`),children:(0,$.jsxs)(Y,{variant:`ghost`,className:`hidden md:inline-flex`,disabled:D,onClick:()=>{v.mutate(`push`)},children:[w?(0,$.jsx)(wt,{}):(0,$.jsx)(Wt,{}),` Push`]})}):null,A?(0,$.jsx)(U,{title:`Force push`,kbd:Ir(`Control+Shift+P`),children:(0,$.jsxs)(Y,{variant:`ghost`,className:`hidden md:inline-flex`,disabled:D,onClick:()=>{v.mutate(`force-push`)},children:[T?(0,$.jsx)(wt,{}):(0,$.jsx)(Wt,{}),` Force Push`]})}):null,j?(0,$.jsx)(U,{title:`Pull`,kbd:Ir(`Alt+P`),children:(0,$.jsxs)(Y,{variant:`ghost`,className:`hidden md:inline-flex`,disabled:D,onClick:()=>{v.mutate(`pull`)},children:[E?(0,$.jsx)(wt,{}):(0,$.jsx)(rr,{}),` Pull`]})}):null]}):null,t[4]=d,t[5]=T,t[6]=D,t[7]=v,t[8]=E,t[9]=w,t[10]=c,t[11]=M,t[12]=A,t[13]=O,t[14]=j,t[15]=k,t[16]=N):N=t[16];let P;t[17]!==s||t[18]!==_||t[19]!==l||t[20]!==a||t[21]!==c||t[22]!==n?(P=(0,$.jsx)(Lr,{viewerContextId:n,cwd:a,files:_,gitStatus:l,open:s,onOpenChange:c}),t[17]=s,t[18]=_,t[19]=l,t[20]=a,t[21]=c,t[22]=n,t[23]=P):P=t[23];let F;return t[24]!==N||t[25]!==P?(F=(0,$.jsxs)($.Fragment,{children:[N,P]}),t[24]=N,t[25]=P,t[26]=F):F=t[26],F}function ag(e,t){X.error(_r(e,t===`pull`?`Failed to pull changes`:t===`force-push`?`Failed to force push changes`:`Failed to push changes`))}function og(e){let t=(0,Q.c)(11),{viewerContextId:n,cwd:r}=e,i,a,o;t[0]!==r||t[1]!==n?(i=Er(r),o=nn,a=Mt({viewerContextId:n,cwd:i}),t[0]=r,t[1]=n,t[2]=i,t[3]=a,t[4]=o):(i=t[2],a=t[3],o=t[4]);let s=!!(n&&i),c;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(c=[`data`],t[5]=c):c=t[5];let l;t[6]!==a||t[7]!==s?(l={...a,enabled:s,select:Cr,notifyOnChangeProps:c},t[6]=a,t[7]=s,t[8]=l):l=t[8];let u=o(l);if(!u.data?.label)return null;let d;return t[9]===u.data.label?d=t[10]:(d=(0,$.jsx)(bs,{variant:`outline`,children:u.data.label}),t[9]=u.data.label,t[10]=d),d}function sg(e,t){return e.renderKey||e.itemKey||`message-row:${t}`}function cg(e){let t=[],n=null,r=!1,i=()=>{if(!n){r=!1;return}r&&t.push(n),n=null,r=!1};return e.items.forEach((a,o)=>{let s=sg(a,o);if(a.kind===`assistant`){n||={kind:`assistant`,key:s,itemKeys:[]},n.itemKeys.push(s),r||=!e.hideFooter&&ch(a)||sh({item:a,hideThinking:e.hideThinking,hideToolBlocks:e.hideToolBlocks});return}i(),t.push({kind:`user`,key:s,itemKey:s})}),i(),t}function lg(e,t){return e.kind!==t.kind||e.key!==t.key?!1:e.kind===`user`&&t.kind===`user`?e.itemKey===t.itemKey:!(e.kind!==`assistant`||t.kind!==`assistant`)}function ug(e,t){if(e.length===0)return t;let n=e.length!==t.length,r=[];for(let i=0;i<t.length;i+=1){let a=t[i],o=e[i];if(o&&lg(o,a)){r.push(o);continue}n=!0,r.push(a)}return n?r:e}function dg(e){let t=new Map;return e.forEach((e,n)=>{t.set(sg(e,n),e)}),t}function fg(e){let t={items:e,itemByKey:dg(e),revision:0},n=new Set,r=new Map,i=new Set,a=new Set,o=new Map,s=e=>{let t=r.get(e);if(t)for(let e of t)e()},c=e=>{let n=[],r=t.items.findIndex((t,n)=>sg(t,n)===e);if(r<0)return n;for(let e=r;e<t.items.length;e+=1){let r=t.items[e];if(!r||r.kind!==`assistant`)break;n.push(sg(r,e))}return n},l=e=>{let t=o.get(e),n=c(e);return t&&Mi(t,n)?t:(o.set(e,n),n)};return{getSnapshot:()=>t,getAssistantGroupItemKeys:l,getItem:e=>t.itemByKey.get(e),setItems:e=>{if(t.items===e)return;let r=t.itemByKey,o=dg(e);t={items:e,itemByKey:o,revision:t.revision+1};let c=new Set;for(let e of r.keys())r.get(e)!==o.get(e)&&c.add(e);for(let e of o.keys())r.get(e)!==o.get(e)&&c.add(e);for(let t of i){let n=cg({items:e,hideFooter:t.hideFooter,hideThinking:t.hideThinking,hideToolBlocks:t.hideToolBlocks}),r=ug(t.groups,n);r!==t.groups&&(t.groups=r,t.listener())}for(let e of a){let t=l(e.groupKey);Mi(e.itemKeys,t)||(e.itemKeys=t,e.listener())}for(let e of n)e();for(let e of c)s(e)},subscribe:e=>(n.add(e),()=>{n.delete(e)}),subscribeGroups:({hideFooter:e,hideThinking:t,hideToolBlocks:n,groups:r,listener:a})=>{let o={hideFooter:e,hideThinking:t,hideToolBlocks:n,groups:r,listener:a};return i.add(o),()=>{i.delete(o)}},subscribeAssistantGroupItems:(e,t)=>{let n={groupKey:e,itemKeys:l(e),listener:t};return a.add(n),()=>{a.delete(n)}},subscribeItems:(e,t)=>{let n=[...new Set(e)];for(let e of n){let n=r.get(e)??new Set;n.add(t),r.set(e,n)}return()=>{for(let e of n){let n=r.get(e);n&&(n.delete(t),n.size===0&&r.delete(e))}}}}}function pg(e){let t=(0,Q.c)(3),n,r;return t[0]===e?(n=t[1],r=t[2]):(n=()=>e.getSnapshot().revision,r=()=>e.getSnapshot().revision,t[0]=e,t[1]=n,t[2]=r),Z.useSyncExternalStore(e.subscribe,n,r)}function mg(e){return e.some(e=>e.kind===`assistant`&&e.blocks.some(e=>e.type===`text`&&typeof e.text==`string`&&e.text.trim().length>0))}function hg(e){let t=(0,Q.c)(3),n,r;return t[0]===e?(n=t[1],r=t[2]):(n=()=>e.getSnapshot().items.length>0,r=()=>e.getSnapshot().items.length>0,t[0]=e,t[1]=n,t[2]=r),Z.useSyncExternalStore(e.subscribe,n,r)}function gg(e){let t=(0,Q.c)(3),n,r;return t[0]===e?(n=t[1],r=t[2]):(n=()=>mg(e.getSnapshot().items),r=()=>mg(e.getSnapshot().items),t[0]=e,t[1]=n,t[2]=r),Z.useSyncExternalStore(e.subscribe,n,r)}function _g(e){let t=(0,Q.c)(16),{hideFooter:n,hideThinking:r,hideToolBlocks:i,store:a}=e,o;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o=[],t[0]=o):o=t[0];let s;t[1]!==n||t[2]!==r||t[3]!==i?(s={hideFooter:n,hideThinking:r,hideToolBlocks:i,revision:-1,groups:o},t[1]=n,t[2]=r,t[3]=i,t[4]=s):s=t[4];let c=Z.useRef(s),l;t[5]!==n||t[6]!==r||t[7]!==i||t[8]!==a?(l=()=>{let e=a.getSnapshot(),t=c.current;if(t.revision===e.revision&&t.hideFooter===n&&t.hideThinking===r&&t.hideToolBlocks===i)return t.groups;let o=cg({items:e.items,hideFooter:n,hideThinking:r,hideToolBlocks:i}),s=t.hideFooter===n&&t.hideThinking===r&&t.hideToolBlocks===i?ug(t.groups,o):o;return c.current={hideFooter:n,hideThinking:r,hideToolBlocks:i,revision:e.revision,groups:s},s},t[5]=n,t[6]=r,t[7]=i,t[8]=a,t[9]=l):l=t[9];let u=l,d;t[10]!==u||t[11]!==n||t[12]!==r||t[13]!==i||t[14]!==a?(d=e=>a.subscribeGroups({hideFooter:n,hideThinking:r,hideToolBlocks:i,groups:u(),listener:e}),t[10]=u,t[11]=n,t[12]=r,t[13]=i,t[14]=a,t[15]=d):d=t[15];let f=d;return Z.useSyncExternalStore(f,u,u)}function vg(e,t){let n=(0,Q.c)(7),r;n[0]!==t||n[1]!==e?(r=n=>e.subscribeItems([t],n),n[0]=t,n[1]=e,n[2]=r):r=n[2];let i,a;return n[3]!==t||n[4]!==e?(i=()=>e.getItem(t),a=()=>e.getItem(t),n[3]=t,n[4]=e,n[5]=i,n[6]=a):(i=n[5],a=n[6]),Z.useSyncExternalStore(r,i,a)}function yg(e){return{hideThinking:e.hideThinking,hideToolBlocks:e.hideToolBlocks,items:e.itemKeys.flatMap(t=>{let n=e.store.getItem(t);return n?.kind===`assistant`?[n]:[]})}}function bg(e,t){if(e.hideThinking!==t.hideThinking||e.hideToolBlocks!==t.hideToolBlocks||e.items.length!==t.items.length)return!1;for(let n=0;n<e.items.length;n+=1)if(e.items[n]!==t.items[n])return!1;return!0}function xg(e){let t=e,n=new Set;return{getSnapshot:()=>t,setSnapshot:e=>{if(!bg(t,e)){t=e;for(let e of n)e()}},subscribe:e=>(n.add(e),()=>{n.delete(e)})}}function Sg(e={isMessagesNearTop:!0,isMessagesNearBottom:!0,hasPreviousMessageJumpTarget:!1,hasNextMessageJumpTarget:!1}){let t=e,n=new Set;return{getSnapshot:()=>t,setSnapshot:e=>{if(!(t.isMessagesNearTop===e.isMessagesNearTop&&t.isMessagesNearBottom===e.isMessagesNearBottom&&t.hasPreviousMessageJumpTarget===e.hasPreviousMessageJumpTarget&&t.hasNextMessageJumpTarget===e.hasNextMessageJumpTarget)){t=e;for(let e of n)e()}},subscribe:e=>(n.add(e),()=>{n.delete(e)})}}function Cg(e,t){let n=(0,Q.c)(4),r,i;return n[0]!==t||n[1]!==e?(r=()=>t(e.getSnapshot()),i=()=>t(e.getSnapshot()),n[0]=t,n[1]=e,n[2]=r,n[3]=i):(r=n[2],i=n[3]),Z.useSyncExternalStore(e.subscribe,r,i)}function wg(e){return e?e.querySelector(`[data-slot="scroll-area-viewport"]`)||(e instanceof HTMLDivElement?e:null):null}var Tg=48;function Eg(e){return Math.max(0,e.scrollHeight-e.scrollTop-e.clientHeight)}function Dg(e,t=Tg){return e.scrollTop<t}function Og(e,t=Tg){return Eg(e)<t}function kg(e){return[...e.querySelectorAll(`[data-message-anchor='true']`)]}function Ag(e,t){if(e.length===0)return-1;let n=t.scrollTop+8,r=0;for(let t=0;t<e.length;t+=1){if(e[t].offsetTop<=n){r=t;continue}break}return r}function jg(e){let t=kg(e),n=Ag(t,e);if(n<0)return null;let r=t[n],i=e.scrollTop+8;return r&&r.offsetTop<i-1?r:n===0?null:t[n-1]}function Mg(e){let t=kg(e),n=Ag(t,e);return n<0||n>=t.length-1?null:t[n+1]}function Ng(e){return{isMessagesNearTop:Dg(e),isMessagesNearBottom:Og(e),hasPreviousMessageJumpTarget:!!jg(e),hasNextMessageJumpTarget:!!Mg(e)}}function Pg(e){e.scrollTo({top:e.scrollHeight,behavior:`auto`})}function Fg(e){return e.key===`ArrowUp`||e.key===`PageUp`||e.key===`Home`||e.key===` `&&e.shiftKey}function Ig(e){return e.key===`Enter`||e.key===` `}function Lg(e,t){if(!(e instanceof Element))return null;let n=e.closest(`[data-conversation-tool-collapsible-trigger='true']`);return!n||!t.contains(n)||n.getAttribute(`aria-expanded`)===`true`?null:n}function Rg({autoScrollEnabled:e,isSessionViewLoading:t,sessionState:n}){let r=Z.useRef(null),i=Z.useRef(null),a=Z.useRef(null),o=Z.useRef(null),s=Z.useRef(``),c=Z.useRef(0),l=Z.useRef(0),u=Z.useRef(0),d=Z.useRef(!0),f=Z.useRef(0),p=Z.useRef(n.streaming),m=Z.useRef(0),h=Z.useRef(null),g=Z.useRef(Sg()),_=Z.useCallback(e=>{g.current.setSnapshot(Ng(e))},[]),v=Z.useCallback(e=>{c.current=e.scrollTop,l.current=e.scrollHeight,u.current=e.clientHeight},[]),y=Z.useCallback(t=>{e&&d.current&&Pg(t),v(t),_(t)},[e,v,_]),b=Z.useCallback(t=>{!e||!d.current||(window.cancelAnimationFrame(m.current),m.current=window.requestAnimationFrame(()=>{m.current=0,t.isConnected&&(y(t),m.current=window.requestAnimationFrame(()=>{m.current=0,t.isConnected&&y(t)}))}))},[e,y]),x=Z.useCallback(()=>{let e=o.current;e&&(d.current=!1,e.scrollTo({top:0,behavior:`auto`}))},[]),S=Z.useCallback(()=>{let e=o.current;e&&(d.current=!1,h.current={scrollHeight:e.scrollHeight,scrollTop:e.scrollTop})},[]),C=Z.useCallback(()=>{h.current=null},[]),w=Z.useCallback(()=>{let t=o.current;t&&(d.current=e,Pg(t),v(t),_(t),b(t))},[e,v,b,_]),T=Z.useCallback(()=>{let e=o.current;if(!e)return;let t=jg(e);t&&(d.current=!1,e.scrollTo({top:Math.max(0,t.offsetTop-8),behavior:`auto`}))},[]),E=Z.useCallback(()=>{let e=o.current;if(!e)return;let t=Mg(e);t&&(d.current=!1,e.scrollTo({top:Math.max(0,t.offsetTop-8),behavior:`auto`}))},[]);Z.useEffect(()=>{let t=wg(r.current);if(o.current=t,!t)return;let n=()=>{f.current=window.performance.now()+500},i=()=>window.performance.now()<f.current,a=()=>{let n=t.scrollTop,r=n<c.current-1,a=n>c.current+1;r&&i()&&!Og(t)?d.current=!1:a&&Og(t)&&(d.current=e),v(t),_(t)},s=()=>{n()},l=e=>{n(),Lg(e.target,t)&&(d.current=!1)},u=e=>{if(Lg(e.target,t)&&Ig(e)){d.current=!1;return}n(),Fg(e)&&(d.current=!1)};return a(),t.addEventListener(`scroll`,a,{passive:!0}),t.addEventListener(`wheel`,s,{passive:!0}),t.addEventListener(`pointerdown`,l,{capture:!0,passive:!0}),t.addEventListener(`keydown`,u,{capture:!0}),()=>{t.removeEventListener(`scroll`,a),t.removeEventListener(`wheel`,s),t.removeEventListener(`pointerdown`,l,{capture:!0}),t.removeEventListener(`keydown`,u,{capture:!0})}},[e,v,_]),Z.useEffect(()=>{if(!e){d.current=!1,window.cancelAnimationFrame(m.current),m.current=0;return}let t=o.current;!t||!Og(t)||(d.current=!0,b(t))},[e,b]),Z.useEffect(()=>()=>{window.cancelAnimationFrame(m.current)},[]);let D=Z.useCallback(()=>{if(t)return;let e=o.current||wg(r.current);if(!e)return;o.current=e;let n=h.current;if(n){h.current=null,e.scrollTop=n.scrollTop+Math.max(0,e.scrollHeight-n.scrollHeight),v(e),_(e);return}y(e),b(e)},[t,v,b,y,_]);return Z.useLayoutEffect(()=>{!p.current&&n.streaming&&e&&(d.current=!0),p.current=n.streaming,D()},[e,n.streaming,D]),Z.useLayoutEffect(()=>{if(typeof ResizeObserver>`u`)return;let e=o.current||wg(r.current),t=i.current;if(!e||!t)return;o.current=e;let n=0,a=new ResizeObserver(()=>{window.cancelAnimationFrame(n),n=window.requestAnimationFrame(()=>{e.isConnected&&(y(e),b(e))})});return a.observe(t),a.observe(e),()=>{window.cancelAnimationFrame(n),a.disconnect()}},[b,y]),Z.useLayoutEffect(()=>{if(t)return;let i=di(n);if(!i||s.current===i)return;let a=o.current||wg(r.current);a&&(o.current=a,s.current=i,d.current=e,p.current=n.streaming,Pg(a),v(a),_(a),b(a))},[e,t,n.cwd,n.draft,n.sessionFile,n.sessionId,v,b,_]),{bottomRef:a,cancelHistoryPrepend:C,jumpToNextMessage:E,jumpToPreviousMessage:T,messagesContentRef:i,messagesScrollAreaRef:r,prepareForHistoryPrepend:S,scrollConversationToBottom:w,scrollConversationToTop:x,scrollStateStore:g.current,syncAfterConversationChange:D}}function zg(e){let t=(0,Q.c)(8),{conversationItemsStore:n,draft:r,onClick:i,scrollStateStore:a}=e,o=hg(n),s;t[0]!==r||t[1]!==o?(s=e=>r||!o||e.isMessagesNearBottom,t[0]=r,t[1]=o,t[2]=s):s=t[2];let c=Cg(a,s),l;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(l=Ir(`Control+ArrowDown`),t[3]=l):l=t[3];let u;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,$.jsx)(m,{className:`size-4`}),t[4]=u):u=t[4];let d;return t[5]!==c||t[6]!==i?(d=(0,$.jsx)(U,{title:`Jump to latest message`,kbd:l,children:(0,$.jsx)(Y,{variant:`secondary`,size:`icon-lg`,disabled:c,className:`absolute bottom-4 left-1/2 z-10 -translate-x-1/2 rounded-full border-0 shadow-[0_10px_24px_rgba(0,0,0,0.28)] disabled:pointer-events-none disabled:opacity-0 md:bottom-[18px]`,"aria-label":`Jump to latest message`,onClick:i,children:u})}),t[5]=c,t[6]=i,t[7]=d):d=t[7],d}function Bg(e){let t=(0,Q.c)(6),{conversationItemsStore:n,disabled:r,onRevisionChange:i}=e,a=pg(n),o=Z.useEffectEvent(i),s;t[0]!==r||t[1]!==o?(s=()=>{r||o()},t[0]=r,t[1]=o,t[2]=s):s=t[2];let c;return t[3]!==a||t[4]!==r?(c=[a,r],t[3]=a,t[4]=r,t[5]=c):c=t[5],Z.useLayoutEffect(s,c),null}function Vg(e){let t=(0,Q.c)(10),{centerMessages:n,onClick:r,scrollStateStore:i}=e,a=Cg(i,Hg),o;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o=Ir(`Control+ArrowLeft`),t[0]=o):o=t[0];let s=n?`pointer-events-auto`:`absolute right-4 bottom-4 z-10 md:right-[18px] md:bottom-[18px]`,c;t[1]===s?c=t[2]:(c=E(`rounded-full border-0 shadow-[0_10px_24px_rgba(0,0,0,0.28)] disabled:pointer-events-none disabled:opacity-0`,s),t[1]=s,t[2]=c);let l;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(Aa,{className:`size-4`}),t[3]=l):l=t[3];let u;t[4]!==a||t[5]!==r||t[6]!==c?(u=(0,$.jsx)(U,{title:`Jump to previous message`,kbd:o,children:(0,$.jsx)(Y,{variant:`secondary`,size:`icon-lg`,disabled:a,className:c,"aria-label":`Jump to previous message`,onClick:r,children:l})}),t[4]=a,t[5]=r,t[6]=c,t[7]=u):u=t[7];let d=u;if(!n)return d;let f;return t[8]===d?f=t[9]:(f=(0,$.jsx)(`div`,{className:`pointer-events-none absolute inset-x-4 bottom-4 z-10 md:bottom-[18px]`,children:(0,$.jsx)(`div`,{className:`mx-auto flex w-full max-w-[80ch] justify-end`,children:d})}),t[8]=d,t[9]=f),f}function Hg(e){return!e.hasPreviousMessageJumpTarget}var Ug=Z.createContext(null);function Wg(e){let t=(0,Q.c)(1),n;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n={compare:Ni},t[0]=n):n=t[0],ka(e,Gg,n)}function Gg(e){return{cwd:e.cwd,draft:e.draft,historyOffset:e.historyOffset,historyTotalCount:e.historyTotalCount,sessionFile:e.sessionFile,sessionId:e.sessionId,streaming:e.streaming}}function Kg(e){let t=(0,Q.c)(17),{cancelHistoryPrepend:n,isLoading:r,onLoad:i,prepareForHistoryPrepend:a,scrollStateStore:o}=e,s=Cg(o,qg),c;t[0]!==n||t[1]!==r||t[2]!==i||t[3]!==a?(c=()=>{r||(a(),i().finally(n))},t[0]=n,t[1]=r,t[2]=i,t[3]=a,t[4]=c):c=t[4];let l=c,u,d;t[5]!==r||t[6]!==s||t[7]!==l?(u=()=>{s&&!r&&l()},d=[r,s,l],t[5]=r,t[6]=s,t[7]=l,t[8]=u,t[9]=d):(u=t[8],d=t[9]),Z.useEffect(u,d);let f;t[10]===r?f=t[11]:(f=r?(0,$.jsx)(wt,{}):null,t[10]=r,t[11]=f);let p=r?`Loading earlier messages…`:`Load earlier messages`,m;return t[12]!==r||t[13]!==l||t[14]!==f||t[15]!==p?(m=(0,$.jsx)(`div`,{className:`flex justify-center py-3`,children:(0,$.jsxs)(Y,{type:`button`,variant:`ghost`,size:`sm`,disabled:r,onClick:l,children:[f,p]})}),t[12]=r,t[13]=l,t[14]=f,t[15]=p,t[16]=m):m=t[16],m}function qg(e){return e.isMessagesNearTop}function Jg(e){let t=(0,Q.c)(57),{autoScrollEnabled:n,children:r,centerMessages:i,conversationItemsStore:a,isLoadingOlderHistory:o,isSessionViewLoading:s,onLoadOlderHistory:c,ref:l,sessionState:u}=e,d;t[0]!==n||t[1]!==s||t[2]!==u?(d={autoScrollEnabled:n,isSessionViewLoading:s,sessionState:u},t[0]=n,t[1]=s,t[2]=u,t[3]=d):d=t[3];let{bottomRef:f,cancelHistoryPrepend:p,jumpToNextMessage:m,jumpToPreviousMessage:h,messagesContentRef:g,messagesScrollAreaRef:_,prepareForHistoryPrepend:v,scrollConversationToBottom:y,scrollConversationToTop:b,scrollStateStore:x,syncAfterConversationChange:S}=Rg(d),C;t[4]===s?C=t[5]:(C={disabled:s},t[4]=s,t[5]=C);let{bottomHeight:w,onScroll:T,setScrollElement:E,topHeight:D}=hr(C),O;t[6]!==_||t[7]!==E?(O=e=>{_.current=e,E(e)},t[6]=_,t[7]=E,t[8]=O):O=t[8];let k=O,A,j;t[9]!==m||t[10]!==h||t[11]!==y||t[12]!==b?(A=()=>({jumpToNextMessage:m,jumpToPreviousMessage:h,scrollConversationToBottom:y,scrollConversationToTop:b}),j=[m,h,y,b],t[9]=m,t[10]=h,t[11]=y,t[12]=b,t[13]=A,t[14]=j):(A=t[13],j=t[14]),Z.useImperativeHandle(l,A,j);let M;t[15]!==a||t[16]!==s||t[17]!==S?(M=(0,$.jsx)(Bg,{conversationItemsStore:a,disabled:s,onRevisionChange:S}),t[15]=a,t[16]=s,t[17]=S,t[18]=M):M=t[18];let N;t[19]!==p||t[20]!==o||t[21]!==s||t[22]!==c||t[23]!==v||t[24]!==x||t[25]!==u.historyOffset?(N=u.historyOffset>0&&!s?(0,$.jsx)(Kg,{cancelHistoryPrepend:p,isLoading:o,onLoad:c,prepareForHistoryPrepend:v,scrollStateStore:x}):null,t[19]=p,t[20]=o,t[21]=s,t[22]=c,t[23]=v,t[24]=x,t[25]=u.historyOffset,t[26]=N):N=t[26];let P;t[27]!==r||t[28]!==S||t[29]!==N?(P=(0,$.jsxs)(Ug.Provider,{value:S,children:[N,r]}),t[27]=r,t[28]=S,t[29]=N,t[30]=P):P=t[30];let F;t[31]===f?F=t[32]:(F=(0,$.jsx)(`div`,{ref:f}),t[31]=f,t[32]=F);let I;t[33]!==g||t[34]!==M||t[35]!==P||t[36]!==F?(I=(0,$.jsxs)(`div`,{ref:g,className:`flex min-h-full flex-col`,children:[M,P,F]}),t[33]=g,t[34]=M,t[35]=P,t[36]=F,t[37]=I):I=t[37];let L;t[38]!==T||t[39]!==k||t[40]!==I?(L=(0,$.jsx)(`div`,{ref:k,"data-conversation-viewport":`true`,tabIndex:0,role:`region`,"aria-label":`Conversation messages`,className:`h-full overflow-x-hidden overflow-y-auto overscroll-contain px-4 outline-none [overflow-anchor:none]`,onScroll:T,children:I}),t[38]=T,t[39]=k,t[40]=I,t[41]=L):L=t[41];let R;t[42]!==w||t[43]!==D?(R=(0,$.jsx)(Rn,{bottomHeight:w,topHeight:D}),t[42]=w,t[43]=D,t[44]=R):R=t[44];let z;t[45]!==i||t[46]!==a||t[47]!==s||t[48]!==h||t[49]!==y||t[50]!==x||t[51]!==u.draft?(z=s?null:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(zg,{conversationItemsStore:a,draft:u.draft,onClick:y,scrollStateStore:x}),(0,$.jsx)(Vg,{centerMessages:i,onClick:h,scrollStateStore:x})]}),t[45]=i,t[46]=a,t[47]=s,t[48]=h,t[49]=y,t[50]=x,t[51]=u.draft,t[52]=z):z=t[52];let B;return t[53]!==L||t[54]!==R||t[55]!==z?(B=(0,$.jsxs)(`div`,{className:`relative min-h-0 flex-1`,children:[L,R,z]}),t[53]=L,t[54]=R,t[55]=z,t[56]=B):B=t[56],B}function Yg(e){let t=(0,Q.c)(3),{fallbackLabel:n,hiddenThinkingPreviewStore:r,useHiddenThinkingPreview:i}=e,a=ka(r),o=i&&a?a:n;if(!o.trim()){let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(`div`,{"aria-hidden":`true`,className:`invisible leading-5 font-medium`,children:`Working…`}),t[0]=e):e=t[0],e}let s;return t[1]===o?s=t[2]:(s=(0,$.jsx)(`div`,{className:`leading-5 font-medium text-foreground`,children:o}),t[1]=o,t[2]=s),s}function Xg(e){let t=(0,Q.c)(25),{hiddenThinkingPreviewStore:n,onCancel:i,state:a,useHiddenThinkingPreview:o}=e,s;t[0]!==a.done||t[1]!==a.error?(s=(0,$.jsx)(`span`,{className:`mt-0.5 inline-flex items-center justify-center`,children:a.done?(0,$.jsx)(cn,{className:`size-4 text-emerald-600`}):a.error?(0,$.jsx)(Di,{className:`size-4 text-destructive`}):(0,$.jsx)(wt,{})}),t[0]=a.done,t[1]=a.error,t[2]=s):s=t[2];let c;t[3]!==n||t[4]!==a.done||t[5]!==a.error||t[6]!==a.label||t[7]!==o?(c=(0,$.jsx)(`div`,{className:`min-w-0 shrink-0`,children:a.done?(0,$.jsx)(`div`,{className:`font-medium text-foreground`,children:`Done`}):a.error?(0,$.jsx)(`div`,{className:`font-medium text-destructive`,children:a.label}):(0,$.jsx)(Yg,{fallbackLabel:a.label,hiddenThinkingPreviewStore:n,useHiddenThinkingPreview:o})}),t[3]=n,t[4]=a.done,t[5]=a.error,t[6]=a.label,t[7]=o,t[8]=c):c=t[8];let l;t[9]!==i||t[10]!==a.cancelable||t[11]!==a.done||t[12]!==a.error?(l=a.cancelable&&!a.done&&!a.error&&i?(0,$.jsxs)(Y,{type:`button`,variant:`outline`,size:`xs`,className:`gap-1.5 text-xs`,onClick:i,children:[`Cancel`,(0,$.jsx)(r,{children:`Esc`})]}):null,t[9]=i,t[10]=a.cancelable,t[11]=a.done,t[12]=a.error,t[13]=l):l=t[13];let u;t[14]!==c||t[15]!==l?(u=(0,$.jsxs)(`div`,{className:`flex min-h-5 min-w-0 items-center justify-start gap-2`,children:[c,l]}),t[14]=c,t[15]=l,t[16]=u):u=t[16];let d;t[17]===a.summary?d=t[18]:(d=a.summary?(0,$.jsx)(`div`,{className:`truncate text-muted-foreground`,children:a.summary}):null,t[17]=a.summary,t[18]=d);let f;t[19]!==u||t[20]!==d?(f=(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[u,d]}),t[19]=u,t[20]=d,t[21]=f):f=t[21];let p;return t[22]!==s||t[23]!==f?(p=(0,$.jsxs)(`div`,{role:`status`,"aria-live":`polite`,className:`flex w-full items-start gap-3 rounded-xl p-1 text-sm text-muted-foreground`,children:[s,f]}),t[22]=s,t[23]=f,t[24]=p):p=t[24],p}function Zg(e){let t=(0,Q.c)(11),{className:n,group:r,hideFooter:i,hideThinking:a,hideToolBlocks:o,store:s}=e;if(r.kind===`user`){let e;return t[0]!==n||t[1]!==r.itemKey||t[2]!==s?(e=(0,$.jsx)(Qg,{className:n,itemKey:r.itemKey,store:s}),t[0]=n,t[1]=r.itemKey,t[2]=s,t[3]=e):e=t[3],e}let c;return t[4]!==n||t[5]!==r.key||t[6]!==i||t[7]!==a||t[8]!==o||t[9]!==s?(c=(0,$.jsx)(e_,{className:n,groupKey:r.key,hideFooter:i,hideThinking:a,hideToolBlocks:o,store:s}),t[4]=n,t[5]=r.key,t[6]=i,t[7]=a,t[8]=o,t[9]=s,t[10]=c):c=t[10],c}function Qg(e){let t=(0,Q.c)(5),{className:n,itemKey:r,store:i}=e,a=vg(i,r);if(!a||a.kind!==`user`)return null;let o;t[0]===a?o=t[1]:(o=(0,$.jsx)(ih,{item:a}),t[0]=a,t[1]=o);let s;return t[2]!==n||t[3]!==o?(s=(0,$.jsx)(`div`,{"data-message-anchor":`true`,className:n,children:o}),t[2]=n,t[3]=o,t[4]=s):s=t[4],s}function $g(e,t){let n=(0,Q.c)(7),r;n[0]!==t||n[1]!==e?(r=n=>e.subscribeAssistantGroupItems(t,n),n[0]=t,n[1]=e,n[2]=r):r=n[2];let i,a;return n[3]!==t||n[4]!==e?(i=()=>e.getAssistantGroupItemKeys(t),a=()=>e.getAssistantGroupItemKeys(t),n[3]=t,n[4]=e,n[5]=i,n[6]=a):(i=n[5],a=n[6]),Z.useSyncExternalStore(r,i,a)}function e_({className:e,groupKey:t,hideFooter:n,hideThinking:r,hideToolBlocks:i,store:a}){let o=$g(a,t),s=Z.use(Ug),c=Z.useRef(null);c.current||=xg(yg({hideThinking:r,hideToolBlocks:i,itemKeys:o,store:a}));let l=c.current;return Z.useLayoutEffect(()=>{let e=()=>{l.setSnapshot(yg({hideThinking:r,hideToolBlocks:i,itemKeys:o,store:a})),s?.()};return e(),a.subscribeItems(o,e)},[l,r,i,o,a,s]),(0,$.jsx)(gh,{className:e,hideFooter:n,store:l})}function t_(e){let t=(0,Q.c)(20),{centerMessages:n,conversationItemsStore:r,hideFooter:i,hideThinking:a,hideToolBlocks:o}=e,s=n?`mx-auto w-full max-w-[80ch]`:`w-full`,c;t[0]!==r||t[1]!==i||t[2]!==a||t[3]!==o?(c={store:r,hideFooter:i,hideThinking:a,hideToolBlocks:o},t[0]=r,t[1]=i,t[2]=a,t[3]=o,t[4]=c):c=t[4];let l=_g(c);if(l.length===0)return null;let u;if(t[5]!==r||t[6]!==s||t[7]!==i||t[8]!==a||t[9]!==o||t[10]!==l){let e;t[12]!==r||t[13]!==s||t[14]!==i||t[15]!==a||t[16]!==o?(e=e=>(0,$.jsx)(Zg,{className:s,group:e,hideFooter:i,hideThinking:a,hideToolBlocks:o,store:r},e.key),t[12]=r,t[13]=s,t[14]=i,t[15]=a,t[16]=o,t[17]=e):e=t[17],u=l.map(e),t[5]=r,t[6]=s,t[7]=i,t[8]=a,t[9]=o,t[10]=l,t[11]=u}else u=t[11];let d;return t[18]===u?d=t[19]:(d=(0,$.jsx)($.Fragment,{children:u}),t[18]=u,t[19]=d),d}function n_(e){let t=(0,Q.c)(23),{awaitingFirstTurn:n,conversationItemsStore:r,draft:i,cwd:a,isSessionViewLoading:o,isSubmitting:s,onCreateSession:c,streaming:l,viewerContextId:u,workingStateStore:d}=e,f=hg(r),p=gg(r),m=ka(d),h;t[0]!==p||t[1]!==m?(h=m||(p?{label:`Done`,done:!0}:null),t[0]=p,t[1]=m,t[2]=h):h=t[2];let g=h,_=!!(o||!i&&!f&&(s||n||l||g)),v=o?`Loading session…`:g&&!g.done?g.label:`Loading…`;if(_){let e;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(wt,{}),t[3]=e):e=t[3];let n;t[4]===v?n=t[5]:(n=v?(0,$.jsx)(`div`,{children:v}):null,t[4]=v,t[5]=n);let r;return t[6]===n?r=t[7]:(r=(0,$.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-center gap-3 py-10 text-sm text-muted-foreground`,children:[e,n]}),t[6]=n,t[7]=r),r}if(f)return null;let y=i?`New session`:`Start a new conversation`,b;t[8]===y?b=t[9]:(b=(0,$.jsx)(Qh,{children:y}),t[8]=y,t[9]=b);let x=i?void 0:`This is the native Pico session view backed by the new TypeScript runtime.`,S;t[10]===x?S=t[11]:(S=(0,$.jsx)($h,{children:x}),t[10]=x,t[11]=S);let C;t[12]!==b||t[13]!==S?(C=(0,$.jsxs)(Yh,{children:[b,S]}),t[12]=b,t[13]=S,t[14]=C):C=t[14];let w;t[15]!==a||t[16]!==i||t[17]!==c||t[18]!==u?(w=i?(0,$.jsxs)(eg,{className:`flex flex-col items-center gap-3`,children:[a?(0,$.jsx)(bs,{variant:`outline`,children:Bi(a)}):null,(0,$.jsx)(og,{viewerContextId:u,cwd:a})]}):(0,$.jsx)(eg,{children:(0,$.jsx)(Y,{onClick:c,children:`New session`})}),t[15]=a,t[16]=i,t[17]=c,t[18]=u,t[19]=w):w=t[19];let T;return t[20]!==C||t[21]!==w?(T=(0,$.jsxs)(Jh,{children:[C,w]}),t[20]=C,t[21]=w,t[22]=T):T=t[22],T}function r_(e){let t=(0,Q.c)(11),{centerMessages:n,conversationItemsStore:r,hiddenThinkingPreviewStore:i,hideThinking:a,onCancelCompaction:o,streaming:s,workingStateStore:c}=e,l=hg(r),u=gg(r),d=n?`mx-auto w-full max-w-[80ch]`:`w-full`,f=ka(c),p;t[0]!==u||t[1]!==f?(p=f||(u?{label:`Done`,done:!0}:null),t[0]=u,t[1]=f,t[2]=p):p=t[2];let m=p;if(!l||!m)return null;let h=`${d} mt-4`,g=s&&a,_;t[3]!==m||t[4]!==i||t[5]!==o||t[6]!==g?(_=(0,$.jsx)(Xg,{hiddenThinkingPreviewStore:i,onCancel:o,state:m,useHiddenThinkingPreview:g}),t[3]=m,t[4]=i,t[5]=o,t[6]=g,t[7]=_):_=t[7];let v;return t[8]!==h||t[9]!==_?(v=(0,$.jsx)(`div`,{className:h,children:_}),t[8]=h,t[9]=_,t[10]=v):v=t[10],v}function i_(e){let t=(0,Q.c)(5),{centerMessages:n,conversationItemsStore:r,hideToolBlocks:i,sessionStore:a}=e,o=ka(a,a_);if(!hg(r))return null;let s;return t[0]!==n||t[1]!==r||t[2]!==o||t[3]!==i?(s=(0,$.jsx)(`div`,{className:`flex flex-col gap-4 pt-4`,children:(0,$.jsx)(t_,{centerMessages:n,conversationItemsStore:r,hideFooter:!1,hideThinking:o,hideToolBlocks:i})}),t[0]=n,t[1]=r,t[2]=o,t[3]=i,t[4]=s):s=t[4],s}function a_(e){return e.hideThinkingBlock}var o_=Z.memo(function(e){let t=(0,Q.c)(41),{awaitingFirstTurn:n,conversationFrameRef:r,conversationItemsStore:i,displaySettingsStore:a,hiddenThinkingPreviewStore:o,isLoadingOlderHistory:s,isSessionViewLoading:c,isSubmitting:l,onCancelCompaction:u,onCreateSession:d,onLoadOlderHistory:f,sessionStore:p,viewerContextId:m,workingStateStore:h}=e,g=Wg(p),{autoScrollEnabled:_,centerMessages:v,hideToolBlocks:y}=ka(a),b=ka(p,s_),x;t[0]!==i||t[1]!==p?(x=()=>{i.setItems(p.state.items)},t[0]=i,t[1]=p,t[2]=x):x=t[2];let S;t[3]!==i||t[4]!==b||t[5]!==y||t[6]!==p?(S=[i,b,y,p],t[3]=i,t[4]=b,t[5]=y,t[6]=p,t[7]=S):S=t[7],Z.useLayoutEffect(x,S);let C;t[8]!==n||t[9]!==i||t[10]!==c||t[11]!==l||t[12]!==d||t[13]!==g.cwd||t[14]!==g.draft||t[15]!==g.streaming||t[16]!==m||t[17]!==h?(C=(0,$.jsx)(n_,{awaitingFirstTurn:n,conversationItemsStore:i,cwd:g.cwd,draft:g.draft,isSessionViewLoading:c,isSubmitting:l,onCreateSession:d,streaming:g.streaming,viewerContextId:m,workingStateStore:h}),t[8]=n,t[9]=i,t[10]=c,t[11]=l,t[12]=d,t[13]=g.cwd,t[14]=g.draft,t[15]=g.streaming,t[16]=m,t[17]=h,t[18]=C):C=t[18];let w;t[19]!==v||t[20]!==i||t[21]!==o||t[22]!==b||t[23]!==y||t[24]!==c||t[25]!==u||t[26]!==g.streaming||t[27]!==p||t[28]!==h?(w=c?null:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(i_,{centerMessages:v,conversationItemsStore:i,hideToolBlocks:y,sessionStore:p}),(0,$.jsx)(r_,{centerMessages:v,conversationItemsStore:i,hiddenThinkingPreviewStore:o,hideThinking:b,onCancelCompaction:u,streaming:g.streaming,workingStateStore:h})]}),t[19]=v,t[20]=i,t[21]=o,t[22]=b,t[23]=y,t[24]=c,t[25]=u,t[26]=g.streaming,t[27]=p,t[28]=h,t[29]=w):w=t[29];let T;return t[30]!==_||t[31]!==v||t[32]!==r||t[33]!==i||t[34]!==s||t[35]!==c||t[36]!==f||t[37]!==g||t[38]!==C||t[39]!==w?(T=(0,$.jsxs)(Jg,{ref:r,autoScrollEnabled:_,centerMessages:v,conversationItemsStore:i,isLoadingOlderHistory:s,isSessionViewLoading:c,onLoadOlderHistory:f,sessionState:g,children:[C,w]}),t[30]=_,t[31]=v,t[32]=r,t[33]=i,t[34]=s,t[35]=c,t[36]=f,t[37]=g,t[38]=C,t[39]=w,t[40]=T):T=t[40],T});function s_(e){return e.hideThinkingBlock}function c_(e){let t=(0,Q.c)(43),{actionsRef:n,awaitingFirstTurn:r,composerPanelRef:i,contextUsageStore:a,conversationFrameRef:o,conversationItemsStore:s,defaultNewSessionDirectory:c,displaySettingsStore:l,fileInputRef:u,hiddenThinkingPreviewStore:d,isLoadingOlderHistory:f,isSessionViewLoading:p,isSubmitting:m,newSessionDirectoryOptions:h,onCancelCompaction:g,onCreateSession:_,onLoadOlderHistory:v,onOpenAddDirectoryDialog:y,sessionStore:b,store:x,viewerContextId:S,workingStateStore:C}=e,w;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(w={compare:Ni},t[0]=w):w=t[0];let T=ka(b,l_,w),E=hg(s);if(T.draft&&!E&&!p){let e;t[1]!==c||t[2]!==h||t[3]!==_||t[4]!==y||t[5]!==T.cwd||t[6]!==S?(e=(0,$.jsx)(Uh,{cwd:T.cwd,defaultNewSessionDirectory:c,directoryOptions:h,onCreateSession:_,onOpenAddDirectoryDialog:y,viewerContextId:S}),t[1]=c,t[2]=h,t[3]=_,t[4]=y,t[5]=T.cwd,t[6]=S,t[7]=e):e=t[7];let r;return t[8]!==n||t[9]!==i||t[10]!==a||t[11]!==l||t[12]!==u||t[13]!==b||t[14]!==x||t[15]!==e?(r=(0,$.jsx)(`div`,{className:`grid min-h-0 flex-1 items-end justify-items-center overflow-auto p-4 md:place-items-center`,children:(0,$.jsx)(qh,{actionsRef:n,composerPanelRef:i,contextUsageStore:a,displaySettingsStore:l,fileInputRef:u,sessionStore:b,store:x,topContent:e})}),t[8]=n,t[9]=i,t[10]=a,t[11]=l,t[12]=u,t[13]=b,t[14]=x,t[15]=e,t[16]=r):r=t[16],r}let D;t[17]!==r||t[18]!==o||t[19]!==s||t[20]!==l||t[21]!==d||t[22]!==f||t[23]!==p||t[24]!==m||t[25]!==g||t[26]!==_||t[27]!==v||t[28]!==b||t[29]!==S||t[30]!==C?(D=(0,$.jsx)(o_,{awaitingFirstTurn:r,conversationFrameRef:o,conversationItemsStore:s,displaySettingsStore:l,hiddenThinkingPreviewStore:d,isLoadingOlderHistory:f,isSessionViewLoading:p,isSubmitting:m,onCancelCompaction:g,onCreateSession:_,onLoadOlderHistory:v,sessionStore:b,viewerContextId:S,workingStateStore:C}),t[17]=r,t[18]=o,t[19]=s,t[20]=l,t[21]=d,t[22]=f,t[23]=p,t[24]=m,t[25]=g,t[26]=_,t[27]=v,t[28]=b,t[29]=S,t[30]=C,t[31]=D):D=t[31];let O;t[32]!==n||t[33]!==i||t[34]!==a||t[35]!==l||t[36]!==u||t[37]!==b||t[38]!==x?(O=(0,$.jsx)(qh,{actionsRef:n,composerPanelRef:i,contextUsageStore:a,displaySettingsStore:l,fileInputRef:u,sessionStore:b,store:x}),t[32]=n,t[33]=i,t[34]=a,t[35]=l,t[36]=u,t[37]=b,t[38]=x,t[39]=O):O=t[39];let k;return t[40]!==D||t[41]!==O?(k=(0,$.jsxs)($.Fragment,{children:[D,O]}),t[40]=D,t[41]=O,t[42]=k):k=t[42],k}function l_(e){return{cwd:e.cwd,draft:e.draft}}function u_(){let e=ft(St);return e===`files`||e===`review`?e:`review`}function d_(e){e===`commit-diff`||e===`history`||ye(St,e)}function f_(e,t){vl(e,`activeTab`,t),d_(t)}function p_(){return{activeTab:u_(),fileActivePath:``,filePreviewPath:``,fileTabs:[],fileTreeCollapsed:!1}}function m_(e){return e.filePreviewPath&&!e.fileTabs.includes(e.filePreviewPath)?[...e.fileTabs,e.filePreviewPath]:e.fileTabs}function h_(e){return m_(e).length>0}function g_(e){_l(e,e=>({...e,fileActivePath:``,filePreviewPath:``,fileTabs:[],fileTreeCollapsed:!1}))}function __(e,t,n){t&&(d_(`files`),_l(e,e=>{let r=!!n?.pin||e.fileTabs.includes(t)||e.fileActivePath===t,i=r?e.fileTabs.includes(t)?e.fileTabs:[...e.fileTabs,t]:e.fileTabs,a=r?e.filePreviewPath===t?``:e.filePreviewPath:t;return{...e,activeTab:`files`,fileActivePath:t,filePreviewPath:a,fileTabs:i,fileTreeCollapsed:!1}}))}function v_(e,t){_l(e,e=>{let n=m_(e).indexOf(t),r=e.fileTabs.filter(e=>e!==t),i=e.filePreviewPath===t?``:e.filePreviewPath,a=i&&!r.includes(i)?[...r,i]:r,o=e.fileActivePath===t?a[Math.max(0,n-1)]||a[0]||``:e.fileActivePath;return{...e,fileActivePath:o,filePreviewPath:i,fileTabs:r}})}function y_(e,t){_l(e,e=>{let n=e.fileTabs.includes(t)?[t]:[];return{...e,fileActivePath:t,filePreviewPath:n.length===0?t:``,fileTabs:n}})}function b_(e,t){_l(e,e=>{let n=m_(e),r=n.indexOf(t);if(r<0)return e;let i=new Set(n.slice(0,r+1)),a=e.fileTabs.filter(e=>i.has(e)),o=i.has(e.filePreviewPath)?e.filePreviewPath:``,s=o&&!a.includes(o)?[...a,o]:a;return{...e,fileActivePath:s.includes(e.fileActivePath)?e.fileActivePath:t,filePreviewPath:o,fileTabs:a}})}function x_(e){_l(e,e=>({...e,fileActivePath:``,filePreviewPath:``,fileTabs:[]}))}function S_(e,t){let n=t.filter((e,n)=>e&&t.indexOf(e)===n);n.length!==0&&_l(e,e=>({...e,fileActivePath:n.includes(e.fileActivePath)?e.fileActivePath:n[0]||``,filePreviewPath:``,fileTabs:n}))}var C_=Z.lazy(async()=>({default:(await pt(()=>import(`./right-sidebar-CWvXcZzC.js`),__vite__mapDeps([0,1,2,3,4,5,6,7]))).RightSidebar})),w_=Z.lazy(async()=>({default:(await pt(()=>import(`./terminal-panel-YGR6v-ZH.js`),__vite__mapDeps([8,1,3,6,7,9]))).TerminalPanel}));function T_(e){let t=(0,Q.c)(3),{label:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsx)(wt,{}),t[0]=r):r=t[0];let i;return t[1]===n?i=t[2]:(i=(0,$.jsxs)(`div`,{className:`flex h-full min-h-24 w-full items-center justify-center gap-2 text-sm text-muted-foreground`,children:[r,(0,$.jsx)(`span`,{children:n})]}),t[1]=n,t[2]=i),i}function E_(e,t){return e.cwd===t.cwd&&e.sessionId===t.sessionId}function D_(e){let t=(0,Q.c)(7),{sessionStore:n,viewerContextId:r}=e,i=ka(n,O_),a;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,$.jsx)(Iu,{value:`session`,className:`h-8 data-active:bg-muted dark:data-active:bg-muted`,children:`Session`}),t[0]=a):a=t[0];let o;t[1]!==i||t[2]!==r?(o=(0,$.jsx)(Iu,{value:`git`,className:`h-8 data-active:bg-muted dark:data-active:bg-muted`,children:(0,$.jsx)(tg,{viewerContextId:r,cwd:i})}),t[1]=i,t[2]=r,t[3]=o):o=t[3];let s;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,$.jsx)(Iu,{value:`terminal`,className:`h-8 data-active:bg-muted dark:data-active:bg-muted`,children:`Terminal`}),t[4]=s):s=t[4];let c;return t[5]===o?c=t[6]:(c=(0,$.jsxs)(Fu,{className:`w-full gap-2 rounded-none border-b border-border/70 bg-background p-2 group-data-horizontal/tabs:h-auto md:hidden`,children:[a,o,s]}),t[5]=o,t[6]=c),c}function O_(e){return e.cwd}var k_=Z.memo(function(e){let t=(0,Q.c)(27),{active:n,composerDiffLineComments:r,onAddDiffLineComment:i,onCloseAllFiles:a,onCloseFile:o,onCloseFilesToRight:s,onCloseOtherFiles:c,onOpenFile:l,onReorderFiles:u,rightSidebarStore:d,sessionStore:f,viewerContextId:p}=e,m=ka(f,ov),h=ka(d,sv),g=ka(d,cv),_=ka(d,lv),v;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(v={compare:Mi},t[0]=v):v=t[0];let y=ka(d,m_,v),b=ka(d,uv),x;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,$.jsx)(T_,{label:`Loading files…`}),t[1]=x):x=t[1];let S,C;t[2]===d?(S=t[3],C=t[4]):(S=e=>{vl(d,`fileActivePath`,e)},C=e=>{f_(d,e)},t[2]=d,t[3]=S,t[4]=C);let w;t[5]===d?w=t[6]:(w=e=>{vl(d,`fileTreeCollapsed`,e)},t[5]=d,t[6]=w);let T;return t[7]!==n||t[8]!==h||t[9]!==g||t[10]!==r||t[11]!==m||t[12]!==_||t[13]!==y||t[14]!==b||t[15]!==i||t[16]!==a||t[17]!==o||t[18]!==s||t[19]!==c||t[20]!==l||t[21]!==u||t[22]!==S||t[23]!==C||t[24]!==w||t[25]!==p?(T=(0,$.jsx)(Z.Suspense,{fallback:x,children:(0,$.jsx)(C_,{viewerContextId:p,cwd:m,active:n,activeFilePath:h,activeTab:g,diffLineComments:r,filePreviewPath:_,fileTabs:y,fileTreeCollapsed:b,onActiveFileChange:S,onActiveTabChange:C,onAddDiffLineComment:i,onCloseAllFiles:a,onCloseFile:o,onCloseFilesToRight:s,onCloseOtherFiles:c,onFileTreeCollapsedChange:w,onOpenFile:l,onReorderFiles:u})}),t[7]=n,t[8]=h,t[9]=g,t[10]=r,t[11]=m,t[12]=_,t[13]=y,t[14]=b,t[15]=i,t[16]=a,t[17]=o,t[18]=s,t[19]=c,t[20]=l,t[21]=u,t[22]=S,t[23]=C,t[24]=w,t[25]=p,t[26]=T):T=t[26],T});function A_(e){let t=(0,Q.c)(31),{active:n,composerDiffLineComments:r,onAddDiffLineComment:i,onCloseAllFiles:a,onCloseFile:o,onCloseFilesToRight:s,onCloseOtherFiles:c,onOpenFile:l,onReorderFiles:u,rightSidebarStore:d,sessionStore:f,viewerContextId:p}=e,m=ka(f,F_),h=ka(d,P_),g=ka(d,N_),_=ka(d,M_),v;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(v={compare:Mi},t[0]=v):v=t[0];let y=ka(d,m_,v),b=ka(d,j_),x=!n,S=n?`open`:`closed`,C;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(C=(0,$.jsx)(T_,{label:`Loading files…`}),t[1]=C):C=t[1];let w,T;t[2]===d?(w=t[3],T=t[4]):(w=e=>{vl(d,`fileActivePath`,e)},T=e=>{f_(d,e)},t[2]=d,t[3]=w,t[4]=T);let E;t[5]===d?E=t[6]:(E=e=>{vl(d,`fileTreeCollapsed`,e)},t[5]=d,t[6]=E);let D;t[7]!==n||t[8]!==h||t[9]!==g||t[10]!==r||t[11]!==m||t[12]!==_||t[13]!==y||t[14]!==b||t[15]!==i||t[16]!==a||t[17]!==o||t[18]!==s||t[19]!==c||t[20]!==l||t[21]!==u||t[22]!==w||t[23]!==T||t[24]!==E||t[25]!==p?(D=(0,$.jsx)(Z.Suspense,{fallback:C,children:(0,$.jsx)(C_,{viewerContextId:p,cwd:m,active:n,activeFilePath:h,activeTab:g,diffLineComments:r,filePreviewPath:_,fileTabs:y,fileTreeCollapsed:b,onActiveFileChange:w,onActiveTabChange:T,onAddDiffLineComment:i,onCloseAllFiles:a,onCloseFile:o,onCloseFilesToRight:s,onCloseOtherFiles:c,onFileTreeCollapsedChange:E,onOpenFile:l,onReorderFiles:u,showToolbar:!1})}),t[7]=n,t[8]=h,t[9]=g,t[10]=r,t[11]=m,t[12]=_,t[13]=y,t[14]=b,t[15]=i,t[16]=a,t[17]=o,t[18]=s,t[19]=c,t[20]=l,t[21]=u,t[22]=w,t[23]=T,t[24]=E,t[25]=p,t[26]=D):D=t[26];let O;return t[27]!==x||t[28]!==S||t[29]!==D?(O=(0,$.jsx)(`aside`,{"aria-label":`Right sidebar`,"aria-hidden":x,"data-state":S,className:`flex h-full min-h-0 w-full min-w-0 flex-col border-l border-border/70 bg-background data-[state=closed]:pointer-events-none data-[state=closed]:border-transparent`,children:D}),t[27]=x,t[28]=S,t[29]=D,t[30]=O):O=t[30],O}function j_(e){return e.fileTreeCollapsed}function M_(e){return e.filePreviewPath}function N_(e){return e.activeTab}function P_(e){return e.fileActivePath}function F_(e){return e.cwd}var I_=520,L_=320,R_=320,z_=260,B_=1600,V_=280,H_=160,U_=220,W_=1200;function G_(){return{fileViewWidth:I_,gitPanelWidth:L_}}function K_(e,t){let n=typeof e==`number`?e:Number(e);return Number.isFinite(n)?Math.round(Math.min(B_,Math.max(z_,n))):t}function q_(e){if(!e||typeof e!=`object`)return G_();let t=e;return{fileViewWidth:K_(t.fileViewWidth,I_),gitPanelWidth:K_(t.gitPanelWidth,L_)}}function J_(){try{let e=ft(Re);return e?q_(JSON.parse(e)):G_()}catch{return G_()}}function Y_(e){ye(Re,JSON.stringify(q_(e)))}function X_(e,t){return e.fileViewWidth===t.fileViewWidth&&e.gitPanelWidth===t.gitPanelWidth}function Z_(e){if(e==null||e===``)return V_;let t=typeof e==`number`?e:Number(e);return Number.isFinite(t)?Math.round(Math.min(W_,Math.max(H_,t))):V_}function Q_(){return Z_(ft(A))}function $_(e){ye(A,String(Z_(e)))}function ev(e,t,n){return Number.isFinite(e)?n<=t?Math.max(0,n):Math.min(n,Math.max(t,e)):t}function tv({availableWidth:e,fileOpen:t,fileWidth:n,gitOpen:r,gitWidth:i}){let a=Math.max(0,e-R_);if(!t&&!r)return{fileWidth:0,gitWidth:0,sideWidth:0};if(t&&!r){let e=ev(n,Math.min(z_,a),a);return{fileWidth:e,gitWidth:0,sideWidth:e}}if(!t&&r){let e=ev(i,Math.min(z_,a),a);return{fileWidth:0,gitWidth:e,sideWidth:e}}let o=Math.max(1,n+i);if(o<=a)return{fileWidth:n,gitWidth:i,sideWidth:n+i};let s=Math.min(z_,a/2),c=Math.round(n/o*a);c=Math.max(s,Math.min(a-s,c));let l=Math.max(0,a-c);return{fileWidth:c,gitWidth:l,sideWidth:c+l}}function nv(e){let t=(0,Q.c)(24),{label:n,max:r,min:i,onResize:a,onResizeEnd:o,onResizeStart:s,size:c}=e,l;t[0]!==r||t[1]!==i||t[2]!==a||t[3]!==o||t[4]!==s||t[5]!==c?(l={max:r,min:i,onResize:a,onResizeEnd:o,onResizeStart:s,size:c},t[0]=r,t[1]=i,t[2]=a,t[3]=o,t[4]=s,t[5]=c,t[6]=l):l=t[6];let u=Pi(l),[d,f]=Z.useState(`col-resize`),[p,m]=Z.useState(10),h,g;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(h=()=>{let e=()=>{m(wn())},t=window.matchMedia(`(pointer:coarse)`);return f(Pr()),e(),t.addEventListener(`change`,e),()=>{t.removeEventListener(`change`,e)}},g=[],t[7]=h,t[8]=g):(h=t[7],g=t[8]),Z.useEffect(h,g);let _=d===`ew-resize`?`cursor-ew-resize`:`cursor-col-resize`,v;t[9]===u?v=t[10]:(v=e=>{let t=u.current;t.onResize(ev(e,t.min,t.max))},t[9]=u,t[10]=v);let y=v,b=`${p}px`,x;t[11]!==d||t[12]!==b?(x={"--resize-target-width":b,cursor:d},t[11]=d,t[12]=b,t[13]=x):x=t[13];let S=x,C=`absolute inset-y-0 left-0 z-20 w-(--resize-target-width) -translate-x-1/2 touch-none bg-transparent outline-hidden after:absolute after:inset-y-0 after:left-1/2 after:w-px after:bg-transparent focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 ${fr} ${_}`,w,T;t[14]!==u||t[15]!==y?(T=e=>{if(e.key!==`ArrowLeft`&&e.key!==`ArrowRight`)return;e.preventDefault();let t=e.shiftKey?48:16;y(u.current.size+(e.key===`ArrowLeft`?t:-t))},w=e=>{if(e.button!==0)return;e.preventDefault();let t=u.current,n=e.clientX,r=t.size,i=Pr(),a=document.body.style.cursor,o=document.body.style.userSelect,s=Bt(i);t.onResizeStart?.(),Object.assign(document.body.style,{userSelect:`none`,cursor:i});let c=e=>{y(r+n-e.clientX)},l=()=>{s(),Object.assign(document.body.style,{userSelect:o,cursor:a}),document.removeEventListener(`pointermove`,c),document.removeEventListener(`pointerup`,l),document.removeEventListener(`pointercancel`,l),u.current.onResizeEnd?.()};document.addEventListener(`pointermove`,c),document.addEventListener(`pointerup`,l),document.addEventListener(`pointercancel`,l)},t[14]=u,t[15]=y,t[16]=w,t[17]=T):(w=t[16],T=t[17]);let E;return t[18]!==n||t[19]!==w||t[20]!==S||t[21]!==C||t[22]!==T?(E=(0,$.jsx)(`div`,{role:`separator`,"aria-label":n,"aria-orientation":`vertical`,tabIndex:0,style:S,className:C,onKeyDown:T,onPointerDown:w}),t[18]=n,t[19]=w,t[20]=S,t[21]=C,t[22]=T,t[23]=E):E=t[23],E}function rv(e){let t=(0,Q.c)(24),{label:n,max:r,min:i,onResize:a,onResizeEnd:o,onResizeStart:s,size:c}=e,l;t[0]!==r||t[1]!==i||t[2]!==a||t[3]!==o||t[4]!==s||t[5]!==c?(l={max:r,min:i,onResize:a,onResizeEnd:o,onResizeStart:s,size:c},t[0]=r,t[1]=i,t[2]=a,t[3]=o,t[4]=s,t[5]=c,t[6]=l):l=t[6];let u=Pi(l),[d,f]=Z.useState(`row-resize`),[p,m]=Z.useState(10),h,g;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(h=()=>{let e=()=>{m(wn())},t=window.matchMedia(`(pointer:coarse)`);return f(Ut()),e(),t.addEventListener(`change`,e),()=>{t.removeEventListener(`change`,e)}},g=[],t[7]=h,t[8]=g):(h=t[7],g=t[8]),Z.useEffect(h,g);let _=d===`ns-resize`?`cursor-ns-resize`:`cursor-row-resize`,v;t[9]===u?v=t[10]:(v=e=>{let t=u.current;t.onResize(ev(e,t.min,t.max))},t[9]=u,t[10]=v);let y=v,b=`${p}px`,x;t[11]!==b||t[12]!==d?(x={"--resize-target-height":b,cursor:d},t[11]=b,t[12]=d,t[13]=x):x=t[13];let S=x,C=`absolute inset-x-0 top-0 z-20 h-(--resize-target-height) -translate-y-1/2 touch-none bg-transparent outline-hidden after:absolute after:inset-x-0 after:top-1/2 after:h-px after:bg-transparent focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 ${fr} ${_}`,w,T;t[14]!==u||t[15]!==y?(T=e=>{if(e.key!==`ArrowUp`&&e.key!==`ArrowDown`)return;e.preventDefault();let t=e.shiftKey?48:16;y(u.current.size+(e.key===`ArrowUp`?t:-t))},w=e=>{if(e.button!==0)return;e.preventDefault();let t=u.current,n=e.clientY,r=t.size,i=Ut(),a=document.body.style.cursor,o=document.body.style.userSelect,s=Bt(i);t.onResizeStart?.(),Object.assign(document.body.style,{userSelect:`none`,cursor:i});let c=e=>{y(r+n-e.clientY)},l=()=>{s(),Object.assign(document.body.style,{userSelect:o,cursor:a}),document.removeEventListener(`pointermove`,c),document.removeEventListener(`pointerup`,l),document.removeEventListener(`pointercancel`,l),u.current.onResizeEnd?.()};document.addEventListener(`pointermove`,c),document.addEventListener(`pointerup`,l),document.addEventListener(`pointercancel`,l)},t[14]=u,t[15]=y,t[16]=w,t[17]=T):(w=t[16],T=t[17]);let E;return t[18]!==n||t[19]!==w||t[20]!==S||t[21]!==C||t[22]!==T?(E=(0,$.jsx)(`div`,{role:`separator`,"aria-label":n,"aria-orientation":`horizontal`,tabIndex:0,style:S,className:C,onKeyDown:T,onPointerDown:w}),t[18]=n,t[19]=w,t[20]=S,t[21]=C,t[22]=T,t[23]=E):E=t[23],E}function iv(e){return av(e)}function av({actionsRef:e,appUiStore:t,awaitingFirstTurn:n,composerDiffLineComments:r,composerPanelRef:i,contextUsageStore:a,conversationFrameRef:o,conversationItemsStore:s,defaultNewSessionDirectory:c,displaySettingsStore:l,fileInputRef:u,gitPanelOpen:d,terminalPanelOpen:f,hiddenThinkingPreviewStore:p,isLoadingOlderHistory:m,isSessionViewLoading:h,isSubmitting:g,isMobile:_,newSessionDirectoryOptions:v,onCancelCompaction:y,onCreateSession:b,onLoadOlderHistory:x,onOpenAddDirectoryDialog:S,onCloseAllFileViewTabs:C,onCloseFileViewTab:w,onCloseFileViewTabsToRight:T,onCloseOtherFileViewTabs:E,onCloseTerminalPanel:D,onAddDiffLineComment:O,onOpenFileViewTab:k,onReorderFileViewTabs:A,onValueChange:j,rightSidebarStore:M,sessionStore:N,store:P,viewerContextId:F,workingStateStore:I}){let L=ka(t,e=>e.currentTab),[R,z]=Z.useState(L===`git`),[B,V]=Z.useState(L===`terminal`);Z.useEffect(()=>{L===`git`&&z(!0),L===`terminal`&&V(!0)},[L]);let H=ka(N,e=>e.draft),U=ka(N,e=>({cwd:e.cwd,sessionId:e.sessionId}),{compare:E_}),W=_||!H||h,ee=L===`session`?`flex min-h-0 flex-1 flex-col`:`hidden min-h-0 flex-1 flex-col md:flex`,te=L===`git`?`min-h-0 flex-1 overflow-hidden md:hidden`:`hidden`,ne=L===`terminal`?`min-h-0 flex-1 overflow-hidden md:hidden`:`hidden`,G=ka(M,h_),K=!_&&d,re=!_&&d&&G,q=re||K,ie=Z.useRef(null),[J,ae]=Z.useState(0),[oe,se]=Z.useState(0),[ce,le]=Z.useState(()=>G_()),ue=Z.useRef(!1),de=Z.useRef(ce);de.current=ce;let fe=ce.fileViewWidth,pe=ce.gitPanelWidth,me=e=>{let t=de.current,n=q_(gl(t,e));X_(t,n)||(de.current=n,le(n),ue.current&&Y_(n))},he=e=>{me(t=>({...t,fileViewWidth:K_(gl(t.fileViewWidth,e),I_)}))},ge=e=>{me(t=>({...t,gitPanelWidth:K_(gl(t.gitPanelWidth,e),L_)}))},[_e,ve]=Z.useState(K),[ye,be]=Z.useState(()=>V_),xe=Z.useRef(!1),Se=Z.useRef(ye);Se.current=ye;let[Ce,we]=Z.useState(!_&&f),[Te,Ee]=Z.useState(!1),[De,Oe]=Z.useState(!1),ke=e=>{let t=Se.current,n=Z_(gl(t,e));t!==n&&(Se.current=n,be(n),xe.current&&$_(n))};Z.useEffect(()=>{let e=J_(),t=Q_();ue.current=!0,xe.current=!0,de.current=e,Se.current=t,le(t=>X_(t,e)?t:e),be(e=>e===t?e:t)},[]);let Ae=(0,$.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-1 flex-col overflow-hidden`,children:[(0,$.jsx)(`div`,{className:ee,children:(0,$.jsx)(c_,{actionsRef:e,awaitingFirstTurn:n,composerPanelRef:i,contextUsageStore:a,conversationFrameRef:o,conversationItemsStore:s,defaultNewSessionDirectory:c,displaySettingsStore:l,fileInputRef:u,hiddenThinkingPreviewStore:p,isLoadingOlderHistory:m,isSessionViewLoading:h,isSubmitting:g,newSessionDirectoryOptions:v,onCancelCompaction:y,onCreateSession:b,onLoadOlderHistory:x,onOpenAddDirectoryDialog:S,sessionStore:N,store:P,viewerContextId:F,workingStateStore:I})}),_?(0,$.jsxs)($.Fragment,{children:[R?(0,$.jsx)(`div`,{className:te,children:(0,$.jsx)(k_,{viewerContextId:F,sessionStore:N,active:L===`git`,composerDiffLineComments:r,rightSidebarStore:M,onAddDiffLineComment:O,onCloseAllFiles:C,onCloseFile:w,onCloseFilesToRight:T,onCloseOtherFiles:E,onOpenFile:k,onReorderFiles:A})}):null,B?(0,$.jsx)(`div`,{className:ne,children:(0,$.jsx)(Z.Suspense,{fallback:(0,$.jsx)(T_,{label:`Loading terminal…`}),children:(0,$.jsx)(w_,{active:L===`terminal`,cwd:U.cwd,onClose:D,sessionId:U.sessionId,showCloseButton:!1,viewerContextId:F})})}):null]}):null]});Z.useLayoutEffect(()=>{if(_){ve(!1),we(!1);return}q&&ve(!0),f&&we(!0)},[q,_,f]),Z.useLayoutEffect(()=>{if(_)return;let e=ie.current;if(!e)return;let t=()=>{ae(e.clientWidth),se(e.clientHeight)};if(t(),typeof ResizeObserver>`u`)return window.addEventListener(`resize`,t),()=>window.removeEventListener(`resize`,t);let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[_]);let je=J||(typeof window>`u`?1200:window.innerWidth),Me=oe||(typeof window>`u`?800:window.innerHeight),Ne=q||_e||K,Pe=tv({availableWidth:je,fileOpen:re,fileWidth:fe,gitOpen:K,gitWidth:pe}),Fe=q||_e,Ie=q?Pe.sideWidth:0,Le=!_&&f,Re=Le||Ce,ze=Math.max(H_,Me-U_),Be=ev(ye,Math.min(H_,ze),ze),Ve=Le?Be:0,He=!Te&&!De?`transition-[width,height] duration-200 ease-linear`:``,Ue=()=>{Ee(!0)},We=()=>{Ee(!1)},Ge=()=>{Oe(!0)},Ke=()=>{Oe(!1)},qe=Math.max(0,je-R_);return(0,$.jsxs)(Nu,{value:L,onValueChange:j,className:`flex min-h-0 flex-1 flex-col gap-0 overflow-hidden`,children:[W?(0,$.jsx)(D_,{sessionStore:N,viewerContextId:F}):null,_?(0,$.jsx)(`div`,{className:`flex min-h-0 flex-1 overflow-hidden`,children:Ae}):(0,$.jsxs)(`div`,{ref:ie,className:`flex min-h-0 flex-1 flex-col overflow-hidden`,children:[(0,$.jsxs)(`div`,{className:`relative flex min-h-0 w-full shrink-0 overflow-hidden`,style:{height:Le?`calc(100% - ${Ve}px)`:`100%`},children:[(0,$.jsx)(`div`,{"data-desktop-panel":`session`,className:`h-full min-h-0 min-w-0 shrink-0 overflow-hidden max-md:w-full! ${He}`,style:{width:q?`calc(100% - ${Ie}px)`:`100%`},children:Ae}),Fe?(0,$.jsx)(`aside`,{"aria-label":`Desktop side workspace`,"aria-hidden":!q,"data-state":q?`open`:`closed`,"data-desktop-panel":`side-workspace`,className:`hidden h-full min-h-0 min-w-0 shrink-0 overflow-visible bg-background data-[state=closed]:pointer-events-none md:flex ${He}`,style:{width:`${Ie}px`},children:Ne?(0,$.jsxs)(`div`,{"data-desktop-panel":`git`,className:`relative h-full min-h-0 min-w-0 shrink-0 overflow-visible ${He}`,style:{width:`${Ie}px`},children:[K?(0,$.jsx)(nv,{label:`Resize right sidebar`,min:Math.min(z_,qe),max:qe,size:Ie,onResize:e=>{if(!re){ge(e);return}he(Math.max(z_,e-pe))},onResizeStart:Ue,onResizeEnd:We}):null,(0,$.jsx)(`div`,{className:`h-full min-h-0 min-w-0 overflow-hidden`,children:Ne?(0,$.jsx)(A_,{viewerContextId:F,sessionStore:N,active:K,composerDiffLineComments:r,rightSidebarStore:M,onAddDiffLineComment:O,onCloseAllFiles:C,onCloseFile:w,onCloseFilesToRight:T,onCloseOtherFiles:E,onOpenFile:k,onReorderFiles:A}):null})]}):null}):null]}),Re?(0,$.jsxs)(`aside`,{"aria-label":`Terminal`,"aria-hidden":!Le,"data-state":Le?`open`:`closed`,"data-desktop-panel":`terminal`,className:`relative hidden min-h-0 w-full shrink-0 overflow-visible border-t border-border/70 bg-background data-[state=closed]:pointer-events-none data-[state=closed]:border-transparent md:flex ${He}`,style:{height:`${Ve}px`},children:[Le?(0,$.jsx)(rv,{label:`Resize terminal`,min:Math.min(H_,ze),max:ze,size:Ve,onResize:e=>{ke(ev(e,Math.min(H_,ze),ze))},onResizeStart:Ge,onResizeEnd:Ke}):null,(0,$.jsx)(`div`,{className:`h-full min-h-0 w-full min-w-0 overflow-hidden`,children:(0,$.jsx)(Z.Suspense,{fallback:(0,$.jsx)(T_,{label:`Loading terminal…`}),children:(0,$.jsx)(w_,{active:Le,cwd:U.cwd,onClose:D,sessionId:U.sessionId,viewerContextId:F})})})]}):null]})]})}function ov(e){return e.cwd}function sv(e){return e.fileActivePath}function cv(e){return e.activeTab}function lv(e){return e.filePreviewPath}function uv(e){return e.fileTreeCollapsed}var dv=Z.memo(function(e){let t=(0,Q.c)(185),{actionsRef:n,defaultNewSessionDirectory:r,displaySessionCwd:i,gitPanelOpen:a,terminalPanelOpen:o,loadingDisplaySessionTitle:s,currentSessionPinned:c,displaySettingsStore:l,isSessionViewLoading:u,newSessionDirectoryOptions:d,onToggleGitPanel:f,onToggleTerminalPanel:p,sessionStore:m,viewerContextId:h}=e,g;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(g={compare:Ni},t[0]=g):g=t[0];let _=ka(m,fv,g),v=ka(l,pv),y;t[1]!==u||t[2]!==s||t[3]!==_?(y=u?s:ji(_),t[1]=u,t[2]=s,t[3]=_,t[4]=y):y=t[4];let b=y,x,S,C,w,T,E,D,O,k,A,j,M,N,P,F,I,L;if(t[5]!==n||t[6]!==c||t[7]!==r||t[8]!==i||t[9]!==b||t[10]!==u||t[11]!==d||t[12]!==_.sessionHasFile||t[13]!==_.sessionStreaming||t[14]!==h){let e;t[32]===i?e=t[33]:(e=e=>e.path!==i,t[32]=i,t[33]=e);let a=d.filter(e);A=`sticky top-0 z-50 flex h-[var(--header-height)] w-full shrink-0 items-center border-b border-border/70 bg-background p-2`,E=`relative flex w-full items-center gap-1`,t[34]===Symbol.for(`react.memo_cache_sentinel`)?(D=(0,$.jsx)(Wo,{className:`shrink-0`}),t[34]=D):D=t[34];let o;t[35]===r?o=t[36]:(o=r?`Create a new session in ${Bi(r)}`:`Create a new session`,t[35]=r,t[36]=o);let s;t[37]===Symbol.for(`react.memo_cache_sentinel`)?(s=Ir(`Control+N`),t[37]=s):s=t[37];let l;t[38]===n?l=t[39]:(l=()=>{n.current.createSession()},t[38]=n,t[39]=l);let f;t[40]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,$.jsx)(Va,{}),t[40]=f):f=t[40];let p;t[41]===l?p=t[42]:(p=(0,$.jsx)(Y,{size:`icon`,variant:`ghost`,className:`shrink-0 md:group-data-[sidebar-state=expanded]/sidebar-wrapper:hidden`,"aria-label":`Create a new session`,onClick:l,children:f}),t[41]=l,t[42]=p),t[43]!==o||t[44]!==p?(O=(0,$.jsx)(U,{title:o,kbd:s,children:p}),t[43]=o,t[44]=p,t[45]=O):O=t[45];let m;t[46]!==u||t[47]!==_.sessionStreaming?(m=!u&&_.sessionStreaming?(0,$.jsx)(wt,{size:`xs`,className:`shrink-0`,"aria-label":`Session streaming`}):null,t[46]=u,t[47]=_.sessionStreaming,t[48]=m):m=t[48];let g;t[49]===b?g=t[50]:(g=(0,$.jsx)(`h2`,{className:`min-w-0 truncate text-[13px] leading-tight font-semibold`,children:b}),t[49]=b,t[50]=g);let v;t[51]!==b||t[52]!==g?(v=(0,$.jsx)(U,{title:b,children:g}),t[51]=b,t[52]=g,t[53]=v):v=t[53];let y;t[54]!==m||t[55]!==v?(y=(0,$.jsxs)(`div`,{className:`flex max-w-full min-w-0 items-center justify-center gap-1.5`,children:[m,v]}),t[54]=m,t[55]=v,t[56]=y):y=t[56];let R;t[57]===i?R=t[58]:(R=i?(0,$.jsx)(`span`,{className:`inline-flex min-w-0 items-center text-xs text-muted-foreground`,children:(0,$.jsx)(`span`,{className:`truncate`,children:Fi(i)})}):null,t[57]=i,t[58]=R);let z;t[59]!==i||t[60]!==h?(z=(0,$.jsx)(rg,{viewerContextId:h,cwd:i}),t[59]=i,t[60]=h,t[61]=z):z=t[61];let B;t[62]!==R||t[63]!==z?(B=(0,$.jsxs)(`div`,{className:`flex max-w-full min-w-0 items-center justify-center gap-x-2`,children:[R,z]}),t[62]=R,t[63]=z,t[64]=B):B=t[64],t[65]!==y||t[66]!==B?(k=(0,$.jsxs)(`div`,{className:`absolute left-1/2 flex w-max max-w-[calc(100%-4rem)] -translate-x-1/2 flex-col items-center justify-center gap-0 text-center`,children:[y,B]}),t[65]=y,t[66]=B,t[67]=k):k=t[67],w=`ml-auto flex flex-wrap items-center gap-1`,t[68]!==i||t[69]!==h?(T=(0,$.jsx)(ig,{viewerContextId:h,cwd:i}),t[68]=i,t[69]=h,t[70]=T):T=t[70],S=wr,t[71]===Symbol.for(`react.memo_cache_sentinel`)?(C=(0,$.jsx)(U,{title:`Session menu`,children:(0,$.jsx)(Fn,{render:(0,$.jsx)(Y,{size:`icon`,variant:`ghost`,"aria-label":`Session menu`}),children:(0,$.jsx)(Pt,{})})}),t[71]=C):C=t[71],x=Hn,j=`end`,M=`w-56`;let V;t[72]===n?V=t[73]:(V=()=>{n.current.createSession()},t[72]=n,t[73]=V);let H;t[74]===Symbol.for(`react.memo_cache_sentinel`)?(H=(0,$.jsx)(`span`,{children:`Create new session`}),t[74]=H):H=t[74];let W;t[75]===Symbol.for(`react.memo_cache_sentinel`)?(W=(0,$.jsx)(vr,{children:Ir(`Control+N`)}),t[75]=W):W=t[75],t[76]===V?N=t[77]:(N=(0,$.jsxs)(kr,{onClick:V,children:[H,W]}),t[76]=V,t[77]=N),t[78]!==n||t[79]!==r||t[80]!==d?(P=d.length>0?(0,$.jsxs)(ur,{children:[(0,$.jsx)(Xn,{children:`New session in…`}),(0,$.jsx)($n,{className:`w-72`,children:d.map(e=>(0,$.jsxs)(kr,{onClick:()=>{n.current.createSession(e.path)},children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e.label}),(0,$.jsx)(`span`,{className:`truncate`,children:Bi(e.path)})]}),e.path===r?(0,$.jsx)(vr,{children:`Default`}):null]},e.path))})]}):null,t[78]=n,t[79]=r,t[80]=d,t[81]=P):P=t[81],t[82]===Symbol.for(`react.memo_cache_sentinel`)?(F=(0,$.jsx)(Jn,{}),t[82]=F):F=t[82];let ee=!_.sessionHasFile,te;t[83]===n?te=t[84]:(te=()=>{n.current.onToggleCurrentSessionPinned()},t[83]=n,t[84]=te);let ne=c?`Unpin from sidebar`:`Pin to sidebar`,G;t[85]===ne?G=t[86]:(G=(0,$.jsx)(`span`,{children:ne}),t[85]=ne,t[86]=G),t[87]!==ee||t[88]!==te||t[89]!==G?(I=(0,$.jsx)(kr,{disabled:ee,onClick:te,children:G}),t[87]=ee,t[88]=te,t[89]=G,t[90]=I):I=t[90],L=_.sessionHasFile?(0,$.jsxs)(ur,{children:[(0,$.jsx)(Xn,{children:`Move to…`}),(0,$.jsxs)($n,{className:`w-72`,children:[a.map(e=>(0,$.jsx)(kr,{onClick:()=>{n.current.onMoveCurrentSession(e.path)},children:(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e.label}),(0,$.jsx)(`span`,{className:`truncate`,children:Bi(e.path)})]})},e.path)),(0,$.jsx)(kr,{onClick:()=>{n.current.onMoveCurrentSessionToAnyDirectory()},children:`Other directory…`})]})]}):null,t[5]=n,t[6]=c,t[7]=r,t[8]=i,t[9]=b,t[10]=u,t[11]=d,t[12]=_.sessionHasFile,t[13]=_.sessionStreaming,t[14]=h,t[15]=x,t[16]=S,t[17]=C,t[18]=w,t[19]=T,t[20]=E,t[21]=D,t[22]=O,t[23]=k,t[24]=A,t[25]=j,t[26]=M,t[27]=N,t[28]=P,t[29]=F,t[30]=I,t[31]=L}else x=t[15],S=t[16],C=t[17],w=t[18],T=t[19],E=t[20],D=t[21],O=t[22],k=t[23],A=t[24],j=t[25],M=t[26],N=t[27],P=t[28],F=t[29],I=t[30],L=t[31];let R;t[91]===n?R=t[92]:(R=()=>{n.current.onRunCompact()},t[91]=n,t[92]=R);let z;t[93]===Symbol.for(`react.memo_cache_sentinel`)?(z=(0,$.jsx)(`span`,{children:`Compact session`}),t[93]=z):z=t[93];let B;t[94]===R?B=t[95]:(B=(0,$.jsx)(kr,{onClick:R,children:z}),t[94]=R,t[95]=B);let V;t[96]===n?V=t[97]:(V=()=>{n.current.onTreeSession()},t[96]=n,t[97]=V);let H,W;t[98]===Symbol.for(`react.memo_cache_sentinel`)?(H=(0,$.jsx)(`span`,{children:`Tree`}),W=(0,$.jsx)(vr,{children:`Esc Esc`}),t[98]=H,t[99]=W):(H=t[98],W=t[99]);let ee;t[100]===V?ee=t[101]:(ee=(0,$.jsxs)(kr,{onClick:V,children:[H,W]}),t[100]=V,t[101]=ee);let te;t[102]===n?te=t[103]:(te=()=>{n.current.onForkSession()},t[102]=n,t[103]=te);let ne;t[104]===Symbol.for(`react.memo_cache_sentinel`)?(ne=(0,$.jsx)(`span`,{children:`Fork`}),t[104]=ne):ne=t[104];let G;t[105]===Symbol.for(`react.memo_cache_sentinel`)?(G=(0,$.jsx)(vr,{children:Ir(`Control+F`)}),t[105]=G):G=t[105];let K;t[106]===te?K=t[107]:(K=(0,$.jsxs)(kr,{onClick:te,children:[ne,G]}),t[106]=te,t[107]=K);let re;t[108]===Symbol.for(`react.memo_cache_sentinel`)?(re=(0,$.jsx)(Jn,{}),t[108]=re):re=t[108];let q;t[109]===n?q=t[110]:(q=()=>{n.current.onToggleHideThinking()},t[109]=n,t[110]=q);let ie=_.hideThinkingBlock?`Show thinking`:`Hide thinking`,J;t[111]===ie?J=t[112]:(J=(0,$.jsx)(`span`,{children:ie}),t[111]=ie,t[112]=J);let ae;t[113]===Symbol.for(`react.memo_cache_sentinel`)?(ae=(0,$.jsx)(vr,{children:Ir(`Control+T`)}),t[113]=ae):ae=t[113];let oe;t[114]!==q||t[115]!==J?(oe=(0,$.jsxs)(kr,{onClick:q,children:[J,ae]}),t[114]=q,t[115]=J,t[116]=oe):oe=t[116];let se;t[117]===n?se=t[118]:(se=()=>{n.current.onToggleHideToolBlocks()},t[117]=n,t[118]=se);let ce=v?`Show tools`:`Hide tools`,le;t[119]===ce?le=t[120]:(le=(0,$.jsx)(`span`,{children:ce}),t[119]=ce,t[120]=le);let ue;t[121]===Symbol.for(`react.memo_cache_sentinel`)?(ue=(0,$.jsx)(vr,{children:Ir(`Control+O`)}),t[121]=ue):ue=t[121];let de;t[122]!==se||t[123]!==le?(de=(0,$.jsxs)(kr,{onClick:se,children:[le,ue]}),t[122]=se,t[123]=le,t[124]=de):de=t[124];let fe;t[125]===Symbol.for(`react.memo_cache_sentinel`)?(fe=(0,$.jsx)(Jn,{}),t[125]=fe):fe=t[125];let pe=!_.sessionHasFile,me;t[126]===n?me=t[127]:(me=()=>{n.current.onRenameSession()},t[126]=n,t[127]=me);let he;t[128]===Symbol.for(`react.memo_cache_sentinel`)?(he=(0,$.jsx)(`span`,{children:`Rename session`}),t[128]=he):he=t[128];let ge;t[129]===Symbol.for(`react.memo_cache_sentinel`)?(ge=(0,$.jsx)(vr,{children:Ir(`Control+E`)}),t[129]=ge):ge=t[129];let _e;t[130]!==pe||t[131]!==me?(_e=(0,$.jsxs)(kr,{disabled:pe,onClick:me,children:[he,ge]}),t[130]=pe,t[131]=me,t[132]=_e):_e=t[132];let ve=!_.sessionHasFile,ye;t[133]===n?ye=t[134]:(ye=()=>{n.current.onDeleteCurrentSession()},t[133]=n,t[134]=ye);let be;t[135]===Symbol.for(`react.memo_cache_sentinel`)?(be=(0,$.jsx)(`span`,{children:`Delete session`}),t[135]=be):be=t[135];let xe;t[136]===Symbol.for(`react.memo_cache_sentinel`)?(xe=(0,$.jsx)(vr,{children:Ir(`Control+X`)}),t[136]=xe):xe=t[136];let Se;t[137]!==ve||t[138]!==ye?(Se=(0,$.jsxs)(kr,{variant:`destructive`,disabled:ve,onClick:ye,children:[be,xe]}),t[137]=ve,t[138]=ye,t[139]=Se):Se=t[139];let Ce;t[140]!==x||t[141]!==B||t[142]!==ee||t[143]!==K||t[144]!==j||t[145]!==oe||t[146]!==de||t[147]!==M||t[148]!==_e||t[149]!==N||t[150]!==Se||t[151]!==P||t[152]!==F||t[153]!==I||t[154]!==L?(Ce=(0,$.jsxs)(x,{align:j,className:M,children:[N,P,F,I,L,B,ee,K,re,oe,de,fe,_e,Se]}),t[140]=x,t[141]=B,t[142]=ee,t[143]=K,t[144]=j,t[145]=oe,t[146]=de,t[147]=M,t[148]=_e,t[149]=N,t[150]=Se,t[151]=P,t[152]=F,t[153]=I,t[154]=L,t[155]=Ce):Ce=t[155];let we;t[156]!==S||t[157]!==C||t[158]!==Ce?(we=(0,$.jsxs)(S,{children:[C,Ce]}),t[156]=S,t[157]=C,t[158]=Ce,t[159]=we):we=t[159];let Te;t[160]===Symbol.for(`react.memo_cache_sentinel`)?(Te=Ir("Control+`"),t[160]=Te):Te=t[160];let Ee;t[161]===Symbol.for(`react.memo_cache_sentinel`)?(Ee=(0,$.jsx)(Ha,{}),t[161]=Ee):Ee=t[161];let De;t[162]!==p||t[163]!==o?(De=(0,$.jsx)(U,{title:`Toggle terminal`,kbd:Te,children:(0,$.jsx)(Y,{size:`icon`,variant:`ghost`,className:`hidden md:inline-flex`,"aria-pressed":o,"aria-label":`Toggle terminal panel`,onClick:p,children:Ee})}),t[162]=p,t[163]=o,t[164]=De):De=t[164];let Oe;t[165]===Symbol.for(`react.memo_cache_sentinel`)?(Oe=Ir(`Control+\\`),t[165]=Oe):Oe=t[165];let ke;t[166]===Symbol.for(`react.memo_cache_sentinel`)?(ke=(0,$.jsx)(za,{}),t[166]=ke):ke=t[166];let Ae;t[167]!==a||t[168]!==f?(Ae=(0,$.jsx)(U,{title:`Toggle right sidebar`,kbd:Oe,children:(0,$.jsx)(Y,{size:`icon`,variant:`ghost`,className:`hidden md:inline-flex`,"aria-pressed":a,"aria-label":`Toggle right sidebar`,onClick:f,children:ke})}),t[167]=a,t[168]=f,t[169]=Ae):Ae=t[169];let je;t[170]!==w||t[171]!==T||t[172]!==we||t[173]!==De||t[174]!==Ae?(je=(0,$.jsxs)(`div`,{className:w,children:[T,we,De,Ae]}),t[170]=w,t[171]=T,t[172]=we,t[173]=De,t[174]=Ae,t[175]=je):je=t[175];let Me;t[176]!==E||t[177]!==D||t[178]!==O||t[179]!==k||t[180]!==je?(Me=(0,$.jsxs)(`div`,{className:E,children:[D,O,k,je]}),t[176]=E,t[177]=D,t[178]=O,t[179]=k,t[180]=je,t[181]=Me):Me=t[181];let Ne;return t[182]!==A||t[183]!==Me?(Ne=(0,$.jsx)(`div`,{className:A,children:Me}),t[182]=A,t[183]=Me,t[184]=Ne):Ne=t[184],Ne});function fv(e){return{firstMessage:e.firstMessage,hideThinkingBlock:e.hideThinkingBlock,sessionHasFile:!!e.sessionFile,sessionName:e.sessionName,sessionStreaming:e.streaming}}function pv(e){return e.hideToolBlocks}var mv=250,hv=1e3,gv=1e3,_v=60*gv,vv=60*_v,yv=24*vv,bv=7*yv,xv=30*yv,Sv=365*yv;function Cv(e,t){let n=(0,Q.c)(4),[r,i]=Z.useState(!1),a,o;return n[0]!==t||n[1]!==e?(a=()=>{if(!e){i(!1);return}let n=window.setTimeout(()=>{i(!0)},t);return()=>{window.clearTimeout(n)}},o=[t,e],n[0]=t,n[1]=e,n[2]=a,n[3]=o):(a=n[2],o=n[3]),Z.useEffect(a,o),r}function wv(e){let t=(0,Q.c)(4),{path:n}=e,r;t[0]===n?r=t[1]:(r=Fi(n)||n,t[0]=n,t[1]=r);let i=r,a;return t[2]===i?a=t[3]:(a=(0,$.jsx)(`span`,{className:`block min-w-0 truncate text-sm font-medium text-sidebar-foreground`,children:i}),t[2]=i,t[3]=a),a}var Tv=[],Ev=`__pico_pinned_sessions__`,Dv=`__pico_directories__`;function Ov(){if(typeof window>`u`)return!1;let e=window.navigator.platform||window.navigator.userAgent;return/mac|iphone|ipad|ipod/i.test(e)}function kv(e){return Ov()?e.metaKey:e.ctrlKey}function Av(e,t=Date.now()){if(!e)return``;let n=new Date(e).getTime();if(Number.isNaN(n))return``;let r=t-n,i=r>=0,a=Math.max(1,Math.floor(Math.abs(r)/1e3)),o=i?``:`in `;if(a<60)return`${o}${a}s`;let s=Math.floor(a/60);if(s<60)return`${o}${s}m`;let c=Math.floor(s/60);if(c<24)return`${o}${c}h`;let l=Math.floor(c/24);if(l<7)return`${o}${l}d`;let u=Math.floor(l/7);if(u<5)return`${o}${u}w`;let d=Math.floor(l/30);if(d<12)return`${o}${Math.max(1,d)}mo`;let f=Math.floor(l/365);return`${o}${Math.max(1,f)}y`}function jv(e){return e?!Number.isNaN(new Date(e).getTime()):!1}function Mv(e){let t=Math.max(1,Math.floor(e/gv));if(t<60)return gv;let n=Math.floor(t/60);if(n<60)return _v;let r=Math.floor(n/60);if(r<24)return vv;let i=Math.floor(r/24);return i<7?yv:Math.floor(i/7)<5?bv:Math.floor(i/30)<12?xv:Sv}function Nv(e,t=Date.now()){let n=t-e,r=Math.abs(n),i=Mv(r),a=r%i,o=n>=0?i-a:a||i;return Math.max(hv,o)}function Pv(e){let t=(0,Q.c)(18),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({value:i,className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a;t[4]===i?a=t[5]:(a=i?new Date(i).getTime():NaN,t[4]=i,t[5]=a);let o=a,s;t[6]===i?s=t[7]:(s=()=>Av(i),t[6]=i,t[7]=s);let[c,l]=Z.useState(s),u,d;if(t[8]!==o||t[9]!==i?(u=()=>{if(Number.isNaN(o)){l(``);return}let e,t=!1,n=()=>{if(t)return;let r=Date.now();l(Av(i,r)),e=window.setTimeout(n,Nv(o,r))};return n(),()=>{t=!0,e!==void 0&&window.clearTimeout(e)}},d=[o,i],t[8]=o,t[9]=i,t[10]=u,t[11]=d):(u=t[10],d=t[11]),Z.useEffect(u,d),!c)return null;let f;t[12]===n?f=t[13]:(f=E(`tabular-nums`,n),t[12]=n,t[13]=f);let p;return t[14]!==c||t[15]!==r||t[16]!==f?(p=(0,$.jsx)(`span`,{className:f,...r,children:c}),t[14]=c,t[15]=r,t[16]=f,t[17]=p):p=t[17],p}function Fv(e,t){return e.length===t.length&&e.every((e,n)=>e===t[n])}function Iv(e,t){let n=Object.keys(e).sort();return Fv(n,Object.keys(t).sort())?n.every(n=>!!e[n]==!!t[n]):!1}function Lv(){let e=hl({},Iv),t=()=>{ye(Dt,JSON.stringify(e.state))};return Object.assign(e,{loadStored(){_l(e,h())},toggle(t){e.setCollapsed(t,!e.state[t])},setCollapsed(n,r){_l(e,e=>{if(!!e[n]===r)return e;let t={...e};return r?t[n]=!0:delete t[n],t}),t()},setAll(n,r){_l(e,e=>{let t=!1,i={...e};for(let e of n)if(r){if(i[e])continue;i[e]=!0,t=!0}else{if(!i[e])continue;delete i[e],t=!0}return t?i:e}),t()},remove(n){_l(e,e=>{if(!e[n])return e;let t={...e};return delete t[n],t}),t()}}),e}function Rv(e,t,n){let r=(0,Q.c)(3),i;return r[0]!==t||r[1]!==n?(i=e=>n?!1:!!e[t],r[0]=t,r[1]=n,r[2]=i):i=r[2],ka(e,i)}function zv(e,t){let n=(0,Q.c)(2),r;return n[0]===t?r=n[1]:(r=e=>t.length>0&&t.every(t=>e[t]),n[0]=t,n[1]=r),ka(e,r)}function Bv(e){let t=(0,Q.c)(20),{id:n,disabled:r,children:i}=e,a;t[0]===n?a=t[1]:(a={type:`directory`,directory:n},t[0]=n,t[1]=a);let o;t[2]!==n||t[3]!==a?(o={id:n,data:a},t[2]=n,t[3]=a,t[4]=o):o=t[4];let{attributes:s,listeners:c,setNodeRef:l,transform:u,transition:d,isDragging:f}=Pn(o),p;t[5]===u?p=t[6]:(p=gr.Transform.toString(u),t[5]=u,t[6]=p);let m;t[7]!==p||t[8]!==d?(m={transform:p,transition:d},t[7]=p,t[8]=d,t[9]=m):m=t[9];let h;t[10]!==s||t[11]!==i||t[12]!==r||t[13]!==f||t[14]!==c?(h=i({attributes:r?{}:s,listeners:r?{}:c,isDragging:r?!1:f}),t[10]=s,t[11]=i,t[12]=r,t[13]=f,t[14]=c,t[15]=h):h=t[15];let g;return t[16]!==l||t[17]!==m||t[18]!==h?(g=(0,$.jsx)(`div`,{ref:l,style:m,children:h}),t[16]=l,t[17]=m,t[18]=h,t[19]=g):g=t[19],g}function Vv(e,t){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}function Hv(){let e=hl(new Set,Vv);return Object.assign(e,{setKeys(t){_l(e,new Set(t.filter(Boolean)))}}),e}function Uv(e){let t=e?.trim()||``;return t?t.startsWith(`path:`)||t.startsWith(`id:`)?t:t.includes(`/`)||t.includes(`\\`)?We({path:t}):t:``}function Wv(){let e=hl({sessionId:``,sessionKey:``});return Object.assign(e,{setActive(t){let n=t.sessionId||``,r=Uv(t.sessionKey);_l(e,e=>e.sessionId===n&&e.sessionKey===r?e:{sessionId:n,sessionKey:r})}}),e}function Gv(e,t){let n=(0,Q.c)(2),r;return n[0]===t?r=n[1]:(r=e=>!!(t&&e.has(t)),n[0]=t,n[1]=r),ka(e,r)}function Kv(e,t,n){let r=(0,Q.c)(3),i;return r[0]!==t||r[1]!==n?(i=e=>e.sessionKey&&t===e.sessionKey?!0:!!(e.sessionId&&n===e.sessionId),r[0]=t,r[1]=n,r[2]=i):i=r[2],ka(e,i)}function qv({entryKey:e,directorySessionsStore:t,activeSessionStore:n,selectedSessionKeyStore:r,isPinned:i,isMobile:a,overlay:o,moveTargetDirectories:s,setOpenMobile:c,onSessionClick:l,onRenameSession:u,onDeleteSession:d,onSetSessionUnread:f,onMoveSession:p,onMoveSessionAnyDirectory:m,onTogglePinnedSession:h}){let g=ty(t,e),_=Gv(r,e),v=Kv(n,e,g?.id),y=Sr({id:`session:${e}`,disabled:a||o||!g?.path,data:{type:`session`,entry:g,entryKey:e,sourceDirectory:g?.cwd||``}});if(!g)return null;let b=g.lastMessageAt||g.modified||g.lastUserMessageAt,x=jv(b),S=g.lastMessagePreview?.trim()||``,C=i?Fi(g.cwd?.trim()||g.path?.trim()||``):``,w=x&&b?new Date(b).toLocaleString():void 0,T=!!g.unread&&!g.streaming,D=!!(g.optimistic||g.id?.startsWith(`optimistic:`)&&!g.path),O=s.filter(e=>e&&e!==g.cwd),k=!!(g.path&&m),A=!!(g.path&&p)&&O.length>0||k,j=!!(!D&&h||g.path&&(u||d||f)||A)&&!o,M=(0,$.jsxs)(ns,{type:`button`,"data-sidebar-session-item":!0,"data-session-key":e,isActive:v||_,className:E(`relative h-auto min-w-0 items-start gap-2 py-2 pr-2 pl-8 not-data-active:hover:bg-transparent! not-data-active:hover:text-sidebar-foreground! not-data-active:data-open:hover:bg-transparent! not-data-active:data-open:hover:text-sidebar-foreground!`,(v||_)&&`bg-sidebar-accent text-sidebar-accent-foreground`),onClick:e=>{l?.(g,{multiSelectKey:kv(e),shiftKey:e.shiftKey}),a&&c(!1)},children:[g.streaming?(0,$.jsx)(`span`,{className:`absolute top-2.5 left-2 flex size-4 items-center justify-center`,children:(0,$.jsx)(wt,{size:`xs`,"aria-label":`Session streaming`})}):T?(0,$.jsx)(`span`,{className:`absolute top-2.5 left-2 flex size-4 items-center justify-center`,children:(0,$.jsx)(`span`,{className:`size-2 rounded-full bg-primary`,"aria-label":`Session done`})}):null,(0,$.jsx)(`span`,{className:`flex min-w-0 flex-1 items-start gap-2`,children:(0,$.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,$.jsx)(`span`,{className:`flex min-w-0 items-center gap-2`,children:(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate pr-16 font-medium`,children:g.title})}),S?(0,$.jsx)(`span`,{className:`min-w-0 truncate text-[11px] font-normal text-sidebar-foreground/50`,children:S}):null,C?(0,$.jsx)(`span`,{className:`min-w-0 truncate text-[11px] font-normal text-sidebar-foreground/50`,children:C}):null]})})]}),N=x?(0,$.jsx)(`span`,{className:`absolute top-2.5 right-2 z-10 flex min-w-4 items-center justify-end`,children:(0,$.jsx)(U,{title:a?void 0:w,side:`right`,align:`center`,children:(0,$.jsx)(Pv,{value:b,className:`shrink-0 text-[11px] font-normal text-sidebar-foreground/50`})})}):null,P=(0,$.jsxs)(`div`,{ref:y.setNodeRef,className:E(`group/session relative`,y.isDragging&&!o&&`opacity-40`),style:{transform:gr.Translate.toString(y.transform)},...y.attributes,...y.listeners,children:[M,N]});return(0,$.jsx)(es,{children:j?(0,$.jsxs)(Qn,{children:[(0,$.jsx)(En,{render:P}),(0,$.jsxs)(Ln,{className:`w-44`,children:[h&&!D?(0,$.jsx)(zr,{onClick:()=>h(g),children:i?`Unpin`:`Pin to sidebar`}):null,f&&g.path?(0,$.jsx)(zr,{onClick:()=>f(g,!g.unread),children:g.unread?`Mark as read`:`Mark as unread`}):null,A?(0,$.jsxs)(Cn,{children:[(0,$.jsx)(Fr,{children:`Move to…`}),(0,$.jsxs)(zt,{className:`w-72`,children:[O.map(e=>(0,$.jsx)(zr,{onClick:()=>p?.(g,e),children:(0,$.jsx)(`span`,{className:`truncate`,children:Bi(e)})},e)),k?(0,$.jsx)(zr,{onClick:()=>m?.(g),children:`Other directory…`}):null]})]}):null,u&&g.path?(0,$.jsx)(zr,{onClick:()=>u(g),children:`Rename`}):null,d&&g.path?(0,$.jsx)(zr,{variant:`destructive`,onClick:()=>d(g),children:`Delete`}):null]})]}):P})}function Jv(e,t){return e===t?!0:!e||!t?!1:e.path===t.path&&e.id===t.id&&e.cwd===t.cwd&&e.name===t.name&&e.title===t.title&&e.modified===t.modified&&e.lastUserMessageAt===t.lastUserMessageAt&&e.lastMessageAt===t.lastMessageAt&&e.lastMessagePreview===t.lastMessagePreview&&e.messageCount===t.messageCount&&JSON.stringify(e.contextUsage??null)===JSON.stringify(t.contextUsage??null)&&!!e.streaming==!!t.streaming&&!!e.unread==!!t.unread&&!!e.optimistic==!!t.optimistic}function Yv(e){let t=new Map;for(let n of Object.values(e))for(let e of n){let n=We(e);!n||t.has(n)||t.set(n,e)}return t}function Xv(e){let t={};for(let[n,r]of Object.entries(e))t[n]=r.flatMap(e=>{let t=We(e);return t?[t]:[]});return t}function Zv(e,t){return e.isLoadingSessions===t.isLoadingSessions&&Fv(e.sessionKeys,t.sessionKeys)}function Qv(e,t){let n=new Set([...Object.keys(e.sessionKeysByDirectory),...Object.keys(e.loadingByDirectory),...Object.keys(t.sessionKeysByDirectory),...Object.keys(t.loadingByDirectory)]);for(let r of n)if(!Fv(e.sessionKeysByDirectory[r]??Tv,t.sessionKeysByDirectory[r]??Tv)||!!e.loadingByDirectory[r]!=!!t.loadingByDirectory[r])return!1;let r=new Set([...e.entriesByKey.keys(),...t.entriesByKey.keys()]);for(let n of r)if(!Jv(e.entriesByKey.get(n),t.entriesByKey.get(n)))return!1;return!0}function $v(e,t){let n=hl({sessionKeysByDirectory:Xv(e),entriesByKey:Yv(e),loadingByDirectory:t},Qv);return Object.assign(n,{setData(e,t){_l(n,{sessionKeysByDirectory:Xv(e),entriesByKey:Yv(e),loadingByDirectory:t})}}),n}function ey(e,t){let n=(0,Q.c)(3),r;n[0]===t?r=n[1]:(r=e=>({sessionKeys:e.sessionKeysByDirectory[t]??Tv,isLoadingSessions:!!e.loadingByDirectory[t]}),n[0]=t,n[1]=r);let i;return n[2]===Symbol.for(`react.memo_cache_sentinel`)?(i={compare:Zv},n[2]=i):i=n[2],ka(e,r,i)}function ty(e,t){let n=(0,Q.c)(3),r;n[0]===t?r=n[1]:(r=e=>e.entriesByKey.get(t),n[0]=t,n[1]=r);let i;return n[2]===Symbol.for(`react.memo_cache_sentinel`)?(i={compare:Jv},n[2]=i):i=n[2],ka(e,r,i)}var ny=Z.memo(function(e){let t=(0,Q.c)(68),{directory:n,directorySessionsStore:r,collapsedDirectoryStore:i,searchActive:a,moveTargetDirectories:o,activeSessionStore:s,selectedSessionKeyStore:c,pinnedSessionKeys:l,isMobile:u,setOpenMobile:d,isDragging:f,isSessionDropTarget:p,overlay:m,attributes:h,listeners:g,onSessionClick:_,onRenameSession:v,onDeleteSession:y,onSetSessionUnread:b,onMoveSession:x,onMoveSessionAnyDirectory:S,onTogglePinnedSession:C,onCreateSessionInDirectory:w,onDeleteOldSessionsInDirectory:T,onRemoveDirectory:D}=e,O=m===void 0?!1:m,[k,A]=Z.useState(5),{isLoadingSessions:j,sessionKeys:M}=ey(r,n),N=Rv(i,n,a),P;t[0]===l?P=t[1]:(P=new Set(l),t[0]=l,t[1]=P);let F=P,I;t[2]===F?I=t[3]:(I=e=>!F.has(e),t[2]=F,t[3]=I);let L=M.filter(I),R=a?L.length:Math.min(L.length,k),z=L.slice(0,R),B=R<L.length,V=Cv(j,mv),H=j&&M.length===0,W=V&&L.length===0&&N,ee=!O&&!!(w||T||D),te;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(te=E(`group/directory-label flex min-w-0 flex-1 cursor-default items-center gap-2 text-left text-sm text-sidebar-foreground`),t[4]=te):te=t[4];let ne=a||O,G;t[5]===h?G=t[6]:(G=h??{},t[5]=h,t[6]=G);let K;t[7]===g?K=t[8]:(K=g??{},t[7]=g,t[8]=K);let re;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(re=(0,$.jsx)(Na,{className:`size-4 shrink-0 text-sidebar-foreground/50`}),t[9]=re):re=t[9];let q;t[10]===n?q=t[11]:(q=(0,$.jsx)(`span`,{className:`max-w-full min-w-0`,children:(0,$.jsx)(wv,{path:n})}),t[10]=n,t[11]=q);let ie;t[12]!==N||t[13]!==O||t[14]!==a?(ie=!a&&!O?N?(0,$.jsx)(qt,{className:`size-4 shrink-0 opacity-0 transition-opacity group-hover/directory-label:opacity-100 group-focus-visible/directory-label:opacity-100`}):(0,$.jsx)(en,{className:`size-4 shrink-0 opacity-0 transition-opacity group-hover/directory-label:opacity-100 group-focus-visible/directory-label:opacity-100`}):null,t[12]=N,t[13]=O,t[14]=a,t[15]=ie):ie=t[15];let J;t[16]===W?J=t[17]:(J=W?(0,$.jsx)(wt,{size:`xs`,className:`shrink-0`}):null,t[16]=W,t[17]=J);let ae;t[18]!==ie||t[19]!==J||t[20]!==ne||t[21]!==G||t[22]!==K||t[23]!==q?(ae=(0,$.jsxs)(ep,{type:`button`,className:te,disabled:ne,...G,...K,children:[re,q,ie,J]}),t[18]=ie,t[19]=J,t[20]=ne,t[21]=G,t[22]=K,t[23]=q,t[24]=ae):ae=t[24];let oe;t[25]!==n||t[26]!==u||t[27]!==w||t[28]!==O?(oe=w&&!O&&!u?(0,$.jsx)(U,{title:`Create a session in ${n}`,children:(0,$.jsx)(Y,{size:`icon`,variant:`ghost`,className:`shrink-0 hover:bg-sidebar-accent/50 hover:text-sidebar-accent-foreground`,onClick:()=>w(n),children:(0,$.jsx)(Va,{className:`size-4`})})}):null,t[25]=n,t[26]=u,t[27]=w,t[28]=O,t[29]=oe):oe=t[29];let se;t[30]!==n||t[31]!==ee||t[32]!==u||t[33]!==w||t[34]!==T||t[35]!==D?(se=ee&&u?(0,$.jsxs)(wr,{children:[(0,$.jsx)(Fn,{render:(0,$.jsx)(Y,{size:`icon`,variant:`ghost`,className:`shrink-0 hover:bg-sidebar-accent/50 hover:text-sidebar-accent-foreground`,"aria-label":`Directory actions for ${n}`}),children:(0,$.jsx)(ja,{className:`size-4`})}),(0,$.jsxs)(Hn,{align:`end`,className:`w-48`,children:[w?(0,$.jsx)(kr,{onClick:()=>w(n),children:`New session`}):null,T?(0,$.jsx)(kr,{onClick:()=>T(n),children:`Delete old sessions…`}):null,D?(0,$.jsx)(kr,{variant:`destructive`,onClick:()=>D(n),children:`Remove from sidebar`}):null]})]}):null,t[30]=n,t[31]=ee,t[32]=u,t[33]=w,t[34]=T,t[35]=D,t[36]=se):se=t[36];let ce;t[37]!==ae||t[38]!==oe||t[39]!==se?(ce=(0,$.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg`,children:[ae,oe,se]}),t[37]=ae,t[38]=oe,t[39]=se,t[40]=ce):ce=t[40];let le=ce,ue=$f,de=!N,fe;t[41]!==i||t[42]!==n||t[43]!==O||t[44]!==a?(fe=e=>{a||O||i.setCollapsed(n,!e)},t[41]=i,t[42]=n,t[43]=O,t[44]=a,t[45]=fe):fe=t[45];let pe=O&&`bg-sidebar shadow-lg ring-1 ring-sidebar-border/70`,me=p&&!O&&`bg-sidebar-accent/40 ring-1 ring-sidebar-ring/50`,he=f&&!O&&`opacity-0`,ge;t[46]!==pe||t[47]!==me||t[48]!==he?(ge=E(`rounded-lg py-1`,pe,me,he),t[46]=pe,t[47]=me,t[48]=he,t[49]=ge):ge=t[49];let _e=Xo,ve;t[50]!==n||t[51]!==le||t[52]!==ee||t[53]!==u||t[54]!==w||t[55]!==T||t[56]!==D?(ve=ee&&!u?(0,$.jsxs)(Qn,{children:[(0,$.jsx)(En,{render:le}),(0,$.jsxs)(Ln,{className:`w-48`,children:[w?(0,$.jsx)(zr,{onClick:()=>w(n),children:`New session`}):null,T?(0,$.jsx)(zr,{onClick:()=>T(n),children:`Delete old sessions…`}):null,D?(0,$.jsx)(zr,{variant:`destructive`,onClick:()=>D(n),children:`Remove from sidebar`}):null]})]}):le,t[50]=n,t[51]=le,t[52]=ee,t[53]=u,t[54]=w,t[55]=T,t[56]=D,t[57]=ve):ve=t[57];let ye=O?null:(0,$.jsx)(tp,{children:(0,$.jsx)(Qo,{children:H?(0,$.jsxs)(`div`,{className:`flex items-center gap-2 p-2 text-sm text-sidebar-foreground/70`,children:[V?(0,$.jsx)(wt,{size:`xs`}):(0,$.jsx)(`span`,{className:`size-4`,"aria-hidden":`true`}),`Loading sessions…`]}):L.length>0?(0,$.jsxs)(`div`,{className:`flex flex-col`,children:[(0,$.jsx)($o,{children:z.map(e=>(0,$.jsx)(qv,{entryKey:e,directorySessionsStore:r,activeSessionStore:s,selectedSessionKeyStore:c,isPinned:l.includes(e),isMobile:u,overlay:O,moveTargetDirectories:o,setOpenMobile:d,onSessionClick:_,onRenameSession:v,onDeleteSession:y,onSetSessionUnread:b,onMoveSession:x,onMoveSessionAnyDirectory:S,onTogglePinnedSession:C},e))}),B?(0,$.jsxs)(Y,{variant:`ghost`,className:`h-8 justify-start pl-8 text-sidebar-foreground/60 hover:bg-sidebar-accent/50 hover:text-sidebar-accent-foreground`,onClick:()=>{A(e=>Math.min(L.length,e+5))},children:[`Show`,` `,Math.min(5,L.length-R),` `,`more`]}):null]}):(0,$.jsx)(`div`,{className:`p-2 text-sm text-sidebar-foreground/70`,children:a?`No matching unpinned sessions.`:`No unpinned sessions.`})})}),be;t[58]!==_e||t[59]!==ve||t[60]!==ye?(be=(0,$.jsxs)(_e,{className:`py-0`,children:[ve,ye]}),t[58]=_e,t[59]=ve,t[60]=ye,t[61]=be):be=t[61];let xe;return t[62]!==ue||t[63]!==de||t[64]!==fe||t[65]!==ge||t[66]!==be?(xe=(0,$.jsx)(ue,{open:de,onOpenChange:fe,className:ge,children:be}),t[62]=ue,t[63]=de,t[64]=fe,t[65]=ge,t[66]=be,t[67]=xe):xe=t[67],xe});function ry(e){let t=(0,Q.c)(53),{pinnedSessionKeys:n,directorySessionsStore:r,collapsedDirectoryStore:i,searchActive:a,activeSessionStore:o,selectedSessionKeyStore:s,isMobile:c,moveTargetDirectories:l,setOpenMobile:u,onSessionClick:d,onRenameSession:f,onDeleteSession:p,onSetSessionUnread:m,onMoveSession:h,onMoveSessionAnyDirectory:g,onTogglePinnedSession:_}=e,v=Rv(i,Ev,a);if(n.length===0)return null;let y=!v,b;t[0]!==i||t[1]!==a?(b=e=>{a||i.setCollapsed(Ev,!e)},t[0]=i,t[1]=a,t[2]=b):b=t[2];let x;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,$.jsx)(ep,{className:`group/pinned-label justify-between gap-3`}),t[3]=x):x=t[3];let S;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,$.jsx)(`span`,{className:`min-w-0 truncate`,children:`Pinned`}),t[4]=S):S=t[4];let C;t[5]!==v||t[6]!==a?(C=a?null:v?(0,$.jsx)(qt,{className:`size-4 shrink-0 opacity-0 transition-opacity group-hover/pinned-label:opacity-100 group-focus-visible/pinned-label:opacity-100`}):(0,$.jsx)(en,{className:`size-4 shrink-0 opacity-0 transition-opacity group-hover/pinned-label:opacity-100 group-focus-visible/pinned-label:opacity-100`}),t[5]=v,t[6]=a,t[7]=C):C=t[7];let w;t[8]===C?w=t[9]:(w=(0,$.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-center gap-2 text-left`,children:[S,C]}),t[8]=C,t[9]=w);let T;t[10]===n.length?T=t[11]:(T=(0,$.jsx)(`span`,{className:`text-[11px] font-normal text-sidebar-foreground/50`,children:n.length}),t[10]=n.length,t[11]=T);let E;t[12]!==w||t[13]!==T?(E=(0,$.jsxs)(Zo,{render:x,children:[w,T]}),t[12]=w,t[13]=T,t[14]=E):E=t[14];let D;if(t[15]!==o||t[16]!==r||t[17]!==c||t[18]!==l||t[19]!==p||t[20]!==h||t[21]!==g||t[22]!==f||t[23]!==d||t[24]!==m||t[25]!==_||t[26]!==n||t[27]!==s||t[28]!==u){let e;t[30]!==o||t[31]!==r||t[32]!==c||t[33]!==l||t[34]!==p||t[35]!==h||t[36]!==g||t[37]!==f||t[38]!==d||t[39]!==m||t[40]!==_||t[41]!==s||t[42]!==u?(e=e=>(0,$.jsx)(qv,{entryKey:e,directorySessionsStore:r,activeSessionStore:o,selectedSessionKeyStore:s,isPinned:!0,isMobile:c,overlay:!1,moveTargetDirectories:l,setOpenMobile:u,onSessionClick:d,onRenameSession:f,onDeleteSession:p,onSetSessionUnread:m,onMoveSession:h,onMoveSessionAnyDirectory:g,onTogglePinnedSession:_},e),t[30]=o,t[31]=r,t[32]=c,t[33]=l,t[34]=p,t[35]=h,t[36]=g,t[37]=f,t[38]=d,t[39]=m,t[40]=_,t[41]=s,t[42]=u,t[43]=e):e=t[43],D=n.map(e),t[15]=o,t[16]=r,t[17]=c,t[18]=l,t[19]=p,t[20]=h,t[21]=g,t[22]=f,t[23]=d,t[24]=m,t[25]=_,t[26]=n,t[27]=s,t[28]=u,t[29]=D}else D=t[29];let O;t[44]===D?O=t[45]:(O=(0,$.jsx)(tp,{children:(0,$.jsx)(Qo,{children:(0,$.jsx)($o,{children:D})})}),t[44]=D,t[45]=O);let k;t[46]!==O||t[47]!==E?(k=(0,$.jsxs)(Xo,{className:`py-1`,children:[E,O]}),t[46]=O,t[47]=E,t[48]=k):k=t[48];let A;return t[49]!==y||t[50]!==k||t[51]!==b?(A=(0,$.jsx)($f,{open:y,onOpenChange:b,children:k}),t[49]=y,t[50]=k,t[51]=b,t[52]=A):A=t[52],A}function iy(e){let t=(0,Q.c)(14),{searchActive:n,visibleDirectories:r,collapsedDirectoryStore:i}=e,a=zv(i,r),o=a?`Expand all directories`:`Collapse all directories`,s=n||r.length===0,c;t[0]!==a||t[1]!==i||t[2]!==r?(c=()=>{i.setAll(r,!a)},t[0]=a,t[1]=i,t[2]=r,t[3]=c):c=t[3];let l;t[4]===a?l=t[5]:(l=a?(0,$.jsx)(fn,{}):(0,$.jsx)(gn,{}),t[4]=a,t[5]=l);let u;t[6]!==s||t[7]!==c||t[8]!==l||t[9]!==o?(u=(0,$.jsx)(Y,{size:`icon`,variant:`ghost`,className:`text-sidebar-foreground/70 hover:bg-sidebar-accent/50 hover:text-sidebar-accent-foreground`,disabled:s,onClick:c,"aria-label":o,children:l}),t[6]=s,t[7]=c,t[8]=l,t[9]=o,t[10]=u):u=t[10];let d;return t[11]!==u||t[12]!==o?(d=(0,$.jsx)(U,{title:o,children:u}),t[11]=u,t[12]=o,t[13]=d):d=t[13],d}function ay(e){let t=(0,Q.c)(13),{onOpenSessionsDialog:n,onCreateSession:i}=e,a,o;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,$.jsx)(Vt,{}),o=(0,$.jsx)(`span`,{children:`Search sessions…`}),t[0]=a,t[1]=o):(a=t[0],o=t[1]);let s;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,$.jsx)(`span`,{className:`ml-auto hidden items-center md:flex`,children:(0,$.jsx)(r,{children:Ir(`Control+S`)})}),t[2]=s):s=t[2];let c;t[3]===n?c=t[4]:(c=(0,$.jsx)(es,{children:(0,$.jsxs)(ns,{type:`button`,onClick:n,children:[a,o,s]})}),t[3]=n,t[4]=c);let l,u;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(Va,{}),u=(0,$.jsx)(`span`,{children:`New session`}),t[5]=l,t[6]=u):(l=t[5],u=t[6]);let d;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,$.jsx)(`span`,{className:`ml-auto hidden items-center md:flex`,children:(0,$.jsx)(r,{children:Ir(`Control+N`)})}),t[7]=d):d=t[7];let f;t[8]===i?f=t[9]:(f=(0,$.jsx)(es,{children:(0,$.jsxs)(ns,{type:`button`,onClick:i,children:[l,u,d]})}),t[8]=i,t[9]=f);let p;return t[10]!==c||t[11]!==f?(p=(0,$.jsx)(qo,{className:`gap-2 border-b border-sidebar-border/70`,children:(0,$.jsxs)($o,{className:`gap-1`,children:[c,f]})}),t[10]=c,t[11]=f,t[12]=p):p=t[12],p}function oy(e){let t=(0,Q.c)(25),{sessionSearch:n,visibleDirectories:r,matchingSessionCount:i,collapsed:a,collapsedDirectoryStore:o,onOpenAddDirectoryDialog:s}=e,c;t[0]===n?c=t[1]:(c=n.trim(),t[0]=n,t[1]=c);let l=c.length>0,u=l?`${i} matching session${i===1?``:`s`}`:`Directories`,d;t[2]===u?d=t[3]:(d=(0,$.jsx)(`span`,{className:`min-w-0 truncate`,children:u}),t[2]=u,t[3]=d);let f;t[4]!==a||t[5]!==l?(f=l?null:a?(0,$.jsx)(qt,{className:`size-4 shrink-0 text-sidebar-foreground/60`}):(0,$.jsx)(en,{className:`size-4 shrink-0 text-sidebar-foreground/60`}),t[4]=a,t[5]=l,t[6]=f):f=t[6];let p;t[7]!==d||t[8]!==f?(p=(0,$.jsxs)(ep,{type:`button`,className:`group/directories-label flex min-w-0 flex-1 items-center gap-2 text-left outline-hidden`,children:[d,f]}),t[7]=d,t[8]=f,t[9]=p):p=t[9];let m;t[10]!==a||t[11]!==o||t[12]!==l||t[13]!==r?(m=a?null:(0,$.jsx)(iy,{searchActive:l,visibleDirectories:r,collapsedDirectoryStore:o}),t[10]=a,t[11]=o,t[12]=l,t[13]=r,t[14]=m):m=t[14];let h;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(h=Ir(`Control+D`),t[15]=h):h=t[15];let g;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,$.jsx)(Ma,{}),t[16]=g):g=t[16];let _;t[17]===s?_=t[18]:(_=(0,$.jsx)(U,{title:`Add directory`,kbd:h,children:(0,$.jsx)(Y,{variant:`ghost`,size:`icon`,className:`hover:bg-sidebar-accent/50 hover:text-sidebar-accent-foreground`,onClick:s,"aria-label":`Add directory`,children:g})}),t[17]=s,t[18]=_);let v;t[19]!==m||t[20]!==_?(v=(0,$.jsxs)(`span`,{className:`flex items-center gap-1`,children:[m,_]}),t[19]=m,t[20]=_,t[21]=v):v=t[21];let y;return t[22]!==v||t[23]!==p?(y=(0,$.jsxs)(Zo,{className:`justify-between gap-3`,children:[p,v]}),t[22]=v,t[23]=p,t[24]=y):y=t[24],y}function sy(e){return cy(e)}function cy(e){let t=(0,Q.c)(165),{sessionSearch:n,onOpenSessionsDialog:i,visibleDirectories:a,directorySessionsStore:o,matchingSessionCount:s,selectedSessionKeys:c,activeSessionId:l,activeSessionKey:u,pinnedSessionKeys:d,emptyStateText:f,onCreateSession:p,onOpenAddDirectoryDialog:m,onOpenCommandPalette:h,onOpenSettings:g,onSessionClick:_,onRenameSession:v,onDeleteSession:y,onSetSessionUnread:b,onMoveSession:x,onMoveSessionAnyDirectory:S,onTogglePinnedSession:C,onCreateSessionInDirectory:w,onDeleteOldSessionsInDirectory:T,onRemoveDirectory:E,onReorderDirectories:D}=e,{isMobile:O,setOpenMobile:A}=zo(),j;t[0]===n?j=t[1]:(j=n.trim(),t[0]=n,t[1]=j);let M=j.length>0,N=!M&&a.length>1,[P,F]=Z.useState(null),[I,L]=Z.useState(null),[R,z]=Z.useState(null),[B,V]=Z.useState(null),[H]=Z.useState(Lv),[U]=Z.useState(Hv),[W]=Z.useState(Wv),ee=Rv(H,Dv,M),te,ne;t[2]!==U||t[3]!==c?(te=()=>{U.setKeys(c)},ne=[U,c],t[2]=U,t[3]=c,t[4]=te,t[5]=ne):(te=t[4],ne=t[5]),Z.useLayoutEffect(te,ne);let G,K;t[6]!==l||t[7]!==u||t[8]!==W?(G=()=>{W.setActive({sessionId:l,sessionKey:u})},K=[l,u,W],t[6]=l,t[7]=u,t[8]=W,t[9]=G,t[10]=K):(G=t[9],K=t[10]),Z.useLayoutEffect(G,K);let re;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(re={activationConstraint:{distance:6}},t[11]=re):re=t[11];let q=zn(nr(Or,re)),ie,J;t[12]===H?(ie=t[13],J=t[14]):(ie=()=>{H.loadStored()},J=[H],t[12]=H,t[13]=ie,t[14]=J),Z.useEffect(ie,J);let ae,oe;t[15]===N?(ae=t[16],oe=t[17]):(oe=()=>{N||(F(null),V(null))},ae=[N],t[15]=N,t[16]=ae,t[17]=oe),Z.useEffect(oe,ae);let se;bb0:{if(!B||B.length===0){se=a;break bb0}let e;t[18]===a?e=t[19]:(e=new Set(a),t[18]=a,t[19]=e);let n=e,r;if(t[20]!==B||t[21]!==a||t[22]!==n){let e;t[24]===n?e=t[25]:(e=e=>n.has(e),t[24]=n,t[25]=e);let i=B.filter(e),o=a.filter(e=>!i.includes(e));r=[...i,...o],t[20]=B,t[21]=a,t[22]=n,t[23]=r}else r=t[23];se=r}let ce=se,le,ue;t[26]!==ce||t[27]!==B||t[28]!==a?(le=()=>{B&&Fv(ce,a)&&V(null)},ue=[ce,B,a],t[26]=ce,t[27]=B,t[28]=a,t[29]=le,t[30]=ue):(le=t[29],ue=t[30]),Z.useEffect(le,ue);let de;t[31]!==H||t[32]!==E?(de=e=>{H.remove(e),E?.(e)},t[31]=H,t[32]=E,t[33]=de):de=t[33];let fe=de,pe;t[34]===a?pe=t[35]:(pe=(e,t)=>{V(n=>{let r=n&&n.length>0?n:a,i=r.indexOf(e),o=r.indexOf(t);return i===-1||o===-1||i===o?n:Nn(r,i,o)})},t[34]=a,t[35]=pe);let me=pe,he;t[36]!==N||t[37]!==O||t[38]!==a?(he=e=>{let t=e.active.data.current;if(t?.type===`session`&&t.entry){if(O)return;L({entryKey:t.entryKey||String(e.active.id),entry:t.entry,sourceDirectory:t.sourceDirectory||t.entry.cwd||``}),z(null);return}t?.type!==`directory`||!N||(F(String(e.active.id)),V(a))},t[36]=N,t[37]=O,t[38]=a,t[39]=he):he=t[39];let ge=he,_e;t[40]!==N||t[41]!==O||t[42]!==me||t[43]!==a?(_e=e=>{let t=e.active.data.current,n=String(e.active.id),r=e.over?String(e.over.id):``;if(t?.type===`session`){if(O)return;let e=a.includes(r)?r:``;z(e&&e!==t.sourceDirectory?e:null);return}N&&(!n||!r||n===r||me(n,r))},t[40]=N,t[41]=O,t[42]=me,t[43]=a,t[44]=_e):_e=t[44];let ve=_e,ye;t[45]===Symbol.for(`react.memo_cache_sentinel`)?(ye=()=>{F(null),L(null),z(null),V(null)},t[45]=ye):ye=t[45];let be=ye,xe;t[46]!==N||t[47]!==O||t[48]!==x||t[49]!==D||t[50]!==B||t[51]!==a?(xe=e=>{let t=e.active.data.current,n=String(e.active.id),r=e.over?String(e.over.id):``;if(t?.type===`session`){if(O){L(null),z(null);return}let e=a.includes(r)?r:``;t.entry&&e&&e!==t.sourceDirectory&&x?.(t.entry,e),L(null),z(null);return}let i=B;if(N&&(!i||i.length===0)&&n&&r&&n!==r){let e=a.indexOf(n),t=a.indexOf(r);e!==-1&&t!==-1&&(i=Nn(a,e,t))}i&&i.length>0&&!Fv(i,a)&&D?.(i),F(null),V(null)},t[46]=N,t[47]=O,t[48]=x,t[49]=D,t[50]=B,t[51]=a,t[52]=xe):xe=t[52];let Se=xe,Ce;t[53]!==p||t[54]!==i?(Ce=(0,$.jsx)(ay,{onOpenSessionsDialog:i,onCreateSession:p}),t[53]=p,t[54]=i,t[55]=Ce):Ce=t[55];let we;t[56]!==W||t[57]!==H||t[58]!==o||t[59]!==O||t[60]!==y||t[61]!==x||t[62]!==v||t[63]!==_||t[64]!==b||t[65]!==C||t[66]!==d||t[67]!==M||t[68]!==U||t[69]!==A||t[70]!==a?(we=(0,$.jsx)(ry,{pinnedSessionKeys:d,directorySessionsStore:o,collapsedDirectoryStore:H,searchActive:M,activeSessionStore:W,selectedSessionKeyStore:U,isMobile:O,moveTargetDirectories:a,setOpenMobile:A,onSessionClick:_,onRenameSession:v,onDeleteSession:y,onSetSessionUnread:b,onMoveSession:x,onTogglePinnedSession:C}),t[56]=W,t[57]=H,t[58]=o,t[59]=O,t[60]=y,t[61]=x,t[62]=v,t[63]=_,t[64]=b,t[65]=C,t[66]=d,t[67]=M,t[68]=U,t[69]=A,t[70]=a,t[71]=we):we=t[71];let Te=!ee,Ee;t[72]!==H||t[73]!==M?(Ee=e=>{M||H.setCollapsed(Dv,!e)},t[72]=H,t[73]=M,t[74]=Ee):Ee=t[74];let De;t[75]!==H||t[76]!==ee||t[77]!==s||t[78]!==m||t[79]!==n||t[80]!==a?(De=(0,$.jsx)(oy,{sessionSearch:n,visibleDirectories:a,matchingSessionCount:s,collapsed:ee,collapsedDirectoryStore:H,onOpenAddDirectoryDialog:m}),t[75]=H,t[76]=ee,t[77]=s,t[78]=m,t[79]=n,t[80]=a,t[81]=De):De=t[81];let Oe;t[82]!==W||t[83]!==H||t[84]!==N||t[85]!==o||t[86]!==f||t[87]!==O||t[88]!==w||t[89]!==T||t[90]!==y||t[91]!==x||t[92]!==S||t[93]!==E||t[94]!==v||t[95]!==_||t[96]!==b||t[97]!==C||t[98]!==ce||t[99]!==d||t[100]!==fe||t[101]!==M||t[102]!==U||t[103]!==R||t[104]!==A||t[105]!==a?(Oe=(0,$.jsx)(tp,{children:(0,$.jsx)(Qo,{children:a.length===0?(0,$.jsx)(`div`,{className:`p-2`,children:(0,$.jsx)(Jh,{className:`rounded-xl border border-dashed bg-sidebar-accent/10 py-10`,children:(0,$.jsxs)(Yh,{children:[(0,$.jsx)(Zh,{variant:`icon`,children:(0,$.jsx)(Na,{})}),(0,$.jsx)(Qh,{children:f})]})})}):(0,$.jsx)(rn,{items:ce,strategy:yn,children:ce.map(e=>(0,$.jsx)(Bv,{id:e,disabled:!N,children:t=>{let{attributes:n,listeners:r,isDragging:i}=t;return(0,$.jsx)(ny,{directory:e,directorySessionsStore:o,collapsedDirectoryStore:H,searchActive:M,moveTargetDirectories:a,activeSessionStore:W,selectedSessionKeyStore:U,pinnedSessionKeys:d,isMobile:O,setOpenMobile:A,isDragging:i,isSessionDropTarget:R===e,attributes:n,listeners:r,onSessionClick:_,onRenameSession:v,onDeleteSession:y,onSetSessionUnread:b,onMoveSession:x,onMoveSessionAnyDirectory:S,onTogglePinnedSession:C,onCreateSessionInDirectory:w,onDeleteOldSessionsInDirectory:T,onRemoveDirectory:E?fe:void 0})}},e))})})}),t[82]=W,t[83]=H,t[84]=N,t[85]=o,t[86]=f,t[87]=O,t[88]=w,t[89]=T,t[90]=y,t[91]=x,t[92]=S,t[93]=E,t[94]=v,t[95]=_,t[96]=b,t[97]=C,t[98]=ce,t[99]=d,t[100]=fe,t[101]=M,t[102]=U,t[103]=R,t[104]=A,t[105]=a,t[106]=Oe):Oe=t[106];let ke;t[107]!==De||t[108]!==Oe?(ke=(0,$.jsxs)(Xo,{className:`py-1`,children:[De,Oe]}),t[107]=De,t[108]=Oe,t[109]=ke):ke=t[109];let Ae;t[110]!==Te||t[111]!==Ee||t[112]!==ke?(Ae=(0,$.jsx)($f,{open:Te,onOpenChange:Ee,children:ke}),t[110]=Te,t[111]=Ee,t[112]=ke,t[113]=Ae):Ae=t[113];let je;t[114]!==P||t[115]!==I||t[116]!==W||t[117]!==H||t[118]!==o||t[119]!==O||t[120]!==w||t[121]!==T||t[122]!==y||t[123]!==x||t[124]!==S||t[125]!==E||t[126]!==v||t[127]!==_||t[128]!==b||t[129]!==C||t[130]!==d||t[131]!==fe||t[132]!==M||t[133]!==U||t[134]!==A||t[135]!==a?(je=P?(0,$.jsx)(ny,{directory:P,directorySessionsStore:o,collapsedDirectoryStore:H,searchActive:M,moveTargetDirectories:a,activeSessionStore:W,selectedSessionKeyStore:U,pinnedSessionKeys:d,isMobile:O,setOpenMobile:A,overlay:!0,onSessionClick:_,onRenameSession:v,onDeleteSession:y,onSetSessionUnread:b,onMoveSession:x,onMoveSessionAnyDirectory:S,onTogglePinnedSession:C,onCreateSessionInDirectory:w,onDeleteOldSessionsInDirectory:T,onRemoveDirectory:E?fe:void 0}):I?(0,$.jsx)($o,{className:`w-64 rounded-lg bg-sidebar p-1 shadow-lg ring-1 ring-sidebar-border/70`,children:(0,$.jsx)(qv,{entryKey:I.entryKey,directorySessionsStore:o,activeSessionStore:W,selectedSessionKeyStore:U,isPinned:d.includes(I.entryKey),isMobile:O,overlay:!0,moveTargetDirectories:a,setOpenMobile:A,onSessionClick:_,onRenameSession:v,onDeleteSession:y,onSetSessionUnread:b,onMoveSession:x,onMoveSessionAnyDirectory:S,onTogglePinnedSession:C})}):null,t[114]=P,t[115]=I,t[116]=W,t[117]=H,t[118]=o,t[119]=O,t[120]=w,t[121]=T,t[122]=y,t[123]=x,t[124]=S,t[125]=E,t[126]=v,t[127]=_,t[128]=b,t[129]=C,t[130]=d,t[131]=fe,t[132]=M,t[133]=U,t[134]=A,t[135]=a,t[136]=je):je=t[136];let Me;t[137]===je?Me=t[138]:(Me=(0,$.jsx)(Kn,{children:je}),t[137]=je,t[138]=Me);let Ne;t[139]!==Se||t[140]!==ve||t[141]!==ge||t[142]!==q||t[143]!==we||t[144]!==Ae||t[145]!==Me?(Ne=(0,$.jsx)(Yo,{children:(0,$.jsxs)(Nt,{sensors:q,collisionDetection:pr,onDragStart:ge,onDragOver:ve,onDragEnd:Se,onDragCancel:be,children:[we,Ae,Me]})}),t[139]=Se,t[140]=ve,t[141]=ge,t[142]=q,t[143]=we,t[144]=Ae,t[145]=Me,t[146]=Ne):Ne=t[146];let Pe,Fe;t[147]===Symbol.for(`react.memo_cache_sentinel`)?(Pe=(0,$.jsx)(k,{}),Fe=(0,$.jsx)(`span`,{children:`Commands`}),t[147]=Pe,t[148]=Fe):(Pe=t[147],Fe=t[148]);let Ie;t[149]===Symbol.for(`react.memo_cache_sentinel`)?(Ie=(0,$.jsx)(`span`,{className:`ml-auto hidden items-center md:flex`,children:(0,$.jsx)(r,{children:Ir(`Control+K`)})}),t[149]=Ie):Ie=t[149];let Le;t[150]===h?Le=t[151]:(Le=(0,$.jsx)(es,{children:(0,$.jsxs)(ns,{type:`button`,onClick:h,children:[Pe,Fe,Ie]})}),t[150]=h,t[151]=Le);let Re,ze;t[152]===Symbol.for(`react.memo_cache_sentinel`)?(Re=(0,$.jsx)(Ba,{}),ze=(0,$.jsx)(`span`,{children:`Settings`}),t[152]=Re,t[153]=ze):(Re=t[152],ze=t[153]);let Be;t[154]===Symbol.for(`react.memo_cache_sentinel`)?(Be=(0,$.jsx)(`span`,{className:`ml-auto hidden items-center md:flex`,children:(0,$.jsx)(r,{children:Ir(`Control+,`)})}),t[154]=Be):Be=t[154];let Ve;t[155]===g?Ve=t[156]:(Ve=(0,$.jsx)(es,{children:(0,$.jsxs)(ns,{type:`button`,onClick:g,children:[Re,ze,Be]})}),t[155]=g,t[156]=Ve);let He;t[157]!==Le||t[158]!==Ve?(He=(0,$.jsx)(Jo,{className:`gap-2 border-t border-sidebar-border/70`,children:(0,$.jsxs)($o,{className:`gap-1`,children:[Le,Ve]})}),t[157]=Le,t[158]=Ve,t[159]=He):He=t[159];let Ue;t[160]===Symbol.for(`react.memo_cache_sentinel`)?(Ue=(0,$.jsx)(Go,{}),t[160]=Ue):Ue=t[160];let We;return t[161]!==Ce||t[162]!==Ne||t[163]!==He?(We=(0,$.jsxs)(Uo,{collapsible:`offcanvas`,className:`top-[var(--header-height)] !h-[calc(100svh_-_var(--header-height))] border-r border-sidebar-border/70`,children:[Ce,Ne,He,Ue]}),t[161]=Ce,t[162]=Ne,t[163]=He,t[164]=We):We=t[164],We}var ly=`__pico_pinned_sessions__`;function uy(e,t){let n=t.sessionPath?.trim()||``,r=t.sessionId?.trim()||``;if(n){let t=We({path:n});if(e.has(t))return t}if(r){let t=We({id:r});if(e.has(t))return t}for(let[t,i]of e)if(n&&i.path===n||r&&i.id===r)return t;return``}function dy(e){return fy(e)}function fy(e){let t=(0,Q.c)(122),{viewerContextId:n,sidebarStore:r,sessionWorkspaceRef:a}=e,[o]=Z.useState(Ay),s=Gl(r,ky,Mi),c=Gl(r,Oy,Vi),l=Gl(r,Dy),u=Gl(r,Ey,Nl),d=Gl(r,Ty),f;t[0]===d?f=t[1]:(f=d.flatMap(wy),t[0]=d,t[1]=f);let p=f,m=Gl(r,Cy,Vi),h=Gl(r,Sy,Mi),g=Gl(r,xy),_=Gl(r,by),v=Gl(r,yy,Mi),y=Gl(r,vy,_y),b=Gl(r,gy),x=y.activeSessionId,S=y.activeSessionKey,C=y.activeSessionPath,w=y.activeStreaming,T;if(t[2]!==u||t[3]!==h){let e;t[5]===u?e=t[6]:(e=(e,t)=>e+(u[t]?.length??0),t[5]=u,t[6]=e),T=h.reduce(e,0),t[2]=u,t[3]=h,t[4]=T}else T=t[4];let E=T,O=Gl(r,hy),k=Gl(r,my),A=Gl(r,py),j;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(j={signature:``,key:``},t[7]=j):j=t[7];let M=Z.useRef(j),N=Z.useRef(0),P;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(P={},t[8]=P):P=t[8];let F=Z.useRef(P),I=Z.useRef(null),L;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(L=e=>{let t=N.current+1;N.current=t;for(let n of e)F.current[n]=t;return t},t[9]=L):L=t[9];let R=L,z;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(z=(e,t)=>e.filter(e=>F.current[e]===t),t[10]=z):z=t[10];let V=z,H;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(H=(e,t)=>{for(let n of e)F.current[n]===t&&delete F.current[n]},t[11]=H):H=t[11];let U=H,W,ee;t[12]!==_||t[13]!==o||t[14]!==u||t[15]!==d?(W=()=>{o.setData(d.length>0?{...u,[ly]:d}:u,_)},ee=[_,o,u,d],t[12]=_,t[13]=o,t[14]=u,t[15]=d,t[16]=W,t[17]=ee):(W=t[16],ee=t[17]),Z.useLayoutEffect(W,ee);let te,ne;t[18]===r?(te=t[19],ne=t[20]):(te=()=>{let e=0,t=window.requestAnimationFrame(()=>{e=window.setTimeout(()=>{r.setSidebarDeferredDirectoryLoadingReady(!0)},0)});return()=>{window.cancelAnimationFrame(t),e&&window.clearTimeout(e)}},ne=[r],t[18]=r,t[19]=te,t[20]=ne),Z.useEffect(te,ne);let G,K;t[21]!==s||t[22]!==r?(G=()=>{let e=new Set(s);r.setDirectoryIndexDataByPath(t=>{let n={};for(let[r,i]of Object.entries(t))e.has(r)&&(n[r]=i);return JSON.stringify(n)===JSON.stringify(t)?t:n}),r.setDirectoryIndexLoading(t=>{let n={};for(let[r,i]of Object.entries(t))e.has(r)&&(n[r]=i);return JSON.stringify(n)===JSON.stringify(t)?t:n});let t={};for(let[n,r]of Object.entries(F.current))e.has(n)&&(t[n]=r);F.current=t},K=[s,r],t[21]=s,t[22]=r,t[23]=G,t[24]=K):(G=t[23],K=t[24]),Z.useEffect(G,K);let re,q;t[25]!==x||t[26]!==S||t[27]!==C||t[28]!==w||t[29]!==s||t[30]!==g||t[31]!==_||t[32]!==c||t[33]!==b||t[34]!==r||t[35]!==n?(re=()=>{if(!n||!b)return;let e=b.directoryIndexes||{},t=Object.keys(e),i=new Set(t);r.setSidebarState(n=>{let r=Fl(t.length?Cl(n.directoryIndexDataByPath,e):n.directoryIndexDataByPath,{sessionId:x,sessionPath:C}),i=t.length?Tl(n.directoryIndexLoading,t,!1):n.directoryIndexLoading,a=!wl(n.directoryIndexDataByPath,r);return!a&&i===n.directoryIndexLoading?n:{directoryIndexDataByPath:a?r:n.directoryIndexDataByPath,directoryIndexLoading:i}});let a=I.current,o={},l=[];for(let e of s){let t=c.get(e)?.revision||``,n=a?.revisions[e]||``;o[e]=t,!i.has(e)&&Object.prototype.hasOwnProperty.call(g,e)&&(_[e]||F.current[e]||n!==t&&(w||l.push(e)))}if(I.current={activeSessionId:x,activeSessionKey:S,activeSessionPath:C,revisions:o},l.length===0)return;let u=R(l);Sl({viewerContextId:n,directories:l}).then(e=>{let t=V(l,u);if(t.length===0)return;U(t,u);let n=Object.fromEntries(t.flatMap(t=>{let n=e.directoryIndexes[t];return n?[[t,n]]:[]}));r.setSidebarState(e=>{let r=Object.keys(n).length>0?Ml(e.directoryIndexDataByPath,n):e.directoryIndexDataByPath,i=Tl(e.directoryIndexLoading,t,!1);return r===e.directoryIndexDataByPath&&i===e.directoryIndexLoading?e:{directoryIndexDataByPath:r,directoryIndexLoading:i}})}).catch(e=>{let t=V(l,u);t.length!==0&&(U(t,u),r.setDirectoryIndexLoading(e=>Tl(e,t,!1)),X.error(e instanceof Error?e.message:`Failed to load sidebar sessions`))})},q=[s,g,_,x,S,C,w,c,b,r,n],t[25]=x,t[26]=S,t[27]=C,t[28]=w,t[29]=s,t[30]=g,t[31]=_,t[32]=c,t[33]=b,t[34]=r,t[35]=n,t[36]=re,t[37]=q):(re=t[36],q=t[37]),Z.useEffect(re,q);let ie,J;t[38]!==x||t[39]!==S||t[40]!==C||t[41]!==r?(ie=()=>{!x&&!S&&!C||r.setSidebarSessionStatusByKey(e=>Rl(e,{type:`session_status`,sessionKey:S,sessionId:x,sessionPath:C,unread:!1}))},J=[x,S,C,r],t[38]=x,t[39]=S,t[40]=C,t[41]=r,t[42]=ie,t[43]=J):(ie=t[42],J=t[43]),Z.useEffect(ie,J);let ae,oe;t[44]!==x||t[45]!==S||t[46]!==C||t[47]!==m||t[48]!==r?(ae=()=>{let e=[x,C,S].join(`\0`),t=uy(m,{sessionId:x,sessionPath:C});!t&&S&&m.has(S)&&(t=S);let n=M.current;n.signature===e&&n.key===t||(M.current={signature:e,key:t},r.setSelectedSidebarSessionKeys(e=>{let n=t?[t]:[];return Mi(e,n)?e:n}),r.setSidebarSessionSelectionAnchor(e=>e===t?e:t))},oe=[x,S,C,m,r],t[44]=x,t[45]=S,t[46]=C,t[47]=m,t[48]=r,t[49]=ae,t[50]=oe):(ae=t[49],oe=t[50]),Z.useEffect(ae,oe);let se,ce;t[51]!==s||t[52]!==g||t[53]!==_||t[54]!==k||t[55]!==r||t[56]!==n?(se=()=>{if(!n||!k)return;let e=s.filter(e=>!Object.prototype.hasOwnProperty.call(g,e)&&!_[e]&&!F.current[e]);if(e.length===0)return;let t=R(e);r.setDirectoryIndexLoading(t=>Tl(t,e,!0)),Sl({viewerContextId:n,directories:e}).then(n=>{let i=V(e,t);if(i.length===0)return;U(i,t);let a=Object.fromEntries(i.flatMap(e=>{let t=n.directoryIndexes[e];return t?[[e,t]]:[]}));r.setSidebarState(e=>{let t=Object.keys(a).length>0?Ml(e.directoryIndexDataByPath,a):e.directoryIndexDataByPath,n=Tl(e.directoryIndexLoading,i,!1);return t===e.directoryIndexDataByPath&&n===e.directoryIndexLoading?e:{directoryIndexDataByPath:t,directoryIndexLoading:n}})}).catch(n=>{let i=V(e,t);i.length!==0&&(U(i,t),r.setDirectoryIndexLoading(e=>Tl(e,i,!1)),X.error(n instanceof Error?n.message:`Failed to load sidebar sessions`))})},ce=[s,g,_,k,r,n],t[51]=s,t[52]=g,t[53]=_,t[54]=k,t[55]=r,t[56]=n,t[57]=se,t[58]=ce):(se=t[57],ce=t[58]),Z.useEffect(se,ce);let le,ue;t[59]!==m||t[60]!==r?(le=()=>{let e=new Set(m.keys());r.setSelectedSidebarSessionKeys(t=>{let n=t.filter(t=>e.has(t));return n.length===t.length?t:n}),r.setSidebarSessionSelectionAnchor(t=>t&&e.has(t)?t:``)},ue=[m,r],t[59]=m,t[60]=r,t[61]=le,t[62]=ue):(le=t[61],ue=t[62]),Z.useEffect(le,ue);let de;t[63]===r?de=t[64]:(de=e=>{let t=i(e);t.length!==0&&r.setSidebarDirectories(e=>{let n=i(e);return JSON.stringify(n)===JSON.stringify(t)?e:(ye(D,JSON.stringify(t)),t)})},t[63]=r,t[64]=de);let fe=de,pe;t[65]===r?pe=t[66]:(pe=e=>{let t=We(e);t&&r.setPinnedSidebarSessionKeys(e=>{let n=At(e),r=n.includes(t)?n.filter(e=>e!==t):[t,...n];return ye(B,JSON.stringify(r)),r})},t[65]=r,t[66]=pe);let me=pe,he;t[67]===r?he=t[68]:(he=(e,t)=>{let n=t===void 0?``:t,i=At(e),a=i.length===0?``:n&&i.includes(n)?n:i[i.length-1]??``;r.setSelectedSidebarSessionKeys(e=>Mi(e,i)?e:i),r.setSidebarSessionSelectionAnchor(e=>e===a?e:a)},t[67]=r,t[68]=he);let ge=he,_e;t[69]!==v||t[70]!==ge||t[71]!==A?(_e=e=>{let t=e.trim();if(!t)return;let n=Pl(),r=n.indexOf(t);if(r<0){ge([t],t);return}let i=n.includes(A)?A:v.find(e=>n.includes(e))??t,a=n.indexOf(i);if(a<0){ge([t],t);return}let o=Math.min(a,r),s=Math.max(a,r);ge(n.slice(o,s+1),i)},t[69]=v,t[70]=ge,t[71]=A,t[72]=_e):_e=t[72];let ve=_e,be;t[73]!==ve||t[74]!==v||t[75]!==a||t[76]!==ge?(be=(e,t)=>{let n=We(e);if(!n){e.id&&a.current?.selectSession(e.id,{sessionPath:e.path});return}if(t.shiftKey){ve(n);return}if(t.multiSelectKey){ge(v.includes(n)?v.filter(e=>e!==n):[...v,n],n);return}ge([n],n),e.id&&!jl(e)&&a.current?.selectSession(e.id,{sessionPath:e.path})},t[73]=ve,t[74]=v,t[75]=a,t[76]=ge,t[77]=be):be=t[77];let xe=be,Se;t[78]===a?Se=t[79]:(Se=()=>{a.current?.openSessionsDialog()},t[78]=a,t[79]=Se);let Ce=x||void 0,we=S||void 0,Te,Ee,De,Oe;t[80]===a?(Te=t[81],Ee=t[82],De=t[83],Oe=t[84]):(Te=()=>{a.current?.createSession(void 0,{closeMobileSidebar:!0})},Ee=()=>{a.current?.openAddDirectoryDialog()},De=()=>{a.current?.openCommandPalette()},Oe=()=>{a.current?.openSettingsDialog()},t[80]=a,t[81]=Te,t[82]=Ee,t[83]=De,t[84]=Oe);let ke,Ae,je,Me,Ne;t[85]===a?(ke=t[86],Ae=t[87],je=t[88],Me=t[89],Ne=t[90]):(ke=e=>{a.current?.openRenameDialogForEntry(e)},Ae=e=>{a.current?.openDeleteDialog([e])},je=(e,t)=>{a.current?.setSessionUnread(e,t)},Me=(e,t)=>{a.current?.moveSessionToDirectory(e,t)},Ne=e=>{a.current?.openMoveSessionDirectoryDialogForEntry(e)},t[85]=a,t[86]=ke,t[87]=Ae,t[88]=je,t[89]=Me,t[90]=Ne);let Pe,Fe;t[91]===a?(Pe=t[92],Fe=t[93]):(Pe=e=>{a.current?.createSession(e,{closeMobileSidebar:!0})},Fe=e=>{a.current?.openDeleteOldDirectorySessionsDialog(e)},t[91]=a,t[92]=Pe,t[93]=Fe);let Ie;t[94]===r?Ie=t[95]:(Ie=e=>{r.setSidebarDirectories(t=>{let n=t.filter(t=>t!==e);return ye(D,JSON.stringify(n)),n})},t[94]=r,t[95]=Ie);let Le;return t[96]!==o||t[97]!==l||t[98]!==xe||t[99]!==E||t[100]!==p||t[101]!==fe||t[102]!==v||t[103]!==O||t[104]!==Se||t[105]!==Ce||t[106]!==we||t[107]!==Te||t[108]!==Ee||t[109]!==De||t[110]!==Oe||t[111]!==ke||t[112]!==Ae||t[113]!==je||t[114]!==Me||t[115]!==Ne||t[116]!==Pe||t[117]!==Fe||t[118]!==Ie||t[119]!==me||t[120]!==h?(Le=(0,$.jsx)(sy,{sessionSearch:O,onOpenSessionsDialog:Se,visibleDirectories:h,directorySessionsStore:o,matchingSessionCount:E,selectedSessionKeys:v,activeSessionId:Ce,activeSessionKey:we,pinnedSessionKeys:p,emptyStateText:l,onCreateSession:Te,onOpenAddDirectoryDialog:Ee,onOpenCommandPalette:De,onOpenSettings:Oe,onSessionClick:xe,onRenameSession:ke,onDeleteSession:Ae,onSetSessionUnread:je,onMoveSession:Me,onMoveSessionAnyDirectory:Ne,onTogglePinnedSession:me,onCreateSessionInDirectory:Pe,onDeleteOldSessionsInDirectory:Fe,onRemoveDirectory:Ie,onReorderDirectories:fe}),t[96]=o,t[97]=l,t[98]=xe,t[99]=E,t[100]=p,t[101]=fe,t[102]=v,t[103]=O,t[104]=Se,t[105]=Ce,t[106]=we,t[107]=Te,t[108]=Ee,t[109]=De,t[110]=Oe,t[111]=ke,t[112]=Ae,t[113]=je,t[114]=Me,t[115]=Ne,t[116]=Pe,t[117]=Fe,t[118]=Ie,t[119]=me,t[120]=h,t[121]=Le):Le=t[121],Le}function py(e){return e.state.sidebarSessionSelectionAnchor}function my(e){return e.state.sidebarDeferredDirectoryLoadingReady}function hy(e){return e.state.sessionSearch}function gy(e){return e.state.sessionsEvent}function _y(e,t){return e.activeSessionId===t.activeSessionId&&e.activeSessionKey===t.activeSessionKey&&e.activeSessionPath===t.activeSessionPath&&e.activeStreaming===t.activeStreaming&&e.event?.activeSessionId===t.event?.activeSessionId&&e.event?.activeSessionKey===t.event?.activeSessionKey&&e.event?.activeSessionPath===t.event?.activeSessionPath&&Mi(e.event?.directories||[],t.event?.directories||[])}function vy(e){let t=e.state.sessionsEvent,n=e.state.activeSidebarSessionId,r=e.state.activeSidebarSessionKey,i=e.state.activeSidebarSessionPath,a=e.state.sidebarSessionStatusByKey;return{event:t,activeSessionId:n,activeSessionKey:r,activeSessionPath:i,activeStreaming:!!((i?a[`path:${i}`]:void 0)||(n?a[`id:${n}`]:void 0)||(r?a[`key:${r}`]:void 0))?.streaming}}function yy(e){return e.state.selectedSidebarSessionKeys}function by(e){return e.state.directoryIndexLoading}function xy(e){return e.state.directoryIndexDataByPath}function Sy(e){return e.derived.visibleDirectories}function Cy(e){return e.derived.sidebarSessionEntriesByKey}function wy(e){let t=We(e);return t?[t]:[]}function Ty(e){return e.derived.pinnedSidebarSessions}function Ey(e){return e.derived.filteredDirectorySessions}function Dy(e){return e.derived.emptySidebarStateText}function Oy(e){return e.derived.directoryStateByPath}function ky(e){return e.derived.baseSidebarDirectories}function Ay(){return $v({},{})}var jy=4e3,My=`/sounds/session-done.mp3`,Ny=.85,Py=null,Fy=null,Iy=null;function Ly(){if(typeof window>`u`)return null;let e=window;return globalThis.AudioContext??e.webkitAudioContext??null}function Ry(){if(typeof navigator>`u`)return!1;let e=navigator.userActivation;return e?e.isActive:!0}function zy({requireUserActivation:e=!1}={}){let t=Ly();if(!t)return null;if(!Py){if(e&&!Ry())return null;Py=new t}return Py}async function By(e){if(e.state===`suspended`){if(!Ry())return!1;try{await e.resume()}catch{return!1}}return e.state===`running`}async function Vy(e){return Fy||(Iy??=fetch(My).then(e=>{if(!e.ok)throw Error(`Failed to load ${My}`);return e.arrayBuffer()}).then(t=>e.decodeAudioData(t)).then(e=>(Fy=e,e)).catch(()=>(Iy=null,null)),Iy)}function Hy(e){let t=e.createOscillator(),n=e.createGain();t.type=`triangle`,t.frequency.setValueAtTime(659.25,e.currentTime),t.frequency.linearRampToValueAtTime(783.99,e.currentTime+.12),n.gain.setValueAtTime(1e-4,e.currentTime),n.gain.exponentialRampToValueAtTime(.08,e.currentTime+.02),n.gain.exponentialRampToValueAtTime(1e-4,e.currentTime+.28),t.connect(n),n.connect(e.destination),t.start(e.currentTime),t.stop(e.currentTime+.3)}async function Uy(){let e=zy({requireUserActivation:!0});return!e||!await By(e)?!1:!!await Vy(e)}async function Wy(){let e=zy({requireUserActivation:!0});if(!e||!await By(e))return!1;let t=await Vy(e);if(!t)return Hy(e),!0;let n=e.createBufferSource(),r=e.createGain();return n.buffer=t,r.gain.value=Ny,n.connect(r),r.connect(e.destination),n.start(),!0}function Gy(){return typeof Notification>`u`?`unsupported`:Notification.permission}async function Ky(){if(typeof Notification>`u`)return`unsupported`;let e=Notification.requestPermission();return typeof e==`string`?e:await e}function qy({title:e,body:t,tag:n}){if(typeof Notification>`u`||Notification.permission!==`granted`)return!1;try{let r=new Notification(e,{body:t,tag:n,silent:!0});return window.setTimeout(()=>{r.close()},jy),!0}catch{return!1}}var Jy=[`🌑`,`🌒`,`🌓`,`🌔`,`🌕`,`🌖`,`🌗`,`🌘`],Yy=500;function Xy(){return typeof document>`u`?!0:document.visibilityState===`visible`&&document.hasFocus()}function Zy(e,t){let n=new Set(e?e.split(`
21
+ `):[]);return t&&n.add(t),n.size}function Qy({backgroundCurrentSessionUnreadKey:e,currentPageTitle:t,sessionStreaming:n,sidebarUnreadVersion:r,titleStreamingFrameIndex:i}){let a=`${n?`${Jy[i]} `:``}${t}`,o=Zy(r,e);document.title=o>0?`(${o}) ${a}`:a}function $y(e){let t=(0,Q.c)(20),{isSessionViewLoading:n,loadingDisplaySessionTitle:r,notificationStore:i,onSelectSession:a,sessionStore:o,sidebarStore:s}=e,c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c={compare:Ni},t[0]=c):c=t[0];let l=ka(o,tb,c),u=ka(i),d,f;t[1]===u.sessionDoneSoundEnabled?(d=t[2],f=t[3]):(d=()=>{if(!u.sessionDoneSoundEnabled)return;let e=eb;return window.addEventListener(`pointerdown`,e,!0),window.addEventListener(`keydown`,e,!0),()=>{window.removeEventListener(`pointerdown`,e,!0),window.removeEventListener(`keydown`,e,!0)}},f=[u.sessionDoneSoundEnabled],t[1]=u.sessionDoneSoundEnabled,t[2]=d,t[3]=f),Z.useEffect(d,f);let p;t[4]===l?p=t[5]:(p=ji(l),t[4]=l,t[5]=p);let m=p,h=n?r:l.uiTitle||(m===`New session`?`Pico`:m),g;t[6]===i?g=t[7]:(g=e=>{let t=new Set(e);vl(i,`sessionDoneEvents`,e=>e.filter(e=>!t.has(e.id)))},t[6]=i,t[7]=g);let _=g,v;return t[8]!==h||t[9]!==u.sessionDoneDesktopNotificationsEnabled||t[10]!==u.sessionDoneEvents||t[11]!==u.sessionDoneSoundEnabled||t[12]!==_||t[13]!==a||t[14]!==l.activeSessionKey||t[15]!==l.activeSessionNotificationKey||t[16]!==l.sessionCwd||t[17]!==l.sessionStreaming||t[18]!==s?(v=(0,$.jsx)(nb,{activeSessionKey:l.activeSessionKey,activeSessionNotificationKey:l.activeSessionNotificationKey,currentPageTitle:h,sessionCwd:l.sessionCwd,sessionDoneDesktopNotificationsEnabled:u.sessionDoneDesktopNotificationsEnabled,sessionDoneSoundEnabled:u.sessionDoneSoundEnabled,sessionStreaming:l.sessionStreaming,sessionDoneEvents:u.sessionDoneEvents,sidebarStore:s,onConsumeSessionDoneEvents:_,onSelectSession:a}),t[8]=h,t[9]=u.sessionDoneDesktopNotificationsEnabled,t[10]=u.sessionDoneEvents,t[11]=u.sessionDoneSoundEnabled,t[12]=_,t[13]=a,t[14]=l.activeSessionKey,t[15]=l.activeSessionNotificationKey,t[16]=l.sessionCwd,t[17]=l.sessionStreaming,t[18]=s,t[19]=v):v=t[19],v}function eb(){Uy()}function tb(e){return{activeSessionKey:e.sessionKey,activeSessionNotificationKey:Ii({sessionId:e.sessionId,sessionFile:e.sessionFile}),sessionCwd:e.cwd,sessionName:e.sessionName,sessionStreaming:e.streaming,firstMessage:e.firstMessage,uiTitle:e.uiState.title?.trim()||``}}function nb(e){let t=(0,Q.c)(28),{activeSessionKey:n,activeSessionNotificationKey:r,currentPageTitle:i,sessionCwd:a,sessionDoneDesktopNotificationsEnabled:o,sessionDoneSoundEnabled:s,sessionStreaming:c,sessionDoneEvents:l,sidebarStore:u,onConsumeSessionDoneEvents:d,onSelectSession:f}=e,p=ka(u,rb),m;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(m=Xy(),t[0]=m):m=t[0];let h=Z.useRef(m),g=Z.useRef(0),_=Z.useRef(``),v;t[1]!==i||t[2]!==c||t[3]!==p?(v={currentPageTitle:i,sessionStreaming:c,sidebarUnreadVersion:p},t[1]=i,t[2]=c,t[3]=p,t[4]=v):v=t[4];let y=Z.useRef(v),b;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(b=new Set,t[5]=b):b=t[5];let x=Z.useRef(b),S;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(S=()=>{Qy({...y.current,backgroundCurrentSessionUnreadKey:_.current,titleStreamingFrameIndex:g.current})},t[6]=S):S=t[6];let C=S,w,T;t[7]!==i||t[8]!==c||t[9]!==p?(w=()=>{y.current={currentPageTitle:i,sessionStreaming:c,sidebarUnreadVersion:p},C()},T=[i,c,p],t[7]=i,t[8]=c,t[9]=p,t[10]=w,t[11]=T):(w=t[10],T=t[11]),Z.useEffect(w,T);let E,D;t[12]===r?(E=t[13],D=t[14]):(E=()=>{let e=()=>{let e=Xy();if(h.current=e,e||!r){_.current=``,C();return}let t=_.current;t&&t!==r&&(_.current=``,C())};return e(),window.addEventListener(`focus`,e),window.addEventListener(`blur`,e),document.addEventListener(`visibilitychange`,e),()=>{window.removeEventListener(`focus`,e),window.removeEventListener(`blur`,e),document.removeEventListener(`visibilitychange`,e)}},D=[r],t[12]=r,t[13]=E,t[14]=D),Z.useEffect(E,D);let O,k;t[15]===c?(O=t[16],k=t[17]):(k=()=>{if(!c){g.current=0,C();return}let e=window.setInterval(()=>{g.current=(g.current+1)%Jy.length,C()},Yy);return()=>{window.clearInterval(e)}},O=[c],t[15]=c,t[16]=O,t[17]=k),Z.useEffect(k,O);let A,j;return t[18]!==n||t[19]!==r||t[20]!==d||t[21]!==f||t[22]!==a||t[23]!==o||t[24]!==l||t[25]!==s?(A=()=>{if(l.length===0)return;let e=[],t=!1;for(let i of l){if(e.push(i.id),x.current.has(i.id))continue;x.current.add(i.id);let c=Ii({sessionId:i.sessionId,sessionPath:i.sessionPath}),l=!!(c&&r&&c===r||i.sessionKey&&n&&i.sessionKey===n),u=Hi(i),d=i.cwd||a||`Open Pico to continue`,p=i.sessionPath||i.sessionId||i.id,m=h.current;if(l){!m&&c&&(_.current=c,C()),o&&!m&&qy({title:u,body:d,tag:p}),s&&!m&&!t&&(t=!0,Wy());continue}if(i.sessionId){let e=i.sessionId,t=i.id;X.success(u,{id:t,className:`cursor-pointer`,action:(0,$.jsx)(`button`,{type:`button`,"aria-label":`Open ${u}`,className:`absolute inset-0 z-10 cursor-pointer rounded-[var(--border-radius)] bg-transparent p-0 focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:outline-none`,onClick:()=>{X.dismiss(t),f(e)}})})}else X.success(u);o&&!m&&qy({title:u,body:d,tag:p}),s&&!t&&(t=!0,Wy())}d(e)},j=[n,r,d,f,a,o,l,s],t[18]=n,t[19]=r,t[20]=d,t[21]=f,t[22]=a,t[23]=o,t[24]=l,t[25]=s,t[26]=A,t[27]=j):(A=t[26],j=t[27]),Z.useEffect(A,j),null}function rb(e){return e.derived.sidebarSessions.flatMap(ib).sort().join(`
22
+ `)}function ib(e){if(!e.unread)return[];let t=Ii(e);return t?[t]:[]}function ab(e,t){return e.optimisticId||`pending-draft:${t}`}function ob(e,t,n){let r=e.findIndex((e,n)=>ab(e,n)===t);if(r===-1)return null;let i=e[r];if(!i)return null;let a=[...e],o=r+n,s=a[o];if(n===-1&&(i.streamingBehavior===`followUp`&&!s||i.streamingBehavior===`followUp`&&s.streamingBehavior===`steer`))return a[r]={...i,streamingBehavior:`steer`},a;if(n===1&&(i.streamingBehavior===`steer`&&!s||i.streamingBehavior===`steer`&&s.streamingBehavior===`followUp`))return a[r]={...i,streamingBehavior:`followUp`},a;if(!s)return null;let[c]=a.splice(r,1);return c?(a.splice(o,0,c),a):null}var sb=[],cb=[],lb=[];function ub(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1){let r=e[n],i=t[n];if(!r||!i||r.id!==i.id||r.cwd!==i.cwd||r.path!==i.path||r.lineNumber!==i.lineNumber||r.side!==i.side||r.text!==i.text||r.tabKey!==i.tabKey||r.tabTitle!==i.tabTitle||r.commit!==i.commit||r.shortHash!==i.shortHash||r.mode!==i.mode)return!1}return!0}function db(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1){let r=e[n],i=t[n];if(!r||!i||r.mimeType!==i.mimeType||r.data!==i.data||r.previewUrl!==i.previewUrl)return!1}return!0}function fb(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1){let r=e[n],i=t[n];if(!r||!i||r.pendingId!==i.pendingId||r.text!==i.text||r.streamingBehavior!==i.streamingBehavior||!db(r.images,i.images))return!1}return!0}function pb(e,t){return e.activeSessionId===t.activeSessionId&&e.awaitingFirstTurn===t.awaitingFirstTurn&&e.canStartPendingQueue===t.canStartPendingQueue&&e.centerMessages===t.centerMessages&&ub(e.composerDiffLineComments,t.composerDiffLineComments)&&e.composerSkill===t.composerSkill&&e.composerSyncNonce===t.composerSyncNonce&&e.composerText===t.composerText&&e.disabled===t.disabled&&e.isCompacting===t.isCompacting&&e.isStreaming===t.isStreaming&&e.isSubmitting===t.isSubmitting&&e.viewerContextId===t.viewerContextId&&db(e.composerImages,t.composerImages)&&fb(e.currentPendingMessages,t.currentPendingMessages)}function mb(e){return{activeSessionId:void 0,awaitingFirstTurn:!1,canStartPendingQueue:!1,centerMessages:!1,composerDiffLineComments:sb,composerImages:cb,composerSkill:void 0,composerSyncNonce:0,composerText:``,currentPendingMessages:lb,disabled:!1,isCompacting:!1,isStreaming:!1,isSubmitting:!1,viewerContextId:e}}function hb(e){let t=e.cwd?.trim()||e.previous.cwd?.trim()||``;return{...Ze(),connected:e.previous.connected,draft:!0,sessionKey:`optimistic:${e.ownerKey}`,cwd:t||void 0,model:e.previous.model,thinkingLevel:e.previous.thinkingLevel,availableThinkingLevels:e.previous.availableThinkingLevels,availableModels:e.previous.availableModels,availableSkills:e.previous.availableSkills,hideThinkingBlock:e.previous.hideThinkingBlock}}function gb(){return typeof crypto<`u`&&typeof crypto.randomUUID==`function`?`optimistic:${crypto.randomUUID()}`:`optimistic:${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}function _b(e,t){if(t.pendingId&&e.some(e=>e.kind===`user`&&e.pendingId===t.pendingId))return e;let n=[...e],r=n[n.length-1],i=r?.kind===`assistant`&&r.streaming?n.length-1:n.length;return n.splice(i,0,t),n}function vb(e,t){let n=!1,r=e.filter(e=>{let r=e.kind===`user`&&e.pendingId===t;return r&&(n=!0),!r});return n?r:e}var yb=`Compacting context...`,bb=`Error: Compaction cancelled`;function xb(e,t){return e?.label===t?.label&&e?.summary===t?.summary&&e?.done===t?.done&&e?.error===t?.error&&e?.cancelable===t?.cancelable}function Sb(e){let t=new mo(t=>{e.onLatest(t)},{key:e.key,wait:e.wait,leading:!1,trailing:!0});return{add:e=>t.maybeExecute(e),flush:()=>t.flush(),cancel:()=>t.cancel()}}var Cb=`pico-offline-prompts`,wb=1,Tb=`prompts`,Eb=`pico-offline-prompts`,Db;function Ob(){return typeof indexedDB<`u`}function kb(){return Ob()?(Db??=new Promise(e=>{let t=indexedDB.open(Cb,wb);t.onupgradeneeded=()=>{let e=t.result;e.objectStoreNames.contains(Tb)||e.createObjectStore(Tb,{keyPath:`id`})},t.onerror=()=>e(null),t.onsuccess=()=>e(t.result)}),Db):Promise.resolve(null)}function Ab(){try{let e=window.localStorage.getItem(Eb);if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)?Pb(t):[]}catch{return[]}}function jb(e){try{window.localStorage.setItem(Eb,JSON.stringify(e))}catch{}}function Mb(e){if(!e||typeof e!=`object`)return null;let t=e;return typeof t.mimeType!=`string`||typeof t.data!=`string`?null:{type:`image`,mimeType:t.mimeType,data:t.data}}function Nb(e){if(!e||typeof e!=`object`)return null;let t=e;if(typeof t.id!=`string`||!t.id||typeof t.contextId!=`string`||!t.contextId||typeof t.message!=`string`||typeof t.clientRequestId!=`string`)return null;let n=Array.isArray(t.images)?t.images.flatMap(e=>{let t=Mb(e);return t?[t]:[]}):[];return{id:t.id,contextId:t.contextId,createdAt:typeof t.createdAt==`number`&&Number.isFinite(t.createdAt)?t.createdAt:Date.now(),sessionId:typeof t.sessionId==`string`?t.sessionId:void 0,targetSessionKey:typeof t.targetSessionKey==`string`?t.targetSessionKey:void 0,message:t.message,images:n,streamingBehavior:t.streamingBehavior===`followUp`||t.streamingBehavior===`steer`?t.streamingBehavior:void 0,pendingId:typeof t.pendingId==`string`?t.pendingId:void 0,clientRequestId:t.clientRequestId,thinkingLevel:typeof t.thinkingLevel==`string`?t.thinkingLevel:void 0,draftOwnerKey:typeof t.draftOwnerKey==`string`?t.draftOwnerKey:void 0,draftCwd:typeof t.draftCwd==`string`?t.draftCwd:void 0}}function Pb(e){return e.flatMap(e=>{let t=Nb(e);return t?[t]:[]}).sort((e,t)=>e.createdAt-t.createdAt)}async function Fb(e){let t=await kb();if(!t){let t=Ab().filter(t=>t.id!==e.id);t.push(e),jb(Pb(t));return}await new Promise((n,r)=>{let i=t.transaction(Tb,`readwrite`),a=i.objectStore(Tb).put(e);a.onerror=()=>r(a.error),i.oncomplete=()=>n(),i.onerror=()=>r(i.error)})}async function Ib(e){let t=await kb();if(!t){let t=Ab();return e?t.filter(t=>t.contextId===e):t}let n=await new Promise((e,n)=>{let r=t.transaction(Tb,`readonly`),i=r.objectStore(Tb).getAll();i.onerror=()=>n(i.error),i.onsuccess=()=>e(Pb(i.result)),r.onerror=()=>n(r.error)});return e?n.filter(t=>t.contextId===e):n}async function Lb(e){let t=await kb();if(!t){jb(Ab().filter(t=>t.id!==e));return}await new Promise((n,r)=>{let i=t.transaction(Tb,`readwrite`),a=i.objectStore(Tb).delete(e);a.onerror=()=>r(a.error),i.oncomplete=()=>n(),i.onerror=()=>r(i.error)})}function Rb(e){return!(`ok`in e)||!e.ok?null:e.pendingMessages.map(e=>({pendingId:e.pendingId,text:e.text,images:e.images.flatMap(e=>{let t=lt(e);return t?[t]:[]}),streamingBehavior:e.streamingBehavior===`steer`?`steer`:`followUp`}))}function zb(e,t){return e.assistantOutputSignature===t.assistantOutputSignature&&e.cwd===t.cwd&&e.draft===t.draft&&e.sessionFile===t.sessionFile&&e.sessionId===t.sessionId&&e.sessionKey===t.sessionKey&&e.streaming===t.streaming}function Bb(e){let t=0,n=``;for(let r=0;r<e.length;r+=1){let i=e[r];!i||i.kind!==`assistant`||i.blocks.some(e=>e.type===`text`&&e.text.trim())&&(t+=1,n=i.itemKey||i.renderKey||`index:${r}`)}return`${t}:${n}`}function Vb(e){let t=(0,Q.c)(1),n;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n={compare:zb},t[0]=n):n=t[0],ka(e,Hb,n)}function Hb(e){return{assistantOutputSignature:Bb(e.items),cwd:e.cwd,draft:e.draft,sessionFile:e.sessionFile,sessionId:e.sessionId,sessionKey:e.sessionKey,streaming:e.streaming}}function Ub(e){return e===`followUp`?`followUp`:`steer`}function Wb(e,t){return e.replace(/\s+/g,` `).trim()||(t.length===0?``:`${t.length.toLocaleString()} image${t.length===1?``:`s`}`)}function Gb(){return typeof crypto<`u`&&typeof crypto.randomUUID==`function`?`optimistic:${crypto.randomUUID()}`:`optimistic:${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}function Kb(){return typeof crypto<`u`&&typeof crypto.randomUUID==`function`?`prompt:${crypto.randomUUID()}`:`prompt:${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}function qb(e){if(typeof navigator<`u`&&navigator.onLine===!1)return!0;let t=e instanceof Error?e.message.toLowerCase():``;return t===`failed to fetch`||t===`load failed`||t.includes(`networkerror`)||t.includes(`network error`)}function Jb(e,{contextId:t,sessionState:n,fallbackSessionId:r,targetSessionKey:i}){if(i)return hi(e,{contextId:t,searchParams:{sessionKey:i}});let a=n.sessionKey&&!n.sessionKey.startsWith(`optimistic:`)?n.sessionKey:void 0,o=!!(a&&(n.draft||!n.sessionId));return hi(e,{contextId:t,sessionId:o||n.draft?void 0:n.sessionId??r,searchParams:o?{sessionKey:a}:void 0})}function Yb(e){return hi(`/api/prompt`,{contextId:e.contextId,sessionId:e.targetSessionKey?void 0:e.sessionId,searchParams:e.targetSessionKey?{sessionKey:e.targetSessionKey}:void 0})}function Xb(e){return{message:e.message,images:e.images,streamingBehavior:e.streamingBehavior,pendingId:e.pendingId,clientRequestId:e.clientRequestId,thinkingLevel:e.thinkingLevel,draftOwnerKey:e.draftOwnerKey,draftCwd:e.draftCwd}}function Zb(e){return e instanceof Error&&e.message.toLowerCase().includes(`pending prompt not found`)}function Qb(e,t,n){let r=e.findIndex(e=>e.pendingId===t);if(r===-1)return null;let i=e[r];if(!i)return null;let a=[...e],o=r+n,s=a[o];if(n===-1&&(i.streamingBehavior===`followUp`&&!s||i.streamingBehavior===`followUp`&&s.streamingBehavior===`steer`))return a[r]={...i,streamingBehavior:`steer`},a;if(n===1&&(i.streamingBehavior===`steer`&&!s||i.streamingBehavior===`steer`&&s.streamingBehavior===`followUp`))return a[r]={...i,streamingBehavior:`followUp`},a;if(!s)return null;let[c]=a.splice(r,1);return c?(a.splice(o,0,c),a):null}function $b({viewerContextId:e,activeSessionId:t,defaultNewSessionDirectory:n,sessionStore:r,sessionStateRef:a,draftSessionLoadingOwnerKey:o,pendingDraftPrompt:s,pendingDraftFollowUps:c,awaitingFirstTurn:l,pendingMessages:u,composerDiffLineCommentsRef:d,composerImagesRef:f,composerTextRef:p,composerSkillRef:m,replaceComposerDraft:h,lastSyncedEditorTextRef:_,rememberRecentDirectory:v,prefetchDirectorySessionsIndex:y,addOptimisticUserMessage:b,removeOptimisticUserMessage:x,addOptimisticSidebarSession:S,removeOptimisticSidebarSession:C,updateOptimisticSidebarSessionPreview:w,setSidebarDirectories:T,setStoredDraftDirectory:E,setDraftSessionLoadingOwnerKey:O,setPendingDraftPrompt:k,setPendingDraftFollowUps:A,setPendingMessages:j,setAwaitingFirstTurn:M,setIsSubmitting:N,setComposerDiffLineComments:P,setComposerImages:F}){let I=ki(),L=Z.useRef(o),R=Z.useRef(null),z=Z.useRef(0),B=Z.useRef(s),V=Z.useRef(c),H=Z.useRef(u),U=Z.useRef(l),W=Z.useRef(null),te=Vb(r),ne=Z.useRef(async()=>!1);Z.useEffect(()=>{L.current=o},[o]),Z.useEffect(()=>{B.current=s},[s]),Z.useEffect(()=>{V.current=c},[c]),Z.useEffect(()=>{H.current=u},[u]),Z.useEffect(()=>{U.current=l},[l]);let G=Z.useCallback(e=>{j(t=>{let n=e(t);return H.current=n,n})},[j]),K=Z.useCallback(e=>{G(t=>t.some(t=>t.pendingId===e.pendingId)?t:[...t,e])},[G]),re=Z.useCallback(e=>{G(t=>t.filter(t=>t.pendingId!==e))},[G]),q=Z.useCallback((e,t)=>{G(n=>{if(n.some(t=>t.pendingId===e.pendingId))return n;let r=[...n];return r.splice(Math.max(0,Math.min(t,r.length)),0,e),r})},[G]),ie=an({mutationFn:async n=>{if(!e)throw Error(`Viewer context unavailable`);return await oi(hi(`/api/directory/resolve`,{contextId:e,sessionId:t}),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({path:n})})},onSuccess:async t=>{await I.invalidateQueries({queryKey:vi.directorySessionsIndex(e,t.path),refetchType:`active`})}}),J=Z.useCallback(e=>(h(e.message),F(e.images.map(e=>({...e}))),!0),[h,F]),ae=Z.useCallback(e=>{let t=B.current;if(!t||t.ownerKey!==e)return!1;x(t.optimisticId),C(t.optimisticSidebarSessionId);for(let e of V.current)x(e.optimisticId);return R.current=null,B.current=null,V.current=[],k(null),A([]),W.current=null,U.current=!1,M(!1),J(t)},[J,C,x,M,A,k]),oe=Z.useCallback(async t=>{if(!e)return!1;let n=t.trim();if(!n)return!1;try{let e=await ie.mutateAsync(n);return T(t=>{let n=i([...t,e.path]);return ye(D,JSON.stringify(n)),n}),v(e.path),y(e.path),e.path}catch(e){return X.error(e instanceof Error?e.message:`Failed to add directory`),!1}},[ie,y,v,T,e]),se=Z.useCallback(async({cwd:n})=>{if(!e)throw Error(`Viewer context unavailable`);return await oi(Jb(`/api/session/new`,{contextId:e,sessionState:a.current,fallbackSessionId:t}),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({cwd:n})})},[t,a,e]),ce=Z.useCallback(async t=>{if(!e)return!1;let r=Ri({cwdOverride:t,defaultDirectory:n,currentCwd:a.current.cwd});r&&(v(r),ye(fe,r),E(r));let i=ee({cwd:r});L.current=i,O(i),W.current=null,U.current=!1,M(!1),H.current=[],j(e=>e.length===0?e:[]);let o=z.current+1;z.current=o;try{let e=await se({cwd:r});return z.current===o?(R.current={ownerKey:i,sessionKey:e.sessionKey,cwd:e.cwd},L.current===i&&(L.current=null,O(e=>e===i?null:e)),B.current?.ownerKey===i&&ne.current(i,e.sessionKey),!0):!0}catch(e){return z.current===o?(L.current===i&&(L.current=null),O(e=>e===i?null:e),R.current?.ownerKey===i&&(R.current=null),ae(i),X.error(e instanceof Error?e.message:`Failed to create session`),!1):!0}},[se,n,v,ae,a,M,O,j,E,e]),le=Z.useCallback((e,t)=>{let n=t||L.current;if(!n)return!1;let r=yf({text:p.current,skillName:m.current,diffLineComments:d.current}).trim(),i=f.current.map(e=>({...e}));if(!r&&i.length===0)return!1;let a=B.current?.ownerKey===n?B.current:null,o=Wb(r,i);if(a){let t=Ub(e),n=Gb();w({...a.optimisticSidebarSessionId?{optimisticSidebarSessionId:a.optimisticSidebarSessionId}:{},preview:o});let s=[...V.current,{message:r,images:i,streamingBehavior:t,optimisticId:n}];V.current=s,A(s)}else{let t={ownerKey:n,message:r,images:i,streamingBehavior:e,optimisticId:b({message:r,images:i,queued:!1}),optimisticSidebarSessionId:S({lastMessagePreview:o})};B.current=t,k(t),U.current=!0,M(!0),X.info(`Prompt will send when the new session is ready.`)}return h(``,void 0,{forceSync:!0}),P([]),F([]),_.current=``,!0},[S,b,d,f,m,p,_,h,M,P,F,A,k,w]),ue=an({mutationFn:async({message:n,images:r,streamingBehavior:i,pendingId:o,clientRequestId:s,thinkingLevel:c,targetSessionKey:l,draftTarget:u})=>{if(!e)throw Error(`Viewer context unavailable`);return await oi(Jb(`/api/prompt`,{contextId:e,sessionState:a.current,fallbackSessionId:t,targetSessionKey:l}),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({message:n,images:r,streamingBehavior:i,pendingId:o,clientRequestId:s,thinkingLevel:c,draftOwnerKey:u?.ownerKey,draftCwd:u?.cwd})})},onSuccess:async()=>{await I.invalidateQueries({queryKey:vi.sessionTree(e,di(a.current)),refetchType:`active`})}}),de=Z.useRef(!1),pe=Z.useRef(new Set),me=Z.useCallback(async()=>{if(!(!e||de.current)&&!(typeof navigator<`u`&&navigator.onLine===!1)){de.current=!0;try{let t=await Ib(e);if(t.length===0)return;let n=0;for(let e of t)try{await oi(Yb(e),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(Xb(e))}),await Lb(e.id),pe.current.delete(e.id),n+=1}catch(t){if(qb(t))break;pe.current.has(e.id)||(pe.current.add(e.id),X.error(t instanceof Error?`Failed to send queued prompt: ${t.message}`:`Failed to send queued prompt`));break}n>0&&(X.success(n===1?`Sent queued prompt`:`Sent ${n.toLocaleString()} queued prompts`),await I.invalidateQueries({refetchType:`active`}))}finally{de.current=!1}}},[I,e]);Z.useEffect(()=>{if(!e)return;let t=()=>{me()};window.addEventListener(`online`,t),window.addEventListener(`focus`,t),document.addEventListener(`visibilitychange`,t);let n=window.setInterval(t,3e4);return t(),()=>{window.removeEventListener(`online`,t),window.removeEventListener(`focus`,t),document.removeEventListener(`visibilitychange`,t),window.clearInterval(n)}},[me,e]);let he=Z.useCallback(async(n,r)=>{if(!e)return!1;if(L.current)return le(n);let i=d.current.map(e=>({...e})),o=yf({text:p.current,skillName:m.current,diffLineComments:i}).trim();if(!o&&f.current.length===0)return!1;let s=a.current,c=R.current,l=s.draft?ee(s):``,u=!r?.targetSessionKey&&s.draft&&c&&g(l,c.ownerKey)?c.sessionKey:void 0,v=r?.targetSessionKey||u,y=s.draft?{ownerKey:r?.targetDraftOwnerKey||(v&&c?.sessionKey===v?c.ownerKey:l),cwd:r?.targetDraftCwd||v&&c?.sessionKey===v&&c.cwd||s.cwd}:void 0;if(s.draft&&s.sessionKey?.startsWith(`optimistic:`)&&!v)return!L.current&&l&&(L.current=l,O(l)),le(n,l);let T=r?.forceFirstPrompt?!1:!!(s.streaming||s.compacting||U.current),E=T?Ub(n):void 0,D=f.current.map(e=>({...e})),k=Wb(o,D),A=T?Gb():void 0;T||(W.current=Bb(s.items),U.current=!0,M(!0));let j=r?.optimisticId??(T?void 0:b({message:o,images:D,queued:!1})),I=r?.optimisticSidebarSessionId??(!T&&s.draft?S({lastMessagePreview:k}):void 0);w({...I?{optimisticSidebarSessionId:I}:{},preview:k}),A&&E&&K({pendingId:A,text:o,images:D.map(e=>({...e})),streamingBehavior:E});let z=Kb();N(!0),h(``,void 0,{forceSync:!0}),P([]),F([]),_.current=``;try{let e=await ue.mutateAsync({message:o,images:D,streamingBehavior:E,pendingId:A,clientRequestId:z,thinkingLevel:s.thinkingLevel,targetSessionKey:v,draftTarget:y});return A&&`queued`in e&&(!e.queued||e.canceled)&&re(A),v&&R.current?.sessionKey===v&&(R.current=null),!0}catch(n){let r=v||(s.sessionKey&&!s.sessionKey.startsWith(`optimistic:`)&&(s.draft||!s.sessionId)?s.sessionKey:void 0),a=r?void 0:s.sessionId??t;return qb(n)&&(r||a)?(await Fb({id:z,contextId:e,createdAt:Date.now(),sessionId:a,targetSessionKey:r,message:o,images:D.map(e=>({type:`image`,mimeType:e.mimeType,data:e.data})),streamingBehavior:E,pendingId:A,clientRequestId:z,thinkingLevel:s.thinkingLevel,draftOwnerKey:y?.ownerKey,draftCwd:y?.cwd}),A&&re(A),x(j),C(I),T||(W.current=null,U.current=!1,M(!1)),X.info(`Prompt queued locally and will send when reconnected`),!0):(A&&re(A),x(j),C(I),T||(W.current=null,U.current=!1,M(!1)),!hf({text:p.current,skillName:m.current}).trim()&&d.current.length===0&&(h(o),P(e=>e.length===0?i.map(e=>({...e})):e),F(e=>e.length===0?D.map(e=>({...e})):e)),X.error(n instanceof Error?n.message:`Failed to submit prompt`),!1)}finally{N(!1)}},[t,K,S,b,d,f,m,p,_,ue,le,a,re,C,x,h,M,P,F,O,N,w,e]),ge=Z.useCallback(async(e,t)=>{if(L.current)return!1;let n=V.current;if(n.length===0)return!1;let r=n.map(e=>({message:e.message,images:e.images.map(e=>({...e})),streamingBehavior:e.streamingBehavior,optimisticId:e.optimisticId}));V.current=[],A([]);let i=async(n=0)=>{let o=r[n];if(!o)return!0;try{await ue.mutateAsync({message:o.message,images:o.images,streamingBehavior:o.streamingBehavior,pendingId:o.optimisticId,clientRequestId:Kb(),thinkingLevel:a.current.thinkingLevel,targetSessionKey:e,draftTarget:t})}catch(e){for(let e of r.slice(n))x(e.optimisticId);return p.current||(h(o.message),F(o.images)),X.error(e instanceof Error?e.message:`Failed to submit queued follow-up`),!1}return await i(n+1)};return await i()},[p,ue,x,a,h,F,A]),_e=Z.useCallback(async(e,t)=>{let n=B.current;if(!n||n.ownerKey!==e||L.current)return!1;let r=R.current,i=t||(r?.ownerKey===e?r.sessionKey:void 0),o={ownerKey:e,cwd:r?.cwd||a.current.cwd};if(B.current=null,k(null),J(n),!await he(n.streamingBehavior,{forceFirstPrompt:!0,optimisticId:n.optimisticId,optimisticSidebarSessionId:n.optimisticSidebarSessionId,targetSessionKey:i,targetDraftOwnerKey:o.ownerKey,targetDraftCwd:o.cwd})){C(n.optimisticSidebarSessionId);for(let e of V.current)x(e.optimisticId);return V.current=[],A([]),R.current?.ownerKey===e&&(R.current=null),!1}return await ge(i,o),R.current?.ownerKey===e&&(R.current=null),!0},[J,ge,C,x,A,k,he]);ne.current=_e,Z.useEffect(()=>{if(!o)return;let e=a.current;if(e.sessionKey?.startsWith(`optimistic:`))return;let t=ee(e);if(!e.draft||!g(t,o))return;let n=e.sessionKey?.startsWith(`optimistic:`)?void 0:e.sessionKey;n&&(R.current={ownerKey:o,sessionKey:n,cwd:e.cwd}),L.current=null,O(null),B.current?.ownerKey===o&&_e(o,n)},[o,_e,te,a,O]),Z.useEffect(()=>{if(!l)return;let e=W.current,t=e!==null&&te.assistantOutputSignature!==e;(a.current.streaming||t||u.length>0)&&(W.current=null,U.current=!1,M(!1))},[l,u.length,te.assistantOutputSignature,te.streaming,a,M]);let ve=an({mutationFn:async()=>{if(!e)throw Error(`Viewer context unavailable`);return await oi(Jb(`/api/abort`,{contextId:e,sessionState:a.current,fallbackSessionId:t}),{method:`POST`})},onSuccess:async()=>{await I.invalidateQueries({queryKey:vi.sessionTree(e,di(a.current)),refetchType:`active`})}}),be=Z.useCallback(async()=>{if(e)try{await ve.mutateAsync()}catch(e){X.error(e instanceof Error?e.message:`Failed to abort session`)}},[ve,e]),xe=an({mutationFn:async n=>{if(!e)throw Error(`Viewer context unavailable`);return await oi(Jb(`/api/pending-messages/reorder`,{contextId:e,sessionState:a.current,fallbackSessionId:t}),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({pendingMessages:n})})},onSuccess:async()=>{await I.invalidateQueries({queryKey:vi.sessionTree(e,di(a.current)),refetchType:`active`})}}),Se=Z.useCallback(async(t,n)=>{if(!e)return;let r=H.current,i=r.find(e=>e.pendingId===t);if(!i)return;if(!n.trim()&&i.images.length===0){X.error(`Enter a message or keep at least one image`);return}let a=r.map(e=>e.pendingId===t?{...e,text:n}:e);G(e=>e.map(e=>e.pendingId===t?{...e,text:n}:e));try{await xe.mutateAsync(a)}catch(e){G(()=>r),X.error(e instanceof Error?e.message:`Failed to update pending prompt`)}},[xe,H,G,e]),Ce=an({mutationFn:async()=>{if(!e)throw Error(`Viewer context unavailable`);return await oi(Jb(`/api/pending-messages/start`,{contextId:e,sessionState:a.current,fallbackSessionId:t}),{method:`POST`})},onSuccess:async()=>{await I.invalidateQueries({queryKey:vi.sessionTree(e,di(a.current)),refetchType:`active`})}}),we=Z.useCallback(async()=>{if(e&&H.current.length!==0){N(!0);try{let e=Rb(await Ce.mutateAsync());e&&G(()=>e)}catch(e){X.error(e instanceof Error?e.message:`Failed to start queue`)}finally{N(!1)}}},[H,N,Ce,G,e]),Te=an({mutationFn:async n=>{if(!e)throw Error(`Viewer context unavailable`);return await oi(Jb(`/api/pending-message/remove`,{contextId:e,sessionState:a.current,fallbackSessionId:t}),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({pendingId:n})})},onSuccess:async()=>{await I.invalidateQueries({queryKey:vi.sessionTree(e,di(a.current)),refetchType:`active`})}});return{abortSession:be,addDirectoryPath:oe,createSession:ce,editPendingMessage:Se,removePendingMessage:Z.useCallback(async t=>{if(!e)return;let n=H.current.findIndex(e=>e.pendingId===t),r=H.current[n];re(t);try{await Te.mutateAsync(t)}catch(e){if(Zb(e))return;r&&q(r,n),X.error(e instanceof Error?e.message:`Failed to remove pending prompt`)}},[re,Te,q,e]),reorderPending:Z.useCallback(async(t,n)=>{if(!e)return;let r=H.current,i=Qb(r,t,n);if(i){G(()=>i);try{await xe.mutateAsync(i)}catch(e){G(()=>r),X.error(e instanceof Error?e.message:`Failed to update pending prompts`)}}},[xe,H,G,e]),startPendingQueue:we,submitPrompt:he}}function ex(){let{setTheme:e,systemTheme:t}=Ei(),n=Z.useRef(void 0),r=n.current??ct();n.current=r;let[i,a]=Z.useState(r),[o,s]=Z.useState(()=>he(r)??Ie()),c=qe(i,o,t);return Z.useEffect(()=>{e(c),ye(ke,c);let t=Ne(c);t&&(document.documentElement.dataset.picoThemeMode=t)},[c,e]),{appliedTheme:c,colorMode:o,previewThemeFamily:(e,t)=>{let n=le(e),r=he(n);a(n),(t||r)&&s(Ae(t??r))},setColorMode:e=>{let t=Ae(e);s(t),ye(p,t)},setThemeFamily:e=>{let t=le(e),n=he(t);a(t),ye(v,t),n&&(s(n),ye(p,n))},systemTheme:t,themeFamily:i}}function tx(e,t){return e.sessionKey||t.sessionKey?e.sessionKey===t.sessionKey:e.sessionId||t.sessionId?e.sessionId===t.sessionId:e.sessionFile||t.sessionFile?e.sessionFile===t.sessionFile:e.cwd===t.cwd&&e.draft===t.draft}function nx(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1)if(e[n]!==t[n])return!1;return!0}function rx(e,t,n){let r=!1,i={...e};for(let[a,o]of Object.entries(e)){let e=!1,s=o.sessions.map(i=>i.path!==t||i.name===n&&i.title===n?i:(e=!0,r=!0,{...i,name:n,title:n}));e&&(i[a]={...o,sessions:s})}return r?i:e}function ix(e,t){if(t.size===0)return e;let n=!1,r={...e};for(let[i,a]of Object.entries(e)){let e=a.sessions.filter(e=>!e.path||!t.has(e.path)),o=a.sessions.length-e.length;o!==0&&(n=!0,r[i]={...a,totalCount:Math.max(0,a.totalCount-o),sessions:e})}return n?r:e}function ax(e){if(!e)return 0;let t=new Date(e).getTime();return Number.isFinite(t)?t:0}function ox(e,t){return ax(t.lastUserMessageAt||t.modified)-ax(e.lastUserMessageAt||e.modified)||ax(t.modified)-ax(e.modified)}function sx(e,t){return!!(e.path&&(e.path===t.previousPath||e.path===t.nextPath)||t.sessionId&&e.id===t.sessionId)}function cx(e,t){let n=t.previousPath.trim(),r=(t.nextPath||n).trim(),i=t.nextCwd.trim();if(!n||!r||!i)return e;let a=t.fallbackEntry.id||``,o=!1,s,c={...e};for(let[t,i]of Object.entries(e)){let e=0,l=i.sessions.filter(t=>sx(t,{previousPath:n,nextPath:r,sessionId:a})?(s??=t,e+=1,!1):!0);e!==0&&(o=!0,c[t]={...i,totalCount:Math.max(0,i.totalCount-e),sessions:l})}let l=c[i]||e[i];if(!l)return o?c:e;let u={...s||t.fallbackEntry,path:r,cwd:i};return l.sessions.some(e=>sx(e,{previousPath:r,nextPath:r,sessionId:u.id||a}))?o?c:e:(o=!0,c[i]={...l,totalCount:l.totalCount+1,sessions:[u,...l.sessions].sort(ox)},c)}function lx(e,t){if(!e||t.size===0)return[];let n=[];for(let[r,i]of Object.entries(e))i.sessions.some(e=>e.path&&t.has(e.path))&&n.push(r);return n}function ux(e){return Array.from(new Set(e.filter(Boolean)))}function dx(e,t,n){if(n.length===0)return e;let r=!1,i={...e};for(let a of n){let n=t?.[a];if(n){e[a]!==n&&(i[a]=n,r=!0);continue}Object.prototype.hasOwnProperty.call(e,a)&&(delete i[a],r=!0)}return r?i:e}function fx(e,t){if(!e?.directoryIndexes)return e;let n=t(e.directoryIndexes);return n===e.directoryIndexes?e:{...e,directoryIndexes:n}}function px(e,t){return{selectedSidebarSessionKeys:e.selectedSidebarSessionKeys.filter(e=>!t.has(e)),sidebarSessionSelectionAnchor:e.sidebarSessionSelectionAnchor&&t.has(e.sidebarSessionSelectionAnchor)?``:e.sidebarSessionSelectionAnchor}}function mx(e,t,n){if(!t||!n||t===n)return e;let r=!1,i=new Set,a=[];for(let o of e){let e=o===t?n:o;e!==o&&(r=!0),!(!e||i.has(e))&&(i.add(e),a.push(e))}return r?a:e}function hx({viewerContextId:e,activeSessionId:t,sessionStateRef:n,setSessionState:r,getDirectoryIndexDataByPath:i,setDirectoryIndexDataByPath:a,getSessionsEvent:o,setSessionsEvent:s,getSidebarSelection:c,optimisticallyClearActiveDeletedSession:l,setSelectedSidebarSessionKeys:u,setSidebarSessionSelectionAnchor:d,setPinnedSidebarSessionKeys:f,setCompactWorkingState:p,isCompactAbortRequested:m}){let h=ki(),g=Z.useRef(0),_=Z.useRef(0),v=Z.useRef(null);Z.useEffect(()=>()=>{v.current&&clearTimeout(v.current)},[]);let y=Z.useCallback(async i=>{if(!e)return;let[a,o]=i.split(`/`);if(!a||!o)return;let s=++g.current,c=n.current;try{let i=await oi(hi(`/api/model`,{contextId:e,sessionId:t,searchParams:{sessionKey:c.sessionKey}}),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({provider:a,modelId:o})});if(g.current!==s)return;let l=n.current;if(!tx(c,l))return;r({...l,model:i.model??l.model,thinkingLevel:i.thinkingLevel??l.thinkingLevel,availableThinkingLevels:i.availableThinkingLevels??l.availableThinkingLevels})}catch(e){X.error(e instanceof Error?e.message:`Failed to update model`)}},[t,e,n,r]),b=Z.useCallback(async i=>{if(!e)return;let a=_.current+1;_.current=a;let o=n.current,s=o.thinkingLevel,c=o.availableThinkingLevels,l={cwd:o.cwd,draft:o.draft,sessionFile:o.sessionFile,sessionId:o.sessionId,sessionKey:o.sessionKey};s!==i&&r({...o,thinkingLevel:i}),v.current&&clearTimeout(v.current),v.current=setTimeout(()=>{v.current=null,(async()=>{try{let o=await oi(hi(`/api/thinking`,{contextId:e,sessionId:t}),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({level:i})});if(_.current!==a)return;let s=n.current;if(!tx(l,s))return;let c=o.thinkingLevel||i,u=o.availableThinkingLevels.length>0?o.availableThinkingLevels:s.availableThinkingLevels;if(s.thinkingLevel===c&&s.availableThinkingLevels===u)return;r({...s,thinkingLevel:c,availableThinkingLevels:u})}catch(e){if(_.current!==a)return;let t=n.current;tx(l,t)&&t.thinkingLevel===i&&r({...t,thinkingLevel:s,availableThinkingLevels:c}),X.error(e instanceof Error?e.message:`Failed to update thinking level`)}})()},100)},[n,t,r,e]),x=Z.useCallback(async e=>{let t=n.current,r=t.availableThinkingLevels.length?t.availableThinkingLevels:[`off`],i=r.indexOf(t.thinkingLevel||`off`);await b(r[((i>=0?i:0)+e+r.length)%r.length]||r[0])},[n,b]),S=Z.useCallback(async n=>{if(e)try{await oi(hi(`/api/settings/hide-thinking`,{contextId:e,sessionId:t}),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({hide:n})}),X.info(n?`Thinking hidden`:`Thinking shown`)}catch(e){X.error(e instanceof Error?e.message:`Failed to update thinking visibility`)}},[t,e]),C=Z.useCallback(async()=>{await S(!n.current.hideThinkingBlock)},[n,S]),w=Z.useCallback(async()=>{if(e){p(!0);try{await oi(hi(`/api/slash-command`,{contextId:e,sessionId:t}),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({name:`compact`,args:``})})}catch(e){m()||X.error(e instanceof Error?e.message:`Failed to compact session`)}finally{p(!1)}}},[t,m,p,e]),T=Z.useCallback(async()=>{if(e)try{if((await oi(hi(`/api/session/clone`,{contextId:e,sessionId:t}),{method:`POST`,headers:{"content-type":`application/json`}})).cancelled)return;X.success(`Cloned session`)}catch(e){X.error(e instanceof Error?e.message:`Failed to clone session`)}},[t,e]),E=an({mutationFn:async({path:n,name:r})=>{if(!e)throw Error(`Viewer context unavailable`);return await oi(hi(`/api/session/rename`,{contextId:e,sessionId:t}),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({path:n,name:r})})},onSuccess:async()=>{await h.invalidateQueries({queryKey:[`pico`,`directory-sessions-index`,e],refetchType:`active`})}}),D=Z.useCallback(async(t,c)=>{if(!e||!t)return!1;let l=c.trim();if(!l)return X.error(`Name is required`),!1;let u=i(),d=o(),f=new Set([t]),p=lx(u,f),m=lx(d?.directoryIndexes,f),h=n.current.sessionName,g=n.current.sessionFile===t;return s(e=>fx(e,e=>rx(e,t,l))),a(e=>rx(e,t,l)),g&&n.current.sessionName!==l&&r(e=>e.sessionFile===t?{...e,sessionName:l}:e),(async()=>{try{let e=(await E.mutateAsync({path:t,name:l})).name||l;e!==l&&(s(n=>fx(n,n=>rx(n,t,e))),a(n=>rx(n,t,e)),r(n=>n.sessionFile===t&&n.sessionName===l?{...n,sessionName:e}:n)),X.success(`Renamed session`)}catch(e){s(e=>fx(e,e=>dx(e,d?.directoryIndexes,m))),a(e=>dx(e,u,p)),r(e=>e.sessionFile===t&&e.sessionName===l?{...e,sessionName:h}:e),X.error(e instanceof Error?e.message:`Failed to rename session`)}})(),!0},[i,o,E,n,a,r,s,e]),O=an({mutationFn:async({path:n,cwd:r})=>{if(!e)throw Error(`Viewer context unavailable`);return await oi(hi(`/api/session/move`,{contextId:e,sessionId:t}),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({path:n,cwd:r})})},onSuccess:async()=>{await h.invalidateQueries({queryKey:[`pico`,`directory-sessions-index`,e],refetchType:`active`})}}),k=Z.useCallback(async(t,c)=>{if(!e||!t.path)return!1;let l=c.trim();if(!l)return X.error(`Directory is required`),!1;if(t.cwd===l)return!1;let p=t.path,m=i(),h=o(),g=new Set([p]),_=ux([...lx(m,g),...m[l]?[l]:[]]),v=ux([...lx(h?.directoryIndexes,g),...h?.directoryIndexes?.[l]?[l]:[]]),y=n.current.cwd,b=n.current.sessionFile===p;return s(e=>fx(e,e=>cx(e,{previousPath:p,nextCwd:l,fallbackEntry:t}))),a(e=>cx(e,{previousPath:p,nextCwd:l,fallbackEntry:t})),b&&r(e=>e.sessionFile===p?{...e,cwd:l}:e),(async()=>{try{let e=await O.mutateAsync({path:p,cwd:l}),n=We({path:e.previousPath||p}),i=We({path:e.path,id:e.sessionId||t.id});s(n=>fx(n,n=>cx(n,{previousPath:e.previousPath||p,nextPath:e.path,nextCwd:e.cwd,fallbackEntry:{...t,id:e.sessionId||t.id}}))),a(n=>cx(n,{previousPath:e.previousPath||p,nextPath:e.path,nextCwd:e.cwd,fallbackEntry:{...t,id:e.sessionId||t.id}})),u(e=>mx(e,n,i)),d(e=>e===n?i:e),f(e=>{let t=mx(e,n,i);return t!==e&&ye(B,JSON.stringify(t)),t}),r(t=>t.sessionFile===e.previousPath||t.sessionFile===p?{...t,cwd:e.cwd,sessionFile:e.path}:t),X.success(`Moved session`)}catch(e){s(e=>fx(e,e=>dx(e,h?.directoryIndexes,v))),a(e=>dx(e,m,_)),r(e=>e.sessionFile===p&&e.cwd===l?{...e,cwd:y}:e),X.error(e instanceof Error?e.message:`Failed to move session`)}})(),!0},[i,o,O,n,a,f,u,r,s,d,e]),A=an({mutationFn:async n=>{if(!e)throw Error(`Viewer context unavailable`);await oi(hi(`/api/sessions/delete`,{contextId:e,sessionId:t}),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({paths:n})})},onSuccess:async()=>{await h.invalidateQueries({queryKey:[`pico`,`directory-sessions-index`,e],refetchType:`active`})}});return{cycleThinkingLevel:x,deleteSessions:Z.useCallback(t=>{if(!e||t.length===0)return!1;let r=[...t.filter(e=>e.path&&e.path!==n.current.sessionFile),...t.filter(e=>e.path&&e.path===n.current.sessionFile)],f=[],p=new Set;for(let e of r)!e.path||p.has(e.path)||(p.add(e.path),f.push(e.path));if(f.length===0)return!1;let m=new Set(r.flatMap(e=>{let t=We(e);return t?[t]:[]})),h=i(),g=o(),_=lx(h,p),v=lx(g?.directoryIndexes,p),y=c(),b=px(y,m);s(e=>fx(e,e=>ix(e,p))),a(e=>ix(e,p)),u(e=>e.filter(e=>!m.has(e))),d(e=>e&&m.has(e)?``:e);let x=n.current.sessionFile,S=x&&p.has(x)?l?.(x):void 0;return(async()=>{try{await A.mutateAsync(f),X.success(f.length===1?`Deleted session`:`Deleted ${f.length} sessions`)}catch(e){s(e=>fx(e,e=>dx(e,g?.directoryIndexes,v))),a(e=>dx(e,h,_)),S?.();let t=c();nx(t.selectedSidebarSessionKeys,b.selectedSidebarSessionKeys)&&t.sidebarSessionSelectionAnchor===b.sidebarSessionSelectionAnchor&&(u(y.selectedSidebarSessionKeys),d(y.sidebarSessionSelectionAnchor)),X.error(e instanceof Error?e.message:`Failed to delete session`)}})(),!0},[A,i,o,c,l,n,a,u,s,d,e]),moveSessionPath:k,renameSessionPath:D,runClone:T,runCompact:w,setModel:y,setThinkingBlocksHidden:S,setThinkingLevel:b,toggleHideThinking:C}}var gx=3e4,_x=`Compacting context...`,vx=`pico-events-last-id:`;function yx(e){return`${vx}${e}`}function bx(e){try{return window.sessionStorage.getItem(yx(e))}catch{return null}}function xx(e,t){try{window.sessionStorage.setItem(yx(e),t)}catch{}}function Sx(e){let t=typeof e==`string`?e.trim():``;return/^\d+$/.test(t)?t:void 0}function Cx(e){if(ui(e)&&Array.isArray(e.pendingUserMessages))return e.pendingUserMessages.map(e=>({pendingId:typeof e.pendingId==`string`?e.pendingId:``,text:typeof e.text==`string`?e.text:``,images:Array.isArray(e.images)?e.images.flatMap(e=>{let t=lt(e);return t?[t]:[]}):[],streamingBehavior:e.streamingBehavior===`steer`?`steer`:`followUp`}))}function wx(e){return e.refinementReason||e.heuristicReason||e.promptPreview||`The server could not generate a session name.`}function Tx(e=[],t=[]){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1)if(e[n]!==t[n])return!1;return!0}function Ex(e=[],t=[]){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1){let r=e[n],i=t[n];if(!r||!i||r.mimeType!==i.mimeType||r.data!==i.data||r.previewUrl!==i.previewUrl)return!1}return!0}function Dx(e=[],t=[]){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1){let r=e[n],i=t[n];if(!r||!i||r.pendingId!==i.pendingId||r.text!==i.text||r.streamingBehavior!==i.streamingBehavior||!Ex(r.images,i.images))return!1}return!0}function Ox(e=[],t=[]){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1){let r=e[n],i=t[n];if(!r||!i||r.path!==i.path||r.totalCount!==i.totalCount||r.revision!==i.revision)return!1}return!0}function kx(e=[],t=[]){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1){let r=e[n],i=t[n];if(!r||!i||r.path!==i.path||r.id!==i.id||r.cwd!==i.cwd||r.name!==i.name||r.title!==i.title||r.modified!==i.modified||r.lastUserMessageAt!==i.lastUserMessageAt||r.lastMessageAt!==i.lastMessageAt||r.lastMessagePreview!==i.lastMessagePreview||r.messageCount!==i.messageCount||!Ve(r.contextUsage,i.contextUsage)||!!r.streaming!=!!i.streaming||!!r.unread!=!!i.unread||!!r.optimistic!=!!i.optimistic)return!1}return!0}function Ax(e,t){let n=Object.entries(e||{}),r=Object.entries(t||{});if(n.length!==r.length)return!1;for(let[e,r]of n){let n=t?.[e];if(!r||!n||r.directory!==n.directory||r.totalCount!==n.totalCount||r.revision!==n.revision||!kx(r.sessions,n.sessions))return!1}return!0}function jx(e,t){return e===t?!0:!e||!t?!1:e.activeSessionId===t.activeSessionId&&e.activeSessionKey===t.activeSessionKey&&e.activeSessionPath===t.activeSessionPath&&Tx(e.directories||[],t.directories||[])&&Ox(e.directoryStates||[],t.directoryStates||[])&&Ax(e.directoryIndexes,t.directoryIndexes)}function Mx(e,t){switch(e.type){case`text`:return e.text.trim()?`text:${e.text}`:``;case`compaction`:return`compaction:${e.tokensBefore}:${e.estimatedTokensAfter??``}:${e.summary}`;case`thinking`:return t.hideThinking?``:`thinking:${e.summaryLabel||``}:${e.text}`;case`tool`:return t.hideToolBlocks?``:`tool:${e.callId||``}:${e.name||``}:${JSON.stringify(e.args??null)}:${e.output}:${JSON.stringify(e.details??null)}:${e.isError?`1`:`0`}:${e.running?`1`:`0`}`;default:return``}}function Nx(e){return e.renderKey||e.itemKey||``}function Px(e,t){let n=[];for(let r of e){let e=Nx(r);if(r.kind===`user`){n.push(`user:${e}:${r.text}:${r.queued?`1`:`0`}:${r.streamingBehavior||``}:${r.images.map(e=>`${e.mimeType}:${e.data}`).join(`,`)}`);continue}let i=r.blocks.flatMap(e=>{let n=Mx(e,t);return n?[n]:[]}),a=[r.done===!1?`0`:`1`,r.model?.provider||``,r.model?.id||``].join(`:`);if(i.length===0){(r.streaming||r.done===!1||a!==`1::`)&&n.push(`assistant:${e}:${r.streaming?`1`:`0`}:${a}`);continue}n.push(`assistant:${e}:${r.streaming?`1`:`0`}:${a}:${i.join(`|`)}`)}return n.join(`
23
+ `)}function Fx(e,t,n){return e===t?!0:Px(e,n)===Px(t,n)}function Ix(e,t){return e.connected===t.connected&&e.replaying===t.replaying&&e.streaming===t.streaming&&e.compacting===t.compacting&&e.draft===t.draft&&e.historyOffset===t.historyOffset&&e.historyTotalCount===t.historyTotalCount&&e.sessionId===t.sessionId&&e.sessionKey===t.sessionKey&&e.sessionName===t.sessionName&&e.firstMessage===t.firstMessage&&e.sessionFile===t.sessionFile&&e.cwd===t.cwd&&e.modified===t.modified&&e.model===t.model&&e.thinkingLevel===t.thinkingLevel&&e.availableThinkingLevels===t.availableThinkingLevels&&e.availableModels===t.availableModels&&e.availableSkills===t.availableSkills&&e.hideThinkingBlock===t.hideThinkingBlock&&e.uiRequest===t.uiRequest}function Lx(e,t){return e.statuses===t.statuses&&e.title===t.title&&e.editorText===t.editorText}function Rx(e,t){return e===t?!1:!Ix(e,t)||!Lx(e.uiState,t.uiState)||e.items.length===0!=(t.items.length===0)}function zx(e){return ee({cwd:typeof e.cwd==`string`?e.cwd:void 0,sessionFile:typeof e.sessionFile==`string`?e.sessionFile:void 0,sessionId:typeof e.sessionId==`string`?e.sessionId:void 0})}function Bx(e,t){return!t||e.draft!==!0?!1:g(zx(e),t)}function Vx(e,t){return e.draft===!0?g(zx(e),ee(t)):!1}function Hx(e){let t=e.previousState.sessionKey||``,n=typeof e.payload.sessionKey==`string`?e.payload.sessionKey:``;return!(!t.startsWith(`optimistic:`)||!n||n===t||Bx(e.payload,e.ownerKey)||Vx(e.payload,e.previousState))}function Ux(e){let t=(0,Q.c)(85),{viewerContextId:n,sessionId:r,draftSessionLoadingOwnerKey:i,bootstrapSidebarDirectories:a,hideToolBlocksRef:o,sessionStore:s,sessionStateRef:c,composerTextRef:l,composerSkillRef:u,replaceComposerDraftRef:d,handleSelectSessionRef:f,pendingRouteSessionIdRef:p,pendingRouteSessionPathRef:m,setSessionState:h,setConversationItems:_,setHiddenThinkingPreview:v,setWorkingState:y,setCompactRunningState:b,setComposerContextUsage:x,setComposerStreaming:S,setSessionsEvent:C,setSessionDoneEvents:w,applySidebarSessionStatusRef:T,setComposerImages:E,setPendingMessages:D,pendingUiRequestHandlerRef:O,lastSyncedEditorTextRef:k}=e,A=ki(),j=Z.useRef(r),M=Z.useRef(r),N=Z.useRef(i),P=Z.useRef(null),F=Z.useRef(void 0),I=Z.useRef(!1),[L,R]=Z.useState(!1),z=Z.useRef(null),B=Z.useRef(!1),[V,H]=Z.useState(0),U,W;t[0]===r?(U=t[1],W=t[2]):(U=()=>{M.current=r},W=[r],t[0]=r,t[1]=U,t[2]=W),Z.useEffect(U,W);let te,ne;t[3]===i?(te=t[4],ne=t[5]):(te=()=>{N.current=i},ne=[i],t[3]=i,t[4]=te,t[5]=ne),Z.useEffect(te,ne);let G,K;t[6]===n?(G=t[7],K=t[8]):(G=()=>{F.current=Sx(bx(n))},K=[n],t[6]=n,t[7]=G,t[8]=K),Z.useEffect(G,K);let re,q;t[9]===r?(re=t[10],q=t[11]):(re=()=>{P.current||(j.current=r)},q=[r],t[9]=r,t[10]=re,t[11]=q),Z.useEffect(re,q);let J=ka(s,Yx),ae=Z.useRef(0),oe=Z.useRef(Date.now()*1e3),se=Z.useRef(void 0),ce=ka(s,Jx),le,ue;t[12]!==p||t[13]!==m||t[14]!==r||t[15]!==J?(ue=()=>{let e=se.current!==r;if(se.current=r,!r){p.current=void 0,m.current=void 0;return}if(r===J){p.current===r&&(p.current=void 0,m.current=void 0);return}e&&(p.current!==r&&(m.current=void 0),p.current=r)},le=[p,m,r,J],t[12]=p,t[13]=m,t[14]=r,t[15]=J,t[16]=le,t[17]=ue):(le=t[16],ue=t[17]),Z.useEffect(ue,le);let fe,pe;t[18]!==A||t[19]!==n?(fe=()=>{if(!n)return;let e=()=>{z.current=Date.now(),B.current=!0},t=e=>{let t=e===void 0?!1:e;if(document.visibilityState!==`visible`)return;let n=z.current,r=n?Date.now()-n:0,i=t||B.current&&r>=gx;if(z.current=null,B.current=!1,!i)return;let a=P.current;(t||!a||a.readyState!==EventSource.OPEN)&&(j.current=M.current,H(qx)),A.invalidateQueries({refetchType:`active`}).catch(Kx)},r=()=>{if(document.visibilityState===`hidden`){e();return}t()},i=()=>{t()},a=e=>{t(e.persisted)};return document.visibilityState===`hidden`&&e(),window.addEventListener(`blur`,e),window.addEventListener(`focus`,i),window.addEventListener(`pagehide`,e),window.addEventListener(`pageshow`,a),document.addEventListener(`visibilitychange`,r),()=>{window.removeEventListener(`blur`,e),window.removeEventListener(`focus`,i),window.removeEventListener(`pagehide`,e),window.removeEventListener(`pageshow`,a),document.removeEventListener(`visibilitychange`,r)}},pe=[A,n],t[18]=A,t[19]=n,t[20]=fe,t[21]=pe):(fe=t[20],pe=t[21]),Z.useEffect(fe,pe);let me;t[22]!==c||t[23]!==_||t[24]!==h?(me=e=>{if(P.current!==e)return;let t=c.current;if(t.connected)return;let n={...t,connected:!0};c.current=n,_(n.items),h(n)},t[22]=c,t[23]=_,t[24]=h,t[25]=me):me=t[25];let he=me,ge;t[26]!==c||t[27]!==_||t[28]!==h?(ge=e=>{if(P.current!==e)return;let t=c.current;if(!t.connected)return;let n={...t,connected:!1};c.current=n,_(n.items),h(n)},t[26]=c,t[27]=_,t[28]=h,t[29]=ge):ge=t[29];let _e=ge,ve;t[30]!==T||t[31]!==u||t[32]!==l||t[33]!==f||t[34]!==o||t[35]!==k||t[36]!==p||t[37]!==O||t[38]!==d||t[39]!==c||t[40]!==b||t[41]!==x||t[42]!==E||t[43]!==S||t[44]!==_||t[45]!==v||t[46]!==D||t[47]!==w||t[48]!==h||t[49]!==C||t[50]!==y||t[51]!==n?(ve=(e,t,r)=>{if(P.current!==e)return;let i=Sx(r.lastEventId);i&&(F.current=i,xx(n,i));let a=JSON.parse(r.data);if(li(a)){let e=c.current;if(e.sessionId&&e.sessionId!==a.sessionId)return;let t=Pe(e.items,a);if(t===e.items)return;let n={...e,connected:!0,replaying:!1,streaming:!0,items:t,hiddenThinkingPreview:e.hideThinkingBlock?Qr(t):void 0};fa(()=>{c.current=n,_(t),v(n.hiddenThinkingPreview||``,{preserveExisting:!!(e.streaming&&!n.hiddenThinkingPreview)}),e.streaming||(S(!0),y({label:`Working…`,cancelable:!1})),h(n)});return}if(ui(a)){let e=a.activationRevision;if(typeof e==`number`&&e<ae.current)return;typeof e==`number`&&(ae.current=e),I.current||(I.current=!0,R(!0));let t=c.current;if(Hx({ownerKey:N.current,payload:a,previousState:t}))return;let n=l.current;de(t,hf({text:n,skillName:u.current}));let r=t.uiState.editorText||``,i=gi(t,a),s=ee(i)!==ee(t),m=M.current,w=N.current,O=i.draft&&!i.sessionKey?.startsWith(`optimistic:`),A=t.draft&&t.sessionKey?.startsWith(`optimistic:`),j=g(ee(i),w),P=!!(m&&!p.current&&O&&(j||A)),F=!s&&n!==r,L=F?n:ie(i)??i.uiState.editorText??``;fa(()=>{c.current=i,v(i.hiddenThinkingPreview||``,{preserveExisting:!!(t.streaming&&i.streaming&&!i.hiddenThinkingPreview)}),t.contextUsage!==i.contextUsage&&x(i.contextUsage);let e=t.sessionKey!==i.sessionKey||t.sessionId!==i.sessionId||t.sessionFile!==i.sessionFile;t.streaming!==i.streaming&&S(i.streaming),(e||t.compacting!==i.compacting)&&b(i.compacting),(e||t.streaming||i.streaming||t.compacting||i.compacting)&&y(i.compacting?{label:_x,cancelable:!0}:i.streaming?{label:i.uiState.workingMessage||`Working…`}:null),(e||!Fx(t.items,i.items,{hideThinking:i.hideThinkingBlock,hideToolBlocks:o.current}))&&_(i.items),Rx(t,i)&&h(i),(t.sessionKey!==i.sessionKey||t.sessionId!==i.sessionId||t.sessionFile!==i.sessionFile||t.streaming!==i.streaming)&&T.current({type:`session_status`,sessionKey:i.sessionKey,sessionId:i.sessionId,sessionPath:i.sessionFile,streaming:i.streaming,unread:!1}),s&&C(e=>{if(!e)return e;let t={...e,activeSessionId:i.sessionId,activeSessionKey:i.sessionKey,activeSessionPath:i.sessionFile};return jx(e,t)?e:t}),s&&E(Gx),P&&f.current(void 0,{replace:!0}),F||d.current(L,i),k.current=i.uiState.editorText||``;let n=Cx(a);n&&D(e=>Dx(e,n)?e:n)});return}if(mi(a)){C(e=>jx(e,a)?e:a);return}if(ri(a)){T.current(a);return}if(ni(a)){w(e=>e.some(e=>e.id===a.id)?e:[...e,a]);return}if(bi(a)){let e=a.cwd.trim();e&&t.addItem({cwd:e,scopes:new Set(a.scopes??[`status`,`files`,`refs`])});return}if(a.type===`auto_session_naming_error`){console.warn(`[pico] auto session naming failed`,a),X.warning(`Could not name session`,{description:wx(a)});return}if(a.type===`request_error`){X.error(a.error||`Request failed`);return}if(a.type===`extension_error`){X.error(a.error||`Extension error`);return}if(a.type===`extension_ui_request`){if(a.method===`notify`){let e=a.message||`Notification`;a.notifyType===`success`?X.success(e):a.notifyType===`warning`?X.warning(e):a.notifyType===`error`?X.error(e):X.info(e);return}ai(a.method)&&O.current(a)}},t[30]=T,t[31]=u,t[32]=l,t[33]=f,t[34]=o,t[35]=k,t[36]=p,t[37]=O,t[38]=d,t[39]=c,t[40]=b,t[41]=x,t[42]=E,t[43]=S,t[44]=_,t[45]=v,t[46]=D,t[47]=w,t[48]=h,t[49]=C,t[50]=y,t[51]=n,t[52]=ve):ve=t[52];let ye=ve,be;t[53]!==a||t[54]!==_e||t[55]!==ye||t[56]!==he||t[57]!==A||t[58]!==n?(be=()=>{if(!n)return;I.current=!1,R(!1),ae.current=0;let e=new uo(e=>{let t=new Map;for(let n of e){let e=t.get(n.cwd)??new Set;for(let t of n.scopes)e.add(t);t.set(n.cwd,e)}let r=[];for(let[e,i]of t)i.has(`status`)&&r.push(A.invalidateQueries({queryKey:vi.gitStatus(n,e),exact:!0,refetchType:`active`})),i.has(`files`)&&r.push(A.invalidateQueries({queryKey:vi.gitFiles(n,e),exact:!0,refetchType:`active`}),A.invalidateQueries({queryKey:vi.projectFileTree(n,e),exact:!0,refetchType:`active`}),A.invalidateQueries({queryKey:vi.gitFileReviews(n,e),exact:!1,refetchType:`active`})),i.has(`refs`)&&r.push(A.invalidateQueries({queryKey:vi.gitBranches(n,e),exact:!0,refetchType:`active`}),A.invalidateQueries({queryKey:vi.gitCommits(n,e),exact:!1,refetchType:`active`}));Promise.all(r).catch(Wx)},{key:`pico.git.invalidations`,wait:100}),t=new EventSource(hi(`/events`,{contextId:n,sessionId:j.current,searchParams:{lastEventId:F.current,sidebarDirectory:a}}));return P.current=t,t.onopen=()=>{he(t)},t.onerror=()=>{_e(t)},t.onmessage=n=>{ye(t,e,n)},()=>{P.current===t&&(P.current=null),t.close(),e.flush(),e.cancel(),e.clear()}},t[53]=a,t[54]=_e,t[55]=ye,t[56]=he,t[57]=A,t[58]=n,t[59]=be):be=t[59];let xe;t[60]!==a||t[61]!==V||t[62]!==_e||t[63]!==ye||t[64]!==he||t[65]!==A||t[66]!==n?(xe=[a,V,_e,ye,he,A,n],t[60]=a,t[61]=V,t[62]=_e,t[63]=ye,t[64]=he,t[65]=A,t[66]=n,t[67]=xe):xe=t[67],Z.useEffect(be,xe);let Se,Ce;t[68]!==i||t[69]!==L||t[70]!==p||t[71]!==m||t[72]!==r||t[73]!==J||t[74]!==n?(Se=()=>{if(!n||!r||i||!L||r===J||p.current!==r)return;let e=new AbortController,t=m.current,a=Math.max(oe.current+1,Date.now()*1e3);return oe.current=a,oi(hi(`/api/session/select`,{contextId:n,sessionId:r,searchParams:{selectionNonce:a,sessionPath:t}}),{method:`POST`,signal:e.signal}).catch(t=>{e.signal.aborted||X.error(t instanceof Error?t.message:`Failed to select session`)}),()=>{e.abort()}},Ce=[i,L,p,m,J,n,r],t[68]=i,t[69]=L,t[70]=p,t[71]=m,t[72]=r,t[73]=J,t[74]=n,t[75]=Se,t[76]=Ce):(Se=t[75],Ce=t[76]),Z.useEffect(Se,Ce);let we,Te;t[77]!==f||t[78]!==p||t[79]!==m||t[80]!==r||t[81]!==ce||t[82]!==J?(we=()=>{if(ce||!J)return;let e=p.current;if(e){J===e&&(p.current=void 0,m.current=void 0);return}J!==r&&f.current(J,{replace:!0})},Te=[f,p,m,r,ce,J],t[77]=f,t[78]=p,t[79]=m,t[80]=r,t[81]=ce,t[82]=J,t[83]=we,t[84]=Te):(we=t[83],Te=t[84]),Z.useEffect(we,Te)}function Wx(){}function Gx(e){return e.length===0?e:[]}function Kx(){}function qx(e){return e+1}function Jx(e){return e.draft}function Yx(e){return e.sessionId}var Xx=500;function Zx(e){return e instanceof HTMLElement&&e.closest(`[data-terminal-panel="true"]`)!==null}function Qx(e){if(!(e instanceof HTMLElement))return!1;let t=e.tagName.toLowerCase();return e.isContentEditable||Zx(e)||t===`input`||t===`textarea`||e.closest(`[contenteditable="true"]`)!==null}function $x(e){return e instanceof HTMLTextAreaElement&&e.name===`prompt`}function eS(e){if(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement)return e.selectionStart!==e.selectionEnd;if(e instanceof HTMLElement){let e=window.getSelection();return!!(e&&String(e).trim())}return!1}function tS(e){let t=(0,Q.c)(35),{addDirectoryOpenRef:n,commandPaletteOpenRef:r,compactRunningRef:i,deleteOpenRef:a,forkOpenRef:o,gitCommitOpenRef:s,moveSessionDirectoryOpenRef:c,pendingUiRequestOpenRef:l,renameOpenRef:u,sessionSearchInputRef:d,sessionsOpenRef:f,settingsOpenRef:p,shortcutActionsRef:m,shortcutStateRef:h,treeOpenRef:g}=e,_=Z.useRef(0),v,y,b,x,S,C,w;if(t[0]!==n||t[1]!==r||t[2]!==i||t[3]!==a||t[4]!==o||t[5]!==s||t[6]!==c||t[7]!==l||t[8]!==u||t[9]!==d||t[10]!==f||t[11]!==p||t[12]!==m||t[13]!==h||t[14]!==g){let e=e=>{let t=h.current,i=r.current,m=n.current||u.current||a.current||o.current||s.current||c.current||g.current||f.current||p.current||l.current,_=document.activeElement,v=_ instanceof HTMLElement&&_.closest(`[data-conversation-viewport="true"]`)!==null,y=_ instanceof HTMLElement?_.dataset.sessionKey?.trim()??``:``,b=y?t.sidebarSessionEntriesByKey.get(y):void 0,x=e.target instanceof HTMLInputElement&&e.target===d.current;return{...t,activeElement:_,activeElementIsConversationViewport:v,blockingModalOpen:m,commandPaletteOpen:i,focusedSidebarSession:b,modalOpen:m||i,targetIsSessionSearch:x}},T=e=>{e&&m.current.closeCommandPalette()},E=t=>{let n=e(t);if(t.repeat||n.modalOpen||t.defaultPrevented||Zx(t.target))return;let r=Date.now();if(r-_.current<=Xx){_.current=0,t.preventDefault(),m.current.openTreeDialog();return}if(_.current=r,i.current){t.preventDefault(),m.current.abortCompact();return}n.sessionIsStreaming&&!Qx(t.target)&&(t.preventDefault(),m.current.abortSession())},D=t=>{let n=e(t);if(n.modalOpen||Qx(t.target)&&!n.targetIsSessionSearch||n.activeElementIsConversationViewport)return;let r=Array.from(document.querySelectorAll(`[data-sidebar-session-item]`)),i=n.activeElement instanceof HTMLElement?n.activeElement.closest(`[data-sidebar-session-item]`):null;if(r.length===0)return;let a=i?r.findIndex(e=>e===i):-1,o=t.key===`Home`?0:t.key===`End`?r.length-1:a>=0?Math.max(0,Math.min(r.length-1,a+(t.key===`ArrowDown`?1:-1))):t.key===`ArrowUp`?r.length-1:0;t.preventDefault(),r[o]?.focus()},O=t=>{let n=e(t);n.modalOpen||Qx(t.target)&&!n.targetIsSessionSearch||n.selectedSidebarSessions.length<=1||(t.preventDefault(),m.current.openDeleteDialog(n.selectedSidebarSessions))},k=t=>{let n=e(t);n.blockingModalOpen||t.defaultPrevented||Zx(t.target)||(t.preventDefault(),T(n.commandPaletteOpen),m.current.focusPrompt())},A=t=>{let n=e(t);if(!(n.currentTab!==`session`||n.modalOpen||t.defaultPrevented||Qx(t.target)&&!$x(t.target))){if(t.preventDefault(),t.key===`ArrowLeft`){m.current.jumpToPreviousMessage();return}if(t.key===`ArrowRight`){m.current.jumpToNextMessage();return}if(t.key===`ArrowUp`){m.current.scrollConversationToTop();return}m.current.scrollConversationToBottom()}};v=t=>{let n=t.altKey&&t.code.startsWith(`Key`)?t.code.slice(3).toLowerCase():t.key.toLowerCase(),r=e(t);if(!(r.blockingModalOpen||t.defaultPrevented)&&!(Zx(t.target)&&!r.commandPaletteOpen&&n!=="`")){if(n===`\\`){t.preventDefault(),T(r.commandPaletteOpen),m.current.toggleGitPanel();return}if(n==="`"){t.preventDefault(),T(r.commandPaletteOpen),m.current.toggleTerminalPanel();return}if(n===`k`){t.preventDefault(),m.current.openCommandPalette();return}if(n===`p`){if(t.preventDefault(),T(r.commandPaletteOpen),t.altKey){m.current.pullGitChanges();return}if(t.shiftKey){m.current.forcePushGitChanges();return}m.current.pushGitChanges();return}if(n===`n`){t.preventDefault(),T(r.commandPaletteOpen),m.current.createSession();return}if(n===`s`){t.preventDefault(),T(r.commandPaletteOpen),m.current.openSessionsDialog();return}if(n===`e`){if(!r.sessionHasFile)return;t.preventDefault(),T(r.commandPaletteOpen),m.current.openRenameDialog();return}if(n===`f`){t.preventDefault(),T(r.commandPaletteOpen),m.current.openForkDialog();return}if(n===`d`){t.preventDefault(),T(r.commandPaletteOpen),m.current.openAddDirectoryDialog();return}if(n===`,`){t.preventDefault(),T(r.commandPaletteOpen),m.current.openSettingsDialog();return}if(n===`m`){if(!r.sessionHasAvailableModels&&!r.commandPaletteOpen)return;t.preventDefault(),T(r.commandPaletteOpen),m.current.focusModelSelector();return}if(n===`t`){t.preventDefault(),T(r.commandPaletteOpen),m.current.toggleHideThinking();return}if(n===`r`){t.preventDefault(),T(r.commandPaletteOpen),m.current.cycleThinkingLevel(t.shiftKey?-1:1);return}if(n===`o`){t.preventDefault(),T(r.commandPaletteOpen),m.current.toggleHideToolBlocks();return}if(n===`c`){if(!r.commandPaletteOpen&&eS(t.target))return;t.preventDefault(),T(r.commandPaletteOpen),m.current.openCommitDialog();return}if(n===`x`){if(Qx(t.target)&&!$x(t.target)||!r.sessionHasFile)return;t.preventDefault(),T(r.commandPaletteOpen),m.current.openDeleteDialogForCurrentSession()}}},y={hotkey:`Escape`,callback:E,options:{meta:{name:`Abort active session`,description:`Abort compaction or the streaming assistant response.`}}},b=[{key:`ArrowDown`},{key:`ArrowUp`},{key:`Home`},{key:`End`},{key:`ArrowDown`,shift:!0},{key:`ArrowUp`,shift:!0},{key:`Home`,shift:!0},{key:`End`,shift:!0}].map(e=>({hotkey:e,callback:D,options:{meta:{name:`Move sidebar focus`,description:`Move keyboard focus through sidebar sessions.`}}})),x={hotkey:`Backspace`,callback:O,options:{meta:{name:`Delete selected sidebar sessions`,description:`Open the delete dialog for multiple selected sidebar sessions.`}}},S={hotkey:{key:`Enter`,ctrl:!0},callback:k,options:{meta:{name:`Focus prompt`,description:`Focus the prompt composer.`}}},C=[`ArrowLeft`,`ArrowRight`,`ArrowUp`,`ArrowDown`].map(e=>({hotkey:{key:e,ctrl:!0},callback:A,options:{meta:{name:`Navigate conversation`,description:`Jump between messages or to conversation boundaries.`}}})),w=[{key:`\\`},{key:"`"},{key:`K`},{key:`P`},{key:`P`,shift:!0},{key:`N`},{key:`S`},{key:`E`},{key:`F`},{key:`D`},{key:`,`},{key:`M`},{key:`T`},{key:`R`},{key:`R`,shift:!0},{key:`V`},{key:`O`},{key:`C`},{key:`X`}].map(e=>({hotkey:{...e,ctrl:!0},callback:v,options:{meta:{name:`App shell shortcut`,description:`Run a Pico app shell command.`}}})),t[0]=n,t[1]=r,t[2]=i,t[3]=a,t[4]=o,t[5]=s,t[6]=c,t[7]=l,t[8]=u,t[9]=d,t[10]=f,t[11]=p,t[12]=m,t[13]=h,t[14]=g,t[15]=v,t[16]=y,t[17]=b,t[18]=x,t[19]=S,t[20]=C,t[21]=w}else v=t[15],y=t[16],b=t[17],x=t[18],S=t[19],C=t[20],w=t[21];let T;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(T={key:`P`,alt:!0},t[22]=T):T=t[22];let E;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(E={meta:{name:`App shell shortcut`,description:`Run a Pico app shell command.`}},t[23]=E):E=t[23];let D;t[24]===v?D=t[25]:(D={hotkey:T,callback:v,options:E},t[24]=v,t[25]=D);let O;t[26]!==y||t[27]!==b||t[28]!==x||t[29]!==S||t[30]!==C||t[31]!==w||t[32]!==D?(O=[y,...b,x,S,...C,...w,D],t[26]=y,t[27]=b,t[28]=x,t[29]=S,t[30]=C,t[31]=w,t[32]=D,t[33]=O):O=t[33];let k=O,A;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(A={conflictBehavior:`allow`,ignoreInputs:!1,preventDefault:!1,stopPropagation:!1},t[34]=A):A=t[34],Ea(k,A)}var nS=6;function rS(e){return iS(e)}function iS({viewerContextId:e,sessionId:r,onSelectSession:a,sidebar:o,sidebarStore:c,sessionSearchInputRef:l,ref:u}){let d=ki(),f=Z.useRef(null);f.current||=Ze();let p=Z.useRef(null);p.current||=hl(f.current);let m=p.current,h=Z.useRef(m.state),g=Z.useRef(null);g.current||=hl({currentTab:`session`,gitPanelOpen:!1,terminalPanelOpen:!1,initialLoadingSessionId:r||null,loadingSessionId:null},Ni);let _=g.current,v=Z.useRef(null);v.current||=hl(p_());let y=v.current,b=Z.useCallback(e=>{vl(_,`currentTab`,e)},[_]),x=Z.useCallback(e=>{let t=gl(_.state.gitPanelOpen,e);vl(_,`gitPanelOpen`,t),ye(M,t?`1`:`0`)},[_]),S=Z.useCallback(e=>{let t=gl(_.state.terminalPanelOpen,e);vl(_,`terminalPanelOpen`,t),ye(N,t?`1`:`0`)},[_]),w=Z.useCallback(e=>{vl(_,`loadingSessionId`,e)},[_]),T=Z.useRef(r),E=Z.useRef(null);E.current||=hl({text:``,syncNonce:0});let O=E.current,k=Z.useRef(null);k.current||=hl([]);let A=k.current,j=Z.useRef([]),P=Z.useRef([]),[I,L]=Z.useState([]),R=Z.useRef(null);R.current||=hl({autoScrollEnabled:!0,centerMessages:!1,hideToolBlocks:!1},Ni);let z=R.current,V=Z.useRef(z.state),H=Z.useRef(z.state.hideToolBlocks),U=Z.useCallback(e=>{let t=z.state,n=gl(t.hideToolBlocks,e);if(n===t.hideToolBlocks)return;let r={...t,hideToolBlocks:n};V.current=r,H.current=r.hideToolBlocks,_l(z,r)},[z]),te=Z.useCallback(e=>{let t=z.state,n=gl(t.centerMessages,e);if(n===t.centerMessages)return;let r={...t,centerMessages:n};V.current=r,_l(z,r)},[z]),ne=Z.useCallback(e=>{let t=z.state,n=gl(t.autoScrollEnabled,e);if(n===t.autoScrollEnabled)return;let r={...t,autoScrollEnabled:n};V.current=r,_l(z,r)},[z]),K=Z.useRef(null);K.current||=hl(!1);let q=K.current,ie=Z.useRef(null);ie.current||=hl(null);let J=ie.current,oe=Z.useRef(null);oe.current||=hl([]);let ce=oe.current,le=Z.useRef(null);le.current||=hl(!1);let ue=le.current,pe=Z.useRef(null);pe.current||=hl([]);let me=pe.current,he=Z.useRef(null);he.current||=hl({desktopNotificationPermission:`unsupported`,sessionDoneDesktopNotificationsEnabled:!0,sessionDoneEvents:[],sessionDoneSoundEnabled:!0},Ni);let ge=he.current,_e=Z.useCallback(e=>{vl(ge,`sessionDoneEvents`,e)},[ge]),ve=Z.useCallback(e=>{vl(ge,`sessionDoneSoundEnabled`,e)},[ge]),be=Z.useCallback(e=>{vl(ge,`sessionDoneDesktopNotificationsEnabled`,e)},[ge]),xe=Z.useCallback(e=>{vl(ge,`desktopNotificationPermission`,e)},[ge]),Se=Z.useRef(null);Se.current||=hl({draftSessionLoadingOwnerKey:null,storedDraftDirectory:``},Ni);let Ce=Se.current,we=Z.useCallback(e=>{vl(Ce,`draftSessionLoadingOwnerKey`,e)},[Ce]),Te=Z.useCallback(e=>{vl(Ce,`storedDraftDirectory`,e)},[Ce]),Ee=Z.useRef(null);Ee.current||=hl([],Mi);let De=Ee.current,Oe=Z.useCallback(e=>{let t=De.state,n=gl(t,e);n!==t&&_l(De,n)},[De]),{isMobile:ke,openMobile:Ae,openMobileSettled:je,setOpenMobile:Me}=zo(),Ne=Z.useRef(null),Pe=Z.useRef(null),Fe=Z.useRef(null);Fe.current||=hl(mb(e),pb);let Ie=Fe.current,Re=Z.useCallback(e=>{let t=P.current,n=gl(t,e);if(n===t)return;P.current=n,L(n);let r=Ie.state;_l(Ie,{...r,composerDiffLineComments:r.disabled?[]:n})},[Ie]),ze=Z.useRef(null);ze.current||=hl(void 0);let Be=ze.current,Ve=Z.useRef(null);Ve.current||=new mo(e=>{_l(Be,e)},{key:`pico.composer.context-usage`,wait:250,leading:!0,trailing:!0});let He=Ve.current;Z.useEffect(()=>()=>{He.flush(),He.cancel()},[He]);let Ue=Z.useCallback(e=>{let t=O.state,n=gl(t,e);n!==t&&fa(()=>{_l(O,n);let e=Ie.state;_l(Ie,{...e,composerSkill:e.disabled?void 0:n.skillName,composerSyncNonce:n.syncNonce,composerText:e.disabled?``:n.text})})},[O,Ie]),Ge=Z.useCallback(e=>{let t=A.state,n=gl(t,e);n!==t&&(j.current=n,fa(()=>{_l(A,n);let e=Ie.state;_l(Ie,{...e,composerImages:e.disabled?[]:n})}))},[A,Ie]),Ke=Z.useCallback(e=>{He.maybeExecute(e)},[He]),qe=Z.useCallback(e=>{let t=Ie.state;_l(Ie,{...t,isStreaming:t.disabled?!1:e})},[Ie]),Ye=Z.useRef(null),Xe=Z.useRef(!1),Qe=Z.useRef(null),$e=Z.useRef(!1),et=Z.useRef(null),tt=Z.useRef(!1),nt=Z.useRef(null),it=Z.useRef(null),at=Z.useRef(!1),ot=Z.useRef(null),st=Z.useRef(!1),ct=Z.useRef(null),lt=Z.useRef(!1),ut=Z.useRef(null),dt=Z.useRef(!1),ft=Z.useRef(null),pt=Z.useRef(!1),mt=Z.useRef(null),ht=Z.useRef(!1),gt=Z.useRef(null),vt=Z.useRef(!1),bt=Z.useRef(null),xt=Z.useRef(!1),St=Z.useRef(null),Ct=Z.useRef(!1),wt=Z.useRef(null),Et=Z.useRef(!1),Dt=Z.useRef(null),Ot=Z.useRef(!1),[kt,jt]=Z.useState(!1),Mt=Z.useRef(``),Nt=Z.useCallback((e,t=r)=>{let n=e.sessionId||(e.sessionKey?void 0:t),i=e.draft?``:n?.trim()||``,a=e.draft?``:(e.sessionFile||e.sessionPath||``).trim(),o=e.draft?``:Ii({sessionFile:a,sessionId:i})||e.sessionKey?.trim()||``;c.setSidebarState(e=>e.activeSidebarSessionId===i&&e.activeSidebarSessionKey===o&&e.activeSidebarSessionPath===a?e:{activeSidebarSessionId:i,activeSidebarSessionKey:o,activeSidebarSessionPath:a})},[r,c]),Pt=Z.useCallback(e=>{let t=h.current,n=typeof e==`function`?e(t):e,r=m.state;Object.is(t,n)&&Object.is(r,n)||(h.current=n,_l(m,n),Nt(n))},[Nt,m]),Ft=Z.useRef(O.state.text),It=Z.useRef(O.state.skillName),Lt=Z.useRef(void 0),zt=Z.useRef(void 0),Bt=Z.useRef(e=>{});Bt.current=e=>{wt.current?.open(e)};let Vt=Z.useRef(new Set),Ht=Z.useRef(!1),Ut=Z.useRef(null);Ut.current||=fg(h.current.items);let Wt=Ut.current,Gt=Z.useCallback(async()=>{let t=h.current,n=t.historyOffset,r=t.sessionId?.trim();if(Ot.current||t.draft||!r||n<=0)return;let i=t.sessionKey;Ot.current=!0,jt(!0);try{let t=await oi(hi(`/api/session/history`,{contextId:e,sessionId:r,searchParams:{before:n,limit:50}})),a=h.current;if(a.sessionKey!==i||a.historyOffset!==n)return;let o={...a,items:[...t.items,...a.items],historyOffset:t.offset,historyTotalCount:t.totalCount};Wt.setItems(o.items),Pt(o)}catch(e){X.error(`Could not load earlier messages`,{description:e instanceof Error?e.message:String(e)})}finally{Ot.current=!1,jt(!1)}},[Wt,Pt,e]),Kt=Z.useRef(null);Kt.current||=hl(h.current.hiddenThinkingPreview||``);let qt=Kt.current,Jt=Z.useRef(null);Jt.current||=hl(null,xb);let Yt=Jt.current,Xt=Z.useRef(!1),Zt=Z.useRef(!1),Qt=Z.useCallback(e=>{Xt.current=e,e&&(Zt.current=!1)},[]),$t=Z.useCallback(e=>{let t=q.state,n=gl(t,e);n!==t&&fa(()=>{_l(q,n);let e=Ie.state;_l(Ie,{...e,awaitingFirstTurn:e.disabled?!1:n}),n&&!h.current.streaming?_l(Yt,{label:``}):!n&&Yt.state?.label===``&&_l(Yt,null)})},[q,Ie,Yt]),en=Z.useCallback(e=>{let t=ue.state,n=gl(t,e);n!==t&&fa(()=>{_l(ue,n);let e=Ie.state;_l(Ie,{...e,isSubmitting:e.disabled?!1:n})})},[Ie,ue]),tn=Z.useCallback(()=>{let e=ce.state.map((e,t)=>({pendingId:e.optimisticId||`pending-draft:${t}`,text:e.message,images:e.images,streamingBehavior:e.streamingBehavior})),t=Ie.state;_l(Ie,{...t,currentPendingMessages:t.disabled?[]:[...e,...me.state]})},[Ie,ce,me]),nn=Z.useCallback(e=>{let t=J.state,n=gl(t,e);n!==t&&fa(()=>{_l(J,n),n?_l(Yt,{label:`Waiting for new session…`}):Yt.state?.label===`Waiting for new session…`&&_l(Yt,null)})},[J,Yt]),rn=Z.useCallback(e=>{let t=ce.state,n=gl(t,e);n!==t&&fa(()=>{_l(ce,n),tn()})},[ce,tn]),on=Z.useCallback(e=>{let t=me.state,n=gl(t,e);n!==t&&fa(()=>{_l(me,n),tn()})},[me,tn]),sn=Z.useRef(null);sn.current||=Sb({key:`pico.conversation.streaming-items`,wait:16,onLatest:e=>{Wt.setItems(e)}});let cn=sn.current,ln=Z.useCallback(e=>{if(e.some(e=>e.kind===`assistant`&&e.streaming)&&typeof window<`u`){cn.add(e);return}cn.cancel(),Wt.setItems(e)},[cn,Wt]);Z.useEffect(()=>()=>{cn.flush(),cn.cancel()},[cn]);let un=Z.useCallback((e,t)=>{t?.preserveExisting&&!e||_l(qt,e)},[qt]),dn=Z.useCallback(e=>{_l(Yt,e)},[Yt]),fn=Z.useCallback(e=>{let t=gb(),n={kind:`user`,itemKey:`pending:${t}`,pendingId:t,text:e.message,images:e.images.map(e=>({...e})),queued:e.queued,streamingBehavior:e.streamingBehavior},r=h.current,i=_b(r.items,n);if(i!==r.items){let e={...r,items:i};h.current=e,Wt.setItems(i),Pt(e)}return t},[Wt]),pn=Z.useCallback(e=>{if(!e)return;let t=h.current,n=vb(t.items,e);if(n===t.items)return;let r={...t,items:n};h.current=r,Wt.setItems(n),Pt(r)},[Wt]),{colorMode:mn,previewThemeFamily:hn,setColorMode:gn,setThemeFamily:_n,systemTheme:vn,themeFamily:yn}=ex(),{initialLoadingSessionId:bn,loadingSessionId:xn}=ka(_,e=>({initialLoadingSessionId:e.initialLoadingSessionId,loadingSessionId:e.loadingSessionId}),{compare:Ni}),{draftSessionLoadingOwnerKey:Sn,storedDraftDirectory:Cn}=ka(Ce),wn=ka(m,e=>({cwd:e.cwd,draft:e.draft,sessionFile:e.sessionFile,sessionId:e.sessionId,sessionKey:e.sessionKey}),{compare:Ni}),Tn=ka(_,e=>e.gitPanelOpen),En=ka(_,e=>e.terminalPanelOpen),Dn=(e,t)=>{e&&fa(()=>{x(!0),ke&&b(`git`),__(y,e,{...t,pin:ke||t?.pin})})},On=e=>{v_(y,e)},kn=e=>{y_(y,e)},An=e=>{b_(y,e)},jn=()=>{x_(y)},Mn=e=>{S_(y,e)},Nn=()=>{let e=y.state.activeTab;if(ke){f_(y,`review`),b(t=>t===`git`&&e===`review`?`session`:`git`);return}if(Tn&&e===`review`){x(!1);return}fa(()=>{f_(y,`review`),x(!0)})};Z.useEffect(()=>{g_(y)},[y,wn.cwd]),Z.useEffect(()=>{wn.draft&&g_(y)},[y,wn.draft]),Gl(c,e=>e.derived.workspaceVersion);let{baseSidebarDirectories:Pn,directoryStateByPath:Fn,directoryIndexes:In,sidebarSessions:Ln,selectedSidebarSessions:Rn,sidebarSessionEntriesByKey:zn}=c.getWorkspaceSnapshot(),Bn=Gl(c,e=>e.state.sessionsEvent?.directories||[],Mi),Vn=Z.useRef(e=>{c.setSidebarSessionStatusByKey(t=>Rl(t,e))});Vn.current=e=>{c.setSidebarSessionStatusByKey(t=>Rl(t,e))};let Hn=wn.sessionId||(wn.sessionKey?void 0:r),Un=We({path:wn.sessionFile,id:Hn}),Wn=Gl(c,e=>Un?e.state.pinnedSidebarSessionKeys.includes(Un):!1),Gn=Ui(wn),Kn=Z.useRef(``);Z.useLayoutEffect(()=>{Kn.current!==Gn&&(Kn.current=Gn,He.cancel(),_l(Be,h.current.contextUsage))},[Be,He,Gn]);let qn=bn&&!wn.sessionKey?bn:null,Jn=xn&&xn!==wn.sessionId?xn:qn&&qn!==wn.sessionId?qn:null,Yn=!!Jn,Xn=Jn?Ln.find(e=>e.id===Jn):void 0,Zn=Je(Xn),Qn=Zn===`New session`?`Loading session…`:Zn,$n=Yn?Xn?.cwd:wn.cwd;Z.useEffect(()=>{let e=T.current;if(T.current=r,e===r)return;let t=h.current,n=r?zt.current||c.state.derived.sidebarSessions.find(e=>e.id===r)?.path:void 0;Nt(r?t.draft||t.sessionId!==r?{sessionId:r,sessionPath:n}:t:{draft:!0},r),_l(_,e=>({...e,currentTab:e.currentTab===`git`||e.currentTab===`terminal`?`session`:e.currentTab,initialLoadingSessionId:r?e.initialLoadingSessionId:null,loadingSessionId:r&&h.current.sessionId!==r?r:null}))},[_,Nt,r,c]),Z.useEffect(()=>{ke||b(e=>e===`git`||e===`terminal`?`session`:e)},[ke,b]);let er=(e,t=h.current)=>{let n=mf(e),r=n.matched?n.text:e,i=n.matched?n.skillName:void 0;Ft.current=r,It.current=i;let a=O.state;(a.text!==r||a.skillName!==i)&&_l(O,{...a,text:r,skillName:i}),de(t,hf({text:r,skillName:i}))},tr=(e,t=h.current,n)=>{let r=mf(e),i=r.matched?r.text:e,a=r.matched?r.skillName:void 0;Ft.current=i,It.current=a,Ue(e=>{let t=e.text===i&&e.skillName===a,r=n?.forceSync===!0;return t&&!r?e:{text:i,skillName:a,syncNonce:r?e.syncNonce+1:e.syncNonce}}),de(t,hf({text:i,skillName:a}))},nr=Pi(tr),rr=()=>{fa(()=>{x(ae()),S(_t()),Te(C()||``),ve(t()),be(F()),U(rt()),te(G()),ne(W()),Oe(re()),xe(Gy())})};Z.useEffect(()=>{rr()},[]);let ir=()=>{gt.current?.close(),bt.current?.close(),Ye.current?.open()},ar=()=>{Ye.current?.close()},or=()=>{Ye.current?.close(),bt.current?.close(),gt.current?.open()},sr=()=>{Ye.current?.close(),gt.current?.close(),bt.current?.open()},cr=()=>{Ye.current?.close(),gt.current?.close(),bt.current?.close(),mt.current?.open()},lr=async t=>{await Promise.all([d.invalidateQueries({queryKey:vi.gitStatus(e,t),exact:!0,refetchType:`active`}),d.invalidateQueries({queryKey:vi.gitFiles(e,t),exact:!0,refetchType:`active`}),d.invalidateQueries({queryKey:vi.gitBranches(e,t),exact:!0,refetchType:`active`}),d.invalidateQueries({queryKey:vi.gitCommits(e,t),exact:!1,refetchType:`active`}),d.invalidateQueries({queryKey:vi.projectFileTree(e,t),exact:!0,refetchType:`active`}),d.invalidateQueries({queryKey:vi.gitFileReviews(e,t),exact:!1,refetchType:`active`})])},ur=an({mutationKey:vi.gitAction(e,h.current.cwd?.trim()||``,`push`),mutationFn:async t=>await oi(hi(`/api/git-push`,{contextId:e}),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({cwd:t})}),onSuccess:async(t,n)=>{await d.invalidateQueries({queryKey:vi.gitStatus(e,n),exact:!0,refetchType:`active`}),await lr(n),Rt({response:t})},onError:e=>{X.error(e instanceof Error?e.message:`Failed to push`)}}),dr=an({mutationKey:vi.gitAction(e,h.current.cwd?.trim()||``,`force-push`),mutationFn:async t=>await oi(hi(`/api/git-push`,{contextId:e}),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({cwd:t,force:!0})}),onSuccess:async(t,n)=>{await d.invalidateQueries({queryKey:vi.gitStatus(e,n),exact:!0,refetchType:`active`}),await lr(n),Rt({response:t,force:!0})},onError:e=>{X.error(e instanceof Error?e.message:`Failed to force push`)}}),fr=an({mutationKey:vi.gitAction(e,h.current.cwd?.trim()||``,`pull`),mutationFn:async t=>await oi(hi(`/api/git-pull`,{contextId:e}),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({cwd:t})}),onSuccess:async(t,n)=>{await d.invalidateQueries({queryKey:vi.gitStatus(e,n),exact:!0,refetchType:`active`}),await lr(n),X.success(`Pulled changes`)},onError:e=>{X.error(e instanceof Error?e.message:`Failed to pull`)}}),pr=async e=>{let t=h.current.cwd?.trim()||``;if(!t){X.error(`Open a session in a repository before running Git actions.`);return}let n=e===`pull`?fr:e===`force-push`?dr:ur;ur.isPending||dr.isPending||fr.isPending||await n.mutateAsync(t).catch(()=>{})},mr=async()=>{await pr(`push`)},hr=async()=>{await pr(`force-push`)},gr=async()=>{await pr(`pull`)},_r=()=>{if(ke){b(e=>e===`git`?`session`:`git`);return}x(e=>!e)},vr=()=>{if(ke){b(e=>e===`terminal`?`session`:`terminal`);return}S(e=>!e)},yr=()=>{if(ke){b(e=>e===`terminal`?`session`:e);return}S(!1)},br=()=>{let e=h.current;e.sessionFile&&it.current?.open({path:e.sessionFile,title:e.sessionName||ji(e),hasGeneratedName:!!e.sessionName?.trim()})},xr=e=>{it.current?.openForEntry(e)},Sr=e=>{ot.current?.open(e)},Cr=e=>{ct.current?.open(e)},wr=()=>{let e=h.current;if(e.sessionFile)return{path:e.sessionFile,id:e.sessionId,cwd:e.cwd,title:ji(e),name:e.sessionName,modified:e.modified}},Tr=()=>{let e=wr();e&&Sr([e])},Er=()=>{Qe.current?.open()},Dr=e=>{e.path&&(nt.current=e,et.current?.open())},Or=()=>{let e=wr();e&&Dr(e)},kr=async()=>{await ut.current?.open()},Ar=async()=>{await ft.current?.open()},jr=()=>{or()},Mr=()=>{if(_.state.currentTab!==`session`&&b(`session`),ke&&(Ae||je)){Ht.current=!0,Ae&&Me(!1);return}window.requestAnimationFrame(()=>{Pe.current?.focusPrompt({preventScroll:!0})})},Nr=()=>{Pe.current?.openModelPicker()},Pr=Pi(Mr),Fr=Z.useRef(null),Lr=()=>$e.current||Ct.current||Xe.current||lt.current||st.current||dt.current||ht.current||at.current||vt.current||xt.current||pt.current||Et.current?!0:typeof document>`u`?!1:!!document.querySelector(`[data-slot="dialog-content"][data-open], [data-slot="drawer-content"][data-state="open"]`);Z.useEffect(()=>{let e=()=>{Fr.current!==null&&window.clearTimeout(Fr.current),Fr.current=window.setTimeout(()=>{Fr.current=null,!Lr()&&Pr.current()},0)};return window.addEventListener(`pico:dialog-closed`,e),()=>{window.removeEventListener(`pico:dialog-closed`,e),Fr.current!==null&&(window.clearTimeout(Fr.current),Fr.current=null)}},[Pr]);let Rr=Z.useRef({sessionId:``,nonce:0}),zr=Z.useRef(null),Br=Z.useRef(null),Vr=()=>{zr.current!==null&&window.clearTimeout(zr.current),zr.current=window.setTimeout(()=>{zr.current=null,!Lr()&&Pr.current()},50)};Z.useEffect(()=>()=>{zr.current!==null&&(window.clearTimeout(zr.current),zr.current=null)},[]),Z.useEffect(()=>{if(!Ht.current||Ae||je)return;Ht.current=!1;let e=window.setTimeout(()=>{Pr.current()},0);return()=>{window.clearTimeout(e)}},[Pr,Ae,je]),Z.useEffect(()=>{if(Yn||Lr())return;let e=wn.sessionKey||wn.sessionId||`draft`;Br.current!==e&&(Br.current=e,Pr.current())},[Pr,Yn,wn.sessionId,wn.sessionKey]),Z.useEffect(()=>{let e=Rr.current;!e.nonce||Yn||Lr()||e.sessionId&&wn.sessionId!==e.sessionId||Vr()},[Yn,wn.sessionId]);let Hr=e=>{ve(e),ye(Le,e?`1`:`0`),e&&Uy()},Ur=async e=>{if(be(e),ye(n,e?`1`:`0`),!e)return;let t=await Ky();xe(t),t===`denied`?X.info(`Allow notifications for this site in your browser to receive desktop alerts.`):t===`unsupported`&&X.error(`Desktop notifications are unavailable in this browser.`)},Wr=Z.useCallback((e,t)=>{let n=e?Li(c.state.derived.sidebarSessionEntriesByKey,{sessionId:e,sessionPath:t?.sessionPath}):``;c.setSelectedSidebarSessionKeys(e=>n?Mi(e,[n])?e:[n]:e.length===0?e:[]),c.setSidebarSessionSelectionAnchor(e=>e===n?e:n)},[c]),Gr=Z.useCallback((e,t)=>{b(e=>e===`git`?`session`:e),Wr(e,t),Nt({draft:!e,sessionId:e,sessionPath:t?.sessionPath}),Lt.current=e,zt.current=t?.sessionPath?.trim()||void 0,e&&(Rr.current={sessionId:e,nonce:Rr.current.nonce+1}),w(t=>e?!h.current.draft&&h.current.sessionId===e?t:e:null),a?.(e,t)},[a,h,Nt,Wr]),Kr=Pi(Gr);Ux({viewerContextId:e,sessionId:r,draftSessionLoadingOwnerKey:Sn,bootstrapSidebarDirectories:c.state.state.initialSidebarBootstrapDirectories,hideToolBlocksRef:H,sessionStore:m,sessionStateRef:h,composerTextRef:Ft,composerSkillRef:It,replaceComposerDraftRef:nr,handleSelectSessionRef:Kr,pendingRouteSessionIdRef:Lt,pendingRouteSessionPathRef:zt,setSessionState:Pt,setConversationItems:ln,setHiddenThinkingPreview:un,setWorkingState:dn,setCompactRunningState:Qt,setComposerContextUsage:Ke,setComposerStreaming:qe,setSessionsEvent:c.setSessionsEvent,setSessionDoneEvents:_e,applySidebarSessionStatusRef:Vn,setComposerImages:Ge,setPendingMessages:on,pendingUiRequestHandlerRef:Bt,lastSyncedEditorTextRef:Mt}),Z.useEffect(()=>{let e=wn.cwd?.trim();e&&(ye(fe,e),Te(e))},[wn.cwd]),Z.useEffect(()=>{let e=wn.cwd?.trim(),t=wn.sessionId?.trim();if(!r||!t||wn.draft||!e||t!==r)return;let n=`${t}\n${e}`;Vt.current.has(n)||(Vt.current.add(n),c.setSidebarDirectories(t=>{let n=i(t);if(n.includes(e))return t;let r=i([e,...n]);return ye(D,JSON.stringify(r)),r}))},[r,wn.cwd,wn.draft,wn.sessionId,c]);let qr=wn.cwd?.trim()||Pn[0]||Cn||``,Jr=Z.useMemo(()=>{let e=[],t=new Set,n=(n,r)=>{let i=n.trim();!i||t.has(i)||(t.add(i),e.push({path:i,label:r}))};wn.cwd?.trim()&&n(wn.cwd,`Current session directory`),Cn&&n(Cn,`Draft directory`);for(let e of Pn)n(e,`Sidebar directory`);return e},[Pn,wn.cwd,Cn]),Yr=Z.useMemo(()=>i([...Pn,...Bn,wn.cwd||``,Cn,...Array.from(Fn.keys()),...Object.values(In).flatMap(e=>e.map(e=>e.cwd||``))]),[Pn,In,Fn,wn.cwd,Bn,Cn]),Y=wn.cwd?.trim()||(Pn.length>0?Pn[0]??``:Cn)||qr,Xr=e=>{let t=e.trim();t&&Oe(e=>{let n=i([t,...e]).slice(0,8);return ye(s,JSON.stringify(n)),n})},Zr=Z.useCallback(e=>{},[]),Qr=Z.useCallback(e=>{let t=h.current,n=(e?.id||t.sessionKey||`optimistic:${ee(t)}`).trim(),r=(e?.cwd||t.cwd||qr).trim();if(!n||!r)return;let a=new Date().toISOString(),o={id:n,cwd:r,title:`New session`,modified:a,lastUserMessageAt:a,lastMessageAt:a,...e?.lastMessagePreview?{lastMessagePreview:e.lastMessagePreview}:{},streaming:!0,unread:!1,optimistic:!0},s=We(o);c.setSidebarDirectories(e=>{let t=i(e);if(t.includes(r))return e;let n=i([r,...t]);return ye(D,JSON.stringify(n)),n});let l={...o,id:n,cwd:r};return c.setDirectoryIndexDataByPath(e=>Ol(e,l)),c.setSessionsEvent(e=>e&&{...e,directoryIndexes:Ol(e.directoryIndexes||{},l)}),s&&(c.setSelectedSidebarSessionKeys(e=>Mi(e,[s])?e:[s]),c.setSidebarSessionSelectionAnchor(e=>e===s?e:s)),n},[qr,h,c]),$r=Z.useCallback(e=>{let t=e?.trim()||``;if(!t)return;let n=We({id:t});c.setDirectoryIndexDataByPath(e=>Al(e,t)),c.setSessionsEvent(e=>e?.directoryIndexes?{...e,directoryIndexes:Al(e.directoryIndexes,t)}:e),n&&(c.setSelectedSidebarSessionKeys(e=>e.filter(e=>e!==n)),c.setSidebarSessionSelectionAnchor(e=>e===n?``:e))},[c]),ei=Z.useCallback(e=>{let t=e.preview.trim();if(!t)return;let n=h.current,r=new Date().toISOString(),i=e.optimisticSidebarSessionId||n.sessionId||n.sessionKey,a=n.sessionFile,o={...i?{sessionId:i}:{},...a?{sessionPath:a}:{},preview:t,modified:r};c.setDirectoryIndexDataByPath(e=>kl(e,o)),c.setSessionsEvent(e=>{if(!e?.directoryIndexes)return e;let t=kl(e.directoryIndexes,o);return t===e.directoryIndexes?e:{...e,directoryIndexes:t}})},[h,c]),ti=Z.useCallback(()=>{c.setSelectedSidebarSessionKeys(e=>e.length===0?e:[]),c.setSidebarSessionSelectionAnchor(e=>e&&``)},[c]),ni=q.state,ri=ue.state,ii=J.state,ai=ce.state,si=me.state,{abortSession:ci,addDirectoryPath:li,createSession:ui,editPendingMessage:di,removePendingMessage:pi,reorderPending:mi,startPendingQueue:gi,submitPrompt:_i}=$b({viewerContextId:e,activeSessionId:Hn,defaultNewSessionDirectory:qr,sessionStore:m,sessionStateRef:h,draftSessionLoadingOwnerKey:Sn,pendingDraftPrompt:ii,pendingDraftFollowUps:ai,awaitingFirstTurn:ni,pendingMessages:si,composerDiffLineCommentsRef:P,composerImagesRef:j,composerTextRef:Ft,composerSkillRef:It,replaceComposerDraft:tr,lastSyncedEditorTextRef:Mt,rememberRecentDirectory:Xr,prefetchDirectorySessionsIndex:Zr,addOptimisticUserMessage:fn,removeOptimisticUserMessage:pn,addOptimisticSidebarSession:Qr,removeOptimisticSidebarSession:$r,updateOptimisticSidebarSessionPreview:ei,setSidebarDirectories:c.setSidebarDirectories,setStoredDraftDirectory:Te,setDraftSessionLoadingOwnerKey:we,setPendingDraftPrompt:nn,setPendingDraftFollowUps:rn,setPendingMessages:on,setAwaitingFirstTurn:$t,setIsSubmitting:en,setComposerDiffLineComments:Re,setComposerImages:Ge}),yi=Z.useCallback(e=>{let t=e.trim();if(!t)return;let n=h.current;if(!n.draft||n.items.length>0)return;ye(fe,t),Te(t),Xr(t);let r=hb({previous:n,cwd:t,ownerKey:ee({cwd:t})});h.current=r,Wt.setItems(r.items),Pt(r),de(r,hf({text:Ft.current,skillName:It.current}))},[Wt,Xr,h,Pt,Te]),bi=Z.useCallback(async e=>{let t=await li(e);return typeof t==`string`&&yi(t),t},[li,yi]),xi=Z.useCallback(async(e,t)=>{let n=h.current,r=Ri({cwdOverride:e,defaultDirectory:qr,currentCwd:n.cwd}),i=ee({cwd:r}),a=`optimistic:${i}`,o=!!t?.closeMobileSidebar&&ke&&Ae,s=ui(r);Gr(void 0),ti(),$t(!1),on(e=>e.length===0?e:[]);let c=hb({previous:n,cwd:r,ownerKey:i});h.current=c,Wt.setItems(c.items),Pt(c),o?(Ht.current=!0,Me(!1)):Mr(),!await s&&h.current.sessionKey===a&&(h.current=n,Wt.setItems(n.items),Pt(n))},[ti,Wt,qr,Mr,Gr,ke,Ae,ui,h,$t,Me,on,Pt]),Si=()=>typeof crypto<`u`&&typeof crypto.randomUUID==`function`?`diff-comment:${crypto.randomUUID()}`:`diff-comment:${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`,Ci=e=>{let t=e.text.trim(),n=h.current.cwd?.trim()||``;!t||!n||(Re(r=>[...r,{...e,id:Si(),cwd:n,text:t}]),Pe.current?.focusPrompt({preventScroll:!0}))},wi=async e=>{if(!e||e.length===0)return;let t=Array.from(e).filter(e=>e.type.startsWith(`image/`));if(t.length===0)return;let n=await Promise.all(t.slice(0,8).map(e=>fi(e)));Ge(e=>[...e,...n].slice(0,8))},Ti=O.state,Ei=A.state,Di=ai.map((e,t)=>({pendingId:ab(e,t),text:e.message,images:e.images,streamingBehavior:e.streamingBehavior})),Oi=Di.length>0||si.length>0?[...Di,...si]:lb,Ai=Yn,Fi=Ai?sb:I,zi=Ai?lb:Oi,Bi=Ai?cb:Ei,Vi=Ai?``:Ti.text,Hi=Ai?void 0:Ti.skillName,Wi=(e,t)=>{let n=ai.find((t,n)=>ab(t,n)===e);return n?!t.trim()&&n.images.length===0?(X.error(`Enter a message or keep at least one image`),!0):(rn(n=>n.map((n,r)=>ab(n,r)===e?{...n,message:t}:n)),!0):!1},Gi=e=>ai.some((t,n)=>ab(t,n)===e)?(rn(t=>t.filter((t,n)=>ab(t,n)!==e)),!0):!1,Ki=(e,t)=>{let n=ob(ai,e,t);return n?(rn(n),!0):!1},qi=Z.useCallback(e=>{if(Qt(e),e){_l(Yt,{label:yb,cancelable:!0});return}if(Zt.current){Zt.current=!1,_l(Yt,{label:bb,error:!0});return}Yt.state?.label===`Compacting context...`&&_l(Yt,null)},[Qt,Yt]),Ji=Z.useCallback(()=>Zt.current,[]),{cycleThinkingLevel:Yi,deleteSessions:Xi,moveSessionPath:Zi,renameSessionPath:Qi,runClone:$i,runCompact:ea,setModel:ta,setThinkingBlocksHidden:na,setThinkingLevel:ra,toggleHideThinking:ia}=hx({viewerContextId:e,activeSessionId:Hn,sessionStateRef:h,setSessionState:Pt,getDirectoryIndexDataByPath:()=>c.state.state.directoryIndexDataByPath,setDirectoryIndexDataByPath:c.setDirectoryIndexDataByPath,getSessionsEvent:()=>c.state.state.sessionsEvent,setSessionsEvent:c.setSessionsEvent,getSidebarSelection:()=>{let e=c.state.state;return{selectedSidebarSessionKeys:e.selectedSidebarSessionKeys,sidebarSessionSelectionAnchor:e.sidebarSessionSelectionAnchor}},optimisticallyClearActiveDeletedSession:e=>{let t=h.current;if(t.sessionFile!==e)return;let n=`delete:${e}`,r=`optimistic:${n}`;Gr(void 0,{replace:!0});let i=hb({previous:t,cwd:t.cwd,ownerKey:n});return h.current=i,Wt.setItems(i.items),Pt(i),()=>{h.current.sessionKey===r&&(t.sessionId&&Gr(t.sessionId,{replace:!0,sessionPath:t.sessionFile}),h.current=t,Wt.setItems(t.items),Pt(t))}},setSelectedSidebarSessionKeys:c.setSelectedSidebarSessionKeys,setSidebarSessionSelectionAnchor:c.setSidebarSessionSelectionAnchor,setPinnedSidebarSessionKeys:c.setPinnedSidebarSessionKeys,setCompactWorkingState:qi,isCompactAbortRequested:Ji}),aa=async(e,t)=>{let n=await Zi(e,t);return n&&Xr(t),n},oa=async(t,n)=>{if(!e||!t.path)return!1;let r=t.path,i=!!t.unread,a=!!n,o=e=>{c.setSidebarSessionStatusByKey(n=>Rl(n,{type:`session_status`,sessionId:t.id,sessionPath:r,unread:e}))};o(a);try{return await oi(hi(`/api/session/read-state`,{contextId:e,sessionId:Hn}),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({path:r,unread:a})}),await d.invalidateQueries({queryKey:[`pico`,`directory-sessions-index`,e],refetchType:`active`}),X.success(a?`Marked session unread`:`Marked session read`),!0}catch(e){return o(i),X.error(e instanceof Error?e.message:`Failed to update session read state`),!1}},sa=async e=>{let t=nt.current;if(!t)return!1;let n=await aa(t,e);return n&&(nt.current=null),n},ca=async e=>{let t=h.current;return t.sessionFile?await aa({path:t.sessionFile,id:t.sessionId,cwd:t.cwd,title:ji(t),name:t.sessionName,modified:t.modified},e):!1},la=e=>{U(e),ye(Tt,e?`1`:`0`)},ua=()=>{let e=V.current.hideToolBlocks;la(!e),X.info(e?`Tools shown`:`Tools hidden`)},da=e=>{te(e),ye(yt,e?`1`:`0`)},pa=e=>{ne(e),ye(se,e?`1`:`0`)},ma=(e=`login`)=>{St.current?.open(e)},ha=async(e,t)=>{let n=t.trim(),r=()=>{tr(``,h.current,{forceSync:!0})};switch(e){case`login`:if(n){X.error(`/login does not take any arguments yet.`);return}r(),ma(`login`);return;case`logout`:if(n){X.error(`/logout does not take any arguments yet.`);return}r(),ma(`logout`);return;case`compact`:if(Ei.length>0){X.error(`Built-in slash commands do not support images.`);return}r(),await ea();return;case`clone`:if(n){X.error(`/clone does not take any arguments.`);return}if(Ei.length>0){X.error(`Built-in slash commands do not support images.`);return}r(),await $i();return;case`rename`:if(!wn.sessionFile){X.error(`Start the session before renaming it.`);return}if(!n){r(),br();return}r(),await Qi(wn.sessionFile,n);return;case`delete`:if(!wn.sessionFile){X.error(`Start the session before deleting it.`);return}r(),Tr();return;case`fork`:if(n){X.error(`/fork does not take any arguments.`);return}r(),await kr();return;case`tree`:if(n){X.error(`/tree does not take any arguments.`);return}r(),await Ar();return;case`hide-thinking`:r(),h.current.hideThinkingBlock||await ia();return;case`show-thinking`:r(),h.current.hideThinkingBlock&&await ia();return;case`hide-tools`:r(),la(!0);return;case`show-tools`:r(),la(!1);return;default:X.error(`Unsupported slash command: /${e}`)}},ga=e=>{_n(e)},_a=(e,t)=>{hn(e,t)},va=e=>{gn(e)},ya={activeSessionId:Hn,awaitingFirstTurn:Ai?!1:ni,canStartPendingQueue:!Ai&&si.length>0&&!h.current.streaming&&!h.current.compacting&&!ni&&!ri,centerMessages:V.current.centerMessages,composerDiffLineComments:Fi,composerImages:Bi,composerSkill:Hi,composerSyncNonce:Ti.syncNonce,composerText:Vi,currentPendingMessages:zi,disabled:Ai,isCompacting:Ai?!1:h.current.compacting,isStreaming:Ai?!1:h.current.streaming,isSubmitting:Ai?!1:ri,viewerContextId:e};Z.useLayoutEffect(()=>{_l(Ie,ya)});let ba=Pi({abortSession:ci,onPickImages:wi,removeDiffLineComment:e=>{Re(t=>t.filter(t=>t.id!==e))},onRemoveComposerImage:e=>{Ge(t=>t.filter((t,n)=>n!==e))},editPendingDraftFollowUp:Wi,editPendingMessage:di,removePendingDraftFollowUp:Gi,removePendingMessage:pi,reorderPending:mi,reorderPendingDraftFollowUp:Ki,startPendingQueue:gi,runBuiltinSlashCommand:ha,setModel:ta,setThinkingLevel:ra,submitPrompt:_i,syncComposerDraft:er}),xa=Pi({gitPanelOpen:Tn,hasAvailableModels:h.current.availableModels.length>0,isMobile:ke,selectedSidebarSessions:Rn,sessionFile:wn.sessionFile,terminalPanelOpen:En}),Sa=Pi(()=>{let e=xa.current,t=h.current.hideThinkingBlock,n=h.current.thinkingLevel,r=[{id:`new-session`,group:`Sessions`,title:`New session`,description:`Create a new draft session`,shortcut:Ir(`Control+N`),keywords:[`create`,`draft`,`session`],onSelect:xi},{id:`open-sessions`,group:`Sessions`,title:`Open sessions`,description:`Search and switch sessions`,shortcut:Ir(`Control+S`),keywords:[`session`,`search`,`switch`,`jump`],onSelect:or},{id:`open-git-view`,group:`Git`,title:e.isMobile?`Toggle right sidebar tab`:e.gitPanelOpen?`Close right sidebar`:`Open right sidebar`,description:e.isMobile?`Switch the mobile right sidebar tab on or off`:`Toggle the right sidebar`,shortcut:Ir(`Control+\\`),keywords:[`right`,`sidebar`,`git`,`changes`,`branch`,`commit`,`panel`],onSelect:_r},{id:`toggle-terminal`,group:`Workspace`,title:e.isMobile?`Toggle terminal tab`:e.terminalPanelOpen?`Close terminal`:`Open terminal`,description:e.isMobile?`Switch the mobile terminal tab on or off`:`Toggle the bottom terminal panel`,shortcut:Ir("Control+`"),keywords:[`terminal`,`shell`,`console`,`bottom`,`panel`],onSelect:vr},{id:`commit-changes`,group:`Git`,title:`Commit changes`,description:`Open the Git commit dialog`,shortcut:Ir(`Control+C`),keywords:[`git`,`commit`,`changes`,`stage`],onSelect:cr},{id:`push-changes`,group:`Git`,title:`Push changes`,description:`Push local commits to the remote`,shortcut:Ir(`Control+P`),keywords:[`git`,`push`,`remote`,`upstream`],onSelect:mr},{id:`force-push-changes`,group:`Git`,title:`Force push changes`,description:`Force push local commits with --force-with-lease`,shortcut:Ir(`Control+Shift+P`),keywords:[`git`,`force`,`push`,`remote`,`upstream`,`lease`],onSelect:hr},{id:`pull-changes`,group:`Git`,title:`Pull changes`,description:`Pull remote changes into the current branch`,shortcut:Ir(`Alt+P`),keywords:[`git`,`pull`,`remote`,`upstream`],onSelect:gr},{id:`focus-prompt`,group:`Assistant`,title:`Focus prompt`,description:`Move focus to the prompt field`,shortcut:Ir(`Control+Enter`),keywords:[`prompt`,`composer`,`input`,`message`,`reply`],onSelect:Mr},{id:`set-model`,group:`Assistant`,title:`Set model`,description:`Open the model picker`,shortcut:Ir(`Control+M`),keywords:[`model`,`provider`,`picker`,`choose`],onSelect:()=>{if(!xa.current.hasAvailableModels)throw Error(`No models are available right now.`);Nr()}},{id:`add-directory`,group:`Sidebar`,title:`Add Directory`,description:`Add a directory accordion to the sidebar`,shortcut:Ir(`Control+D`),keywords:[`workspace`,`sidebar`,`directory`,`folder`],onSelect:Er},{id:`tree-session`,group:`Sessions`,title:`Open tree`,description:`Jump to an earlier point in the current session tree`,shortcut:`Esc Esc`,keywords:[`tree`,`branch`,`history`,`navigate`],onSelect:Ar},{id:`fork-session`,group:`Sessions`,title:`Fork session`,description:`Create a new session from a previous user message`,shortcut:Ir(`Control+F`),keywords:[`fork`,`branch`,`draft`],onSelect:kr},{id:`clone-session`,group:`Sessions`,title:`Clone session`,description:`Duplicate the current active branch into a new session`,keywords:[`clone`,`branch`,`duplicate`,`session`],onSelect:$i},{id:`compact-session`,group:`Sessions`,title:`Compact`,description:`Manually compact the session context with /compact`,keywords:[`compact`,`context`,`compress`,`summarize`],onSelect:ea},{id:`toggle-thinking`,group:`Assistant`,title:t?`Show thinking blocks`:`Hide thinking blocks`,description:t?`Show assistant thinking blocks`:`Hide assistant thinking blocks`,shortcut:Ir(`Control+T`),keywords:[`thinking`,`reasoning`,`visibility`,`show`,`hide`],onSelect:ia},{id:`cycle-reasoning`,group:`Assistant`,title:`Next reasoning level`,description:`Current level: ${n}`,shortcut:Ir(`Control+R`),keywords:[`thinking`,`reasoning`,`level`,`cycle`,`next`],onSelect:()=>{Yi(1)}},{id:`previous-reasoning`,group:`Assistant`,title:`Previous reasoning level`,description:`Current level: ${n}`,shortcut:Ir(`Control+Shift+R`),keywords:[`thinking`,`reasoning`,`level`,`cycle`,`previous`,`back`],onSelect:()=>{Yi(-1)}},{id:`toggle-review-pane`,group:`Git`,title:`Toggle Review Pane`,description:`Toggle the review pane for changed files`,keywords:[`review`,`diff`,`file`,`changes`,`pane`],onSelect:Nn},{id:`toggle-tools`,group:`Assistant`,title:V.current.hideToolBlocks?`Show tool calls`:`Hide tool calls`,description:V.current.hideToolBlocks?`Show assistant tool calls`:`Hide assistant tool calls`,shortcut:Ir(`Control+O`),keywords:[`tools`,`tool calls`,`visibility`,`show`,`hide`],onSelect:ua},{id:`login-provider`,group:`App`,title:`Login to provider`,description:`Configure provider API key or subscription auth`,keywords:[`login`,`auth`,`api key`,`oauth`,`provider`],onSelect:()=>ma(`login`)},{id:`logout-provider`,group:`App`,title:`Logout from provider`,description:`Remove stored provider credentials`,keywords:[`logout`,`auth`,`api key`,`oauth`,`provider`],onSelect:()=>ma(`logout`)},{id:`open-settings`,group:`App`,title:`Open settings`,description:`Open app settings`,shortcut:Ir(`Control+,`),keywords:[`settings`,`theme`,`notifications`,`display`],onSelect:sr}];return e.sessionFile&&(r.splice(1,0,{id:`rename-session`,group:`Sessions`,title:`Rename session`,description:`Rename the current session`,shortcut:Ir(`Control+E`),keywords:[`rename`,`title`,`name`],onSelect:br}),r.push({id:`delete-session`,group:`Sessions`,title:`Delete session`,description:`Delete ${ji(h.current)}`,shortcut:Ir(`Control+X`),keywords:[`delete`,`remove`,`session`],onSelect:Tr})),e.selectedSidebarSessions.length>0&&r.push({id:`delete-selected-sessions`,group:`Sidebar`,title:`Delete selected sidebar sessions`,description:`Delete ${e.selectedSidebarSessions.length} selected sidebar ${e.selectedSidebarSessions.length===1?`session`:`sessions`}`,keywords:[`delete`,`selected`,`sidebar`,`sessions`],onSelect:()=>{Sr(xa.current.selectedSidebarSessions)}}),r}),Ca=Z.useCallback(async()=>{Xt.current&&(Zt.current=!0,await ci())},[ci]),wa=Pi({abortCompact:Ca,abortSession:ci,createSession:xi,closeCommandPalette:ar,forcePushGitChanges:hr,focusModelSelector:Nr,focusPrompt:Mr,focusSessionSearch:jr,jumpToNextMessage:()=>{Dt.current?.jumpToNextMessage()},jumpToPreviousMessage:()=>{Dt.current?.jumpToPreviousMessage()},openAddDirectoryDialog:Er,openCommandPalette:ir,openCommitDialog:cr,openDeleteDialog:Sr,openDeleteDialogForCurrentSession:Tr,openForkDialog:kr,openRenameDialog:br,openSessionsDialog:or,openSettingsDialog:sr,openTreeDialog:Ar,pullGitChanges:gr,pushGitChanges:mr,scrollConversationToBottom:()=>{Dt.current?.scrollConversationToBottom()},scrollConversationToTop:()=>{Dt.current?.scrollConversationToTop()},toggleGitPanel:_r,toggleTerminalPanel:vr,toggleHideThinking:ia,toggleHideToolBlocks:ua,cycleThinkingLevel:Yi}),Ta=Pi({currentTab:ke?_.state.currentTab:`session`,selectedSidebarSessions:Rn,sessionHasAvailableModels:h.current.availableModels.length>0,sessionHasFile:!!wn.sessionFile,sessionIsStreaming:h.current.streaming,sidebarSessionEntriesByKey:zn}),Ea=Pi({createSession:xi,onDeleteCurrentSession:Tr,onForkSession:kr,onMoveCurrentSession:ca,onMoveCurrentSessionToAnyDirectory:Or,onRenameSession:br,onRunCompact:ea,onToggleCurrentSessionPinned:()=>{let e=h.current,t=We({path:e.sessionFile,id:e.sessionId});t&&c.setPinnedSidebarSessionKeys(e=>{let n=At(e),r=n.includes(t)?n.filter(e=>e!==t):[t,...n];return ye(B,JSON.stringify(r)),r})},onToggleHideThinking:ia,onToggleHideToolBlocks:ua,onTreeSession:Ar});tS({addDirectoryOpenRef:$e,commandPaletteOpenRef:Xe,compactRunningRef:Xt,deleteOpenRef:st,forkOpenRef:dt,gitCommitOpenRef:ht,moveSessionDirectoryOpenRef:tt,pendingUiRequestOpenRef:Et,renameOpenRef:at,sessionSearchInputRef:l,sessionsOpenRef:vt,settingsOpenRef:xt,shortcutActionsRef:wa,shortcutStateRef:Ta,treeOpenRef:pt});let Da=Z.useRef(null);return Da.current={stores:{appUi:_,composer:Ie,contextUsage:Be,conversationItems:Wt,displaySettings:z,draftFlow:Ce,notification:ge,rightSidebar:y,session:m,sidebar:c},refs:{composerImages:j,composerPanel:Pe,composerSkill:It,composerText:Ft,conversationFrame:Dt,sessionState:h},actions:{createSession:xi,focusModelSelector:Nr,focusPrompt:Mr,focusSessionSearch:jr,openAddDirectoryDialog:Er,openCommandPalette:ir,openDeleteDialog:Sr,moveSessionToDirectory:aa,openDeleteOldDirectorySessionsDialog:Cr,openMoveSessionDirectoryDialogForEntry:Dr,openRenameDialogForEntry:xr,openSessionsDialog:or,openSettingsDialog:sr,setSessionUnread:oa,selectSession:Gr}},Z.useImperativeHandle(u,()=>{let e=Da.current?.actions;return{createSession:e?.createSession??xi,openAddDirectoryDialog:e?.openAddDirectoryDialog??Er,openCommandPalette:e?.openCommandPalette??ir,openDeleteDialog:e?.openDeleteDialog??Sr,openDeleteOldDirectorySessionsDialog:e?.openDeleteOldDirectorySessionsDialog??Cr,moveSessionToDirectory:e?.moveSessionToDirectory??aa,openMoveSessionDirectoryDialogForEntry:e?.openMoveSessionDirectoryDialogForEntry??Dr,openRenameDialogForEntry:e?.openRenameDialogForEntry??xr,openSessionsDialog:e?.openSessionsDialog??or,openSettingsDialog:e?.openSettingsDialog??sr,setSessionUnread:e?.setSessionUnread??oa,selectSession:e?.selectSession??Gr}},[xi,Gr,Er,ir,aa,Sr,Cr,Dr,xr,or,sr,oa]),(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)($y,{isSessionViewLoading:Yn,loadingDisplaySessionTitle:Qn,notificationStore:ge,sessionStore:m,sidebarStore:c,onSelectSession:Gr}),(0,$.jsx)(dv,{actionsRef:Ea,defaultNewSessionDirectory:qr,displaySessionCwd:$n,gitPanelOpen:Tn,terminalPanelOpen:En,loadingDisplaySessionTitle:Qn,currentSessionPinned:Wn,displaySettingsStore:z,isSessionViewLoading:Yn,newSessionDirectoryOptions:Jr,onToggleGitPanel:_r,onToggleTerminalPanel:vr,sessionStore:m,viewerContextId:e}),(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 overflow-hidden`,children:[o,(0,$.jsx)(Ko,{className:`min-h-0 overflow-hidden`,children:(0,$.jsx)(iv,{actionsRef:ba,appUiStore:_,composerDiffLineComments:Fi,composerPanelRef:Pe,contextUsageStore:Be,conversationFrameRef:Dt,conversationItemsStore:Wt,defaultNewSessionDirectory:qr,displaySettingsStore:z,fileInputRef:Ne,gitPanelOpen:Tn,terminalPanelOpen:En,hiddenThinkingPreviewStore:qt,isLoadingOlderHistory:kt,isSessionViewLoading:Yn,isSubmitting:ri,isMobile:ke,newSessionDirectoryOptions:Jr,onCancelCompaction:Ca,onCreateSession:e=>{xi(e)},onLoadOlderHistory:Gt,onOpenAddDirectoryDialog:Er,onCloseAllFileViewTabs:jn,onCloseFileViewTab:On,onCloseFileViewTabsToRight:An,onCloseOtherFileViewTabs:kn,onAddDiffLineComment:Ci,onOpenFileViewTab:Dn,onReorderFileViewTabs:Mn,onCloseTerminalPanel:yr,rightSidebarStore:y,sessionStore:m,store:Ie,viewerContextId:e,workingStateStore:Yt,awaitingFirstTurn:ni,onValueChange:b})})]}),(0,$.jsx)(hu,{activeSessionId:Hn,addDirectoryDialogRef:Qe,addDirectoryOpenRef:$e,addDirectoryPath:bi,baseSidebarDirectories:Pn,commandPaletteCommandsRef:Sa,commandPaletteOpenRef:Xe,commandPaletteRef:Ye,currentSessionQueryScope:Gn,currentTheme:yn,currentThemeColorMode:mn,authDialogRef:St,authOpenRef:Ct,deleteDialogRef:ot,deleteOpenRef:st,deleteSessions:Xi,deleteOldDirectorySessionsDialogRef:ct,deleteOldDirectorySessionsOpenRef:lt,notificationStore:ge,forkDialogRef:ut,forkOpenRef:dt,gitCommitDialogRef:mt,gitCommitOpenRef:ht,displaySettingsStore:z,knownDirectories:Yr,moveSessionDirectoryDialogRef:et,moveSessionDirectoryOpenRef:tt,moveSessionDirectoryTargetToPath:sa,onAutoScrollEnabledChange:pa,onCenterMessagesChange:da,onHideThinkingBlocksChange:e=>{na(e)},onHideToolBlocksChange:la,onSessionDoneDesktopNotificationsEnabledChange:Ur,onSessionDoneSoundEnabledChange:Hr,onSessionDialogSelect:Gr,onThemeChange:ga,onThemeColorModeChange:va,onThemePreviewChange:_a,systemTheme:vn,recentDirectoriesStore:De,renameDialogRef:it,renameOpenRef:at,renameSessionPath:Qi,sessionCwd:wn.cwd,sessionsDialogDirectory:Y,sessionsDialogRef:gt,sessionsOpenRef:vt,sessionStore:m,settingsDialogRef:bt,settingsOpenRef:xt,sidebarStore:c,treeDialogRef:ft,treeOpenRef:pt,uiRequestDialogRef:wt,uiRequestOpenRef:Et,viewerContextId:e})]})}function aS({sessionId:e,onSelectSession:t}){let[n,r]=Z.useState(``),a=Z.useRef(null);a.current||=Wl();let o=a.current,s=Z.useRef(null),c=Z.useRef(null);return Z.useEffect(()=>{let e=window.localStorage.getItem(`pico-context-id`)?.trim()||R();ye(T,e),r(e);let t=i(De().directories),n=t.slice(0,nS),a=x();o.setSidebarState(e=>Mi(e.sidebarDirectories,t)&&Mi(e.initialSidebarBootstrapDirectories,n)&&Mi(e.pinnedSidebarSessionKeys,a)?e:{sidebarDirectories:t,initialSidebarBootstrapDirectories:n,pinnedSidebarSessionKeys:a})},[o]),(0,$.jsx)(Ho,{className:`h-full flex-col overflow-hidden bg-background [--header-height:3rem]`,children:(0,$.jsx)(rS,{ref:c,viewerContextId:n,sessionId:e,onSelectSession:t,sidebar:(0,$.jsx)(dy,{viewerContextId:n,sidebarStore:o,sessionWorkspaceRef:c}),sidebarStore:o,sessionSearchInputRef:s})})}function oS(){let e=(0,Q.c)(6),{session:t}=Ai.useSearch(),n=Ai.useNavigate(),r;e[0]!==n||e[1]!==t?(r=(e,r)=>{let i=e||void 0;i!==t&&n({search:e=>({...e,session:i}),replace:r?.replace??!1})},e[0]=n,e[1]=t,e[2]=r):r=e[2];let i;return e[3]!==t||e[4]!==r?(i=(0,$.jsx)(aS,{sessionId:t,onSelectSession:r}),e[3]=t,e[4]=r,e[5]=i):i=e[5],i}export{oS as component};