@prismshadow/penguin-server 0.2.2 → 0.2.3

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 (299) hide show
  1. package/README.md +1 -0
  2. package/dist/api/types.d.ts +311 -22
  3. package/dist/chunk-3QINBW3W.js +565 -0
  4. package/dist/chunk-3QINBW3W.js.map +1 -0
  5. package/dist/hmr/manifest.d.ts +44 -0
  6. package/dist/hmr/manifest.js +27 -0
  7. package/dist/hmr/manifest.js.map +1 -0
  8. package/dist/index.js +1995 -796
  9. package/dist/index.js.map +1 -1
  10. package/dist/reset-admin-password.d.ts +28 -0
  11. package/dist/reset-admin-password.js +39 -0
  12. package/dist/reset-admin-password.js.map +1 -0
  13. package/package.json +11 -3
  14. package/web-dist/assets/cpp-DIPi6g--.js +1 -0
  15. package/web-dist/assets/highlighter-Nvj8c0Yw.js +152 -0
  16. package/web-dist/assets/index--uKtXcEB.js +183 -0
  17. package/web-dist/assets/index-BqF51KT4.css +1 -0
  18. package/web-dist/assets/ruby-B13GW9FM.js +1 -0
  19. package/web-dist/index.html +2 -2
  20. package/web-dist/assets/abap-BdImnpbu.js +0 -1
  21. package/web-dist/assets/actionscript-3-CoDkCxhg.js +0 -1
  22. package/web-dist/assets/ada-bCR0ucgS.js +0 -1
  23. package/web-dist/assets/andromeeda-C4gqWexZ.js +0 -1
  24. package/web-dist/assets/angular-html-DA-rfuFy.js +0 -1
  25. package/web-dist/assets/angular-ts-BrjP3tb8.js +0 -1
  26. package/web-dist/assets/apache-Pmp26Uib.js +0 -1
  27. package/web-dist/assets/apex-Dqspr-GT.js +0 -1
  28. package/web-dist/assets/apl-CORt7UWP.js +0 -1
  29. package/web-dist/assets/applescript-Co6uUVPk.js +0 -1
  30. package/web-dist/assets/ara-BRHolxvo.js +0 -1
  31. package/web-dist/assets/asciidoc-Ve4PFQV2.js +0 -1
  32. package/web-dist/assets/asm-D_Q5rh1f.js +0 -1
  33. package/web-dist/assets/astro-HNnZUWAn.js +0 -1
  34. package/web-dist/assets/aurora-x-D-2ljcwZ.js +0 -1
  35. package/web-dist/assets/awk-DMzUqQB5.js +0 -1
  36. package/web-dist/assets/ayu-dark-DYE7WIF3.js +0 -1
  37. package/web-dist/assets/ayu-light-BA47KaF1.js +0 -1
  38. package/web-dist/assets/ayu-mirage-32ctXXKs.js +0 -1
  39. package/web-dist/assets/ballerina-BFfxhgS-.js +0 -1
  40. package/web-dist/assets/bat-BkioyH1T.js +0 -1
  41. package/web-dist/assets/beancount-k_qm7-4y.js +0 -1
  42. package/web-dist/assets/berry-uYugtg8r.js +0 -1
  43. package/web-dist/assets/bibtex-CHM0blh-.js +0 -1
  44. package/web-dist/assets/bicep-Bmn6On1c.js +0 -1
  45. package/web-dist/assets/bird2-BIv1doCn.js +0 -1
  46. package/web-dist/assets/blade-2xfisSek.js +0 -1
  47. package/web-dist/assets/bsl-BO_Y6i37.js +0 -1
  48. package/web-dist/assets/c3-MRO5bC_T.js +0 -1
  49. package/web-dist/assets/cadence-Bv_4Rxtq.js +0 -1
  50. package/web-dist/assets/cairo-KRGpt6FW.js +0 -1
  51. package/web-dist/assets/catppuccin-frappe-DFWUc33u.js +0 -1
  52. package/web-dist/assets/catppuccin-latte-C9dUb6Cb.js +0 -1
  53. package/web-dist/assets/catppuccin-macchiato-DQyhUUbL.js +0 -1
  54. package/web-dist/assets/catppuccin-mocha-D87Tk5Gz.js +0 -1
  55. package/web-dist/assets/clarity-D53aC0YG.js +0 -1
  56. package/web-dist/assets/clojure-P80f7IUj.js +0 -1
  57. package/web-dist/assets/cmake-D1j8_8rp.js +0 -1
  58. package/web-dist/assets/cobol-nBiQ_Alo.js +0 -1
  59. package/web-dist/assets/codeowners-Bp6g37R7.js +0 -1
  60. package/web-dist/assets/codeql-DsOJ9woJ.js +0 -1
  61. package/web-dist/assets/coffee-Ch7k5sss.js +0 -1
  62. package/web-dist/assets/common-lisp-Cg-RD9OK.js +0 -1
  63. package/web-dist/assets/coq-DkFqJrB1.js +0 -1
  64. package/web-dist/assets/cpp-UfJy6YNI.js +0 -1
  65. package/web-dist/assets/crystal-DGywbUpC.js +0 -1
  66. package/web-dist/assets/csharp-DSvCPggb.js +0 -1
  67. package/web-dist/assets/csv-fuZLfV_i.js +0 -1
  68. package/web-dist/assets/cue-D82EKSYY.js +0 -1
  69. package/web-dist/assets/cypher-COkxafJQ.js +0 -1
  70. package/web-dist/assets/d-85-TOEBH.js +0 -1
  71. package/web-dist/assets/dark-plus-C3mMm8J8.js +0 -1
  72. package/web-dist/assets/dart-bE4Kk8sk.js +0 -1
  73. package/web-dist/assets/dax-CEL-wOlO.js +0 -1
  74. package/web-dist/assets/desktop-BmXAJ9_W.js +0 -1
  75. package/web-dist/assets/docker-BcOcwvcX.js +0 -1
  76. package/web-dist/assets/dotenv-Da5cRb03.js +0 -1
  77. package/web-dist/assets/dracula-BzJJZx-M.js +0 -1
  78. package/web-dist/assets/dracula-soft-BXkSAIEj.js +0 -1
  79. package/web-dist/assets/dream-maker-BtqSS_iP.js +0 -1
  80. package/web-dist/assets/edge-FbVlp4U3.js +0 -1
  81. package/web-dist/assets/elixir-CkH2-t6x.js +0 -1
  82. package/web-dist/assets/elm-DbKCFpqz.js +0 -1
  83. package/web-dist/assets/emacs-lisp-CXvaQtF9.js +0 -1
  84. package/web-dist/assets/erb-Dm6A9KJ5.js +0 -1
  85. package/web-dist/assets/erlang-DsQrWhSR.js +0 -1
  86. package/web-dist/assets/everforest-dark-BgDCqdQA.js +0 -1
  87. package/web-dist/assets/everforest-light-C8M2exoo.js +0 -1
  88. package/web-dist/assets/fennel-BYunw83y.js +0 -1
  89. package/web-dist/assets/fish-BvzEVeQv.js +0 -1
  90. package/web-dist/assets/fluent-C4IJs8-o.js +0 -1
  91. package/web-dist/assets/fortran-fixed-form-CkoXwp7k.js +0 -1
  92. package/web-dist/assets/fortran-free-form-BxgE0vQu.js +0 -1
  93. package/web-dist/assets/fsharp-CXgrBDvD.js +0 -1
  94. package/web-dist/assets/gdresource-BOOCDP_w.js +0 -1
  95. package/web-dist/assets/gdscript-C5YyOfLZ.js +0 -1
  96. package/web-dist/assets/gdshader-DkwncUOv.js +0 -1
  97. package/web-dist/assets/genie-D0YGMca9.js +0 -1
  98. package/web-dist/assets/gherkin-DyxjwDmM.js +0 -1
  99. package/web-dist/assets/git-commit-F4YmCXRG.js +0 -1
  100. package/web-dist/assets/git-rebase-r7XF79zn.js +0 -1
  101. package/web-dist/assets/github-dark-default-Cuk6v7N8.js +0 -1
  102. package/web-dist/assets/github-dark-dimmed-DH5Ifo-i.js +0 -1
  103. package/web-dist/assets/github-dark-high-contrast-E3gJ1_iC.js +0 -1
  104. package/web-dist/assets/github-light-default-D7oLnXFd.js +0 -1
  105. package/web-dist/assets/github-light-high-contrast-BfjtVDDH.js +0 -1
  106. package/web-dist/assets/gleam-BspZqrRM.js +0 -1
  107. package/web-dist/assets/glimmer-js-ByusRIyA.js +0 -1
  108. package/web-dist/assets/glimmer-ts-BfAWNZQY.js +0 -1
  109. package/web-dist/assets/glsl-DplSGwfg.js +0 -1
  110. package/web-dist/assets/gn-n2N0HUVH.js +0 -1
  111. package/web-dist/assets/gnuplot-DdkO51Og.js +0 -1
  112. package/web-dist/assets/graphql-ChdNCCLP.js +0 -1
  113. package/web-dist/assets/groovy-gcz8RCvz.js +0 -1
  114. package/web-dist/assets/gruvbox-dark-hard-CFHQjOhq.js +0 -1
  115. package/web-dist/assets/gruvbox-dark-medium-GsRaNv29.js +0 -1
  116. package/web-dist/assets/gruvbox-dark-soft-CVdnzihN.js +0 -1
  117. package/web-dist/assets/gruvbox-light-hard-CH1njM8p.js +0 -1
  118. package/web-dist/assets/gruvbox-light-medium-DRw_LuNl.js +0 -1
  119. package/web-dist/assets/gruvbox-light-soft-hJgmCMqR.js +0 -1
  120. package/web-dist/assets/hack-DbPARsA_.js +0 -1
  121. package/web-dist/assets/haml-D5jkg6IW.js +0 -1
  122. package/web-dist/assets/handlebars-BpdQsYii.js +0 -1
  123. package/web-dist/assets/haskell-Df6bDoY_.js +0 -1
  124. package/web-dist/assets/haxe-CzTSHFRz.js +0 -1
  125. package/web-dist/assets/hcl-BWvSN4gD.js +0 -1
  126. package/web-dist/assets/hjson-D5-asLiD.js +0 -1
  127. package/web-dist/assets/hlsl-D3lLCCz7.js +0 -1
  128. package/web-dist/assets/horizon-BUw7H-hv.js +0 -1
  129. package/web-dist/assets/horizon-bright-CUuTKBJd.js +0 -1
  130. package/web-dist/assets/houston-DnULxvSX.js +0 -1
  131. package/web-dist/assets/html-derivative-DlHx6ybY.js +0 -1
  132. package/web-dist/assets/http-jrhK8wxY.js +0 -1
  133. package/web-dist/assets/hurl-irOxFIW8.js +0 -1
  134. package/web-dist/assets/hxml-Bvhsp5Yf.js +0 -1
  135. package/web-dist/assets/hy-DFXneXwc.js +0 -1
  136. package/web-dist/assets/imba-DGztddWO.js +0 -1
  137. package/web-dist/assets/index-B3puu-Hr.js +0 -153
  138. package/web-dist/assets/index-CaDuyrN0.css +0 -1
  139. package/web-dist/assets/index-rgHg3m6g.js +0 -181
  140. package/web-dist/assets/jinja-f2NsQr07.js +0 -1
  141. package/web-dist/assets/jison-wvAkD_A8.js +0 -1
  142. package/web-dist/assets/json5-C9tS-k6U.js +0 -1
  143. package/web-dist/assets/jsonc-Des-eS-w.js +0 -1
  144. package/web-dist/assets/jsonl-DcaNXYhu.js +0 -1
  145. package/web-dist/assets/jsonnet-DFQXde-d.js +0 -1
  146. package/web-dist/assets/jssm-C2t-YnRu.js +0 -1
  147. package/web-dist/assets/julia-D7OTSIA_.js +0 -1
  148. package/web-dist/assets/just-CUsbIsdP.js +0 -1
  149. package/web-dist/assets/kanagawa-dragon-CkXjmgJE.js +0 -1
  150. package/web-dist/assets/kanagawa-lotus-CfQXZHmo.js +0 -1
  151. package/web-dist/assets/kanagawa-wave-DWedfzmr.js +0 -1
  152. package/web-dist/assets/kdl-DV7GczEv.js +0 -1
  153. package/web-dist/assets/kotlin-BdnUsdx6.js +0 -1
  154. package/web-dist/assets/kusto-wEQ09or8.js +0 -1
  155. package/web-dist/assets/laserwave-DUszq2jm.js +0 -1
  156. package/web-dist/assets/latex-CaSxy8MP.js +0 -1
  157. package/web-dist/assets/lean-BZvkOJ9d.js +0 -1
  158. package/web-dist/assets/less-B1dDrJ26.js +0 -1
  159. package/web-dist/assets/light-plus-B7mTdjB0.js +0 -1
  160. package/web-dist/assets/liquid-C0sCDyMI.js +0 -1
  161. package/web-dist/assets/llvm-DjAJT7YJ.js +0 -1
  162. package/web-dist/assets/logo-BtOb2qkB.js +0 -1
  163. package/web-dist/assets/lua-BaeVxFsk.js +0 -1
  164. package/web-dist/assets/luau-KW6xsasC.js +0 -1
  165. package/web-dist/assets/make-CHLpvVh8.js +0 -1
  166. package/web-dist/assets/marko-DjSrsDqO.js +0 -1
  167. package/web-dist/assets/material-theme-D5KoaKCx.js +0 -1
  168. package/web-dist/assets/material-theme-darker-BfHTSMKl.js +0 -1
  169. package/web-dist/assets/material-theme-lighter-B0m2ddpp.js +0 -1
  170. package/web-dist/assets/material-theme-ocean-CyktbL80.js +0 -1
  171. package/web-dist/assets/material-theme-palenight-Csfq5Kiy.js +0 -1
  172. package/web-dist/assets/matlab-D7o27uSR.js +0 -1
  173. package/web-dist/assets/mdc-DTYItulj.js +0 -1
  174. package/web-dist/assets/mdx-Cmh6b_Ma.js +0 -1
  175. package/web-dist/assets/mermaid-mWjccvbQ.js +0 -1
  176. package/web-dist/assets/min-dark-CafNBF8u.js +0 -1
  177. package/web-dist/assets/min-light-CTRr51gU.js +0 -1
  178. package/web-dist/assets/mipsasm-CKIfxQSi.js +0 -1
  179. package/web-dist/assets/mojo-rZm6bMo-.js +0 -1
  180. package/web-dist/assets/monokai-D4h5O-jR.js +0 -1
  181. package/web-dist/assets/moonbit-_H4v1dQx.js +0 -1
  182. package/web-dist/assets/move-IF9eRakj.js +0 -1
  183. package/web-dist/assets/narrat-DRg8JJMk.js +0 -1
  184. package/web-dist/assets/nextflow-C-mBbutL.js +0 -1
  185. package/web-dist/assets/nextflow-groovy-vE_lwT2v.js +0 -1
  186. package/web-dist/assets/nginx-BpAMiNFr.js +0 -1
  187. package/web-dist/assets/night-owl-C39BiMTA.js +0 -1
  188. package/web-dist/assets/night-owl-light-CMTm3GFP.js +0 -1
  189. package/web-dist/assets/nim-BIad80T-.js +0 -1
  190. package/web-dist/assets/nix-CwoSXNpI.js +0 -1
  191. package/web-dist/assets/nord-Ddv68eIx.js +0 -1
  192. package/web-dist/assets/nushell-Cz2AlsmD.js +0 -1
  193. package/web-dist/assets/objective-c-DXmwc3jG.js +0 -1
  194. package/web-dist/assets/objective-cpp-CLxacb5B.js +0 -1
  195. package/web-dist/assets/ocaml-C0hk2d4L.js +0 -1
  196. package/web-dist/assets/odin-BBf5iR-q.js +0 -1
  197. package/web-dist/assets/one-dark-pro-DVMEJ2y_.js +0 -1
  198. package/web-dist/assets/one-light-C3Wv6jpd.js +0 -1
  199. package/web-dist/assets/openscad-C4EeE6gA.js +0 -1
  200. package/web-dist/assets/pascal-D93ZcfNL.js +0 -1
  201. package/web-dist/assets/perl-B9cMNwum.js +0 -1
  202. package/web-dist/assets/pkl-u5AG7uiY.js +0 -1
  203. package/web-dist/assets/plastic-3e1v2bzS.js +0 -1
  204. package/web-dist/assets/plsql-ChMvpjG-.js +0 -1
  205. package/web-dist/assets/po-BTJTHyun.js +0 -1
  206. package/web-dist/assets/poimandres-CS3Unz2-.js +0 -1
  207. package/web-dist/assets/polar-C0HS_06l.js +0 -1
  208. package/web-dist/assets/postcss-CXtECtnM.js +0 -1
  209. package/web-dist/assets/powerquery-CEu0bR-o.js +0 -1
  210. package/web-dist/assets/powershell-Dpen1YoG.js +0 -1
  211. package/web-dist/assets/prisma-Dd19v3D-.js +0 -1
  212. package/web-dist/assets/prolog-CbFg5uaA.js +0 -1
  213. package/web-dist/assets/proto-C7zT0LnQ.js +0 -1
  214. package/web-dist/assets/pug-DKIMFp6K.js +0 -1
  215. package/web-dist/assets/puppet-BMWR74SV.js +0 -1
  216. package/web-dist/assets/purescript-CklMAg4u.js +0 -1
  217. package/web-dist/assets/qml-3beO22l8.js +0 -1
  218. package/web-dist/assets/qmldir-C8lEn-DE.js +0 -1
  219. package/web-dist/assets/qss-IeuSbFQv.js +0 -1
  220. package/web-dist/assets/r-Dspwwk_N.js +0 -1
  221. package/web-dist/assets/racket-BqYA7rlc.js +0 -1
  222. package/web-dist/assets/raku-DXvB9xmW.js +0 -1
  223. package/web-dist/assets/razor-BjBPvh-w.js +0 -1
  224. package/web-dist/assets/red-bN70gL4F.js +0 -1
  225. package/web-dist/assets/reg-C-SQnVFl.js +0 -1
  226. package/web-dist/assets/regexp-CDVJQ6XC.js +0 -1
  227. package/web-dist/assets/rel-C3B-1QV4.js +0 -1
  228. package/web-dist/assets/riscv-BM1_JUlF.js +0 -1
  229. package/web-dist/assets/ron-D8l8udqQ.js +0 -1
  230. package/web-dist/assets/rose-pine-dawn-DHQR4-dF.js +0 -1
  231. package/web-dist/assets/rose-pine-moon-D4_iv3hh.js +0 -1
  232. package/web-dist/assets/rose-pine-qdsjHGoJ.js +0 -1
  233. package/web-dist/assets/rosmsg-BJDFO7_C.js +0 -1
  234. package/web-dist/assets/rst-CpCqk9r5.js +0 -1
  235. package/web-dist/assets/ruby-DyJCeAvU.js +0 -1
  236. package/web-dist/assets/sas-DEy46yEz.js +0 -1
  237. package/web-dist/assets/sass-Cj5Yp3dK.js +0 -1
  238. package/web-dist/assets/scala-C151Ov-r.js +0 -1
  239. package/web-dist/assets/scheme-C98Dy4si.js +0 -1
  240. package/web-dist/assets/scss-D5BDwBP9.js +0 -1
  241. package/web-dist/assets/sdbl-DVxCFoDh.js +0 -1
  242. package/web-dist/assets/shaderlab-Dg9Lc6iA.js +0 -1
  243. package/web-dist/assets/shellsession-BADoaaVG.js +0 -1
  244. package/web-dist/assets/slack-dark-BthQWCQV.js +0 -1
  245. package/web-dist/assets/slack-ochin-DqwNpetd.js +0 -1
  246. package/web-dist/assets/smalltalk-BERRCDM3.js +0 -1
  247. package/web-dist/assets/snazzy-light-Bw305WKR.js +0 -1
  248. package/web-dist/assets/solarized-dark-DXbdFlpD.js +0 -1
  249. package/web-dist/assets/solarized-light-L9t79GZl.js +0 -1
  250. package/web-dist/assets/solidity-rGO070M0.js +0 -1
  251. package/web-dist/assets/soy-8wufbnw4.js +0 -1
  252. package/web-dist/assets/sparql-rVzFXLq3.js +0 -1
  253. package/web-dist/assets/splunk-BtCnVYZw.js +0 -1
  254. package/web-dist/assets/ssh-config-_ykCGR6B.js +0 -1
  255. package/web-dist/assets/stata-DI20mbqo.js +0 -1
  256. package/web-dist/assets/stylus-BEDo0Tqx.js +0 -1
  257. package/web-dist/assets/surrealql-Bq5Q-fJD.js +0 -1
  258. package/web-dist/assets/svelte-Cy7k_4gC.js +0 -1
  259. package/web-dist/assets/swift-D82vCrfD.js +0 -1
  260. package/web-dist/assets/synthwave-84-CbfX1IO0.js +0 -1
  261. package/web-dist/assets/system-verilog-CnnmHF94.js +0 -1
  262. package/web-dist/assets/systemd-4A_iFExJ.js +0 -1
  263. package/web-dist/assets/talonscript-CkByrt1z.js +0 -1
  264. package/web-dist/assets/tasl-QIJgUcNo.js +0 -1
  265. package/web-dist/assets/tcl-dwOrl1Do.js +0 -1
  266. package/web-dist/assets/templ-DhtptRzy.js +0 -1
  267. package/web-dist/assets/terraform-BETggiCN.js +0 -1
  268. package/web-dist/assets/tex-idrVyKtj.js +0 -1
  269. package/web-dist/assets/tokyo-night-hegEt444.js +0 -1
  270. package/web-dist/assets/ts-tags-D351s5mN.js +0 -1
  271. package/web-dist/assets/tsv-B_m7g4N7.js +0 -1
  272. package/web-dist/assets/turtle-BsS91CYL.js +0 -1
  273. package/web-dist/assets/twig-CW1WmMYd.js +0 -1
  274. package/web-dist/assets/typespec-CAFt9gP4.js +0 -1
  275. package/web-dist/assets/typst-DHCkPAjA.js +0 -1
  276. package/web-dist/assets/v-BcVCzyr7.js +0 -1
  277. package/web-dist/assets/vala-CsfeWuGM.js +0 -1
  278. package/web-dist/assets/vb-D17OF-Vu.js +0 -1
  279. package/web-dist/assets/verilog-BQ8w6xss.js +0 -1
  280. package/web-dist/assets/vesper-DRje8inN.js +0 -1
  281. package/web-dist/assets/vhdl-CeAyd5Ju.js +0 -1
  282. package/web-dist/assets/viml-CJc9bBzg.js +0 -1
  283. package/web-dist/assets/vitesse-black-Bkuqu6BP.js +0 -1
  284. package/web-dist/assets/vitesse-dark-D0r3Knsf.js +0 -1
  285. package/web-dist/assets/vitesse-light-CVO1_9PV.js +0 -1
  286. package/web-dist/assets/vue-D2xRrEX4.js +0 -1
  287. package/web-dist/assets/vue-html-AaS7Mt5G.js +0 -1
  288. package/web-dist/assets/vue-vine-BoDAl6tE.js +0 -1
  289. package/web-dist/assets/vyper-CDx5xZoG.js +0 -1
  290. package/web-dist/assets/wasm-CG6Dc4jp.js +0 -1
  291. package/web-dist/assets/wasm-MzD3tlZU.js +0 -1
  292. package/web-dist/assets/wenyan-BV7otONQ.js +0 -1
  293. package/web-dist/assets/wgsl-Dx-B1_4e.js +0 -1
  294. package/web-dist/assets/wikitext-BhOHFoWU.js +0 -1
  295. package/web-dist/assets/wit-5i3qLPDT.js +0 -1
  296. package/web-dist/assets/wolfram-lXgVvXCa.js +0 -1
  297. package/web-dist/assets/xsl-CtQFsRM5.js +0 -1
  298. package/web-dist/assets/zenscript-DVFEvuxE.js +0 -1
  299. package/web-dist/assets/zig-VOosw3JB.js +0 -1
@@ -1,181 +0,0 @@
1
- (function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))l(o);new MutationObserver(o=>{for(const c of o)if(c.type==="childList")for(const u of c.addedNodes)u.tagName==="LINK"&&u.rel==="modulepreload"&&l(u)}).observe(document,{childList:!0,subtree:!0});function a(o){const c={};return o.integrity&&(c.integrity=o.integrity),o.referrerPolicy&&(c.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?c.credentials="include":o.crossOrigin==="anonymous"?c.credentials="omit":c.credentials="same-origin",c}function l(o){if(o.ep)return;o.ep=!0;const c=a(o);fetch(o.href,c)}})();function xk(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Wm={exports:{}},go={};var wv;function iC(){if(wv)return go;wv=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function a(l,o,c){var u=null;if(c!==void 0&&(u=""+c),o.key!==void 0&&(u=""+o.key),"key"in o){c={};for(var f in o)f!=="key"&&(c[f]=o[f])}else c=o;return o=c.ref,{$$typeof:e,type:l,key:u,ref:o!==void 0?o:null,props:c}}return go.Fragment=t,go.jsx=a,go.jsxs=a,go}var Sv;function oC(){return Sv||(Sv=1,Wm.exports=iC()),Wm.exports}var s=oC(),Km={exports:{}},nt={};var jv;function cC(){if(jv)return nt;jv=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.portal"),a=Symbol.for("react.fragment"),l=Symbol.for("react.strict_mode"),o=Symbol.for("react.profiler"),c=Symbol.for("react.consumer"),u=Symbol.for("react.context"),f=Symbol.for("react.forward_ref"),p=Symbol.for("react.suspense"),h=Symbol.for("react.memo"),g=Symbol.for("react.lazy"),v=Symbol.for("react.activity"),k=Symbol.iterator;function w(R){return R===null||typeof R!="object"?null:(R=k&&R[k]||R["@@iterator"],typeof R=="function"?R:null)}var j={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},E=Object.assign,C={};function M(R,H,S){this.props=R,this.context=H,this.refs=C,this.updater=S||j}M.prototype.isReactComponent={},M.prototype.setState=function(R,H){if(typeof R!="object"&&typeof R!="function"&&R!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,R,H,"setState")},M.prototype.forceUpdate=function(R){this.updater.enqueueForceUpdate(this,R,"forceUpdate")};function _(){}_.prototype=M.prototype;function D(R,H,S){this.props=R,this.context=H,this.refs=C,this.updater=S||j}var V=D.prototype=new _;V.constructor=D,E(V,M.prototype),V.isPureReactComponent=!0;var F=Array.isArray;function A(){}var P={H:null,A:null,T:null,S:null},Q=Object.prototype.hasOwnProperty;function K(R,H,S){var U=S.ref;return{$$typeof:e,type:R,key:H,ref:U!==void 0?U:null,props:S}}function O(R,H){return K(R.type,H,R.props)}function z(R){return typeof R=="object"&&R!==null&&R.$$typeof===e}function I(R){var H={"=":"=0",":":"=2"};return"$"+R.replace(/[=:]/g,function(S){return H[S]})}var B=/\/+/g;function $(R,H){return typeof R=="object"&&R!==null&&R.key!=null?I(""+R.key):H.toString(36)}function G(R){switch(R.status){case"fulfilled":return R.value;case"rejected":throw R.reason;default:switch(typeof R.status=="string"?R.then(A,A):(R.status="pending",R.then(function(H){R.status==="pending"&&(R.status="fulfilled",R.value=H)},function(H){R.status==="pending"&&(R.status="rejected",R.reason=H)})),R.status){case"fulfilled":return R.value;case"rejected":throw R.reason}}throw R}function q(R,H,S,U,ee){var ie=typeof R;(ie==="undefined"||ie==="boolean")&&(R=null);var de=!1;if(R===null)de=!0;else switch(ie){case"bigint":case"string":case"number":de=!0;break;case"object":switch(R.$$typeof){case e:case t:de=!0;break;case g:return de=R._init,q(de(R._payload),H,S,U,ee)}}if(de)return ee=ee(R),de=U===""?"."+$(R,0):U,F(ee)?(S="",de!=null&&(S=de.replace(B,"$&/")+"/"),q(ee,H,S,"",function(te){return te})):ee!=null&&(z(ee)&&(ee=O(ee,S+(ee.key==null||R&&R.key===ee.key?"":(""+ee.key).replace(B,"$&/")+"/")+de)),H.push(ee)),1;de=0;var me=U===""?".":U+":";if(F(R))for(var ye=0;ye<R.length;ye++)U=R[ye],ie=me+$(U,ye),de+=q(U,H,S,ie,ee);else if(ye=w(R),typeof ye=="function")for(R=ye.call(R),ye=0;!(U=R.next()).done;)U=U.value,ie=me+$(U,ye++),de+=q(U,H,S,ie,ee);else if(ie==="object"){if(typeof R.then=="function")return q(G(R),H,S,U,ee);throw H=String(R),Error("Objects are not valid as a React child (found: "+(H==="[object Object]"?"object with keys {"+Object.keys(R).join(", ")+"}":H)+"). If you meant to render a collection of children, use an array instead.")}return de}function ae(R,H,S){if(R==null)return R;var U=[],ee=0;return q(R,U,"","",function(ie){return H.call(S,ie,ee++)}),U}function Z(R){if(R._status===-1){var H=R._result;H=H(),H.then(function(S){(R._status===0||R._status===-1)&&(R._status=1,R._result=S)},function(S){(R._status===0||R._status===-1)&&(R._status=2,R._result=S)}),R._status===-1&&(R._status=0,R._result=H)}if(R._status===1)return R._result.default;throw R._result}var X=typeof reportError=="function"?reportError:function(R){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var H=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof R=="object"&&R!==null&&typeof R.message=="string"?String(R.message):String(R),error:R});if(!window.dispatchEvent(H))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",R);return}console.error(R)},T={map:ae,forEach:function(R,H,S){ae(R,function(){H.apply(this,arguments)},S)},count:function(R){var H=0;return ae(R,function(){H++}),H},toArray:function(R){return ae(R,function(H){return H})||[]},only:function(R){if(!z(R))throw Error("React.Children.only expected to receive a single React element child.");return R}};return nt.Activity=v,nt.Children=T,nt.Component=M,nt.Fragment=a,nt.Profiler=o,nt.PureComponent=D,nt.StrictMode=l,nt.Suspense=p,nt.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=P,nt.__COMPILER_RUNTIME={__proto__:null,c:function(R){return P.H.useMemoCache(R)}},nt.cache=function(R){return function(){return R.apply(null,arguments)}},nt.cacheSignal=function(){return null},nt.cloneElement=function(R,H,S){if(R==null)throw Error("The argument must be a React element, but you passed "+R+".");var U=E({},R.props),ee=R.key;if(H!=null)for(ie in H.key!==void 0&&(ee=""+H.key),H)!Q.call(H,ie)||ie==="key"||ie==="__self"||ie==="__source"||ie==="ref"&&H.ref===void 0||(U[ie]=H[ie]);var ie=arguments.length-2;if(ie===1)U.children=S;else if(1<ie){for(var de=Array(ie),me=0;me<ie;me++)de[me]=arguments[me+2];U.children=de}return K(R.type,ee,U)},nt.createContext=function(R){return R={$$typeof:u,_currentValue:R,_currentValue2:R,_threadCount:0,Provider:null,Consumer:null},R.Provider=R,R.Consumer={$$typeof:c,_context:R},R},nt.createElement=function(R,H,S){var U,ee={},ie=null;if(H!=null)for(U in H.key!==void 0&&(ie=""+H.key),H)Q.call(H,U)&&U!=="key"&&U!=="__self"&&U!=="__source"&&(ee[U]=H[U]);var de=arguments.length-2;if(de===1)ee.children=S;else if(1<de){for(var me=Array(de),ye=0;ye<de;ye++)me[ye]=arguments[ye+2];ee.children=me}if(R&&R.defaultProps)for(U in de=R.defaultProps,de)ee[U]===void 0&&(ee[U]=de[U]);return K(R,ie,ee)},nt.createRef=function(){return{current:null}},nt.forwardRef=function(R){return{$$typeof:f,render:R}},nt.isValidElement=z,nt.lazy=function(R){return{$$typeof:g,_payload:{_status:-1,_result:R},_init:Z}},nt.memo=function(R,H){return{$$typeof:h,type:R,compare:H===void 0?null:H}},nt.startTransition=function(R){var H=P.T,S={};P.T=S;try{var U=R(),ee=P.S;ee!==null&&ee(S,U),typeof U=="object"&&U!==null&&typeof U.then=="function"&&U.then(A,X)}catch(ie){X(ie)}finally{H!==null&&S.types!==null&&(H.types=S.types),P.T=H}},nt.unstable_useCacheRefresh=function(){return P.H.useCacheRefresh()},nt.use=function(R){return P.H.use(R)},nt.useActionState=function(R,H,S){return P.H.useActionState(R,H,S)},nt.useCallback=function(R,H){return P.H.useCallback(R,H)},nt.useContext=function(R){return P.H.useContext(R)},nt.useDebugValue=function(){},nt.useDeferredValue=function(R,H){return P.H.useDeferredValue(R,H)},nt.useEffect=function(R,H){return P.H.useEffect(R,H)},nt.useEffectEvent=function(R){return P.H.useEffectEvent(R)},nt.useId=function(){return P.H.useId()},nt.useImperativeHandle=function(R,H,S){return P.H.useImperativeHandle(R,H,S)},nt.useInsertionEffect=function(R,H){return P.H.useInsertionEffect(R,H)},nt.useLayoutEffect=function(R,H){return P.H.useLayoutEffect(R,H)},nt.useMemo=function(R,H){return P.H.useMemo(R,H)},nt.useOptimistic=function(R,H){return P.H.useOptimistic(R,H)},nt.useReducer=function(R,H,S){return P.H.useReducer(R,H,S)},nt.useRef=function(R){return P.H.useRef(R)},nt.useState=function(R){return P.H.useState(R)},nt.useSyncExternalStore=function(R,H,S){return P.H.useSyncExternalStore(R,H,S)},nt.useTransition=function(){return P.H.useTransition()},nt.version="19.2.7",nt}var Cv;function Uh(){return Cv||(Cv=1,Km.exports=cC()),Km.exports}var y=Uh(),Ym={exports:{}},xo={},Qm={exports:{}},Xm={};var Nv;function uC(){return Nv||(Nv=1,(function(e){function t(q,ae){var Z=q.length;q.push(ae);e:for(;0<Z;){var X=Z-1>>>1,T=q[X];if(0<o(T,ae))q[X]=ae,q[Z]=T,Z=X;else break e}}function a(q){return q.length===0?null:q[0]}function l(q){if(q.length===0)return null;var ae=q[0],Z=q.pop();if(Z!==ae){q[0]=Z;e:for(var X=0,T=q.length,R=T>>>1;X<R;){var H=2*(X+1)-1,S=q[H],U=H+1,ee=q[U];if(0>o(S,Z))U<T&&0>o(ee,S)?(q[X]=ee,q[U]=Z,X=U):(q[X]=S,q[H]=Z,X=H);else if(U<T&&0>o(ee,Z))q[X]=ee,q[U]=Z,X=U;else break e}}return ae}function o(q,ae){var Z=q.sortIndex-ae.sortIndex;return Z!==0?Z:q.id-ae.id}if(e.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var c=performance;e.unstable_now=function(){return c.now()}}else{var u=Date,f=u.now();e.unstable_now=function(){return u.now()-f}}var p=[],h=[],g=1,v=null,k=3,w=!1,j=!1,E=!1,C=!1,M=typeof setTimeout=="function"?setTimeout:null,_=typeof clearTimeout=="function"?clearTimeout:null,D=typeof setImmediate<"u"?setImmediate:null;function V(q){for(var ae=a(h);ae!==null;){if(ae.callback===null)l(h);else if(ae.startTime<=q)l(h),ae.sortIndex=ae.expirationTime,t(p,ae);else break;ae=a(h)}}function F(q){if(E=!1,V(q),!j)if(a(p)!==null)j=!0,A||(A=!0,I());else{var ae=a(h);ae!==null&&G(F,ae.startTime-q)}}var A=!1,P=-1,Q=5,K=-1;function O(){return C?!0:!(e.unstable_now()-K<Q)}function z(){if(C=!1,A){var q=e.unstable_now();K=q;var ae=!0;try{e:{j=!1,E&&(E=!1,_(P),P=-1),w=!0;var Z=k;try{t:{for(V(q),v=a(p);v!==null&&!(v.expirationTime>q&&O());){var X=v.callback;if(typeof X=="function"){v.callback=null,k=v.priorityLevel;var T=X(v.expirationTime<=q);if(q=e.unstable_now(),typeof T=="function"){v.callback=T,V(q),ae=!0;break t}v===a(p)&&l(p),V(q)}else l(p);v=a(p)}if(v!==null)ae=!0;else{var R=a(h);R!==null&&G(F,R.startTime-q),ae=!1}}break e}finally{v=null,k=Z,w=!1}ae=void 0}}finally{ae?I():A=!1}}}var I;if(typeof D=="function")I=function(){D(z)};else if(typeof MessageChannel<"u"){var B=new MessageChannel,$=B.port2;B.port1.onmessage=z,I=function(){$.postMessage(null)}}else I=function(){M(z,0)};function G(q,ae){P=M(function(){q(e.unstable_now())},ae)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(q){q.callback=null},e.unstable_forceFrameRate=function(q){0>q||125<q?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):Q=0<q?Math.floor(1e3/q):5},e.unstable_getCurrentPriorityLevel=function(){return k},e.unstable_next=function(q){switch(k){case 1:case 2:case 3:var ae=3;break;default:ae=k}var Z=k;k=ae;try{return q()}finally{k=Z}},e.unstable_requestPaint=function(){C=!0},e.unstable_runWithPriority=function(q,ae){switch(q){case 1:case 2:case 3:case 4:case 5:break;default:q=3}var Z=k;k=q;try{return ae()}finally{k=Z}},e.unstable_scheduleCallback=function(q,ae,Z){var X=e.unstable_now();switch(typeof Z=="object"&&Z!==null?(Z=Z.delay,Z=typeof Z=="number"&&0<Z?X+Z:X):Z=X,q){case 1:var T=-1;break;case 2:T=250;break;case 5:T=1073741823;break;case 4:T=1e4;break;default:T=5e3}return T=Z+T,q={id:g++,callback:ae,priorityLevel:q,startTime:Z,expirationTime:T,sortIndex:-1},Z>X?(q.sortIndex=Z,t(h,q),a(p)===null&&q===a(h)&&(E?(_(P),P=-1):E=!0,G(F,Z-X))):(q.sortIndex=T,t(p,q),j||w||(j=!0,A||(A=!0,I()))),q},e.unstable_shouldYield=O,e.unstable_wrapCallback=function(q){var ae=k;return function(){var Z=k;k=ae;try{return q.apply(this,arguments)}finally{k=Z}}}})(Xm)),Xm}var Tv;function dC(){return Tv||(Tv=1,Qm.exports=uC()),Qm.exports}var Zm={exports:{}},Vn={};var Mv;function fC(){if(Mv)return Vn;Mv=1;var e=Uh();function t(p){var h="https://react.dev/errors/"+p;if(1<arguments.length){h+="?args[]="+encodeURIComponent(arguments[1]);for(var g=2;g<arguments.length;g++)h+="&args[]="+encodeURIComponent(arguments[g])}return"Minified React error #"+p+"; visit "+h+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function a(){}var l={d:{f:a,r:function(){throw Error(t(522))},D:a,C:a,L:a,m:a,X:a,S:a,M:a},p:0,findDOMNode:null},o=Symbol.for("react.portal");function c(p,h,g){var v=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:o,key:v==null?null:""+v,children:p,containerInfo:h,implementation:g}}var u=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function f(p,h){if(p==="font")return"";if(typeof h=="string")return h==="use-credentials"?h:""}return Vn.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=l,Vn.createPortal=function(p,h){var g=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!h||h.nodeType!==1&&h.nodeType!==9&&h.nodeType!==11)throw Error(t(299));return c(p,h,null,g)},Vn.flushSync=function(p){var h=u.T,g=l.p;try{if(u.T=null,l.p=2,p)return p()}finally{u.T=h,l.p=g,l.d.f()}},Vn.preconnect=function(p,h){typeof p=="string"&&(h?(h=h.crossOrigin,h=typeof h=="string"?h==="use-credentials"?h:"":void 0):h=null,l.d.C(p,h))},Vn.prefetchDNS=function(p){typeof p=="string"&&l.d.D(p)},Vn.preinit=function(p,h){if(typeof p=="string"&&h&&typeof h.as=="string"){var g=h.as,v=f(g,h.crossOrigin),k=typeof h.integrity=="string"?h.integrity:void 0,w=typeof h.fetchPriority=="string"?h.fetchPriority:void 0;g==="style"?l.d.S(p,typeof h.precedence=="string"?h.precedence:void 0,{crossOrigin:v,integrity:k,fetchPriority:w}):g==="script"&&l.d.X(p,{crossOrigin:v,integrity:k,fetchPriority:w,nonce:typeof h.nonce=="string"?h.nonce:void 0})}},Vn.preinitModule=function(p,h){if(typeof p=="string")if(typeof h=="object"&&h!==null){if(h.as==null||h.as==="script"){var g=f(h.as,h.crossOrigin);l.d.M(p,{crossOrigin:g,integrity:typeof h.integrity=="string"?h.integrity:void 0,nonce:typeof h.nonce=="string"?h.nonce:void 0})}}else h==null&&l.d.M(p)},Vn.preload=function(p,h){if(typeof p=="string"&&typeof h=="object"&&h!==null&&typeof h.as=="string"){var g=h.as,v=f(g,h.crossOrigin);l.d.L(p,g,{crossOrigin:v,integrity:typeof h.integrity=="string"?h.integrity:void 0,nonce:typeof h.nonce=="string"?h.nonce:void 0,type:typeof h.type=="string"?h.type:void 0,fetchPriority:typeof h.fetchPriority=="string"?h.fetchPriority:void 0,referrerPolicy:typeof h.referrerPolicy=="string"?h.referrerPolicy:void 0,imageSrcSet:typeof h.imageSrcSet=="string"?h.imageSrcSet:void 0,imageSizes:typeof h.imageSizes=="string"?h.imageSizes:void 0,media:typeof h.media=="string"?h.media:void 0})}},Vn.preloadModule=function(p,h){if(typeof p=="string")if(h){var g=f(h.as,h.crossOrigin);l.d.m(p,{as:typeof h.as=="string"&&h.as!=="script"?h.as:void 0,crossOrigin:g,integrity:typeof h.integrity=="string"?h.integrity:void 0})}else l.d.m(p)},Vn.requestFormReset=function(p){l.d.r(p)},Vn.unstable_batchedUpdates=function(p,h){return p(h)},Vn.useFormState=function(p,h,g){return u.H.useFormState(p,h,g)},Vn.useFormStatus=function(){return u.H.useHostTransitionStatus()},Vn.version="19.2.7",Vn}var Ev;function yk(){if(Ev)return Zm.exports;Ev=1;function e(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}return e(),Zm.exports=fC(),Zm.exports}var Av;function mC(){if(Av)return xo;Av=1;var e=dC(),t=Uh(),a=yk();function l(n){var r="https://react.dev/errors/"+n;if(1<arguments.length){r+="?args[]="+encodeURIComponent(arguments[1]);for(var i=2;i<arguments.length;i++)r+="&args[]="+encodeURIComponent(arguments[i])}return"Minified React error #"+n+"; visit "+r+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function o(n){return!(!n||n.nodeType!==1&&n.nodeType!==9&&n.nodeType!==11)}function c(n){var r=n,i=n;if(n.alternate)for(;r.return;)r=r.return;else{n=r;do r=n,(r.flags&4098)!==0&&(i=r.return),n=r.return;while(n)}return r.tag===3?i:null}function u(n){if(n.tag===13){var r=n.memoizedState;if(r===null&&(n=n.alternate,n!==null&&(r=n.memoizedState)),r!==null)return r.dehydrated}return null}function f(n){if(n.tag===31){var r=n.memoizedState;if(r===null&&(n=n.alternate,n!==null&&(r=n.memoizedState)),r!==null)return r.dehydrated}return null}function p(n){if(c(n)!==n)throw Error(l(188))}function h(n){var r=n.alternate;if(!r){if(r=c(n),r===null)throw Error(l(188));return r!==n?null:n}for(var i=n,d=r;;){var x=i.return;if(x===null)break;var b=x.alternate;if(b===null){if(d=x.return,d!==null){i=d;continue}break}if(x.child===b.child){for(b=x.child;b;){if(b===i)return p(x),n;if(b===d)return p(x),r;b=b.sibling}throw Error(l(188))}if(i.return!==d.return)i=x,d=b;else{for(var N=!1,L=x.child;L;){if(L===i){N=!0,i=x,d=b;break}if(L===d){N=!0,d=x,i=b;break}L=L.sibling}if(!N){for(L=b.child;L;){if(L===i){N=!0,i=b,d=x;break}if(L===d){N=!0,d=b,i=x;break}L=L.sibling}if(!N)throw Error(l(189))}}if(i.alternate!==d)throw Error(l(190))}if(i.tag!==3)throw Error(l(188));return i.stateNode.current===i?n:r}function g(n){var r=n.tag;if(r===5||r===26||r===27||r===6)return n;for(n=n.child;n!==null;){if(r=g(n),r!==null)return r;n=n.sibling}return null}var v=Object.assign,k=Symbol.for("react.element"),w=Symbol.for("react.transitional.element"),j=Symbol.for("react.portal"),E=Symbol.for("react.fragment"),C=Symbol.for("react.strict_mode"),M=Symbol.for("react.profiler"),_=Symbol.for("react.consumer"),D=Symbol.for("react.context"),V=Symbol.for("react.forward_ref"),F=Symbol.for("react.suspense"),A=Symbol.for("react.suspense_list"),P=Symbol.for("react.memo"),Q=Symbol.for("react.lazy"),K=Symbol.for("react.activity"),O=Symbol.for("react.memo_cache_sentinel"),z=Symbol.iterator;function I(n){return n===null||typeof n!="object"?null:(n=z&&n[z]||n["@@iterator"],typeof n=="function"?n:null)}var B=Symbol.for("react.client.reference");function $(n){if(n==null)return null;if(typeof n=="function")return n.$$typeof===B?null:n.displayName||n.name||null;if(typeof n=="string")return n;switch(n){case E:return"Fragment";case M:return"Profiler";case C:return"StrictMode";case F:return"Suspense";case A:return"SuspenseList";case K:return"Activity"}if(typeof n=="object")switch(n.$$typeof){case j:return"Portal";case D:return n.displayName||"Context";case _:return(n._context.displayName||"Context")+".Consumer";case V:var r=n.render;return n=n.displayName,n||(n=r.displayName||r.name||"",n=n!==""?"ForwardRef("+n+")":"ForwardRef"),n;case P:return r=n.displayName||null,r!==null?r:$(n.type)||"Memo";case Q:r=n._payload,n=n._init;try{return $(n(r))}catch{}}return null}var G=Array.isArray,q=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ae=a.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,Z={pending:!1,data:null,method:null,action:null},X=[],T=-1;function R(n){return{current:n}}function H(n){0>T||(n.current=X[T],X[T]=null,T--)}function S(n,r){T++,X[T]=n.current,n.current=r}var U=R(null),ee=R(null),ie=R(null),de=R(null);function me(n,r){switch(S(ie,r),S(ee,n),S(U,null),r.nodeType){case 9:case 11:n=(n=r.documentElement)&&(n=n.namespaceURI)?Vy(n):0;break;default:if(n=r.tagName,r=r.namespaceURI)r=Vy(r),n=Gy(r,n);else switch(n){case"svg":n=1;break;case"math":n=2;break;default:n=0}}H(U),S(U,n)}function ye(){H(U),H(ee),H(ie)}function te(n){n.memoizedState!==null&&S(de,n);var r=U.current,i=Gy(r,n.type);r!==i&&(S(ee,n),S(U,i))}function be(n){ee.current===n&&(H(U),H(ee)),de.current===n&&(H(de),fo._currentValue=Z)}var Re,Fe;function ce(n){if(Re===void 0)try{throw Error()}catch(i){var r=i.stack.trim().match(/\n( *(at )?)/);Re=r&&r[1]||"",Fe=-1<i.stack.indexOf(`
2
- at`)?" (<anonymous>)":-1<i.stack.indexOf("@")?"@unknown:0:0":""}return`
3
- `+Re+n+Fe}var Ve=!1;function je(n,r){if(!n||Ve)return"";Ve=!0;var i=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var d={DetermineComponentFrameRoot:function(){try{if(r){var ke=function(){throw Error()};if(Object.defineProperty(ke.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(ke,[])}catch(fe){var oe=fe}Reflect.construct(n,[],ke)}else{try{ke.call()}catch(fe){oe=fe}n.call(ke.prototype)}}else{try{throw Error()}catch(fe){oe=fe}(ke=n())&&typeof ke.catch=="function"&&ke.catch(function(){})}}catch(fe){if(fe&&oe&&typeof fe.stack=="string")return[fe.stack,oe.stack]}return[null,null]}};d.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var x=Object.getOwnPropertyDescriptor(d.DetermineComponentFrameRoot,"name");x&&x.configurable&&Object.defineProperty(d.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var b=d.DetermineComponentFrameRoot(),N=b[0],L=b[1];if(N&&L){var Y=N.split(`
4
- `),se=L.split(`
5
- `);for(x=d=0;d<Y.length&&!Y[d].includes("DetermineComponentFrameRoot");)d++;for(;x<se.length&&!se[x].includes("DetermineComponentFrameRoot");)x++;if(d===Y.length||x===se.length)for(d=Y.length-1,x=se.length-1;1<=d&&0<=x&&Y[d]!==se[x];)x--;for(;1<=d&&0<=x;d--,x--)if(Y[d]!==se[x]){if(d!==1||x!==1)do if(d--,x--,0>x||Y[d]!==se[x]){var xe=`
6
- `+Y[d].replace(" at new "," at ");return n.displayName&&xe.includes("<anonymous>")&&(xe=xe.replace("<anonymous>",n.displayName)),xe}while(1<=d&&0<=x);break}}}finally{Ve=!1,Error.prepareStackTrace=i}return(i=n?n.displayName||n.name:"")?ce(i):""}function wt(n,r){switch(n.tag){case 26:case 27:case 5:return ce(n.type);case 16:return ce("Lazy");case 13:return n.child!==r&&r!==null?ce("Suspense Fallback"):ce("Suspense");case 19:return ce("SuspenseList");case 0:case 15:return je(n.type,!1);case 11:return je(n.type.render,!1);case 1:return je(n.type,!0);case 31:return ce("Activity");default:return""}}function an(n){try{var r="",i=null;do r+=wt(n,i),i=n,n=n.return;while(n);return r}catch(d){return`
7
- Error generating stack: `+d.message+`
8
- `+d.stack}}var rn=Object.prototype.hasOwnProperty,sn=e.unstable_scheduleCallback,Ut=e.unstable_cancelCallback,At=e.unstable_shouldYield,fn=e.unstable_requestPaint,st=e.unstable_now,nn=e.unstable_getCurrentPriorityLevel,pe=e.unstable_ImmediatePriority,Se=e.unstable_UserBlockingPriority,De=e.unstable_NormalPriority,ze=e.unstable_LowPriority,Ue=e.unstable_IdlePriority,W=e.log,ge=e.unstable_setDisableYieldValue,Ne=null,Te=null;function Pe(n){if(typeof W=="function"&&ge(n),Te&&typeof Te.setStrictMode=="function")try{Te.setStrictMode(Ne,n)}catch{}}var We=Math.clz32?Math.clz32:Ce,tt=Math.log,it=Math.LN2;function Ce(n){return n>>>=0,n===0?32:31-(tt(n)/it|0)|0}var Oe=256,Ke=262144,vt=4194304;function xt(n){var r=n&42;if(r!==0)return r;switch(n&-n){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return n&261888;case 262144:case 524288:case 1048576:case 2097152:return n&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return n&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return n}}function St(n,r,i){var d=n.pendingLanes;if(d===0)return 0;var x=0,b=n.suspendedLanes,N=n.pingedLanes;n=n.warmLanes;var L=d&134217727;return L!==0?(d=L&~b,d!==0?x=xt(d):(N&=L,N!==0?x=xt(N):i||(i=L&~n,i!==0&&(x=xt(i))))):(L=d&~b,L!==0?x=xt(L):N!==0?x=xt(N):i||(i=d&~n,i!==0&&(x=xt(i)))),x===0?0:r!==0&&r!==x&&(r&b)===0&&(b=x&-x,i=r&-r,b>=i||b===32&&(i&4194048)!==0)?r:x}function ln(n,r){return(n.pendingLanes&~(n.suspendedLanes&~n.pingedLanes)&r)===0}function $t(n,r){switch(n){case 1:case 2:case 4:case 8:case 64:return r+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return r+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Oa(){var n=vt;return vt<<=1,(vt&62914560)===0&&(vt=4194304),n}function aa(n){for(var r=[],i=0;31>i;i++)r.push(n);return r}function En(n,r){n.pendingLanes|=r,r!==268435456&&(n.suspendedLanes=0,n.pingedLanes=0,n.warmLanes=0)}function An(n,r,i,d,x,b){var N=n.pendingLanes;n.pendingLanes=i,n.suspendedLanes=0,n.pingedLanes=0,n.warmLanes=0,n.expiredLanes&=i,n.entangledLanes&=i,n.errorRecoveryDisabledLanes&=i,n.shellSuspendCounter=0;var L=n.entanglements,Y=n.expirationTimes,se=n.hiddenUpdates;for(i=N&~i;0<i;){var xe=31-We(i),ke=1<<xe;L[xe]=0,Y[xe]=-1;var oe=se[xe];if(oe!==null)for(se[xe]=null,xe=0;xe<oe.length;xe++){var fe=oe[xe];fe!==null&&(fe.lane&=-536870913)}i&=~ke}d!==0&&ar(n,d,0),b!==0&&x===0&&n.tag!==0&&(n.suspendedLanes|=b&~(N&~r))}function ar(n,r,i){n.pendingLanes|=r,n.suspendedLanes&=~r;var d=31-We(r);n.entangledLanes|=r,n.entanglements[d]=n.entanglements[d]|1073741824|i&261930}function Yn(n,r){var i=n.entangledLanes|=r;for(n=n.entanglements;i;){var d=31-We(i),x=1<<d;x&r|n[d]&r&&(n[d]|=r),i&=~x}}function ts(n,r){var i=r&-r;return i=(i&42)!==0?1:Pn(i),(i&(n.suspendedLanes|r))!==0?0:i}function Pn(n){switch(n){case 2:n=1;break;case 8:n=4;break;case 32:n=16;break;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:n=128;break;case 268435456:n=134217728;break;default:n=0}return n}function ba(n){return n&=-n,2<n?8<n?(n&134217727)!==0?32:268435456:8:2}function Da(){var n=ae.p;return n!==0?n:(n=window.event,n===void 0?32:hv(n.type))}function gr(n,r){var i=ae.p;try{return ae.p=n,r()}finally{ae.p=i}}var Bn=Math.random().toString(36).slice(2),qt="__reactFiber$"+Bn,Zt="__reactProps$"+Bn,Hn="__reactContainer$"+Bn,on="__reactEvents$"+Bn,Rr="__reactListeners$"+Bn,xr="__reactHandles$"+Bn,rr="__reactResources$"+Bn,Qn="__reactMarker$"+Bn;function sr(n){delete n[qt],delete n[Zt],delete n[on],delete n[Rr],delete n[xr]}function ka(n){var r=n[qt];if(r)return r;for(var i=n.parentNode;i;){if(r=i[Hn]||i[qt]){if(i=r.alternate,r.child!==null||i!==null&&i.child!==null)for(n=Jy(n);n!==null;){if(i=n[qt])return i;n=Jy(n)}return r}n=i,i=n.parentNode}return null}function ra(n){if(n=n[qt]||n[Hn]){var r=n.tag;if(r===5||r===6||r===13||r===31||r===26||r===27||r===3)return n}return null}function za(n){var r=n.tag;if(r===5||r===26||r===27||r===6)return n.stateNode;throw Error(l(33))}function yn(n){var r=n[rr];return r||(r=n[rr]={hoistableStyles:new Map,hoistableScripts:new Map}),r}function he(n){n[Qn]=!0}var Le=new Set,ot={};function rt(n,r){Rt(n,r),Rt(n+"Capture",r)}function Rt(n,r){for(ot[n]=r,n=0;n<r.length;n++)Le.add(r[n])}var Vt=RegExp("^[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD][:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"),vn={},sa={};function Fn(n){return rn.call(sa,n)?!0:rn.call(vn,n)?!1:Vt.test(n)?sa[n]=!0:(vn[n]=!0,!1)}function Xn(n,r,i){if(Fn(r))if(i===null)n.removeAttribute(r);else{switch(typeof i){case"undefined":case"function":case"symbol":n.removeAttribute(r);return;case"boolean":var d=r.toLowerCase().slice(0,5);if(d!=="data-"&&d!=="aria-"){n.removeAttribute(r);return}}n.setAttribute(r,""+i)}}function _n(n,r,i){if(i===null)n.removeAttribute(r);else{switch(typeof i){case"undefined":case"function":case"symbol":case"boolean":n.removeAttribute(r);return}n.setAttribute(r,""+i)}}function wa(n,r,i,d){if(d===null)n.removeAttribute(i);else{switch(typeof d){case"undefined":case"function":case"symbol":case"boolean":n.removeAttribute(i);return}n.setAttributeNS(r,i,""+d)}}function qn(n){switch(typeof n){case"bigint":case"boolean":case"number":case"string":case"undefined":return n;case"object":return n;default:return""}}function Ml(n){var r=n.type;return(n=n.nodeName)&&n.toLowerCase()==="input"&&(r==="checkbox"||r==="radio")}function Ni(n,r,i){var d=Object.getOwnPropertyDescriptor(n.constructor.prototype,r);if(!n.hasOwnProperty(r)&&typeof d<"u"&&typeof d.get=="function"&&typeof d.set=="function"){var x=d.get,b=d.set;return Object.defineProperty(n,r,{configurable:!0,get:function(){return x.call(this)},set:function(N){i=""+N,b.call(this,N)}}),Object.defineProperty(n,r,{enumerable:d.enumerable}),{getValue:function(){return i},setValue:function(N){i=""+N},stopTracking:function(){n._valueTracker=null,delete n[r]}}}}function ns(n){if(!n._valueTracker){var r=Ml(n)?"checked":"value";n._valueTracker=Ni(n,r,""+n[r])}}function ue(n){if(!n)return!1;var r=n._valueTracker;if(!r)return!0;var i=r.getValue(),d="";return n&&(d=Ml(n)?n.checked?"true":"false":n.value),n=d,n!==i?(r.setValue(n),!0):!1}function _e(n){if(n=n||(typeof document<"u"?document:void 0),typeof n>"u")return null;try{return n.activeElement||n.body}catch{return n.body}}var ut=/[\n"\\]/g;function Je(n){return n.replace(ut,function(r){return"\\"+r.charCodeAt(0).toString(16)+" "})}function Pt(n,r,i,d,x,b,N,L){n.name="",N!=null&&typeof N!="function"&&typeof N!="symbol"&&typeof N!="boolean"?n.type=N:n.removeAttribute("type"),r!=null?N==="number"?(r===0&&n.value===""||n.value!=r)&&(n.value=""+qn(r)):n.value!==""+qn(r)&&(n.value=""+qn(r)):N!=="submit"&&N!=="reset"||n.removeAttribute("value"),r!=null?Nn(n,N,qn(r)):i!=null?Nn(n,N,qn(i)):d!=null&&n.removeAttribute("value"),x==null&&b!=null&&(n.defaultChecked=!!b),x!=null&&(n.checked=x&&typeof x!="function"&&typeof x!="symbol"),L!=null&&typeof L!="function"&&typeof L!="symbol"&&typeof L!="boolean"?n.name=""+qn(L):n.removeAttribute("name")}function Wt(n,r,i,d,x,b,N,L){if(b!=null&&typeof b!="function"&&typeof b!="symbol"&&typeof b!="boolean"&&(n.type=b),r!=null||i!=null){if(!(b!=="submit"&&b!=="reset"||r!=null)){ns(n);return}i=i!=null?""+qn(i):"",r=r!=null?""+qn(r):i,L||r===n.value||(n.value=r),n.defaultValue=r}d=d??x,d=typeof d!="function"&&typeof d!="symbol"&&!!d,n.checked=L?n.checked:!!d,n.defaultChecked=!!d,N!=null&&typeof N!="function"&&typeof N!="symbol"&&typeof N!="boolean"&&(n.name=N),ns(n)}function Nn(n,r,i){r==="number"&&_e(n.ownerDocument)===n||n.defaultValue===""+i||(n.defaultValue=""+i)}function bn(n,r,i,d){if(n=n.options,r){r={};for(var x=0;x<i.length;x++)r["$"+i[x]]=!0;for(i=0;i<n.length;i++)x=r.hasOwnProperty("$"+n[i].value),n[i].selected!==x&&(n[i].selected=x),x&&d&&(n[i].defaultSelected=!0)}else{for(i=""+qn(i),r=null,x=0;x<n.length;x++){if(n[x].value===i){n[x].selected=!0,d&&(n[x].defaultSelected=!0);return}r!==null||n[x].disabled||(r=n[x])}r!==null&&(r.selected=!0)}}function as(n,r,i){if(r!=null&&(r=""+qn(r),r!==n.value&&(n.value=r),i==null)){n.defaultValue!==r&&(n.defaultValue=r);return}n.defaultValue=i!=null?""+qn(i):""}function rs(n,r,i,d){if(r==null){if(d!=null){if(i!=null)throw Error(l(92));if(G(d)){if(1<d.length)throw Error(l(93));d=d[0]}i=d}i==null&&(i=""),r=i}i=qn(r),n.defaultValue=i,d=n.textContent,d===i&&d!==""&&d!==null&&(n.value=d),ns(n)}function lr(n,r){if(r){var i=n.firstChild;if(i&&i===n.lastChild&&i.nodeType===3){i.nodeValue=r;return}}n.textContent=r}var Ti=new Set("animationIterationCount aspectRatio borderImageOutset borderImageSlice borderImageWidth boxFlex boxFlexGroup boxOrdinalGroup columnCount columns flex flexGrow flexPositive flexShrink flexNegative flexOrder gridArea gridRow gridRowEnd gridRowSpan gridRowStart gridColumn gridColumnEnd gridColumnSpan gridColumnStart fontWeight lineClamp lineHeight opacity order orphans scale tabSize widows zIndex zoom fillOpacity floodOpacity stopOpacity strokeDasharray strokeDashoffset strokeMiterlimit strokeOpacity strokeWidth MozAnimationIterationCount MozBoxFlex MozBoxFlexGroup MozLineClamp msAnimationIterationCount msFlex msZoom msFlexGrow msFlexNegative msFlexOrder msFlexPositive msFlexShrink msGridColumn msGridColumnSpan msGridRow msGridRowSpan WebkitAnimationIterationCount WebkitBoxFlex WebKitBoxFlexGroup WebkitBoxOrdinalGroup WebkitColumnCount WebkitColumns WebkitFlex WebkitFlexGrow WebkitFlexPositive WebkitFlexShrink WebkitLineClamp".split(" "));function qs(n,r,i){var d=r.indexOf("--")===0;i==null||typeof i=="boolean"||i===""?d?n.setProperty(r,""):r==="float"?n.cssFloat="":n[r]="":d?n.setProperty(r,i):typeof i!="number"||i===0||Ti.has(r)?r==="float"?n.cssFloat=i:n[r]=(""+i).trim():n[r]=i+"px"}function Ua(n,r,i){if(r!=null&&typeof r!="object")throw Error(l(62));if(n=n.style,i!=null){for(var d in i)!i.hasOwnProperty(d)||r!=null&&r.hasOwnProperty(d)||(d.indexOf("--")===0?n.setProperty(d,""):d==="float"?n.cssFloat="":n[d]="");for(var x in r)d=r[x],r.hasOwnProperty(x)&&i[x]!==d&&qs(n,x,d)}else for(var b in r)r.hasOwnProperty(b)&&qs(n,b,r[b])}function le(n){if(n.indexOf("-")===-1)return!1;switch(n){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var Ae=new Map([["acceptCharset","accept-charset"],["htmlFor","for"],["httpEquiv","http-equiv"],["crossOrigin","crossorigin"],["accentHeight","accent-height"],["alignmentBaseline","alignment-baseline"],["arabicForm","arabic-form"],["baselineShift","baseline-shift"],["capHeight","cap-height"],["clipPath","clip-path"],["clipRule","clip-rule"],["colorInterpolation","color-interpolation"],["colorInterpolationFilters","color-interpolation-filters"],["colorProfile","color-profile"],["colorRendering","color-rendering"],["dominantBaseline","dominant-baseline"],["enableBackground","enable-background"],["fillOpacity","fill-opacity"],["fillRule","fill-rule"],["floodColor","flood-color"],["floodOpacity","flood-opacity"],["fontFamily","font-family"],["fontSize","font-size"],["fontSizeAdjust","font-size-adjust"],["fontStretch","font-stretch"],["fontStyle","font-style"],["fontVariant","font-variant"],["fontWeight","font-weight"],["glyphName","glyph-name"],["glyphOrientationHorizontal","glyph-orientation-horizontal"],["glyphOrientationVertical","glyph-orientation-vertical"],["horizAdvX","horiz-adv-x"],["horizOriginX","horiz-origin-x"],["imageRendering","image-rendering"],["letterSpacing","letter-spacing"],["lightingColor","lighting-color"],["markerEnd","marker-end"],["markerMid","marker-mid"],["markerStart","marker-start"],["overlinePosition","overline-position"],["overlineThickness","overline-thickness"],["paintOrder","paint-order"],["panose-1","panose-1"],["pointerEvents","pointer-events"],["renderingIntent","rendering-intent"],["shapeRendering","shape-rendering"],["stopColor","stop-color"],["stopOpacity","stop-opacity"],["strikethroughPosition","strikethrough-position"],["strikethroughThickness","strikethrough-thickness"],["strokeDasharray","stroke-dasharray"],["strokeDashoffset","stroke-dashoffset"],["strokeLinecap","stroke-linecap"],["strokeLinejoin","stroke-linejoin"],["strokeMiterlimit","stroke-miterlimit"],["strokeOpacity","stroke-opacity"],["strokeWidth","stroke-width"],["textAnchor","text-anchor"],["textDecoration","text-decoration"],["textRendering","text-rendering"],["transformOrigin","transform-origin"],["underlinePosition","underline-position"],["underlineThickness","underline-thickness"],["unicodeBidi","unicode-bidi"],["unicodeRange","unicode-range"],["unitsPerEm","units-per-em"],["vAlphabetic","v-alphabetic"],["vHanging","v-hanging"],["vIdeographic","v-ideographic"],["vMathematical","v-mathematical"],["vectorEffect","vector-effect"],["vertAdvY","vert-adv-y"],["vertOriginX","vert-origin-x"],["vertOriginY","vert-origin-y"],["wordSpacing","word-spacing"],["writingMode","writing-mode"],["xmlnsXlink","xmlns:xlink"],["xHeight","x-height"]]),Ze=/^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*:/i;function bt(n){return Ze.test(""+n)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":n}function pt(){}var $a=null;function Vs(n){return n=n.target||n.srcElement||window,n.correspondingUseElement&&(n=n.correspondingUseElement),n.nodeType===3?n.parentNode:n}var Gs=null,ss=null;function qg(n){var r=ra(n);if(r&&(n=r.stateNode)){var i=n[Zt]||null;e:switch(n=r.stateNode,r.type){case"input":if(Pt(n,i.value,i.defaultValue,i.defaultValue,i.checked,i.defaultChecked,i.type,i.name),r=i.name,i.type==="radio"&&r!=null){for(i=n;i.parentNode;)i=i.parentNode;for(i=i.querySelectorAll('input[name="'+Je(""+r)+'"][type="radio"]'),r=0;r<i.length;r++){var d=i[r];if(d!==n&&d.form===n.form){var x=d[Zt]||null;if(!x)throw Error(l(90));Pt(d,x.value,x.defaultValue,x.defaultValue,x.checked,x.defaultChecked,x.type,x.name)}}for(r=0;r<i.length;r++)d=i[r],d.form===n.form&&ue(d)}break e;case"textarea":as(n,i.value,i.defaultValue);break e;case"select":r=i.value,r!=null&&bn(n,!!i.multiple,r,!1)}}}var Vd=!1;function Vg(n,r,i){if(Vd)return n(r,i);Vd=!0;try{var d=n(r);return d}finally{if(Vd=!1,(Gs!==null||ss!==null)&&(ru(),Gs&&(r=Gs,n=ss,ss=Gs=null,qg(r),n)))for(r=0;r<n.length;r++)qg(n[r])}}function Mi(n,r){var i=n.stateNode;if(i===null)return null;var d=i[Zt]||null;if(d===null)return null;i=d[r];e:switch(r){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(d=!d.disabled)||(n=n.type,d=!(n==="button"||n==="input"||n==="select"||n==="textarea")),n=!d;break e;default:n=!1}if(n)return null;if(i&&typeof i!="function")throw Error(l(231,r,typeof i));return i}var _r=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Gd=!1;if(_r)try{var Ei={};Object.defineProperty(Ei,"passive",{get:function(){Gd=!0}}),window.addEventListener("test",Ei,Ei),window.removeEventListener("test",Ei,Ei)}catch{Gd=!1}var ls=null,Wd=null,yc=null;function Gg(){if(yc)return yc;var n,r=Wd,i=r.length,d,x="value"in ls?ls.value:ls.textContent,b=x.length;for(n=0;n<i&&r[n]===x[n];n++);var N=i-n;for(d=1;d<=N&&r[i-d]===x[b-d];d++);return yc=x.slice(n,1<d?1-d:void 0)}function vc(n){var r=n.keyCode;return"charCode"in n?(n=n.charCode,n===0&&r===13&&(n=13)):n=r,n===10&&(n=13),32<=n||n===13?n:0}function bc(){return!0}function Wg(){return!1}function la(n){function r(i,d,x,b,N){this._reactName=i,this._targetInst=x,this.type=d,this.nativeEvent=b,this.target=N,this.currentTarget=null;for(var L in n)n.hasOwnProperty(L)&&(i=n[L],this[L]=i?i(b):b[L]);return this.isDefaultPrevented=(b.defaultPrevented!=null?b.defaultPrevented:b.returnValue===!1)?bc:Wg,this.isPropagationStopped=Wg,this}return v(r.prototype,{preventDefault:function(){this.defaultPrevented=!0;var i=this.nativeEvent;i&&(i.preventDefault?i.preventDefault():typeof i.returnValue!="unknown"&&(i.returnValue=!1),this.isDefaultPrevented=bc)},stopPropagation:function(){var i=this.nativeEvent;i&&(i.stopPropagation?i.stopPropagation():typeof i.cancelBubble!="unknown"&&(i.cancelBubble=!0),this.isPropagationStopped=bc)},persist:function(){},isPersistent:bc}),r}var Ws={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(n){return n.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},kc=la(Ws),Ai=v({},Ws,{view:0,detail:0}),sj=la(Ai),Kd,Yd,Ri,wc=v({},Ai,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Xd,button:0,buttons:0,relatedTarget:function(n){return n.relatedTarget===void 0?n.fromElement===n.srcElement?n.toElement:n.fromElement:n.relatedTarget},movementX:function(n){return"movementX"in n?n.movementX:(n!==Ri&&(Ri&&n.type==="mousemove"?(Kd=n.screenX-Ri.screenX,Yd=n.screenY-Ri.screenY):Yd=Kd=0,Ri=n),Kd)},movementY:function(n){return"movementY"in n?n.movementY:Yd}}),Kg=la(wc),lj=v({},wc,{dataTransfer:0}),ij=la(lj),oj=v({},Ai,{relatedTarget:0}),Qd=la(oj),cj=v({},Ws,{animationName:0,elapsedTime:0,pseudoElement:0}),uj=la(cj),dj=v({},Ws,{clipboardData:function(n){return"clipboardData"in n?n.clipboardData:window.clipboardData}}),fj=la(dj),mj=v({},Ws,{data:0}),Yg=la(mj),pj={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},hj={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},gj={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function xj(n){var r=this.nativeEvent;return r.getModifierState?r.getModifierState(n):(n=gj[n])?!!r[n]:!1}function Xd(){return xj}var yj=v({},Ai,{key:function(n){if(n.key){var r=pj[n.key]||n.key;if(r!=="Unidentified")return r}return n.type==="keypress"?(n=vc(n),n===13?"Enter":String.fromCharCode(n)):n.type==="keydown"||n.type==="keyup"?hj[n.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Xd,charCode:function(n){return n.type==="keypress"?vc(n):0},keyCode:function(n){return n.type==="keydown"||n.type==="keyup"?n.keyCode:0},which:function(n){return n.type==="keypress"?vc(n):n.type==="keydown"||n.type==="keyup"?n.keyCode:0}}),vj=la(yj),bj=v({},wc,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Qg=la(bj),kj=v({},Ai,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Xd}),wj=la(kj),Sj=v({},Ws,{propertyName:0,elapsedTime:0,pseudoElement:0}),jj=la(Sj),Cj=v({},wc,{deltaX:function(n){return"deltaX"in n?n.deltaX:"wheelDeltaX"in n?-n.wheelDeltaX:0},deltaY:function(n){return"deltaY"in n?n.deltaY:"wheelDeltaY"in n?-n.wheelDeltaY:"wheelDelta"in n?-n.wheelDelta:0},deltaZ:0,deltaMode:0}),Nj=la(Cj),Tj=v({},Ws,{newState:0,oldState:0}),Mj=la(Tj),Ej=[9,13,27,32],Zd=_r&&"CompositionEvent"in window,_i=null;_r&&"documentMode"in document&&(_i=document.documentMode);var Aj=_r&&"TextEvent"in window&&!_i,Xg=_r&&(!Zd||_i&&8<_i&&11>=_i),Zg=" ",Jg=!1;function e0(n,r){switch(n){case"keyup":return Ej.indexOf(r.keyCode)!==-1;case"keydown":return r.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function t0(n){return n=n.detail,typeof n=="object"&&"data"in n?n.data:null}var El=!1;function Rj(n,r){switch(n){case"compositionend":return t0(r);case"keypress":return r.which!==32?null:(Jg=!0,Zg);case"textInput":return n=r.data,n===Zg&&Jg?null:n;default:return null}}function _j(n,r){if(El)return n==="compositionend"||!Zd&&e0(n,r)?(n=Gg(),yc=Wd=ls=null,El=!1,n):null;switch(n){case"paste":return null;case"keypress":if(!(r.ctrlKey||r.altKey||r.metaKey)||r.ctrlKey&&r.altKey){if(r.char&&1<r.char.length)return r.char;if(r.which)return String.fromCharCode(r.which)}return null;case"compositionend":return Xg&&r.locale!=="ko"?null:r.data;default:return null}}var Ij={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function n0(n){var r=n&&n.nodeName&&n.nodeName.toLowerCase();return r==="input"?!!Ij[n.type]:r==="textarea"}function a0(n,r,i,d){Gs?ss?ss.push(d):ss=[d]:Gs=d,r=du(r,"onChange"),0<r.length&&(i=new kc("onChange","change",null,i,d),n.push({event:i,listeners:r}))}var Ii=null,Li=null;function Lj(n){$y(n,0)}function Sc(n){var r=za(n);if(ue(r))return n}function r0(n,r){if(n==="change")return r}var s0=!1;if(_r){var Jd;if(_r){var ef="oninput"in document;if(!ef){var l0=document.createElement("div");l0.setAttribute("oninput","return;"),ef=typeof l0.oninput=="function"}Jd=ef}else Jd=!1;s0=Jd&&(!document.documentMode||9<document.documentMode)}function i0(){Ii&&(Ii.detachEvent("onpropertychange",o0),Li=Ii=null)}function o0(n){if(n.propertyName==="value"&&Sc(Li)){var r=[];a0(r,Li,n,Vs(n)),Vg(Lj,r)}}function Oj(n,r,i){n==="focusin"?(i0(),Ii=r,Li=i,Ii.attachEvent("onpropertychange",o0)):n==="focusout"&&i0()}function Dj(n){if(n==="selectionchange"||n==="keyup"||n==="keydown")return Sc(Li)}function zj(n,r){if(n==="click")return Sc(r)}function Uj(n,r){if(n==="input"||n==="change")return Sc(r)}function $j(n,r){return n===r&&(n!==0||1/n===1/r)||n!==n&&r!==r}var Sa=typeof Object.is=="function"?Object.is:$j;function Oi(n,r){if(Sa(n,r))return!0;if(typeof n!="object"||n===null||typeof r!="object"||r===null)return!1;var i=Object.keys(n),d=Object.keys(r);if(i.length!==d.length)return!1;for(d=0;d<i.length;d++){var x=i[d];if(!rn.call(r,x)||!Sa(n[x],r[x]))return!1}return!0}function c0(n){for(;n&&n.firstChild;)n=n.firstChild;return n}function u0(n,r){var i=c0(n);n=0;for(var d;i;){if(i.nodeType===3){if(d=n+i.textContent.length,n<=r&&d>=r)return{node:i,offset:r-n};n=d}e:{for(;i;){if(i.nextSibling){i=i.nextSibling;break e}i=i.parentNode}i=void 0}i=c0(i)}}function d0(n,r){return n&&r?n===r?!0:n&&n.nodeType===3?!1:r&&r.nodeType===3?d0(n,r.parentNode):"contains"in n?n.contains(r):n.compareDocumentPosition?!!(n.compareDocumentPosition(r)&16):!1:!1}function f0(n){n=n!=null&&n.ownerDocument!=null&&n.ownerDocument.defaultView!=null?n.ownerDocument.defaultView:window;for(var r=_e(n.document);r instanceof n.HTMLIFrameElement;){try{var i=typeof r.contentWindow.location.href=="string"}catch{i=!1}if(i)n=r.contentWindow;else break;r=_e(n.document)}return r}function tf(n){var r=n&&n.nodeName&&n.nodeName.toLowerCase();return r&&(r==="input"&&(n.type==="text"||n.type==="search"||n.type==="tel"||n.type==="url"||n.type==="password")||r==="textarea"||n.contentEditable==="true")}var Pj=_r&&"documentMode"in document&&11>=document.documentMode,Al=null,nf=null,Di=null,af=!1;function m0(n,r,i){var d=i.window===i?i.document:i.nodeType===9?i:i.ownerDocument;af||Al==null||Al!==_e(d)||(d=Al,"selectionStart"in d&&tf(d)?d={start:d.selectionStart,end:d.selectionEnd}:(d=(d.ownerDocument&&d.ownerDocument.defaultView||window).getSelection(),d={anchorNode:d.anchorNode,anchorOffset:d.anchorOffset,focusNode:d.focusNode,focusOffset:d.focusOffset}),Di&&Oi(Di,d)||(Di=d,d=du(nf,"onSelect"),0<d.length&&(r=new kc("onSelect","select",null,r,i),n.push({event:r,listeners:d}),r.target=Al)))}function Ks(n,r){var i={};return i[n.toLowerCase()]=r.toLowerCase(),i["Webkit"+n]="webkit"+r,i["Moz"+n]="moz"+r,i}var Rl={animationend:Ks("Animation","AnimationEnd"),animationiteration:Ks("Animation","AnimationIteration"),animationstart:Ks("Animation","AnimationStart"),transitionrun:Ks("Transition","TransitionRun"),transitionstart:Ks("Transition","TransitionStart"),transitioncancel:Ks("Transition","TransitionCancel"),transitionend:Ks("Transition","TransitionEnd")},rf={},p0={};_r&&(p0=document.createElement("div").style,"AnimationEvent"in window||(delete Rl.animationend.animation,delete Rl.animationiteration.animation,delete Rl.animationstart.animation),"TransitionEvent"in window||delete Rl.transitionend.transition);function Ys(n){if(rf[n])return rf[n];if(!Rl[n])return n;var r=Rl[n],i;for(i in r)if(r.hasOwnProperty(i)&&i in p0)return rf[n]=r[i];return n}var h0=Ys("animationend"),g0=Ys("animationiteration"),x0=Ys("animationstart"),Bj=Ys("transitionrun"),Hj=Ys("transitionstart"),Fj=Ys("transitioncancel"),y0=Ys("transitionend"),v0=new Map,sf="abort auxClick beforeToggle cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");sf.push("scrollEnd");function ir(n,r){v0.set(n,r),rt(r,[n])}var jc=typeof reportError=="function"?reportError:function(n){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var r=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof n=="object"&&n!==null&&typeof n.message=="string"?String(n.message):String(n),error:n});if(!window.dispatchEvent(r))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",n);return}console.error(n)},Pa=[],_l=0,lf=0;function Cc(){for(var n=_l,r=lf=_l=0;r<n;){var i=Pa[r];Pa[r++]=null;var d=Pa[r];Pa[r++]=null;var x=Pa[r];Pa[r++]=null;var b=Pa[r];if(Pa[r++]=null,d!==null&&x!==null){var N=d.pending;N===null?x.next=x:(x.next=N.next,N.next=x),d.pending=x}b!==0&&b0(i,x,b)}}function Nc(n,r,i,d){Pa[_l++]=n,Pa[_l++]=r,Pa[_l++]=i,Pa[_l++]=d,lf|=d,n.lanes|=d,n=n.alternate,n!==null&&(n.lanes|=d)}function of(n,r,i,d){return Nc(n,r,i,d),Tc(n)}function Qs(n,r){return Nc(n,null,null,r),Tc(n)}function b0(n,r,i){n.lanes|=i;var d=n.alternate;d!==null&&(d.lanes|=i);for(var x=!1,b=n.return;b!==null;)b.childLanes|=i,d=b.alternate,d!==null&&(d.childLanes|=i),b.tag===22&&(n=b.stateNode,n===null||n._visibility&1||(x=!0)),n=b,b=b.return;return n.tag===3?(b=n.stateNode,x&&r!==null&&(x=31-We(i),n=b.hiddenUpdates,d=n[x],d===null?n[x]=[r]:d.push(r),r.lane=i|536870912),b):null}function Tc(n){if(50<ro)throw ro=0,xm=null,Error(l(185));for(var r=n.return;r!==null;)n=r,r=n.return;return n.tag===3?n.stateNode:null}var Il={};function qj(n,r,i,d){this.tag=n,this.key=i,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=r,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=d,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function ja(n,r,i,d){return new qj(n,r,i,d)}function cf(n){return n=n.prototype,!(!n||!n.isReactComponent)}function Ir(n,r){var i=n.alternate;return i===null?(i=ja(n.tag,r,n.key,n.mode),i.elementType=n.elementType,i.type=n.type,i.stateNode=n.stateNode,i.alternate=n,n.alternate=i):(i.pendingProps=r,i.type=n.type,i.flags=0,i.subtreeFlags=0,i.deletions=null),i.flags=n.flags&65011712,i.childLanes=n.childLanes,i.lanes=n.lanes,i.child=n.child,i.memoizedProps=n.memoizedProps,i.memoizedState=n.memoizedState,i.updateQueue=n.updateQueue,r=n.dependencies,i.dependencies=r===null?null:{lanes:r.lanes,firstContext:r.firstContext},i.sibling=n.sibling,i.index=n.index,i.ref=n.ref,i.refCleanup=n.refCleanup,i}function k0(n,r){n.flags&=65011714;var i=n.alternate;return i===null?(n.childLanes=0,n.lanes=r,n.child=null,n.subtreeFlags=0,n.memoizedProps=null,n.memoizedState=null,n.updateQueue=null,n.dependencies=null,n.stateNode=null):(n.childLanes=i.childLanes,n.lanes=i.lanes,n.child=i.child,n.subtreeFlags=0,n.deletions=null,n.memoizedProps=i.memoizedProps,n.memoizedState=i.memoizedState,n.updateQueue=i.updateQueue,n.type=i.type,r=i.dependencies,n.dependencies=r===null?null:{lanes:r.lanes,firstContext:r.firstContext}),n}function Mc(n,r,i,d,x,b){var N=0;if(d=n,typeof n=="function")cf(n)&&(N=1);else if(typeof n=="string")N=Y5(n,i,U.current)?26:n==="html"||n==="head"||n==="body"?27:5;else e:switch(n){case K:return n=ja(31,i,r,x),n.elementType=K,n.lanes=b,n;case E:return Xs(i.children,x,b,r);case C:N=8,x|=24;break;case M:return n=ja(12,i,r,x|2),n.elementType=M,n.lanes=b,n;case F:return n=ja(13,i,r,x),n.elementType=F,n.lanes=b,n;case A:return n=ja(19,i,r,x),n.elementType=A,n.lanes=b,n;default:if(typeof n=="object"&&n!==null)switch(n.$$typeof){case D:N=10;break e;case _:N=9;break e;case V:N=11;break e;case P:N=14;break e;case Q:N=16,d=null;break e}N=29,i=Error(l(130,n===null?"null":typeof n,"")),d=null}return r=ja(N,i,r,x),r.elementType=n,r.type=d,r.lanes=b,r}function Xs(n,r,i,d){return n=ja(7,n,d,r),n.lanes=i,n}function uf(n,r,i){return n=ja(6,n,null,r),n.lanes=i,n}function w0(n){var r=ja(18,null,null,0);return r.stateNode=n,r}function df(n,r,i){return r=ja(4,n.children!==null?n.children:[],n.key,r),r.lanes=i,r.stateNode={containerInfo:n.containerInfo,pendingChildren:null,implementation:n.implementation},r}var S0=new WeakMap;function Ba(n,r){if(typeof n=="object"&&n!==null){var i=S0.get(n);return i!==void 0?i:(r={value:n,source:r,stack:an(r)},S0.set(n,r),r)}return{value:n,source:r,stack:an(r)}}var Ll=[],Ol=0,Ec=null,zi=0,Ha=[],Fa=0,is=null,yr=1,vr="";function Lr(n,r){Ll[Ol++]=zi,Ll[Ol++]=Ec,Ec=n,zi=r}function j0(n,r,i){Ha[Fa++]=yr,Ha[Fa++]=vr,Ha[Fa++]=is,is=n;var d=yr;n=vr;var x=32-We(d)-1;d&=~(1<<x),i+=1;var b=32-We(r)+x;if(30<b){var N=x-x%5;b=(d&(1<<N)-1).toString(32),d>>=N,x-=N,yr=1<<32-We(r)+x|i<<x|d,vr=b+n}else yr=1<<b|i<<x|d,vr=n}function ff(n){n.return!==null&&(Lr(n,1),j0(n,1,0))}function mf(n){for(;n===Ec;)Ec=Ll[--Ol],Ll[Ol]=null,zi=Ll[--Ol],Ll[Ol]=null;for(;n===is;)is=Ha[--Fa],Ha[Fa]=null,vr=Ha[--Fa],Ha[Fa]=null,yr=Ha[--Fa],Ha[Fa]=null}function C0(n,r){Ha[Fa++]=yr,Ha[Fa++]=vr,Ha[Fa++]=is,yr=r.id,vr=r.overflow,is=n}var In=null,Kt=null,yt=!1,os=null,qa=!1,pf=Error(l(519));function cs(n){var r=Error(l(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw Ui(Ba(r,n)),pf}function N0(n){var r=n.stateNode,i=n.type,d=n.memoizedProps;switch(r[qt]=n,r[Zt]=d,i){case"dialog":ft("cancel",r),ft("close",r);break;case"iframe":case"object":case"embed":ft("load",r);break;case"video":case"audio":for(i=0;i<lo.length;i++)ft(lo[i],r);break;case"source":ft("error",r);break;case"img":case"image":case"link":ft("error",r),ft("load",r);break;case"details":ft("toggle",r);break;case"input":ft("invalid",r),Wt(r,d.value,d.defaultValue,d.checked,d.defaultChecked,d.type,d.name,!0);break;case"select":ft("invalid",r);break;case"textarea":ft("invalid",r),rs(r,d.value,d.defaultValue,d.children)}i=d.children,typeof i!="string"&&typeof i!="number"&&typeof i!="bigint"||r.textContent===""+i||d.suppressHydrationWarning===!0||Fy(r.textContent,i)?(d.popover!=null&&(ft("beforetoggle",r),ft("toggle",r)),d.onScroll!=null&&ft("scroll",r),d.onScrollEnd!=null&&ft("scrollend",r),d.onClick!=null&&(r.onclick=pt),r=!0):r=!1,r||cs(n,!0)}function T0(n){for(In=n.return;In;)switch(In.tag){case 5:case 31:case 13:qa=!1;return;case 27:case 3:qa=!0;return;default:In=In.return}}function Dl(n){if(n!==In)return!1;if(!yt)return T0(n),yt=!0,!1;var r=n.tag,i;if((i=r!==3&&r!==27)&&((i=r===5)&&(i=n.type,i=!(i!=="form"&&i!=="button")||_m(n.type,n.memoizedProps)),i=!i),i&&Kt&&cs(n),T0(n),r===13){if(n=n.memoizedState,n=n!==null?n.dehydrated:null,!n)throw Error(l(317));Kt=Zy(n)}else if(r===31){if(n=n.memoizedState,n=n!==null?n.dehydrated:null,!n)throw Error(l(317));Kt=Zy(n)}else r===27?(r=Kt,Ss(n.type)?(n=zm,zm=null,Kt=n):Kt=r):Kt=In?Ga(n.stateNode.nextSibling):null;return!0}function Zs(){Kt=In=null,yt=!1}function hf(){var n=os;return n!==null&&(ua===null?ua=n:ua.push.apply(ua,n),os=null),n}function Ui(n){os===null?os=[n]:os.push(n)}var gf=R(null),Js=null,Or=null;function us(n,r,i){S(gf,r._currentValue),r._currentValue=i}function Dr(n){n._currentValue=gf.current,H(gf)}function xf(n,r,i){for(;n!==null;){var d=n.alternate;if((n.childLanes&r)!==r?(n.childLanes|=r,d!==null&&(d.childLanes|=r)):d!==null&&(d.childLanes&r)!==r&&(d.childLanes|=r),n===i)break;n=n.return}}function yf(n,r,i,d){var x=n.child;for(x!==null&&(x.return=n);x!==null;){var b=x.dependencies;if(b!==null){var N=x.child;b=b.firstContext;e:for(;b!==null;){var L=b;b=x;for(var Y=0;Y<r.length;Y++)if(L.context===r[Y]){b.lanes|=i,L=b.alternate,L!==null&&(L.lanes|=i),xf(b.return,i,n),d||(N=null);break e}b=L.next}}else if(x.tag===18){if(N=x.return,N===null)throw Error(l(341));N.lanes|=i,b=N.alternate,b!==null&&(b.lanes|=i),xf(N,i,n),N=null}else N=x.child;if(N!==null)N.return=x;else for(N=x;N!==null;){if(N===n){N=null;break}if(x=N.sibling,x!==null){x.return=N.return,N=x;break}N=N.return}x=N}}function zl(n,r,i,d){n=null;for(var x=r,b=!1;x!==null;){if(!b){if((x.flags&524288)!==0)b=!0;else if((x.flags&262144)!==0)break}if(x.tag===10){var N=x.alternate;if(N===null)throw Error(l(387));if(N=N.memoizedProps,N!==null){var L=x.type;Sa(x.pendingProps.value,N.value)||(n!==null?n.push(L):n=[L])}}else if(x===de.current){if(N=x.alternate,N===null)throw Error(l(387));N.memoizedState.memoizedState!==x.memoizedState.memoizedState&&(n!==null?n.push(fo):n=[fo])}x=x.return}n!==null&&yf(r,n,i,d),r.flags|=262144}function Ac(n){for(n=n.firstContext;n!==null;){if(!Sa(n.context._currentValue,n.memoizedValue))return!0;n=n.next}return!1}function el(n){Js=n,Or=null,n=n.dependencies,n!==null&&(n.firstContext=null)}function Ln(n){return M0(Js,n)}function Rc(n,r){return Js===null&&el(n),M0(n,r)}function M0(n,r){var i=r._currentValue;if(r={context:r,memoizedValue:i,next:null},Or===null){if(n===null)throw Error(l(308));Or=r,n.dependencies={lanes:0,firstContext:r},n.flags|=524288}else Or=Or.next=r;return i}var Vj=typeof AbortController<"u"?AbortController:function(){var n=[],r=this.signal={aborted:!1,addEventListener:function(i,d){n.push(d)}};this.abort=function(){r.aborted=!0,n.forEach(function(i){return i()})}},Gj=e.unstable_scheduleCallback,Wj=e.unstable_NormalPriority,kn={$$typeof:D,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function vf(){return{controller:new Vj,data:new Map,refCount:0}}function $i(n){n.refCount--,n.refCount===0&&Gj(Wj,function(){n.controller.abort()})}var Pi=null,bf=0,Ul=0,$l=null;function Kj(n,r){if(Pi===null){var i=Pi=[];bf=0,Ul=Sm(),$l={status:"pending",value:void 0,then:function(d){i.push(d)}}}return bf++,r.then(E0,E0),r}function E0(){if(--bf===0&&Pi!==null){$l!==null&&($l.status="fulfilled");var n=Pi;Pi=null,Ul=0,$l=null;for(var r=0;r<n.length;r++)(0,n[r])()}}function Yj(n,r){var i=[],d={status:"pending",value:null,reason:null,then:function(x){i.push(x)}};return n.then(function(){d.status="fulfilled",d.value=r;for(var x=0;x<i.length;x++)(0,i[x])(r)},function(x){for(d.status="rejected",d.reason=x,x=0;x<i.length;x++)(0,i[x])(void 0)}),d}var A0=q.S;q.S=function(n,r){my=st(),typeof r=="object"&&r!==null&&typeof r.then=="function"&&Kj(n,r),A0!==null&&A0(n,r)};var tl=R(null);function kf(){var n=tl.current;return n!==null?n:Bt.pooledCache}function _c(n,r){r===null?S(tl,tl.current):S(tl,r.pool)}function R0(){var n=kf();return n===null?null:{parent:kn._currentValue,pool:n}}var Pl=Error(l(460)),wf=Error(l(474)),Ic=Error(l(542)),Lc={then:function(){}};function _0(n){return n=n.status,n==="fulfilled"||n==="rejected"}function I0(n,r,i){switch(i=n[i],i===void 0?n.push(r):i!==r&&(r.then(pt,pt),r=i),r.status){case"fulfilled":return r.value;case"rejected":throw n=r.reason,O0(n),n;default:if(typeof r.status=="string")r.then(pt,pt);else{if(n=Bt,n!==null&&100<n.shellSuspendCounter)throw Error(l(482));n=r,n.status="pending",n.then(function(d){if(r.status==="pending"){var x=r;x.status="fulfilled",x.value=d}},function(d){if(r.status==="pending"){var x=r;x.status="rejected",x.reason=d}})}switch(r.status){case"fulfilled":return r.value;case"rejected":throw n=r.reason,O0(n),n}throw al=r,Pl}}function nl(n){try{var r=n._init;return r(n._payload)}catch(i){throw i!==null&&typeof i=="object"&&typeof i.then=="function"?(al=i,Pl):i}}var al=null;function L0(){if(al===null)throw Error(l(459));var n=al;return al=null,n}function O0(n){if(n===Pl||n===Ic)throw Error(l(483))}var Bl=null,Bi=0;function Oc(n){var r=Bi;return Bi+=1,Bl===null&&(Bl=[]),I0(Bl,n,r)}function Hi(n,r){r=r.props.ref,n.ref=r!==void 0?r:null}function Dc(n,r){throw r.$$typeof===k?Error(l(525)):(n=Object.prototype.toString.call(r),Error(l(31,n==="[object Object]"?"object with keys {"+Object.keys(r).join(", ")+"}":n)))}function D0(n){function r(ne,J){if(n){var re=ne.deletions;re===null?(ne.deletions=[J],ne.flags|=16):re.push(J)}}function i(ne,J){if(!n)return null;for(;J!==null;)r(ne,J),J=J.sibling;return null}function d(ne){for(var J=new Map;ne!==null;)ne.key!==null?J.set(ne.key,ne):J.set(ne.index,ne),ne=ne.sibling;return J}function x(ne,J){return ne=Ir(ne,J),ne.index=0,ne.sibling=null,ne}function b(ne,J,re){return ne.index=re,n?(re=ne.alternate,re!==null?(re=re.index,re<J?(ne.flags|=67108866,J):re):(ne.flags|=67108866,J)):(ne.flags|=1048576,J)}function N(ne){return n&&ne.alternate===null&&(ne.flags|=67108866),ne}function L(ne,J,re,ve){return J===null||J.tag!==6?(J=uf(re,ne.mode,ve),J.return=ne,J):(J=x(J,re),J.return=ne,J)}function Y(ne,J,re,ve){var Ge=re.type;return Ge===E?xe(ne,J,re.props.children,ve,re.key):J!==null&&(J.elementType===Ge||typeof Ge=="object"&&Ge!==null&&Ge.$$typeof===Q&&nl(Ge)===J.type)?(J=x(J,re.props),Hi(J,re),J.return=ne,J):(J=Mc(re.type,re.key,re.props,null,ne.mode,ve),Hi(J,re),J.return=ne,J)}function se(ne,J,re,ve){return J===null||J.tag!==4||J.stateNode.containerInfo!==re.containerInfo||J.stateNode.implementation!==re.implementation?(J=df(re,ne.mode,ve),J.return=ne,J):(J=x(J,re.children||[]),J.return=ne,J)}function xe(ne,J,re,ve,Ge){return J===null||J.tag!==7?(J=Xs(re,ne.mode,ve,Ge),J.return=ne,J):(J=x(J,re),J.return=ne,J)}function ke(ne,J,re){if(typeof J=="string"&&J!==""||typeof J=="number"||typeof J=="bigint")return J=uf(""+J,ne.mode,re),J.return=ne,J;if(typeof J=="object"&&J!==null){switch(J.$$typeof){case w:return re=Mc(J.type,J.key,J.props,null,ne.mode,re),Hi(re,J),re.return=ne,re;case j:return J=df(J,ne.mode,re),J.return=ne,J;case Q:return J=nl(J),ke(ne,J,re)}if(G(J)||I(J))return J=Xs(J,ne.mode,re,null),J.return=ne,J;if(typeof J.then=="function")return ke(ne,Oc(J),re);if(J.$$typeof===D)return ke(ne,Rc(ne,J),re);Dc(ne,J)}return null}function oe(ne,J,re,ve){var Ge=J!==null?J.key:null;if(typeof re=="string"&&re!==""||typeof re=="number"||typeof re=="bigint")return Ge!==null?null:L(ne,J,""+re,ve);if(typeof re=="object"&&re!==null){switch(re.$$typeof){case w:return re.key===Ge?Y(ne,J,re,ve):null;case j:return re.key===Ge?se(ne,J,re,ve):null;case Q:return re=nl(re),oe(ne,J,re,ve)}if(G(re)||I(re))return Ge!==null?null:xe(ne,J,re,ve,null);if(typeof re.then=="function")return oe(ne,J,Oc(re),ve);if(re.$$typeof===D)return oe(ne,J,Rc(ne,re),ve);Dc(ne,re)}return null}function fe(ne,J,re,ve,Ge){if(typeof ve=="string"&&ve!==""||typeof ve=="number"||typeof ve=="bigint")return ne=ne.get(re)||null,L(J,ne,""+ve,Ge);if(typeof ve=="object"&&ve!==null){switch(ve.$$typeof){case w:return ne=ne.get(ve.key===null?re:ve.key)||null,Y(J,ne,ve,Ge);case j:return ne=ne.get(ve.key===null?re:ve.key)||null,se(J,ne,ve,Ge);case Q:return ve=nl(ve),fe(ne,J,re,ve,Ge)}if(G(ve)||I(ve))return ne=ne.get(re)||null,xe(J,ne,ve,Ge,null);if(typeof ve.then=="function")return fe(ne,J,re,Oc(ve),Ge);if(ve.$$typeof===D)return fe(ne,J,re,Rc(J,ve),Ge);Dc(J,ve)}return null}function $e(ne,J,re,ve){for(var Ge=null,Nt=null,Be=J,ct=J=0,gt=null;Be!==null&&ct<re.length;ct++){Be.index>ct?(gt=Be,Be=null):gt=Be.sibling;var Tt=oe(ne,Be,re[ct],ve);if(Tt===null){Be===null&&(Be=gt);break}n&&Be&&Tt.alternate===null&&r(ne,Be),J=b(Tt,J,ct),Nt===null?Ge=Tt:Nt.sibling=Tt,Nt=Tt,Be=gt}if(ct===re.length)return i(ne,Be),yt&&Lr(ne,ct),Ge;if(Be===null){for(;ct<re.length;ct++)Be=ke(ne,re[ct],ve),Be!==null&&(J=b(Be,J,ct),Nt===null?Ge=Be:Nt.sibling=Be,Nt=Be);return yt&&Lr(ne,ct),Ge}for(Be=d(Be);ct<re.length;ct++)gt=fe(Be,ne,ct,re[ct],ve),gt!==null&&(n&&gt.alternate!==null&&Be.delete(gt.key===null?ct:gt.key),J=b(gt,J,ct),Nt===null?Ge=gt:Nt.sibling=gt,Nt=gt);return n&&Be.forEach(function(Ms){return r(ne,Ms)}),yt&&Lr(ne,ct),Ge}function Xe(ne,J,re,ve){if(re==null)throw Error(l(151));for(var Ge=null,Nt=null,Be=J,ct=J=0,gt=null,Tt=re.next();Be!==null&&!Tt.done;ct++,Tt=re.next()){Be.index>ct?(gt=Be,Be=null):gt=Be.sibling;var Ms=oe(ne,Be,Tt.value,ve);if(Ms===null){Be===null&&(Be=gt);break}n&&Be&&Ms.alternate===null&&r(ne,Be),J=b(Ms,J,ct),Nt===null?Ge=Ms:Nt.sibling=Ms,Nt=Ms,Be=gt}if(Tt.done)return i(ne,Be),yt&&Lr(ne,ct),Ge;if(Be===null){for(;!Tt.done;ct++,Tt=re.next())Tt=ke(ne,Tt.value,ve),Tt!==null&&(J=b(Tt,J,ct),Nt===null?Ge=Tt:Nt.sibling=Tt,Nt=Tt);return yt&&Lr(ne,ct),Ge}for(Be=d(Be);!Tt.done;ct++,Tt=re.next())Tt=fe(Be,ne,ct,Tt.value,ve),Tt!==null&&(n&&Tt.alternate!==null&&Be.delete(Tt.key===null?ct:Tt.key),J=b(Tt,J,ct),Nt===null?Ge=Tt:Nt.sibling=Tt,Nt=Tt);return n&&Be.forEach(function(lC){return r(ne,lC)}),yt&&Lr(ne,ct),Ge}function zt(ne,J,re,ve){if(typeof re=="object"&&re!==null&&re.type===E&&re.key===null&&(re=re.props.children),typeof re=="object"&&re!==null){switch(re.$$typeof){case w:e:{for(var Ge=re.key;J!==null;){if(J.key===Ge){if(Ge=re.type,Ge===E){if(J.tag===7){i(ne,J.sibling),ve=x(J,re.props.children),ve.return=ne,ne=ve;break e}}else if(J.elementType===Ge||typeof Ge=="object"&&Ge!==null&&Ge.$$typeof===Q&&nl(Ge)===J.type){i(ne,J.sibling),ve=x(J,re.props),Hi(ve,re),ve.return=ne,ne=ve;break e}i(ne,J);break}else r(ne,J);J=J.sibling}re.type===E?(ve=Xs(re.props.children,ne.mode,ve,re.key),ve.return=ne,ne=ve):(ve=Mc(re.type,re.key,re.props,null,ne.mode,ve),Hi(ve,re),ve.return=ne,ne=ve)}return N(ne);case j:e:{for(Ge=re.key;J!==null;){if(J.key===Ge)if(J.tag===4&&J.stateNode.containerInfo===re.containerInfo&&J.stateNode.implementation===re.implementation){i(ne,J.sibling),ve=x(J,re.children||[]),ve.return=ne,ne=ve;break e}else{i(ne,J);break}else r(ne,J);J=J.sibling}ve=df(re,ne.mode,ve),ve.return=ne,ne=ve}return N(ne);case Q:return re=nl(re),zt(ne,J,re,ve)}if(G(re))return $e(ne,J,re,ve);if(I(re)){if(Ge=I(re),typeof Ge!="function")throw Error(l(150));return re=Ge.call(re),Xe(ne,J,re,ve)}if(typeof re.then=="function")return zt(ne,J,Oc(re),ve);if(re.$$typeof===D)return zt(ne,J,Rc(ne,re),ve);Dc(ne,re)}return typeof re=="string"&&re!==""||typeof re=="number"||typeof re=="bigint"?(re=""+re,J!==null&&J.tag===6?(i(ne,J.sibling),ve=x(J,re),ve.return=ne,ne=ve):(i(ne,J),ve=uf(re,ne.mode,ve),ve.return=ne,ne=ve),N(ne)):i(ne,J)}return function(ne,J,re,ve){try{Bi=0;var Ge=zt(ne,J,re,ve);return Bl=null,Ge}catch(Be){if(Be===Pl||Be===Ic)throw Be;var Nt=ja(29,Be,null,ne.mode);return Nt.lanes=ve,Nt.return=ne,Nt}}}var rl=D0(!0),z0=D0(!1),ds=!1;function Sf(n){n.updateQueue={baseState:n.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function jf(n,r){n=n.updateQueue,r.updateQueue===n&&(r.updateQueue={baseState:n.baseState,firstBaseUpdate:n.firstBaseUpdate,lastBaseUpdate:n.lastBaseUpdate,shared:n.shared,callbacks:null})}function fs(n){return{lane:n,tag:0,payload:null,callback:null,next:null}}function ms(n,r,i){var d=n.updateQueue;if(d===null)return null;if(d=d.shared,(Mt&2)!==0){var x=d.pending;return x===null?r.next=r:(r.next=x.next,x.next=r),d.pending=r,r=Tc(n),b0(n,null,i),r}return Nc(n,d,r,i),Tc(n)}function Fi(n,r,i){if(r=r.updateQueue,r!==null&&(r=r.shared,(i&4194048)!==0)){var d=r.lanes;d&=n.pendingLanes,i|=d,r.lanes=i,Yn(n,i)}}function Cf(n,r){var i=n.updateQueue,d=n.alternate;if(d!==null&&(d=d.updateQueue,i===d)){var x=null,b=null;if(i=i.firstBaseUpdate,i!==null){do{var N={lane:i.lane,tag:i.tag,payload:i.payload,callback:null,next:null};b===null?x=b=N:b=b.next=N,i=i.next}while(i!==null);b===null?x=b=r:b=b.next=r}else x=b=r;i={baseState:d.baseState,firstBaseUpdate:x,lastBaseUpdate:b,shared:d.shared,callbacks:d.callbacks},n.updateQueue=i;return}n=i.lastBaseUpdate,n===null?i.firstBaseUpdate=r:n.next=r,i.lastBaseUpdate=r}var Nf=!1;function qi(){if(Nf){var n=$l;if(n!==null)throw n}}function Vi(n,r,i,d){Nf=!1;var x=n.updateQueue;ds=!1;var b=x.firstBaseUpdate,N=x.lastBaseUpdate,L=x.shared.pending;if(L!==null){x.shared.pending=null;var Y=L,se=Y.next;Y.next=null,N===null?b=se:N.next=se,N=Y;var xe=n.alternate;xe!==null&&(xe=xe.updateQueue,L=xe.lastBaseUpdate,L!==N&&(L===null?xe.firstBaseUpdate=se:L.next=se,xe.lastBaseUpdate=Y))}if(b!==null){var ke=x.baseState;N=0,xe=se=Y=null,L=b;do{var oe=L.lane&-536870913,fe=oe!==L.lane;if(fe?(ht&oe)===oe:(d&oe)===oe){oe!==0&&oe===Ul&&(Nf=!0),xe!==null&&(xe=xe.next={lane:0,tag:L.tag,payload:L.payload,callback:null,next:null});e:{var $e=n,Xe=L;oe=r;var zt=i;switch(Xe.tag){case 1:if($e=Xe.payload,typeof $e=="function"){ke=$e.call(zt,ke,oe);break e}ke=$e;break e;case 3:$e.flags=$e.flags&-65537|128;case 0:if($e=Xe.payload,oe=typeof $e=="function"?$e.call(zt,ke,oe):$e,oe==null)break e;ke=v({},ke,oe);break e;case 2:ds=!0}}oe=L.callback,oe!==null&&(n.flags|=64,fe&&(n.flags|=8192),fe=x.callbacks,fe===null?x.callbacks=[oe]:fe.push(oe))}else fe={lane:oe,tag:L.tag,payload:L.payload,callback:L.callback,next:null},xe===null?(se=xe=fe,Y=ke):xe=xe.next=fe,N|=oe;if(L=L.next,L===null){if(L=x.shared.pending,L===null)break;fe=L,L=fe.next,fe.next=null,x.lastBaseUpdate=fe,x.shared.pending=null}}while(!0);xe===null&&(Y=ke),x.baseState=Y,x.firstBaseUpdate=se,x.lastBaseUpdate=xe,b===null&&(x.shared.lanes=0),ys|=N,n.lanes=N,n.memoizedState=ke}}function U0(n,r){if(typeof n!="function")throw Error(l(191,n));n.call(r)}function $0(n,r){var i=n.callbacks;if(i!==null)for(n.callbacks=null,n=0;n<i.length;n++)U0(i[n],r)}var Hl=R(null),zc=R(0);function P0(n,r){n=Vr,S(zc,n),S(Hl,r),Vr=n|r.baseLanes}function Tf(){S(zc,Vr),S(Hl,Hl.current)}function Mf(){Vr=zc.current,H(Hl),H(zc)}var Ca=R(null),Va=null;function ps(n){var r=n.alternate;S(mn,mn.current&1),S(Ca,n),Va===null&&(r===null||Hl.current!==null||r.memoizedState!==null)&&(Va=n)}function Ef(n){S(mn,mn.current),S(Ca,n),Va===null&&(Va=n)}function B0(n){n.tag===22?(S(mn,mn.current),S(Ca,n),Va===null&&(Va=n)):hs()}function hs(){S(mn,mn.current),S(Ca,Ca.current)}function Na(n){H(Ca),Va===n&&(Va=null),H(mn)}var mn=R(0);function Uc(n){for(var r=n;r!==null;){if(r.tag===13){var i=r.memoizedState;if(i!==null&&(i=i.dehydrated,i===null||Om(i)||Dm(i)))return r}else if(r.tag===19&&(r.memoizedProps.revealOrder==="forwards"||r.memoizedProps.revealOrder==="backwards"||r.memoizedProps.revealOrder==="unstable_legacy-backwards"||r.memoizedProps.revealOrder==="together")){if((r.flags&128)!==0)return r}else if(r.child!==null){r.child.return=r,r=r.child;continue}if(r===n)break;for(;r.sibling===null;){if(r.return===null||r.return===n)return null;r=r.return}r.sibling.return=r.return,r=r.sibling}return null}var zr=0,lt=null,Ot=null,wn=null,$c=!1,Fl=!1,sl=!1,Pc=0,Gi=0,ql=null,Qj=0;function cn(){throw Error(l(321))}function Af(n,r){if(r===null)return!1;for(var i=0;i<r.length&&i<n.length;i++)if(!Sa(n[i],r[i]))return!1;return!0}function Rf(n,r,i,d,x,b){return zr=b,lt=r,r.memoizedState=null,r.updateQueue=null,r.lanes=0,q.H=n===null||n.memoizedState===null?jx:Gf,sl=!1,b=i(d,x),sl=!1,Fl&&(b=F0(r,i,d,x)),H0(n),b}function H0(n){q.H=Yi;var r=Ot!==null&&Ot.next!==null;if(zr=0,wn=Ot=lt=null,$c=!1,Gi=0,ql=null,r)throw Error(l(300));n===null||Sn||(n=n.dependencies,n!==null&&Ac(n)&&(Sn=!0))}function F0(n,r,i,d){lt=n;var x=0;do{if(Fl&&(ql=null),Gi=0,Fl=!1,25<=x)throw Error(l(301));if(x+=1,wn=Ot=null,n.updateQueue!=null){var b=n.updateQueue;b.lastEffect=null,b.events=null,b.stores=null,b.memoCache!=null&&(b.memoCache.index=0)}q.H=Cx,b=r(i,d)}while(Fl);return b}function Xj(){var n=q.H,r=n.useState()[0];return r=typeof r.then=="function"?Wi(r):r,n=n.useState()[0],(Ot!==null?Ot.memoizedState:null)!==n&&(lt.flags|=1024),r}function _f(){var n=Pc!==0;return Pc=0,n}function If(n,r,i){r.updateQueue=n.updateQueue,r.flags&=-2053,n.lanes&=~i}function Lf(n){if($c){for(n=n.memoizedState;n!==null;){var r=n.queue;r!==null&&(r.pending=null),n=n.next}$c=!1}zr=0,wn=Ot=lt=null,Fl=!1,Gi=Pc=0,ql=null}function Zn(){var n={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return wn===null?lt.memoizedState=wn=n:wn=wn.next=n,wn}function pn(){if(Ot===null){var n=lt.alternate;n=n!==null?n.memoizedState:null}else n=Ot.next;var r=wn===null?lt.memoizedState:wn.next;if(r!==null)wn=r,Ot=n;else{if(n===null)throw lt.alternate===null?Error(l(467)):Error(l(310));Ot=n,n={memoizedState:Ot.memoizedState,baseState:Ot.baseState,baseQueue:Ot.baseQueue,queue:Ot.queue,next:null},wn===null?lt.memoizedState=wn=n:wn=wn.next=n}return wn}function Bc(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function Wi(n){var r=Gi;return Gi+=1,ql===null&&(ql=[]),n=I0(ql,n,r),r=lt,(wn===null?r.memoizedState:wn.next)===null&&(r=r.alternate,q.H=r===null||r.memoizedState===null?jx:Gf),n}function Hc(n){if(n!==null&&typeof n=="object"){if(typeof n.then=="function")return Wi(n);if(n.$$typeof===D)return Ln(n)}throw Error(l(438,String(n)))}function Of(n){var r=null,i=lt.updateQueue;if(i!==null&&(r=i.memoCache),r==null){var d=lt.alternate;d!==null&&(d=d.updateQueue,d!==null&&(d=d.memoCache,d!=null&&(r={data:d.data.map(function(x){return x.slice()}),index:0})))}if(r==null&&(r={data:[],index:0}),i===null&&(i=Bc(),lt.updateQueue=i),i.memoCache=r,i=r.data[r.index],i===void 0)for(i=r.data[r.index]=Array(n),d=0;d<n;d++)i[d]=O;return r.index++,i}function Ur(n,r){return typeof r=="function"?r(n):r}function Fc(n){var r=pn();return Df(r,Ot,n)}function Df(n,r,i){var d=n.queue;if(d===null)throw Error(l(311));d.lastRenderedReducer=i;var x=n.baseQueue,b=d.pending;if(b!==null){if(x!==null){var N=x.next;x.next=b.next,b.next=N}r.baseQueue=x=b,d.pending=null}if(b=n.baseState,x===null)n.memoizedState=b;else{r=x.next;var L=N=null,Y=null,se=r,xe=!1;do{var ke=se.lane&-536870913;if(ke!==se.lane?(ht&ke)===ke:(zr&ke)===ke){var oe=se.revertLane;if(oe===0)Y!==null&&(Y=Y.next={lane:0,revertLane:0,gesture:null,action:se.action,hasEagerState:se.hasEagerState,eagerState:se.eagerState,next:null}),ke===Ul&&(xe=!0);else if((zr&oe)===oe){se=se.next,oe===Ul&&(xe=!0);continue}else ke={lane:0,revertLane:se.revertLane,gesture:null,action:se.action,hasEagerState:se.hasEagerState,eagerState:se.eagerState,next:null},Y===null?(L=Y=ke,N=b):Y=Y.next=ke,lt.lanes|=oe,ys|=oe;ke=se.action,sl&&i(b,ke),b=se.hasEagerState?se.eagerState:i(b,ke)}else oe={lane:ke,revertLane:se.revertLane,gesture:se.gesture,action:se.action,hasEagerState:se.hasEagerState,eagerState:se.eagerState,next:null},Y===null?(L=Y=oe,N=b):Y=Y.next=oe,lt.lanes|=ke,ys|=ke;se=se.next}while(se!==null&&se!==r);if(Y===null?N=b:Y.next=L,!Sa(b,n.memoizedState)&&(Sn=!0,xe&&(i=$l,i!==null)))throw i;n.memoizedState=b,n.baseState=N,n.baseQueue=Y,d.lastRenderedState=b}return x===null&&(d.lanes=0),[n.memoizedState,d.dispatch]}function zf(n){var r=pn(),i=r.queue;if(i===null)throw Error(l(311));i.lastRenderedReducer=n;var d=i.dispatch,x=i.pending,b=r.memoizedState;if(x!==null){i.pending=null;var N=x=x.next;do b=n(b,N.action),N=N.next;while(N!==x);Sa(b,r.memoizedState)||(Sn=!0),r.memoizedState=b,r.baseQueue===null&&(r.baseState=b),i.lastRenderedState=b}return[b,d]}function q0(n,r,i){var d=lt,x=pn(),b=yt;if(b){if(i===void 0)throw Error(l(407));i=i()}else i=r();var N=!Sa((Ot||x).memoizedState,i);if(N&&(x.memoizedState=i,Sn=!0),x=x.queue,Pf(W0.bind(null,d,x,n),[n]),x.getSnapshot!==r||N||wn!==null&&wn.memoizedState.tag&1){if(d.flags|=2048,Vl(9,{destroy:void 0},G0.bind(null,d,x,i,r),null),Bt===null)throw Error(l(349));b||(zr&127)!==0||V0(d,r,i)}return i}function V0(n,r,i){n.flags|=16384,n={getSnapshot:r,value:i},r=lt.updateQueue,r===null?(r=Bc(),lt.updateQueue=r,r.stores=[n]):(i=r.stores,i===null?r.stores=[n]:i.push(n))}function G0(n,r,i,d){r.value=i,r.getSnapshot=d,K0(r)&&Y0(n)}function W0(n,r,i){return i(function(){K0(r)&&Y0(n)})}function K0(n){var r=n.getSnapshot;n=n.value;try{var i=r();return!Sa(n,i)}catch{return!0}}function Y0(n){var r=Qs(n,2);r!==null&&da(r,n,2)}function Uf(n){var r=Zn();if(typeof n=="function"){var i=n;if(n=i(),sl){Pe(!0);try{i()}finally{Pe(!1)}}}return r.memoizedState=r.baseState=n,r.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ur,lastRenderedState:n},r}function Q0(n,r,i,d){return n.baseState=i,Df(n,Ot,typeof d=="function"?d:Ur)}function Zj(n,r,i,d,x){if(Gc(n))throw Error(l(485));if(n=r.action,n!==null){var b={payload:x,action:n,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(N){b.listeners.push(N)}};q.T!==null?i(!0):b.isTransition=!1,d(b),i=r.pending,i===null?(b.next=r.pending=b,X0(r,b)):(b.next=i.next,r.pending=i.next=b)}}function X0(n,r){var i=r.action,d=r.payload,x=n.state;if(r.isTransition){var b=q.T,N={};q.T=N;try{var L=i(x,d),Y=q.S;Y!==null&&Y(N,L),Z0(n,r,L)}catch(se){$f(n,r,se)}finally{b!==null&&N.types!==null&&(b.types=N.types),q.T=b}}else try{b=i(x,d),Z0(n,r,b)}catch(se){$f(n,r,se)}}function Z0(n,r,i){i!==null&&typeof i=="object"&&typeof i.then=="function"?i.then(function(d){J0(n,r,d)},function(d){return $f(n,r,d)}):J0(n,r,i)}function J0(n,r,i){r.status="fulfilled",r.value=i,ex(r),n.state=i,r=n.pending,r!==null&&(i=r.next,i===r?n.pending=null:(i=i.next,r.next=i,X0(n,i)))}function $f(n,r,i){var d=n.pending;if(n.pending=null,d!==null){d=d.next;do r.status="rejected",r.reason=i,ex(r),r=r.next;while(r!==d)}n.action=null}function ex(n){n=n.listeners;for(var r=0;r<n.length;r++)(0,n[r])()}function tx(n,r){return r}function nx(n,r){if(yt){var i=Bt.formState;if(i!==null){e:{var d=lt;if(yt){if(Kt){t:{for(var x=Kt,b=qa;x.nodeType!==8;){if(!b){x=null;break t}if(x=Ga(x.nextSibling),x===null){x=null;break t}}b=x.data,x=b==="F!"||b==="F"?x:null}if(x){Kt=Ga(x.nextSibling),d=x.data==="F!";break e}}cs(d)}d=!1}d&&(r=i[0])}}return i=Zn(),i.memoizedState=i.baseState=r,d={pending:null,lanes:0,dispatch:null,lastRenderedReducer:tx,lastRenderedState:r},i.queue=d,i=kx.bind(null,lt,d),d.dispatch=i,d=Uf(!1),b=Vf.bind(null,lt,!1,d.queue),d=Zn(),x={state:r,dispatch:null,action:n,pending:null},d.queue=x,i=Zj.bind(null,lt,x,b,i),x.dispatch=i,d.memoizedState=n,[r,i,!1]}function ax(n){var r=pn();return rx(r,Ot,n)}function rx(n,r,i){if(r=Df(n,r,tx)[0],n=Fc(Ur)[0],typeof r=="object"&&r!==null&&typeof r.then=="function")try{var d=Wi(r)}catch(N){throw N===Pl?Ic:N}else d=r;r=pn();var x=r.queue,b=x.dispatch;return i!==r.memoizedState&&(lt.flags|=2048,Vl(9,{destroy:void 0},Jj.bind(null,x,i),null)),[d,b,n]}function Jj(n,r){n.action=r}function sx(n){var r=pn(),i=Ot;if(i!==null)return rx(r,i,n);pn(),r=r.memoizedState,i=pn();var d=i.queue.dispatch;return i.memoizedState=n,[r,d,!1]}function Vl(n,r,i,d){return n={tag:n,create:i,deps:d,inst:r,next:null},r=lt.updateQueue,r===null&&(r=Bc(),lt.updateQueue=r),i=r.lastEffect,i===null?r.lastEffect=n.next=n:(d=i.next,i.next=n,n.next=d,r.lastEffect=n),n}function lx(){return pn().memoizedState}function qc(n,r,i,d){var x=Zn();lt.flags|=n,x.memoizedState=Vl(1|r,{destroy:void 0},i,d===void 0?null:d)}function Vc(n,r,i,d){var x=pn();d=d===void 0?null:d;var b=x.memoizedState.inst;Ot!==null&&d!==null&&Af(d,Ot.memoizedState.deps)?x.memoizedState=Vl(r,b,i,d):(lt.flags|=n,x.memoizedState=Vl(1|r,b,i,d))}function ix(n,r){qc(8390656,8,n,r)}function Pf(n,r){Vc(2048,8,n,r)}function e5(n){lt.flags|=4;var r=lt.updateQueue;if(r===null)r=Bc(),lt.updateQueue=r,r.events=[n];else{var i=r.events;i===null?r.events=[n]:i.push(n)}}function ox(n){var r=pn().memoizedState;return e5({ref:r,nextImpl:n}),function(){if((Mt&2)!==0)throw Error(l(440));return r.impl.apply(void 0,arguments)}}function cx(n,r){return Vc(4,2,n,r)}function ux(n,r){return Vc(4,4,n,r)}function dx(n,r){if(typeof r=="function"){n=n();var i=r(n);return function(){typeof i=="function"?i():r(null)}}if(r!=null)return n=n(),r.current=n,function(){r.current=null}}function fx(n,r,i){i=i!=null?i.concat([n]):null,Vc(4,4,dx.bind(null,r,n),i)}function Bf(){}function mx(n,r){var i=pn();r=r===void 0?null:r;var d=i.memoizedState;return r!==null&&Af(r,d[1])?d[0]:(i.memoizedState=[n,r],n)}function px(n,r){var i=pn();r=r===void 0?null:r;var d=i.memoizedState;if(r!==null&&Af(r,d[1]))return d[0];if(d=n(),sl){Pe(!0);try{n()}finally{Pe(!1)}}return i.memoizedState=[d,r],d}function Hf(n,r,i){return i===void 0||(zr&1073741824)!==0&&(ht&261930)===0?n.memoizedState=r:(n.memoizedState=i,n=hy(),lt.lanes|=n,ys|=n,i)}function hx(n,r,i,d){return Sa(i,r)?i:Hl.current!==null?(n=Hf(n,i,d),Sa(n,r)||(Sn=!0),n):(zr&42)===0||(zr&1073741824)!==0&&(ht&261930)===0?(Sn=!0,n.memoizedState=i):(n=hy(),lt.lanes|=n,ys|=n,r)}function gx(n,r,i,d,x){var b=ae.p;ae.p=b!==0&&8>b?b:8;var N=q.T,L={};q.T=L,Vf(n,!1,r,i);try{var Y=x(),se=q.S;if(se!==null&&se(L,Y),Y!==null&&typeof Y=="object"&&typeof Y.then=="function"){var xe=Yj(Y,d);Ki(n,r,xe,Ea(n))}else Ki(n,r,d,Ea(n))}catch(ke){Ki(n,r,{then:function(){},status:"rejected",reason:ke},Ea())}finally{ae.p=b,N!==null&&L.types!==null&&(N.types=L.types),q.T=N}}function t5(){}function Ff(n,r,i,d){if(n.tag!==5)throw Error(l(476));var x=xx(n).queue;gx(n,x,r,Z,i===null?t5:function(){return yx(n),i(d)})}function xx(n){var r=n.memoizedState;if(r!==null)return r;r={memoizedState:Z,baseState:Z,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ur,lastRenderedState:Z},next:null};var i={};return r.next={memoizedState:i,baseState:i,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ur,lastRenderedState:i},next:null},n.memoizedState=r,n=n.alternate,n!==null&&(n.memoizedState=r),r}function yx(n){var r=xx(n);r.next===null&&(r=n.alternate.memoizedState),Ki(n,r.next.queue,{},Ea())}function qf(){return Ln(fo)}function vx(){return pn().memoizedState}function bx(){return pn().memoizedState}function n5(n){for(var r=n.return;r!==null;){switch(r.tag){case 24:case 3:var i=Ea();n=fs(i);var d=ms(r,n,i);d!==null&&(da(d,r,i),Fi(d,r,i)),r={cache:vf()},n.payload=r;return}r=r.return}}function a5(n,r,i){var d=Ea();i={lane:d,revertLane:0,gesture:null,action:i,hasEagerState:!1,eagerState:null,next:null},Gc(n)?wx(r,i):(i=of(n,r,i,d),i!==null&&(da(i,n,d),Sx(i,r,d)))}function kx(n,r,i){var d=Ea();Ki(n,r,i,d)}function Ki(n,r,i,d){var x={lane:d,revertLane:0,gesture:null,action:i,hasEagerState:!1,eagerState:null,next:null};if(Gc(n))wx(r,x);else{var b=n.alternate;if(n.lanes===0&&(b===null||b.lanes===0)&&(b=r.lastRenderedReducer,b!==null))try{var N=r.lastRenderedState,L=b(N,i);if(x.hasEagerState=!0,x.eagerState=L,Sa(L,N))return Nc(n,r,x,0),Bt===null&&Cc(),!1}catch{}if(i=of(n,r,x,d),i!==null)return da(i,n,d),Sx(i,r,d),!0}return!1}function Vf(n,r,i,d){if(d={lane:2,revertLane:Sm(),gesture:null,action:d,hasEagerState:!1,eagerState:null,next:null},Gc(n)){if(r)throw Error(l(479))}else r=of(n,i,d,2),r!==null&&da(r,n,2)}function Gc(n){var r=n.alternate;return n===lt||r!==null&&r===lt}function wx(n,r){Fl=$c=!0;var i=n.pending;i===null?r.next=r:(r.next=i.next,i.next=r),n.pending=r}function Sx(n,r,i){if((i&4194048)!==0){var d=r.lanes;d&=n.pendingLanes,i|=d,r.lanes=i,Yn(n,i)}}var Yi={readContext:Ln,use:Hc,useCallback:cn,useContext:cn,useEffect:cn,useImperativeHandle:cn,useLayoutEffect:cn,useInsertionEffect:cn,useMemo:cn,useReducer:cn,useRef:cn,useState:cn,useDebugValue:cn,useDeferredValue:cn,useTransition:cn,useSyncExternalStore:cn,useId:cn,useHostTransitionStatus:cn,useFormState:cn,useActionState:cn,useOptimistic:cn,useMemoCache:cn,useCacheRefresh:cn};Yi.useEffectEvent=cn;var jx={readContext:Ln,use:Hc,useCallback:function(n,r){return Zn().memoizedState=[n,r===void 0?null:r],n},useContext:Ln,useEffect:ix,useImperativeHandle:function(n,r,i){i=i!=null?i.concat([n]):null,qc(4194308,4,dx.bind(null,r,n),i)},useLayoutEffect:function(n,r){return qc(4194308,4,n,r)},useInsertionEffect:function(n,r){qc(4,2,n,r)},useMemo:function(n,r){var i=Zn();r=r===void 0?null:r;var d=n();if(sl){Pe(!0);try{n()}finally{Pe(!1)}}return i.memoizedState=[d,r],d},useReducer:function(n,r,i){var d=Zn();if(i!==void 0){var x=i(r);if(sl){Pe(!0);try{i(r)}finally{Pe(!1)}}}else x=r;return d.memoizedState=d.baseState=x,n={pending:null,lanes:0,dispatch:null,lastRenderedReducer:n,lastRenderedState:x},d.queue=n,n=n.dispatch=a5.bind(null,lt,n),[d.memoizedState,n]},useRef:function(n){var r=Zn();return n={current:n},r.memoizedState=n},useState:function(n){n=Uf(n);var r=n.queue,i=kx.bind(null,lt,r);return r.dispatch=i,[n.memoizedState,i]},useDebugValue:Bf,useDeferredValue:function(n,r){var i=Zn();return Hf(i,n,r)},useTransition:function(){var n=Uf(!1);return n=gx.bind(null,lt,n.queue,!0,!1),Zn().memoizedState=n,[!1,n]},useSyncExternalStore:function(n,r,i){var d=lt,x=Zn();if(yt){if(i===void 0)throw Error(l(407));i=i()}else{if(i=r(),Bt===null)throw Error(l(349));(ht&127)!==0||V0(d,r,i)}x.memoizedState=i;var b={value:i,getSnapshot:r};return x.queue=b,ix(W0.bind(null,d,b,n),[n]),d.flags|=2048,Vl(9,{destroy:void 0},G0.bind(null,d,b,i,r),null),i},useId:function(){var n=Zn(),r=Bt.identifierPrefix;if(yt){var i=vr,d=yr;i=(d&~(1<<32-We(d)-1)).toString(32)+i,r="_"+r+"R_"+i,i=Pc++,0<i&&(r+="H"+i.toString(32)),r+="_"}else i=Qj++,r="_"+r+"r_"+i.toString(32)+"_";return n.memoizedState=r},useHostTransitionStatus:qf,useFormState:nx,useActionState:nx,useOptimistic:function(n){var r=Zn();r.memoizedState=r.baseState=n;var i={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return r.queue=i,r=Vf.bind(null,lt,!0,i),i.dispatch=r,[n,r]},useMemoCache:Of,useCacheRefresh:function(){return Zn().memoizedState=n5.bind(null,lt)},useEffectEvent:function(n){var r=Zn(),i={impl:n};return r.memoizedState=i,function(){if((Mt&2)!==0)throw Error(l(440));return i.impl.apply(void 0,arguments)}}},Gf={readContext:Ln,use:Hc,useCallback:mx,useContext:Ln,useEffect:Pf,useImperativeHandle:fx,useInsertionEffect:cx,useLayoutEffect:ux,useMemo:px,useReducer:Fc,useRef:lx,useState:function(){return Fc(Ur)},useDebugValue:Bf,useDeferredValue:function(n,r){var i=pn();return hx(i,Ot.memoizedState,n,r)},useTransition:function(){var n=Fc(Ur)[0],r=pn().memoizedState;return[typeof n=="boolean"?n:Wi(n),r]},useSyncExternalStore:q0,useId:vx,useHostTransitionStatus:qf,useFormState:ax,useActionState:ax,useOptimistic:function(n,r){var i=pn();return Q0(i,Ot,n,r)},useMemoCache:Of,useCacheRefresh:bx};Gf.useEffectEvent=ox;var Cx={readContext:Ln,use:Hc,useCallback:mx,useContext:Ln,useEffect:Pf,useImperativeHandle:fx,useInsertionEffect:cx,useLayoutEffect:ux,useMemo:px,useReducer:zf,useRef:lx,useState:function(){return zf(Ur)},useDebugValue:Bf,useDeferredValue:function(n,r){var i=pn();return Ot===null?Hf(i,n,r):hx(i,Ot.memoizedState,n,r)},useTransition:function(){var n=zf(Ur)[0],r=pn().memoizedState;return[typeof n=="boolean"?n:Wi(n),r]},useSyncExternalStore:q0,useId:vx,useHostTransitionStatus:qf,useFormState:sx,useActionState:sx,useOptimistic:function(n,r){var i=pn();return Ot!==null?Q0(i,Ot,n,r):(i.baseState=n,[n,i.queue.dispatch])},useMemoCache:Of,useCacheRefresh:bx};Cx.useEffectEvent=ox;function Wf(n,r,i,d){r=n.memoizedState,i=i(d,r),i=i==null?r:v({},r,i),n.memoizedState=i,n.lanes===0&&(n.updateQueue.baseState=i)}var Kf={enqueueSetState:function(n,r,i){n=n._reactInternals;var d=Ea(),x=fs(d);x.payload=r,i!=null&&(x.callback=i),r=ms(n,x,d),r!==null&&(da(r,n,d),Fi(r,n,d))},enqueueReplaceState:function(n,r,i){n=n._reactInternals;var d=Ea(),x=fs(d);x.tag=1,x.payload=r,i!=null&&(x.callback=i),r=ms(n,x,d),r!==null&&(da(r,n,d),Fi(r,n,d))},enqueueForceUpdate:function(n,r){n=n._reactInternals;var i=Ea(),d=fs(i);d.tag=2,r!=null&&(d.callback=r),r=ms(n,d,i),r!==null&&(da(r,n,i),Fi(r,n,i))}};function Nx(n,r,i,d,x,b,N){return n=n.stateNode,typeof n.shouldComponentUpdate=="function"?n.shouldComponentUpdate(d,b,N):r.prototype&&r.prototype.isPureReactComponent?!Oi(i,d)||!Oi(x,b):!0}function Tx(n,r,i,d){n=r.state,typeof r.componentWillReceiveProps=="function"&&r.componentWillReceiveProps(i,d),typeof r.UNSAFE_componentWillReceiveProps=="function"&&r.UNSAFE_componentWillReceiveProps(i,d),r.state!==n&&Kf.enqueueReplaceState(r,r.state,null)}function ll(n,r){var i=r;if("ref"in r){i={};for(var d in r)d!=="ref"&&(i[d]=r[d])}if(n=n.defaultProps){i===r&&(i=v({},i));for(var x in n)i[x]===void 0&&(i[x]=n[x])}return i}function Mx(n){jc(n)}function Ex(n){console.error(n)}function Ax(n){jc(n)}function Wc(n,r){try{var i=n.onUncaughtError;i(r.value,{componentStack:r.stack})}catch(d){setTimeout(function(){throw d})}}function Rx(n,r,i){try{var d=n.onCaughtError;d(i.value,{componentStack:i.stack,errorBoundary:r.tag===1?r.stateNode:null})}catch(x){setTimeout(function(){throw x})}}function Yf(n,r,i){return i=fs(i),i.tag=3,i.payload={element:null},i.callback=function(){Wc(n,r)},i}function _x(n){return n=fs(n),n.tag=3,n}function Ix(n,r,i,d){var x=i.type.getDerivedStateFromError;if(typeof x=="function"){var b=d.value;n.payload=function(){return x(b)},n.callback=function(){Rx(r,i,d)}}var N=i.stateNode;N!==null&&typeof N.componentDidCatch=="function"&&(n.callback=function(){Rx(r,i,d),typeof x!="function"&&(vs===null?vs=new Set([this]):vs.add(this));var L=d.stack;this.componentDidCatch(d.value,{componentStack:L!==null?L:""})})}function r5(n,r,i,d,x){if(i.flags|=32768,d!==null&&typeof d=="object"&&typeof d.then=="function"){if(r=i.alternate,r!==null&&zl(r,i,x,!0),i=Ca.current,i!==null){switch(i.tag){case 31:case 13:return Va===null?su():i.alternate===null&&un===0&&(un=3),i.flags&=-257,i.flags|=65536,i.lanes=x,d===Lc?i.flags|=16384:(r=i.updateQueue,r===null?i.updateQueue=new Set([d]):r.add(d),bm(n,d,x)),!1;case 22:return i.flags|=65536,d===Lc?i.flags|=16384:(r=i.updateQueue,r===null?(r={transitions:null,markerInstances:null,retryQueue:new Set([d])},i.updateQueue=r):(i=r.retryQueue,i===null?r.retryQueue=new Set([d]):i.add(d)),bm(n,d,x)),!1}throw Error(l(435,i.tag))}return bm(n,d,x),su(),!1}if(yt)return r=Ca.current,r!==null?((r.flags&65536)===0&&(r.flags|=256),r.flags|=65536,r.lanes=x,d!==pf&&(n=Error(l(422),{cause:d}),Ui(Ba(n,i)))):(d!==pf&&(r=Error(l(423),{cause:d}),Ui(Ba(r,i))),n=n.current.alternate,n.flags|=65536,x&=-x,n.lanes|=x,d=Ba(d,i),x=Yf(n.stateNode,d,x),Cf(n,x),un!==4&&(un=2)),!1;var b=Error(l(520),{cause:d});if(b=Ba(b,i),ao===null?ao=[b]:ao.push(b),un!==4&&(un=2),r===null)return!0;d=Ba(d,i),i=r;do{switch(i.tag){case 3:return i.flags|=65536,n=x&-x,i.lanes|=n,n=Yf(i.stateNode,d,n),Cf(i,n),!1;case 1:if(r=i.type,b=i.stateNode,(i.flags&128)===0&&(typeof r.getDerivedStateFromError=="function"||b!==null&&typeof b.componentDidCatch=="function"&&(vs===null||!vs.has(b))))return i.flags|=65536,x&=-x,i.lanes|=x,x=_x(x),Ix(x,n,i,d),Cf(i,x),!1}i=i.return}while(i!==null);return!1}var Qf=Error(l(461)),Sn=!1;function On(n,r,i,d){r.child=n===null?z0(r,null,i,d):rl(r,n.child,i,d)}function Lx(n,r,i,d,x){i=i.render;var b=r.ref;if("ref"in d){var N={};for(var L in d)L!=="ref"&&(N[L]=d[L])}else N=d;return el(r),d=Rf(n,r,i,N,b,x),L=_f(),n!==null&&!Sn?(If(n,r,x),$r(n,r,x)):(yt&&L&&ff(r),r.flags|=1,On(n,r,d,x),r.child)}function Ox(n,r,i,d,x){if(n===null){var b=i.type;return typeof b=="function"&&!cf(b)&&b.defaultProps===void 0&&i.compare===null?(r.tag=15,r.type=b,Dx(n,r,b,d,x)):(n=Mc(i.type,null,d,r,r.mode,x),n.ref=r.ref,n.return=r,r.child=n)}if(b=n.child,!rm(n,x)){var N=b.memoizedProps;if(i=i.compare,i=i!==null?i:Oi,i(N,d)&&n.ref===r.ref)return $r(n,r,x)}return r.flags|=1,n=Ir(b,d),n.ref=r.ref,n.return=r,r.child=n}function Dx(n,r,i,d,x){if(n!==null){var b=n.memoizedProps;if(Oi(b,d)&&n.ref===r.ref)if(Sn=!1,r.pendingProps=d=b,rm(n,x))(n.flags&131072)!==0&&(Sn=!0);else return r.lanes=n.lanes,$r(n,r,x)}return Xf(n,r,i,d,x)}function zx(n,r,i,d){var x=d.children,b=n!==null?n.memoizedState:null;if(n===null&&r.stateNode===null&&(r.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),d.mode==="hidden"){if((r.flags&128)!==0){if(b=b!==null?b.baseLanes|i:i,n!==null){for(d=r.child=n.child,x=0;d!==null;)x=x|d.lanes|d.childLanes,d=d.sibling;d=x&~b}else d=0,r.child=null;return Ux(n,r,b,i,d)}if((i&536870912)!==0)r.memoizedState={baseLanes:0,cachePool:null},n!==null&&_c(r,b!==null?b.cachePool:null),b!==null?P0(r,b):Tf(),B0(r);else return d=r.lanes=536870912,Ux(n,r,b!==null?b.baseLanes|i:i,i,d)}else b!==null?(_c(r,b.cachePool),P0(r,b),hs(),r.memoizedState=null):(n!==null&&_c(r,null),Tf(),hs());return On(n,r,x,i),r.child}function Qi(n,r){return n!==null&&n.tag===22||r.stateNode!==null||(r.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),r.sibling}function Ux(n,r,i,d,x){var b=kf();return b=b===null?null:{parent:kn._currentValue,pool:b},r.memoizedState={baseLanes:i,cachePool:b},n!==null&&_c(r,null),Tf(),B0(r),n!==null&&zl(n,r,d,!0),r.childLanes=x,null}function Kc(n,r){return r=Qc({mode:r.mode,children:r.children},n.mode),r.ref=n.ref,n.child=r,r.return=n,r}function $x(n,r,i){return rl(r,n.child,null,i),n=Kc(r,r.pendingProps),n.flags|=2,Na(r),r.memoizedState=null,n}function s5(n,r,i){var d=r.pendingProps,x=(r.flags&128)!==0;if(r.flags&=-129,n===null){if(yt){if(d.mode==="hidden")return n=Kc(r,d),r.lanes=536870912,Qi(null,n);if(Ef(r),(n=Kt)?(n=Xy(n,qa),n=n!==null&&n.data==="&"?n:null,n!==null&&(r.memoizedState={dehydrated:n,treeContext:is!==null?{id:yr,overflow:vr}:null,retryLane:536870912,hydrationErrors:null},i=w0(n),i.return=r,r.child=i,In=r,Kt=null)):n=null,n===null)throw cs(r);return r.lanes=536870912,null}return Kc(r,d)}var b=n.memoizedState;if(b!==null){var N=b.dehydrated;if(Ef(r),x)if(r.flags&256)r.flags&=-257,r=$x(n,r,i);else if(r.memoizedState!==null)r.child=n.child,r.flags|=128,r=null;else throw Error(l(558));else if(Sn||zl(n,r,i,!1),x=(i&n.childLanes)!==0,Sn||x){if(d=Bt,d!==null&&(N=ts(d,i),N!==0&&N!==b.retryLane))throw b.retryLane=N,Qs(n,N),da(d,n,N),Qf;su(),r=$x(n,r,i)}else n=b.treeContext,Kt=Ga(N.nextSibling),In=r,yt=!0,os=null,qa=!1,n!==null&&C0(r,n),r=Kc(r,d),r.flags|=4096;return r}return n=Ir(n.child,{mode:d.mode,children:d.children}),n.ref=r.ref,r.child=n,n.return=r,n}function Yc(n,r){var i=r.ref;if(i===null)n!==null&&n.ref!==null&&(r.flags|=4194816);else{if(typeof i!="function"&&typeof i!="object")throw Error(l(284));(n===null||n.ref!==i)&&(r.flags|=4194816)}}function Xf(n,r,i,d,x){return el(r),i=Rf(n,r,i,d,void 0,x),d=_f(),n!==null&&!Sn?(If(n,r,x),$r(n,r,x)):(yt&&d&&ff(r),r.flags|=1,On(n,r,i,x),r.child)}function Px(n,r,i,d,x,b){return el(r),r.updateQueue=null,i=F0(r,d,i,x),H0(n),d=_f(),n!==null&&!Sn?(If(n,r,b),$r(n,r,b)):(yt&&d&&ff(r),r.flags|=1,On(n,r,i,b),r.child)}function Bx(n,r,i,d,x){if(el(r),r.stateNode===null){var b=Il,N=i.contextType;typeof N=="object"&&N!==null&&(b=Ln(N)),b=new i(d,b),r.memoizedState=b.state!==null&&b.state!==void 0?b.state:null,b.updater=Kf,r.stateNode=b,b._reactInternals=r,b=r.stateNode,b.props=d,b.state=r.memoizedState,b.refs={},Sf(r),N=i.contextType,b.context=typeof N=="object"&&N!==null?Ln(N):Il,b.state=r.memoizedState,N=i.getDerivedStateFromProps,typeof N=="function"&&(Wf(r,i,N,d),b.state=r.memoizedState),typeof i.getDerivedStateFromProps=="function"||typeof b.getSnapshotBeforeUpdate=="function"||typeof b.UNSAFE_componentWillMount!="function"&&typeof b.componentWillMount!="function"||(N=b.state,typeof b.componentWillMount=="function"&&b.componentWillMount(),typeof b.UNSAFE_componentWillMount=="function"&&b.UNSAFE_componentWillMount(),N!==b.state&&Kf.enqueueReplaceState(b,b.state,null),Vi(r,d,b,x),qi(),b.state=r.memoizedState),typeof b.componentDidMount=="function"&&(r.flags|=4194308),d=!0}else if(n===null){b=r.stateNode;var L=r.memoizedProps,Y=ll(i,L);b.props=Y;var se=b.context,xe=i.contextType;N=Il,typeof xe=="object"&&xe!==null&&(N=Ln(xe));var ke=i.getDerivedStateFromProps;xe=typeof ke=="function"||typeof b.getSnapshotBeforeUpdate=="function",L=r.pendingProps!==L,xe||typeof b.UNSAFE_componentWillReceiveProps!="function"&&typeof b.componentWillReceiveProps!="function"||(L||se!==N)&&Tx(r,b,d,N),ds=!1;var oe=r.memoizedState;b.state=oe,Vi(r,d,b,x),qi(),se=r.memoizedState,L||oe!==se||ds?(typeof ke=="function"&&(Wf(r,i,ke,d),se=r.memoizedState),(Y=ds||Nx(r,i,Y,d,oe,se,N))?(xe||typeof b.UNSAFE_componentWillMount!="function"&&typeof b.componentWillMount!="function"||(typeof b.componentWillMount=="function"&&b.componentWillMount(),typeof b.UNSAFE_componentWillMount=="function"&&b.UNSAFE_componentWillMount()),typeof b.componentDidMount=="function"&&(r.flags|=4194308)):(typeof b.componentDidMount=="function"&&(r.flags|=4194308),r.memoizedProps=d,r.memoizedState=se),b.props=d,b.state=se,b.context=N,d=Y):(typeof b.componentDidMount=="function"&&(r.flags|=4194308),d=!1)}else{b=r.stateNode,jf(n,r),N=r.memoizedProps,xe=ll(i,N),b.props=xe,ke=r.pendingProps,oe=b.context,se=i.contextType,Y=Il,typeof se=="object"&&se!==null&&(Y=Ln(se)),L=i.getDerivedStateFromProps,(se=typeof L=="function"||typeof b.getSnapshotBeforeUpdate=="function")||typeof b.UNSAFE_componentWillReceiveProps!="function"&&typeof b.componentWillReceiveProps!="function"||(N!==ke||oe!==Y)&&Tx(r,b,d,Y),ds=!1,oe=r.memoizedState,b.state=oe,Vi(r,d,b,x),qi();var fe=r.memoizedState;N!==ke||oe!==fe||ds||n!==null&&n.dependencies!==null&&Ac(n.dependencies)?(typeof L=="function"&&(Wf(r,i,L,d),fe=r.memoizedState),(xe=ds||Nx(r,i,xe,d,oe,fe,Y)||n!==null&&n.dependencies!==null&&Ac(n.dependencies))?(se||typeof b.UNSAFE_componentWillUpdate!="function"&&typeof b.componentWillUpdate!="function"||(typeof b.componentWillUpdate=="function"&&b.componentWillUpdate(d,fe,Y),typeof b.UNSAFE_componentWillUpdate=="function"&&b.UNSAFE_componentWillUpdate(d,fe,Y)),typeof b.componentDidUpdate=="function"&&(r.flags|=4),typeof b.getSnapshotBeforeUpdate=="function"&&(r.flags|=1024)):(typeof b.componentDidUpdate!="function"||N===n.memoizedProps&&oe===n.memoizedState||(r.flags|=4),typeof b.getSnapshotBeforeUpdate!="function"||N===n.memoizedProps&&oe===n.memoizedState||(r.flags|=1024),r.memoizedProps=d,r.memoizedState=fe),b.props=d,b.state=fe,b.context=Y,d=xe):(typeof b.componentDidUpdate!="function"||N===n.memoizedProps&&oe===n.memoizedState||(r.flags|=4),typeof b.getSnapshotBeforeUpdate!="function"||N===n.memoizedProps&&oe===n.memoizedState||(r.flags|=1024),d=!1)}return b=d,Yc(n,r),d=(r.flags&128)!==0,b||d?(b=r.stateNode,i=d&&typeof i.getDerivedStateFromError!="function"?null:b.render(),r.flags|=1,n!==null&&d?(r.child=rl(r,n.child,null,x),r.child=rl(r,null,i,x)):On(n,r,i,x),r.memoizedState=b.state,n=r.child):n=$r(n,r,x),n}function Hx(n,r,i,d){return Zs(),r.flags|=256,On(n,r,i,d),r.child}var Zf={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function Jf(n){return{baseLanes:n,cachePool:R0()}}function em(n,r,i){return n=n!==null?n.childLanes&~i:0,r&&(n|=Ma),n}function Fx(n,r,i){var d=r.pendingProps,x=!1,b=(r.flags&128)!==0,N;if((N=b)||(N=n!==null&&n.memoizedState===null?!1:(mn.current&2)!==0),N&&(x=!0,r.flags&=-129),N=(r.flags&32)!==0,r.flags&=-33,n===null){if(yt){if(x?ps(r):hs(),(n=Kt)?(n=Xy(n,qa),n=n!==null&&n.data!=="&"?n:null,n!==null&&(r.memoizedState={dehydrated:n,treeContext:is!==null?{id:yr,overflow:vr}:null,retryLane:536870912,hydrationErrors:null},i=w0(n),i.return=r,r.child=i,In=r,Kt=null)):n=null,n===null)throw cs(r);return Dm(n)?r.lanes=32:r.lanes=536870912,null}var L=d.children;return d=d.fallback,x?(hs(),x=r.mode,L=Qc({mode:"hidden",children:L},x),d=Xs(d,x,i,null),L.return=r,d.return=r,L.sibling=d,r.child=L,d=r.child,d.memoizedState=Jf(i),d.childLanes=em(n,N,i),r.memoizedState=Zf,Qi(null,d)):(ps(r),tm(r,L))}var Y=n.memoizedState;if(Y!==null&&(L=Y.dehydrated,L!==null)){if(b)r.flags&256?(ps(r),r.flags&=-257,r=nm(n,r,i)):r.memoizedState!==null?(hs(),r.child=n.child,r.flags|=128,r=null):(hs(),L=d.fallback,x=r.mode,d=Qc({mode:"visible",children:d.children},x),L=Xs(L,x,i,null),L.flags|=2,d.return=r,L.return=r,d.sibling=L,r.child=d,rl(r,n.child,null,i),d=r.child,d.memoizedState=Jf(i),d.childLanes=em(n,N,i),r.memoizedState=Zf,r=Qi(null,d));else if(ps(r),Dm(L)){if(N=L.nextSibling&&L.nextSibling.dataset,N)var se=N.dgst;N=se,d=Error(l(419)),d.stack="",d.digest=N,Ui({value:d,source:null,stack:null}),r=nm(n,r,i)}else if(Sn||zl(n,r,i,!1),N=(i&n.childLanes)!==0,Sn||N){if(N=Bt,N!==null&&(d=ts(N,i),d!==0&&d!==Y.retryLane))throw Y.retryLane=d,Qs(n,d),da(N,n,d),Qf;Om(L)||su(),r=nm(n,r,i)}else Om(L)?(r.flags|=192,r.child=n.child,r=null):(n=Y.treeContext,Kt=Ga(L.nextSibling),In=r,yt=!0,os=null,qa=!1,n!==null&&C0(r,n),r=tm(r,d.children),r.flags|=4096);return r}return x?(hs(),L=d.fallback,x=r.mode,Y=n.child,se=Y.sibling,d=Ir(Y,{mode:"hidden",children:d.children}),d.subtreeFlags=Y.subtreeFlags&65011712,se!==null?L=Ir(se,L):(L=Xs(L,x,i,null),L.flags|=2),L.return=r,d.return=r,d.sibling=L,r.child=d,Qi(null,d),d=r.child,L=n.child.memoizedState,L===null?L=Jf(i):(x=L.cachePool,x!==null?(Y=kn._currentValue,x=x.parent!==Y?{parent:Y,pool:Y}:x):x=R0(),L={baseLanes:L.baseLanes|i,cachePool:x}),d.memoizedState=L,d.childLanes=em(n,N,i),r.memoizedState=Zf,Qi(n.child,d)):(ps(r),i=n.child,n=i.sibling,i=Ir(i,{mode:"visible",children:d.children}),i.return=r,i.sibling=null,n!==null&&(N=r.deletions,N===null?(r.deletions=[n],r.flags|=16):N.push(n)),r.child=i,r.memoizedState=null,i)}function tm(n,r){return r=Qc({mode:"visible",children:r},n.mode),r.return=n,n.child=r}function Qc(n,r){return n=ja(22,n,null,r),n.lanes=0,n}function nm(n,r,i){return rl(r,n.child,null,i),n=tm(r,r.pendingProps.children),n.flags|=2,r.memoizedState=null,n}function qx(n,r,i){n.lanes|=r;var d=n.alternate;d!==null&&(d.lanes|=r),xf(n.return,r,i)}function am(n,r,i,d,x,b){var N=n.memoizedState;N===null?n.memoizedState={isBackwards:r,rendering:null,renderingStartTime:0,last:d,tail:i,tailMode:x,treeForkCount:b}:(N.isBackwards=r,N.rendering=null,N.renderingStartTime=0,N.last=d,N.tail=i,N.tailMode=x,N.treeForkCount=b)}function Vx(n,r,i){var d=r.pendingProps,x=d.revealOrder,b=d.tail;d=d.children;var N=mn.current,L=(N&2)!==0;if(L?(N=N&1|2,r.flags|=128):N&=1,S(mn,N),On(n,r,d,i),d=yt?zi:0,!L&&n!==null&&(n.flags&128)!==0)e:for(n=r.child;n!==null;){if(n.tag===13)n.memoizedState!==null&&qx(n,i,r);else if(n.tag===19)qx(n,i,r);else if(n.child!==null){n.child.return=n,n=n.child;continue}if(n===r)break e;for(;n.sibling===null;){if(n.return===null||n.return===r)break e;n=n.return}n.sibling.return=n.return,n=n.sibling}switch(x){case"forwards":for(i=r.child,x=null;i!==null;)n=i.alternate,n!==null&&Uc(n)===null&&(x=i),i=i.sibling;i=x,i===null?(x=r.child,r.child=null):(x=i.sibling,i.sibling=null),am(r,!1,x,i,b,d);break;case"backwards":case"unstable_legacy-backwards":for(i=null,x=r.child,r.child=null;x!==null;){if(n=x.alternate,n!==null&&Uc(n)===null){r.child=x;break}n=x.sibling,x.sibling=i,i=x,x=n}am(r,!0,i,null,b,d);break;case"together":am(r,!1,null,null,void 0,d);break;default:r.memoizedState=null}return r.child}function $r(n,r,i){if(n!==null&&(r.dependencies=n.dependencies),ys|=r.lanes,(i&r.childLanes)===0)if(n!==null){if(zl(n,r,i,!1),(i&r.childLanes)===0)return null}else return null;if(n!==null&&r.child!==n.child)throw Error(l(153));if(r.child!==null){for(n=r.child,i=Ir(n,n.pendingProps),r.child=i,i.return=r;n.sibling!==null;)n=n.sibling,i=i.sibling=Ir(n,n.pendingProps),i.return=r;i.sibling=null}return r.child}function rm(n,r){return(n.lanes&r)!==0?!0:(n=n.dependencies,!!(n!==null&&Ac(n)))}function l5(n,r,i){switch(r.tag){case 3:me(r,r.stateNode.containerInfo),us(r,kn,n.memoizedState.cache),Zs();break;case 27:case 5:te(r);break;case 4:me(r,r.stateNode.containerInfo);break;case 10:us(r,r.type,r.memoizedProps.value);break;case 31:if(r.memoizedState!==null)return r.flags|=128,Ef(r),null;break;case 13:var d=r.memoizedState;if(d!==null)return d.dehydrated!==null?(ps(r),r.flags|=128,null):(i&r.child.childLanes)!==0?Fx(n,r,i):(ps(r),n=$r(n,r,i),n!==null?n.sibling:null);ps(r);break;case 19:var x=(n.flags&128)!==0;if(d=(i&r.childLanes)!==0,d||(zl(n,r,i,!1),d=(i&r.childLanes)!==0),x){if(d)return Vx(n,r,i);r.flags|=128}if(x=r.memoizedState,x!==null&&(x.rendering=null,x.tail=null,x.lastEffect=null),S(mn,mn.current),d)break;return null;case 22:return r.lanes=0,zx(n,r,i,r.pendingProps);case 24:us(r,kn,n.memoizedState.cache)}return $r(n,r,i)}function Gx(n,r,i){if(n!==null)if(n.memoizedProps!==r.pendingProps)Sn=!0;else{if(!rm(n,i)&&(r.flags&128)===0)return Sn=!1,l5(n,r,i);Sn=(n.flags&131072)!==0}else Sn=!1,yt&&(r.flags&1048576)!==0&&j0(r,zi,r.index);switch(r.lanes=0,r.tag){case 16:e:{var d=r.pendingProps;if(n=nl(r.elementType),r.type=n,typeof n=="function")cf(n)?(d=ll(n,d),r.tag=1,r=Bx(null,r,n,d,i)):(r.tag=0,r=Xf(null,r,n,d,i));else{if(n!=null){var x=n.$$typeof;if(x===V){r.tag=11,r=Lx(null,r,n,d,i);break e}else if(x===P){r.tag=14,r=Ox(null,r,n,d,i);break e}}throw r=$(n)||n,Error(l(306,r,""))}}return r;case 0:return Xf(n,r,r.type,r.pendingProps,i);case 1:return d=r.type,x=ll(d,r.pendingProps),Bx(n,r,d,x,i);case 3:e:{if(me(r,r.stateNode.containerInfo),n===null)throw Error(l(387));d=r.pendingProps;var b=r.memoizedState;x=b.element,jf(n,r),Vi(r,d,null,i);var N=r.memoizedState;if(d=N.cache,us(r,kn,d),d!==b.cache&&yf(r,[kn],i,!0),qi(),d=N.element,b.isDehydrated)if(b={element:d,isDehydrated:!1,cache:N.cache},r.updateQueue.baseState=b,r.memoizedState=b,r.flags&256){r=Hx(n,r,d,i);break e}else if(d!==x){x=Ba(Error(l(424)),r),Ui(x),r=Hx(n,r,d,i);break e}else for(n=r.stateNode.containerInfo,n.nodeType===9?n=n.body:n=n.nodeName==="HTML"?n.ownerDocument.body:n,Kt=Ga(n.firstChild),In=r,yt=!0,os=null,qa=!0,i=z0(r,null,d,i),r.child=i;i;)i.flags=i.flags&-3|4096,i=i.sibling;else{if(Zs(),d===x){r=$r(n,r,i);break e}On(n,r,d,i)}r=r.child}return r;case 26:return Yc(n,r),n===null?(i=av(r.type,null,r.pendingProps,null))?r.memoizedState=i:yt||(i=r.type,n=r.pendingProps,d=fu(ie.current).createElement(i),d[qt]=r,d[Zt]=n,Dn(d,i,n),he(d),r.stateNode=d):r.memoizedState=av(r.type,n.memoizedProps,r.pendingProps,n.memoizedState),null;case 27:return te(r),n===null&&yt&&(d=r.stateNode=ev(r.type,r.pendingProps,ie.current),In=r,qa=!0,x=Kt,Ss(r.type)?(zm=x,Kt=Ga(d.firstChild)):Kt=x),On(n,r,r.pendingProps.children,i),Yc(n,r),n===null&&(r.flags|=4194304),r.child;case 5:return n===null&&yt&&((x=d=Kt)&&(d=D5(d,r.type,r.pendingProps,qa),d!==null?(r.stateNode=d,In=r,Kt=Ga(d.firstChild),qa=!1,x=!0):x=!1),x||cs(r)),te(r),x=r.type,b=r.pendingProps,N=n!==null?n.memoizedProps:null,d=b.children,_m(x,b)?d=null:N!==null&&_m(x,N)&&(r.flags|=32),r.memoizedState!==null&&(x=Rf(n,r,Xj,null,null,i),fo._currentValue=x),Yc(n,r),On(n,r,d,i),r.child;case 6:return n===null&&yt&&((n=i=Kt)&&(i=z5(i,r.pendingProps,qa),i!==null?(r.stateNode=i,In=r,Kt=null,n=!0):n=!1),n||cs(r)),null;case 13:return Fx(n,r,i);case 4:return me(r,r.stateNode.containerInfo),d=r.pendingProps,n===null?r.child=rl(r,null,d,i):On(n,r,d,i),r.child;case 11:return Lx(n,r,r.type,r.pendingProps,i);case 7:return On(n,r,r.pendingProps,i),r.child;case 8:return On(n,r,r.pendingProps.children,i),r.child;case 12:return On(n,r,r.pendingProps.children,i),r.child;case 10:return d=r.pendingProps,us(r,r.type,d.value),On(n,r,d.children,i),r.child;case 9:return x=r.type._context,d=r.pendingProps.children,el(r),x=Ln(x),d=d(x),r.flags|=1,On(n,r,d,i),r.child;case 14:return Ox(n,r,r.type,r.pendingProps,i);case 15:return Dx(n,r,r.type,r.pendingProps,i);case 19:return Vx(n,r,i);case 31:return s5(n,r,i);case 22:return zx(n,r,i,r.pendingProps);case 24:return el(r),d=Ln(kn),n===null?(x=kf(),x===null&&(x=Bt,b=vf(),x.pooledCache=b,b.refCount++,b!==null&&(x.pooledCacheLanes|=i),x=b),r.memoizedState={parent:d,cache:x},Sf(r),us(r,kn,x)):((n.lanes&i)!==0&&(jf(n,r),Vi(r,null,null,i),qi()),x=n.memoizedState,b=r.memoizedState,x.parent!==d?(x={parent:d,cache:d},r.memoizedState=x,r.lanes===0&&(r.memoizedState=r.updateQueue.baseState=x),us(r,kn,d)):(d=b.cache,us(r,kn,d),d!==x.cache&&yf(r,[kn],i,!0))),On(n,r,r.pendingProps.children,i),r.child;case 29:throw r.pendingProps}throw Error(l(156,r.tag))}function Pr(n){n.flags|=4}function sm(n,r,i,d,x){if((r=(n.mode&32)!==0)&&(r=!1),r){if(n.flags|=16777216,(x&335544128)===x)if(n.stateNode.complete)n.flags|=8192;else if(vy())n.flags|=8192;else throw al=Lc,wf}else n.flags&=-16777217}function Wx(n,r){if(r.type!=="stylesheet"||(r.state.loading&4)!==0)n.flags&=-16777217;else if(n.flags|=16777216,!ov(r))if(vy())n.flags|=8192;else throw al=Lc,wf}function Xc(n,r){r!==null&&(n.flags|=4),n.flags&16384&&(r=n.tag!==22?Oa():536870912,n.lanes|=r,Yl|=r)}function Xi(n,r){if(!yt)switch(n.tailMode){case"hidden":r=n.tail;for(var i=null;r!==null;)r.alternate!==null&&(i=r),r=r.sibling;i===null?n.tail=null:i.sibling=null;break;case"collapsed":i=n.tail;for(var d=null;i!==null;)i.alternate!==null&&(d=i),i=i.sibling;d===null?r||n.tail===null?n.tail=null:n.tail.sibling=null:d.sibling=null}}function Yt(n){var r=n.alternate!==null&&n.alternate.child===n.child,i=0,d=0;if(r)for(var x=n.child;x!==null;)i|=x.lanes|x.childLanes,d|=x.subtreeFlags&65011712,d|=x.flags&65011712,x.return=n,x=x.sibling;else for(x=n.child;x!==null;)i|=x.lanes|x.childLanes,d|=x.subtreeFlags,d|=x.flags,x.return=n,x=x.sibling;return n.subtreeFlags|=d,n.childLanes=i,r}function i5(n,r,i){var d=r.pendingProps;switch(mf(r),r.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Yt(r),null;case 1:return Yt(r),null;case 3:return i=r.stateNode,d=null,n!==null&&(d=n.memoizedState.cache),r.memoizedState.cache!==d&&(r.flags|=2048),Dr(kn),ye(),i.pendingContext&&(i.context=i.pendingContext,i.pendingContext=null),(n===null||n.child===null)&&(Dl(r)?Pr(r):n===null||n.memoizedState.isDehydrated&&(r.flags&256)===0||(r.flags|=1024,hf())),Yt(r),null;case 26:var x=r.type,b=r.memoizedState;return n===null?(Pr(r),b!==null?(Yt(r),Wx(r,b)):(Yt(r),sm(r,x,null,d,i))):b?b!==n.memoizedState?(Pr(r),Yt(r),Wx(r,b)):(Yt(r),r.flags&=-16777217):(n=n.memoizedProps,n!==d&&Pr(r),Yt(r),sm(r,x,n,d,i)),null;case 27:if(be(r),i=ie.current,x=r.type,n!==null&&r.stateNode!=null)n.memoizedProps!==d&&Pr(r);else{if(!d){if(r.stateNode===null)throw Error(l(166));return Yt(r),null}n=U.current,Dl(r)?N0(r):(n=ev(x,d,i),r.stateNode=n,Pr(r))}return Yt(r),null;case 5:if(be(r),x=r.type,n!==null&&r.stateNode!=null)n.memoizedProps!==d&&Pr(r);else{if(!d){if(r.stateNode===null)throw Error(l(166));return Yt(r),null}if(b=U.current,Dl(r))N0(r);else{var N=fu(ie.current);switch(b){case 1:b=N.createElementNS("http://www.w3.org/2000/svg",x);break;case 2:b=N.createElementNS("http://www.w3.org/1998/Math/MathML",x);break;default:switch(x){case"svg":b=N.createElementNS("http://www.w3.org/2000/svg",x);break;case"math":b=N.createElementNS("http://www.w3.org/1998/Math/MathML",x);break;case"script":b=N.createElement("div"),b.innerHTML="<script><\/script>",b=b.removeChild(b.firstChild);break;case"select":b=typeof d.is=="string"?N.createElement("select",{is:d.is}):N.createElement("select"),d.multiple?b.multiple=!0:d.size&&(b.size=d.size);break;default:b=typeof d.is=="string"?N.createElement(x,{is:d.is}):N.createElement(x)}}b[qt]=r,b[Zt]=d;e:for(N=r.child;N!==null;){if(N.tag===5||N.tag===6)b.appendChild(N.stateNode);else if(N.tag!==4&&N.tag!==27&&N.child!==null){N.child.return=N,N=N.child;continue}if(N===r)break e;for(;N.sibling===null;){if(N.return===null||N.return===r)break e;N=N.return}N.sibling.return=N.return,N=N.sibling}r.stateNode=b;e:switch(Dn(b,x,d),x){case"button":case"input":case"select":case"textarea":d=!!d.autoFocus;break e;case"img":d=!0;break e;default:d=!1}d&&Pr(r)}}return Yt(r),sm(r,r.type,n===null?null:n.memoizedProps,r.pendingProps,i),null;case 6:if(n&&r.stateNode!=null)n.memoizedProps!==d&&Pr(r);else{if(typeof d!="string"&&r.stateNode===null)throw Error(l(166));if(n=ie.current,Dl(r)){if(n=r.stateNode,i=r.memoizedProps,d=null,x=In,x!==null)switch(x.tag){case 27:case 5:d=x.memoizedProps}n[qt]=r,n=!!(n.nodeValue===i||d!==null&&d.suppressHydrationWarning===!0||Fy(n.nodeValue,i)),n||cs(r,!0)}else n=fu(n).createTextNode(d),n[qt]=r,r.stateNode=n}return Yt(r),null;case 31:if(i=r.memoizedState,n===null||n.memoizedState!==null){if(d=Dl(r),i!==null){if(n===null){if(!d)throw Error(l(318));if(n=r.memoizedState,n=n!==null?n.dehydrated:null,!n)throw Error(l(557));n[qt]=r}else Zs(),(r.flags&128)===0&&(r.memoizedState=null),r.flags|=4;Yt(r),n=!1}else i=hf(),n!==null&&n.memoizedState!==null&&(n.memoizedState.hydrationErrors=i),n=!0;if(!n)return r.flags&256?(Na(r),r):(Na(r),null);if((r.flags&128)!==0)throw Error(l(558))}return Yt(r),null;case 13:if(d=r.memoizedState,n===null||n.memoizedState!==null&&n.memoizedState.dehydrated!==null){if(x=Dl(r),d!==null&&d.dehydrated!==null){if(n===null){if(!x)throw Error(l(318));if(x=r.memoizedState,x=x!==null?x.dehydrated:null,!x)throw Error(l(317));x[qt]=r}else Zs(),(r.flags&128)===0&&(r.memoizedState=null),r.flags|=4;Yt(r),x=!1}else x=hf(),n!==null&&n.memoizedState!==null&&(n.memoizedState.hydrationErrors=x),x=!0;if(!x)return r.flags&256?(Na(r),r):(Na(r),null)}return Na(r),(r.flags&128)!==0?(r.lanes=i,r):(i=d!==null,n=n!==null&&n.memoizedState!==null,i&&(d=r.child,x=null,d.alternate!==null&&d.alternate.memoizedState!==null&&d.alternate.memoizedState.cachePool!==null&&(x=d.alternate.memoizedState.cachePool.pool),b=null,d.memoizedState!==null&&d.memoizedState.cachePool!==null&&(b=d.memoizedState.cachePool.pool),b!==x&&(d.flags|=2048)),i!==n&&i&&(r.child.flags|=8192),Xc(r,r.updateQueue),Yt(r),null);case 4:return ye(),n===null&&Tm(r.stateNode.containerInfo),Yt(r),null;case 10:return Dr(r.type),Yt(r),null;case 19:if(H(mn),d=r.memoizedState,d===null)return Yt(r),null;if(x=(r.flags&128)!==0,b=d.rendering,b===null)if(x)Xi(d,!1);else{if(un!==0||n!==null&&(n.flags&128)!==0)for(n=r.child;n!==null;){if(b=Uc(n),b!==null){for(r.flags|=128,Xi(d,!1),n=b.updateQueue,r.updateQueue=n,Xc(r,n),r.subtreeFlags=0,n=i,i=r.child;i!==null;)k0(i,n),i=i.sibling;return S(mn,mn.current&1|2),yt&&Lr(r,d.treeForkCount),r.child}n=n.sibling}d.tail!==null&&st()>nu&&(r.flags|=128,x=!0,Xi(d,!1),r.lanes=4194304)}else{if(!x)if(n=Uc(b),n!==null){if(r.flags|=128,x=!0,n=n.updateQueue,r.updateQueue=n,Xc(r,n),Xi(d,!0),d.tail===null&&d.tailMode==="hidden"&&!b.alternate&&!yt)return Yt(r),null}else 2*st()-d.renderingStartTime>nu&&i!==536870912&&(r.flags|=128,x=!0,Xi(d,!1),r.lanes=4194304);d.isBackwards?(b.sibling=r.child,r.child=b):(n=d.last,n!==null?n.sibling=b:r.child=b,d.last=b)}return d.tail!==null?(n=d.tail,d.rendering=n,d.tail=n.sibling,d.renderingStartTime=st(),n.sibling=null,i=mn.current,S(mn,x?i&1|2:i&1),yt&&Lr(r,d.treeForkCount),n):(Yt(r),null);case 22:case 23:return Na(r),Mf(),d=r.memoizedState!==null,n!==null?n.memoizedState!==null!==d&&(r.flags|=8192):d&&(r.flags|=8192),d?(i&536870912)!==0&&(r.flags&128)===0&&(Yt(r),r.subtreeFlags&6&&(r.flags|=8192)):Yt(r),i=r.updateQueue,i!==null&&Xc(r,i.retryQueue),i=null,n!==null&&n.memoizedState!==null&&n.memoizedState.cachePool!==null&&(i=n.memoizedState.cachePool.pool),d=null,r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(d=r.memoizedState.cachePool.pool),d!==i&&(r.flags|=2048),n!==null&&H(tl),null;case 24:return i=null,n!==null&&(i=n.memoizedState.cache),r.memoizedState.cache!==i&&(r.flags|=2048),Dr(kn),Yt(r),null;case 25:return null;case 30:return null}throw Error(l(156,r.tag))}function o5(n,r){switch(mf(r),r.tag){case 1:return n=r.flags,n&65536?(r.flags=n&-65537|128,r):null;case 3:return Dr(kn),ye(),n=r.flags,(n&65536)!==0&&(n&128)===0?(r.flags=n&-65537|128,r):null;case 26:case 27:case 5:return be(r),null;case 31:if(r.memoizedState!==null){if(Na(r),r.alternate===null)throw Error(l(340));Zs()}return n=r.flags,n&65536?(r.flags=n&-65537|128,r):null;case 13:if(Na(r),n=r.memoizedState,n!==null&&n.dehydrated!==null){if(r.alternate===null)throw Error(l(340));Zs()}return n=r.flags,n&65536?(r.flags=n&-65537|128,r):null;case 19:return H(mn),null;case 4:return ye(),null;case 10:return Dr(r.type),null;case 22:case 23:return Na(r),Mf(),n!==null&&H(tl),n=r.flags,n&65536?(r.flags=n&-65537|128,r):null;case 24:return Dr(kn),null;case 25:return null;default:return null}}function Kx(n,r){switch(mf(r),r.tag){case 3:Dr(kn),ye();break;case 26:case 27:case 5:be(r);break;case 4:ye();break;case 31:r.memoizedState!==null&&Na(r);break;case 13:Na(r);break;case 19:H(mn);break;case 10:Dr(r.type);break;case 22:case 23:Na(r),Mf(),n!==null&&H(tl);break;case 24:Dr(kn)}}function Zi(n,r){try{var i=r.updateQueue,d=i!==null?i.lastEffect:null;if(d!==null){var x=d.next;i=x;do{if((i.tag&n)===n){d=void 0;var b=i.create,N=i.inst;d=b(),N.destroy=d}i=i.next}while(i!==x)}}catch(L){Lt(r,r.return,L)}}function gs(n,r,i){try{var d=r.updateQueue,x=d!==null?d.lastEffect:null;if(x!==null){var b=x.next;d=b;do{if((d.tag&n)===n){var N=d.inst,L=N.destroy;if(L!==void 0){N.destroy=void 0,x=r;var Y=i,se=L;try{se()}catch(xe){Lt(x,Y,xe)}}}d=d.next}while(d!==b)}}catch(xe){Lt(r,r.return,xe)}}function Yx(n){var r=n.updateQueue;if(r!==null){var i=n.stateNode;try{$0(r,i)}catch(d){Lt(n,n.return,d)}}}function Qx(n,r,i){i.props=ll(n.type,n.memoizedProps),i.state=n.memoizedState;try{i.componentWillUnmount()}catch(d){Lt(n,r,d)}}function Ji(n,r){try{var i=n.ref;if(i!==null){switch(n.tag){case 26:case 27:case 5:var d=n.stateNode;break;case 30:d=n.stateNode;break;default:d=n.stateNode}typeof i=="function"?n.refCleanup=i(d):i.current=d}}catch(x){Lt(n,r,x)}}function br(n,r){var i=n.ref,d=n.refCleanup;if(i!==null)if(typeof d=="function")try{d()}catch(x){Lt(n,r,x)}finally{n.refCleanup=null,n=n.alternate,n!=null&&(n.refCleanup=null)}else if(typeof i=="function")try{i(null)}catch(x){Lt(n,r,x)}else i.current=null}function Xx(n){var r=n.type,i=n.memoizedProps,d=n.stateNode;try{e:switch(r){case"button":case"input":case"select":case"textarea":i.autoFocus&&d.focus();break e;case"img":i.src?d.src=i.src:i.srcSet&&(d.srcset=i.srcSet)}}catch(x){Lt(n,n.return,x)}}function lm(n,r,i){try{var d=n.stateNode;A5(d,n.type,i,r),d[Zt]=r}catch(x){Lt(n,n.return,x)}}function Zx(n){return n.tag===5||n.tag===3||n.tag===26||n.tag===27&&Ss(n.type)||n.tag===4}function im(n){e:for(;;){for(;n.sibling===null;){if(n.return===null||Zx(n.return))return null;n=n.return}for(n.sibling.return=n.return,n=n.sibling;n.tag!==5&&n.tag!==6&&n.tag!==18;){if(n.tag===27&&Ss(n.type)||n.flags&2||n.child===null||n.tag===4)continue e;n.child.return=n,n=n.child}if(!(n.flags&2))return n.stateNode}}function om(n,r,i){var d=n.tag;if(d===5||d===6)n=n.stateNode,r?(i.nodeType===9?i.body:i.nodeName==="HTML"?i.ownerDocument.body:i).insertBefore(n,r):(r=i.nodeType===9?i.body:i.nodeName==="HTML"?i.ownerDocument.body:i,r.appendChild(n),i=i._reactRootContainer,i!=null||r.onclick!==null||(r.onclick=pt));else if(d!==4&&(d===27&&Ss(n.type)&&(i=n.stateNode,r=null),n=n.child,n!==null))for(om(n,r,i),n=n.sibling;n!==null;)om(n,r,i),n=n.sibling}function Zc(n,r,i){var d=n.tag;if(d===5||d===6)n=n.stateNode,r?i.insertBefore(n,r):i.appendChild(n);else if(d!==4&&(d===27&&Ss(n.type)&&(i=n.stateNode),n=n.child,n!==null))for(Zc(n,r,i),n=n.sibling;n!==null;)Zc(n,r,i),n=n.sibling}function Jx(n){var r=n.stateNode,i=n.memoizedProps;try{for(var d=n.type,x=r.attributes;x.length;)r.removeAttributeNode(x[0]);Dn(r,d,i),r[qt]=n,r[Zt]=i}catch(b){Lt(n,n.return,b)}}var Br=!1,jn=!1,cm=!1,ey=typeof WeakSet=="function"?WeakSet:Set,Rn=null;function c5(n,r){if(n=n.containerInfo,Am=vu,n=f0(n),tf(n)){if("selectionStart"in n)var i={start:n.selectionStart,end:n.selectionEnd};else e:{i=(i=n.ownerDocument)&&i.defaultView||window;var d=i.getSelection&&i.getSelection();if(d&&d.rangeCount!==0){i=d.anchorNode;var x=d.anchorOffset,b=d.focusNode;d=d.focusOffset;try{i.nodeType,b.nodeType}catch{i=null;break e}var N=0,L=-1,Y=-1,se=0,xe=0,ke=n,oe=null;t:for(;;){for(var fe;ke!==i||x!==0&&ke.nodeType!==3||(L=N+x),ke!==b||d!==0&&ke.nodeType!==3||(Y=N+d),ke.nodeType===3&&(N+=ke.nodeValue.length),(fe=ke.firstChild)!==null;)oe=ke,ke=fe;for(;;){if(ke===n)break t;if(oe===i&&++se===x&&(L=N),oe===b&&++xe===d&&(Y=N),(fe=ke.nextSibling)!==null)break;ke=oe,oe=ke.parentNode}ke=fe}i=L===-1||Y===-1?null:{start:L,end:Y}}else i=null}i=i||{start:0,end:0}}else i=null;for(Rm={focusedElem:n,selectionRange:i},vu=!1,Rn=r;Rn!==null;)if(r=Rn,n=r.child,(r.subtreeFlags&1028)!==0&&n!==null)n.return=r,Rn=n;else for(;Rn!==null;){switch(r=Rn,b=r.alternate,n=r.flags,r.tag){case 0:if((n&4)!==0&&(n=r.updateQueue,n=n!==null?n.events:null,n!==null))for(i=0;i<n.length;i++)x=n[i],x.ref.impl=x.nextImpl;break;case 11:case 15:break;case 1:if((n&1024)!==0&&b!==null){n=void 0,i=r,x=b.memoizedProps,b=b.memoizedState,d=i.stateNode;try{var $e=ll(i.type,x);n=d.getSnapshotBeforeUpdate($e,b),d.__reactInternalSnapshotBeforeUpdate=n}catch(Xe){Lt(i,i.return,Xe)}}break;case 3:if((n&1024)!==0){if(n=r.stateNode.containerInfo,i=n.nodeType,i===9)Lm(n);else if(i===1)switch(n.nodeName){case"HEAD":case"HTML":case"BODY":Lm(n);break;default:n.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((n&1024)!==0)throw Error(l(163))}if(n=r.sibling,n!==null){n.return=r.return,Rn=n;break}Rn=r.return}}function ty(n,r,i){var d=i.flags;switch(i.tag){case 0:case 11:case 15:Fr(n,i),d&4&&Zi(5,i);break;case 1:if(Fr(n,i),d&4)if(n=i.stateNode,r===null)try{n.componentDidMount()}catch(N){Lt(i,i.return,N)}else{var x=ll(i.type,r.memoizedProps);r=r.memoizedState;try{n.componentDidUpdate(x,r,n.__reactInternalSnapshotBeforeUpdate)}catch(N){Lt(i,i.return,N)}}d&64&&Yx(i),d&512&&Ji(i,i.return);break;case 3:if(Fr(n,i),d&64&&(n=i.updateQueue,n!==null)){if(r=null,i.child!==null)switch(i.child.tag){case 27:case 5:r=i.child.stateNode;break;case 1:r=i.child.stateNode}try{$0(n,r)}catch(N){Lt(i,i.return,N)}}break;case 27:r===null&&d&4&&Jx(i);case 26:case 5:Fr(n,i),r===null&&d&4&&Xx(i),d&512&&Ji(i,i.return);break;case 12:Fr(n,i);break;case 31:Fr(n,i),d&4&&ry(n,i);break;case 13:Fr(n,i),d&4&&sy(n,i),d&64&&(n=i.memoizedState,n!==null&&(n=n.dehydrated,n!==null&&(i=y5.bind(null,i),U5(n,i))));break;case 22:if(d=i.memoizedState!==null||Br,!d){r=r!==null&&r.memoizedState!==null||jn,x=Br;var b=jn;Br=d,(jn=r)&&!b?qr(n,i,(i.subtreeFlags&8772)!==0):Fr(n,i),Br=x,jn=b}break;case 30:break;default:Fr(n,i)}}function ny(n){var r=n.alternate;r!==null&&(n.alternate=null,ny(r)),n.child=null,n.deletions=null,n.sibling=null,n.tag===5&&(r=n.stateNode,r!==null&&sr(r)),n.stateNode=null,n.return=null,n.dependencies=null,n.memoizedProps=null,n.memoizedState=null,n.pendingProps=null,n.stateNode=null,n.updateQueue=null}var Jt=null,ia=!1;function Hr(n,r,i){for(i=i.child;i!==null;)ay(n,r,i),i=i.sibling}function ay(n,r,i){if(Te&&typeof Te.onCommitFiberUnmount=="function")try{Te.onCommitFiberUnmount(Ne,i)}catch{}switch(i.tag){case 26:jn||br(i,r),Hr(n,r,i),i.memoizedState?i.memoizedState.count--:i.stateNode&&(i=i.stateNode,i.parentNode.removeChild(i));break;case 27:jn||br(i,r);var d=Jt,x=ia;Ss(i.type)&&(Jt=i.stateNode,ia=!1),Hr(n,r,i),oo(i.stateNode),Jt=d,ia=x;break;case 5:jn||br(i,r);case 6:if(d=Jt,x=ia,Jt=null,Hr(n,r,i),Jt=d,ia=x,Jt!==null)if(ia)try{(Jt.nodeType===9?Jt.body:Jt.nodeName==="HTML"?Jt.ownerDocument.body:Jt).removeChild(i.stateNode)}catch(b){Lt(i,r,b)}else try{Jt.removeChild(i.stateNode)}catch(b){Lt(i,r,b)}break;case 18:Jt!==null&&(ia?(n=Jt,Yy(n.nodeType===9?n.body:n.nodeName==="HTML"?n.ownerDocument.body:n,i.stateNode),ai(n)):Yy(Jt,i.stateNode));break;case 4:d=Jt,x=ia,Jt=i.stateNode.containerInfo,ia=!0,Hr(n,r,i),Jt=d,ia=x;break;case 0:case 11:case 14:case 15:gs(2,i,r),jn||gs(4,i,r),Hr(n,r,i);break;case 1:jn||(br(i,r),d=i.stateNode,typeof d.componentWillUnmount=="function"&&Qx(i,r,d)),Hr(n,r,i);break;case 21:Hr(n,r,i);break;case 22:jn=(d=jn)||i.memoizedState!==null,Hr(n,r,i),jn=d;break;default:Hr(n,r,i)}}function ry(n,r){if(r.memoizedState===null&&(n=r.alternate,n!==null&&(n=n.memoizedState,n!==null))){n=n.dehydrated;try{ai(n)}catch(i){Lt(r,r.return,i)}}}function sy(n,r){if(r.memoizedState===null&&(n=r.alternate,n!==null&&(n=n.memoizedState,n!==null&&(n=n.dehydrated,n!==null))))try{ai(n)}catch(i){Lt(r,r.return,i)}}function u5(n){switch(n.tag){case 31:case 13:case 19:var r=n.stateNode;return r===null&&(r=n.stateNode=new ey),r;case 22:return n=n.stateNode,r=n._retryCache,r===null&&(r=n._retryCache=new ey),r;default:throw Error(l(435,n.tag))}}function Jc(n,r){var i=u5(n);r.forEach(function(d){if(!i.has(d)){i.add(d);var x=v5.bind(null,n,d);d.then(x,x)}})}function oa(n,r){var i=r.deletions;if(i!==null)for(var d=0;d<i.length;d++){var x=i[d],b=n,N=r,L=N;e:for(;L!==null;){switch(L.tag){case 27:if(Ss(L.type)){Jt=L.stateNode,ia=!1;break e}break;case 5:Jt=L.stateNode,ia=!1;break e;case 3:case 4:Jt=L.stateNode.containerInfo,ia=!0;break e}L=L.return}if(Jt===null)throw Error(l(160));ay(b,N,x),Jt=null,ia=!1,b=x.alternate,b!==null&&(b.return=null),x.return=null}if(r.subtreeFlags&13886)for(r=r.child;r!==null;)ly(r,n),r=r.sibling}var or=null;function ly(n,r){var i=n.alternate,d=n.flags;switch(n.tag){case 0:case 11:case 14:case 15:oa(r,n),ca(n),d&4&&(gs(3,n,n.return),Zi(3,n),gs(5,n,n.return));break;case 1:oa(r,n),ca(n),d&512&&(jn||i===null||br(i,i.return)),d&64&&Br&&(n=n.updateQueue,n!==null&&(d=n.callbacks,d!==null&&(i=n.shared.hiddenCallbacks,n.shared.hiddenCallbacks=i===null?d:i.concat(d))));break;case 26:var x=or;if(oa(r,n),ca(n),d&512&&(jn||i===null||br(i,i.return)),d&4){var b=i!==null?i.memoizedState:null;if(d=n.memoizedState,i===null)if(d===null)if(n.stateNode===null){e:{d=n.type,i=n.memoizedProps,x=x.ownerDocument||x;t:switch(d){case"title":b=x.getElementsByTagName("title")[0],(!b||b[Qn]||b[qt]||b.namespaceURI==="http://www.w3.org/2000/svg"||b.hasAttribute("itemprop"))&&(b=x.createElement(d),x.head.insertBefore(b,x.querySelector("head > title"))),Dn(b,d,i),b[qt]=n,he(b),d=b;break e;case"link":var N=lv("link","href",x).get(d+(i.href||""));if(N){for(var L=0;L<N.length;L++)if(b=N[L],b.getAttribute("href")===(i.href==null||i.href===""?null:i.href)&&b.getAttribute("rel")===(i.rel==null?null:i.rel)&&b.getAttribute("title")===(i.title==null?null:i.title)&&b.getAttribute("crossorigin")===(i.crossOrigin==null?null:i.crossOrigin)){N.splice(L,1);break t}}b=x.createElement(d),Dn(b,d,i),x.head.appendChild(b);break;case"meta":if(N=lv("meta","content",x).get(d+(i.content||""))){for(L=0;L<N.length;L++)if(b=N[L],b.getAttribute("content")===(i.content==null?null:""+i.content)&&b.getAttribute("name")===(i.name==null?null:i.name)&&b.getAttribute("property")===(i.property==null?null:i.property)&&b.getAttribute("http-equiv")===(i.httpEquiv==null?null:i.httpEquiv)&&b.getAttribute("charset")===(i.charSet==null?null:i.charSet)){N.splice(L,1);break t}}b=x.createElement(d),Dn(b,d,i),x.head.appendChild(b);break;default:throw Error(l(468,d))}b[qt]=n,he(b),d=b}n.stateNode=d}else iv(x,n.type,n.stateNode);else n.stateNode=sv(x,d,n.memoizedProps);else b!==d?(b===null?i.stateNode!==null&&(i=i.stateNode,i.parentNode.removeChild(i)):b.count--,d===null?iv(x,n.type,n.stateNode):sv(x,d,n.memoizedProps)):d===null&&n.stateNode!==null&&lm(n,n.memoizedProps,i.memoizedProps)}break;case 27:oa(r,n),ca(n),d&512&&(jn||i===null||br(i,i.return)),i!==null&&d&4&&lm(n,n.memoizedProps,i.memoizedProps);break;case 5:if(oa(r,n),ca(n),d&512&&(jn||i===null||br(i,i.return)),n.flags&32){x=n.stateNode;try{lr(x,"")}catch($e){Lt(n,n.return,$e)}}d&4&&n.stateNode!=null&&(x=n.memoizedProps,lm(n,x,i!==null?i.memoizedProps:x)),d&1024&&(cm=!0);break;case 6:if(oa(r,n),ca(n),d&4){if(n.stateNode===null)throw Error(l(162));d=n.memoizedProps,i=n.stateNode;try{i.nodeValue=d}catch($e){Lt(n,n.return,$e)}}break;case 3:if(hu=null,x=or,or=mu(r.containerInfo),oa(r,n),or=x,ca(n),d&4&&i!==null&&i.memoizedState.isDehydrated)try{ai(r.containerInfo)}catch($e){Lt(n,n.return,$e)}cm&&(cm=!1,iy(n));break;case 4:d=or,or=mu(n.stateNode.containerInfo),oa(r,n),ca(n),or=d;break;case 12:oa(r,n),ca(n);break;case 31:oa(r,n),ca(n),d&4&&(d=n.updateQueue,d!==null&&(n.updateQueue=null,Jc(n,d)));break;case 13:oa(r,n),ca(n),n.child.flags&8192&&n.memoizedState!==null!=(i!==null&&i.memoizedState!==null)&&(tu=st()),d&4&&(d=n.updateQueue,d!==null&&(n.updateQueue=null,Jc(n,d)));break;case 22:x=n.memoizedState!==null;var Y=i!==null&&i.memoizedState!==null,se=Br,xe=jn;if(Br=se||x,jn=xe||Y,oa(r,n),jn=xe,Br=se,ca(n),d&8192)e:for(r=n.stateNode,r._visibility=x?r._visibility&-2:r._visibility|1,x&&(i===null||Y||Br||jn||il(n)),i=null,r=n;;){if(r.tag===5||r.tag===26){if(i===null){Y=i=r;try{if(b=Y.stateNode,x)N=b.style,typeof N.setProperty=="function"?N.setProperty("display","none","important"):N.display="none";else{L=Y.stateNode;var ke=Y.memoizedProps.style,oe=ke!=null&&ke.hasOwnProperty("display")?ke.display:null;L.style.display=oe==null||typeof oe=="boolean"?"":(""+oe).trim()}}catch($e){Lt(Y,Y.return,$e)}}}else if(r.tag===6){if(i===null){Y=r;try{Y.stateNode.nodeValue=x?"":Y.memoizedProps}catch($e){Lt(Y,Y.return,$e)}}}else if(r.tag===18){if(i===null){Y=r;try{var fe=Y.stateNode;x?Qy(fe,!0):Qy(Y.stateNode,!1)}catch($e){Lt(Y,Y.return,$e)}}}else if((r.tag!==22&&r.tag!==23||r.memoizedState===null||r===n)&&r.child!==null){r.child.return=r,r=r.child;continue}if(r===n)break e;for(;r.sibling===null;){if(r.return===null||r.return===n)break e;i===r&&(i=null),r=r.return}i===r&&(i=null),r.sibling.return=r.return,r=r.sibling}d&4&&(d=n.updateQueue,d!==null&&(i=d.retryQueue,i!==null&&(d.retryQueue=null,Jc(n,i))));break;case 19:oa(r,n),ca(n),d&4&&(d=n.updateQueue,d!==null&&(n.updateQueue=null,Jc(n,d)));break;case 30:break;case 21:break;default:oa(r,n),ca(n)}}function ca(n){var r=n.flags;if(r&2){try{for(var i,d=n.return;d!==null;){if(Zx(d)){i=d;break}d=d.return}if(i==null)throw Error(l(160));switch(i.tag){case 27:var x=i.stateNode,b=im(n);Zc(n,b,x);break;case 5:var N=i.stateNode;i.flags&32&&(lr(N,""),i.flags&=-33);var L=im(n);Zc(n,L,N);break;case 3:case 4:var Y=i.stateNode.containerInfo,se=im(n);om(n,se,Y);break;default:throw Error(l(161))}}catch(xe){Lt(n,n.return,xe)}n.flags&=-3}r&4096&&(n.flags&=-4097)}function iy(n){if(n.subtreeFlags&1024)for(n=n.child;n!==null;){var r=n;iy(r),r.tag===5&&r.flags&1024&&r.stateNode.reset(),n=n.sibling}}function Fr(n,r){if(r.subtreeFlags&8772)for(r=r.child;r!==null;)ty(n,r.alternate,r),r=r.sibling}function il(n){for(n=n.child;n!==null;){var r=n;switch(r.tag){case 0:case 11:case 14:case 15:gs(4,r,r.return),il(r);break;case 1:br(r,r.return);var i=r.stateNode;typeof i.componentWillUnmount=="function"&&Qx(r,r.return,i),il(r);break;case 27:oo(r.stateNode);case 26:case 5:br(r,r.return),il(r);break;case 22:r.memoizedState===null&&il(r);break;case 30:il(r);break;default:il(r)}n=n.sibling}}function qr(n,r,i){for(i=i&&(r.subtreeFlags&8772)!==0,r=r.child;r!==null;){var d=r.alternate,x=n,b=r,N=b.flags;switch(b.tag){case 0:case 11:case 15:qr(x,b,i),Zi(4,b);break;case 1:if(qr(x,b,i),d=b,x=d.stateNode,typeof x.componentDidMount=="function")try{x.componentDidMount()}catch(se){Lt(d,d.return,se)}if(d=b,x=d.updateQueue,x!==null){var L=d.stateNode;try{var Y=x.shared.hiddenCallbacks;if(Y!==null)for(x.shared.hiddenCallbacks=null,x=0;x<Y.length;x++)U0(Y[x],L)}catch(se){Lt(d,d.return,se)}}i&&N&64&&Yx(b),Ji(b,b.return);break;case 27:Jx(b);case 26:case 5:qr(x,b,i),i&&d===null&&N&4&&Xx(b),Ji(b,b.return);break;case 12:qr(x,b,i);break;case 31:qr(x,b,i),i&&N&4&&ry(x,b);break;case 13:qr(x,b,i),i&&N&4&&sy(x,b);break;case 22:b.memoizedState===null&&qr(x,b,i),Ji(b,b.return);break;case 30:break;default:qr(x,b,i)}r=r.sibling}}function um(n,r){var i=null;n!==null&&n.memoizedState!==null&&n.memoizedState.cachePool!==null&&(i=n.memoizedState.cachePool.pool),n=null,r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(n=r.memoizedState.cachePool.pool),n!==i&&(n!=null&&n.refCount++,i!=null&&$i(i))}function dm(n,r){n=null,r.alternate!==null&&(n=r.alternate.memoizedState.cache),r=r.memoizedState.cache,r!==n&&(r.refCount++,n!=null&&$i(n))}function cr(n,r,i,d){if(r.subtreeFlags&10256)for(r=r.child;r!==null;)oy(n,r,i,d),r=r.sibling}function oy(n,r,i,d){var x=r.flags;switch(r.tag){case 0:case 11:case 15:cr(n,r,i,d),x&2048&&Zi(9,r);break;case 1:cr(n,r,i,d);break;case 3:cr(n,r,i,d),x&2048&&(n=null,r.alternate!==null&&(n=r.alternate.memoizedState.cache),r=r.memoizedState.cache,r!==n&&(r.refCount++,n!=null&&$i(n)));break;case 12:if(x&2048){cr(n,r,i,d),n=r.stateNode;try{var b=r.memoizedProps,N=b.id,L=b.onPostCommit;typeof L=="function"&&L(N,r.alternate===null?"mount":"update",n.passiveEffectDuration,-0)}catch(Y){Lt(r,r.return,Y)}}else cr(n,r,i,d);break;case 31:cr(n,r,i,d);break;case 13:cr(n,r,i,d);break;case 23:break;case 22:b=r.stateNode,N=r.alternate,r.memoizedState!==null?b._visibility&2?cr(n,r,i,d):eo(n,r):b._visibility&2?cr(n,r,i,d):(b._visibility|=2,Gl(n,r,i,d,(r.subtreeFlags&10256)!==0||!1)),x&2048&&um(N,r);break;case 24:cr(n,r,i,d),x&2048&&dm(r.alternate,r);break;default:cr(n,r,i,d)}}function Gl(n,r,i,d,x){for(x=x&&((r.subtreeFlags&10256)!==0||!1),r=r.child;r!==null;){var b=n,N=r,L=i,Y=d,se=N.flags;switch(N.tag){case 0:case 11:case 15:Gl(b,N,L,Y,x),Zi(8,N);break;case 23:break;case 22:var xe=N.stateNode;N.memoizedState!==null?xe._visibility&2?Gl(b,N,L,Y,x):eo(b,N):(xe._visibility|=2,Gl(b,N,L,Y,x)),x&&se&2048&&um(N.alternate,N);break;case 24:Gl(b,N,L,Y,x),x&&se&2048&&dm(N.alternate,N);break;default:Gl(b,N,L,Y,x)}r=r.sibling}}function eo(n,r){if(r.subtreeFlags&10256)for(r=r.child;r!==null;){var i=n,d=r,x=d.flags;switch(d.tag){case 22:eo(i,d),x&2048&&um(d.alternate,d);break;case 24:eo(i,d),x&2048&&dm(d.alternate,d);break;default:eo(i,d)}r=r.sibling}}var to=8192;function Wl(n,r,i){if(n.subtreeFlags&to)for(n=n.child;n!==null;)cy(n,r,i),n=n.sibling}function cy(n,r,i){switch(n.tag){case 26:Wl(n,r,i),n.flags&to&&n.memoizedState!==null&&Q5(i,or,n.memoizedState,n.memoizedProps);break;case 5:Wl(n,r,i);break;case 3:case 4:var d=or;or=mu(n.stateNode.containerInfo),Wl(n,r,i),or=d;break;case 22:n.memoizedState===null&&(d=n.alternate,d!==null&&d.memoizedState!==null?(d=to,to=16777216,Wl(n,r,i),to=d):Wl(n,r,i));break;default:Wl(n,r,i)}}function uy(n){var r=n.alternate;if(r!==null&&(n=r.child,n!==null)){r.child=null;do r=n.sibling,n.sibling=null,n=r;while(n!==null)}}function no(n){var r=n.deletions;if((n.flags&16)!==0){if(r!==null)for(var i=0;i<r.length;i++){var d=r[i];Rn=d,fy(d,n)}uy(n)}if(n.subtreeFlags&10256)for(n=n.child;n!==null;)dy(n),n=n.sibling}function dy(n){switch(n.tag){case 0:case 11:case 15:no(n),n.flags&2048&&gs(9,n,n.return);break;case 3:no(n);break;case 12:no(n);break;case 22:var r=n.stateNode;n.memoizedState!==null&&r._visibility&2&&(n.return===null||n.return.tag!==13)?(r._visibility&=-3,eu(n)):no(n);break;default:no(n)}}function eu(n){var r=n.deletions;if((n.flags&16)!==0){if(r!==null)for(var i=0;i<r.length;i++){var d=r[i];Rn=d,fy(d,n)}uy(n)}for(n=n.child;n!==null;){switch(r=n,r.tag){case 0:case 11:case 15:gs(8,r,r.return),eu(r);break;case 22:i=r.stateNode,i._visibility&2&&(i._visibility&=-3,eu(r));break;default:eu(r)}n=n.sibling}}function fy(n,r){for(;Rn!==null;){var i=Rn;switch(i.tag){case 0:case 11:case 15:gs(8,i,r);break;case 23:case 22:if(i.memoizedState!==null&&i.memoizedState.cachePool!==null){var d=i.memoizedState.cachePool.pool;d!=null&&d.refCount++}break;case 24:$i(i.memoizedState.cache)}if(d=i.child,d!==null)d.return=i,Rn=d;else e:for(i=n;Rn!==null;){d=Rn;var x=d.sibling,b=d.return;if(ny(d),d===i){Rn=null;break e}if(x!==null){x.return=b,Rn=x;break e}Rn=b}}}var d5={getCacheForType:function(n){var r=Ln(kn),i=r.data.get(n);return i===void 0&&(i=n(),r.data.set(n,i)),i},cacheSignal:function(){return Ln(kn).controller.signal}},f5=typeof WeakMap=="function"?WeakMap:Map,Mt=0,Bt=null,dt=null,ht=0,It=0,Ta=null,xs=!1,Kl=!1,fm=!1,Vr=0,un=0,ys=0,ol=0,mm=0,Ma=0,Yl=0,ao=null,ua=null,pm=!1,tu=0,my=0,nu=1/0,au=null,vs=null,Tn=0,bs=null,Ql=null,Gr=0,hm=0,gm=null,py=null,ro=0,xm=null;function Ea(){return(Mt&2)!==0&&ht!==0?ht&-ht:q.T!==null?Sm():Da()}function hy(){if(Ma===0)if((ht&536870912)===0||yt){var n=Ke;Ke<<=1,(Ke&3932160)===0&&(Ke=262144),Ma=n}else Ma=536870912;return n=Ca.current,n!==null&&(n.flags|=32),Ma}function da(n,r,i){(n===Bt&&(It===2||It===9)||n.cancelPendingCommit!==null)&&(Xl(n,0),ks(n,ht,Ma,!1)),En(n,i),((Mt&2)===0||n!==Bt)&&(n===Bt&&((Mt&2)===0&&(ol|=i),un===4&&ks(n,ht,Ma,!1)),kr(n))}function gy(n,r,i){if((Mt&6)!==0)throw Error(l(327));var d=!i&&(r&127)===0&&(r&n.expiredLanes)===0||ln(n,r),x=d?h5(n,r):vm(n,r,!0),b=d;do{if(x===0){Kl&&!d&&ks(n,r,0,!1);break}else{if(i=n.current.alternate,b&&!m5(i)){x=vm(n,r,!1),b=!1;continue}if(x===2){if(b=r,n.errorRecoveryDisabledLanes&b)var N=0;else N=n.pendingLanes&-536870913,N=N!==0?N:N&536870912?536870912:0;if(N!==0){r=N;e:{var L=n;x=ao;var Y=L.current.memoizedState.isDehydrated;if(Y&&(Xl(L,N).flags|=256),N=vm(L,N,!1),N!==2){if(fm&&!Y){L.errorRecoveryDisabledLanes|=b,ol|=b,x=4;break e}b=ua,ua=x,b!==null&&(ua===null?ua=b:ua.push.apply(ua,b))}x=N}if(b=!1,x!==2)continue}}if(x===1){Xl(n,0),ks(n,r,0,!0);break}e:{switch(d=n,b=x,b){case 0:case 1:throw Error(l(345));case 4:if((r&4194048)!==r)break;case 6:ks(d,r,Ma,!xs);break e;case 2:ua=null;break;case 3:case 5:break;default:throw Error(l(329))}if((r&62914560)===r&&(x=tu+300-st(),10<x)){if(ks(d,r,Ma,!xs),St(d,0,!0)!==0)break e;Gr=r,d.timeoutHandle=Wy(xy.bind(null,d,i,ua,au,pm,r,Ma,ol,Yl,xs,b,"Throttled",-0,0),x);break e}xy(d,i,ua,au,pm,r,Ma,ol,Yl,xs,b,null,-0,0)}}break}while(!0);kr(n)}function xy(n,r,i,d,x,b,N,L,Y,se,xe,ke,oe,fe){if(n.timeoutHandle=-1,ke=r.subtreeFlags,ke&8192||(ke&16785408)===16785408){ke={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:pt},cy(r,b,ke);var $e=(b&62914560)===b?tu-st():(b&4194048)===b?my-st():0;if($e=X5(ke,$e),$e!==null){Gr=b,n.cancelPendingCommit=$e(Cy.bind(null,n,r,b,i,d,x,N,L,Y,xe,ke,null,oe,fe)),ks(n,b,N,!se);return}}Cy(n,r,b,i,d,x,N,L,Y)}function m5(n){for(var r=n;;){var i=r.tag;if((i===0||i===11||i===15)&&r.flags&16384&&(i=r.updateQueue,i!==null&&(i=i.stores,i!==null)))for(var d=0;d<i.length;d++){var x=i[d],b=x.getSnapshot;x=x.value;try{if(!Sa(b(),x))return!1}catch{return!1}}if(i=r.child,r.subtreeFlags&16384&&i!==null)i.return=r,r=i;else{if(r===n)break;for(;r.sibling===null;){if(r.return===null||r.return===n)return!0;r=r.return}r.sibling.return=r.return,r=r.sibling}}return!0}function ks(n,r,i,d){r&=~mm,r&=~ol,n.suspendedLanes|=r,n.pingedLanes&=~r,d&&(n.warmLanes|=r),d=n.expirationTimes;for(var x=r;0<x;){var b=31-We(x),N=1<<b;d[b]=-1,x&=~N}i!==0&&ar(n,i,r)}function ru(){return(Mt&6)===0?(so(0),!1):!0}function ym(){if(dt!==null){if(It===0)var n=dt.return;else n=dt,Or=Js=null,Lf(n),Bl=null,Bi=0,n=dt;for(;n!==null;)Kx(n.alternate,n),n=n.return;dt=null}}function Xl(n,r){var i=n.timeoutHandle;i!==-1&&(n.timeoutHandle=-1,I5(i)),i=n.cancelPendingCommit,i!==null&&(n.cancelPendingCommit=null,i()),Gr=0,ym(),Bt=n,dt=i=Ir(n.current,null),ht=r,It=0,Ta=null,xs=!1,Kl=ln(n,r),fm=!1,Yl=Ma=mm=ol=ys=un=0,ua=ao=null,pm=!1,(r&8)!==0&&(r|=r&32);var d=n.entangledLanes;if(d!==0)for(n=n.entanglements,d&=r;0<d;){var x=31-We(d),b=1<<x;r|=n[x],d&=~b}return Vr=r,Cc(),i}function yy(n,r){lt=null,q.H=Yi,r===Pl||r===Ic?(r=L0(),It=3):r===wf?(r=L0(),It=4):It=r===Qf?8:r!==null&&typeof r=="object"&&typeof r.then=="function"?6:1,Ta=r,dt===null&&(un=1,Wc(n,Ba(r,n.current)))}function vy(){var n=Ca.current;return n===null?!0:(ht&4194048)===ht?Va===null:(ht&62914560)===ht||(ht&536870912)!==0?n===Va:!1}function by(){var n=q.H;return q.H=Yi,n===null?Yi:n}function ky(){var n=q.A;return q.A=d5,n}function su(){un=4,xs||(ht&4194048)!==ht&&Ca.current!==null||(Kl=!0),(ys&134217727)===0&&(ol&134217727)===0||Bt===null||ks(Bt,ht,Ma,!1)}function vm(n,r,i){var d=Mt;Mt|=2;var x=by(),b=ky();(Bt!==n||ht!==r)&&(au=null,Xl(n,r)),r=!1;var N=un;e:do try{if(It!==0&&dt!==null){var L=dt,Y=Ta;switch(It){case 8:ym(),N=6;break e;case 3:case 2:case 9:case 6:Ca.current===null&&(r=!0);var se=It;if(It=0,Ta=null,Zl(n,L,Y,se),i&&Kl){N=0;break e}break;default:se=It,It=0,Ta=null,Zl(n,L,Y,se)}}p5(),N=un;break}catch(xe){yy(n,xe)}while(!0);return r&&n.shellSuspendCounter++,Or=Js=null,Mt=d,q.H=x,q.A=b,dt===null&&(Bt=null,ht=0,Cc()),N}function p5(){for(;dt!==null;)wy(dt)}function h5(n,r){var i=Mt;Mt|=2;var d=by(),x=ky();Bt!==n||ht!==r?(au=null,nu=st()+500,Xl(n,r)):Kl=ln(n,r);e:do try{if(It!==0&&dt!==null){r=dt;var b=Ta;t:switch(It){case 1:It=0,Ta=null,Zl(n,r,b,1);break;case 2:case 9:if(_0(b)){It=0,Ta=null,Sy(r);break}r=function(){It!==2&&It!==9||Bt!==n||(It=7),kr(n)},b.then(r,r);break e;case 3:It=7;break e;case 4:It=5;break e;case 7:_0(b)?(It=0,Ta=null,Sy(r)):(It=0,Ta=null,Zl(n,r,b,7));break;case 5:var N=null;switch(dt.tag){case 26:N=dt.memoizedState;case 5:case 27:var L=dt;if(N?ov(N):L.stateNode.complete){It=0,Ta=null;var Y=L.sibling;if(Y!==null)dt=Y;else{var se=L.return;se!==null?(dt=se,lu(se)):dt=null}break t}}It=0,Ta=null,Zl(n,r,b,5);break;case 6:It=0,Ta=null,Zl(n,r,b,6);break;case 8:ym(),un=6;break e;default:throw Error(l(462))}}g5();break}catch(xe){yy(n,xe)}while(!0);return Or=Js=null,q.H=d,q.A=x,Mt=i,dt!==null?0:(Bt=null,ht=0,Cc(),un)}function g5(){for(;dt!==null&&!At();)wy(dt)}function wy(n){var r=Gx(n.alternate,n,Vr);n.memoizedProps=n.pendingProps,r===null?lu(n):dt=r}function Sy(n){var r=n,i=r.alternate;switch(r.tag){case 15:case 0:r=Px(i,r,r.pendingProps,r.type,void 0,ht);break;case 11:r=Px(i,r,r.pendingProps,r.type.render,r.ref,ht);break;case 5:Lf(r);default:Kx(i,r),r=dt=k0(r,Vr),r=Gx(i,r,Vr)}n.memoizedProps=n.pendingProps,r===null?lu(n):dt=r}function Zl(n,r,i,d){Or=Js=null,Lf(r),Bl=null,Bi=0;var x=r.return;try{if(r5(n,x,r,i,ht)){un=1,Wc(n,Ba(i,n.current)),dt=null;return}}catch(b){if(x!==null)throw dt=x,b;un=1,Wc(n,Ba(i,n.current)),dt=null;return}r.flags&32768?(yt||d===1?n=!0:Kl||(ht&536870912)!==0?n=!1:(xs=n=!0,(d===2||d===9||d===3||d===6)&&(d=Ca.current,d!==null&&d.tag===13&&(d.flags|=16384))),jy(r,n)):lu(r)}function lu(n){var r=n;do{if((r.flags&32768)!==0){jy(r,xs);return}n=r.return;var i=i5(r.alternate,r,Vr);if(i!==null){dt=i;return}if(r=r.sibling,r!==null){dt=r;return}dt=r=n}while(r!==null);un===0&&(un=5)}function jy(n,r){do{var i=o5(n.alternate,n);if(i!==null){i.flags&=32767,dt=i;return}if(i=n.return,i!==null&&(i.flags|=32768,i.subtreeFlags=0,i.deletions=null),!r&&(n=n.sibling,n!==null)){dt=n;return}dt=n=i}while(n!==null);un=6,dt=null}function Cy(n,r,i,d,x,b,N,L,Y){n.cancelPendingCommit=null;do iu();while(Tn!==0);if((Mt&6)!==0)throw Error(l(327));if(r!==null){if(r===n.current)throw Error(l(177));if(b=r.lanes|r.childLanes,b|=lf,An(n,i,b,N,L,Y),n===Bt&&(dt=Bt=null,ht=0),Ql=r,bs=n,Gr=i,hm=b,gm=x,py=d,(r.subtreeFlags&10256)!==0||(r.flags&10256)!==0?(n.callbackNode=null,n.callbackPriority=0,b5(De,function(){return Ay(),null})):(n.callbackNode=null,n.callbackPriority=0),d=(r.flags&13878)!==0,(r.subtreeFlags&13878)!==0||d){d=q.T,q.T=null,x=ae.p,ae.p=2,N=Mt,Mt|=4;try{c5(n,r,i)}finally{Mt=N,ae.p=x,q.T=d}}Tn=1,Ny(),Ty(),My()}}function Ny(){if(Tn===1){Tn=0;var n=bs,r=Ql,i=(r.flags&13878)!==0;if((r.subtreeFlags&13878)!==0||i){i=q.T,q.T=null;var d=ae.p;ae.p=2;var x=Mt;Mt|=4;try{ly(r,n);var b=Rm,N=f0(n.containerInfo),L=b.focusedElem,Y=b.selectionRange;if(N!==L&&L&&L.ownerDocument&&d0(L.ownerDocument.documentElement,L)){if(Y!==null&&tf(L)){var se=Y.start,xe=Y.end;if(xe===void 0&&(xe=se),"selectionStart"in L)L.selectionStart=se,L.selectionEnd=Math.min(xe,L.value.length);else{var ke=L.ownerDocument||document,oe=ke&&ke.defaultView||window;if(oe.getSelection){var fe=oe.getSelection(),$e=L.textContent.length,Xe=Math.min(Y.start,$e),zt=Y.end===void 0?Xe:Math.min(Y.end,$e);!fe.extend&&Xe>zt&&(N=zt,zt=Xe,Xe=N);var ne=u0(L,Xe),J=u0(L,zt);if(ne&&J&&(fe.rangeCount!==1||fe.anchorNode!==ne.node||fe.anchorOffset!==ne.offset||fe.focusNode!==J.node||fe.focusOffset!==J.offset)){var re=ke.createRange();re.setStart(ne.node,ne.offset),fe.removeAllRanges(),Xe>zt?(fe.addRange(re),fe.extend(J.node,J.offset)):(re.setEnd(J.node,J.offset),fe.addRange(re))}}}}for(ke=[],fe=L;fe=fe.parentNode;)fe.nodeType===1&&ke.push({element:fe,left:fe.scrollLeft,top:fe.scrollTop});for(typeof L.focus=="function"&&L.focus(),L=0;L<ke.length;L++){var ve=ke[L];ve.element.scrollLeft=ve.left,ve.element.scrollTop=ve.top}}vu=!!Am,Rm=Am=null}finally{Mt=x,ae.p=d,q.T=i}}n.current=r,Tn=2}}function Ty(){if(Tn===2){Tn=0;var n=bs,r=Ql,i=(r.flags&8772)!==0;if((r.subtreeFlags&8772)!==0||i){i=q.T,q.T=null;var d=ae.p;ae.p=2;var x=Mt;Mt|=4;try{ty(n,r.alternate,r)}finally{Mt=x,ae.p=d,q.T=i}}Tn=3}}function My(){if(Tn===4||Tn===3){Tn=0,fn();var n=bs,r=Ql,i=Gr,d=py;(r.subtreeFlags&10256)!==0||(r.flags&10256)!==0?Tn=5:(Tn=0,Ql=bs=null,Ey(n,n.pendingLanes));var x=n.pendingLanes;if(x===0&&(vs=null),ba(i),r=r.stateNode,Te&&typeof Te.onCommitFiberRoot=="function")try{Te.onCommitFiberRoot(Ne,r,void 0,(r.current.flags&128)===128)}catch{}if(d!==null){r=q.T,x=ae.p,ae.p=2,q.T=null;try{for(var b=n.onRecoverableError,N=0;N<d.length;N++){var L=d[N];b(L.value,{componentStack:L.stack})}}finally{q.T=r,ae.p=x}}(Gr&3)!==0&&iu(),kr(n),x=n.pendingLanes,(i&261930)!==0&&(x&42)!==0?n===xm?ro++:(ro=0,xm=n):ro=0,so(0)}}function Ey(n,r){(n.pooledCacheLanes&=r)===0&&(r=n.pooledCache,r!=null&&(n.pooledCache=null,$i(r)))}function iu(){return Ny(),Ty(),My(),Ay()}function Ay(){if(Tn!==5)return!1;var n=bs,r=hm;hm=0;var i=ba(Gr),d=q.T,x=ae.p;try{ae.p=32>i?32:i,q.T=null,i=gm,gm=null;var b=bs,N=Gr;if(Tn=0,Ql=bs=null,Gr=0,(Mt&6)!==0)throw Error(l(331));var L=Mt;if(Mt|=4,dy(b.current),oy(b,b.current,N,i),Mt=L,so(0,!1),Te&&typeof Te.onPostCommitFiberRoot=="function")try{Te.onPostCommitFiberRoot(Ne,b)}catch{}return!0}finally{ae.p=x,q.T=d,Ey(n,r)}}function Ry(n,r,i){r=Ba(i,r),r=Yf(n.stateNode,r,2),n=ms(n,r,2),n!==null&&(En(n,2),kr(n))}function Lt(n,r,i){if(n.tag===3)Ry(n,n,i);else for(;r!==null;){if(r.tag===3){Ry(r,n,i);break}else if(r.tag===1){var d=r.stateNode;if(typeof r.type.getDerivedStateFromError=="function"||typeof d.componentDidCatch=="function"&&(vs===null||!vs.has(d))){n=Ba(i,n),i=_x(2),d=ms(r,i,2),d!==null&&(Ix(i,d,r,n),En(d,2),kr(d));break}}r=r.return}}function bm(n,r,i){var d=n.pingCache;if(d===null){d=n.pingCache=new f5;var x=new Set;d.set(r,x)}else x=d.get(r),x===void 0&&(x=new Set,d.set(r,x));x.has(i)||(fm=!0,x.add(i),n=x5.bind(null,n,r,i),r.then(n,n))}function x5(n,r,i){var d=n.pingCache;d!==null&&d.delete(r),n.pingedLanes|=n.suspendedLanes&i,n.warmLanes&=~i,Bt===n&&(ht&i)===i&&(un===4||un===3&&(ht&62914560)===ht&&300>st()-tu?(Mt&2)===0&&Xl(n,0):mm|=i,Yl===ht&&(Yl=0)),kr(n)}function _y(n,r){r===0&&(r=Oa()),n=Qs(n,r),n!==null&&(En(n,r),kr(n))}function y5(n){var r=n.memoizedState,i=0;r!==null&&(i=r.retryLane),_y(n,i)}function v5(n,r){var i=0;switch(n.tag){case 31:case 13:var d=n.stateNode,x=n.memoizedState;x!==null&&(i=x.retryLane);break;case 19:d=n.stateNode;break;case 22:d=n.stateNode._retryCache;break;default:throw Error(l(314))}d!==null&&d.delete(r),_y(n,i)}function b5(n,r){return sn(n,r)}var ou=null,Jl=null,km=!1,cu=!1,wm=!1,ws=0;function kr(n){n!==Jl&&n.next===null&&(Jl===null?ou=Jl=n:Jl=Jl.next=n),cu=!0,km||(km=!0,w5())}function so(n,r){if(!wm&&cu){wm=!0;do for(var i=!1,d=ou;d!==null;){if(n!==0){var x=d.pendingLanes;if(x===0)var b=0;else{var N=d.suspendedLanes,L=d.pingedLanes;b=(1<<31-We(42|n)+1)-1,b&=x&~(N&~L),b=b&201326741?b&201326741|1:b?b|2:0}b!==0&&(i=!0,Dy(d,b))}else b=ht,b=St(d,d===Bt?b:0,d.cancelPendingCommit!==null||d.timeoutHandle!==-1),(b&3)===0||ln(d,b)||(i=!0,Dy(d,b));d=d.next}while(i);wm=!1}}function k5(){Iy()}function Iy(){cu=km=!1;var n=0;ws!==0&&_5()&&(n=ws);for(var r=st(),i=null,d=ou;d!==null;){var x=d.next,b=Ly(d,r);b===0?(d.next=null,i===null?ou=x:i.next=x,x===null&&(Jl=i)):(i=d,(n!==0||(b&3)!==0)&&(cu=!0)),d=x}Tn!==0&&Tn!==5||so(n),ws!==0&&(ws=0)}function Ly(n,r){for(var i=n.suspendedLanes,d=n.pingedLanes,x=n.expirationTimes,b=n.pendingLanes&-62914561;0<b;){var N=31-We(b),L=1<<N,Y=x[N];Y===-1?((L&i)===0||(L&d)!==0)&&(x[N]=$t(L,r)):Y<=r&&(n.expiredLanes|=L),b&=~L}if(r=Bt,i=ht,i=St(n,n===r?i:0,n.cancelPendingCommit!==null||n.timeoutHandle!==-1),d=n.callbackNode,i===0||n===r&&(It===2||It===9)||n.cancelPendingCommit!==null)return d!==null&&d!==null&&Ut(d),n.callbackNode=null,n.callbackPriority=0;if((i&3)===0||ln(n,i)){if(r=i&-i,r===n.callbackPriority)return r;switch(d!==null&&Ut(d),ba(i)){case 2:case 8:i=Se;break;case 32:i=De;break;case 268435456:i=Ue;break;default:i=De}return d=Oy.bind(null,n),i=sn(i,d),n.callbackPriority=r,n.callbackNode=i,r}return d!==null&&d!==null&&Ut(d),n.callbackPriority=2,n.callbackNode=null,2}function Oy(n,r){if(Tn!==0&&Tn!==5)return n.callbackNode=null,n.callbackPriority=0,null;var i=n.callbackNode;if(iu()&&n.callbackNode!==i)return null;var d=ht;return d=St(n,n===Bt?d:0,n.cancelPendingCommit!==null||n.timeoutHandle!==-1),d===0?null:(gy(n,d,r),Ly(n,st()),n.callbackNode!=null&&n.callbackNode===i?Oy.bind(null,n):null)}function Dy(n,r){if(iu())return null;gy(n,r,!0)}function w5(){L5(function(){(Mt&6)!==0?sn(pe,k5):Iy()})}function Sm(){if(ws===0){var n=Ul;n===0&&(n=Oe,Oe<<=1,(Oe&261888)===0&&(Oe=256)),ws=n}return ws}function zy(n){return n==null||typeof n=="symbol"||typeof n=="boolean"?null:typeof n=="function"?n:bt(""+n)}function Uy(n,r){var i=r.ownerDocument.createElement("input");return i.name=r.name,i.value=r.value,n.id&&i.setAttribute("form",n.id),r.parentNode.insertBefore(i,r),n=new FormData(n),i.parentNode.removeChild(i),n}function S5(n,r,i,d,x){if(r==="submit"&&i&&i.stateNode===x){var b=zy((x[Zt]||null).action),N=d.submitter;N&&(r=(r=N[Zt]||null)?zy(r.formAction):N.getAttribute("formAction"),r!==null&&(b=r,N=null));var L=new kc("action","action",null,d,x);n.push({event:L,listeners:[{instance:null,listener:function(){if(d.defaultPrevented){if(ws!==0){var Y=N?Uy(x,N):new FormData(x);Ff(i,{pending:!0,data:Y,method:x.method,action:b},null,Y)}}else typeof b=="function"&&(L.preventDefault(),Y=N?Uy(x,N):new FormData(x),Ff(i,{pending:!0,data:Y,method:x.method,action:b},b,Y))},currentTarget:x}]})}}for(var jm=0;jm<sf.length;jm++){var Cm=sf[jm],j5=Cm.toLowerCase(),C5=Cm[0].toUpperCase()+Cm.slice(1);ir(j5,"on"+C5)}ir(h0,"onAnimationEnd"),ir(g0,"onAnimationIteration"),ir(x0,"onAnimationStart"),ir("dblclick","onDoubleClick"),ir("focusin","onFocus"),ir("focusout","onBlur"),ir(Bj,"onTransitionRun"),ir(Hj,"onTransitionStart"),ir(Fj,"onTransitionCancel"),ir(y0,"onTransitionEnd"),Rt("onMouseEnter",["mouseout","mouseover"]),Rt("onMouseLeave",["mouseout","mouseover"]),Rt("onPointerEnter",["pointerout","pointerover"]),Rt("onPointerLeave",["pointerout","pointerover"]),rt("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),rt("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),rt("onBeforeInput",["compositionend","keypress","textInput","paste"]),rt("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),rt("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),rt("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var lo="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),N5=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(lo));function $y(n,r){r=(r&4)!==0;for(var i=0;i<n.length;i++){var d=n[i],x=d.event;d=d.listeners;e:{var b=void 0;if(r)for(var N=d.length-1;0<=N;N--){var L=d[N],Y=L.instance,se=L.currentTarget;if(L=L.listener,Y!==b&&x.isPropagationStopped())break e;b=L,x.currentTarget=se;try{b(x)}catch(xe){jc(xe)}x.currentTarget=null,b=Y}else for(N=0;N<d.length;N++){if(L=d[N],Y=L.instance,se=L.currentTarget,L=L.listener,Y!==b&&x.isPropagationStopped())break e;b=L,x.currentTarget=se;try{b(x)}catch(xe){jc(xe)}x.currentTarget=null,b=Y}}}}function ft(n,r){var i=r[on];i===void 0&&(i=r[on]=new Set);var d=n+"__bubble";i.has(d)||(Py(r,n,2,!1),i.add(d))}function Nm(n,r,i){var d=0;r&&(d|=4),Py(i,n,d,r)}var uu="_reactListening"+Math.random().toString(36).slice(2);function Tm(n){if(!n[uu]){n[uu]=!0,Le.forEach(function(i){i!=="selectionchange"&&(N5.has(i)||Nm(i,!1,n),Nm(i,!0,n))});var r=n.nodeType===9?n:n.ownerDocument;r===null||r[uu]||(r[uu]=!0,Nm("selectionchange",!1,r))}}function Py(n,r,i,d){switch(hv(r)){case 2:var x=eC;break;case 8:x=tC;break;default:x=Hm}i=x.bind(null,r,i,n),x=void 0,!Gd||r!=="touchstart"&&r!=="touchmove"&&r!=="wheel"||(x=!0),d?x!==void 0?n.addEventListener(r,i,{capture:!0,passive:x}):n.addEventListener(r,i,!0):x!==void 0?n.addEventListener(r,i,{passive:x}):n.addEventListener(r,i,!1)}function Mm(n,r,i,d,x){var b=d;if((r&1)===0&&(r&2)===0&&d!==null)e:for(;;){if(d===null)return;var N=d.tag;if(N===3||N===4){var L=d.stateNode.containerInfo;if(L===x)break;if(N===4)for(N=d.return;N!==null;){var Y=N.tag;if((Y===3||Y===4)&&N.stateNode.containerInfo===x)return;N=N.return}for(;L!==null;){if(N=ka(L),N===null)return;if(Y=N.tag,Y===5||Y===6||Y===26||Y===27){d=b=N;continue e}L=L.parentNode}}d=d.return}Vg(function(){var se=b,xe=Vs(i),ke=[];e:{var oe=v0.get(n);if(oe!==void 0){var fe=kc,$e=n;switch(n){case"keypress":if(vc(i)===0)break e;case"keydown":case"keyup":fe=vj;break;case"focusin":$e="focus",fe=Qd;break;case"focusout":$e="blur",fe=Qd;break;case"beforeblur":case"afterblur":fe=Qd;break;case"click":if(i.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":fe=Kg;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":fe=ij;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":fe=wj;break;case h0:case g0:case x0:fe=uj;break;case y0:fe=jj;break;case"scroll":case"scrollend":fe=sj;break;case"wheel":fe=Nj;break;case"copy":case"cut":case"paste":fe=fj;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":fe=Qg;break;case"toggle":case"beforetoggle":fe=Mj}var Xe=(r&4)!==0,zt=!Xe&&(n==="scroll"||n==="scrollend"),ne=Xe?oe!==null?oe+"Capture":null:oe;Xe=[];for(var J=se,re;J!==null;){var ve=J;if(re=ve.stateNode,ve=ve.tag,ve!==5&&ve!==26&&ve!==27||re===null||ne===null||(ve=Mi(J,ne),ve!=null&&Xe.push(io(J,ve,re))),zt)break;J=J.return}0<Xe.length&&(oe=new fe(oe,$e,null,i,xe),ke.push({event:oe,listeners:Xe}))}}if((r&7)===0){e:{if(oe=n==="mouseover"||n==="pointerover",fe=n==="mouseout"||n==="pointerout",oe&&i!==$a&&($e=i.relatedTarget||i.fromElement)&&(ka($e)||$e[Hn]))break e;if((fe||oe)&&(oe=xe.window===xe?xe:(oe=xe.ownerDocument)?oe.defaultView||oe.parentWindow:window,fe?($e=i.relatedTarget||i.toElement,fe=se,$e=$e?ka($e):null,$e!==null&&(zt=c($e),Xe=$e.tag,$e!==zt||Xe!==5&&Xe!==27&&Xe!==6)&&($e=null)):(fe=null,$e=se),fe!==$e)){if(Xe=Kg,ve="onMouseLeave",ne="onMouseEnter",J="mouse",(n==="pointerout"||n==="pointerover")&&(Xe=Qg,ve="onPointerLeave",ne="onPointerEnter",J="pointer"),zt=fe==null?oe:za(fe),re=$e==null?oe:za($e),oe=new Xe(ve,J+"leave",fe,i,xe),oe.target=zt,oe.relatedTarget=re,ve=null,ka(xe)===se&&(Xe=new Xe(ne,J+"enter",$e,i,xe),Xe.target=re,Xe.relatedTarget=zt,ve=Xe),zt=ve,fe&&$e)t:{for(Xe=T5,ne=fe,J=$e,re=0,ve=ne;ve;ve=Xe(ve))re++;ve=0;for(var Ge=J;Ge;Ge=Xe(Ge))ve++;for(;0<re-ve;)ne=Xe(ne),re--;for(;0<ve-re;)J=Xe(J),ve--;for(;re--;){if(ne===J||J!==null&&ne===J.alternate){Xe=ne;break t}ne=Xe(ne),J=Xe(J)}Xe=null}else Xe=null;fe!==null&&By(ke,oe,fe,Xe,!1),$e!==null&&zt!==null&&By(ke,zt,$e,Xe,!0)}}e:{if(oe=se?za(se):window,fe=oe.nodeName&&oe.nodeName.toLowerCase(),fe==="select"||fe==="input"&&oe.type==="file")var Nt=r0;else if(n0(oe))if(s0)Nt=Uj;else{Nt=Dj;var Be=Oj}else fe=oe.nodeName,!fe||fe.toLowerCase()!=="input"||oe.type!=="checkbox"&&oe.type!=="radio"?se&&le(se.elementType)&&(Nt=r0):Nt=zj;if(Nt&&(Nt=Nt(n,se))){a0(ke,Nt,i,xe);break e}Be&&Be(n,oe,se),n==="focusout"&&se&&oe.type==="number"&&se.memoizedProps.value!=null&&Nn(oe,"number",oe.value)}switch(Be=se?za(se):window,n){case"focusin":(n0(Be)||Be.contentEditable==="true")&&(Al=Be,nf=se,Di=null);break;case"focusout":Di=nf=Al=null;break;case"mousedown":af=!0;break;case"contextmenu":case"mouseup":case"dragend":af=!1,m0(ke,i,xe);break;case"selectionchange":if(Pj)break;case"keydown":case"keyup":m0(ke,i,xe)}var ct;if(Zd)e:{switch(n){case"compositionstart":var gt="onCompositionStart";break e;case"compositionend":gt="onCompositionEnd";break e;case"compositionupdate":gt="onCompositionUpdate";break e}gt=void 0}else El?e0(n,i)&&(gt="onCompositionEnd"):n==="keydown"&&i.keyCode===229&&(gt="onCompositionStart");gt&&(Xg&&i.locale!=="ko"&&(El||gt!=="onCompositionStart"?gt==="onCompositionEnd"&&El&&(ct=Gg()):(ls=xe,Wd="value"in ls?ls.value:ls.textContent,El=!0)),Be=du(se,gt),0<Be.length&&(gt=new Yg(gt,n,null,i,xe),ke.push({event:gt,listeners:Be}),ct?gt.data=ct:(ct=t0(i),ct!==null&&(gt.data=ct)))),(ct=Aj?Rj(n,i):_j(n,i))&&(gt=du(se,"onBeforeInput"),0<gt.length&&(Be=new Yg("onBeforeInput","beforeinput",null,i,xe),ke.push({event:Be,listeners:gt}),Be.data=ct)),S5(ke,n,se,i,xe)}$y(ke,r)})}function io(n,r,i){return{instance:n,listener:r,currentTarget:i}}function du(n,r){for(var i=r+"Capture",d=[];n!==null;){var x=n,b=x.stateNode;if(x=x.tag,x!==5&&x!==26&&x!==27||b===null||(x=Mi(n,i),x!=null&&d.unshift(io(n,x,b)),x=Mi(n,r),x!=null&&d.push(io(n,x,b))),n.tag===3)return d;n=n.return}return[]}function T5(n){if(n===null)return null;do n=n.return;while(n&&n.tag!==5&&n.tag!==27);return n||null}function By(n,r,i,d,x){for(var b=r._reactName,N=[];i!==null&&i!==d;){var L=i,Y=L.alternate,se=L.stateNode;if(L=L.tag,Y!==null&&Y===d)break;L!==5&&L!==26&&L!==27||se===null||(Y=se,x?(se=Mi(i,b),se!=null&&N.unshift(io(i,se,Y))):x||(se=Mi(i,b),se!=null&&N.push(io(i,se,Y)))),i=i.return}N.length!==0&&n.push({event:r,listeners:N})}var M5=/\r\n?/g,E5=/\u0000|\uFFFD/g;function Hy(n){return(typeof n=="string"?n:""+n).replace(M5,`
9
- `).replace(E5,"")}function Fy(n,r){return r=Hy(r),Hy(n)===r}function Dt(n,r,i,d,x,b){switch(i){case"children":typeof d=="string"?r==="body"||r==="textarea"&&d===""||lr(n,d):(typeof d=="number"||typeof d=="bigint")&&r!=="body"&&lr(n,""+d);break;case"className":_n(n,"class",d);break;case"tabIndex":_n(n,"tabindex",d);break;case"dir":case"role":case"viewBox":case"width":case"height":_n(n,i,d);break;case"style":Ua(n,d,b);break;case"data":if(r!=="object"){_n(n,"data",d);break}case"src":case"href":if(d===""&&(r!=="a"||i!=="href")){n.removeAttribute(i);break}if(d==null||typeof d=="function"||typeof d=="symbol"||typeof d=="boolean"){n.removeAttribute(i);break}d=bt(""+d),n.setAttribute(i,d);break;case"action":case"formAction":if(typeof d=="function"){n.setAttribute(i,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}else typeof b=="function"&&(i==="formAction"?(r!=="input"&&Dt(n,r,"name",x.name,x,null),Dt(n,r,"formEncType",x.formEncType,x,null),Dt(n,r,"formMethod",x.formMethod,x,null),Dt(n,r,"formTarget",x.formTarget,x,null)):(Dt(n,r,"encType",x.encType,x,null),Dt(n,r,"method",x.method,x,null),Dt(n,r,"target",x.target,x,null)));if(d==null||typeof d=="symbol"||typeof d=="boolean"){n.removeAttribute(i);break}d=bt(""+d),n.setAttribute(i,d);break;case"onClick":d!=null&&(n.onclick=pt);break;case"onScroll":d!=null&&ft("scroll",n);break;case"onScrollEnd":d!=null&&ft("scrollend",n);break;case"dangerouslySetInnerHTML":if(d!=null){if(typeof d!="object"||!("__html"in d))throw Error(l(61));if(i=d.__html,i!=null){if(x.children!=null)throw Error(l(60));n.innerHTML=i}}break;case"multiple":n.multiple=d&&typeof d!="function"&&typeof d!="symbol";break;case"muted":n.muted=d&&typeof d!="function"&&typeof d!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(d==null||typeof d=="function"||typeof d=="boolean"||typeof d=="symbol"){n.removeAttribute("xlink:href");break}i=bt(""+d),n.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",i);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":d!=null&&typeof d!="function"&&typeof d!="symbol"?n.setAttribute(i,""+d):n.removeAttribute(i);break;case"inert":case"allowFullScreen":case"async":case"autoPlay":case"controls":case"default":case"defer":case"disabled":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"hidden":case"loop":case"noModule":case"noValidate":case"open":case"playsInline":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"itemScope":d&&typeof d!="function"&&typeof d!="symbol"?n.setAttribute(i,""):n.removeAttribute(i);break;case"capture":case"download":d===!0?n.setAttribute(i,""):d!==!1&&d!=null&&typeof d!="function"&&typeof d!="symbol"?n.setAttribute(i,d):n.removeAttribute(i);break;case"cols":case"rows":case"size":case"span":d!=null&&typeof d!="function"&&typeof d!="symbol"&&!isNaN(d)&&1<=d?n.setAttribute(i,d):n.removeAttribute(i);break;case"rowSpan":case"start":d==null||typeof d=="function"||typeof d=="symbol"||isNaN(d)?n.removeAttribute(i):n.setAttribute(i,d);break;case"popover":ft("beforetoggle",n),ft("toggle",n),Xn(n,"popover",d);break;case"xlinkActuate":wa(n,"http://www.w3.org/1999/xlink","xlink:actuate",d);break;case"xlinkArcrole":wa(n,"http://www.w3.org/1999/xlink","xlink:arcrole",d);break;case"xlinkRole":wa(n,"http://www.w3.org/1999/xlink","xlink:role",d);break;case"xlinkShow":wa(n,"http://www.w3.org/1999/xlink","xlink:show",d);break;case"xlinkTitle":wa(n,"http://www.w3.org/1999/xlink","xlink:title",d);break;case"xlinkType":wa(n,"http://www.w3.org/1999/xlink","xlink:type",d);break;case"xmlBase":wa(n,"http://www.w3.org/XML/1998/namespace","xml:base",d);break;case"xmlLang":wa(n,"http://www.w3.org/XML/1998/namespace","xml:lang",d);break;case"xmlSpace":wa(n,"http://www.w3.org/XML/1998/namespace","xml:space",d);break;case"is":Xn(n,"is",d);break;case"innerText":case"textContent":break;default:(!(2<i.length)||i[0]!=="o"&&i[0]!=="O"||i[1]!=="n"&&i[1]!=="N")&&(i=Ae.get(i)||i,Xn(n,i,d))}}function Em(n,r,i,d,x,b){switch(i){case"style":Ua(n,d,b);break;case"dangerouslySetInnerHTML":if(d!=null){if(typeof d!="object"||!("__html"in d))throw Error(l(61));if(i=d.__html,i!=null){if(x.children!=null)throw Error(l(60));n.innerHTML=i}}break;case"children":typeof d=="string"?lr(n,d):(typeof d=="number"||typeof d=="bigint")&&lr(n,""+d);break;case"onScroll":d!=null&&ft("scroll",n);break;case"onScrollEnd":d!=null&&ft("scrollend",n);break;case"onClick":d!=null&&(n.onclick=pt);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!ot.hasOwnProperty(i))e:{if(i[0]==="o"&&i[1]==="n"&&(x=i.endsWith("Capture"),r=i.slice(2,x?i.length-7:void 0),b=n[Zt]||null,b=b!=null?b[i]:null,typeof b=="function"&&n.removeEventListener(r,b,x),typeof d=="function")){typeof b!="function"&&b!==null&&(i in n?n[i]=null:n.hasAttribute(i)&&n.removeAttribute(i)),n.addEventListener(r,d,x);break e}i in n?n[i]=d:d===!0?n.setAttribute(i,""):Xn(n,i,d)}}}function Dn(n,r,i){switch(r){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":ft("error",n),ft("load",n);var d=!1,x=!1,b;for(b in i)if(i.hasOwnProperty(b)){var N=i[b];if(N!=null)switch(b){case"src":d=!0;break;case"srcSet":x=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(l(137,r));default:Dt(n,r,b,N,i,null)}}x&&Dt(n,r,"srcSet",i.srcSet,i,null),d&&Dt(n,r,"src",i.src,i,null);return;case"input":ft("invalid",n);var L=b=N=x=null,Y=null,se=null;for(d in i)if(i.hasOwnProperty(d)){var xe=i[d];if(xe!=null)switch(d){case"name":x=xe;break;case"type":N=xe;break;case"checked":Y=xe;break;case"defaultChecked":se=xe;break;case"value":b=xe;break;case"defaultValue":L=xe;break;case"children":case"dangerouslySetInnerHTML":if(xe!=null)throw Error(l(137,r));break;default:Dt(n,r,d,xe,i,null)}}Wt(n,b,L,Y,se,N,x,!1);return;case"select":ft("invalid",n),d=N=b=null;for(x in i)if(i.hasOwnProperty(x)&&(L=i[x],L!=null))switch(x){case"value":b=L;break;case"defaultValue":N=L;break;case"multiple":d=L;default:Dt(n,r,x,L,i,null)}r=b,i=N,n.multiple=!!d,r!=null?bn(n,!!d,r,!1):i!=null&&bn(n,!!d,i,!0);return;case"textarea":ft("invalid",n),b=x=d=null;for(N in i)if(i.hasOwnProperty(N)&&(L=i[N],L!=null))switch(N){case"value":d=L;break;case"defaultValue":x=L;break;case"children":b=L;break;case"dangerouslySetInnerHTML":if(L!=null)throw Error(l(91));break;default:Dt(n,r,N,L,i,null)}rs(n,d,x,b);return;case"option":for(Y in i)i.hasOwnProperty(Y)&&(d=i[Y],d!=null)&&(Y==="selected"?n.selected=d&&typeof d!="function"&&typeof d!="symbol":Dt(n,r,Y,d,i,null));return;case"dialog":ft("beforetoggle",n),ft("toggle",n),ft("cancel",n),ft("close",n);break;case"iframe":case"object":ft("load",n);break;case"video":case"audio":for(d=0;d<lo.length;d++)ft(lo[d],n);break;case"image":ft("error",n),ft("load",n);break;case"details":ft("toggle",n);break;case"embed":case"source":case"link":ft("error",n),ft("load",n);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(se in i)if(i.hasOwnProperty(se)&&(d=i[se],d!=null))switch(se){case"children":case"dangerouslySetInnerHTML":throw Error(l(137,r));default:Dt(n,r,se,d,i,null)}return;default:if(le(r)){for(xe in i)i.hasOwnProperty(xe)&&(d=i[xe],d!==void 0&&Em(n,r,xe,d,i,void 0));return}}for(L in i)i.hasOwnProperty(L)&&(d=i[L],d!=null&&Dt(n,r,L,d,i,null))}function A5(n,r,i,d){switch(r){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var x=null,b=null,N=null,L=null,Y=null,se=null,xe=null;for(fe in i){var ke=i[fe];if(i.hasOwnProperty(fe)&&ke!=null)switch(fe){case"checked":break;case"value":break;case"defaultValue":Y=ke;default:d.hasOwnProperty(fe)||Dt(n,r,fe,null,d,ke)}}for(var oe in d){var fe=d[oe];if(ke=i[oe],d.hasOwnProperty(oe)&&(fe!=null||ke!=null))switch(oe){case"type":b=fe;break;case"name":x=fe;break;case"checked":se=fe;break;case"defaultChecked":xe=fe;break;case"value":N=fe;break;case"defaultValue":L=fe;break;case"children":case"dangerouslySetInnerHTML":if(fe!=null)throw Error(l(137,r));break;default:fe!==ke&&Dt(n,r,oe,fe,d,ke)}}Pt(n,N,L,Y,se,xe,b,x);return;case"select":fe=N=L=oe=null;for(b in i)if(Y=i[b],i.hasOwnProperty(b)&&Y!=null)switch(b){case"value":break;case"multiple":fe=Y;default:d.hasOwnProperty(b)||Dt(n,r,b,null,d,Y)}for(x in d)if(b=d[x],Y=i[x],d.hasOwnProperty(x)&&(b!=null||Y!=null))switch(x){case"value":oe=b;break;case"defaultValue":L=b;break;case"multiple":N=b;default:b!==Y&&Dt(n,r,x,b,d,Y)}r=L,i=N,d=fe,oe!=null?bn(n,!!i,oe,!1):!!d!=!!i&&(r!=null?bn(n,!!i,r,!0):bn(n,!!i,i?[]:"",!1));return;case"textarea":fe=oe=null;for(L in i)if(x=i[L],i.hasOwnProperty(L)&&x!=null&&!d.hasOwnProperty(L))switch(L){case"value":break;case"children":break;default:Dt(n,r,L,null,d,x)}for(N in d)if(x=d[N],b=i[N],d.hasOwnProperty(N)&&(x!=null||b!=null))switch(N){case"value":oe=x;break;case"defaultValue":fe=x;break;case"children":break;case"dangerouslySetInnerHTML":if(x!=null)throw Error(l(91));break;default:x!==b&&Dt(n,r,N,x,d,b)}as(n,oe,fe);return;case"option":for(var $e in i)oe=i[$e],i.hasOwnProperty($e)&&oe!=null&&!d.hasOwnProperty($e)&&($e==="selected"?n.selected=!1:Dt(n,r,$e,null,d,oe));for(Y in d)oe=d[Y],fe=i[Y],d.hasOwnProperty(Y)&&oe!==fe&&(oe!=null||fe!=null)&&(Y==="selected"?n.selected=oe&&typeof oe!="function"&&typeof oe!="symbol":Dt(n,r,Y,oe,d,fe));return;case"img":case"link":case"area":case"base":case"br":case"col":case"embed":case"hr":case"keygen":case"meta":case"param":case"source":case"track":case"wbr":case"menuitem":for(var Xe in i)oe=i[Xe],i.hasOwnProperty(Xe)&&oe!=null&&!d.hasOwnProperty(Xe)&&Dt(n,r,Xe,null,d,oe);for(se in d)if(oe=d[se],fe=i[se],d.hasOwnProperty(se)&&oe!==fe&&(oe!=null||fe!=null))switch(se){case"children":case"dangerouslySetInnerHTML":if(oe!=null)throw Error(l(137,r));break;default:Dt(n,r,se,oe,d,fe)}return;default:if(le(r)){for(var zt in i)oe=i[zt],i.hasOwnProperty(zt)&&oe!==void 0&&!d.hasOwnProperty(zt)&&Em(n,r,zt,void 0,d,oe);for(xe in d)oe=d[xe],fe=i[xe],!d.hasOwnProperty(xe)||oe===fe||oe===void 0&&fe===void 0||Em(n,r,xe,oe,d,fe);return}}for(var ne in i)oe=i[ne],i.hasOwnProperty(ne)&&oe!=null&&!d.hasOwnProperty(ne)&&Dt(n,r,ne,null,d,oe);for(ke in d)oe=d[ke],fe=i[ke],!d.hasOwnProperty(ke)||oe===fe||oe==null&&fe==null||Dt(n,r,ke,oe,d,fe)}function qy(n){switch(n){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function R5(){if(typeof performance.getEntriesByType=="function"){for(var n=0,r=0,i=performance.getEntriesByType("resource"),d=0;d<i.length;d++){var x=i[d],b=x.transferSize,N=x.initiatorType,L=x.duration;if(b&&L&&qy(N)){for(N=0,L=x.responseEnd,d+=1;d<i.length;d++){var Y=i[d],se=Y.startTime;if(se>L)break;var xe=Y.transferSize,ke=Y.initiatorType;xe&&qy(ke)&&(Y=Y.responseEnd,N+=xe*(Y<L?1:(L-se)/(Y-se)))}if(--d,r+=8*(b+N)/(x.duration/1e3),n++,10<n)break}}if(0<n)return r/n/1e6}return navigator.connection&&(n=navigator.connection.downlink,typeof n=="number")?n:5}var Am=null,Rm=null;function fu(n){return n.nodeType===9?n:n.ownerDocument}function Vy(n){switch(n){case"http://www.w3.org/2000/svg":return 1;case"http://www.w3.org/1998/Math/MathML":return 2;default:return 0}}function Gy(n,r){if(n===0)switch(r){case"svg":return 1;case"math":return 2;default:return 0}return n===1&&r==="foreignObject"?0:n}function _m(n,r){return n==="textarea"||n==="noscript"||typeof r.children=="string"||typeof r.children=="number"||typeof r.children=="bigint"||typeof r.dangerouslySetInnerHTML=="object"&&r.dangerouslySetInnerHTML!==null&&r.dangerouslySetInnerHTML.__html!=null}var Im=null;function _5(){var n=window.event;return n&&n.type==="popstate"?n===Im?!1:(Im=n,!0):(Im=null,!1)}var Wy=typeof setTimeout=="function"?setTimeout:void 0,I5=typeof clearTimeout=="function"?clearTimeout:void 0,Ky=typeof Promise=="function"?Promise:void 0,L5=typeof queueMicrotask=="function"?queueMicrotask:typeof Ky<"u"?function(n){return Ky.resolve(null).then(n).catch(O5)}:Wy;function O5(n){setTimeout(function(){throw n})}function Ss(n){return n==="head"}function Yy(n,r){var i=r,d=0;do{var x=i.nextSibling;if(n.removeChild(i),x&&x.nodeType===8)if(i=x.data,i==="/$"||i==="/&"){if(d===0){n.removeChild(x),ai(r);return}d--}else if(i==="$"||i==="$?"||i==="$~"||i==="$!"||i==="&")d++;else if(i==="html")oo(n.ownerDocument.documentElement);else if(i==="head"){i=n.ownerDocument.head,oo(i);for(var b=i.firstChild;b;){var N=b.nextSibling,L=b.nodeName;b[Qn]||L==="SCRIPT"||L==="STYLE"||L==="LINK"&&b.rel.toLowerCase()==="stylesheet"||i.removeChild(b),b=N}}else i==="body"&&oo(n.ownerDocument.body);i=x}while(i);ai(r)}function Qy(n,r){var i=n;n=0;do{var d=i.nextSibling;if(i.nodeType===1?r?(i._stashedDisplay=i.style.display,i.style.display="none"):(i.style.display=i._stashedDisplay||"",i.getAttribute("style")===""&&i.removeAttribute("style")):i.nodeType===3&&(r?(i._stashedText=i.nodeValue,i.nodeValue=""):i.nodeValue=i._stashedText||""),d&&d.nodeType===8)if(i=d.data,i==="/$"){if(n===0)break;n--}else i!=="$"&&i!=="$?"&&i!=="$~"&&i!=="$!"||n++;i=d}while(i)}function Lm(n){var r=n.firstChild;for(r&&r.nodeType===10&&(r=r.nextSibling);r;){var i=r;switch(r=r.nextSibling,i.nodeName){case"HTML":case"HEAD":case"BODY":Lm(i),sr(i);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(i.rel.toLowerCase()==="stylesheet")continue}n.removeChild(i)}}function D5(n,r,i,d){for(;n.nodeType===1;){var x=i;if(n.nodeName.toLowerCase()!==r.toLowerCase()){if(!d&&(n.nodeName!=="INPUT"||n.type!=="hidden"))break}else if(d){if(!n[Qn])switch(r){case"meta":if(!n.hasAttribute("itemprop"))break;return n;case"link":if(b=n.getAttribute("rel"),b==="stylesheet"&&n.hasAttribute("data-precedence"))break;if(b!==x.rel||n.getAttribute("href")!==(x.href==null||x.href===""?null:x.href)||n.getAttribute("crossorigin")!==(x.crossOrigin==null?null:x.crossOrigin)||n.getAttribute("title")!==(x.title==null?null:x.title))break;return n;case"style":if(n.hasAttribute("data-precedence"))break;return n;case"script":if(b=n.getAttribute("src"),(b!==(x.src==null?null:x.src)||n.getAttribute("type")!==(x.type==null?null:x.type)||n.getAttribute("crossorigin")!==(x.crossOrigin==null?null:x.crossOrigin))&&b&&n.hasAttribute("async")&&!n.hasAttribute("itemprop"))break;return n;default:return n}}else if(r==="input"&&n.type==="hidden"){var b=x.name==null?null:""+x.name;if(x.type==="hidden"&&n.getAttribute("name")===b)return n}else return n;if(n=Ga(n.nextSibling),n===null)break}return null}function z5(n,r,i){if(r==="")return null;for(;n.nodeType!==3;)if((n.nodeType!==1||n.nodeName!=="INPUT"||n.type!=="hidden")&&!i||(n=Ga(n.nextSibling),n===null))return null;return n}function Xy(n,r){for(;n.nodeType!==8;)if((n.nodeType!==1||n.nodeName!=="INPUT"||n.type!=="hidden")&&!r||(n=Ga(n.nextSibling),n===null))return null;return n}function Om(n){return n.data==="$?"||n.data==="$~"}function Dm(n){return n.data==="$!"||n.data==="$?"&&n.ownerDocument.readyState!=="loading"}function U5(n,r){var i=n.ownerDocument;if(n.data==="$~")n._reactRetry=r;else if(n.data!=="$?"||i.readyState!=="loading")r();else{var d=function(){r(),i.removeEventListener("DOMContentLoaded",d)};i.addEventListener("DOMContentLoaded",d),n._reactRetry=d}}function Ga(n){for(;n!=null;n=n.nextSibling){var r=n.nodeType;if(r===1||r===3)break;if(r===8){if(r=n.data,r==="$"||r==="$!"||r==="$?"||r==="$~"||r==="&"||r==="F!"||r==="F")break;if(r==="/$"||r==="/&")return null}}return n}var zm=null;function Zy(n){n=n.nextSibling;for(var r=0;n;){if(n.nodeType===8){var i=n.data;if(i==="/$"||i==="/&"){if(r===0)return Ga(n.nextSibling);r--}else i!=="$"&&i!=="$!"&&i!=="$?"&&i!=="$~"&&i!=="&"||r++}n=n.nextSibling}return null}function Jy(n){n=n.previousSibling;for(var r=0;n;){if(n.nodeType===8){var i=n.data;if(i==="$"||i==="$!"||i==="$?"||i==="$~"||i==="&"){if(r===0)return n;r--}else i!=="/$"&&i!=="/&"||r++}n=n.previousSibling}return null}function ev(n,r,i){switch(r=fu(i),n){case"html":if(n=r.documentElement,!n)throw Error(l(452));return n;case"head":if(n=r.head,!n)throw Error(l(453));return n;case"body":if(n=r.body,!n)throw Error(l(454));return n;default:throw Error(l(451))}}function oo(n){for(var r=n.attributes;r.length;)n.removeAttributeNode(r[0]);sr(n)}var Wa=new Map,tv=new Set;function mu(n){return typeof n.getRootNode=="function"?n.getRootNode():n.nodeType===9?n:n.ownerDocument}var Wr=ae.d;ae.d={f:$5,r:P5,D:B5,C:H5,L:F5,m:q5,X:G5,S:V5,M:W5};function $5(){var n=Wr.f(),r=ru();return n||r}function P5(n){var r=ra(n);r!==null&&r.tag===5&&r.type==="form"?yx(r):Wr.r(n)}var ei=typeof document>"u"?null:document;function nv(n,r,i){var d=ei;if(d&&typeof r=="string"&&r){var x=Je(r);x='link[rel="'+n+'"][href="'+x+'"]',typeof i=="string"&&(x+='[crossorigin="'+i+'"]'),tv.has(x)||(tv.add(x),n={rel:n,crossOrigin:i,href:r},d.querySelector(x)===null&&(r=d.createElement("link"),Dn(r,"link",n),he(r),d.head.appendChild(r)))}}function B5(n){Wr.D(n),nv("dns-prefetch",n,null)}function H5(n,r){Wr.C(n,r),nv("preconnect",n,r)}function F5(n,r,i){Wr.L(n,r,i);var d=ei;if(d&&n&&r){var x='link[rel="preload"][as="'+Je(r)+'"]';r==="image"&&i&&i.imageSrcSet?(x+='[imagesrcset="'+Je(i.imageSrcSet)+'"]',typeof i.imageSizes=="string"&&(x+='[imagesizes="'+Je(i.imageSizes)+'"]')):x+='[href="'+Je(n)+'"]';var b=x;switch(r){case"style":b=ti(n);break;case"script":b=ni(n)}Wa.has(b)||(n=v({rel:"preload",href:r==="image"&&i&&i.imageSrcSet?void 0:n,as:r},i),Wa.set(b,n),d.querySelector(x)!==null||r==="style"&&d.querySelector(co(b))||r==="script"&&d.querySelector(uo(b))||(r=d.createElement("link"),Dn(r,"link",n),he(r),d.head.appendChild(r)))}}function q5(n,r){Wr.m(n,r);var i=ei;if(i&&n){var d=r&&typeof r.as=="string"?r.as:"script",x='link[rel="modulepreload"][as="'+Je(d)+'"][href="'+Je(n)+'"]',b=x;switch(d){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":b=ni(n)}if(!Wa.has(b)&&(n=v({rel:"modulepreload",href:n},r),Wa.set(b,n),i.querySelector(x)===null)){switch(d){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(i.querySelector(uo(b)))return}d=i.createElement("link"),Dn(d,"link",n),he(d),i.head.appendChild(d)}}}function V5(n,r,i){Wr.S(n,r,i);var d=ei;if(d&&n){var x=yn(d).hoistableStyles,b=ti(n);r=r||"default";var N=x.get(b);if(!N){var L={loading:0,preload:null};if(N=d.querySelector(co(b)))L.loading=5;else{n=v({rel:"stylesheet",href:n,"data-precedence":r},i),(i=Wa.get(b))&&Um(n,i);var Y=N=d.createElement("link");he(Y),Dn(Y,"link",n),Y._p=new Promise(function(se,xe){Y.onload=se,Y.onerror=xe}),Y.addEventListener("load",function(){L.loading|=1}),Y.addEventListener("error",function(){L.loading|=2}),L.loading|=4,pu(N,r,d)}N={type:"stylesheet",instance:N,count:1,state:L},x.set(b,N)}}}function G5(n,r){Wr.X(n,r);var i=ei;if(i&&n){var d=yn(i).hoistableScripts,x=ni(n),b=d.get(x);b||(b=i.querySelector(uo(x)),b||(n=v({src:n,async:!0},r),(r=Wa.get(x))&&$m(n,r),b=i.createElement("script"),he(b),Dn(b,"link",n),i.head.appendChild(b)),b={type:"script",instance:b,count:1,state:null},d.set(x,b))}}function W5(n,r){Wr.M(n,r);var i=ei;if(i&&n){var d=yn(i).hoistableScripts,x=ni(n),b=d.get(x);b||(b=i.querySelector(uo(x)),b||(n=v({src:n,async:!0,type:"module"},r),(r=Wa.get(x))&&$m(n,r),b=i.createElement("script"),he(b),Dn(b,"link",n),i.head.appendChild(b)),b={type:"script",instance:b,count:1,state:null},d.set(x,b))}}function av(n,r,i,d){var x=(x=ie.current)?mu(x):null;if(!x)throw Error(l(446));switch(n){case"meta":case"title":return null;case"style":return typeof i.precedence=="string"&&typeof i.href=="string"?(r=ti(i.href),i=yn(x).hoistableStyles,d=i.get(r),d||(d={type:"style",instance:null,count:0,state:null},i.set(r,d)),d):{type:"void",instance:null,count:0,state:null};case"link":if(i.rel==="stylesheet"&&typeof i.href=="string"&&typeof i.precedence=="string"){n=ti(i.href);var b=yn(x).hoistableStyles,N=b.get(n);if(N||(x=x.ownerDocument||x,N={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},b.set(n,N),(b=x.querySelector(co(n)))&&!b._p&&(N.instance=b,N.state.loading=5),Wa.has(n)||(i={rel:"preload",as:"style",href:i.href,crossOrigin:i.crossOrigin,integrity:i.integrity,media:i.media,hrefLang:i.hrefLang,referrerPolicy:i.referrerPolicy},Wa.set(n,i),b||K5(x,n,i,N.state))),r&&d===null)throw Error(l(528,""));return N}if(r&&d!==null)throw Error(l(529,""));return null;case"script":return r=i.async,i=i.src,typeof i=="string"&&r&&typeof r!="function"&&typeof r!="symbol"?(r=ni(i),i=yn(x).hoistableScripts,d=i.get(r),d||(d={type:"script",instance:null,count:0,state:null},i.set(r,d)),d):{type:"void",instance:null,count:0,state:null};default:throw Error(l(444,n))}}function ti(n){return'href="'+Je(n)+'"'}function co(n){return'link[rel="stylesheet"]['+n+"]"}function rv(n){return v({},n,{"data-precedence":n.precedence,precedence:null})}function K5(n,r,i,d){n.querySelector('link[rel="preload"][as="style"]['+r+"]")?d.loading=1:(r=n.createElement("link"),d.preload=r,r.addEventListener("load",function(){return d.loading|=1}),r.addEventListener("error",function(){return d.loading|=2}),Dn(r,"link",i),he(r),n.head.appendChild(r))}function ni(n){return'[src="'+Je(n)+'"]'}function uo(n){return"script[async]"+n}function sv(n,r,i){if(r.count++,r.instance===null)switch(r.type){case"style":var d=n.querySelector('style[data-href~="'+Je(i.href)+'"]');if(d)return r.instance=d,he(d),d;var x=v({},i,{"data-href":i.href,"data-precedence":i.precedence,href:null,precedence:null});return d=(n.ownerDocument||n).createElement("style"),he(d),Dn(d,"style",x),pu(d,i.precedence,n),r.instance=d;case"stylesheet":x=ti(i.href);var b=n.querySelector(co(x));if(b)return r.state.loading|=4,r.instance=b,he(b),b;d=rv(i),(x=Wa.get(x))&&Um(d,x),b=(n.ownerDocument||n).createElement("link"),he(b);var N=b;return N._p=new Promise(function(L,Y){N.onload=L,N.onerror=Y}),Dn(b,"link",d),r.state.loading|=4,pu(b,i.precedence,n),r.instance=b;case"script":return b=ni(i.src),(x=n.querySelector(uo(b)))?(r.instance=x,he(x),x):(d=i,(x=Wa.get(b))&&(d=v({},i),$m(d,x)),n=n.ownerDocument||n,x=n.createElement("script"),he(x),Dn(x,"link",d),n.head.appendChild(x),r.instance=x);case"void":return null;default:throw Error(l(443,r.type))}else r.type==="stylesheet"&&(r.state.loading&4)===0&&(d=r.instance,r.state.loading|=4,pu(d,i.precedence,n));return r.instance}function pu(n,r,i){for(var d=i.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),x=d.length?d[d.length-1]:null,b=x,N=0;N<d.length;N++){var L=d[N];if(L.dataset.precedence===r)b=L;else if(b!==x)break}b?b.parentNode.insertBefore(n,b.nextSibling):(r=i.nodeType===9?i.head:i,r.insertBefore(n,r.firstChild))}function Um(n,r){n.crossOrigin==null&&(n.crossOrigin=r.crossOrigin),n.referrerPolicy==null&&(n.referrerPolicy=r.referrerPolicy),n.title==null&&(n.title=r.title)}function $m(n,r){n.crossOrigin==null&&(n.crossOrigin=r.crossOrigin),n.referrerPolicy==null&&(n.referrerPolicy=r.referrerPolicy),n.integrity==null&&(n.integrity=r.integrity)}var hu=null;function lv(n,r,i){if(hu===null){var d=new Map,x=hu=new Map;x.set(i,d)}else x=hu,d=x.get(i),d||(d=new Map,x.set(i,d));if(d.has(n))return d;for(d.set(n,null),i=i.getElementsByTagName(n),x=0;x<i.length;x++){var b=i[x];if(!(b[Qn]||b[qt]||n==="link"&&b.getAttribute("rel")==="stylesheet")&&b.namespaceURI!=="http://www.w3.org/2000/svg"){var N=b.getAttribute(r)||"";N=n+N;var L=d.get(N);L?L.push(b):d.set(N,[b])}}return d}function iv(n,r,i){n=n.ownerDocument||n,n.head.insertBefore(i,r==="title"?n.querySelector("head > title"):null)}function Y5(n,r,i){if(i===1||r.itemProp!=null)return!1;switch(n){case"meta":case"title":return!0;case"style":if(typeof r.precedence!="string"||typeof r.href!="string"||r.href==="")break;return!0;case"link":if(typeof r.rel!="string"||typeof r.href!="string"||r.href===""||r.onLoad||r.onError)break;return r.rel==="stylesheet"?(n=r.disabled,typeof r.precedence=="string"&&n==null):!0;case"script":if(r.async&&typeof r.async!="function"&&typeof r.async!="symbol"&&!r.onLoad&&!r.onError&&r.src&&typeof r.src=="string")return!0}return!1}function ov(n){return!(n.type==="stylesheet"&&(n.state.loading&3)===0)}function Q5(n,r,i,d){if(i.type==="stylesheet"&&(typeof d.media!="string"||matchMedia(d.media).matches!==!1)&&(i.state.loading&4)===0){if(i.instance===null){var x=ti(d.href),b=r.querySelector(co(x));if(b){r=b._p,r!==null&&typeof r=="object"&&typeof r.then=="function"&&(n.count++,n=gu.bind(n),r.then(n,n)),i.state.loading|=4,i.instance=b,he(b);return}b=r.ownerDocument||r,d=rv(d),(x=Wa.get(x))&&Um(d,x),b=b.createElement("link"),he(b);var N=b;N._p=new Promise(function(L,Y){N.onload=L,N.onerror=Y}),Dn(b,"link",d),i.instance=b}n.stylesheets===null&&(n.stylesheets=new Map),n.stylesheets.set(i,r),(r=i.state.preload)&&(i.state.loading&3)===0&&(n.count++,i=gu.bind(n),r.addEventListener("load",i),r.addEventListener("error",i))}}var Pm=0;function X5(n,r){return n.stylesheets&&n.count===0&&yu(n,n.stylesheets),0<n.count||0<n.imgCount?function(i){var d=setTimeout(function(){if(n.stylesheets&&yu(n,n.stylesheets),n.unsuspend){var b=n.unsuspend;n.unsuspend=null,b()}},6e4+r);0<n.imgBytes&&Pm===0&&(Pm=62500*R5());var x=setTimeout(function(){if(n.waitingForImages=!1,n.count===0&&(n.stylesheets&&yu(n,n.stylesheets),n.unsuspend)){var b=n.unsuspend;n.unsuspend=null,b()}},(n.imgBytes>Pm?50:800)+r);return n.unsuspend=i,function(){n.unsuspend=null,clearTimeout(d),clearTimeout(x)}}:null}function gu(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)yu(this,this.stylesheets);else if(this.unsuspend){var n=this.unsuspend;this.unsuspend=null,n()}}}var xu=null;function yu(n,r){n.stylesheets=null,n.unsuspend!==null&&(n.count++,xu=new Map,r.forEach(Z5,n),xu=null,gu.call(n))}function Z5(n,r){if(!(r.state.loading&4)){var i=xu.get(n);if(i)var d=i.get(null);else{i=new Map,xu.set(n,i);for(var x=n.querySelectorAll("link[data-precedence],style[data-precedence]"),b=0;b<x.length;b++){var N=x[b];(N.nodeName==="LINK"||N.getAttribute("media")!=="not all")&&(i.set(N.dataset.precedence,N),d=N)}d&&i.set(null,d)}x=r.instance,N=x.getAttribute("data-precedence"),b=i.get(N)||d,b===d&&i.set(null,x),i.set(N,x),this.count++,d=gu.bind(this),x.addEventListener("load",d),x.addEventListener("error",d),b?b.parentNode.insertBefore(x,b.nextSibling):(n=n.nodeType===9?n.head:n,n.insertBefore(x,n.firstChild)),r.state.loading|=4}}var fo={$$typeof:D,Provider:null,Consumer:null,_currentValue:Z,_currentValue2:Z,_threadCount:0};function J5(n,r,i,d,x,b,N,L,Y){this.tag=1,this.containerInfo=n,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=aa(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=aa(0),this.hiddenUpdates=aa(null),this.identifierPrefix=d,this.onUncaughtError=x,this.onCaughtError=b,this.onRecoverableError=N,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=Y,this.incompleteTransitions=new Map}function cv(n,r,i,d,x,b,N,L,Y,se,xe,ke){return n=new J5(n,r,i,N,Y,se,xe,ke,L),r=1,b===!0&&(r|=24),b=ja(3,null,null,r),n.current=b,b.stateNode=n,r=vf(),r.refCount++,n.pooledCache=r,r.refCount++,b.memoizedState={element:d,isDehydrated:i,cache:r},Sf(b),n}function uv(n){return n?(n=Il,n):Il}function dv(n,r,i,d,x,b){x=uv(x),d.context===null?d.context=x:d.pendingContext=x,d=fs(r),d.payload={element:i},b=b===void 0?null:b,b!==null&&(d.callback=b),i=ms(n,d,r),i!==null&&(da(i,n,r),Fi(i,n,r))}function fv(n,r){if(n=n.memoizedState,n!==null&&n.dehydrated!==null){var i=n.retryLane;n.retryLane=i!==0&&i<r?i:r}}function Bm(n,r){fv(n,r),(n=n.alternate)&&fv(n,r)}function mv(n){if(n.tag===13||n.tag===31){var r=Qs(n,67108864);r!==null&&da(r,n,67108864),Bm(n,67108864)}}function pv(n){if(n.tag===13||n.tag===31){var r=Ea();r=Pn(r);var i=Qs(n,r);i!==null&&da(i,n,r),Bm(n,r)}}var vu=!0;function eC(n,r,i,d){var x=q.T;q.T=null;var b=ae.p;try{ae.p=2,Hm(n,r,i,d)}finally{ae.p=b,q.T=x}}function tC(n,r,i,d){var x=q.T;q.T=null;var b=ae.p;try{ae.p=8,Hm(n,r,i,d)}finally{ae.p=b,q.T=x}}function Hm(n,r,i,d){if(vu){var x=Fm(d);if(x===null)Mm(n,r,d,bu,i),gv(n,d);else if(aC(x,n,r,i,d))d.stopPropagation();else if(gv(n,d),r&4&&-1<nC.indexOf(n)){for(;x!==null;){var b=ra(x);if(b!==null)switch(b.tag){case 3:if(b=b.stateNode,b.current.memoizedState.isDehydrated){var N=xt(b.pendingLanes);if(N!==0){var L=b;for(L.pendingLanes|=2,L.entangledLanes|=2;N;){var Y=1<<31-We(N);L.entanglements[1]|=Y,N&=~Y}kr(b),(Mt&6)===0&&(nu=st()+500,so(0))}}break;case 31:case 13:L=Qs(b,2),L!==null&&da(L,b,2),ru(),Bm(b,2)}if(b=Fm(d),b===null&&Mm(n,r,d,bu,i),b===x)break;x=b}x!==null&&d.stopPropagation()}else Mm(n,r,d,null,i)}}function Fm(n){return n=Vs(n),qm(n)}var bu=null;function qm(n){if(bu=null,n=ka(n),n!==null){var r=c(n);if(r===null)n=null;else{var i=r.tag;if(i===13){if(n=u(r),n!==null)return n;n=null}else if(i===31){if(n=f(r),n!==null)return n;n=null}else if(i===3){if(r.stateNode.current.memoizedState.isDehydrated)return r.tag===3?r.stateNode.containerInfo:null;n=null}else r!==n&&(n=null)}}return bu=n,null}function hv(n){switch(n){case"beforetoggle":case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"toggle":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 2;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 8;case"message":switch(nn()){case pe:return 2;case Se:return 8;case De:case ze:return 32;case Ue:return 268435456;default:return 32}default:return 32}}var Vm=!1,js=null,Cs=null,Ns=null,mo=new Map,po=new Map,Ts=[],nC="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset".split(" ");function gv(n,r){switch(n){case"focusin":case"focusout":js=null;break;case"dragenter":case"dragleave":Cs=null;break;case"mouseover":case"mouseout":Ns=null;break;case"pointerover":case"pointerout":mo.delete(r.pointerId);break;case"gotpointercapture":case"lostpointercapture":po.delete(r.pointerId)}}function ho(n,r,i,d,x,b){return n===null||n.nativeEvent!==b?(n={blockedOn:r,domEventName:i,eventSystemFlags:d,nativeEvent:b,targetContainers:[x]},r!==null&&(r=ra(r),r!==null&&mv(r)),n):(n.eventSystemFlags|=d,r=n.targetContainers,x!==null&&r.indexOf(x)===-1&&r.push(x),n)}function aC(n,r,i,d,x){switch(r){case"focusin":return js=ho(js,n,r,i,d,x),!0;case"dragenter":return Cs=ho(Cs,n,r,i,d,x),!0;case"mouseover":return Ns=ho(Ns,n,r,i,d,x),!0;case"pointerover":var b=x.pointerId;return mo.set(b,ho(mo.get(b)||null,n,r,i,d,x)),!0;case"gotpointercapture":return b=x.pointerId,po.set(b,ho(po.get(b)||null,n,r,i,d,x)),!0}return!1}function xv(n){var r=ka(n.target);if(r!==null){var i=c(r);if(i!==null){if(r=i.tag,r===13){if(r=u(i),r!==null){n.blockedOn=r,gr(n.priority,function(){pv(i)});return}}else if(r===31){if(r=f(i),r!==null){n.blockedOn=r,gr(n.priority,function(){pv(i)});return}}else if(r===3&&i.stateNode.current.memoizedState.isDehydrated){n.blockedOn=i.tag===3?i.stateNode.containerInfo:null;return}}}n.blockedOn=null}function ku(n){if(n.blockedOn!==null)return!1;for(var r=n.targetContainers;0<r.length;){var i=Fm(n.nativeEvent);if(i===null){i=n.nativeEvent;var d=new i.constructor(i.type,i);$a=d,i.target.dispatchEvent(d),$a=null}else return r=ra(i),r!==null&&mv(r),n.blockedOn=i,!1;r.shift()}return!0}function yv(n,r,i){ku(n)&&i.delete(r)}function rC(){Vm=!1,js!==null&&ku(js)&&(js=null),Cs!==null&&ku(Cs)&&(Cs=null),Ns!==null&&ku(Ns)&&(Ns=null),mo.forEach(yv),po.forEach(yv)}function wu(n,r){n.blockedOn===r&&(n.blockedOn=null,Vm||(Vm=!0,e.unstable_scheduleCallback(e.unstable_NormalPriority,rC)))}var Su=null;function vv(n){Su!==n&&(Su=n,e.unstable_scheduleCallback(e.unstable_NormalPriority,function(){Su===n&&(Su=null);for(var r=0;r<n.length;r+=3){var i=n[r],d=n[r+1],x=n[r+2];if(typeof d!="function"){if(qm(d||i)===null)continue;break}var b=ra(i);b!==null&&(n.splice(r,3),r-=3,Ff(b,{pending:!0,data:x,method:i.method,action:d},d,x))}}))}function ai(n){function r(Y){return wu(Y,n)}js!==null&&wu(js,n),Cs!==null&&wu(Cs,n),Ns!==null&&wu(Ns,n),mo.forEach(r),po.forEach(r);for(var i=0;i<Ts.length;i++){var d=Ts[i];d.blockedOn===n&&(d.blockedOn=null)}for(;0<Ts.length&&(i=Ts[0],i.blockedOn===null);)xv(i),i.blockedOn===null&&Ts.shift();if(i=(n.ownerDocument||n).$$reactFormReplay,i!=null)for(d=0;d<i.length;d+=3){var x=i[d],b=i[d+1],N=x[Zt]||null;if(typeof b=="function")N||vv(i);else if(N){var L=null;if(b&&b.hasAttribute("formAction")){if(x=b,N=b[Zt]||null)L=N.formAction;else if(qm(x)!==null)continue}else L=N.action;typeof L=="function"?i[d+1]=L:(i.splice(d,3),d-=3),vv(i)}}}function bv(){function n(b){b.canIntercept&&b.info==="react-transition"&&b.intercept({handler:function(){return new Promise(function(N){return x=N})},focusReset:"manual",scroll:"manual"})}function r(){x!==null&&(x(),x=null),d||setTimeout(i,20)}function i(){if(!d&&!navigation.transition){var b=navigation.currentEntry;b&&b.url!=null&&navigation.navigate(b.url,{state:b.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var d=!1,x=null;return navigation.addEventListener("navigate",n),navigation.addEventListener("navigatesuccess",r),navigation.addEventListener("navigateerror",r),setTimeout(i,100),function(){d=!0,navigation.removeEventListener("navigate",n),navigation.removeEventListener("navigatesuccess",r),navigation.removeEventListener("navigateerror",r),x!==null&&(x(),x=null)}}}function Gm(n){this._internalRoot=n}ju.prototype.render=Gm.prototype.render=function(n){var r=this._internalRoot;if(r===null)throw Error(l(409));var i=r.current,d=Ea();dv(i,d,n,r,null,null)},ju.prototype.unmount=Gm.prototype.unmount=function(){var n=this._internalRoot;if(n!==null){this._internalRoot=null;var r=n.containerInfo;dv(n.current,2,null,n,null,null),ru(),r[Hn]=null}};function ju(n){this._internalRoot=n}ju.prototype.unstable_scheduleHydration=function(n){if(n){var r=Da();n={blockedOn:null,target:n,priority:r};for(var i=0;i<Ts.length&&r!==0&&r<Ts[i].priority;i++);Ts.splice(i,0,n),i===0&&xv(n)}};var kv=t.version;if(kv!=="19.2.7")throw Error(l(527,kv,"19.2.7"));ae.findDOMNode=function(n){var r=n._reactInternals;if(r===void 0)throw typeof n.render=="function"?Error(l(188)):(n=Object.keys(n).join(","),Error(l(268,n)));return n=h(r),n=n!==null?g(n):null,n=n===null?null:n.stateNode,n};var sC={bundleType:0,version:"19.2.7",rendererPackageName:"react-dom",currentDispatcherRef:q,reconcilerVersion:"19.2.7"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var Cu=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Cu.isDisabled&&Cu.supportsFiber)try{Ne=Cu.inject(sC),Te=Cu}catch{}}return xo.createRoot=function(n,r){if(!o(n))throw Error(l(299));var i=!1,d="",x=Mx,b=Ex,N=Ax;return r!=null&&(r.unstable_strictMode===!0&&(i=!0),r.identifierPrefix!==void 0&&(d=r.identifierPrefix),r.onUncaughtError!==void 0&&(x=r.onUncaughtError),r.onCaughtError!==void 0&&(b=r.onCaughtError),r.onRecoverableError!==void 0&&(N=r.onRecoverableError)),r=cv(n,1,!1,null,null,i,d,null,x,b,N,bv),n[Hn]=r.current,Tm(n),new Gm(r)},xo.hydrateRoot=function(n,r,i){if(!o(n))throw Error(l(299));var d=!1,x="",b=Mx,N=Ex,L=Ax,Y=null;return i!=null&&(i.unstable_strictMode===!0&&(d=!0),i.identifierPrefix!==void 0&&(x=i.identifierPrefix),i.onUncaughtError!==void 0&&(b=i.onUncaughtError),i.onCaughtError!==void 0&&(N=i.onCaughtError),i.onRecoverableError!==void 0&&(L=i.onRecoverableError),i.formState!==void 0&&(Y=i.formState)),r=cv(n,1,!0,r,i??null,d,x,Y,b,N,L,bv),r.context=uv(null),i=r.current,d=Ea(),d=Pn(d),x=fs(d),x.callback=null,ms(i,x,d),i=d,r.current.lanes=i,En(r,i),kr(r),n[Hn]=r.current,Tm(n),new ju(r)},xo.version="19.2.7",xo}var Rv;function pC(){if(Rv)return Ym.exports;Rv=1;function e(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}return e(),Ym.exports=mC(),Ym.exports}var hC=pC();const vk={appName:"PenguinHarness",nav:{chat:"对话",newChat:"新对话",agents:"智能体",skills:"技能库",models:"模型库",usage:"成本中心",traces:"轨迹观测",benchmark:"评估中心",lastConversation:"最近一次对话",collapseSidebar:"收起侧栏",expandSidebar:"展开侧栏",collapseGroup:"折叠",expandGroup:"展开",pinGroup:"置顶分组",unpinGroup:"取消置顶"},settings:{language:"语言",showCliSessions:"显示 CLI 会话",proxyMenu:"代理选项",proxyDialogTitle:"代理选项",proxyForApp:"应用程序使用代理",proxyForAgent:"Agent 环境使用代理",proxyAddress:"代理地址",proxyAddressPlaceholder:"留空 = 跟随系统代理",theme:"主题",themeLight:"浅色",themeDark:"深色",followSystem:"跟随系统",langZh:"中文",langEn:"English",fontSize:"字号",fontSmall:"小",fontMedium:"中",fontLarge:"大",accent:"主题色",accentNames:{neutral:"灰白",blue:"蓝",green:"绿",violet:"紫",rose:"红",amber:"橙"}},update:{lastUpdated:e=>`最近更新日期 ${e}`,newVersionBadge:"有新版本可用",newVersion:e=>`新版本 v${e} 可用`,checkNow:"检查更新",checking:"检查中…",foundNew:e=>`发现新版本 v${e},点击下方更新入口即可安装`,upToDate:"已是最新版本",checkFailed:"检查更新失败,请稍后重试",checkDisabled:"更新检查已关闭(PENGUIN_UPDATE_CHECK=off)",releaseNotes:"更新说明",updateNow:"立即更新",updating:"更新中…",updated:"更新完成,重启服务后生效",restartHint:"在终端重新运行 penguin web(或 penguin server)即可完成重启",failed:"更新失败",unsupported:"当前安装方式不支持在线更新",confirmBody:"将下载最新版本并安装到服务器上的安装目录(数据目录不受影响)。安装完成后需要重启服务才会生效。",adminOnly:"只有管理员可以在这里执行更新。"},notify:{taskCompleteTitle:"任务完成",taskCompleteBody:e=>`「${e}」已完成,点击查看`},common:{save:"保存",cancel:"取消",create:"创建",delete:"删除",edit:"编辑",settings:"设置",confirm:"确认",close:"关闭",loading:"加载中…",saved:"已保存",saving:"保存中…",noChangesToSave:"当前没有需要保存的修改",confirmSaveTitle:"保存修改",confirmSaveBody:"确定保存这些修改吗?修改将写入服务器上的配置文件。",none:"(无)",retry:"重试",unknownError:"请求失败,请稍后重试",requiredField:"此项必填",copied:"已复制",name:"名称",username:"用户名",role:"角色",actions:"操作",created:"创建时间",cost:"成本",time:"时间"},auth:{usernameHint:"2~32 位:小写字母开头,仅小写字母、数字与下划线",password:"密码",passwordHint:"至少 8 个字符",showPassword:"显示密码",hidePassword:"隐藏密码",login:"登录",logout:"登出",admin:"管理员",defaultAdminNote:"首次使用请以内置管理员 admin 登录,初始密码在服务端首次启动时打印(形如 penguin-1234),登录后请尽快修改密码"},account:{changePassword:"修改密码",oldPassword:"当前密码",oldPasswordHint:"内置管理员的初始密码在服务端首次启动时打印(形如 penguin-1234)",newPassword:"新密码",confirmPassword:"确认新密码",passwordMismatch:"两次输入的新密码不一致",initialPasswordBanner:"当前账号正在使用初始密码,建议尽快修改",changeNow:"去修改"},admin:{users:"用户管理",roleAdmin:"管理员",roleUser:"用户",createUser:"新增用户",initialPassword:"初始密码",initialPasswordFlag:"初始密码",defaultProjectNote:e=>`将自动创建默认 Project:${e}`,resetPassword:"重置密码",resetPasswordTitle:e=>`重置 ${e} 的密码`,resetPasswordNote:"重置后该用户的登录会话全部失效,需用新密码重新登录",deleteUserTitle:e=>`删除用户 ${e}`,deleteUserConfirm:e=>`将删除用户 ${e} 及其名下全部 Project(含数据目录),不可恢复。`},project:{switcher:"Project",create:"新建 Project",createTitle:"新建 Project",id:"Project id",idHint:"2~64 位:小写字母开头,仅小写字母、数字与下划线;创建后不可修改",idPrefixHint:"id 固定以「用户名-」为前缀,后接小写字母、数字或下划线;创建后不可修改",name:"显示名(可选,缺省为 Project id)",displayName:"显示名",settings:"Project 设置",settingsTitle:"Project 设置",members:"成员",addMember:"添加成员",removeMember:"移除",chatDefaultsTitle:"新对话默认值",chatDefaultsHint:"新建对话时预填的默认值:Agent、工作目录、审批模式、思考等级与默认模型。",chatDefaultsAgent:"Agent",chatDefaultsNotSet:"未设置",chatDefaultsApprovalNotSet:"未设置(默认全部放行)",chatDefaultsThinkingNotSet:"未设置(跟随智能体配置)",chatDefaultsWorkspaceHint:"留空表示使用临时工作区",chatDefaultsModelHint:"与模型页的默认模型同步",deleteProject:"删除 Project",deleteConfirm:"确认删除该 Project?项目目录将被递归删除,不可恢复。",deleteDefaultForbidden:"default_project 与 CLI 共用,不允许在 Web 端删除",deleteLastForbidden:"这是当前账号最后一个 Project,删除后将无 Project 可用;请先创建新的 Project",noCredentialTitle:"尚未配置模型 credential",noCredentialBody:"当前 Project 的默认模型尚未配置 API key,发起对话前请先前往模型页配置。",goToModels:"前往模型页",later:"稍后再说"},agent:{listTitle:"Agents",create:"创建 Agent",createTitle:"创建 Agent",id:"Agent id",idHint:"2~64 位:小写字母开头,仅小写字母、数字与下划线;创建后不可修改",nameHint:"留空则使用 Agent id 作为名称",description:"描述",sessionCount:e=>`${e} 个 Session`,toolCount:e=>`${e} 个工具`,vaultKeyCount:e=>`${e} 个密钥`,scheduleCount:e=>`${e} 个定时任务`,memoryCount:e=>`${e} 条记忆`,updatedAt:"最后修改",activity:e=>`近 ${e} 天 Session 活跃度`,settings:"Agent 设置",backToList:"返回 Agents",tabOverview:"概览",tabPrompt:"系统提示词",tabMemory:"记忆",tabRuntime:"运行参数",tabTools:"工具",tabSkills:"技能",tabVault:"密钥保险柜",tabSchedules:"定时任务",stateDir:"State 路径",copyStateDir:"复制 State 路径",agentsMd:"AGENTS.md",systemPrompt:"system_prompt 模板",placeholdersTitle:"可用占位符(点击插入)",insertPlaceholder:"插入到 system_prompt 光标处",placeholders:[["{{AGENTS_MD}}","注入 AGENTS.md 内容"],["{{VAULT}}","注入保险柜区块(vault.prompt,含键名清单);开关关闭时为空"],["{{SKILLS}}","注入技能区块(skills.prompt,含已安装技能元数据);开关关闭时为空"],["{{MEMORY}}","注入记忆区块:memory.prompt 加 memory.workspace_prompt(仅持久工作区);关闭记忆时为空"],["{{SCHEDULES}}","注入定时任务区块(schedules.prompt,含任务名清单);开关关闭时为空"],["{{PLATFORM}}","运行平台"],["{{OS_VERSION}}","操作系统版本"],["{{SHELL}}","命令执行使用的 Shell"],["{{DATE}}","当前日期"],["{{PROJECT_DIR}}","PenguinHarness 应用数据根目录(存放全部 Agent 数据与 Project 级数据;不是本次任务的工作目录)"],["{{AGENT_ID}}","当前 Agent id"],["{{CWD}}","Workspace 绝对路径"],["{{PROVIDER}}","模型 provider 分组"],["{{MODEL_ID}}","上游模型 id"],["{{SESSION_ID}}","当前 Session id"]],maxTurns:"max_turns(单 Task 最大轮次,-1 不限制)",maxTokens:"model.max_tokens",thinkingLevel:"model.thinking_level",thinkingLevelOptions:[["","不提交覆盖值,沿用当前生效的配置。"],["low","开启较低强度的扩展推理。"],["medium","开启中等强度的扩展推理(新建 Agent 的缺省档位)。"],["high","开启较高强度的扩展推理,响应更慢。"],["xhigh","开启最高强度的扩展推理,部分模型上效果与 high 相同。"]],thinkingLevelNoneKept:"已存的历史档位:新选择不再提供关闭档(多数模型不支持关闭思考)。",timeoutMs:"model.timeoutMs",timeoutMsHint:"单次 Request 超时,毫秒",compaction:"上下文压缩(compaction)",maxContextLength:"max_context_length",maxContextLengthHint:"触发压缩的上下文阈值",maxSessionTurns:"max_session_turns",maxSessionTurnsHint:"触发压缩的轮数阈值",compactionMode:"mode(压缩方式)",compactionModeOptions:[["","不提交覆盖值,沿用当前生效的配置。"],["summarize","先让模型为旧上下文生成摘要,再从摘要续接新的上下文窗口(缺省)。"],["discard","不生成摘要,直接丢弃旧上下文,下一轮从新窗口重新开始。"]],compactionPrompt:"prompt(摘要提示词)",maxTurnsInvalid:"max_turns 必须 > 0 或为 -1",timeoutInvalid:"timeoutMs 必须 > 0 或为 -1",toolFieldInvalid:(e,t)=>`${e}: ${t} 必须是 > 0 的整数或 -1`,toolPermission:"permission",permissionReadLabel:"Read-only",permissionReadDescription:"仅读取。审批模式为 read-only 时自动放行,无需确认。",permissionReadWriteLabel:"Read & write",permissionReadWriteDescription:"可修改。审批模式为 read-only 时需人工确认。",toolTimeout:"timeoutMs",toolMaxOutput:"maxOutputLength",toolCallDescription:"call_description",callDescriptionHint:"call_description:开启(缺省)时该工具的 schema 保留可选的 description 参数——模型为每次调用写一句说明,运行期间展示给用户;关闭则装配时从 schema 滤除该参数。仅参数中定义了 description 属性的工具可切换。",mcpServers:"MCP Server",mcpDesc:"连接外部 MCP Server:其工具以 mcp__<name>__<tool> 并入本 Agent 的工具列表。此区块的改动即时保存。",mcpEmpty:"尚未配置 MCP Server",mcpAdd:"添加 MCP Server",mcpEditTitle:"编辑 MCP Server",mcpRemove:"删除",mcpName:"name",mcpNameHint:"工具名前缀:mcp__<name>__<tool>;限字母、数字、_ 和 -",mcpTransport:"transport",mcpTransportStdio:"本地进程:启动 command 后经 stdin/stdout 通信",mcpTransportHttp:"Streamable HTTP:当前规范的远程 transport",mcpTransportSse:"旧版 HTTP+SSE:仅为未迁移的服务保留",mcpTarget:"command / url",mcpCommand:"command",mcpArgs:"args",mcpArgsHint:"每行一个参数",mcpEnv:"env",mcpEnvHint:"每行一条 KEY=value;Agent vault 不注入 MCP Server 进程",mcpCwd:"cwd",mcpCwdHint:"留空则使用本次 Session 的 Workspace",mcpUrl:"url",mcpHeaders:"headers",mcpHeadersHint:"每行一条 Header-Name: value(如 Authorization 等认证头)",mcpConnectTimeout:"connectTimeoutMs",mcpBudgetsHint:"留空使用默认值:connectTimeoutMs 是连接与工具发现预算(默认 10000);timeoutMs / maxOutputLength 作用于该 Server 的全部工具。",mcpNameInvalid:"限字母、数字、_ 和 -,且以字母或数字开头",mcpUrlInvalid:"必须是合法的 http(s) URL",mcpLineInvalid:e=>`第 ${e} 行格式无效`,mcpNumberInvalid:"必须是 > 0 的整数",mcpDuplicateName:"同名 Server 已存在",mcpTest:"测试连接",mcpTesting:"测试中…",mcpTestOk:(e,t)=>{const a=t!==void 0?`(${(t/1e3).toFixed(1)}s)`:"";return e===0?`连接成功,但该 Server 未暴露任何工具${a}`:`连接成功,发现 ${e} 个工具${a}`},mcpTestFail:e=>`连接失败:${e}`,mcpTestAllConfirm:e=>`将逐一连接已配置的 ${e} 个 MCP Server 并做工具发现(真实连接,不保存任何改动),结果显示在各行上。`,mcpTestAllStart:"开始测试",mcpTestPending:"测试中…",mcpTestBadge:(e,t)=>`${e} 个工具${t!==void 0?` · ${(t/1e3).toFixed(1)}s`:""}`,mcpTestBadgeFail:"连接失败",mcpDeleteTitle:"删除 MCP Server",mcpDeleteConfirm:e=>`确认删除 MCP Server「${e}」?其工具自下次 Session 起不再可用。`,defaultValue:"(缺省)",deleteAgent:"删除 Agent",builtinUndeletable:"内置 Agent 不可被删除",deleteConfirm:e=>`确认删除 Agent「${e}」?其目录(含全部 Trace)将被递归删除,不可恢复。`,stateTitle:"Agent State",stateVersion:"Agent State 版本",transferDesc:"导出当前 Agent State 快照包(tar.gz);导入整目录覆盖,并以包内版本为准。",exportSnapshot:"导出快照",importSnapshot:"导入快照",importing:"导入中…",importDone:e=>`导入完成,Agent State 版本 v${e}`,importConflictTitle:"版本冲突",importConflictBody:"快照包版本不高于当前版本,导入将覆盖现有 Agent State。确认继续?",resetConfigTitle:"还原为默认配置",resetConfigAction:"还原为默认配置",resetConfigConfirmBody:"此操作会用当前默认值覆盖该 Agent 的现有配置:自定义系统提示词、工具列表、模型/压缩参数与 MCP Server 全部被替换,仅保留名称与描述。与 Skill 更新一样不可撤销,确认继续?",resetConfigDone:"配置已还原为当前默认值",kernelTitle:"内核",kernelLegacy:"早于内核版本机制",kernelOutdatedHint:"内核有更新",kernelUpToDate:"已是最新",kernelUpdateTitle:"更新内核",kernelCurrent:"当前",kernelLatest:"最新",kernelUpdateAction:"更新内核",kernelUpdateConfirmBody:"将把未自定义的字段更新为当前内置默认值;自定义过的字段保持不变并在结果中列出。名称、描述、版本号与 MCP Server 不受影响。确认继续?",kernelUpdateDone:(e,t)=>t>0?`内核已更新至 ${e},${t} 个字段跟进新默认`:`内核已更新至 ${e},字段均已是当前默认或保持自定义`,kernelUpdateKeptIntro:"以下字段因自定义被保留:",kernelListSeparator:"、",kernelFieldTool:e=>`工具 ${e}`,kernelFields:{system_prompt:"系统提示词模板",max_turns:"单任务最大轮数","model.max_tokens":"模型最大输出 Token","model.thinking_level":"思考力度","model.timeoutMs":"请求超时","compaction.max_context_length":"压缩上下文阈值","compaction.max_session_turns":"压缩会话轮数阈值","compaction.mode":"压缩模式","compaction.prompt":"压缩提示词","memory.enabled":"记忆开关","memory.prompt":"记忆提示词","memory.workspace_prompt":"工作区记忆提示词","vault.enabled":"Vault 小节开关","vault.prompt":"Vault 提示词","skills.enabled":"技能小节开关","skills.prompt":"技能提示词","schedules.enabled":"定时任务小节开关","schedules.prompt":"定时任务提示词"}},models:{title:"模型配置",addCustom:"添加自定义模型",addToGroup:"新增模型",editTitle:"模型配置",addTitle:"新增模型(OpenAI 协议)",addTitleVendor:"新增模型",addProtocolHint:"新增模型走 OpenAI Chat Completions 兼容协议,base URL 填其兼容端点",vendorProtocolHint:e=>`仅支持 ${e} 官方接口协议,OpenAI 兼容接口请使用自定义模型分组`,autoRouteNone:"该 id 不是可识别的官方模型 id:请核对,或改在 Custom / 自建分组以 OpenAI 兼容接口接入",addGroup:"新增分组",addGroupTitle:"新增分组",addGroupDesc:"自建分组与 Custom 同语义:组内模型走 OpenAI Chat Completions 兼容协议(base URL 必填,API key 留空读取 OPENAI_API_KEY)。分组由模型条目承载,保存首个模型后即出现。",groupNameLabel:"分组名",groupNameHint:"小写字母 / 数字开头,可含 - 与 _",groupNameInvalid:"分组名只能用小写字母、数字、- 与 _(首字符为字母或数字),长度不超过 32",groupNameExists:"该分组名已被内置分组或既有条目占用",groupEmptyHint:"该分组暂无模型,点「新增模型」添加",searchPlaceholder:"搜索模型:id / 名称 / 厂商",noSearchResults:"没有匹配的模型",syncCatalog:"同步预置",syncCatalogHint:"用内置目录更新预置模型:新增缺失条目、以目录字段为准刷新差异;本地新增模型与 API key 保持不变",syncDone:(e,t)=>`预置模型已同步:新增 ${e}、更新 ${t}`,syncUpToDate:"预置模型已是最新",homepage:"模型主页",speedTest:"测速",speedTestTitle:"分组测速",speedTestConfirm:e=>`将对该分组的 ${e} 个模型逐个发起一次真实请求,测量首 token 延迟(TTFT)与输出速率(TPS),会消耗少量 API 额度。是否继续?`,speedTestStart:"开始测速",speedPending:"测速中…",speedFailed:"测速失败",ttftTitle:"首 token 延迟(TTFT)",tpsTitle:"输出速率(TPS)",modelCount:e=>`${e} 个模型`,modelId:"模型 ID",modelIdHint:"上游 API 使用的模型 id,如 gpt-5.5",displayName:"模型名称",displayNameHint:"留空则展示模型 ID",providerGroup:"分组",contextWindow:"上下文窗口",tokenUnit:"Token",contextWindowHint:"留空表示未知",maxTokens:"最大输出长度",maxTokensHint:"留空沿用 Agent 设置",maxTokensTitle:"按模型限制单次请求的最大输出 Token 数;留空沿用 Agent 设置,小上下文模型建议调低",maxTokensInvalid:"必须为正整数",clientTypeLocked:e=>`协议:${e}(沿用原配置,不可修改)`,vision:"支持视觉",visionOffProxyHint:"使用视觉代理模型读图",visionBadge:"视觉",freeBadge:"免费",visionModelBadge:"视觉代理",setVisionModel:"设为视觉代理模型",visionModelHint:"供不支持图片的模型经 describe_image 代读图片",priceUnitShort:"/M tok",testConnection:"测试连通性",testing:"测试中…",testOk:e=>`连通正常(${e} ms)`,testFailed:e=>`连通失败:${e}`,priceCacheRead:"缓存读取价格",priceCacheWrite:"缓存写入价格",priceOutput:"输出价格",currency:"币种",currencyUsd:"美元 $",currencyCny:"人民币 ¥",apiKey:"API key",apiKeyKeepHint:"留空保留现有 key",apiKeyEnvHint:e=>`留空则使用环境变量 ${e}`,keyConfigured:"已配置 key",clearApiKey:"清除已存 API key",baseUrl:"自定义 base URL",baseUrlHint:"留空使用厂商默认地址",baseUrlSuffixTitle:"客户端会在 base URL 后追加右侧灰色协议路径",baseUrlRequired:"必须填写 base URL",contextWindowDefaultHint:e=>`留空按 ${e} 计`,confirmDeleteTitle:"删除模型",confirmDelete:e=>`确定删除「${e}」?该模型的配置与 API key 将一并移除。`,groupApiKey:"统一配置 API key",groupApiKeyTitle:e=>`为「${e}」统一配置 API key`,groupApiKeyHint:e=>`将写入该分组下全部 ${e} 个模型;留空不改动。`,getApiKey:"获取 API key",getModelIds:"获取模型 id",groupKeyApplied:e=>`已为 ${e} 个模型配置 API key`,providerEnvNotes:{zhipu:"缺省端点为 Z.AI 国际版(api.z.ai);智谱开放平台(bigmodel.cn)的 key 需填 base URL https://open.bigmodel.cn/api/paas/v4",moonshot:"缺省端点为国内版(api.moonshot.cn);platform.kimi.com(国际)的 key 需填 base URL https://api.moonshot.ai/v1"},confirmVisionModelTitle:"设为视觉代理模型",confirmVisionModel:e=>`确定把「${e}」设为视觉代理模型?不支持图片的模型将由它经 describe_image 代读图片。`,confirmSaveTitle:"保存模型配置",confirmSave:e=>`确定保存对「${e}」的配置修改?`,confirmDefaultTitle:"设为默认模型",confirmDefault:e=>`确定把「${e}」设为默认模型?新建的 Session 将默认使用它。`,default:"默认",setDefault:"设为默认模型",remove:"删除模型",readOnlyHint:"member 只读;模型与 credential 修改仅 owner 可执行",empty:"尚未配置任何模型",noKey:"未配置 key",showModelsWithoutKey:e=>`显示未配置 key 的模型(${e} 个)`,modelIdExists:"该模型 id 已存在",pricingAllOrNone:"三项价格需一并填写",pricingInvalid:"必须为数字",contextWindowInvalid:"必须为数字"},memory:{desc:"跨 Session 的长期记忆(存于 agent_state/memory/):agent 会在对话中自行记下值得保留的信息,你也可以直接让它记住某件事。用户记忆对本 Agent 的所有会话生效,工作区记忆按工作区隔离;记忆修改在对话中由 agent 完成。关闭开关只停止使用记忆,不删除任何文件。",enable:"启用记忆",userScope:"用户记忆",templateMissing:"提示词模板中没有 {{MEMORY}} 占位符,记忆不会进入上下文。",insertPlaceholder:"插入 {{MEMORY}} 占位符",insertPlaceholderDone:"已插入",promptSection:"记忆提示词",promptSectionHint:"注入模板 {{MEMORY}} 占位符的内容。主提示词每个会话都注入;工作区附加段仅在持久工作区的会话中追加。",promptLabel:"主提示词",workspacePromptLabel:"工作区附加段",promptPlaceholders:[["{{USER_MEMORY_INDEX}}","用户记忆索引 MEMORY.md 的内容(最多注入 200 行、总计 25000 字符)"],["{{WORKSPACE_MEMORY_INDEX}}","当前工作区记忆索引的内容(最多注入 200 行、总计 25000 字符);仅在工作区附加段生效"],["{{WORKSPACE_MEMORY_DIR}}","当前工作区记忆目录的绝对路径;仅在工作区附加段生效"]],insertToken:"插入到光标处",itemCount:e=>`${e} 条`,emptyScope:"这个工作区还没有记忆——agent 会在会话中自行记下值得保留的信息",emptyUserScope:"还没有用户记忆——在对话里说「记住……」即可让 agent 保存",add:"添加",addTitle:"添加记忆",addWhy:"记忆整理由 agent 在对话中完成:填写内容后打开新对话,由 agent 整理保存。",addContentLabel:"要记住的内容或来源",addContentPlaceholder:"粘贴要记住的内容,或文件路径 / 链接",addPromptLead:{user:"请把下面的内容整理成记忆,存入用户记忆:",workspace:"请把下面的内容整理成记忆,存入这个工作区的记忆:"},view:"查看",edit:"编辑",editTitle:"编辑记忆",editWhy:"内容修改由 agent 在对话中完成:确认引导语后打开新对话,agent 会同步更新记忆文件与 MEMORY.md 索引。",editRequirementLabel:"修改要求",editRequirementPlaceholder:"描述要怎么改(可留空,跳转后在对话中补充)",editPromptLabel:"引导语预览",editCopyPrompt:"复制 Prompt",editCopied:"已复制",editOpenChat:"打开新对话",delete:"删除",deleteTitle:"删除这条记忆?",deleteConfirm:e=>`将删除「${e}」并移除 MEMORY.md 中对应的索引行。此操作不可恢复。`,deleteDone:"已删除",editPromptLead:e=>`请帮我更新一条记忆:${e}`,editPromptTail:"修改要求:"},vault:{desc:"本 Agent 专属的环境变量(存于 agent_state/.vault.toml):键值对注入其 shell 命令(exec_command)的子进程环境;键名会告知模型,值不进入模型上下文。子 Agent 使用各自的保险柜,不继承。保存后自下一个任务起生效(进行中的任务不受影响)。",key:"键名",value:"值",valueMasked:"值(掩码)",add:"添加",addTitle:"添加环境变量",remove:"删除",deleteTitle:"删除环境变量",deleteConfirm:e=>`确认删除环境变量「${e}」?值不可恢复。`,overwriteTitle:"覆盖已有环境变量",overwriteConfirm:e=>`「${e}」已存在,保存将覆盖原值且不可恢复。`,empty:"尚未配置任何环境变量",readOnlyHint:"member 只读;Vault 修改仅 owner 可执行",keyHint:"字母、数字与下划线,不能以数字开头",keyInvalid:"键名不合法:仅字母、数字与下划线,且不能以数字开头",valueRequired:"值不能为空",injection:{enable:"启用密钥保险柜",templateMissing:"提示词模板中没有 {{VAULT}} 占位符,保险柜小节不会进入上下文。",legacyTemplate:"模板仍是旧版硬编码的 # Vault 段落:一键迁移会将该段落原位替换为 {{VAULT}} 占位符,措辞不变,此后可在下方编辑。",insertPlaceholder:"插入 {{VAULT}} 占位符",migrate:"迁移为 {{VAULT}} 占位符",promptSection:"保险柜提示词",promptSectionHint:"注入模板 {{VAULT}} 占位符的内容;开关关闭或模板无占位符时不注入。",promptLabel:"提示词",promptPlaceholders:[["{{VAULT_KEYS}}","保险柜键名列表(每键一行「- KEY」,仅键名,值永不注入;无键时为空)"]]}},schedule:{desc:"定时任务(agent_state/schedule/*.toml):到点自动向目标 Session 发送 prompt;文件亦可手工编辑,Web 端修改后即时生效。",readOnlyHint:"member 只读;定时任务修改仅 owner 可执行",colStatus:"状态",colPeriod:"周期",colTarget:"目标",colFireTimes:"下次 / 最近触发",colQueued:"排队",statusNames:{active:"生效",disabled:"停用",expired:"已过期",done:"已完成",missed:"已错过",invalid:"无效"},queued:"排队中",once:"一次性",newSession:"新建会话",invalidFiles:"解析失败的文件(已跳过调度)",empty:"尚未配置定时任务",enable:"启用",disable:"停用",addTitle:"新建定时任务",editTitle:e=>`编辑定时任务「${e}」`,nameHint:"即文件名(不含 .toml),创建后不可改",prompt:"Prompt",enabled:"启用",startAt:"开始时间",endAt:"结束时间(可选)",period:"周期",periodPlaceholder:"30m / 12h / 7d,留空为一次性",target:"目标",targetNew:"每次新建会话",targetSession:"绑定 Session",sessionId:"Session",chooseSession:"选择要绑定的 Session",sessionSearch:"搜索标题或 Session id…",sessionNoMatch:"无匹配的 Session",sessionEmpty:"该 Agent 暂无 Session",workspace:"Workspace(可选,留空自动创建临时工作区)",model:"Model",modelDefault:"Project 默认",deleteTitle:"删除定时任务",deleteConfirm:e=>`确认删除定时任务「${e}」?`,injection:{enable:"启用定时任务",templateMissing:"提示词模板中没有 {{SCHEDULES}} 占位符,定时任务小节不会进入上下文。",insertPlaceholder:"插入 {{SCHEDULES}} 占位符",promptSection:"定时任务提示词",promptSectionHint:"注入模板 {{SCHEDULES}} 占位符的内容,教模型用文件工具管理定时任务;开关关闭或模板无占位符时不注入。",promptLabel:"提示词",promptPlaceholders:[["{{SCHEDULE_LIST}}","现有任务名列表(每任务一行「- 名称」;无任务时注入空清单说明)"]]}},skills:{pageTitle:"技能库",pageDesc:"内置 Skill 库:浏览、快捷调用,或安装到 Agent。",quickInvoke:"快捷调用",quickInvokeText:e=>`使用 ${e} 技能`,quickInvokeNeedsInstall:"先在当前 Agent 安装该技能后才能快捷调用",manageInstall:"管理安装",manageInstallTitle:e=>`管理安装:${e}`,install:"安装",installed:"已安装",uninstall:"卸载",skillCount:e=>`${e} 个技能`,usedByAgents:e=>e===0?"未被使用":`${e} 个 Agent 在用`,installedToast:(e,t)=>`已将 ${e} 安装到 ${t}`,updateOutdated:e=>`有新版本:更新 ${e} 个 Agent 的安装`,updateAction:"更新",updateConfirmTitle:e=>`更新 ${e}`,updateConfirmWarning:e=>`更新 ${e} 会把库内当前副本重装到各 Agent,覆盖其已安装的文件——对已装技能的本地改动会丢失,如有需要请先导出备份。`,updatedToast:(e,t)=>`已将 ${e} 更新到最新版(${t} 个 Agent)`,uninstalledToast:(e,t)=>`已从 ${t} 卸载 ${e}`,uninstallConfirmTitle:e=>`卸载 ${e}`,uninstallConfirmBody:(e,t)=>`确定从 ${t} 卸载 ${e} 吗?已安装的技能文件(含本地改动)将被删除。`,agentTabDesc:"该 Agent 已安装的技能(agent_state/skills/,文件即事实来源):元数据注入系统提示词,正文由模型按需读取;卸载会删除整个技能目录。",agentTabEmpty:"尚未安装任何技能",exportSkill:"打包导出",importSkill:"导入技能",importChatTitle:"推荐:让 Agent 在对话中安装",importChatWhy:"Agent 能完整阅读、审查并按需调整技能内容,比直接上传更可靠。",importSourceLabel:"技能来源",importSourceHint:"支持网页 / GitHub 仓库或目录 / 本地路径 / 其他生态的安装命令",importSourcePlaceholder:"https://…、git 仓库、/path/to/skill 或 npx skills add <name>",importSourceToken:"<来源>",importPromptLabel:"发送给 Agent 的 Prompt(预览)",importPromptLead:{webUrl:e=>`请阅读这个网页,并把其中的 Skill 安装到你的技能目录:${e}。`,repoUrl:e=>`请获取这个仓库或目录(git clone 或直接抓取),定位其中含 SKILL.md 的技能目录,并安装到你的技能目录:${e}。`,localPath:e=>`请直接读取这个本地路径下的技能文件,并安装到你的技能目录:${e}。`,command:e=>`这是一条其他生态的技能/插件安装命令,请不要直接执行:先解读它会安装什么,从对应的仓库或注册表获取相同内容,再安装到你的技能目录:${e}。`,reference:e=>`请根据这个技能/插件引用找到其来源(仓库、插件市场或文档页),并把对应的 Skill 安装到你的技能目录:${e}。`},importPromptTail:"安装前请完整阅读全部内容,确认安全、无恶意指令后再写入,并向我说明它的用途。如果你安装了 skill-porting 技能,请先阅读并按其流程处理。",importCopyPrompt:"复制 Prompt",importCopied:"已复制到剪贴板",importOpenChat:"打开新对话",importUploadTitle:"上传技能 zip 包",importUploadDesc:"zip 根目录为 SKILL.md,或仅含一个内含 SKILL.md 的顶层目录。",importUploadAction:"选择 zip 文件",importUploading:"上传中…",importDoneToast:"技能已安装",importOverwriteTitle:"覆盖已安装技能",importOverwriteBody:e=>`技能「${e}」已存在,覆盖安装将替换其全部文件(含本地改动),不可恢复。确认继续?`,importOverwriteAction:"覆盖安装",injection:{enable:"启用技能",templateMissing:"提示词模板中没有 {{SKILLS}} 占位符,技能小节不会进入上下文。",legacyTemplate:"模板仍是旧版硬编码的 # Skills 段落:一键迁移会将该段落原位替换为 {{SKILLS}} 占位符,措辞不变,此后可在下方编辑。",insertPlaceholder:"插入 {{SKILLS}} 占位符",migrate:"迁移为 {{SKILLS}} 占位符",promptSection:"技能提示词",promptSectionHint:"注入模板 {{SKILLS}} 占位符的内容;开关关闭或模板无占位符时不注入。",promptLabel:"提示词",promptPlaceholders:[["{{SKILL_METADATA}}","已安装技能的元数据行(每技能一行「- 名称 — 描述」;无技能时为空)"]]}},chat:{newSessionMenu:"新建对话",chooseAgent:"选择 Agent",chooseModel:"选择模型",thinkingLevel:"思考等级",thinkingLevelNames:{none:"无",low:"低",medium:"中",high:"高",xhigh:"极高"},workspaceUseThis:"使用此目录",workspaceUp:"上级目录",workspaceNoSubdirs:"无子目录",workspaceAuto:"临时工作区",workspaceClear:"改用临时工作区",workspaceDirInvalid:"目录不存在或无法访问,已回退",groupByWorkspace:"按工作区分组",groupByAgent:"按 Agent 分组",tempWorkspaces:"临时工作区",newSessionInWorkspace:"在此工作区新建对话",draftSubtitle:"最擅长 AI 开发任务的自进化 Agent",exampleFolders:{webapps:"搭建网页应用",agents:"搭建和优化智能体"},exampleTasks:{game:{label:"2D 企鹅雪橇越野小游戏",desc:"可爱南极企鹅滑雪橇跳石头,难度由易到难的 2D 纯前端小游戏",prompt:"做一个可爱的南极企鹅滑雪橇越野 2D 小游戏:按空格键起跳,跃过冰面上迎面而来的石头;开局要足够简单、上手无压力,滑行速度与障碍密度随时间平滑、循序渐进地上升,避免突然变难,实时计分,撞上石头即结束并可一键重新开始。2D 横版画面、可爱卡通风,纯前端实现(单个 HTML 文件即可),界面遵循 web-design 技能。完成后在浏览器里自测一次,确认开局能轻松玩过几秒,并告诉我怎么打开和怎么玩。"},gamecenter:{label:"多智能体搭建小游戏中心",desc:"并行产出 10 个玩法互不重复的纯前端小游戏,配一个统一风格的索引首页",prompt:`用多智能体并行搭建一个网页小游戏中心:10 个玩法互不重复的纯前端小游戏,外加一个索引首页。
10
-
11
- ## 分工方式
12
- - 先规划这 10 个游戏(例如贪吃蛇、2048、俄罗斯方块、打砖块、扫雷、记忆翻牌、推箱子、太空射击、跳跃平台、节奏点击),确认玩法确实互不重复,并定好统一的目录结构、配色与交互规范。
13
- - 再把 10 个游戏分派给多个子智能体并行实现,每个子智能体只负责自己的那一个游戏,严格按既定规范产出,互不改动他人的文件。
14
-
15
- ## 每个游戏
16
- - 独立的 \`games/<slug>/index.html\`,纯前端单文件、file:// 直接打开即可运行,不依赖后端与任何 CDN 资源。
17
- - 具备开始 / 重新开始、实时计分或计时、失败或通关结算,并同时支持键盘与触摸操作,页面内写明玩法说明。
18
- - 提供返回索引首页的入口。
19
-
20
- ## 索引首页
21
- - 根目录 \`index.html\`:卡片网格列出全部 10 个游戏(名称 + 一句话玩法 + 操作方式),点击进入对应游戏。
22
- - 与所有游戏共用一套设计语言,遵循 web-design 技能。
23
-
24
- ## 收尾
25
- - 统一验收:10 个游戏玩法确实不重复、风格一致,索引页的链接全部可达。
26
- - 在浏览器里逐个自测,确认都能开始、能结束、能重开,然后告诉我怎么打开。`},lol:{label:"英雄联盟音乐播放器",desc:"用 SoundCloud Widget API 播放历届 Worlds 主题曲,单文件即开即用",prompt:`用 SoundCloud Widget API(见 https://developers.soundcloud.com/docs/api/html5-widget)做一个英雄联盟 Worlds 主题曲播放器,单文件 index.html,file:// 打开即用。
27
-
28
- ## 技术约束
29
- - 使用 SC.Widget JS API(widget.load / widget.toggle / widget.setVolume / widget.seekTo),引入 https://w.soundcloud.com/player/api.js
30
- - iframe 必须可见(180px 高),visual=true color=f0b90b single_active=true
31
- - 仅包含以下 8 首已确认可播曲目(oEmbed 验证通过),不要添加未经 oEmbed 验证的曲目:
32
- - Warriors (S4) — soundcloud.com/leagueoflegends/warriors
33
- - Worlds Collide (S5) — soundcloud.com/leagueoflegends/worlds-collide
34
- - Legends Never Die (S7) — soundcloud.com/leagueoflegends/legends-never-die
35
- - Phoenix (S9) — soundcloud.com/leagueoflegends/phoenix
36
- - Burn It All Down (S11) — soundcloud.com/leagueoflegends/burn-it-all-down
37
- - GODS (S13) — soundcloud.com/leagueoflegends/gods
38
- - Heavy Is The Crown (S14) — soundcloud.com/linkinpark/heavy-is-the-crown
39
- - Sacrifice (S15) — soundcloud.com/leagueoflegends/sacrifice
40
-
41
- ## 布局
42
- - 左侧 260px 粘性侧边栏:曲目列表(S4/S5/… 标签 + emoji + 曲名 + 年份),点击高亮金色边框,SC.Widget.load() 切歌 + auto_play
43
- - 右侧主区域:Hero 标题 + 桌面时钟(80px 等宽金色 HH:MM:SS,每秒刷新,冒号闪烁)+ 心情标签
44
- - 播放器卡片:SoundCloud iframe + 自定义控制栏(⏮ ▶/⏸ ⏭ + 曲目信息 + 音量滑块,点击喇叭图标静音切换)
45
- - 心情波动区:15 根金色动画柱,切歌时重新随机生成
46
- - 键盘快捷键:空格播放暂停、← → 切歌、↑ ↓ 调音量
47
-
48
- ## 设计
49
- Penguin 视觉风格(见 web-design 技能),默认深色。手机端侧边栏变为顶部横向滚动。
50
-
51
- 完成后在浏览器打开 index.html 自测一次。`},rag:{label:"构建 Claude Code 文档 RAG 智能体",desc:"收集 claude-code-docs 仓库,生成可对话、带来源引用的 RAG 知识应用",prompt:"收集 https://github.com/ericbuess/claude-code-docs 的文档,构建一个 RAG 知识应用:克隆仓库并整理语料,建立检索索引;应用化身 Claude Code 配置专家,检索增强回答 Claude Code 相关问题并标注可点击的来源引用——引用要能展示命中的原文片段,并链接到真实文档;按 web-design 技能提供美观的 Web 聊天界面。完成后运行应用,用一个中文问题和一个英文问题各自测一次,确认两者都检索到了正确的英文文档、流式回答正常,并告诉我访问方式。"},agentBenchmarkBuild:{label:"构建通用决策智能体和评测基准",desc:"创建一个通用决策 Agent,并用足球、售后和投资任务检验它",prompt:`请依次使用 \`agent-creation\` 和 \`benchmark-design\`,创建决策 Agent,并产出 Frozen Benchmark 与 Formal Baseline。
52
-
53
- Agent:
54
- - id:\`finite_choice_agent\`
55
- - 能力:面对有限选项,在公开信息不足或冲突时仍能给出稳定、可解释的选择
56
- - installed_skills:\`[]\`
57
-
58
- Benchmark:
59
- - id:\`contextual-choice-adaptation\`
60
- - capability:从公开规则、历史案例和当前事实中形成并迁移稳定的有限选择决策过程
61
- - desired_baseline_score:\`<75\`
62
- - pilot_iteration_limit:\`5\`
63
-
64
- 场景:
65
- 1. 根据历史比赛与当前信息进行足球投注决策。
66
- 2. 根据售后政策与工单事实选择处置动作。
67
- 3. 根据投资策略、历史市场与当前指标选择投资动作。`},agentOptimization:{label:"优化通用决策智能体的准确率",desc:"根据已有评测结果改进 Agent,并验证新版本是否真正提升",prompt:"请使用 `agent-optimization`,根据 Frozen Benchmark 优化决策 Agent。\n\n- test_agent_id:`finite_choice_agent`\n- benchmark_id:`contextual-choice-adaptation`\n- capability_direction:提高信息不完整、规则冲突和有限选项决策中的稳定性\n- runs:`3`\n- desired_score:`>=95`\n- candidate_round_limit:`5`"}},sessionList:"Session",defaultSessionTitle:"新对话",model:"Model",workspace:"Workspace",workspaceHint:"留空自动创建临时工作区;指定时必须是服务器上已存在的目录",approvalMode:"审批模式",approvalModeNames:{"allow-all":"全部放行","deny-all":"全部拒绝","read-only":"放行只读","always-ask":"总是询问"},approvalModes:{"allow-all":"全部放行(allow-all)","deny-all":"全部拒绝(deny-all)","read-only":"放行只读(read-only)","always-ask":"总是询问(always-ask)"},statusRunning:"运行中",statusCompacting:"压缩中",pendingApprovals:e=>`${e} 个待审批`,jumpToLatest:"回到最新消息",loadingEarlier:"正在加载更早的对话…",loadEarlierRetry:"更早的对话加载失败,点击重试",historyBeginning:"已是对话开头",outlineTitle:"对话索引",outlineTickLabel:(e,t)=>`第 ${e} 轮:${t}`,outlineNoText:"(图片或附件)",outlineAnswering:"回答生成中…",inputPlaceholder:"输入消息,Enter 发送,Shift+Enter 换行,可粘贴图片",inputPlaceholderShort:"输入消息…",steerPlaceholder:"给运行中的 Agent 留言,随下一轮对话送达",steerPlaceholderShort:"给运行中的 Agent 留言…",steerSend:"发送给运行中的 Agent",steerQueuedIndicator:"插话已排队,将随下一轮送达",steerQueuedItem:e=>`插话已排队,将随下一轮送达:${e}`,userSteering:"用户插话",steerModeLabel:"运行中发送方式",steerModeSteer:"插话",steerModeSteerHint:"立即插话:随下一轮对话送达运行中的 Agent",steerModeFollowUp:"排队",steerModeFollowUpHint:"排队跟进:本轮结束后自动作为新消息发送",followUpPlaceholder:"排队为下一条消息,本轮结束后自动发送",followUpPlaceholderShort:"排队为下一条消息…",followUpSend:"排队为下一条消息",followUpQueuedChip:e=>`${e} 条跟进消息已排队,本轮结束后自动发送`,send:"发送",stop:"停止",compact:"压缩上下文",approve:"允许",deny:"拒绝",decisionAllow:"已批准",decisionDeny:"已拒绝",decisionManual:"手动",decisionAuto:"自动",thinking:"思考",subagent:"子会话",subagentRunning:"运行中",aborted:e=>`[已中断]${e?`:${e}`:""}`,modelAuthDead:"模型 API 认证失败:请在模型配置页更新该模型的 API key,或新建会话。",modelAuthDeadOpenModels:"打开模型配置",modelAuthDeadRetry:"重试",modelAuthDeadCta:"新建会话",modelAuthDeadPlaceholder:"模型认证失败,请先更新 API key",reconnect:(e,t,a,l)=>{const o=e==="timeout"?"连接超时或网络中断":e==="malformed"?"响应不完整或无法解析":"模型服务返回错误",c=t==="gaveUp"?"已停止重试":t==="retried"?`已发起第 ${a} 次重试`:l!==void 0?`第 ${a} 次重试,${l} 秒后发起…`:`正在发起第 ${a} 次重试…`;return`[重试] ${o},${c}`},reconnectRetryNow:"立即重试",reconnectGiveUp:"放弃",imageAlt:"用户上传的图片",toolImageAlt:"工具输出的图片",imagesAsPathHint:"当前模型不支持直接查看图片:发送时图片将保存到会话临时目录,以文件路径转交(模型经 describe_image 查看)",infoPanel:"Session 信息",sessionStats:"统计",sessionIdLabel:"Session id",copySessionId:"复制 Session id",traceFile:"轨迹文件",processList:"会话进程",processStop:"停止",processExited:"已退出",runningServices:e=>`${e} 个运行中的服务`,statTokens:"Token 累计",statTotalTokens:"总 Token",statCacheHit:e=>`缓存命中率 ${e}`,statElapsed:"用时",statInput:"输入 tokens",statCached:"已缓存",statOutput:"输出 tokens",statTps:"输出 TPS",statParenOpen:"(",statParenClose:")",noSessions:"还没有 Session",emptyStream:"发送一条消息开始对话",historyLoadFailed:"历史消息加载失败",statsLabel:"统计信息",removeImage:"移除图片",openWorkspace:"打开工作区",openAgents:"智能体面板",filesInMessage:e=>`${e} 个文件`,imagesInMessage:e=>`${e} 张图片`,openPreview:"点击预览",showMoreFiles:e=>`显示其余 ${e} 个文件`,showLess:"收起",moreGroups:e=>`更多分组(${e})`,contextUsage:"上下文占用",contextUnknown:"上下文占用:压缩后待下次请求回报",slashHint:"输入 / 使用命令",switchAgent:"交给其他 Agent,发送时开启新会话",switchAgentTitle:"选择 Agent",agentSearchPlaceholder:"搜索 Agent:id / 名称",agentsNoMatch:"没有匹配的 Agent",handoffTargetTitle:e=>`发送后交接给 ${e}`,handoffRemove:"移除交接目标",skillsSelect:"技能",skillRemove:"移除技能",skillsSearchPlaceholder:"搜索技能",skillsNoMatch:"没有匹配的技能",skillsEmptyHint:"暂无已装技能,去技能库添加",skillsAutoMessage:e=>`使用 ${e.join("、")} 技能`,handoffFrom:e=>`由 ${e} 的对话交接而来`,handoffBack:e=>e?`回到原对话:${e}`:"回到原对话",switchModel:"切换模型,发送时开启新会话延续本对话",switchModelTitle:"切换模型",modelSwitchTargetTitle:e=>`发送后换用 ${e} 延续本对话`,modelSwitchRemove:"移除切换模型",modelSwitchBusyHint:"本轮结束后才能切换模型:新会话要从当前会话的记录接续",modelSwitchFrom:e=>e?`已切换模型(原为 ${e}),延续原会话`:"已切换模型,延续原会话",modelSwitchAutoMessage:"换用新模型继续这段对话",modelLockedHint:"输入 /model 切换模型",scheduledFrom:e=>`由定时任务「${e}」触发`,emptyGreeting:"开始一段新对话",mcpConnectTitle:"MCP 连接",mcpServerList:e=>e.join("、"),mcpConnectResult:(e,t)=>{const a=[];return(e>0||t.length===0)&&a.push(`发现 ${e} 个工具`),t.length>0&&a.push(`不可用:${t.join("、")}`),a.join(";")},mcpToolsCount:e=>`${e} 个工具`,mcpServerFailed:"连接失败",mcpConnectAborted:"已中断,下次发送时重新连接",compactionTitle:"压缩",compactionDone:e=>e==="discard"?"已丢弃旧上下文":"已切换到摘要后的新上下文",compactionFailed:(e,t)=>e==="aborted"?"已中断,保留当前上下文":t!==void 0?`失败(${t}),保留当前上下文`:"失败,保留当前上下文",unknownTool:"(未知工具)",workRunning:"运行中",workDone:"运行完毕",workGroupSteps:e=>`${e} 步`,approvalWaiting:"待审批",copyCode:"复制代码",copyReply:"复制回复",copyMessage:"复制消息",deleteSession:"删除对话",renameSession:"重命名对话",renameSessionLabel:"标题",deleteSessionConfirm:e=>`确定删除「${e}」?该对话的消息与 Trace 将被移除,且不可恢复。`,draftGroup:"草稿",draftUntitled:"(无标题草稿)",deleteDraft:"删除草稿",deleteDraftConfirm:e=>`确定删除草稿「${e}」?未发送的内容将被丢弃。`,archiveSession:"归档",unarchiveSession:"取消归档",loadMore:"更多",folderGroups:{subagent:e=>`子智能体(${e})`,schedule:e=>`定时任务(${e})`,archived:e=>`已归档(${e})`},skillsBanner:e=>`使用技能:${e.join("、")}`,attachedFilesBanner:e=>`附加文件:${e.join("、")}`,plusMenu:"更多输入方式",uploadImage:"上传图片",uploadImageDesc:"为本条消息附加图片",uploadFile:"上传文件",uploadFileDesc:"文件存入会话临时目录,模型按路径读取",removeFile:"移除文件",attachmentTooLarge:e=>`${e} 超过 10MB 上限,未添加。`,goalMode:"目标模式",goalModeDesc:"循环运行直至目标完成",goalBudgetLabel:"Token 预算",goalBudgetUnlimited:"预算不限",goalBudgetValue:e=>`预算 ${e}`,goalBudgetPlaceholder:"例如 500k",goalBudgetHint:"支持 k/m 后缀;留空表示预算不限",goalBudgetInvalid:"无效预算:应为正数,可带 k/m 后缀(500k、2m)",goalBudgetSave:"保存预算",goalRemove:"退出目标模式",goalRoundBanner:e=>`目标 · 第 ${e} 轮`,goalRoundImages:e=>`${e} 张附图`,goalProgress:(e,t)=>`第 ${e} 轮 · tokens ${t}`,goalStatus:{active:"进行中",complete:"已完成",blocked:"受阻",budget_limited:"预算耗尽",aborted:"已中断"}},subagentPanel:{title:"智能体面板",topologyLabel:"调用关系",mainSessionNote:"主会话请在对话区查看",empty:"本次任务尚未派生子智能体",nodeRunning:"运行中",nodeDone:"已完成"},files:{title:"文件",upload:"上传",download:"下载",openInNewTab:"新页面打开",previewNotIsolatedHint:"当前访问地址无法提供独立预览源,页面将以沙箱模式打开:localStorage、Cookie 与第三方 embed 不可用。经 127.0.0.1 或 localhost 访问,或配置 PENGUIN_PREVIEW_ORIGIN 即可解除。",refresh:"刷新",root:"根目录",empty:"空目录",previewUnsupported:"该类型不支持预览,请下载查看",uploaded:"已上传",overwriteTitle:"覆盖同名文件",overwriteConfirm:e=>`当前目录已存在以下 ${e} 个同名文件,上传将覆盖:`,loadFailed:"加载失败",previewTruncated:"内容过大,预览已截断,请下载查看完整文件",details:"详情",workspacePath:"Workspace 路径",htmlRendered:"渲染视图",htmlSource:"源码",backToList:"返回列表",resizeHandle:"拖拽调整宽度,双击恢复默认"},usage:{title:"成本与统计",today:"今日",last7d:"近 7 天",total:"累计",tokens:"Token",requests:"Requests",from:"起始日期",to:"结束日期",colCacheRead:"cache_read",colCacheWrite:"cache_write",colOutput:"output",uncostedNote:"* 只计入配置了价格的模型成本",filterAllAgents:"全部 Agent",filterAllModels:"全部模型",chartAgentCalls:"各 Agent 调用次数",chartSuccessRate:"各模型成功率",chartTokenTrend:"Token 逐日变化",chartCostTrend:"成本逐日变化",empty:"暂无用量记录",successAborted:"已中断(不计入)",errors:"异常",errorsTotal:"总数",errorsUnexpected:"未预期",errorsExpected:"预期内",errorsTopCode:"最常见",errorsColCode:"来源 · 错误码",errorsColKind:"类型",errorsColMessage:"消息",errorsEmpty:"暂无异常",errorsNewer:"较新",errorsOlder:"更早",errorsPageOf:(e,t,a)=>`第 ${e} / ${t} 页 · 共 ${a} 条`},traces:{title:"轨迹观测",timeline:"执行时间线",laneLLM:"模型",kindThinking:"思考",kindModelReply:"模型回复",kindToolGen:"工具调用生成",legendToolExec:"工具调用执行",legendOther:"其他",toolParams:"参数 Schema",legendApprovalWait:"审批等待",task:e=>`第 ${e} 轮`,globalSummary:"全局统计",tasksLabel:"轮次",messages:"消息",truncatedNote:(e,t)=>`仅展示前 ${e} / ${t} 条消息`,zoom:"缩放",zoomReset:"双击复位缩放",zoomOut:"缩小",zoomIn:"放大",linkHint:"鼠标移到时间线段或消息行即可联动高亮,点击时间线段跳转到对应消息;图例可高亮同类;拖动下方滑块平移/缩放",filesTitle:"Trace 文件",selectSession:"在左侧选择一个 Session",toolCalls:"工具调用",taskInput:"本轮输入 tokens",taskOutput:"本轮输出 tokens",cacheHit:"命中缓存",hitRate:"命中率",compactions:"压缩次数",compactionRound:"压缩",empty:"该 Agent 暂无 Trace",inProgress:"进行中",systemPrompt:"系统提示词",toolDefs:e=>`工具定义(${e})`,exportFile:"导出",importTrace:"导入 Trace",importAgent:"导入到 Agent",importPickFile:"选择文件",importing:"导入中…",fileTooLarge:"文件超过 14MB 上限。"},benchmark:{title:"评估中心",selectBenchmark:"在左侧选择一个 Benchmark",emptyAgent:"该 Agent 暂无 Benchmark",caseCount:e=>`${e} 题`,trendTitle:e=>`${e}随时间变化`,cases:"题目",viewCase:"查看详情",taskMaterials:"任务材料",rubric:"评分标准",agentHidden:"被测 Agent 不可见",caseFileUnavailable:"案例文件暂时无法读取",evaluations:"评估明细",noEvaluations:"暂无评估记录",summaryLabel:"评估说明",legendUnlabeled:"未标注模型",colVersion:"版本",colModel:"模型 ID",colThinkingLevel:"推理强度",colScore:"Score",colDuration:"耗时",colCase:"题目",colRun:"运行",colSession:"Session"},errors:{networkError:"网络错误,请检查连接",modelCredentialMissing:e=>`模型 ${e} 还没有可用的 API key,请先在「模型」页为它配置`,noDefaultModel:"该 Project 还没有默认模型,请先在「模型」页添加模型并设为默认",byCode:{invalid_credentials:"用户名或密码错误。",too_many_attempts:"登录失败次数过多,请稍后重试。",password_mismatch:"当前密码不正确。",invalid_password:"密码至少 8 位。",admin_required:"仅管理员可执行此操作。",desktop_single_user:"桌面应用为单用户模式,用户管理不可用。",not_found:"资源不存在,或你没有访问权限。",agent_not_found:"该 Agent 已不存在。",unknown_agent:"该 Agent 不存在于本 Project。",agent_exists:"该 Agent id 已被占用。",project_exists:"该 Project id 已被占用。",user_exists:"该用户名已被占用。",user_not_found:"该用户已不存在。",cannot_delete_admin:"内置 admin 不可删除。",member_not_found:"该用户不是本 Project 的成员。",schedule_exists:"已存在同名定时任务。",schedule_not_found:"该定时任务已不存在。",unknown_skill:"该技能不在技能库中。",file_not_found:"该文件已不存在。",file_too_large:"文件过大。",too_many_files:"一条消息附加的文件过多。",payload_too_large:"请求体过大。",dir_not_absolute:"目录必须是绝对路径。",dir_not_found:"该目录不存在或不可访问。",not_a_dir:"该路径不是目录。",path_not_found:"该路径不存在。",workspace_missing:"该 Session 的 Workspace 已不存在。",task_in_progress:"该 Session 已有任务在运行。",version_conflict:"快照版本不高于当前版本。",invalid_title:"标题无效。",invalid_proxy_url:"代理地址无效:应为 http://主机[:端口]、https://主机[:端口] 或 主机[:端口]。",invalid_trace:"该文件不是有效的 Trace 文件。",trace_session_exists:"该 Agent 已存在同名 Session,无法导入重复的 Trace。"}}};let m=vk;function gC(e){m=e}const xC={appName:"PenguinHarness",nav:{chat:"Chat",newChat:"New chat",agents:"Agents",skills:"Skills",models:"Models",usage:"Cost Center",traces:"Trajectories",benchmark:"Evaluation Center",lastConversation:"Last conversation",collapseSidebar:"Collapse sidebar",expandSidebar:"Expand sidebar",collapseGroup:"Collapse",expandGroup:"Expand",pinGroup:"Pin group",unpinGroup:"Unpin group"},settings:{language:"Language",showCliSessions:"Show CLI sessions",proxyMenu:"Proxy options…",proxyDialogTitle:"Proxy options",proxyForApp:"Application uses the proxy",proxyForAgent:"Agent environment uses the proxy",proxyAddress:"Proxy address",proxyAddressPlaceholder:"Empty = follow system proxy",theme:"Theme",themeLight:"Light",themeDark:"Dark",followSystem:"System",langZh:"中文",langEn:"English",fontSize:"Font size",fontSmall:"S",fontMedium:"M",fontLarge:"L",accent:"Accent",accentNames:{neutral:"Neutral",blue:"Blue",green:"Green",violet:"Violet",rose:"Rose",amber:"Amber"}},update:{lastUpdated:e=>`Last updated ${e}`,newVersionBadge:"New version available",newVersion:e=>`New version v${e} available`,checkNow:"Check for updates",checking:"Checking…",foundNew:e=>`New version v${e} found — use the update entry below to install`,upToDate:"You're on the latest version",checkFailed:"Update check failed — try again later",checkDisabled:"Update checks are disabled (PENGUIN_UPDATE_CHECK=off)",releaseNotes:"Release notes",updateNow:"Update now",updating:"Updating…",updated:"Update complete — restart the service to apply",restartHint:"Restart by re-running penguin web (or penguin server) in a terminal",failed:"Update failed",unsupported:"This install cannot be updated from the web UI",confirmBody:"Downloads the latest release and installs it into the install directory on the server (the data directory is not touched). Restart the service afterwards for the update to take effect.",adminOnly:"Only an administrator can run the update from here."},notify:{taskCompleteTitle:"Task completed",taskCompleteBody:e=>`"${e}" has finished — click to view`},common:{save:"Save",cancel:"Cancel",create:"Create",delete:"Delete",edit:"Edit",settings:"Settings",confirm:"Confirm",close:"Close",loading:"Loading…",saved:"Saved",saving:"Saving…",noChangesToSave:"No changes to save",confirmSaveTitle:"Save changes",confirmSaveBody:"Save these changes? They will be written to the configuration files on the server.",none:"(none)",retry:"Retry",unknownError:"Request failed, please try again later",requiredField:"This field is required",copied:"Copied",name:"Name",username:"Username",role:"Role",actions:"Actions",created:"Created",cost:"Cost",time:"Time"},auth:{usernameHint:"2–32 chars: starts with a lowercase letter; lowercase letters, digits and underscores only",password:"Password",passwordHint:"At least 8 characters",showPassword:"Show password",hidePassword:"Hide password",login:"Sign in",logout:"Sign out",admin:"Admin",defaultAdminNote:"First run: sign in as the built-in admin “admin” with the initial password printed in the server startup output (looks like penguin-1234), then change it soon"},account:{changePassword:"Change password",oldPassword:"Current password",oldPasswordHint:"The built-in admin's initial password is printed in the server startup output (looks like penguin-1234)",newPassword:"New password",confirmPassword:"Confirm new password",passwordMismatch:"New passwords do not match",initialPasswordBanner:"This account is using its initial password. Please change it soon.",changeNow:"Change now"},admin:{users:"Users",roleAdmin:"Admin",roleUser:"User",createUser:"Add user",initialPassword:"Initial password",initialPasswordFlag:"initial password",defaultProjectNote:e=>`A default Project will be created: ${e}`,resetPassword:"Reset password",resetPasswordTitle:e=>`Reset password for ${e}`,resetPasswordNote:"All sign-in sessions of this user will be revoked; they must sign in with the new password",deleteUserTitle:e=>`Delete user ${e}`,deleteUserConfirm:e=>`This deletes user ${e} and every Project they own (including data directories). This cannot be undone.`},project:{switcher:"Project",create:"New Project",createTitle:"New Project",id:"Project id",idHint:"2–64 chars: starts with a lowercase letter; lowercase letters, digits and underscores only. Cannot be changed later.",idPrefixHint:"The id is prefixed with your username and a hyphen; append lowercase letters, digits or underscores. Cannot be changed later.",name:"Display name (optional, defaults to the Project id)",displayName:"Display name",settings:"Project settings",settingsTitle:"Project settings",members:"Members",addMember:"Add member",removeMember:"Remove",chatDefaultsTitle:"New chat defaults",chatDefaultsHint:"Prefilled defaults for every new chat: agent, working directory, approval mode, thinking level and default model.",chatDefaultsAgent:"Agent",chatDefaultsNotSet:"Not set",chatDefaultsApprovalNotSet:"Not set (defaults to allow all)",chatDefaultsThinkingNotSet:"Not set (follow the agent's config)",chatDefaultsWorkspaceHint:"Empty = temporary workspace",chatDefaultsModelHint:"Same default model as the Models page",deleteProject:"Delete Project",deleteConfirm:"Delete this Project? Its directory will be removed recursively and cannot be recovered.",deleteLastForbidden:"This is the last Project on this account; create another Project before deleting it",deleteDefaultForbidden:"default_project is shared with the CLI and cannot be deleted from the web",noCredentialTitle:"No model credential configured",noCredentialBody:"The default model of this Project has no API key yet. Configure it on the Models page before chatting.",goToModels:"Go to Models",later:"Later"},agent:{listTitle:"Agents",create:"Create agent",createTitle:"Create agent",id:"Agent id",idHint:"2–64 chars: starts with a lowercase letter; lowercase letters, digits and underscores only. Cannot be changed later.",nameHint:"Leave empty to use the agent id as the name",description:"Description",sessionCount:e=>`${e} session${e===1?"":"s"}`,toolCount:e=>`${e} tool${e===1?"":"s"}`,vaultKeyCount:e=>`${e} vault key${e===1?"":"s"}`,scheduleCount:e=>`${e} scheduled task${e===1?"":"s"}`,memoryCount:e=>e===1?"1 memory":`${e} memories`,updatedAt:"Last modified",activity:e=>`${e}-day session activity`,settings:"Agent settings",backToList:"Back to Agents",tabOverview:"Overview",tabPrompt:"System Prompt",tabMemory:"Memory",tabRuntime:"Runtime",tabTools:"Tools",tabSkills:"Skills",tabVault:"Vault",tabSchedules:"Schedules",stateDir:"State path",copyStateDir:"Copy State path",agentsMd:"AGENTS.md",systemPrompt:"system_prompt template",placeholdersTitle:"Available placeholders (click to insert)",insertPlaceholder:"Insert at the system_prompt cursor",placeholders:[["{{AGENTS_MD}}","Injects the AGENTS.md content"],["{{VAULT}}","Injects the vault block (vault.prompt with the key-name list); empty when its toggle is off"],["{{SKILLS}}","Injects the skills block (skills.prompt with installed-skill metadata); empty when its toggle is off"],["{{MEMORY}}","Injects the memory block: memory.prompt plus memory.workspace_prompt (persistent workspaces only); empty when memory is off"],["{{SCHEDULES}}","Injects the scheduled-tasks block (schedules.prompt with the task-name roster); empty when its toggle is off"],["{{PLATFORM}}","Runtime platform"],["{{OS_VERSION}}","Operating system version"],["{{SHELL}}","Shell used to run commands"],["{{DATE}}","Current date"],["{{PROJECT_DIR}}","PenguinHarness app data root — all agents' data and project-level data; not the task working directory"],["{{AGENT_ID}}","Current agent id"],["{{CWD}}","Absolute Workspace path"],["{{PROVIDER}}","Model provider group"],["{{MODEL_ID}}","Upstream model id"],["{{SESSION_ID}}","Current Session id"]],maxTurns:"max_turns (max turns per Task, -1 = unlimited)",maxTokens:"model.max_tokens",thinkingLevel:"model.thinking_level",thinkingLevelOptions:[["","Send no override — keep whatever is currently configured."],["low","Enables a lower tier of extended reasoning."],["medium","Enables a medium tier of extended reasoning (the default tier for a newly created agent)."],["high","Enables a higher tier of extended reasoning; slower responses."],["xhigh","Enables the highest tier of extended reasoning; identical to high on some models."]],thinkingLevelNoneKept:"Stored legacy tier: new selections no longer offer the off tier (many models cannot disable thinking).",timeoutMs:"model.timeoutMs",timeoutMsHint:"Per-request timeout, ms",compaction:"Context compaction",maxContextLength:"max_context_length",maxContextLengthHint:"Context threshold that triggers compaction",maxSessionTurns:"max_session_turns",maxSessionTurnsHint:"Turn threshold that triggers compaction",compactionMode:"mode (compaction strategy)",compactionModeOptions:[["","Send no override — keep whatever is currently configured."],["summarize","Summarizes the old context with the model, then continues from that summary in a fresh window (default)."],["discard","Drops the old context without summarizing; the next turn starts fresh in a new window."]],compactionPrompt:"prompt (summarization prompt)",maxTurnsInvalid:"max_turns must be > 0 or -1",timeoutInvalid:"timeoutMs must be > 0 or -1",toolFieldInvalid:(e,t)=>`${e}: ${t} must be a positive integer or -1`,toolPermission:"permission",permissionReadLabel:"Read-only",permissionReadDescription:"Only reads. Auto-approved when the approval mode is read-only.",permissionReadWriteLabel:"Read & write",permissionReadWriteDescription:"Can modify things. Needs manual confirmation when the approval mode is read-only.",toolTimeout:"timeoutMs",toolMaxOutput:"maxOutputLength",toolCallDescription:"call_description",callDescriptionHint:"call_description: when on (the default), the tool's schema keeps the optional description argument — a model-written sentence about each call, shown to the user while it runs; when off, the argument is filtered out of the schema at assembly. Only tools whose parameters declare a description property can be toggled.",mcpServers:"MCP Servers",mcpDesc:"Connect external MCP Servers: their tools join this agent's toolset as mcp__<name>__<tool>. Changes in this block save immediately.",mcpEmpty:"No MCP Servers configured yet",mcpAdd:"Add MCP Server",mcpEditTitle:"Edit MCP Server",mcpRemove:"Remove",mcpName:"name",mcpNameHint:"Tool-name prefix: mcp__<name>__<tool>; letters, digits, _ and - only",mcpTransport:"transport",mcpTransportStdio:"Local process: spawns command and talks over stdin/stdout",mcpTransportHttp:"Streamable HTTP: the current spec's remote transport",mcpTransportSse:"Legacy HTTP+SSE: kept for servers that have not migrated",mcpTarget:"command / url",mcpCommand:"command",mcpArgs:"args",mcpArgsHint:"One argument per line",mcpEnv:"env",mcpEnvHint:"One KEY=value per line; the Agent vault is not injected into MCP Server processes",mcpCwd:"cwd",mcpCwdHint:"Leave empty to use the Session's Workspace",mcpUrl:"url",mcpHeaders:"headers",mcpHeadersHint:"One Header-Name: value per line (auth headers such as Authorization)",mcpConnectTimeout:"connectTimeoutMs",mcpBudgetsHint:"Leave empty for defaults: connectTimeoutMs is the connect + tool-discovery budget (default 10000); timeoutMs / maxOutputLength bound every tool of this Server.",mcpNameInvalid:"Letters, digits, _ and - only, starting with a letter or digit",mcpUrlInvalid:"Must be a valid http(s) URL",mcpLineInvalid:e=>`Line ${e} is not valid`,mcpNumberInvalid:"Must be an integer > 0",mcpDuplicateName:"A server with this name already exists",mcpTest:"Test connection",mcpTesting:"Testing…",mcpTestOk:(e,t)=>{const a=t!==void 0?` (${(t/1e3).toFixed(1)}s)`:"";return e===0?`Connected, but the server exposes no tools${a}`:`Connected — ${e} tool${e===1?"":"s"}${a}`},mcpTestFail:e=>`Connection failed: ${e}`,mcpTestAllConfirm:e=>`Connects to ${e===1?"the configured MCP server":`each of the ${e} configured MCP servers`} in turn and runs tool discovery (real connections, nothing is saved); results land on each row.`,mcpTestAllStart:"Start test",mcpTestPending:"Testing…",mcpTestBadge:(e,t)=>`${e} tool${e===1?"":"s"}${t!==void 0?` · ${(t/1e3).toFixed(1)}s`:""}`,mcpTestBadgeFail:"Connection failed",mcpDeleteTitle:"Delete MCP Server",mcpDeleteConfirm:e=>`Delete MCP Server "${e}"? Its tools stop being available from the next Session on.`,defaultValue:"(default)",deleteAgent:"Delete agent",builtinUndeletable:"Built-in agents cannot be deleted",deleteConfirm:e=>`Delete agent "${e}"? Its directory (including all Traces) will be removed recursively and cannot be recovered.`,stateTitle:"Agent State",stateVersion:"Agent State version",transferDesc:"Export the current Agent State snapshot (tar.gz); importing overwrites the whole directory and adopts the version inside the package.",exportSnapshot:"Export snapshot",importSnapshot:"Import snapshot",importing:"Importing…",importDone:e=>`Import finished, Agent State version v${e}`,importConflictTitle:"Version conflict",importConflictBody:"The snapshot's version is not newer than the current one; importing will overwrite the existing Agent State. Continue?",resetConfigTitle:"Restore default configuration",resetConfigAction:"Restore default configuration",resetConfigConfirmBody:"This overwrites the agent's existing configuration with the current defaults: the custom system prompt, tool list, model/compaction settings and MCP servers are all replaced, keeping only name and description. Like a skill update this cannot be undone. Continue?",resetConfigDone:"Configuration restored to the current defaults",kernelTitle:"Kernel",kernelLegacy:"predates kernel versioning",kernelOutdatedHint:"Kernel update available",kernelUpToDate:"Up to date",kernelUpdateTitle:"Update kernel",kernelCurrent:"current",kernelLatest:"latest",kernelUpdateAction:"Update kernel",kernelUpdateConfirmBody:"Fields you have not customized will be updated to the current built-in defaults; customized fields stay unchanged and are listed in the result. Name, description, the State version and MCP servers are unaffected. Continue?",kernelUpdateDone:(e,t)=>t>0?`Kernel updated to ${e}; ${t} field(s) now follow the new defaults`:`Kernel updated to ${e}; every field was already current or kept as customized`,kernelUpdateKeptIntro:"Kept because customized:",kernelListSeparator:", ",kernelFieldTool:e=>`tool ${e}`,kernelFields:{system_prompt:"system prompt template",max_turns:"max turns per task","model.max_tokens":"model max output tokens","model.thinking_level":"thinking level","model.timeoutMs":"request timeout","compaction.max_context_length":"compaction context threshold","compaction.max_session_turns":"compaction session-turn threshold","compaction.mode":"compaction mode","compaction.prompt":"compaction prompt","memory.enabled":"memory switch","memory.prompt":"memory prompt","memory.workspace_prompt":"workspace memory prompt","vault.enabled":"Vault section switch","vault.prompt":"Vault prompt","skills.enabled":"Skills section switch","skills.prompt":"Skills prompt","schedules.enabled":"Schedules section switch","schedules.prompt":"Schedules prompt"}},models:{title:"Models",addCustom:"Add custom model",addToGroup:"Add model",editTitle:"Model settings",addTitle:"Add model (OpenAI protocol)",addTitleVendor:"Add model",addProtocolHint:"New models use the OpenAI Chat Completions protocol; set the base URL to a compatible endpoint",vendorProtocolHint:e=>`Only ${e}'s official API protocol is supported; use a custom model group for OpenAI-compatible endpoints.`,autoRouteNone:"This id is not a recognized official model id: double-check it, or add the model under Custom / a user-defined group with an OpenAI-compatible endpoint",addGroup:"Add group",addGroupTitle:"Add group",addGroupDesc:"User-defined groups share Custom semantics: models use the OpenAI Chat Completions protocol (base URL required; an empty API key reads OPENAI_API_KEY). Groups live on model entries — the group appears once its first model is saved.",groupNameLabel:"Group name",groupNameHint:"Starts with a lowercase letter / digit; may contain - and _",groupNameInvalid:"Group names may only use lowercase letters, digits, - and _ (starting with a letter or digit), up to 32 characters",groupNameExists:"This name is taken by a built-in group or an existing entry",groupEmptyHint:"No models in this group yet; use “Add model” to create one",searchPlaceholder:"Search models: id / name / provider",noSearchResults:"No matching models",syncCatalog:"Sync presets",syncCatalogHint:"Update preset models from the built-in catalog: add missing entries and reset differing ones to the catalog's fields; locally added models and API keys are left untouched",syncDone:(e,t)=>`Presets synced: ${e} added, ${t} updated`,syncUpToDate:"Presets are already up to date",homepage:"Model page",speedTest:"Speed test",speedTestTitle:"Speed test",speedTestConfirm:e=>`This sends one real request to each of the ${e} models in this group, one at a time, to measure time-to-first-token (TTFT) and output rate (TPS). It consumes a small amount of API quota. Continue?`,speedTestStart:"Start",speedPending:"Testing…",speedFailed:"Test failed",ttftTitle:"Time to first token (TTFT)",tpsTitle:"Output rate (TPS)",modelCount:e=>`${e} model${e===1?"":"s"}`,modelId:"Model ID",modelIdHint:"The upstream API model id, e.g. gpt-5.5",displayName:"Display name",displayNameHint:"Defaults to the model ID",providerGroup:"Group",contextWindow:"Context window",tokenUnit:"Token",contextWindowHint:"Leave empty if unknown",maxTokens:"Max output tokens",maxTokensHint:"Empty = inherit agent setting",maxTokensTitle:"Caps output tokens per request; leave empty to inherit the agent setting — lower it for small-context models",maxTokensInvalid:"Must be a positive integer",clientTypeLocked:e=>`Protocol: ${e} (kept as configured; not editable)`,vision:"Vision support",visionOffProxyHint:"Images are read via the vision proxy model",visionBadge:"Vision",freeBadge:"Free",visionModelBadge:"Proxy vision",setVisionModel:"Set as proxy vision model",visionModelHint:"Describes images via describe_image for models without vision",priceUnitShort:"/M tok",testConnection:"Test connection",testing:"Testing…",testOk:e=>`Connected (${e} ms)`,testFailed:e=>`Failed: ${e}`,priceCacheRead:"Cache read price",priceCacheWrite:"Cache write price",priceOutput:"Output price",currency:"Currency",currencyUsd:"USD $",currencyCny:"CNY ¥",apiKey:"API key",apiKeyKeepHint:"Leave empty to keep the current key",apiKeyEnvHint:e=>`Leave empty to use the ${e} env var`,keyConfigured:"Key configured",clearApiKey:"Clear stored API key",baseUrl:"Custom base URL",baseUrlHint:"Leave empty to use the provider default",baseUrlSuffixTitle:"The client appends the grey protocol path to the base URL",baseUrlRequired:"A base URL is required",contextWindowDefaultHint:e=>`Defaults to ${e} if empty`,confirmDeleteTitle:"Delete model",confirmDelete:e=>`Delete "${e}"? Its configuration and API key will be removed.`,groupApiKey:"Set API key for group",groupApiKeyTitle:e=>`Set the API key for ${e}`,groupApiKeyHint:e=>`Applies to all ${e} models in this group; leave empty to keep them unchanged.`,getApiKey:"Get API key",getModelIds:"Get model IDs",groupKeyApplied:e=>`API key set for ${e} models`,providerEnvNotes:{zhipu:"Defaults to the Z.AI global endpoint (api.z.ai); keys from bigmodel.cn need base URL https://open.bigmodel.cn/api/paas/v4",moonshot:"Defaults to the China endpoint (api.moonshot.cn); keys from platform.kimi.com need base URL https://api.moonshot.ai/v1"},confirmVisionModelTitle:"Set as proxy vision model",confirmVisionModel:e=>`Make "${e}" the proxy vision model? Models without vision will read images through it via describe_image.`,confirmSaveTitle:"Save model settings",confirmSave:e=>`Save the changes to "${e}"?`,confirmDefaultTitle:"Set as default model",confirmDefault:e=>`Make "${e}" the default model? New sessions will use it by default.`,default:"Default",setDefault:"Set as default model",remove:"Delete model",readOnlyHint:"Members have read-only access; only owners can change models and credentials",empty:"No models configured yet",noKey:"No key",showModelsWithoutKey:e=>`Show model${e===1?"":"s"} without a key (${e})`,modelIdExists:"This model id already exists",pricingAllOrNone:"Fill all three prices",pricingInvalid:"Must be a number",contextWindowInvalid:"Must be a number"},memory:{desc:"Long-term memory across Sessions (stored in agent_state/memory/): the agent saves what is worth keeping as it works, and you can also just ask it to remember something. User memory applies to all of this agent's sessions; workspace memory is kept per workspace. Memory edits are made by the agent in chat. Turning the switch off only stops memory from being used and deletes nothing.",enable:"Enable memory",userScope:"User memory",templateMissing:"The prompt template has no {{MEMORY}} placeholder, so memory never enters the context.",insertPlaceholder:"Insert the {{MEMORY}} placeholder",insertPlaceholderDone:"Inserted",promptSection:"Memory prompt",promptSectionHint:"What the template's {{MEMORY}} placeholder expands to. The main prompt is injected into every session; the workspace addendum only in sessions with a persistent workspace.",promptLabel:"Main prompt",workspacePromptLabel:"Workspace addendum",promptPlaceholders:[["{{USER_MEMORY_INDEX}}","Content of the user MEMORY.md index (at most 200 lines and 25,000 characters total)"],["{{WORKSPACE_MEMORY_INDEX}}","Content of the workspace MEMORY.md index (at most 200 lines and 25,000 characters total); effective only in the workspace addendum"],["{{WORKSPACE_MEMORY_DIR}}","Absolute path of the current workspace's memory directory; effective only in the workspace addendum"]],insertToken:"Insert at the cursor",itemCount:e=>e===1?"1 item":`${e} items`,emptyScope:"No memories for this Workspace yet — the agent saves what is worth keeping as it works",emptyUserScope:'No user memories yet — say "remember …" in a chat and the agent will save it',add:"Add",addTitle:"Add memory",addWhy:"The agent organizes and saves memories in a chat: fill in the content, open a new conversation, and the agent does the rest.",addContentLabel:"Content or source to remember",addContentPlaceholder:"Paste the content to remember, or a file path / URL",addPromptLead:{user:"Please turn the following into memories in user memory:",workspace:"Please turn the following into memories in this workspace's memory:"},view:"View",edit:"Edit",editTitle:"Edit memory",editWhy:"Content edits are made by the agent in a chat: confirm the prompt to open a new conversation, and the agent updates the memory file and its MEMORY.md index together.",editRequirementLabel:"What to change",editRequirementPlaceholder:"Describe the change (optional — you can finish it in the chat)",editPromptLabel:"Prompt preview",editCopyPrompt:"Copy prompt",editCopied:"Copied",editOpenChat:"Open a new chat",delete:"Delete",deleteTitle:"Delete this memory?",deleteConfirm:e=>`This deletes "${e}" and removes its index line from MEMORY.md. This cannot be undone.`,deleteDone:"Deleted",editPromptLead:e=>`Please update a memory: ${e}`,editPromptTail:"What to change: "},vault:{desc:"Environment variables owned by this agent (stored in agent_state/.vault.toml), injected into the environment of its shell commands (exec_command); key names are shared with the model, values never enter the model context. Subagents use their own vaults and do not inherit this one. Saved changes take effect from the next task (a task already running is unaffected).",key:"Name",value:"Value",valueMasked:"Value (masked)",add:"Add",addTitle:"Add variable",remove:"Remove",deleteTitle:"Delete variable",deleteConfirm:e=>`Delete variable "${e}"? Its value cannot be recovered.`,overwriteTitle:"Overwrite existing variable",overwriteConfirm:e=>`"${e}" already exists — saving will overwrite its value, which cannot be recovered.`,empty:"No variables configured yet",readOnlyHint:"Members are read-only; only the owner can edit the vault",keyHint:"Letters, digits and underscores; must not start with a digit",keyInvalid:"Invalid name: only letters, digits and underscores, not starting with a digit",valueRequired:"Value must not be empty",injection:{enable:"Enable vault",templateMissing:"The prompt template has no {{VAULT}} placeholder, so the vault section never enters the context.",legacyTemplate:"The template still carries the legacy hardcoded # Vault section: one-click migration replaces it in place with the {{VAULT}} placeholder, wording unchanged, after which it is editable below.",insertPlaceholder:"Insert the {{VAULT}} placeholder",migrate:"Migrate to the {{VAULT}} placeholder",promptSection:"Vault prompt",promptSectionHint:"What the template's {{VAULT}} placeholder expands to; nothing is injected when the toggle is off or the template lacks the placeholder.",promptLabel:"Prompt",promptPlaceholders:[["{{VAULT_KEYS}}",'Vault key-name list (one "- KEY" line per key, names only — values are never injected; empty when no keys)']]}},schedule:{desc:"Scheduled tasks (agent_state/schedule/*.toml): the prompt is sent to the target Session on schedule; files can also be edited by hand, and changes made here take effect immediately.",readOnlyHint:"Members are read-only; only the owner can modify schedules",colStatus:"Status",colPeriod:"Period",colTarget:"Target",colFireTimes:"Next / last fired",colQueued:"Queue",statusNames:{active:"Active",disabled:"Disabled",expired:"Expired",done:"Done",missed:"Missed",invalid:"Invalid"},queued:"Queued",once:"One-off",newSession:"New session",invalidFiles:"Files that failed to parse (skipped by the scheduler)",empty:"No scheduled tasks yet",enable:"Enable",disable:"Disable",addTitle:"New scheduled task",editTitle:e=>`Edit scheduled task "${e}"`,nameHint:"The file name (without .toml); cannot be changed later",prompt:"Prompt",enabled:"Enabled",startAt:"Start at",endAt:"End at (optional)",period:"Period",periodPlaceholder:"30m / 12h / 7d; leave empty for a one-off task",target:"Target",targetNew:"New session each time",targetSession:"Bound Session",sessionId:"Session",chooseSession:"Choose a Session to bind",sessionSearch:"Search title or Session id…",sessionNoMatch:"No matching Session",sessionEmpty:"This agent has no Sessions yet",workspace:"Workspace (optional; a temporary workspace is created when empty)",model:"Model",modelDefault:"Project default",deleteTitle:"Delete scheduled task",deleteConfirm:e=>`Delete scheduled task "${e}"?`,injection:{enable:"Enable schedules",templateMissing:"The prompt template has no {{SCHEDULES}} placeholder, so the scheduled-tasks section never enters the context.",insertPlaceholder:"Insert the {{SCHEDULES}} placeholder",promptSection:"Schedules prompt",promptSectionHint:"What the template's {{SCHEDULES}} placeholder expands to — teaches the model to manage scheduled tasks with its file tools; nothing is injected when the toggle is off or the template lacks the placeholder.",promptLabel:"Prompt",promptPlaceholders:[["{{SCHEDULE_LIST}}",'Current task-name list (one "- name" line per task; an empty-roster note when none exist)']]}},skills:{pageTitle:"Skill library",pageDesc:"Built-in skill library: browse, quick-start a chat, or install to agents.",quickInvoke:"Quick start",quickInvokeText:e=>`use the ${e} skill`,quickInvokeNeedsInstall:"Install this skill on the current agent first to quick-start",manageInstall:"Manage installs",manageInstallTitle:e=>`Manage installs: ${e}`,install:"Install",installed:"Installed",uninstall:"Uninstall",skillCount:e=>e===1?"1 skill":`${e} skills`,usedByAgents:e=>e===0?"not used yet":e===1?"used by 1 agent":`used by ${e} agents`,installedToast:(e,t)=>`Installed ${e} to ${t}`,updateOutdated:e=>`Update available: update ${e} agent install(s)`,updateAction:"Update",updateConfirmTitle:e=>`Update ${e}`,updateConfirmWarning:e=>`Updating ${e} reinstalls the library copy over each agent's installed files — any local edits to the installed skill are lost. Export a backup first if you need them.`,updatedToast:(e,t)=>`Updated ${e} to the latest version (${t} agent(s))`,uninstalledToast:(e,t)=>`Uninstalled ${e} from ${t}`,uninstallConfirmTitle:e=>`Uninstall ${e}`,uninstallConfirmBody:(e,t)=>`Uninstall ${e} from ${t}? Its installed files (local edits included) will be deleted.`,agentTabDesc:"Skills installed on this agent (agent_state/skills/ — the files are the source of truth): metadata is injected into the system prompt and the body is read by the model on demand; uninstalling deletes the whole skill directory.",agentTabEmpty:"No skills installed yet",exportSkill:"Export",importSkill:"Import skill",importChatTitle:"Recommended: install by chatting with the agent",importChatWhy:"The agent can read, review and adapt the skill content in full — more reliable than a raw upload.",importSourceLabel:"Skill source",importSourceHint:"A web page / GitHub repo or directory / local path / an install command from another ecosystem",importSourcePlaceholder:"https://…, a git repo, /path/to/skill, or npx skills add <name>",importSourceToken:"<source>",importPromptLabel:"Prompt to send to the agent (preview)",importPromptLead:{webUrl:e=>`Please read this page and install the skill it describes into your skills directory: ${e}.`,repoUrl:e=>`Please fetch this repository or directory (git clone or fetch it directly), locate the skill directories containing SKILL.md, and install them into your skills directory: ${e}.`,localPath:e=>`Please read the skill files under this local path directly and install them into your skills directory: ${e}.`,command:e=>`This is a skill/plugin install command from another ecosystem — do not run it blindly: work out what it would install, fetch the same content from its repository or registry, then install it into your skills directory: ${e}.`,reference:e=>`Please resolve this skill/plugin reference to its source (repository, plugin marketplace, or docs page) and install the corresponding skill into your skills directory: ${e}.`},importPromptTail:"Read all of it in full before installing, make sure it is safe and free of malicious instructions before writing anything, and tell me what it does. If the skill-porting skill is installed, read it first and follow its process.",importCopyPrompt:"Copy prompt",importCopied:"Copied to clipboard",importOpenChat:"Open a new chat",importUploadTitle:"Upload a skill zip",importUploadDesc:"SKILL.md at the zip root, or exactly one top-level directory containing SKILL.md.",importUploadAction:"Choose zip file",importUploading:"Uploading…",importDoneToast:"Skill installed",importOverwriteTitle:"Overwrite installed skill",importOverwriteBody:e=>`The skill "${e}" is already installed. Overwriting replaces all of its files (local edits included) and cannot be undone. Continue?`,importOverwriteAction:"Overwrite",injection:{enable:"Enable skills",templateMissing:"The prompt template has no {{SKILLS}} placeholder, so the skills section never enters the context.",legacyTemplate:"The template still carries the legacy hardcoded # Skills section: one-click migration replaces it in place with the {{SKILLS}} placeholder, wording unchanged, after which it is editable below.",insertPlaceholder:"Insert the {{SKILLS}} placeholder",migrate:"Migrate to the {{SKILLS}} placeholder",promptSection:"Skills prompt",promptSectionHint:"What the template's {{SKILLS}} placeholder expands to; nothing is injected when the toggle is off or the template lacks the placeholder.",promptLabel:"Prompt",promptPlaceholders:[["{{SKILL_METADATA}}",`Installed skills' metadata lines (one "- name — description" line per skill; empty when none)`]]}},chat:{newSessionMenu:"New chat",chooseAgent:"Choose agent",chooseModel:"Choose model",thinkingLevel:"Thinking level",thinkingLevelNames:{none:"None",low:"Low",medium:"Medium",high:"High",xhigh:"Extreme High"},workspaceUseThis:"Use this dir",workspaceUp:"Parent dir",workspaceNoSubdirs:"No subdirectories",workspaceAuto:"Temporary workspace",workspaceClear:"Use a temporary workspace instead",workspaceDirInvalid:"Directory does not exist or is inaccessible; reverted",groupByWorkspace:"Group by workspace",groupByAgent:"Group by agent",tempWorkspaces:"Temporary workspaces",newSessionInWorkspace:"New chat in this workspace",draftSubtitle:"The self-evolving agent that excels at AI development tasks",exampleFolders:{webapps:"Build web apps",agents:"Build and optimize agents"},exampleTasks:{game:{label:"2D penguin sled game",desc:"A cute Antarctic penguin sleds over rocks, easy start with a gentle difficulty ramp — a 2D pure-frontend mini game",prompt:"Build a cute Antarctic penguin sledding 2D game: press Space to jump over the rocks coming up on the ice; start easy and forgiving, with sled speed and obstacle density ramping up smoothly and gradually over time (no sudden spikes), live scoring, and hitting a rock ending the run with one-click restart. A 2D side-scroller with a cute cartoon look, pure frontend (a single HTML file is fine), styled per the web-design skill. When done, test it in a browser once, confirm the first few seconds are easy to clear, and tell me how to open it and how to play."},gamecenter:{label:"A mini-game center built by multiple agents",desc:"Ten pure-frontend games with no repeated mechanics, built in parallel behind one index page",prompt:`Build a web mini-game center with multiple agents working in parallel: 10 pure-frontend games with no two sharing the same mechanic, plus an index page.
68
-
69
- ## How to split the work
70
- - First plan the 10 games (say snake, 2048, tetris, breakout, minesweeper, memory match, sokoban, space shooter, platform jumper, rhythm tap), confirm no two mechanics repeat, and fix a shared directory layout, palette and interaction spec.
71
- - Then hand the 10 games to several subagents to implement in parallel — each subagent owns exactly one game, follows the agreed spec, and never edits another's files.
72
-
73
- ## Each game
74
- - Its own \`games/<slug>/index.html\`: pure frontend, a single file that runs straight from file://, with no backend and no CDN assets.
75
- - Start / restart, live score or timer, a lose-or-clear summary, both keyboard and touch controls, and the rules written on the page.
76
- - A way back to the index page.
77
-
78
- ## Index page
79
- - \`index.html\` at the root: a card grid listing all 10 games (name + one-line mechanic + controls), each card opening its game.
80
- - One design language shared with every game, following the web-design skill.
81
-
82
- ## Wrap-up
83
- - Review as a whole: the 10 mechanics really are distinct, the styling is consistent, and every index link resolves.
84
- - Self-test each game in a browser — it starts, it ends, it restarts — then tell me how to open it.`},lol:{label:"League of Legends music player",desc:"Worlds anthems on the SoundCloud Widget API — a single file that opens from file://",prompt:`Build a League of Legends Worlds anthem player with the SoundCloud Widget API (see https://developers.soundcloud.com/docs/api/html5-widget): a single index.html that works when opened from file://.
85
-
86
- ## Technical constraints
87
- - Use the SC.Widget JS API (widget.load / widget.toggle / widget.setVolume / widget.seekTo), loading https://w.soundcloud.com/player/api.js
88
- - The iframe must stay visible (180px tall), with visual=true color=f0b90b single_active=true
89
- - Include ONLY these 8 tracks confirmed playable (oEmbed-verified); do not add tracks that are not oEmbed-verified:
90
- - Warriors (S4) — soundcloud.com/leagueoflegends/warriors
91
- - Worlds Collide (S5) — soundcloud.com/leagueoflegends/worlds-collide
92
- - Legends Never Die (S7) — soundcloud.com/leagueoflegends/legends-never-die
93
- - Phoenix (S9) — soundcloud.com/leagueoflegends/phoenix
94
- - Burn It All Down (S11) — soundcloud.com/leagueoflegends/burn-it-all-down
95
- - GODS (S13) — soundcloud.com/leagueoflegends/gods
96
- - Heavy Is The Crown (S14) — soundcloud.com/linkinpark/heavy-is-the-crown
97
- - Sacrifice (S15) — soundcloud.com/leagueoflegends/sacrifice
98
-
99
- ## Layout
100
- - Left 260px sticky sidebar: the track list (S4/S5/… badge + emoji + title + year); clicking highlights with a gold border and switches tracks via SC.Widget.load() with auto_play
101
- - Right main area: hero title + a desktop clock (80px monospace gold HH:MM:SS, refreshed every second, blinking colons) + a mood tag
102
- - Player card: the SoundCloud iframe + a custom control bar (⏮ ▶/⏸ ⏭ + track info + a volume slider; clicking the speaker icon toggles mute)
103
- - Mood-wave section: 15 gold animated bars, re-randomized on every track switch
104
- - Keyboard shortcuts: Space play/pause, ← → previous/next, ↑ ↓ volume
105
-
106
- ## Design
107
- Penguin visual style (see the web-design skill), dark by default. On phones the sidebar becomes a horizontally scrolling top bar.
108
-
109
- When done, open index.html in a browser and self-test once.`},rag:{label:"Build a Claude Code docs RAG agent",desc:"Collect the claude-code-docs repo into a conversational RAG knowledge app with source citations",prompt:"Collect the docs from https://github.com/ericbuess/claude-code-docs and build a RAG knowledge app: clone the repo and prepare the corpus, then build a retrieval index; the app acts as a Claude Code configuration expert, answering Claude Code questions with retrieval-augmented replies and clickable citations that reveal the matched original text chunk and link to the real documents; give it a beautiful web chat UI following the web-design skill. When done, run the app and self-test one Chinese question and one English question, confirming both retrieve the right English documents and stream their answers, then tell me how to access it."},agentBenchmarkBuild:{label:"Build a general-purpose decision agent and its benchmark",desc:"Create a general decision Agent and test it on football, after-sales, and investment tasks",prompt:`Use \`agent-creation\` followed by \`benchmark-design\` to create a decision Agent and produce a frozen Benchmark with a Formal Baseline.
110
-
111
- Agent:
112
- - id: \`finite_choice_agent\`
113
- - capability: make stable, explainable finite choices when public information is incomplete or conflicting
114
- - installed_skills: \`[]\`
115
-
116
- Benchmark:
117
- - id: \`contextual-choice-adaptation\`
118
- - capability: form and transfer a stable finite-choice decision process from public rules, historical examples, and current facts
119
- - desired_baseline_score: \`<75\`
120
- - pilot_iteration_limit: \`5\`
121
-
122
- Scenarios:
123
- 1. Make football betting decisions from historical matches and current information.
124
- 2. Choose after-sales actions from policy and ticket facts.
125
- 3. Choose investment actions from a strategy, historical markets, and current indicators.`},agentOptimization:{label:"Improve the general-purpose decision agent's accuracy",desc:"Improve an Agent from existing evaluation results and verify that the new version is better",prompt:"Use `agent-optimization` to optimize a decision Agent against its frozen Benchmark.\n\n- test_agent_id: `finite_choice_agent`\n- benchmark_id: `contextual-choice-adaptation`\n- capability_direction: improve stability under incomplete information, conflicting rules, and finite choices\n- runs: `3`\n- desired_score: `>=95`\n- candidate_round_limit: `5`"}},sessionList:"Sessions",defaultSessionTitle:"New chat",model:"Model",workspace:"Workspace",workspaceHint:"Leave empty for an auto-created temporary workspace; if set, it must be an existing directory on the server",approvalMode:"Approval mode",approvalModeNames:{"allow-all":"Approve everything","deny-all":"Deny everything","read-only":"Approve read-only","always-ask":"Ask every time"},approvalModes:{"allow-all":"Approve everything (allow-all)","deny-all":"Deny everything (deny-all)","read-only":"Approve read-only (read-only)","always-ask":"Ask every time (always-ask)"},statusRunning:"Running",statusCompacting:"Compacting",pendingApprovals:e=>`${e} pending approval${e>1?"s":""}`,jumpToLatest:"Jump to latest",loadingEarlier:"Loading earlier messages…",loadEarlierRetry:"Failed to load earlier messages — click to retry",historyBeginning:"Beginning of conversation",outlineTitle:"Outline",outlineTickLabel:(e,t)=>`Turn ${e}: ${t}`,outlineNoText:"(image or attachment)",outlineAnswering:"Answering…",inputPlaceholder:"Type a message. Enter to send, Shift+Enter for newline, paste images",inputPlaceholderShort:"Type a message…",steerPlaceholder:"Message the running agent — delivered with the next turn",steerPlaceholderShort:"Message the running agent…",steerSend:"Send to the running agent",steerQueuedIndicator:"Steering queued — delivered with the next turn",steerQueuedItem:e=>`Steering queued — delivered with the next turn: ${e}`,userSteering:"User steering",steerModeLabel:"Mid-run send mode",steerModeSteer:"Steer",steerModeSteerHint:"Steer now: delivered to the running agent with the next turn",steerModeFollowUp:"Queue",steerModeFollowUpHint:"Queue a follow-up: sent automatically as a new message when this run finishes",followUpPlaceholder:"Queue as the next message — sent automatically when this run finishes",followUpPlaceholderShort:"Queue as the next message…",followUpSend:"Queue as the next message",followUpQueuedChip:e=>`${e} follow-up ${e===1?"message":"messages"} queued — sent when this run finishes`,send:"Send",stop:"Stop",compact:"Compact context",approve:"Allow",deny:"Deny",decisionAllow:"Approved",decisionDeny:"Denied",decisionManual:"manual",decisionAuto:"auto",thinking:"Thinking",subagent:"Subagent",subagentRunning:"Running",aborted:e=>`[Aborted]${e?`: ${e}`:""}`,modelAuthDead:"Model API authentication failed: update this model's API key on the Models page, or start a new Session.",modelAuthDeadOpenModels:"Open Models page",modelAuthDeadRetry:"Retry",modelAuthDeadCta:"New Session",modelAuthDeadPlaceholder:"Model authentication failed — update the API key first",reconnect:(e,t,a,l)=>{const o=e==="timeout"?"Connection timed out":e==="malformed"?"Response incomplete or unparseable":"The model provider returned an error",c=t==="gaveUp"?"no further retries":t==="retried"?`retry #${a} sent`:l!==void 0?`retry #${a} in ${l}s…`:`starting retry #${a}…`;return`[Retry] ${o}; ${c}`},reconnectRetryNow:"Retry now",reconnectGiveUp:"Give up",imageAlt:"Image uploaded by user",toolImageAlt:"Image from tool output",imagesAsPathHint:"This model cannot view images directly: on send, images are saved to the session scratchpad and passed as file paths (viewed via describe_image)",infoPanel:"Session info",sessionStats:"Stats",sessionIdLabel:"Session id",copySessionId:"Copy Session id",traceFile:"Trace file",processList:"Processes",processStop:"Stop",processExited:"exited",runningServices:e=>e===1?"1 running service":`${e} running services`,statTokens:"Total Tokens",statTotalTokens:"Total Tokens",statCacheHit:e=>`cache hit rate ${e}`,statElapsed:"Elapsed",statInput:"Input tokens",statCached:"cached",statOutput:"Output tokens",statTps:"Output TPS",statParenOpen:" (",statParenClose:")",noSessions:"No Sessions yet",emptyStream:"Send a message to start the conversation",historyLoadFailed:"Failed to load history",statsLabel:"Stats",removeImage:"Remove image",openWorkspace:"Open workspace",openAgents:"Agents panel",filesInMessage:e=>`${e} ${e===1?"file":"files"}`,imagesInMessage:e=>`${e} ${e===1?"image":"images"}`,openPreview:"Click to preview",showMoreFiles:e=>`Show ${e} more ${e===1?"file":"files"}`,showLess:"Show less",moreGroups:e=>`More groups (${e})`,contextUsage:"Context usage",contextUnknown:"Context usage: unknown until the next request reports it",slashHint:"Type / for commands",switchAgent:"Hand off to another agent — opens a new session on send",switchAgentTitle:"Choose agent",agentSearchPlaceholder:"Search agents: id / name",agentsNoMatch:"No matching agents",handoffTargetTitle:e=>`Sending hands this conversation to ${e}`,handoffRemove:"Remove handoff target",skillsSelect:"Skills",skillRemove:"Remove skill",skillsSearchPlaceholder:"Search skills",skillsNoMatch:"No matching skills",skillsEmptyHint:"No skills installed yet — add some from the skill library",skillsAutoMessage:e=>e.length===1?`use the ${e[0]} skill`:`use the ${e.join(", ")} skills`,handoffFrom:e=>`Handed off from ${e}'s conversation`,handoffBack:e=>e?`Back to the original conversation: ${e}`:"Back to the original conversation",switchModel:"Switch model — on send, continues this conversation in a new session",switchModelTitle:"Switch model",modelSwitchTargetTitle:e=>`Sending continues this conversation on ${e}`,modelSwitchRemove:"Remove model switch",modelSwitchBusyHint:"The model switch waits for this turn to finish: the new session continues from this session's record",modelSwitchFrom:e=>e?`Switched model (was ${e}) — continued from the earlier conversation`:"Switched model — continued from the earlier conversation",modelSwitchAutoMessage:"Continue this conversation on the new model",modelLockedHint:"Type /model to switch models",scheduledFrom:e=>`Triggered by scheduled task "${e}"`,emptyGreeting:"Start a new conversation",mcpConnectTitle:"MCP connect",mcpServerList:e=>e.join(", "),mcpConnectResult:(e,t)=>{const a=[];return(e>0||t.length===0)&&a.push(`${e} tool${e===1?"":"s"} discovered`),t.length>0&&a.push(`unavailable: ${t.join(", ")}`),a.join("; ")},mcpToolsCount:e=>`${e} tool${e===1?"":"s"}`,mcpServerFailed:"connection failed",mcpConnectAborted:"interrupted — reconnects on the next send",compactionTitle:"Compaction",compactionDone:e=>e==="discard"?"old context discarded":"switched to the summarized context",compactionFailed:(e,t)=>e==="aborted"?"aborted, keeping current context":t!==void 0?`failed (${t}), keeping current context`:"failed, keeping current context",unknownTool:"(unknown tool)",workRunning:"Running",workDone:"Done",workGroupSteps:e=>`${e} ${e===1?"step":"steps"}`,approvalWaiting:"awaiting approval",copyCode:"Copy code",copyReply:"Copy reply",copyMessage:"Copy message",deleteSession:"Delete chat",renameSession:"Rename chat",renameSessionLabel:"Title",deleteSessionConfirm:e=>`Delete "${e}"? Its messages and Trace will be removed permanently.`,draftGroup:"Drafts",draftUntitled:"(untitled draft)",deleteDraft:"Delete draft",deleteDraftConfirm:e=>`Delete draft "${e}"? Unsent content will be discarded.`,archiveSession:"Archive",unarchiveSession:"Unarchive",loadMore:"More",folderGroups:{subagent:e=>`Subagents (${e})`,schedule:e=>`Scheduled (${e})`,archived:e=>`Archived (${e})`},skillsBanner:e=>`Using skill${e.length===1?"":"s"}: ${e.join(", ")}`,attachedFilesBanner:e=>`Attached file${e.length===1?"":"s"}: ${e.join(", ")}`,plusMenu:"More input options",uploadImage:"Upload image",uploadImageDesc:"Attach images to this message",uploadFile:"Upload file",uploadFileDesc:"Saved to the session scratchpad; the model reads them by path",removeFile:"Remove file",attachmentTooLarge:e=>`${e} exceeds the 10MB limit and was not attached.`,goalMode:"Goal mode",goalModeDesc:"Loop until the goal completes",goalBudgetLabel:"Token budget",goalBudgetUnlimited:"Budget unlimited",goalBudgetValue:e=>`Budget ${e}`,goalBudgetPlaceholder:"e.g. 500k",goalBudgetHint:"Use a k/m suffix; leave blank for no budget limit",goalBudgetInvalid:"Invalid budget: use a positive number with an optional k/m suffix (500k, 2m)",goalBudgetSave:"Save budget",goalRemove:"Exit goal mode",goalRoundBanner:e=>`Goal · round ${e}`,goalRoundImages:e=>e===1?"1 attached image":`${e} attached images`,goalProgress:(e,t)=>`round ${e} · tokens ${t}`,goalStatus:{active:"running",complete:"complete",blocked:"blocked",budget_limited:"budget exhausted",aborted:"interrupted"}},subagentPanel:{title:"Agents panel",topologyLabel:"Call graph",mainSessionNote:"The main conversation stays in the chat area",empty:"No subagents in the current task yet",nodeRunning:"running",nodeDone:"done"},files:{title:"Files",upload:"Upload",download:"Download",openInNewTab:"Open in new tab",previewNotIsolatedHint:"This address has no separate preview origin, so the page opens sandboxed: localStorage, cookies and third-party embeds will not work. Reach the app over 127.0.0.1 or localhost, or set PENGUIN_PREVIEW_ORIGIN.",refresh:"Refresh",root:"Workspace root",empty:"Empty directory",previewUnsupported:"Preview not supported for this type; download instead",uploaded:"Uploaded",overwriteTitle:"Overwrite existing files",overwriteConfirm:e=>`The current directory already has ${e} file(s) with these names — uploading will overwrite:`,loadFailed:"Failed to load",previewTruncated:"File too large; preview truncated, download for the full file",details:"Details",workspacePath:"Workspace path",htmlRendered:"Rendered",htmlSource:"Source",backToList:"Back to list",resizeHandle:"Drag to resize, double-click to reset"},usage:{title:"Costs & usage",today:"Today",last7d:"Last 7 days",total:"Total",tokens:"Tokens",requests:"Requests",from:"From",to:"To",colCacheRead:"cache_read",colCacheWrite:"cache_write",colOutput:"output",uncostedNote:"* Only models with configured pricing count toward cost",filterAllAgents:"All agents",filterAllModels:"All models",chartAgentCalls:"Calls per agent",chartSuccessRate:"Model success rate",chartTokenTrend:"Daily token trend",chartCostTrend:"Daily cost trend",empty:"No usage records",successAborted:"Aborted (excluded)",errors:"Errors",errorsTotal:"Total",errorsUnexpected:"Unexpected",errorsExpected:"Expected",errorsTopCode:"Most common",errorsColCode:"Source · code",errorsColKind:"Type",errorsColMessage:"Message",errorsEmpty:"No errors",errorsNewer:"Newer",errorsOlder:"Older",errorsPageOf:(e,t,a)=>`Page ${e} / ${t} · ${a} total`},traces:{title:"Traces",timeline:"Execution timeline",laneLLM:"Model",kindThinking:"thinking",kindModelReply:"model reply",kindToolGen:"tool call gen",legendToolExec:"tool exec",legendOther:"Other",toolParams:"Parameter schema",legendApprovalWait:"approval wait",task:e=>`Turn ${e}`,globalSummary:"Overall",tasksLabel:"Turns",messages:"Messages",truncatedNote:(e,t)=>`Showing first ${e} / ${t} messages`,zoom:"Zoom",zoomReset:"Double-click to reset zoom",zoomOut:"Zoom out",zoomIn:"Zoom in",linkHint:"Hover a timeline segment or event row to cross-highlight, click a segment to jump to its message; legend highlights its kind; drag the bar below to pan/zoom",filesTitle:"Trace files",selectSession:"Select a Session on the left",toolCalls:"Tool calls",taskInput:"Input tokens this turn",taskOutput:"Output tokens this turn",cacheHit:"Cache hits",hitRate:"Hit rate",compactions:"compactions",compactionRound:"Compaction",empty:"No Traces for this agent",inProgress:"in progress",systemPrompt:"System prompt",toolDefs:e=>`Tool definitions (${e})`,exportFile:"Export",importTrace:"Import Trace",importAgent:"Import into Agent",importPickFile:"Choose file",importing:"Importing…",fileTooLarge:"The file exceeds the 14MB limit."},benchmark:{title:"Evaluation Center",selectBenchmark:"Select a Benchmark on the left",emptyAgent:"No Benchmarks for this agent",caseCount:e=>`${e} case${e===1?"":"s"}`,trendTitle:e=>`${e} over time`,cases:"Cases",viewCase:"View details",taskMaterials:"Task materials",rubric:"Scoring rubric",agentHidden:"Hidden from Target Agent",caseFileUnavailable:"Case files are unavailable",evaluations:"Evaluations",noEvaluations:"No evaluations yet",summaryLabel:"Summary",legendUnlabeled:"unlabeled model",colVersion:"Version",colModel:"Model ID",colThinkingLevel:"Thinking level",colScore:"Score",colDuration:"Duration",colCase:"Case",colRun:"Run",colSession:"Session"},errors:{networkError:"Network error, please check your connection",modelCredentialMissing:e=>`Model ${e} has no API key yet — configure it on the Models page first`,noDefaultModel:"This project has no default model yet — add one on the Models page first",byCode:{invalid_credentials:"Incorrect username or password.",too_many_attempts:"Too many failed sign-in attempts. Try again shortly.",password_mismatch:"The current password is incorrect.",invalid_password:"Password must be at least 8 characters.",admin_required:"Only an admin can perform this operation.",desktop_single_user:"The desktop app is single-user; user management is unavailable.",not_found:"This resource does not exist, or you do not have access.",agent_not_found:"This agent no longer exists.",unknown_agent:"That agent does not exist in this Project.",agent_exists:"This agent id is already taken.",project_exists:"This Project id is already taken.",user_exists:"This username is already taken.",user_not_found:"This user no longer exists.",cannot_delete_admin:"The built-in admin cannot be deleted.",member_not_found:"This user is not a member of the Project.",schedule_exists:"A scheduled task with this name already exists.",schedule_not_found:"This scheduled task no longer exists.",unknown_skill:"This skill is not in the library.",file_not_found:"This file no longer exists.",file_too_large:"The file is too large.",too_many_files:"Too many files attached to one message.",payload_too_large:"The request is too large.",dir_not_absolute:"The directory must be an absolute path.",dir_not_found:"That directory does not exist or is inaccessible.",not_a_dir:"That path is not a directory.",path_not_found:"That path does not exist.",workspace_missing:"This Session's Workspace no longer exists.",task_in_progress:"This Session already has a task running.",version_conflict:"The snapshot's version is not newer than the current one.",invalid_title:"The title is invalid.",invalid_proxy_url:"Invalid proxy address — use http://host[:port], https://host[:port], or host[:port].",invalid_trace:"This file is not a valid Trace file.",trace_session_exists:"This agent already has a Session with that id; a duplicate Trace cannot be imported."}}},bk="penguin.lang",kk=y.createContext(null);function yC(e){return e?.toLowerCase().startsWith("zh")?"zh":"en"}function vC(){return yC(navigator.language)}function bC(e){return e==="system"?vC():e}function kC(){const e=localStorage.getItem(bk);return e==="zh"||e==="en"||e==="system"?e:"system"}function wC({children:e}){const[t,a]=y.useState(kC),[,l]=y.useState(0),o=bC(t);gC(o==="en"?xC:vk),y.useEffect(()=>{if(t!=="system")return;const u=()=>l(f=>f+1);return window.addEventListener("languagechange",u),()=>window.removeEventListener("languagechange",u)},[t]);const c=y.useCallback(u=>{localStorage.setItem(bk,u),a(u)},[]);return s.jsx(kk.Provider,{value:{lang:t,locale:o,setLang:c},children:e})}function SC({children:e}){const{locale:t}=La();return s.jsx("div",{className:"contents",children:e},t)}function La(){const e=y.useContext(kk);if(!e)throw new Error("useLocale must be used within a LocaleProvider");return e}const $h=7,wk="penguin.theme",Sk="penguin.fontScale",jk="penguin.accent",Ck="penguin.currency",jC={sm:"16px",md:"18px",lg:"20px"},Nk=y.createContext(null);function CC(){const e=localStorage.getItem(wk);return e==="light"||e==="dark"||e==="system"?e:"system"}function NC(){const e=localStorage.getItem(Sk);return e==="sm"||e==="md"||e==="lg"?e:"md"}function TC(){const e=localStorage.getItem(jk);return e==="neutral"||e==="blue"||e==="green"||e==="violet"||e==="rose"||e==="amber"?e:"neutral"}function MC(){return localStorage.getItem(Ck)==="CNY"?"CNY":"USD"}function EC(){return window.matchMedia("(prefers-color-scheme: dark)").matches}function AC({children:e}){const[t,a]=y.useState(CC),[l,o]=y.useState(EC),[c,u]=y.useState(NC),[f,p]=y.useState(TC),[h,g]=y.useState(MC),v=t==="system"?l:t==="dark";y.useEffect(()=>{document.documentElement.classList.toggle("dark",v)},[v]),y.useEffect(()=>{document.documentElement.style.fontSize=jC[c]},[c]),y.useEffect(()=>{f==="neutral"?delete document.documentElement.dataset.accent:document.documentElement.dataset.accent=f},[f]),y.useEffect(()=>{if(t!=="system")return;const C=window.matchMedia("(prefers-color-scheme: dark)"),M=_=>o(_.matches);return o(C.matches),C.addEventListener("change",M),()=>C.removeEventListener("change",M)},[t]);const k=y.useCallback(C=>{localStorage.setItem(wk,C),a(C)},[]),w=y.useCallback(C=>{localStorage.setItem(Sk,C),u(C)},[]),j=y.useCallback(C=>{localStorage.setItem(jk,C),p(C)},[]),E=y.useCallback(C=>{localStorage.setItem(Ck,C),g(C)},[]);return s.jsx(Nk.Provider,{value:{mode:t,dark:v,setMode:k,fontScale:c,setFontScale:w,accent:f,setAccent:j,currency:h,setCurrency:E},children:e})}function Ps(){const e=y.useContext(Nk);if(!e)throw new Error("useTheme must be used within a ThemeProvider");return e}const RC=[{value:"neutral",color:"#6b7280"},{value:"blue",color:"#2563eb"},{value:"green",color:"#15803d"},{value:"violet",color:"#7c3aed"},{value:"rose",color:"#be123c"},{value:"amber",color:"#b45309"}];class na extends Error{status;code;constructor(t,a,l){super(l),this.name="ApiError",this.status=t,this.code=a}}let Tk=null;function _v(e){Tk=e}function _C(e){return e.startsWith("/api/auth/")}async function Ee(e,t={}){return(await Mk(e,t)).data}async function Mk(e,t={}){let a=e;if(t.query){const f=new URLSearchParams;for(const[h,g]of Object.entries(t.query))g!==void 0&&f.set(h,String(g));const p=f.toString();p&&(a+=`?${p}`)}let l;try{l=await fetch(a,{method:t.method??"GET",credentials:"same-origin",...t.body!==void 0?{headers:{"Content-Type":"application/json"},body:JSON.stringify(t.body)}:{}})}catch{throw new na(0,"network_error",m.errors.networkError)}if(!l.ok){let f="http_error",p=m.common.unknownError;try{const h=await l.json();h.error?.code&&(f=h.error.code),h.error?.message&&(p=h.error.message)}catch{}throw l.status===401&&!_C(e)&&Tk?.(),new na(l.status,f,p)}const o=Date.parse(l.headers.get("date")??""),c=Number.isFinite(o)?o:null;if(l.status===204)return{data:void 0,serverNowMs:c};const u=await l.text();return u?{data:JSON.parse(u),serverNowMs:c}:{data:void 0,serverNowMs:c}}const IC=e=>Ee("/api/auth/login",{method:"POST",body:e}),LC=()=>Ee("/api/auth/logout",{method:"POST",body:{}}),Yu=()=>Ee("/api/me"),OC=e=>Ee("/api/me/password",{method:"PUT",body:e}),Ph=()=>Ee("/api/me/prefs"),jd=e=>Ee("/api/me/prefs",{method:"PUT",body:e}),DC=()=>Ee("/api/admin/users"),zC=e=>Ee("/api/admin/users",{method:"POST",body:e}),UC=(e,t)=>Ee(`/api/admin/users/${encodeURIComponent(e)}/password`,{method:"POST",body:t}),$C=e=>Ee(`/api/admin/users/${encodeURIComponent(e)}`,{method:"DELETE"}),PC=()=>Ee("/api/admin/settings"),BC=e=>Ee("/api/admin/settings",{method:"PUT",body:e}),HC=()=>Ee("/api/projects"),FC=e=>Ee("/api/projects",{method:"POST",body:e}),qC=(e,t)=>Ee(`/api/projects/${encodeURIComponent(e)}`,{method:"PATCH",body:t}),VC=e=>Ee(`/api/projects/${encodeURIComponent(e)}`,{method:"DELETE"}),Jm=e=>Ee(`/api/projects/${encodeURIComponent(e)}/members`),GC=(e,t)=>Ee(`/api/projects/${encodeURIComponent(e)}/members`,{method:"POST",body:t}),WC=(e,t)=>Ee(`/api/projects/${encodeURIComponent(e)}/members/${encodeURIComponent(t)}`,{method:"DELETE"}),Ek=e=>Ee(`/api/projects/${encodeURIComponent(e)}/chat-defaults`),KC=(e,t)=>Ee(`/api/projects/${encodeURIComponent(e)}/chat-defaults`,{method:"PUT",body:t}),mi=e=>Ee(`/api/projects/${encodeURIComponent(e)}/models`),YC=(e,t)=>Ee(`/api/projects/${encodeURIComponent(e)}/models`,{method:"PUT",body:t}),QC=(e,t)=>Ee(`/api/projects/${encodeURIComponent(e)}/models/default`,{method:"PUT",body:t}),Ak=(e,t)=>Ee(`/api/projects/${encodeURIComponent(e)}/models/test`,{method:"POST",body:t}),XC=(e,t)=>Ee(`/api/projects/${encodeURIComponent(e)}/agents/${encodeURIComponent(t)}/vault`),ZC=(e,t,a)=>Ee(`/api/projects/${encodeURIComponent(e)}/agents/${encodeURIComponent(t)}/vault`,{method:"PUT",body:a}),JC=(e,t)=>Ee(`/api/projects/${encodeURIComponent(e)}/agents/${encodeURIComponent(t)}/vault/template-placeholder`,{method:"POST",body:{}}),eN=(e,t)=>Ee(`/api/projects/${encodeURIComponent(e)}/agents/${encodeURIComponent(t)}/skills/template-placeholder`,{method:"POST",body:{}}),tN=(e,t)=>Ee(`/api/projects/${encodeURIComponent(e)}/agents/${encodeURIComponent(t)}/schedules/template-placeholder`,{method:"POST",body:{}}),Bh=(e,t)=>`/api/projects/${encodeURIComponent(e)}/agents/${encodeURIComponent(t)}/memory`,Hh=(e,t,a)=>`${Bh(e,t)}/scopes/${encodeURIComponent(a)}/files`,nN=(e,t)=>Ee(Bh(e,t)),aN=(e,t)=>Ee(`${Bh(e,t)}/template-placeholder`,{method:"POST",body:{}}),rN=(e,t,a)=>Ee(Hh(e,t,a)),sN=(e,t,a,l)=>Ee(`${Hh(e,t,a)}/${encodeURIComponent(l)}`),lN=(e,t,a,l)=>Ee(`${Hh(e,t,a)}/${encodeURIComponent(l)}`,{method:"DELETE"}),iN=e=>Ee(`/api/projects/${encodeURIComponent(e)}/agents`),oN=(e,t)=>Ee(`/api/projects/${encodeURIComponent(e)}/agents`,{method:"POST",body:t}),jl=(e,t)=>Ee(`/api/projects/${encodeURIComponent(e)}/agents/${encodeURIComponent(t)}/config`),kl=(e,t,a)=>Ee(`/api/projects/${encodeURIComponent(e)}/agents/${encodeURIComponent(t)}/config`,{method:"PUT",body:a}),Iv=(e,t,a)=>Ee(`/api/projects/${encodeURIComponent(e)}/agents/${encodeURIComponent(t)}/config/mcp-test`,{method:"POST",body:a}),cN=(e,t)=>Ee(`/api/projects/${encodeURIComponent(e)}/agents/${encodeURIComponent(t)}/config/reset`,{method:"POST"}),uN=(e,t)=>Ee(`/api/projects/${encodeURIComponent(e)}/agents/${encodeURIComponent(t)}/config/kernel-update`,{method:"POST"}),Rk=(e,t,a)=>Ee(`/api/projects/${encodeURIComponent(e)}/agents/${encodeURIComponent(t)}/traces${a?`?limit=${a.limit}&offset=${a.offset}`+(a.category?`&category=${a.category}`:"")+(a.cli?"&cli=1":""):""}`),Fp=(e,t,a)=>{const l=a?`?limit=${a.limit}&offset=${a.offset}`+(a.category?`&category=${a.category}`:"")+(a.withCounts?"&counts=1":"")+(a.cli?"&cli=1":""):"";return Ee(`/api/projects/${encodeURIComponent(e)}/agents/${encodeURIComponent(t)}/sessions${l}`)},dN=(e,t="")=>Ee(`/api/projects/${encodeURIComponent(e)}/dirs?path=${encodeURIComponent(t)}`),qp=(e,t,a)=>Ee(`/api/projects/${encodeURIComponent(e)}/agents/${encodeURIComponent(t)}/sessions`,{method:"POST",body:a}),ep=e=>Ee(`/api/sessions/${encodeURIComponent(e)}`),Vp=(e,t)=>Ee(`/api/sessions/${encodeURIComponent(e)}`,{method:"PATCH",body:t}),td=e=>Ee(`/api/sessions/${encodeURIComponent(e)}`,{method:"DELETE"}),fN=(e,t)=>{const a=t===void 0?"":t.kind==="tail"?`?tailLimit=${t.limit}`:`?before=${encodeURIComponent(t.cursor)}&limit=${t.limit}`;return Mk(`/api/sessions/${encodeURIComponent(e)}/messages${a}`).then(({data:l,serverNowMs:o})=>({...l,serverNowMs:o}))},Io=(e,t)=>Ee(`/api/sessions/${encodeURIComponent(e)}/tasks`,{method:"POST",body:t}),mN=e=>Ee(`/api/sessions/${encodeURIComponent(e)}/goal`),pN=(e,t,a)=>Ee(`/api/sessions/${encodeURIComponent(e)}/approvals/${encodeURIComponent(t)}`,{method:"POST",body:a}),hN=e=>Ee(`/api/sessions/${encodeURIComponent(e)}/abort`,{method:"POST",body:{}}),gN=e=>Ee(`/api/sessions/${encodeURIComponent(e)}/retry-now`,{method:"POST",body:{}}),Lv=e=>Ee(`/api/sessions/${encodeURIComponent(e)}/processes`),xN=(e,t)=>Ee(`/api/sessions/${encodeURIComponent(e)}/processes/${encodeURIComponent(t)}/kill`,{method:"POST",body:{}}),yN=(e,t)=>Ee(`/api/sessions/${encodeURIComponent(e)}/steer`,{method:"POST",body:t}),vN=e=>Ee(`/api/sessions/${encodeURIComponent(e)}/compact`,{method:"POST",body:{}}),bN=(e,t,a,l,o,c)=>Ee(`/api/projects/${encodeURIComponent(e)}/agents/${encodeURIComponent(t)}/traces/${encodeURIComponent(a)}/${l}`,{query:{offset:o,limit:c}}),kN=(e,t,a,l)=>Ee(`/api/projects/${encodeURIComponent(e)}/agents/${encodeURIComponent(t)}/traces/${encodeURIComponent(a)}/${l}/analysis`),wN=(e,t,a,l)=>`/api/projects/${encodeURIComponent(e)}/agents/${encodeURIComponent(t)}/traces/${encodeURIComponent(a)}/${l}/download`,SN=(e,t,a)=>Ee(`/api/projects/${encodeURIComponent(e)}/agents/${encodeURIComponent(t)}/traces/import`,{method:"POST",body:a}),jN=(e,t)=>Ee(`/api/projects/${encodeURIComponent(e)}/usage/errors`,{query:{offset:String(t.offset),limit:String(t.limit),from:t.from,to:t.to,agentId:t.agentId}}),_k=(e,t)=>Ee(`/api/projects/${encodeURIComponent(e)}/usage`,{query:{from:t.from,to:t.to,groupBy:t.groupBy,agentId:t.agentId,provider:t.provider,modelId:t.modelId}}),CN=(e,t)=>Ee(`/api/projects/${e}/agents/${t}`,{method:"DELETE"}),NN=(e,t)=>Ee(`/api/sessions/${e}/files`,{query:{path:t}}),Es=(e,t,a=!1)=>`/api/sessions/${e}/files/content?path=${encodeURIComponent(t)}${a?"&download=1":""}`,Ov=(e,t)=>`/api/sessions/${e}/files/preview-redirect?path=${encodeURIComponent(t)}`,TN=(e,t,a)=>Ee(`/api/sessions/${e}/files/content`,{method:"PUT",body:{dataBase64:a},query:{path:t}}),MN=(e,t)=>Ee(`/api/sessions/${e}/files/stat`,{method:"POST",body:{paths:t}}),EN=(e,t)=>Ee(`/api/projects/${encodeURIComponent(e)}/agents/${encodeURIComponent(t)}/schedules`),AN=(e,t,a)=>Ee(`/api/projects/${encodeURIComponent(e)}/agents/${encodeURIComponent(t)}/schedules`,{method:"POST",body:a}),Dv=(e,t,a,l)=>Ee(`/api/projects/${encodeURIComponent(e)}/agents/${encodeURIComponent(t)}/schedules/${encodeURIComponent(a)}`,{method:"PUT",body:l}),RN=(e,t,a)=>Ee(`/api/projects/${encodeURIComponent(e)}/agents/${encodeURIComponent(t)}/schedules/${encodeURIComponent(a)}`,{method:"DELETE"}),_N=()=>Ee("/api/skills"),Cd=(e,t)=>Ee(`/api/projects/${encodeURIComponent(e)}/agents/${encodeURIComponent(t)}/skills`),zv=(e,t,a)=>Ee(`/api/projects/${encodeURIComponent(e)}/agents/${encodeURIComponent(t)}/skills`,{method:"POST",body:{names:a}}),IN=(e,t,a)=>Ee(`/api/projects/${encodeURIComponent(e)}/agents/${encodeURIComponent(t)}/skills/archive`,{method:"POST",body:a}),LN=(e,t,a)=>`/api/projects/${encodeURIComponent(e)}/agents/${encodeURIComponent(t)}/skills/${encodeURIComponent(a)}/archive`,Ik=(e,t,a)=>Ee(`/api/projects/${encodeURIComponent(e)}/agents/${encodeURIComponent(t)}/skills/${encodeURIComponent(a)}`,{method:"DELETE"}),ON=(e,t)=>Ee(`/api/projects/${encodeURIComponent(e)}/agents/${encodeURIComponent(t)}/benchmarks`),DN=(e,t,a)=>Ee(`/api/projects/${encodeURIComponent(e)}/agents/${encodeURIComponent(t)}/benchmarks/${encodeURIComponent(a)}/cases`),Lk=(e,t,a,l,o)=>`/api/projects/${encodeURIComponent(e)}/agents/${encodeURIComponent(t)}/benchmarks/${encodeURIComponent(a)}/cases/${encodeURIComponent(l)}${o==="rubric"?"/rubric":""}/files`,zN=(e,t,a,l,o,c)=>Ee(Lk(e,t,a,l,c),{query:{path:o}}),UN=(e,t,a,l,o,c,u)=>`${Lk(e,t,a,l,c)}/content?path=${encodeURIComponent(o)}`+(u?.download?"&download=1":"")+(u?.preview&&!u.download?"&preview=1":""),$N=(e,t)=>`/api/projects/${encodeURIComponent(e)}/agents/${encodeURIComponent(t)}/export`,PN=(e,t,a)=>Ee(`/api/projects/${encodeURIComponent(e)}/agents/${encodeURIComponent(t)}/import`,{method:"POST",body:a}),BN=()=>Ee("/api/version"),Ok=(e=!1)=>Ee(`/api/version/update-check${e?"?force=1":""}`),HN=()=>Ee("/api/version/update",{method:"POST",body:{}}),Dk=y.createContext(null);function FN({children:e}){const[t,a]=y.useState(void 0),[l,o]=y.useState(!0),[c,u]=y.useState(!1),[f,p]=y.useState("password");y.useEffect(()=>(_v(()=>a(null)),()=>_v(null)),[]),y.useEffect(()=>{let k=!1;return Yu().then(w=>{k||(a(w.user),o(w.previewIsolated),u(w.desktopMode),p(w.sessionVia))}).catch(w=>{k||(w instanceof na&&w.status,a(null))}),()=>{k=!0}},[]);const h=y.useCallback(async(k,w)=>{const j=await IC({userId:k,password:w});a(j.user);try{const E=await Yu();a(E.user),o(E.previewIsolated),u(E.desktopMode),p(E.sessionVia)}catch{}},[]),g=y.useCallback(async()=>{try{await LC()}finally{a(null)}},[]),v=y.useCallback(async()=>{const k=await Yu();a(k.user),o(k.previewIsolated),u(k.desktopMode),p(k.sessionVia)},[]);return s.jsx(Dk.Provider,{value:{user:t,previewIsolated:l,desktopMode:c,sessionVia:f,login:h,logout:g,refresh:v},children:e})}function xn(){const e=y.useContext(Dk);if(!e)throw new Error("useAuth must be used within an AuthProvider");return e}const Fh=/^(?:[a-z][a-z0-9+.-]*:|[\\/]{2})/i,zk=/^[\\/]{2}/;function qN(e,t){return t+e.replace(/\\/g,"/")}const Uv="popstate";function $v(e){return typeof e=="object"&&e!=null&&"pathname"in e&&"search"in e&&"hash"in e&&"state"in e&&"key"in e}function VN(e={}){function t(l,o){let c=o.state?.masked,{pathname:u,search:f,hash:p}=c||l.location;return Gp("",{pathname:u,search:f,hash:p},o.state&&o.state.usr||null,o.state&&o.state.key||"default",c?{pathname:l.location.pathname,search:l.location.search,hash:l.location.hash}:void 0)}function a(l,o){return typeof o=="string"?o:Wo(o)}return WN(t,a,null,e)}function Qt(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function Tr(e,t){if(!e){typeof console<"u"&&console.warn(t);try{throw new Error(t)}catch{}}}function GN(){return Math.random().toString(36).substring(2,10)}function Pv(e,t){return{usr:e.state,key:e.key,idx:t,masked:e.mask?{pathname:e.pathname,search:e.search,hash:e.hash}:void 0}}function Gp(e,t,a=null,l,o){return{pathname:typeof e=="string"?e:e.pathname,search:"",hash:"",...typeof t=="string"?yi(t):t,state:a,key:t&&t.key||l||GN(),mask:o}}function Wo({pathname:e="/",search:t="",hash:a=""}){return t&&t!=="?"&&(e+=t.charAt(0)==="?"?t:"?"+t),a&&a!=="#"&&(e+=a.charAt(0)==="#"?a:"#"+a),e}function yi(e){let t={};if(e){let a=e.indexOf("#");a>=0&&(t.hash=e.substring(a),e=e.substring(0,a));let l=e.indexOf("?");l>=0&&(t.search=e.substring(l),e=e.substring(0,l)),e&&(t.pathname=e)}return t}function WN(e,t,a,l={}){let{window:o=document.defaultView,v5Compat:c=!1}=l,u=o.history,f="POP",p=null,h=g();h==null&&(h=0,u.replaceState({...u.state,idx:h},""));function g(){return(u.state||{idx:null}).idx}function v(){f="POP";let C=g(),M=C==null?null:C-h;h=C,p&&p({action:f,location:E.location,delta:M})}function k(C,M){f="PUSH";let _=$v(C)?C:Gp(E.location,C,M);h=g()+1;let D=Pv(_,h),V=E.createHref(_.mask||_);try{u.pushState(D,"",V)}catch(F){if(F instanceof DOMException&&F.name==="DataCloneError")throw F;o.location.assign(V)}c&&p&&p({action:f,location:E.location,delta:1})}function w(C,M){f="REPLACE";let _=$v(C)?C:Gp(E.location,C,M);h=g();let D=Pv(_,h),V=E.createHref(_.mask||_);u.replaceState(D,"",V),c&&p&&p({action:f,location:E.location,delta:0})}function j(C){return KN(o,C)}let E={get action(){return f},get location(){return e(o,u)},listen(C){if(p)throw new Error("A history only accepts one active listener");return o.addEventListener(Uv,v),p=C,()=>{o.removeEventListener(Uv,v),p=null}},createHref(C){return t(o,C)},createURL:j,encodeLocation(C){let M=j(C);return{pathname:M.pathname,search:M.search,hash:M.hash}},push:k,replace:w,go(C){return u.go(C)}};return E}function KN(e,t,a=!1){let l="http://localhost";e&&(l=e.location.origin!=="null"?e.location.origin:e.location.href),Qt(l,"No window.location.(origin|href) available to create URL");let o=typeof t=="string"?t:Wo(t);return o=o.replace(/ $/,"%20"),!a&&zk.test(o)&&(o=l+o),new URL(o,l)}function Uk(e,t,a="/"){return YN(e,t,a,!1)}function YN(e,t,a,l,o){let c=Us((typeof t=="string"?yi(t):t).pathname||"/",a);if(c==null)return null;let u=QN(e),f=null,p=Fk(c);for(let h=0;f==null&&h<u.length;++h)f=o4(u[h],p,l);return f}function QN(e){let t=$k(e);return XN(t),t}function $k(e,t=[],a=[],l="",o=!1){let c=(u,f,p=o,h)=>{let g={relativePath:h===void 0?u.path||"":h,caseSensitive:u.caseSensitive===!0,childrenIndex:f,route:u};if(g.relativePath.startsWith("/")){if(!g.relativePath.startsWith(l)&&p)return;Qt(g.relativePath.startsWith(l),`Absolute route path "${g.relativePath}" nested under path "${l}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),g.relativePath=g.relativePath.slice(l.length)}let v=mr([l,g.relativePath]),k=a.concat(g);u.children&&u.children.length>0&&(Qt(u.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${v}".`),$k(u.children,t,k,v,p)),!(u.path==null&&!u.index)&&t.push({path:v,score:l4(v,u.index),routesMeta:k.map((w,j)=>{let[E,C]=Hk(w.relativePath,w.caseSensitive,j===k.length-1);return{...w,matcher:E,compiledParams:C}})})};return e.forEach((u,f)=>{if(u.path===""||!u.path?.includes("?"))c(u,f);else for(let p of Pk(u.path))c(u,f,!0,p)}),t}function Pk(e){let t=e.split("/");if(t.length===0)return[];let[a,...l]=t,o=a.endsWith("?"),c=a.replace(/\?$/,"");if(l.length===0)return o?[c,""]:[c];let u=Pk(l.join("/")),f=[];return f.push(...u.map(p=>p===""?c:[c,p].join("/"))),o&&f.push(...u),f.map(p=>e.startsWith("/")&&p===""?"/":p)}function XN(e){e.sort((t,a)=>t.score!==a.score?a.score-t.score:i4(t.routesMeta.map(l=>l.childrenIndex),a.routesMeta.map(l=>l.childrenIndex)))}const ZN=/^:[\w-]+$/,JN=/^:[\w-]+/,e4=3.5,t4=3,n4=2,a4=1,r4=10,s4=-2,Bv=e=>e==="*";function l4(e,t){let a=e.split("/"),l=a.length;return a.some(Bv)&&(l+=s4),t&&(l+=n4),a.filter(o=>!Bv(o)).reduce((o,c)=>o+(ZN.test(c)?t4:JN.test(c)?e4:c===""?a4:r4),l)}function i4(e,t){return e.length===t.length&&e.slice(0,-1).every((a,l)=>a===t[l])?e[e.length-1]-t[t.length-1]:0}function o4(e,t,a=!1){let{routesMeta:l}=e,o={},c="/",u=[];for(let f=0;f<l.length;++f){let p=l[f],h=f===l.length-1,g=c==="/"?t:t.slice(c.length)||"/",v={path:p.relativePath,caseSensitive:p.caseSensitive,end:h},k=p.matcher&&p.compiledParams?Bk(v,g,p.matcher,p.compiledParams):Ko(v,g),w=p.route;if(!k&&h&&a&&!l[l.length-1].route.index&&(k=Ko({path:p.relativePath,caseSensitive:p.caseSensitive,end:!1},g)),!k)return null;Object.assign(o,k.params),u.push({params:o,pathname:mr([c,k.pathname]),pathnameBase:d4(mr([c,k.pathnameBase])),route:w}),k.pathnameBase!=="/"&&(c=mr([c,k.pathnameBase]))}return u}function Ko(e,t){typeof e=="string"&&(e={path:e,caseSensitive:!1,end:!0});let[a,l]=Hk(e.path,e.caseSensitive,e.end);return Bk(e,t,a,l)}function Bk(e,t,a,l){let o=t.match(a);if(!o)return null;let c=o[0],u=c.replace(/(.)\/+$/,"$1"),f=o.slice(1);return{params:l.reduce((p,{paramName:h,isOptional:g},v)=>{if(h==="*"){let w=f[v]||"";u=c.slice(0,c.length-w.length).replace(/(.)\/+$/,"$1")}const k=f[v];return g&&!k?p[h]=void 0:p[h]=(k||"").replace(/%2F/g,"/"),p},{}),pathname:c,pathnameBase:u,pattern:e}}function Hk(e,t=!1,a=!0){Tr(e==="*"||!e.endsWith("*")||e.endsWith("/*"),`Route path "${e}" will be treated as if it were "${e.replace(/\*$/,"/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${e.replace(/\*$/,"/*")}".`);let l=[],o="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(c,u,f,p,h)=>{if(l.push({paramName:u,isOptional:f!=null}),f){let g=h.charAt(p+c.length);return g&&g!=="/"?"/([^\\/]*)":"(?:/([^\\/]*))?"}return"/([^\\/]+)"}).replace(/\/([\w-]+)\?(?=\/|$|\()/g,"(?:/$1)?");return e.endsWith("*")?(l.push({paramName:"*"}),o+=e==="*"||e==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):a?o+="\\/*$":e!==""&&e!=="/"&&(o+="(?:(?=\\/|$))"),[new RegExp(o,t?void 0:"i"),l]}function Fk(e){try{return e.split("/").map(t=>decodeURIComponent(t).replace(/\//g,"%2F")).join("/")}catch(t){return Tr(!1,`The URL path "${e}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${t}).`),e}}function Us(e,t){if(t==="/")return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let a=t.endsWith("/")?t.length-1:t.length,l=e.charAt(a);return l&&l!=="/"?null:e.slice(a)||"/"}function c4(e,t="/"){let{pathname:a,search:l="",hash:o=""}=typeof e=="string"?yi(e):e,c;return a?(a=qk(a),a.startsWith("/")?c=Hv(a.substring(1),"/"):c=Hv(a,t)):c=t,{pathname:c,search:f4(l),hash:m4(o)}}function Hv(e,t){let a=Vk(t).split("/");return e.split("/").forEach(l=>{l===".."?a.length>1&&a.pop():l!=="."&&a.push(l)}),a.length>1?a.join("/"):"/"}function tp(e,t,a,l){return`Cannot include a '${e}' character in a manually specified \`to.${t}\` field [${JSON.stringify(l)}]. Please separate it out to the \`to.${a}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`}function u4(e){return e.filter((t,a)=>a===0||t.route.path&&t.route.path.length>0)}function qh(e){let t=u4(e);return t.map((a,l)=>l===t.length-1?a.pathname:a.pathnameBase)}function Nd(e,t,a,l=!1){let o;typeof e=="string"?o=yi(e):(o={...e},Qt(!o.pathname||!o.pathname.includes("?"),tp("?","pathname","search",o)),Qt(!o.pathname||!o.pathname.includes("#"),tp("#","pathname","hash",o)),Qt(!o.search||!o.search.includes("#"),tp("#","search","hash",o)));let c=e===""||o.pathname==="",u=c?"/":o.pathname,f;if(u==null)f=a;else{let v=t.length-1;if(!l&&u.startsWith("..")){let k=u.split("/");for(;k[0]==="..";)k.shift(),v-=1;o.pathname=k.join("/")}f=v>=0?t[v]:"/"}let p=c4(o,f),h=u&&u!=="/"&&u.endsWith("/"),g=(c||u===".")&&a.endsWith("/");return!p.pathname.endsWith("/")&&(h||g)&&(p.pathname+="/"),p}const qk=e=>e.replace(/[\\/]{2,}/g,"/"),mr=e=>qk(e.join("/")),Vk=e=>e.replace(/\/+$/,""),d4=e=>Vk(e).replace(/^\/*/,"/"),f4=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,m4=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e;var p4=class{status;statusText;data;error;internal;constructor(e,t,a,l=!1){this.status=e,this.statusText=t||"",this.internal=l,a instanceof Error?(this.data=a.toString(),this.error=a):this.data=a}};function h4(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}function g4(e){return mr(e.map(t=>t.route.path).filter(Boolean))||"/"}const Gk=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Wk(e,t){let a=e;if(typeof a!="string"||!Fh.test(a))return{absoluteURL:void 0,isExternal:!1,to:a};let l=a,o=!1;if(Gk)try{let c=new URL(window.location.href),u=zk.test(a)?new URL(qN(a,c.protocol)):new URL(a),f=Us(u.pathname,t);u.origin===c.origin&&f!=null?a=f+u.search+u.hash:o=!0}catch{Tr(!1,`<Link to="${a}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:l,isExternal:o,to:a}}const Kk=["POST","PUT","PATCH","DELETE"];new Set(Kk);const x4=["GET",...Kk];new Set(x4);const y4=["about:","blob:","chrome:","chrome-untrusted:","content:","data:","devtools:","file:","filesystem:","javascript:"];function v4(e){try{return y4.includes(new URL(e).protocol)}catch{return!1}}const vi=y.createContext(null);vi.displayName="DataRouter";const Td=y.createContext(null);Td.displayName="DataRouterState";const Yk=y.createContext(!1);function b4(){return y.useContext(Yk)}const Qk=y.createContext({isTransitioning:!1});Qk.displayName="ViewTransition";const k4=y.createContext(new Map);k4.displayName="Fetchers";const w4=y.createContext(null);w4.displayName="Await";const tr=y.createContext(null);tr.displayName="Navigation";const rc=y.createContext(null);rc.displayName="Location";const nr=y.createContext({outlet:null,matches:[],isDataRoute:!1});nr.displayName="Route";const Vh=y.createContext(null);Vh.displayName="RouteError";const Xk="REACT_ROUTER_ERROR",S4="REDIRECT",j4="ROUTE_ERROR_RESPONSE";function C4(e){if(e.startsWith(`${Xk}:${S4}:{`))try{let t=JSON.parse(e.slice(28));if(typeof t=="object"&&t&&typeof t.status=="number"&&typeof t.statusText=="string"&&typeof t.location=="string"&&typeof t.reloadDocument=="boolean"&&typeof t.replace=="boolean")return t}catch{}}function N4(e){if(e.startsWith(`${Xk}:${j4}:{`))try{let t=JSON.parse(e.slice(40));if(typeof t=="object"&&t&&typeof t.status=="number"&&typeof t.statusText=="string")return new p4(t.status,t.statusText,t.data)}catch{}}function T4(e,{relative:t}={}){Qt(Cl(),"useHref() may be used only in the context of a <Router> component.");let{basename:a,navigator:l}=y.useContext(tr),{hash:o,pathname:c,search:u}=sc(e,{relative:t}),f=c;return a!=="/"&&(f=c==="/"?a:mr([a,c])),l.createHref({pathname:f,search:u,hash:o})}function Cl(){return y.useContext(rc)!=null}function ya(){return Qt(Cl(),"useLocation() may be used only in the context of a <Router> component."),y.useContext(rc).location}function Zk(e){Qt(Cl(),"useMatch() may be used only in the context of a <Router> component.");let{pathname:t}=ya();return y.useMemo(()=>Ko(e,Fk(t)),[t,e])}const Jk="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function Wn(){let{isDataRoute:e}=y.useContext(nr);return e?F4():M4()}function M4(){Qt(Cl(),"useNavigate() may be used only in the context of a <Router> component.");let e=y.useContext(vi),{basename:t,navigator:a}=y.useContext(tr),{matches:l}=y.useContext(nr),{pathname:o}=ya(),c=JSON.stringify(qh(l)),u=y.useRef(!1);return y.useLayoutEffect(()=>{u.current=!0}),y.useCallback((f,p={})=>{if(Tr(u.current,Jk),!u.current)return;if(typeof f=="number"){a.go(f);return}let h=Nd(f,JSON.parse(c),o,p.relative==="path");e==null&&t!=="/"&&(h.pathname=h.pathname==="/"?t:mr([t,h.pathname])),(p.replace?a.replace:a.push)(h,p.state,p)},[t,a,c,o,e])}const E4=y.createContext(null);function A4(e){let t=y.useContext(nr).outlet;return y.useMemo(()=>t&&y.createElement(E4.Provider,{value:e},t),[t,e])}function ew(){let{matches:e}=y.useContext(nr);return e[e.length-1]?.params??{}}function sc(e,{relative:t}={}){let{matches:a}=y.useContext(nr),{pathname:l}=ya(),o=JSON.stringify(qh(a));return y.useMemo(()=>Nd(e,JSON.parse(o),l,t==="path"),[e,o,l,t])}function R4(e,t){return tw(e,t)}function tw(e,t,a){Qt(Cl(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:l}=y.useContext(tr),{matches:o}=y.useContext(nr),c=o[o.length-1],u=c?c.params:{};c&&c.pathname;let f=c?c.pathnameBase:"/";c&&c.route;let p=ya(),h;if(t){let j=typeof t=="string"?yi(t):t;Qt(f==="/"||j.pathname?.startsWith(f),`When overriding the location using \`<Routes location>\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${f}" but pathname "${j.pathname}" was given in the \`location\` prop.`),h=j}else h=p;let g=h.pathname||"/",v=g;if(f!=="/"){let j=f.replace(/^\//,"").split("/");v="/"+g.replace(/^\//,"").split("/").slice(j.length).join("/")}let k=a&&a.state.matches.length?a.state.matches.map(j=>Object.assign(j,{route:a.manifest[j.route.id]||j.route})):Uk(e,{pathname:v}),w=z4(k&&k.map(j=>Object.assign({},j,{params:Object.assign({},u,j.params),pathname:mr([f,l.encodeLocation?l.encodeLocation(j.pathname.replace(/%/g,"%25").replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:j.pathname]),pathnameBase:j.pathnameBase==="/"?f:mr([f,l.encodeLocation?l.encodeLocation(j.pathnameBase.replace(/%/g,"%25").replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:j.pathnameBase])})),o,a);return t&&w?y.createElement(rc.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",mask:void 0,...h},navigationType:"POP"}},w):w}function _4(){let e=H4(),t=h4(e)?`${e.status} ${e.statusText}`:e instanceof Error?e.message:JSON.stringify(e),a=e instanceof Error?e.stack:null;return y.createElement(y.Fragment,null,y.createElement("h2",null,"Unexpected Application Error!"),y.createElement("h3",{style:{fontStyle:"italic"}},t),a?y.createElement("pre",{style:{padding:"0.5rem",backgroundColor:"rgba(200,200,200, 0.5)"}},a):null,null)}const I4=y.createElement(_4,null);var L4=class extends y.Component{constructor(e){super(e),this.state={location:e.location,revalidation:e.revalidation,error:e.error}}static contextType=Yk;static getDerivedStateFromError(e){return{error:e}}static getDerivedStateFromProps(e,t){return t.location!==e.location||t.revalidation!=="idle"&&e.revalidation==="idle"?{error:e.error,location:e.location,revalidation:e.revalidation}:{error:e.error!==void 0?e.error:t.error,location:t.location,revalidation:e.revalidation||t.revalidation}}componentDidCatch(e,t){this.props.onError?this.props.onError(e,t):console.error("React Router caught the following error during render",e)}render(){let e=this.state.error;if(this.context&&typeof e=="object"&&e&&"digest"in e&&typeof e.digest=="string"){const a=N4(e.digest);a&&(e=a)}let t=e!==void 0?y.createElement(nr.Provider,{value:this.props.routeContext},y.createElement(Vh.Provider,{value:e,children:this.props.component})):this.props.children;return this.context?y.createElement(O4,{error:e},t):t}};const np=new WeakMap;function O4({children:e,error:t}){let{basename:a}=y.useContext(tr);if(typeof t=="object"&&t&&"digest"in t&&typeof t.digest=="string"){let l=C4(t.digest);if(l){let o=np.get(t);if(o)throw o;let c=Wk(l.location,a),u=c.absoluteURL||c.to;if(v4(u))throw new Error("Invalid redirect location");if(Gk&&!np.get(t))if(c.isExternal||l.reloadDocument)window.location.href=u;else{const f=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(c.to,{replace:l.replace}));throw np.set(t,f),f}return y.createElement("meta",{httpEquiv:"refresh",content:`0;url=${u}`})}}return e}function D4({routeContext:e,match:t,children:a}){let l=y.useContext(vi);return l&&l.static&&l.staticContext&&(t.route.errorElement||t.route.ErrorBoundary)&&(l.staticContext._deepestRenderedBoundaryId=t.route.id),y.createElement(nr.Provider,{value:e},a)}function z4(e,t=[],a){let l=a?.state;if(e==null){if(!l)return null;if(l.errors)e=l.matches;else if(t.length===0&&!l.initialized&&l.matches.length>0)e=l.matches;else return null}let o=e,c=l?.errors;if(c!=null){let g=o.findIndex(v=>v.route.id&&c?.[v.route.id]!==void 0);Qt(g>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(c).join(",")}`),o=o.slice(0,Math.min(o.length,g+1))}let u=!1,f=-1;if(a&&l){u=l.renderFallback;for(let g=0;g<o.length;g++){let v=o[g];if((v.route.HydrateFallback||v.route.hydrateFallbackElement)&&(f=g),v.route.id){let{loaderData:k,errors:w}=l,j=v.route.loader&&!k.hasOwnProperty(v.route.id)&&(!w||w[v.route.id]===void 0);if(v.route.lazy||j){a.isStatic&&(u=!0),f>=0?o=o.slice(0,f+1):o=[o[0]];break}}}}let p=a?.onError,h=l&&p?(g,v)=>{p(g,{location:l.location,params:l.matches?.[0]?.params??{},pattern:g4(l.matches),errorInfo:v})}:void 0;return o.reduceRight((g,v,k)=>{let w,j=!1,E=null,C=null;l&&(w=c&&v.route.id?c[v.route.id]:void 0,E=v.route.errorElement||I4,u&&(f<0&&k===0?(q4("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),j=!0,C=null):f===k&&(j=!0,C=v.route.hydrateFallbackElement||null)));let M=t.concat(o.slice(0,k+1)),_=()=>{let D;return w?D=E:j?D=C:v.route.Component?D=y.createElement(v.route.Component,null):v.route.element?D=v.route.element:D=g,y.createElement(D4,{match:v,routeContext:{outlet:g,matches:M,isDataRoute:l!=null},children:D})};return l&&(v.route.ErrorBoundary||v.route.errorElement||k===0)?y.createElement(L4,{location:l.location,revalidation:l.revalidation,component:E,error:w,children:_(),routeContext:{outlet:null,matches:M,isDataRoute:!0},onError:h}):_()},null)}function Gh(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function U4(e){let t=y.useContext(vi);return Qt(t,Gh(e)),t}function $4(e){let t=y.useContext(Td);return Qt(t,Gh(e)),t}function P4(e){let t=y.useContext(nr);return Qt(t,Gh(e)),t}function Wh(e){let t=P4(e),a=t.matches[t.matches.length-1];return Qt(a.route.id,`${e} can only be used on routes that contain a unique "id"`),a.route.id}function B4(){return Wh("useRouteId")}function H4(){let e=y.useContext(Vh),t=$4("useRouteError"),a=Wh("useRouteError");return e!==void 0?e:t.errors?.[a]}function F4(){let{router:e}=U4("useNavigate"),t=Wh("useNavigate"),a=y.useRef(!1);return y.useLayoutEffect(()=>{a.current=!0}),y.useCallback(async(l,o={})=>{Tr(a.current,Jk),a.current&&(typeof l=="number"?await e.navigate(l):await e.navigate(l,{fromRouteId:t,...o}))},[e,t])}const Fv={};function q4(e,t,a){Fv[e]||(Fv[e]=!0,Tr(!1,a))}y.memo(V4);function V4({routes:e,manifest:t,future:a,state:l,isStatic:o,onError:c}){return tw(e,void 0,{manifest:t,state:l,isStatic:o,onError:c})}function Yo({to:e,replace:t,state:a,relative:l}){Qt(Cl(),"<Navigate> may be used only in the context of a <Router> component.");let{static:o}=y.useContext(tr);Tr(!o,"<Navigate> must not be used on the initial render in a <StaticRouter>. This is a no-op, but you should modify your code so the <Navigate> is only ever rendered in response to some user interaction or state change.");let{matches:c}=y.useContext(nr),{pathname:u}=ya(),f=Wn(),p=Nd(e,qh(c),u,l==="path"),h=JSON.stringify(p);return y.useEffect(()=>{f(JSON.parse(h),{replace:t,state:a,relative:l})},[f,h,l,t,a]),null}function G4(e){return A4(e.context)}function fa(e){Qt(!1,"A <Route> is only ever to be used as the child of <Routes> element, never rendered directly. Please wrap your <Route> in a <Routes>.")}function W4({basename:e="/",children:t=null,location:a,navigationType:l="POP",navigator:o,static:c=!1,useTransitions:u}){Qt(!Cl(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let f=e.replace(/^\/*/,"/"),p=y.useMemo(()=>({basename:f,navigator:o,static:c,useTransitions:u,future:{}}),[f,o,c,u]);typeof a=="string"&&(a=yi(a));let{pathname:h="/",search:g="",hash:v="",state:k=null,key:w="default",mask:j}=a,E=y.useMemo(()=>{let C=Us(h,f);return C==null?null:{location:{pathname:C,search:g,hash:v,state:k,key:w,mask:j},navigationType:l}},[f,h,g,v,k,w,l,j]);return Tr(E!=null,`<Router basename="${f}"> is not able to match the URL "${h}${g}${v}" because it does not start with the basename, so the <Router> won't render anything.`),E==null?null:y.createElement(tr.Provider,{value:p},y.createElement(rc.Provider,{children:t,value:E}))}function K4({children:e,location:t}){return R4(Wp(e),t)}function Wp(e,t=[]){let a=[];return y.Children.forEach(e,(l,o)=>{if(!y.isValidElement(l))return;let c=[...t,o];if(l.type===y.Fragment){a.push.apply(a,Wp(l.props.children,c));return}Qt(l.type===fa,`[${typeof l.type=="string"?l.type:l.type.name}] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>`);let u=l.props;Qt(!u.index||!u.children,"An index route cannot have child routes.");let f={id:u.id||c.join("-"),caseSensitive:u.caseSensitive,element:u.element,Component:u.Component,index:u.index,path:u.path,middleware:u.middleware,loader:u.loader,action:u.action,hydrateFallbackElement:u.hydrateFallbackElement,HydrateFallback:u.HydrateFallback,errorElement:u.errorElement,ErrorBoundary:u.ErrorBoundary,shouldRevalidate:u.shouldRevalidate,handle:u.handle,lazy:u.lazy};u.children&&(f.children=Wp(u.children,c)),a.push(f)}),a}const Qu="application/x-www-form-urlencoded";function Md(e){return typeof HTMLElement<"u"&&e instanceof HTMLElement}function Y4(e){return Md(e)&&e.tagName.toLowerCase()==="button"}function Q4(e){return Md(e)&&e.tagName.toLowerCase()==="form"}function X4(e){return Md(e)&&e.tagName.toLowerCase()==="input"}function Z4(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function J4(e,t){return e.button===0&&(!t||t==="_self")&&!Z4(e)}function Kp(e=""){return new URLSearchParams(typeof e=="string"||Array.isArray(e)||e instanceof URLSearchParams?e:Object.keys(e).reduce((t,a)=>{let l=e[a];return t.concat(Array.isArray(l)?l.map(o=>[a,o]):[[a,l]])},[]))}function eT(e,t){let a=Kp(e);return t&&t.forEach((l,o)=>{a.has(o)||t.getAll(o).forEach(c=>{a.append(o,c)})}),a}let Nu=null;function tT(){if(Nu===null)try{new FormData(document.createElement("form"),0),Nu=!1}catch{Nu=!0}return Nu}const nT=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function ap(e){return e!=null&&!nT.has(e)?(Tr(!1,`"${e}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${Qu}"`),null):e}function aT(e,t){let a,l,o,c,u;if(Q4(e)){let f=e.getAttribute("action");l=f?Us(f,t):null,a=e.getAttribute("method")||"get",o=ap(e.getAttribute("enctype"))||Qu,c=new FormData(e)}else if(Y4(e)||X4(e)&&(e.type==="submit"||e.type==="image")){let f=e.form;if(f==null)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let p=e.getAttribute("formaction")||f.getAttribute("action");if(l=p?Us(p,t):null,a=e.getAttribute("formmethod")||f.getAttribute("method")||"get",o=ap(e.getAttribute("formenctype"))||ap(f.getAttribute("enctype"))||Qu,c=new FormData(f,e),!tT()){let{name:h,type:g,value:v}=e;if(g==="image"){let k=h?`${h}.`:"";c.append(`${k}x`,"0"),c.append(`${k}y`,"0")}else h&&c.append(h,v)}}else{if(Md(e))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');a="get",l=null,o=Qu,u=e}return c&&o==="text/plain"&&(u=c,c=void 0),{action:l,method:a.toLowerCase(),encType:o,formData:c,body:u}}function Kh(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function nw(e,t){let a=typeof e=="string"?new URL(e,typeof window>"u"?"server://singlefetch/":window.location.origin):e;return a.pathname.endsWith("/")?a.pathname=`${a.pathname}_.${t}`:a.pathname=`${a.pathname}.${t}`,a}async function rT(e,t){if(e.id in t)return t[e.id];try{let a=await import(e.module);return t[e.id]=a,a}catch(a){return console.error(`Error loading route module \`${e.module}\`, reloading page...`),console.error(a),window.__reactRouterContext&&window.__reactRouterContext.isSpaMode,window.location.reload(),new Promise(()=>{})}}function sT(e){return e==null?!1:e.href==null?e.rel==="preload"&&typeof e.imageSrcSet=="string"&&typeof e.imageSizes=="string":typeof e.rel=="string"&&typeof e.href=="string"}async function lT(e,t,a){return uT((await Promise.all(e.map(async l=>{let o=t.routes[l.route.id];if(o){let c=await rT(o,a);return c.links?c.links():[]}return[]}))).flat(1).filter(sT).filter(l=>l.rel==="stylesheet"||l.rel==="preload").map(l=>l.rel==="stylesheet"?{...l,rel:"prefetch",as:"style"}:{...l,rel:"prefetch"}))}function qv(e,t,a,l,o,c){let u=(p,h)=>a[h]?p.route.id!==a[h].route.id:!0,f=(p,h)=>a[h].pathname!==p.pathname||a[h].route.path?.endsWith("*")&&a[h].params["*"]!==p.params["*"];return c==="assets"?t.filter((p,h)=>u(p,h)||f(p,h)):c==="data"?t.filter((p,h)=>{let g=l.routes[p.route.id];if(!g||!g.hasLoader)return!1;if(u(p,h)||f(p,h))return!0;if(p.route.shouldRevalidate){let v=p.route.shouldRevalidate({currentUrl:new URL(o.pathname+o.search+o.hash,window.origin),currentParams:a[0]?.params||{},nextUrl:new URL(e,window.origin),nextParams:p.params,defaultShouldRevalidate:!0});if(typeof v=="boolean")return v}return!0}):[]}function iT(e,t,{includeHydrateFallback:a}={}){return oT(e.map(l=>{let o=t.routes[l.route.id];if(!o)return[];let c=[o.module];return o.clientActionModule&&(c=c.concat(o.clientActionModule)),o.clientLoaderModule&&(c=c.concat(o.clientLoaderModule)),a&&o.hydrateFallbackModule&&(c=c.concat(o.hydrateFallbackModule)),o.imports&&(c=c.concat(o.imports)),c}).flat(1))}function oT(e){return[...new Set(e)]}function cT(e){let t={},a=Object.keys(e).sort();for(let l of a)t[l]=e[l];return t}function uT(e,t){let a=new Set;return new Set(t),e.reduce((l,o)=>{let c=JSON.stringify(cT(o));return a.has(c)||(a.add(c),l.push({key:c,link:o})),l},[])}function dT(){let e=y.useContext(vi);return Kh(e,"You must render this element inside a <DataRouterContext.Provider> element"),e}function fT(){let e=y.useContext(Td);return Kh(e,"You must render this element inside a <DataRouterStateContext.Provider> element"),e}const Yh=y.createContext(void 0);Yh.displayName="FrameworkContext";function Qh(){let e=y.useContext(Yh);return Kh(e,"You must render this element inside a <HydratedRouter> element"),e}function mT(e,t){let a=y.useContext(Yh),[l,o]=y.useState(!1),[c,u]=y.useState(!1),{onFocus:f,onBlur:p,onMouseEnter:h,onMouseLeave:g,onTouchStart:v}=t,k=y.useRef(null);y.useEffect(()=>{if(e==="render"&&u(!0),e==="viewport"){let E=M=>{M.forEach(_=>{u(_.isIntersecting)})},C=new IntersectionObserver(E,{threshold:.5});return k.current&&C.observe(k.current),()=>{C.disconnect()}}},[e]),y.useEffect(()=>{if(l){let E=setTimeout(()=>{u(!0)},100);return()=>{clearTimeout(E)}}},[l]);let w=()=>{o(!0)},j=()=>{o(!1),u(!1)};return a?e!=="intent"?[c,k,{}]:[c,k,{onFocus:yo(f,w),onBlur:yo(p,j),onMouseEnter:yo(h,w),onMouseLeave:yo(g,j),onTouchStart:yo(v,w)}]:[!1,k,{}]}function yo(e,t){return a=>{e&&e(a),a.defaultPrevented||t(a)}}function pT({page:e,...t}){let a=b4(),{nonce:l}=Qh(),{router:o}=dT(),c=y.useMemo(()=>Uk(o.routes,e,o.basename),[o.routes,e,o.basename]);return c?(t.nonce==null&&l&&(t={...t,nonce:l}),a?y.createElement(gT,{page:e,matches:c,...t}):y.createElement(xT,{page:e,matches:c,...t})):null}function hT(e){let{manifest:t,routeModules:a}=Qh(),[l,o]=y.useState([]);return y.useEffect(()=>{let c=!1;return lT(e,t,a).then(u=>{c||o(u)}),()=>{c=!0}},[e,t,a]),l}function gT({page:e,matches:t,...a}){let l=ya(),o=y.useMemo(()=>{if(e===l.pathname+l.search+l.hash)return[];let c=nw(e,"rsc"),u=!1,f=[];for(let p of t)typeof p.route.shouldRevalidate=="function"?u=!0:f.push(p.route.id);return u&&f.length>0&&c.searchParams.set("_routes",f.join(",")),[c.pathname+c.search]},[e,l,t]);return y.createElement(y.Fragment,null,o.map(c=>y.createElement("link",{key:c,rel:"prefetch",as:"fetch",href:c,...a})))}function xT({page:e,matches:t,...a}){let l=ya(),{manifest:o,routeModules:c}=Qh(),{loaderData:u,matches:f}=fT(),p=y.useMemo(()=>qv(e,t,f,o,l,"data"),[e,t,f,o,l]),h=y.useMemo(()=>qv(e,t,f,o,l,"assets"),[e,t,f,o,l]),g=y.useMemo(()=>{if(e===l.pathname+l.search+l.hash)return[];let w=new Set,j=!1;if(t.forEach(C=>{let M=o.routes[C.route.id];!M||!M.hasLoader||(!p.some(_=>_.route.id===C.route.id)&&C.route.id in u&&c[C.route.id]?.shouldRevalidate||M.hasClientLoader?j=!0:w.add(C.route.id))}),w.size===0)return[];let E=nw(e,"data");return j&&w.size>0&&E.searchParams.set("_routes",t.filter(C=>w.has(C.route.id)).map(C=>C.route.id).join(",")),[E.pathname+E.search]},[u,l,o,p,t,e,c]),v=y.useMemo(()=>iT(h,o),[h,o]),k=hT(h);return y.createElement(y.Fragment,null,g.map(w=>y.createElement("link",{key:w,rel:"prefetch",as:"fetch",href:w,...a})),v.map(w=>y.createElement("link",{key:w,rel:"modulepreload",href:w,...a})),k.map(({key:w,link:j})=>y.createElement("link",{key:w,nonce:a.nonce,...j,crossOrigin:j.crossOrigin??a.crossOrigin})))}function yT(...e){return t=>{e.forEach(a=>{typeof a=="function"?a(t):a!=null&&(a.current=t)})}}const vT=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{vT&&(window.__reactRouterVersion="8.3.0")}catch{}function bT({basename:e,children:t,useTransitions:a,window:l}){let o=y.useRef(null);o.current==null&&(o.current=VN({window:l,v5Compat:!0}));let c=o.current,[u,f]=y.useState({action:c.action,location:c.location}),p=y.useCallback(h=>{a===!1?f(h):y.startTransition(()=>f(h))},[a]);return y.useLayoutEffect(()=>c.listen(p),[c,p]),y.createElement(W4,{basename:e,children:t,location:u.location,navigationType:u.action,navigator:c,useTransitions:a})}const Xh=y.forwardRef(function({onClick:t,discover:a="render",prefetch:l="none",relative:o,reloadDocument:c,replace:u,mask:f,state:p,target:h,to:g,preventScrollReset:v,viewTransition:k,defaultShouldRevalidate:w,...j},E){let{basename:C,navigator:M,useTransitions:_}=y.useContext(tr),D=typeof g=="string"&&Fh.test(g),V=Wk(g,C);g=V.to;let F=T4(g,{relative:o}),A=ya(),P=null;if(f){let G=Nd(f,[],A.mask?A.mask.pathname:"/",!0);C!=="/"&&(G.pathname=G.pathname==="/"?C:mr([C,G.pathname])),P=M.createHref(G)}let[Q,K,O]=mT(l,j),z=ST(g,{replace:u,mask:f,state:p,target:h,preventScrollReset:v,relative:o,viewTransition:k,defaultShouldRevalidate:w,useTransitions:_});function I(G){t&&t(G),G.defaultPrevented||z(G)}let B=!(V.isExternal||c),$=y.createElement("a",{...j,...O,href:(B?P:void 0)||V.absoluteURL||F,onClick:B?I:t,ref:yT(E,K),target:h,"data-discover":!D&&a==="render"?"true":void 0});return Q&&!D?y.createElement(y.Fragment,null,$,y.createElement(pT,{page:F})):$});Xh.displayName="Link";const Zh=y.forwardRef(function({"aria-current":t="page",caseSensitive:a=!1,className:l="",end:o=!1,style:c,to:u,viewTransition:f,children:p,...h},g){let v=sc(u,{relative:h.relative}),k=ya(),w=y.useContext(Td),{navigator:j,basename:E}=y.useContext(tr),C=w!=null&&MT(v)&&f===!0,M=j.encodeLocation?j.encodeLocation(v).pathname:v.pathname,_=k.pathname,D=w&&w.navigation&&w.navigation.location?w.navigation.location.pathname:null;a||(_=_.toLowerCase(),D=D?D.toLowerCase():null,M=M.toLowerCase()),D&&E&&(D=Us(D,E)||D);const V=M!=="/"&&M.endsWith("/")?M.length-1:M.length;let F=_===M||!o&&_.startsWith(M)&&_.charAt(V)==="/",A=D!=null&&(D===M||!o&&D.startsWith(M)&&D.charAt(V)==="/"),P={isActive:F,isPending:A,isTransitioning:C},Q=F?t:void 0,K;typeof l=="function"?K=l(P):K=[l,F?"active":null,A?"pending":null,C?"transitioning":null].filter(Boolean).join(" ");let O=typeof c=="function"?c(P):c;return y.createElement(Xh,{...h,"aria-current":Q,className:K,ref:g,style:O,to:u,viewTransition:f},typeof p=="function"?p(P):p)});Zh.displayName="NavLink";const kT=y.forwardRef(({discover:e="render",fetcherKey:t,navigate:a,reloadDocument:l,replace:o,state:c,method:u="get",action:f,onSubmit:p,relative:h,preventScrollReset:g,viewTransition:v,defaultShouldRevalidate:k,...w},j)=>{let{useTransitions:E}=y.useContext(tr),C=NT(),M=TT(f,{relative:h}),_=u.toLowerCase()==="get"?"get":"post",D=typeof f=="string"&&Fh.test(f),V=F=>{if(p&&p(F),F.defaultPrevented)return;F.preventDefault();let A=F.nativeEvent.submitter,P=A?.getAttribute("formmethod")||u,Q=()=>C(A||F.currentTarget,{fetcherKey:t,method:P,navigate:a,replace:o,state:c,relative:h,preventScrollReset:g,viewTransition:v,defaultShouldRevalidate:k});E&&a!==!1?y.startTransition(()=>Q()):Q()};return y.createElement("form",{ref:j,method:_,action:M,onSubmit:l?p:V,...w,"data-discover":!D&&e==="render"?"true":void 0})});kT.displayName="Form";function wT(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function aw(e){let t=y.useContext(vi);return Qt(t,wT(e)),t}function ST(e,{target:t,replace:a,mask:l,state:o,preventScrollReset:c,relative:u,viewTransition:f,defaultShouldRevalidate:p,useTransitions:h}={}){let g=Wn(),v=ya(),k=sc(e,{relative:u});return y.useCallback(w=>{if(J4(w,t)){w.preventDefault();let j=a!==void 0?a:Wo(v)===Wo(k),E=()=>g(e,{replace:j,mask:l,state:o,preventScrollReset:c,relative:u,viewTransition:f,defaultShouldRevalidate:p});h?y.startTransition(()=>E()):E()}},[v,g,k,a,l,o,t,e,c,u,f,p,h])}function Ed(e){Tr(typeof URLSearchParams<"u","You cannot use the `useSearchParams` hook in a browser that does not support the URLSearchParams API. If you need to support Internet Explorer 11, we recommend you load a polyfill such as https://github.com/ungap/url-search-params.");let t=y.useRef(Kp(e)),a=y.useRef(!1),l=ya(),o=y.useMemo(()=>eT(l.search,a.current?null:t.current),[l.search]),c=Wn();return[o,y.useCallback((u,f)=>{const p=Kp(typeof u=="function"?u(new URLSearchParams(o)):u);a.current=!0,c("?"+p,f)},[c,o])]}let jT=0,CT=()=>`__${String(++jT)}__`;function NT(){let{router:e}=aw("useSubmit"),{basename:t}=y.useContext(tr),a=B4(),l=e.fetch,o=e.navigate;return y.useCallback(async(c,u={})=>{let{action:f,method:p,encType:h,formData:g,body:v}=aT(c,t);u.navigate===!1?await l(u.fetcherKey||CT(),a,u.action||f,{defaultShouldRevalidate:u.defaultShouldRevalidate,preventScrollReset:u.preventScrollReset,formData:g,body:v,formMethod:u.method||p,formEncType:u.encType||h,flushSync:u.flushSync}):await o(u.action||f,{defaultShouldRevalidate:u.defaultShouldRevalidate,preventScrollReset:u.preventScrollReset,formData:g,body:v,formMethod:u.method||p,formEncType:u.encType||h,replace:u.replace,state:u.state,fromRouteId:a,flushSync:u.flushSync,viewTransition:u.viewTransition})},[l,o,t,a])}function TT(e,{relative:t}={}){let{basename:a}=y.useContext(tr),l=y.useContext(nr);Qt(l,"useFormAction must be used inside a RouteContext");let[o]=l.matches.slice(-1),c={...sc(e||".",{relative:t})},u=ya();if(e==null){c.search=u.search;let f=new URLSearchParams(c.search),p=f.getAll("index");if(p.some(h=>h==="")){f.delete("index"),p.filter(g=>g).forEach(g=>f.append("index",g));let h=f.toString();c.search=h?`?${h}`:""}}return(!e||e===".")&&o.route.index&&(c.search=c.search?c.search.replace(/^\?/,"?index&"):"?index"),a!=="/"&&(c.pathname=c.pathname==="/"?a:mr([a,c.pathname])),Wo(c)}function MT(e,{relative:t}={}){let a=y.useContext(Qk);Qt(a!=null,"`useViewTransitionState` must be used within `react-router/dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:l}=aw("useViewTransitionState"),o=sc(e,{relative:t});if(!a.isTransitioning)return!1;let c=Us(a.currentLocation.pathname,l)||a.currentLocation.pathname,u=Us(a.nextLocation.pathname,l)||a.nextLocation.pathname;return Ko(o.pathname,u)!=null||Ko(o.pathname,c)!=null}const Vv="penguin.lastProjectId",Gv=e=>`penguin.lastAgentId.${e}`,rw=y.createContext(null);function Yp(e){return e.name??e.projectId}function tn(e){return e.name??e.agentId}function ET({children:e}){const[t,a]=y.useState([]),[l,o]=y.useState(!0),[c,u]=y.useState(null),[f,p]=y.useState([]),[h,g]=y.useState(!0),[v,k]=y.useState(null),w=y.useCallback(async()=>{o(!0);try{const _=await HC();a(_.projects),u(D=>{const V=D??localStorage.getItem(Vv);return(_.projects.find(A=>A.projectId===V)??_.projects[0])?.projectId??null})}finally{o(!1)}},[]);y.useEffect(()=>{w()},[w]);const j=y.useCallback(_=>{_!==c&&(localStorage.setItem(Vv,_),u(_),k(null),p([]),g(!0),jd({lastProjectId:_}).catch(()=>{}))},[c]),E=y.useCallback(async()=>{if(c){g(!0);try{const _=await iN(c);p(_.agents),k(D=>{const V=D??localStorage.getItem(Gv(c)),F=_.agents.find(P=>P.agentId===V),A=_.agents.find(P=>P.agentId==="default_agent")??_.agents[0]??null;return(F??A)?.agentId??null})}finally{g(!1)}}},[c]);y.useEffect(()=>{p([]),E()},[E]);const C=y.useCallback(_=>{c&&localStorage.setItem(Gv(c),_),k(_)},[c]),M=y.useMemo(()=>{const _=t.find(V=>V.projectId===c)??null,D=f.find(V=>V.agentId===v)??null;return{projects:t,projectsLoading:l,currentProject:_,setCurrentProjectId:j,reloadProjects:w,agents:f,agentsLoading:h,currentAgent:D,setCurrentAgentId:C,reloadAgents:E}},[t,l,c,j,w,f,h,v,C,E]);return s.jsx(rw.Provider,{value:M,children:e})}function Xt(){const e=y.useContext(rw);if(!e)throw new Error("useProject must be used within a ProjectProvider");return e}function sw(e,t){const a=new EventSource(e);a.onmessage=o=>{try{t.onOmniMessage(JSON.parse(o.data),o.lastEventId||null)}catch{}},a.addEventListener("server_event",o=>{try{t.onServerEvent(JSON.parse(o.data),o.lastEventId||null)}catch{}}),t.onOpen&&(a.onopen=t.onOpen);const{onError:l}=t;return l&&(a.onerror=()=>l(a.readyState===EventSource.CLOSED)),{close:()=>a.close()}}function AT(e,t){return sw(`/api/sessions/${encodeURIComponent(e)}/stream`,t)}function RT(e){return sw("/api/events",e)}const lw="\0temp-workspaces",_T=/[/\\]workspaces[/\\]tmp-[0-9a-f]{8}$/;function IT(e){const t=e.trim();return t===""||_T.test(t)}function nd(e){return IT(e)?lw:e.trim()}function LT(e){const t=e.trim().split(/[/\\]+/).filter(Boolean);return t[t.length-1]??"/"}const pl=10,Tu=10;function Qp(e,t){return e.length>t?{items:e.slice(0,t),hasMore:!0}:{items:e,hasMore:!1}}function fr(e){return e.archived?"archived":e.source==="subagent"||e.source==="schedule"?e.source:"active"}const lc=["subagent","schedule","archived"];function Wv(e){const t={active:[],subagent:[],schedule:[],archived:[]};for(const a of e)t[fr(a)].push(a);return t}const OT=["active",...lc];function iw(e){const t=new Map;for(const[a,l]of e)for(const[o,c]of Object.entries(l)){const u=nd(o);let f=t.get(u);f||(f={totals:{active:0,subagent:0,schedule:0,archived:0},agents:{active:[],subagent:[],schedule:[],archived:[]}},t.set(u,f));for(const p of OT){const h=c[p];h>0&&(f.totals[p]+=h,f.agents[p].includes(a)||f.agents[p].push(a))}}return t}function ow(e){let t=null;for(const a of e){const l=fr(a);l!=="active"&&l!=="schedule"||(!t||a.createdAt>t.createdAt||a.createdAt===t.createdAt&&a.sessionId>t.sessionId)&&(t=a)}return t}function cw(e){const t=new Map;for(const o of e){const c=nd(o.workspace);let u=t.get(c);if(!u){const f=c===lw;u={key:c,label:f?"":LT(o.workspace),fullPath:f?null:o.workspace.trim(),temp:f,sessions:[]},t.set(c,u)}u.sessions.push(o)}const a=(o,c)=>o<c?1:o>c?-1:0,l=[...t.values()];for(const o of l)o.sessions.sort((c,u)=>a(c.createdAt,u.createdAt));return l.sort((o,c)=>o.temp!==c.temp?o.temp?1:-1:a(o.sessions[0]?.createdAt??"",c.sessions[0]?.createdAt??"")),l}function Xp(e,t,a){if(a.size===0)return[...e];const l=[],o=[];for(const c of e)(a.has(t(c))?l:o).push(c);return[...l,...o]}const uw=y.createContext(null),As=(e,t)=>`${e}\0${t}`;function DT({children:e}){const{currentProject:t,agents:a}=Xt(),l=t?.projectId??null,o=a.map(X=>X.agentId).join(","),[c,u]=y.useState([]),[f,p]=y.useState(new Map),[h,g]=y.useState(new Map),[v,k]=y.useState(new Map),[w,j]=y.useState(!0),[E,C]=y.useState(!1);y.useEffect(()=>{let X=!1;return Ph().then(T=>{!X&&T.prefs.showCliSessions===!0&&C(!0)}).catch(()=>{}),()=>{X=!0}},[]);const M=y.useCallback(X=>{C(X),jd({showCliSessions:X}).catch(()=>{})},[]),_=y.useRef(0),D=y.useRef([]);D.current=c;const V=y.useRef(f);V.current=f;const F=y.useRef(h);F.current=h;const A=y.useCallback(async()=>{const X=o===""?[]:o.split(",");if(!l||X.length===0)return;const T=++_.current;j(!0);try{const R=await Promise.all(X.map(async de=>{const me=["active",...lc.filter(ye=>V.current.has(As(de,ye)))];try{const ye=await Promise.all(me.map(async te=>{const be=await Fp(l,de,{offset:0,limit:pl+1,category:te,...te==="active"?{withCounts:!0}:{},...E?{cli:!0}:{}});return{category:te,counts:be.counts,workspaceCounts:be.workspaceCounts,...Qp(be.sessions,pl)}}));return{agentId:de,pages:ye}}catch{return{agentId:de,pages:[]}}}));if(T!==_.current)return;const H=[],S=new Set,U=new Map,ee=new Map,ie=new Map;for(const de of R)for(const me of de.pages){U.set(As(de.agentId,me.category),{hasMore:me.hasMore,fetched:me.items.length}),me.counts&&ee.set(de.agentId,me.counts),me.workspaceCounts&&ie.set(de.agentId,me.workspaceCounts);for(const ye of me.items)S.has(ye.sessionId)||(S.add(ye.sessionId),H.push(ye))}u(H),p(U),g(ee),k(ie)}finally{T===_.current&&j(!1)}},[l,o,E]);y.useEffect(()=>{u([]),V.current=new Map,p(V.current),g(new Map),k(new Map),A()},[A]);const P=y.useCallback(async(X,T)=>{if(!l)return;const R=[...new Set(X)].filter(ee=>{const ie=V.current.get(As(ee,T));return ie===void 0?(F.current.get(ee)?.[T]??0)>0:ie.hasMore});if(R.length===0)return;const H=_.current,S=await Promise.all(R.map(async ee=>{const ie=V.current.get(As(ee,T))?.fetched??0;try{const de=(await Fp(l,ee,{offset:ie,limit:pl+1,category:T,...E?{cli:!0}:{}})).sessions;return{agentId:ee,...Qp(de,pl)}}catch{return null}}));if(H!==_.current)return;const U=S.filter(ee=>ee!==null);u(ee=>{const ie=new Set(ee.map(me=>me.sessionId)),de=U.flatMap(me=>me.items.filter(ye=>!ie.has(ye.sessionId)));return de.length>0?[...ee,...de]:ee}),p(ee=>{const ie=new Map(ee);for(const de of U){const me=As(de.agentId,T);ie.set(me,{hasMore:de.hasMore,fetched:(ee.get(me)?.fetched??0)+de.items.length})}return ie})},[l,E]),Q=y.useCallback((X,T)=>f.has(As(X,T)),[f]),K=y.useCallback((X,T)=>{const R=f.get(As(X,T));return R!==void 0?R.hasMore:(h.get(X)?.[T]??0)>0},[f,h]),O=y.useCallback((X,T,R)=>{const{agentId:H,workspace:S}=X;g(U=>{const ee=U.get(H);if(!ee)return U;const ie=new Map(U);return ie.set(H,{...ee,[T]:Math.max(0,ee[T]+R)}),ie}),k(U=>{const ee=U.get(H);if(!ee)return U;const ie=ee[S]??{active:0,subagent:0,schedule:0,archived:0},de=new Map(U);return de.set(H,{...ee,[S]:{...ie,[T]:Math.max(0,ie[T]+R)}}),de})},[]),z=y.useRef(A);z.current=A;const I=y.useRef(l);I.current=l,y.useEffect(()=>{const X=RT({onOmniMessage:()=>{},onServerEvent:T=>{T.type==="schedule_fired"&&T.projectId===I.current&&z.current()}});return()=>X.close()},[]);const B=y.useCallback(X=>{_.current+=1,!D.current.some(R=>R.sessionId===X.sessionId)&&V.current.get(As(X.agentId,fr(X)))?.hasMore===!1&&O(X,fr(X),1),u(R=>[X,...R.filter(H=>H.sessionId!==X.sessionId)])},[O]),$=y.useCallback(X=>{_.current+=1;const T=D.current.find(R=>R.sessionId===X);T&&O(T,fr(T),-1),u(R=>R.filter(H=>H.sessionId!==X))},[O]),G=y.useCallback(X=>{const T=D.current.find(R=>R.sessionId===X.sessionId);T&&fr(T)!==fr(X)&&(O(X,fr(T),-1),O(X,fr(X),1)),u(R=>R.map(H=>H.sessionId===X.sessionId?X:H))},[O]),q=y.useCallback((X,T)=>{u(R=>{const H=R.find(S=>S.sessionId===X);return!H||H.status===T?R:R.map(S=>S.sessionId===X?{...S,status:T}:S)})},[]),ae=y.useCallback((X,T)=>{u(R=>R.map(H=>H.sessionId===X?{...H,title:T}:H))},[]),Z=y.useMemo(()=>{const X=new Map;for(const T of c){const R=X.get(T.agentId);R?R.push(T):X.set(T.agentId,[T])}for(const T of X.values())T.sort((R,H)=>H.createdAt.localeCompare(R.createdAt)||H.sessionId.localeCompare(R.sessionId));return{sessions:c,byAgent:X,countsByAgent:h,workspaceCountsByAgent:v,isLoadedFor:Q,hasMoreFor:K,loading:w,reload:A,loadMoreFor:P,add:B,remove:$,replace:G,setStatus:q,setTitle:ae,showCliSessions:E,setShowCliSessions:M}},[c,h,v,Q,K,w,A,P,B,$,G,q,ae,E,M]);return s.jsx(uw.Provider,{value:Z,children:e})}function Bs(){const e=y.useContext(uw);if(!e)throw new Error("useSessions must be used within a SessionsProvider");return e}let rp=null,sp=null,Xu=null,di=null;const Zp=new Set;function Jp(){for(const e of Zp)e()}function zT(e){return e.disabled===!0?{kind:"disabled"}:e.error!==void 0?{kind:"failed"}:e.updateAvailable&&e.latestVersion!==null?{kind:"found",latestVersion:e.latestVersion}:{kind:"up-to-date"}}function Jh(e){const[t,a]=y.useState(rp),[l,o]=y.useState(Xu);return y.useEffect(()=>{const c=()=>{a(rp),o(Xu)};return Zp.add(c),()=>{Zp.delete(c)}},[]),y.useEffect(()=>{if(!e)return;let c=!1;return sp??=BN().then(u=>(rp=u,Jp(),u)),sp.then(u=>{c||a(u)}).catch(()=>{sp=null}),di??=Ok().then(u=>(Xu=u,Jp(),u)),di.then(u=>{c||o(u)}).catch(()=>{di=null}),()=>{c=!0}},[e]),{version:t,update:l}}async function Kv(){const e=Ok(!0).then(t=>(Xu=t,t));di=e;try{return await e}catch(t){throw di===e&&(di=null),t}finally{Jp()}}function UT(e){return e==="running"||e==="compacting"}const $T=1e4;function PT(e=$T){const t=new Map;return{observe(a,l=Date.now()){const o=[],c=new Set;for(const u of a){if(c.has(u.sessionId))continue;c.add(u.sessionId);const f=UT(u.status),p=t.get(u.sessionId);if(p===void 0){t.set(u.sessionId,{active:f,lastFiredAt:null});continue}p.active&&!f&&(p.lastFiredAt===null||l-p.lastFiredAt>=e)&&(o.push(u.sessionId),p.lastFiredAt=l),p.active=f}for(const u of[...t.keys()])c.has(u)||t.delete(u);return o}}}function BT(){const{sessionVia:e}=xn(),{sessions:t}=Bs(),{setCurrentAgentId:a}=Xt(),l=Wn(),o=y.useRef(PT()),c=y.useRef(l);c.current=l;const u=y.useRef(a);u.current=a;const f=e==="desktop";y.useEffect(()=>{if(!f)return;const p=o.current.observe(t.map(h=>({sessionId:h.sessionId,status:h.status})));if(p.length!==0&&!(!document.hidden&&document.hasFocus())&&!(typeof Notification>"u"||Notification.permission!=="granted"))for(const h of p){const g=t.find(w=>w.sessionId===h),v=g?.title??m.chat.defaultSessionTitle,k=g?.agentId??null;try{const w=new Notification(m.notify.taskCompleteTitle,{body:m.notify.taskCompleteBody(v),tag:`penguin-task-${h}`,icon:"/penguin-logo.svg"});w.onclick=()=>{w.close(),window.focus(),k!==null&&u.current(k),c.current(`/chat/${h}`)}}catch{}}},[f,t])}function $n({open:e,size:t=14,className:a=""}){return s.jsx("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,className:`block shrink-0 transition-transform duration-200 ${e?"rotate-90":""} ${a}`,children:s.jsx("path",{d:"M9 5l7 7-7 7"})})}function Jn({d:e,size:t=16}){return s.jsx("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:s.jsx("path",{d:e})})}const eg="M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7z",dw="m6 14 1.45-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.55 6a2 2 0 0 1-1.94 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",fw="M12 3v3m-6 4a6 6 0 0 1 12 0v5a3 3 0 0 1-3 3H9a3 3 0 0 1-3-3v-5zm3 3h.01M15 13h.01",mw="penguin.sidebarGroupMode";function pw(){return localStorage.getItem(mw)==="agent"?"agent":"workspace"}function hw(e){localStorage.setItem(mw,e)}function gw({value:e,onChange:t}){return s.jsx("div",{className:"flex items-center gap-0.5",children:[{value:"workspace",icon:eg,label:m.chat.groupByWorkspace},{value:"agent",icon:fw,label:m.chat.groupByAgent}].map(a=>s.jsx("button",{type:"button",title:a.label,"aria-label":a.label,"aria-pressed":e===a.value,onClick:()=>t(a.value),className:`flex h-6 w-6 shrink-0 items-center justify-center rounded-md transition-colors duration-150 ${e===a.value?"bg-gray-200/70 text-gray-700 dark:bg-gray-800 dark:text-gray-200":"text-gray-400 hover:bg-gray-200/50 hover:text-gray-700 dark:text-gray-500 dark:hover:bg-gray-800/70 dark:hover:text-gray-300"}`,children:s.jsx(Jn,{d:a.icon,size:14})},a.value))})}const xw="flex w-full items-center gap-1 rounded px-1.5 py-1 text-left text-[11px] font-medium text-gray-400 transition-colors duration-150 hover:bg-gray-200/50 dark:text-gray-500 dark:hover:bg-gray-800/50";function fi({label:e,pending:t=!1,onClick:a,className:l}){return s.jsxs("button",{type:"button","aria-label":m.chat.loadMore,disabled:t,onClick:a,className:`${xw}${l?` ${l}`:""} disabled:opacity-60`,children:[s.jsx("span",{className:"w-3","aria-hidden":!0}),t?m.common.loading:e]})}function yw({label:e,open:t,onToggle:a,more:l=!1,pending:o=!1,onMore:c,children:u}){return s.jsxs("div",{className:"mt-1",children:[s.jsxs("button",{type:"button",onClick:a,className:xw,children:[s.jsx($n,{open:t,size:12}),e]}),t&&u,t&&l&&s.jsx(fi,{label:m.chat.loadMore,pending:o,onClick:()=>c?.()})]})}function Uo({open:e,onToggle:t,icon:a,label:l,uppercase:o=!1,count:c,title:u,actions:f}){return s.jsxs("div",{className:"group/header flex items-center gap-0.5 px-1 pb-0.5",children:[s.jsxs("button",{type:"button",onClick:t,"aria-expanded":e,"aria-label":e?m.nav.collapseGroup:m.nav.expandGroup,...u!==void 0?{title:u}:{},className:"flex min-w-0 flex-1 items-center gap-1 self-stretch rounded px-1 py-0.5 text-left transition-colors duration-150 hover:bg-gray-200/50 dark:hover:bg-gray-800/50",children:[a,s.jsx("span",{className:`min-w-0 truncate text-xs font-semibold ${o?"uppercase tracking-wide ":""}text-gray-500 dark:text-gray-400`,children:l}),c!==void 0&&s.jsx("span",{className:"shrink-0 text-[11px] text-gray-400 dark:text-gray-500",children:c}),s.jsx($n,{open:e,size:12,className:"text-gray-400"}),s.jsx("span",{className:"min-w-0 flex-1"})]}),f]})}function Ad({size:e=12,className:t=""}){return s.jsx("svg",{width:e,height:e,viewBox:"0 0 12 12",fill:"none",stroke:"currentColor","aria-hidden":!0,className:`shrink-0 ${t}`,children:s.jsx("path",{d:"M3 4.5l3 3 3-3",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}function vw({size:e=13,className:t=""}){return s.jsx("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","aria-hidden":!0,className:`shrink-0 ${t}`,children:s.jsx("path",{d:"M5 12l4 4L19 6",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}function bw({size:e=13,className:t=""}){return s.jsx("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","aria-hidden":!0,className:`shrink-0 ${t}`,children:s.jsx("path",{d:"M12 4v11m0 0l-5-5m5 5l5-5M4 20h16",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round"})})}function Yv({size:e=13,className:t=""}){return s.jsx("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","aria-hidden":!0,className:`shrink-0 ${t}`,children:s.jsx("path",{d:"M12 15V4m0 0L7 9m5-5l5 5M4 20h16",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round"})})}function tg({onClose:e,className:t="",...a}){return s.jsx("button",{type:"button","aria-label":m.common.close,onClick:e,className:`rounded-md p-1.5 text-gray-400 transition-colors duration-150 hover:bg-gray-100 hover:text-gray-600 dark:hover:bg-gray-800 dark:hover:text-gray-300 ${t}`,...a,children:s.jsx("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor","aria-hidden":!0,children:s.jsx("path",{d:"M2 2l10 10M12 2L2 12",strokeWidth:"1.5",strokeLinecap:"round"})})})}const kw="M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2zM15 12a3 3 0 1 1-6 0 3 3 0 0 1 6 0z",Za={agents:fw,skills:"M2 3h6a4 4 0 0 1 4 4v14a3 3 0 0 0-3-3H2zM22 3h-6a4 4 0 0 0-4 4v14a3 3 0 0 1 3-3h7z",models:"M7 7h10v10H7zM4 10h3m10 0h3M4 14h3m10 0h3M10 4v3m4-3v3m-4 10v3m4-3v3",usage:"M4 20V10m6 10V4m6 16v-7m4 7H2",traces:"M4 6h16M4 12h10M4 18h13",benchmark:"M7 4h10v5a5 5 0 0 1-10 0V4zM7 5H4v1a3 3 0 0 0 3 3m10-4h3v1a3 3 0 0 1-3 3M12 14v4m-4 0h8"};function ww({open:e,side:t="left",title:a,onClose:l,children:o,widthClass:c}){return y.useEffect(()=>{if(!e)return;const u=f=>{f.key==="Escape"&&l()};return window.addEventListener("keydown",u),()=>window.removeEventListener("keydown",u)},[e,l]),e?s.jsxs("div",{className:"fixed inset-0 z-50",children:[s.jsx("div",{className:"anim-fade absolute inset-0 bg-black/45",onMouseDown:l}),s.jsxs("div",{className:`absolute inset-y-0 flex w-[80vw] flex-col bg-white shadow-xl dark:bg-gray-900 ${c??"max-w-xs"} ${t==="left"?"anim-drawer-left left-0 border-r border-gray-200 dark:border-gray-800":"anim-drawer-right right-0 border-l border-gray-200 dark:border-gray-800"}`,children:[s.jsxs("div",{className:"flex shrink-0 items-center justify-between border-b border-gray-200 px-4 py-3 dark:border-gray-800",children:[s.jsx("span",{className:"text-base font-semibold",children:a??""}),s.jsx(tg,{onClose:l})]}),s.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto pb-[env(safe-area-inset-bottom)]",children:o})]})]}):null}function qe({d:e,size:t=13,className:a=""}){return s.jsx("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round",className:`block shrink-0 ${a}`,"aria-hidden":!0,children:s.jsx("path",{d:e})})}function xl(e){const t=e.toFixed(1);return t.endsWith(".0")?t.slice(0,-2):t}function Ct(e){const t=Math.abs(e);return t<1e3?`${e}`:t<1e6?`${xl(e/1e3)}k`:`${xl(e/1e6)}M`}function hn(e,t){if(e<1e3)return`${Math.round(e)}ms`;const a=e/1e3;if(a<60&&!(t?.compact&&a>=10))return`${xl(a)}s`;const l=Math.round(a);return l<60?`${l}s`:`${Math.floor(l/60)}m${l%60}s`}function Sw(e){const t=Math.max(0,Math.floor(e/1e3));return t<60?`${t}s`:`${Math.floor(t/60)}m${t%60}s`}function eh(e,t){return t>0?e/(t/1e3):null}function ad(e){return e==null||!Number.isFinite(e)?"—":`${Math.abs(e)<1e3?xl(e):Ct(e)} tok/s`}function jw(e,t){const a=e+t;return a>0?e/a:null}function ng(e){return e==null||!Number.isFinite(e)?"—":`${Math.round(e*100)}%`}function hr(e,t="USD",a){if(e==null)return"—";const l=t==="CNY"?"¥":"$",o=t==="CNY"?e*7:e;if(o===0)return`${l}0`;const c=Math.abs(o);if(a?.compact&&c<1)return`${l}${Number(o.toPrecision(2))}`;const u=c>=100?0:c>=1?2:4;return`${l}${o.toFixed(u)}`}function Qo(e){return Number.isInteger(e)?`${e}`:e.toFixed(2).replace(/0+$/,"").replace(/\.$/,"")}function Qv(e){return Number(e.toFixed(1))<1024}function Xo(e){if(e<1024)return`${e}B`;const t=e/1024;if(Qv(t))return`${xl(t)}KB`;const a=t/1024;return Qv(a)?`${xl(a)}MB`:`${xl(a/1024)}GB`}function hl(e){return e<10?`0${e}`:`${e}`}function ha(e){const t=new Date(e);return Number.isNaN(t.getTime())?e:`${t.getFullYear()}-${hl(t.getMonth()+1)}-${hl(t.getDate())} ${hl(t.getHours())}:${hl(t.getMinutes())}`}const HT=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function Cw(e,t){const a=/^\d{4}-(\d{2})-(\d{2})(?:$|T)/.exec(e);if(!a)return e;const l=Number(a[1]),o=Number(a[2]);return l<1||l>12||o<1||o>31?e:t==="en"?`${HT[l-1]} ${o}`:`${l} 月 ${o} 日`}function Nw(e,t){const a=new Date(e);return Number.isNaN(a.getTime())?"":a.toLocaleString(t==="en"?"en-US":"zh-CN",{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"})}function rd(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate()).getTime()}function FT(e,t){const a=new Date(e);if(Number.isNaN(a.getTime()))return e;const l=Math.round((rd(new Date)-rd(a))/864e5);return l<0?ha(e):l===0?t==="en"?"today":"今天":l===1?t==="en"?"yesterday":"昨天":t==="en"?`${l} days ago`:`${l} 天前`}function sd(e,t){const a=new Date(e);if(Number.isNaN(a.getTime()))return e;const l=Math.round((rd(new Date)-rd(a))/864e5);return l<0?e:l===0?t==="en"?"updated today":"今天更新":l===1?t==="en"?"updated yesterday":"昨天更新":t==="en"?`updated ${l} days ago`:`${l} 天前更新`}function qT(e){const t=new Date(e);return Number.isNaN(t.getTime())?e:`${hl(t.getHours())}:${hl(t.getMinutes())}:${hl(t.getSeconds())}`}function Ie(e,t){return e instanceof na?e.code==="model_credential_missing"?t?.modelId?m.errors.modelCredentialMissing(t.modelId):e.message:e.code==="no_default_model"?m.errors.noDefaultModel:m.errors.byCode[e.code]??e.message:m.common.unknownError}function wl({checked:e,onChange:t,disabled:a,className:l,...o}){return s.jsx("button",{type:"button",role:"switch","aria-checked":e,disabled:a,onClick:()=>t(!e),className:"relative inline-flex h-5 w-9 shrink-0 items-center rounded-full inset-ring inset-ring-black/10 dark:inset-ring-white/10 transition-colors duration-200 ease-out focus:outline-none focus-visible:ring-2 focus-visible:ring-[var(--accent-bg)]/40 disabled:cursor-not-allowed disabled:opacity-60 "+(e?"bg-[var(--accent-bg)]":"bg-gray-200 dark:bg-gray-700")+` ${l??""}`,...o,children:s.jsx("span",{"aria-hidden":!0,className:`inline-block size-4 rounded-full border border-black/10 bg-white transition-transform duration-200 ease-out ${e?"translate-x-[18px]":"translate-x-0.5"}`})})}var bi=yk();const Zo=[];function Tw(){const e=Symbol("esc-layer");return Zo.push(e),e}function Mw(e){const t=Zo.lastIndexOf(e);t!==-1&&Zo.splice(t,1)}function Ew(e){return Zo[Zo.length-1]===e}function Gt({open:e,title:t,onClose:a,children:l,footer:o,widthClass:c,headerless:u}){return y.useEffect(()=>{if(!e)return;const f=Tw(),p=h=>{h.key==="Escape"&&Ew(f)&&a()};return window.addEventListener("keydown",p),()=>{window.removeEventListener("keydown",p),Mw(f)}},[e,a]),e?bi.createPortal(s.jsx("div",{className:"anim-fade fixed inset-0 z-50 flex items-end justify-center bg-black/45 p-0 sm:items-center sm:p-4",onMouseDown:f=>{f.target===f.currentTarget&&a()},children:s.jsxs("div",{...u?{role:"dialog","aria-label":t}:{},className:`anim-pop w-full ${c??"sm:max-w-md"} rounded-t-lg border border-gray-200 bg-white pb-[env(safe-area-inset-bottom)] shadow-xl sm:rounded-lg sm:pb-0 dark:border-gray-800 dark:bg-gray-900`,children:[!u&&s.jsxs("div",{className:"flex items-center justify-between border-b border-gray-200 px-4 py-3 dark:border-gray-800",children:[s.jsx("h2",{className:"text-base font-semibold",children:t}),s.jsx(tg,{onClose:a})]}),s.jsx("div",{className:"max-h-[70vh] overflow-y-auto px-4 py-4",children:l}),o&&s.jsx("div",{className:"flex justify-end gap-2 border-t border-gray-200 px-4 py-3 dark:border-gray-800",children:o})]})}),document.body):null}const Mu=4,vo=8;function ga({button:e,open:t,setOpen:a,children:l,menuClass:o,menuStyle:c,className:u,portal:f,onEscape:p}){const h=y.useRef(null),g=y.useRef(null),[v,k]=y.useState(null),w=y.useRef(a);w.current=a;const j=y.useRef(p);j.current=p,y.useEffect(()=>{if(!t)return;const M=V=>{const F=V.target;h.current?.contains(F)||g.current?.contains(F)||w.current(!1)},_=Tw(),D=V=>{if(V.key!=="Escape"||!Ew(_))return;const F=j.current;F?F():w.current(!1)};return window.addEventListener("mousedown",M),window.addEventListener("keydown",D),()=>{Mw(_),window.removeEventListener("mousedown",M),window.removeEventListener("keydown",D)}},[t]);const E=y.useCallback(()=>{if(!t||!f||!h.current){k(null);return}const M=h.current.getBoundingClientRect(),_=g.current,D=_?.offsetWidth??0,V=_?.offsetHeight??0,F=f.align==="right"?M.right-D:M.left,A=Math.max(vo,Math.min(F,window.innerWidth-D-vo)),P=window.innerHeight-M.bottom-Mu-vo,Q=M.top-Mu-vo,K=f.direction==="up",z=(K?V<=Q:V<=P)?K:Q>P;k({left:A,maxHeight:Math.max(0,z?Q:P),...z?{bottom:window.innerHeight-M.top+Mu}:{top:M.bottom+Mu}})},[t,f?.direction,f?.align,l]);y.useLayoutEffect(E,[E]),y.useEffect(()=>{if(!t||!f)return;const M=_=>{g.current?.contains(_.target)||E()};return window.addEventListener("scroll",M,!0),window.addEventListener("resize",E),()=>{window.removeEventListener("scroll",M,!0),window.removeEventListener("resize",E)}},[t,f,E]);const C=`anim-pop ${f?"z-[60]":"z-40"} overflow-y-auto rounded-md border border-gray-200 bg-white py-1 shadow-lg dark:border-gray-700 dark:bg-gray-900 ${f?"":"max-h-[70vh]"} ${o??"left-0 top-full mt-1 w-64 max-w-[calc(100vw-2rem)] origin-top-left"}`;return s.jsxs("div",{className:`relative ${u??""}`,ref:h,children:[e,t&&(f?bi.createPortal(s.jsx("div",{ref:g,style:{position:"fixed",...v?{left:v.left,maxHeight:v.maxHeight,...v.top!==void 0?{top:v.top}:{},...v.bottom!==void 0?{bottom:v.bottom}:{}}:{left:0,top:0,visibility:"hidden"},maxWidth:`calc(100vw - ${vo*2}px)`,...c},className:C,children:l}),document.body):s.jsx("div",{ref:g,...c!==void 0?{style:c}:{},className:`absolute ${C}`,children:l}))]})}function VT(e){let t=2166136261;for(let a=0;a<e.length;a++)t^=e.charCodeAt(a),t=Math.imul(t,16777619);return t>>>0}function GT(e){return VT(e)%360}function Aw(e){const t=GT(e);return{bg:`hsl(${t} 55% 50% / 0.14)`,fg:`hsl(${t} 55% 28%)`,fgDark:`hsl(${t} 55% 73%)`}}const Xv=typeof Intl<"u"&&typeof Intl.Segmenter=="function"?new Intl.Segmenter(void 0,{granularity:"grapheme"}):void 0;function Zv(e){if(e){if(!Xv)return Array.from(e)[0];for(const t of Xv.segment(e))return t.segment}}function Rw(e,t){const a=Zv(e.trim())??Zv((t??"").trim());return a?a.toUpperCase():"?"}function xa({id:e,name:t,size:a=18,className:l}){const o=Aw(e);return s.jsxs("svg",{width:a,height:a,viewBox:"0 0 24 24",className:l,style:{"--tile-fg":o.fg,"--tile-fg-dark":o.fgDark},"aria-hidden":!0,role:"img",children:[s.jsx("rect",{x:"0",y:"0",width:"24",height:"24",rx:"5",fill:o.bg}),s.jsx("text",{x:"12",y:"12",textAnchor:"middle",dominantBaseline:"central",fontSize:"13",fontWeight:"700",className:"[fill:var(--tile-fg)] dark:[fill:var(--tile-fg-dark)]",children:Rw(t??"",e)})]})}const WT={success:2500,info:4e3,error:6e3};let Xr=[],KT=1;const th=new Set;function nh(){for(const e of th)e(Xr)}const YT=160;function _w(e){const t=Xr.find(a=>a.id===e);!t||t.leaving||(Xr=Xr.map(a=>a.id===e?{...a,leaving:!0}:a),nh(),setTimeout(()=>{Xr=Xr.filter(a=>a.id!==e),nh()},YT))}function ag(e,t){if(!t)return;const a=KT++;Xr=[...Xr,{id:a,kind:e,text:t}],nh(),setTimeout(()=>_w(a),WT[e])}const Et=e=>ag("success",e),Qe=e=>ag("error",e),Mr=e=>ag("info",e),QT={success:"border-emerald-200 bg-emerald-50 text-emerald-800 dark:border-emerald-900 dark:bg-emerald-950 dark:text-emerald-200",error:"border-red-200 bg-red-50 text-red-800 dark:border-red-900 dark:bg-red-950 dark:text-red-200",info:"border-sky-200 bg-sky-50 text-sky-800 dark:border-sky-900 dark:bg-sky-950 dark:text-sky-200"};function XT(){const[e,t]=y.useState(Xr);return y.useEffect(()=>(th.add(t),()=>{th.delete(t)}),[]),e.length===0?null:bi.createPortal(s.jsx("div",{className:"pointer-events-none fixed inset-x-0 top-3 z-[100] flex flex-col items-center gap-2 px-4",children:e.map(a=>s.jsx("button",{type:"button",onClick:()=>_w(a.id),className:`pointer-events-auto max-w-lg break-words rounded-md border px-3 py-2 text-left text-sm shadow-lg ${a.leaving?"anim-toast-out":"anim-toast-in"} ${QT[a.kind]}`,children:a.text},a.id))}),document.body)}function ic({text:e,className:t=""}){const a=y.useRef(null),[l,o]=y.useState(!1);return y.useLayoutEffect(()=>{const c=a.current;if(!c)return;const u=()=>o(c.scrollWidth>c.clientWidth+1);if(u(),typeof ResizeObserver>"u")return;const f=new ResizeObserver(u);return f.observe(c),()=>f.disconnect()},[e,t]),s.jsx("span",{ref:a,className:`truncate ${t}`,...l?{title:e}:{},children:e})}const ZT={gray:"bg-gray-100 text-gray-600 dark:bg-gray-800 dark:text-gray-300",brand:"bg-gray-200/80 text-gray-700 dark:bg-gray-700/60 dark:text-gray-200",green:"bg-emerald-50 text-emerald-700 dark:bg-emerald-950 dark:text-emerald-300",yellow:"bg-yellow-50 text-yellow-700 dark:bg-yellow-950 dark:text-yellow-300",amber:"bg-amber-50 text-amber-700 dark:bg-amber-950 dark:text-amber-300",red:"bg-red-50 text-red-700 dark:bg-red-950 dark:text-red-300"};function gn({tone:e="gray",children:t}){return s.jsx("span",{className:`inline-flex items-center rounded-full px-2 py-0.5 text-[11px] font-semibold ${ZT[e]}`,children:t})}function JT(e){switch(e){case"completed":return"green";case"aborted":return"amber";default:return"red"}}const eM={primary:"bg-[var(--accent-bg)] text-[var(--accent-fg)] border border-[var(--accent-bg)] transition-opacity hover:opacity-90 disabled:opacity-50",secondary:"bg-white text-gray-800 border border-gray-300 hover:bg-gray-50 dark:bg-gray-900 dark:text-gray-200 dark:border-gray-700 dark:hover:bg-gray-800",danger:"bg-white text-red-600 border border-gray-300 hover:border-red-300 hover:bg-red-50 dark:bg-gray-900 dark:text-red-400 dark:border-gray-700 dark:hover:bg-red-950",ghost:"bg-transparent text-gray-600 border border-transparent hover:bg-gray-100 hover:text-gray-900 dark:text-gray-300 dark:hover:bg-gray-800 dark:hover:text-gray-100"},tM={sm:"px-2.5 py-1 text-xs rounded-md",md:"px-3 py-1.5 text-sm rounded-md",icon:"p-1.5 rounded-md"};function we({variant:e="secondary",size:t="md",className:a,...l}){return s.jsx("button",{type:"button",className:`inline-flex items-center justify-center gap-1 font-medium transition-colors duration-150 disabled:cursor-not-allowed disabled:opacity-60 ${eM[e]} ${tM[t]} ${a??""}`,...l})}function nM({tone:e}){const t=e==="danger"?"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3zM12 9v4m0 4h.01":"M12 20h9M16.5 3.5a2.1 2.1 0 0 1 3 3L7 19l-4 1 1-4L16.5 3.5z";return s.jsx("span",{"aria-hidden":!0,className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-full ${e==="danger"?"bg-red-100 text-red-600 dark:bg-red-950/60 dark:text-red-400":"bg-gray-100 text-gray-600 dark:bg-gray-800 dark:text-gray-300"}`,children:s.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round",children:s.jsx("path",{d:t})})})}function Mn({open:e,title:t,onClose:a,onConfirm:l,confirmLabel:o,tone:c="danger",busy:u=!1,children:f}){return s.jsxs(Gt,{open:e,title:t,onClose:a,headerless:!0,widthClass:"sm:max-w-sm",children:[s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx(nM,{tone:c}),s.jsx("div",{className:"min-w-0 flex-1 pt-1.5",children:f})]}),s.jsxs("div",{className:"mt-4 flex justify-end gap-2",children:[s.jsx(we,{size:"sm",onClick:a,disabled:u,children:m.common.cancel}),s.jsx(we,{size:"sm",variant:c,disabled:u,onClick:l,children:o??m.common.confirm})]})]})}function ki(){const[e,t]=y.useState(null),a=s.jsx(Mn,{open:e!==null,title:m.common.confirmSaveTitle,tone:"primary",confirmLabel:m.common.save,onClose:()=>t(null),onConfirm:()=>{e?.(),t(null)},children:s.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-300",children:m.common.confirmSaveBody})});return{requestSave:l=>t(()=>l),element:a}}const Rd="rounded-md border border-gray-300 bg-white text-gray-900 transition-[border-color,box-shadow] duration-200 hover:border-gray-400 focus:border-gray-500 focus:outline-none focus:ring-2 focus:ring-gray-400/30 dark:border-gray-700 dark:bg-gray-900 dark:text-gray-100 dark:hover:border-gray-600 dark:focus:border-gray-400 dark:focus:ring-gray-500/30",Iw="w-full px-3 py-1.5 text-left transition-colors duration-150";function er({children:e,required:t}){return s.jsxs("span",{className:"mb-1 block text-xs font-semibold text-gray-600 dark:text-gray-400",children:[e,t&&s.jsx("span",{className:"ml-0.5 text-red-500 dark:text-red-400","aria-hidden":!0,children:"*"})]})}function ld({children:e}){return s.jsx("span",{className:"mt-1 block text-xs text-gray-500 dark:text-gray-500",children:e})}function Sr({id:e,children:t}){return s.jsx("span",{id:e,role:"alert",className:"mt-1 block text-xs text-red-600 dark:text-red-400",children:t})}function oc({label:e,hint:t,error:a,errorId:l,required:o,children:c}){return!e&&!t&&!a?s.jsx(s.Fragment,{children:c}):s.jsxs("label",{className:"block",children:[e!=null&&e!==""&&s.jsx(er,{required:o,children:e}),c,a?s.jsx(Sr,{id:l,children:a}):t?s.jsx(ld,{children:t}):null]})}const Lw=`w-full ${Rd} placeholder:text-gray-400 disabled:cursor-not-allowed disabled:opacity-60 dark:placeholder:text-gray-500`,_d={base:"px-3 py-2 text-base",sm:"px-2 py-1 text-xs"},Id="!border-red-400 !bg-red-50 hover:!border-red-500 focus:!border-red-500 focus:!ring-red-400/30 dark:!border-red-800 dark:!bg-red-950/40 dark:hover:!border-red-700 dark:focus:!border-red-600";function rg(e,t){return e!==void 0&&e!=="off"?{autoComplete:e}:{autoComplete:t?"new-password":"off","data-1p-ignore":"","data-lpignore":"true","data-bwignore":"","data-form-type":"other"}}const Ld=rg(void 0,!1);function at({label:e,hint:t,error:a,invalid:l,required:o,size:c="base",className:u,autoComplete:f,...p}){const h=!!a||!!l,g=y.useId();return s.jsx(oc,{label:e,hint:t,error:a,errorId:g,required:o,children:s.jsx("input",{className:`${Lw} ${_d[c]} ${h?Id:""} ${u??""}`,"aria-invalid":h?!0:void 0,"aria-required":o||void 0,"aria-describedby":a?g:void 0,...rg(f,p.type==="password"),...p})})}const zn=y.forwardRef(function({label:t,hint:a,error:l,invalid:o,required:c,mono:u,size:f="base",className:p,autoComplete:h,...g},v){const k=!!l||!!o,w=y.useId();return s.jsx(oc,{label:t,hint:a,error:l,errorId:w,required:c,children:s.jsx("textarea",{ref:v,className:`${Lw} px-3 py-2 ${f==="sm"?"text-xs leading-relaxed":"text-base"} ${u?"font-mono":""} ${k?Id:""} ${p??""}`,"aria-invalid":k?!0:void 0,"aria-required":c||void 0,"aria-describedby":l?w:void 0,...rg(h,!1),...g})})});function gl({options:e,value:t,onChange:a,cols:l=3}){return s.jsx("div",{className:`grid ${l===2?"grid-cols-2":"grid-cols-3"} gap-0.5 rounded-md bg-gray-100 p-0.5 dark:bg-gray-800`,children:e.map(o=>s.jsx("button",{type:"button",onClick:()=>a(o.value),className:`rounded px-1 py-1 text-xs transition-colors duration-150 ${t===o.value?"bg-white font-medium text-gray-900 shadow-sm dark:bg-gray-600 dark:text-gray-100":"text-gray-500 hover:text-gray-800 dark:text-gray-400 dark:hover:text-gray-200"}`,children:o.label},o.value))})}function en({className:e}){return s.jsx("div",{className:`animate-pulse rounded bg-gray-200 dark:bg-gray-800 ${e??"h-4 w-full"}`})}function pa({rows:e=3}){return s.jsx("div",{className:"space-y-2 p-2",children:Array.from({length:e},(t,a)=>s.jsx(en,{className:"h-8 w-full"},a))})}function Ow({className:e,children:t}){return s.jsx("div",{className:`rounded-md border border-gray-200 bg-white dark:border-gray-800 dark:bg-gray-900 ${e??"p-4"}`,children:t??s.jsxs(s.Fragment,{children:[s.jsx(en,{className:"h-3 w-20"}),s.jsx(en,{className:"mt-2.5 h-6 w-28"}),s.jsx(en,{className:"mt-2.5 h-3 w-24"})]})})}function Er(e){y.useEffect(()=>{document.title=e?`${e} · ${m.appName}`:m.appName},[e])}var aM=["partial_text","partial_thinking","partial_tool_call","partial_tool_call_output"];function id(e){return aM.includes(e.type??"")}function sg(e){return e.type==="event_msg"}function rM(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function lg(e,t){return`[${e}]
126
- ${t}
127
- [/${e}]`}function cc(e,t,a=""){const l=rM(e);return[new RegExp(`\\[${l}\\]${t}\\[/${l}\\]`,a),new RegExp(`<${l}>${t}</${l}>`,a)]}function Od(e,t){return e[0].exec(t)??e[1].exec(t)}var Cr={summary:"summary",userSteering:"user_steering",useSkills:"use_skills",handoffFrom:"handoff_from",scheduledTask:"scheduled_task",modelSwitchFrom:"model_switch_from"},sM="[attached image: ",lM="[attached file: ",iM=/^\[attached image: (.+)\]$/,oM=/^\[attached file: (.+)\]$/;function cM(e){return iM.exec(e)?.[1]??null}function uM(e){return oM.exec(e)?.[1]??null}cc(Cr.summary,"([\\s\\S]*?)","g");function ah(e,t){if(e.length===0)return t;const a=lg(Cr.useSkills,`skills: ${e.join(", ")}`);return t?`${a}
128
-
129
- ${t}`:a}var dM=cc(Cr.useSkills,"\\nskills: ([^\\n]+)\\n");function Dw(e){const t=Od(dM,e);if(!t||t.index!==0)return null;const a=t[1].split(",").map(l=>l.trim()).filter(l=>l.length>0);return a.length===0?null:{skills:a,rest:e.slice(t[0].length).replace(/^\n+/,"")}}function zw(e){const t=/^([\w-]+) \((.*)\)$/.exec(e);return t?{id:t[1],label:t[2]}:{id:e}}function ig(e,t){const a=new RegExp(`^(${t.join("|")}): (.+)$`),l=[];for(const o of e.split(`
130
- `)){const c=a.exec(o);c&&l.push([c[1],c[2]])}return l}function fM(e){const t=e.agentName&&e.agentName!==e.agentId?` (${e.agentName})`:"",a=[`agent: ${e.agentId}${t}`];if(e.sessionId){const l=e.sessionTitle?` (${e.sessionTitle})`:"";a.push(`session: ${e.sessionId}${l}`)}return e.workspace&&a.push(`workspace: ${e.workspace}`),lg(Cr.handoffFrom,["The user handed this conversation to you from another one; its origin is listed below and the user's message, if any, follows. When the request refers to an agent, session, or files without naming them, it means this origin.",...a].join(`
131
- `))}var mM=cc(Cr.handoffFrom,"\\n([\\s\\S]*)\\n","");function Uw(e){const t=e.trim(),a=Od(mM,t);if(!a||a.index!==0||a[0].length!==t.length)return null;const l={agentId:""};for(const[o,c]of ig(a[1],["agent","session","workspace"])){if(o==="workspace"){l.workspace=c;continue}const{id:u,label:f}=zw(c);o==="agent"?(l.agentId=u,f!==void 0&&(l.agentName=f)):(l.sessionId=u,f!==void 0&&(l.sessionTitle=f))}return l.agentId?l:null}var pM=cc(Cr.scheduledTask,"\\n([\\s\\S]*?)\\n");function $w(e){const t=Od(pM,e);if(!t||t.index!==0)return null;const a={name:"",firedAt:""};for(const[l,o]of ig(t[1],["schedule","fired_at"]))l==="schedule"?a.name=o:a.firedAt=o;return a.name?{origin:a,rest:e.slice(t[0].length).replace(/^\n+/,"")}:null}function hM(e){const t=e.sessionTitle?` (${e.sessionTitle})`:"",a=[`session: ${e.sessionId}${t}`];return e.tracePath&&a.push(`trace: ${e.tracePath}`),e.workspace&&a.push(`workspace: ${e.workspace}`),e.prevModelId&&a.push(`previous_model: ${e.prevModelId}`),e.prevProvider&&a.push(`previous_provider: ${e.prevProvider}`),lg(Cr.modelSwitchFrom,["The user switched models: this conversation continues an earlier conversation, now on a different model. Its origin is listed below and the user's message, if any, follows. The earlier history is NOT in your context — when you need it, read the trace file at the path below (JSONL, one message envelope per line: user/assistant text, tool calls and results).",...a].join(`
132
- `))}var gM=cc(Cr.modelSwitchFrom,"\\n([\\s\\S]*)\\n");function Pw(e){const t=e.trim(),a=Od(gM,t);if(!a||a.index!==0||a[0].length!==t.length)return null;const l={sessionId:""},o=["session","trace","workspace","previous_model","previous_provider"];for(const[c,u]of ig(a[1],o))if(c==="session"){const{id:f,label:p}=zw(u);l.sessionId=f,p!==void 0&&(l.sessionTitle=p)}else c==="trace"?l.tracePath=u:c==="workspace"?l.workspace=u:c==="previous_model"?l.prevModelId=u:l.prevProvider=u;return l.sessionId?l:null}var xM=new RegExp(`^\\[${Cr.userSteering}\\]\\n([\\s\\S]*?)\\n\\[/${Cr.userSteering}\\]\\s*$`);function yM(e){const t=xM.exec(e);return t?t[1]:null}function Bw(e){const t=/^\[goal\]\nround: (\d+)\n[\s\S]*?\n\[\/goal\](?:\n|$)/.exec(e);if(!t)return null;const a=Number(t[1]);return!Number.isInteger(a)||a<=0?null:{round:a,rest:e.slice(t[0].length).replace(/^\n+/,"")}}function Jv(e,t){return t?(e.cacheRead*t.cacheRead+e.cacheWrite*t.cacheWrite+e.output*t.output)/1e6:null}function vM(){return{contextNow:0,contextStale:!1,contextAtLastStats:0,sessionTotal:0,subagentTotal:0,taskTokens:0,taskCacheRead:0,taskCacheWrite:0,taskOutput:0,taskMainOutput:0,taskLlmMs:0,pendingCompactionTokens:0,pendingCompactionCacheRead:0,pendingCompactionCacheWrite:0,pendingCompactionOutput:0,hasUsage:!1,sessionElapsedMs:0,compactionActive:!1}}function eb(e,t){e.subagentTotal=t.subagentTokens,e.sessionElapsedMs=t.elapsedMs,e.sessionTotal=t.sessionTokens,e.contextNow=t.contextTokens,e.contextAtLastStats=t.contextTokens}function Hw(e,t){e.taskCacheRead+=t.request.cache_read,e.taskCacheWrite+=t.request.cache_write,e.taskOutput+=t.request.output}function bM(e,t){if(e.sessionTotal=t.session.total,e.compactionActive){e.pendingCompactionTokens+=t.request.total,e.pendingCompactionCacheRead+=t.request.cache_read,e.pendingCompactionCacheWrite+=t.request.cache_write,e.pendingCompactionOutput+=t.request.output;return}e.taskTokens+=t.request.total,Hw(e,t),e.contextNow=t.request.total,e.contextStale=!1,e.taskMainOutput+=t.request.output,e.hasUsage=!0}function kM(e){e.pendingCompactionTokens!==0&&(e.taskTokens+=e.pendingCompactionTokens,e.taskCacheRead+=e.pendingCompactionCacheRead,e.taskCacheWrite+=e.pendingCompactionCacheWrite,e.taskOutput+=e.pendingCompactionOutput,e.hasUsage=!0,og(e))}function og(e){e.pendingCompactionTokens=0,e.pendingCompactionCacheRead=0,e.pendingCompactionCacheWrite=0,e.pendingCompactionOutput=0}function wM(e,t){t>0&&(e.taskLlmMs+=t)}function SM(e,t){e.taskTokens+=t.request.total,Hw(e,t),e.subagentTotal+=t.request.total,e.hasUsage=!0}function jM(e){e.compactionActive=!0}function CM(e,t){e.compactionActive=!1,t==="completed"&&(e.contextStale=!0)}function NM(e){e.taskTokens=0,e.taskCacheRead=0,e.taskCacheWrite=0,e.taskOutput=0,e.taskMainOutput=0,e.taskLlmMs=0,og(e),e.hasUsage=!1,e.compactionActive=!1}function TM(e,t){if(e.sessionElapsedMs+=t,og(e),!e.hasUsage)return e.taskTokens=0,null;const a={context:e.contextNow,contextDelta:e.contextNow-e.contextAtLastStats,tokens:e.sessionTotal+e.subagentTotal,tokensDelta:e.taskTokens,elapsedMs:e.sessionElapsedMs,elapsedDeltaMs:t,tokensByBucket:{cacheRead:e.taskCacheRead,cacheWrite:e.taskCacheWrite,output:e.taskOutput},outputTps:eh(e.taskMainOutput,e.taskLlmMs)};return e.contextAtLastStats=e.contextNow,e.taskTokens=0,e.taskCacheRead=0,e.taskCacheWrite=0,e.taskOutput=0,e.taskMainOutput=0,e.taskLlmMs=0,e.hasUsage=!1,e.compactionActive=!1,a}function MM(e,t,a,l){const o=t&&a!=null?Math.max(0,l-a):0;return e.sessionElapsedMs+o}function EM(e,t){const a=e.tokensByBucket;return`[${t.stats}] ${t.input} ${Ct(a.cacheRead+a.cacheWrite)}${t.parenOpen}${t.cached} ${Ct(a.cacheRead)}${t.parenClose} · ${t.output} ${Ct(a.output)} · ${ad(e.outputTps)}`}function AM(e){return e==="failed"||e==="timeout"||e==="malformed"}function Fw(e,t){return{items:[],nested:e,meta:null,stats:vM(),openText:null,openThinking:null,pendingText:null,pendingThinking:null,openSteering:null,toolCards:new Map,subagents:new Map,localDecisions:t,pendingDecisions:new Map,pendingDecisionTs:new Map,lastTsMs:0,openRequestBeginMs:null,openApprovalWaitMs:0,lastAuthFailureMs:null,taskOpen:!1,taskStartLocalMs:0,taskFirstTsMs:0,taskLastTsMs:0,taskLastReqEndMs:null,nextItemId:1}}function Lo(e=new Set){return Fw(!1,e)}function RM(e,t){return e===null?!1:t===null||e>t}function ea(e){return e.nextItemId++}function od(e,t,a=Date.now()){if(t.origin&&t.origin.length>0){VM(e,t,a);return}if(_M(t)||(e.openSteering=null),t.type==="model_msg"){if(e.stats.compactionActive){Xa(e,t.timestamp),lp(e,t.timestamp);return}if(id(t.payload)){Xa(e,t.timestamp),$M(e,t.payload,dr(t.timestamp));return}PM(e,t.payload,t.timestamp,a),lp(e,t.timestamp);return}if(sg(t)){Xa(e,t.timestamp),BM(e,t.payload,dr(t.timestamp),a),lp(e,t.timestamp);return}if(t.type==="session_meta"&&e.nested){const l=t.payload,o={agentId:IM(l.agent_state),provider:l.provider,modelId:l.model_id};l.source!==void 0&&(o.source=l.source),e.meta=o}}function _M(e){return e.type==="model_msg"&&e.payload.type==="image_url"}function IM(e){const t=e.split(/[\\/]/).filter(a=>a.length>0);return t.length>=2?t[t.length-2]:null}function LM(e,t){const a=t.join("/");for(const l of e)if(l.startsWith(`${a} `)||l.startsWith(`${a}/`))return!0;return!1}function dr(e){const t=Date.parse(e);return Number.isFinite(t)?t:void 0}function lp(e,t){const a=Date.parse(t);Number.isFinite(a)&&(e.lastTsMs=a)}function tb(e,t,a=Date.now(),l=null){for(const o of t)od(e,o,a);if(e.taskOpen){const o=e.taskLastTsMs-e.taskFirstTsMs,c=l===null?0:l-e.taskFirstTsMs;e.taskStartLocalMs=a-Math.max(0,o,c)}}function OM(e){cg(e)}function nb(e){cg(e)}function DM(e,t){e.localDecisions.add(t)}function pi(e,t){return`${e?.join("/")??""} ${t}`}function zM(e,t,a){let l=e;for(const o of t??[])if(l=l.subagents.get(o),!l)return null;return l.toolCards.get(a)??null}function Xa(e,t){if(!e.taskOpen||e.stats.compactionActive)return;const a=Date.parse(t);!Number.isFinite(a)||a<=e.taskLastTsMs||(e.taskLastTsMs=a)}function ab(e,t,a){cg(e);const l=ih(e);l&&(l.gaveUp=!0),e.openRequestBeginMs=null,e.openApprovalWaitMs=0,e.taskOpen=!0,e.taskStartLocalMs=a;const o=Date.parse(t);e.taskFirstTsMs=Number.isFinite(o)?o:a,e.taskLastTsMs=e.taskFirstTsMs,e.taskLastReqEndMs=null,NM(e.stats)}function cg(e){if(!e.taskOpen)return;e.taskOpen=!1,qw(e);const t=e.taskLastReqEndMs??e.taskLastTsMs,a=Math.max(0,t-e.taskFirstTsMs),l=TM(e.stats,a);if(e.nested)return;const o=UM(e);if(l===null&&o.text==="")return;const c={kind:"task_stats",id:ea(e),stats:l,assistantText:o.text,...o.atMs!==void 0?{atMs:o.atMs}:{}};let u=e.items.length;for(;u>0&&e.items[u-1].kind==="compaction";)u--;e.items.splice(u,0,c)}function UM(e){const t=[];let a;for(let l=e.items.length-1;l>=0;l--){const o=e.items[l];if(o.kind==="task_stats")break;o.kind==="assistant_text"&&o.text.trim()&&(t.push(o.text),a===void 0&&(a=o.atMs))}return{text:t.reverse().join(`
133
-
134
- `),...a!==void 0?{atMs:a}:{}}}function $M(e,t,a){switch(t.type){case"partial_text":{if(t.event_type==="start"){e.pendingText=null;const o={kind:"assistant_text",id:ea(e),text:t.text??"",streaming:!0,...a!==void 0?{atMs:a}:{}};e.openText=o,e.items.push(o);return}const l=e.openText;if(!l)return;t.text&&(l.text+=t.text),t.event_type==="stop"&&(l.streaming=!1,t.stop_reason!==void 0&&(l.stopReason=t.stop_reason),e.pendingText=l,e.openText=null);return}case"partial_thinking":{if(t.event_type==="start"){e.pendingThinking=null;const o={kind:"thinking",id:ea(e),thinking:t.thinking??"",streaming:!0};a!==void 0&&(o.startedAtMs=a),e.openThinking=o,e.items.push(o);return}const l=e.openThinking;if(!l)return;t.thinking&&(l.thinking+=t.thinking),t.event_type==="stop"&&(l.streaming=!1,t.stop_reason!==void 0&&(l.stopReason=t.stop_reason),rh(l,a),e.pendingThinking=l,e.openThinking=null);return}case"partial_tool_call":{const l=e.toolCards.get(t.tool_call_id);if(l?.callComplete)return;if(t.event_type==="start"){if(l){l.name=t.name||l.name,l.argumentsText=t.arguments??"",l.callStreaming=!0,a!==void 0&&l.argStartedAtMs===void 0&&(l.argStartedAtMs=a);return}const o=lh(e,{toolCallId:t.tool_call_id,name:t.name,argumentsText:t.arguments??"",callStreaming:!0});a!==void 0&&(o.argStartedAtMs=a);return}if(!l)return;t.name&&!l.name&&(l.name=t.name),t.arguments&&(l.argumentsText+=t.arguments),t.event_type==="stop"&&(l.callStreaming=!1,t.stop_reason!==void 0&&(l.callStopReason=t.stop_reason),a!==void 0&&(l.callStartedAtMs=a));return}case"partial_tool_call_output":{const l=e.toolCards.get(t.tool_call_id);if(!l||l.outputComplete)return;if(t.event_type==="start"){l.outputStreaming=!0,t.output&&(l.output+=t.output),t.images&&t.images.length>0&&(l.images=t.images);return}if(!l.outputStreaming)return;t.output&&(l.output+=t.output),t.images&&t.images.length>0&&(l.images=t.images),t.event_type==="stop"&&(l.outputStreaming=!1,t.stop_reason!==void 0&&(l.outputStopReason=t.stop_reason),Vw(l,a));return}}}function PM(e,t,a,l){switch(t.type){case"text":{if(t.role==="user"){if(t.text.startsWith("[context_summary]")||t.text.startsWith("<context_summary>")){Xa(e,a);return}const f=yM(t.text);if(f!==null){Xa(e,a);const h=dr(a),g={kind:"user_steering",id:ea(e),text:f,...h!==void 0?{atMs:h}:{}};e.items.push(g),e.openSteering=g;return}ab(e,a,l);const p=dr(a);e.items.push({kind:"user_text",id:ea(e),text:t.text,...p!==void 0?{atMs:p}:{}});return}Xa(e,a);const o=e.pendingText??e.openText;if(o){if(!t.text.trim()){$o(e,o),o===e.openText&&(e.openText=null),e.pendingText=null;return}o.text=t.text,o.streaming=!1;const f=dr(a);f!==void 0&&(o.atMs=f),t.stop_reason!==void 0&&(o.stopReason=t.stop_reason),o===e.openText&&(e.openText=null),e.pendingText=null;return}if(!t.text.trim())return;const c=dr(a),u={kind:"assistant_text",id:ea(e),text:t.text,streaming:!1,...c!==void 0?{atMs:c}:{}};t.stop_reason!==void 0&&(u.stopReason=t.stop_reason),e.items.push(u);return}case"image_url":{if(e.openSteering){Xa(e,a),e.openSteering.images=[...e.openSteering.images??[],t.image_url];return}ab(e,a,l);const o=dr(a);e.items.push({kind:"user_image",id:ea(e),imageUrl:t.image_url,...o!==void 0?{atMs:o}:{}});return}case"thinking":{Xa(e,a);const o=dr(a),c=e.pendingThinking??e.openThinking;if(c){if(!t.thinking.trim()){$o(e,c),c===e.openThinking&&(e.openThinking=null),e.pendingThinking=null;return}c.thinking=t.thinking,c.streaming=!1,t.stop_reason!==void 0&&(c.stopReason=t.stop_reason),rh(c,o),c===e.openThinking&&(e.openThinking=null),e.pendingThinking=null;return}if(!t.thinking.trim())return;const u={kind:"thinking",id:ea(e),thinking:t.thinking,streaming:!1};t.stop_reason!==void 0&&(u.stopReason=t.stop_reason),e.lastTsMs>0&&(u.startedAtMs=e.lastTsMs),rh(u,o),e.items.push(u);return}case"tool_call":{Xa(e,a);const o=dr(a),c=e.toolCards.get(t.tool_call_id),u=c?.callComplete?void 0:c;if(u){u.name=t.name,u.argumentsText=t.arguments,u.callStreaming=!1,u.callComplete=!0,t.stop_reason!==void 0&&(u.callStopReason=t.stop_reason),o!==void 0&&(u.callStartedAtMs=o),sh(e,u),rb(u);return}c&&!c.outputComplete&&(c.outputComplete=!0,c.outputStreaming=!1,c.outputStopReason??="aborted");const f=lh(e,{toolCallId:t.tool_call_id,name:t.name,argumentsText:t.arguments,callStreaming:!1});f.callComplete=!0,t.stop_reason!==void 0&&(f.callStopReason=t.stop_reason),o!==void 0&&(f.callStartedAtMs=o),sh(e,f),e.lastTsMs>0&&(f.argStartedAtMs=e.lastTsMs),rb(f);return}case"tool_call_output":{Xa(e,a);let o=e.toolCards.get(t.tool_call_id);o||(o=lh(e,{toolCallId:t.tool_call_id,name:"",argumentsText:"",callStreaming:!1})),o.output=t.output,t.images&&t.images.length>0&&(o.images=t.images),o.outputStreaming=!1,o.outputComplete=!0,t.stop_reason!==void 0&&(o.outputStopReason=t.stop_reason),Vw(o,dr(a));return}case"inline_data":case"inline_thinking":Xa(e,a);return}}function qw(e){for(const t of e.toolCards.values())t.callComplete&&!t.outputComplete&&(t.outputComplete=!0,t.outputStreaming=!1,t.outputStopReason??="aborted")}function rb(e){!e.callStopReason||e.callStopReason==="completed"||e.outputComplete||(e.outputComplete=!0,e.outputStreaming=!1,e.outputStopReason??=e.callStopReason)}function rh(e,t){t===void 0||e.startedAtMs===void 0||(e.durationMs=Math.max(0,t-e.startedAtMs))}function Vw(e,t){if(t===void 0)return;const a=e.approvalAtMs??e.callStartedAtMs;if(a===void 0)return;const l=e.argStartedAtMs!==void 0&&e.callStartedAtMs!==void 0?Math.max(0,e.callStartedAtMs-e.argStartedAtMs):0;e.durationMs=l+Math.max(0,t-a)}function sh(e,t){if(t.approvalWaitCounted)return;const{callStartedAtMs:a,approvalAtMs:l}=t;if(a===void 0||l===void 0)return;t.approvalWaitCounted=!0;const o=l-a;o>0&&(e.openApprovalWaitMs+=o)}function lh(e,t){const a={kind:"tool_call",id:ea(e),toolCallId:t.toolCallId,name:t.name,argumentsText:t.argumentsText,callStreaming:t.callStreaming,callComplete:!1,output:"",outputStreaming:!1,outputComplete:!1},l=e.pendingDecisions.get(t.toolCallId);if(l!==void 0){a.decision=l,a.decisionSource=e.localDecisions.has(t.toolCallId)?"manual":"remote",e.pendingDecisions.delete(t.toolCallId);const o=e.pendingDecisionTs.get(t.toolCallId);o!==void 0&&(a.approvalAtMs=o,e.pendingDecisionTs.delete(t.toolCallId))}return e.toolCards.set(t.toolCallId,a),e.items.push(a),a}function BM(e,t,a,l){switch(t.type){case"approval_decision":{const o=e.toolCards.get(t.tool_call_id);o?(o.decision=t.decision,o.decisionSource=e.localDecisions.has(t.tool_call_id)?"manual":"remote",a!==void 0&&o.approvalAtMs===void 0&&(o.approvalAtMs=a),sh(e,o)):(e.pendingDecisions.set(t.tool_call_id,t.decision),a!==void 0&&e.pendingDecisionTs.set(t.tool_call_id,a));return}case"abort":{qw(e);const o=ih(e);o&&(o.gaveUp=!0);const c={kind:"abort",id:ea(e)};t.reason!=null&&(c.reason=t.reason),e.items.push(c);return}case"token_usage":bM(e.stats,t);return;case"mcp_connect_begin":{e.items.push({kind:"mcp_connect",id:ea(e),servers:t.servers,running:!0,...a!==void 0?{beginTsMs:a}:{}});return}case"mcp_connect_end":{const o=HM(e);if(!o)return;o.running=!1,a!==void 0&&o.beginTsMs!==void 0&&(o.durationMs=Math.max(0,a-o.beginTsMs)),t.status==="aborted"&&(o.aborted=!0),o.toolCount=t.results.reduce((u,f)=>u+(f.tools??0),0),o.results=t.results.map(u=>({server:u.server,status:u.status,durationMs:u.duration_ms,...u.tools!==void 0?{tools:u.tools}:{},...u.error!==void 0?{error:u.error.slice(0,500)}:{}}));const c=t.results.filter(u=>u.status==="failed");c.length>0&&(o.failed=c.map(u=>u.server));return}case"tool_list_ready":{const o=FM(e);if(!o)return;const c=t.tools.filter(u=>u.name.startsWith("mcp__"));c.length>0&&(o.tools=c.map(u=>({name:u.name,...u.description!==void 0?{description:u.description}:{}})));return}case"compaction_begin":{jM(e.stats),e.items.push({kind:"compaction",id:ea(e),reason:t.reason,mode:t.mode,running:!0,...a!==void 0?{beginTsMs:a}:{}});return}case"compaction_end":{CM(e.stats,t.status);const o=qM(e);if(o)o.running=!1,o.status=t.status,t.error_message!==void 0&&(o.errorMessage=t.error_message),a!==void 0&&o.beginTsMs!==void 0&&(o.durationMs=Math.max(0,a-o.beginTsMs));else{const c={kind:"compaction",id:ea(e),reason:t.reason,mode:t.mode,running:!1,status:t.status,...t.error_message!==void 0?{errorMessage:t.error_message}:{}};e.items.push(c)}return}case"request_begin":{const o=ih(e);o&&(o.retrying=!0),e.stats.compactionActive||(e.openRequestBeginMs=a??null,e.openApprovalWaitMs=0);return}case"request_end":{if(e.stats.compactionActive)return;if(t.status==="auth"&&(e.lastAuthFailureMs=a??Date.now()),t.status==="completed"&&(e.lastAuthFailureMs=null),e.openRequestBeginMs!==null&&a!==void 0&&wM(e.stats,a-e.openRequestBeginMs-e.openApprovalWaitMs),e.openRequestBeginMs=null,e.openApprovalWaitMs=0,a!==void 0&&(e.taskLastReqEndMs=a),kM(e.stats),AM(t.status)){const o={kind:"reconnect",id:ea(e),status:t.status,attempt:t.attempt??1,retrying:!1};typeof t.retry_in_ms=="number"&&t.retry_in_ms>0&&(o.plannedDelayMs=t.retry_in_ms,o.arrivedAtMs=l??Date.now()),e.items.push(o)}return}}}function HM(e){for(let t=e.items.length-1;t>=0;t-=1){const a=e.items[t];if(a.kind==="mcp_connect"&&a.running)return a}return null}function FM(e){for(let t=e.items.length-1;t>=0;t-=1){const a=e.items[t];if(a.kind==="mcp_connect")return a}return null}function qM(e){for(let t=e.items.length-1;t>=0;t--){const a=e.items[t];if(a.kind==="compaction"&&a.running)return a}return null}function ih(e){for(let t=e.items.length-1;t>=0;t--){const a=e.items[t];if(a.kind==="reconnect")return!a.retrying&&!a.gaveUp?a:null}return null}function VM(e,t,a){const l=t.origin[0];sg(t)&&t.payload.type==="token_usage"&&SM(e.stats,t.payload),Xa(e,t.timestamp);let o=e.subagents.get(l);o||(o=Fw(!0,e.localDecisions),o.firstSeenLocalMs=a,e.subagents.set(l,o),GM(e,l,o)),o.lastActivityLocalMs=a;const c=dr(t.timestamp);c!==void 0&&(o.firstTsMs===void 0&&(o.firstTsMs=c),(o.lastActivityTsMs===void 0||c>o.lastActivityTsMs)&&(o.lastActivityTsMs=c));const u=t.origin.slice(1),f={...t};u.length>0?f.origin=u:delete f.origin,od(o,f,a)}function GM(e,t,a){for(let l=e.items.length-1;l>=0;l--){const o=e.items[l];if(o.kind==="tool_call"&&o.name==="run_subagent"&&!o.subagent&&!o.outputComplete&&o.decision==="allow"){o.subagent=a,o.subagentSessionId=t;return}}e.items.push({kind:"subagent",id:ea(e),sessionId:t,model:a})}function WM(e,t=100){const a=new Set;for(let l=Math.max(0,e.length-t);l<e.length;l++)a.add(JSON.stringify(e[l]));return a}function KM(e,t){return e.has(JSON.stringify(t))}function Gw(e,t){if(t.origin&&t.origin.length>0){const l=e.subagents.get(t.origin[0]);if(!l)return;const o=t.origin.slice(1),c={...t};o.length>0?c.origin=o:delete c.origin,Gw(l,c);return}if(t.type!=="model_msg"||id(t.payload))return;const a=t.payload;switch(a.type){case"text":{if(a.role!=="assistant")return;const l=e.pendingText??e.openText;l&&($o(e,l),l===e.openText&&(e.openText=null),e.pendingText=null);return}case"thinking":{const l=e.pendingThinking??e.openThinking;l&&($o(e,l),l===e.openThinking&&(e.openThinking=null),e.pendingThinking=null);return}case"tool_call":{const l=e.toolCards.get(a.tool_call_id);l&&!l.callComplete&&($o(e,l),e.toolCards.delete(a.tool_call_id));return}case"tool_call_output":{const l=e.toolCards.get(a.tool_call_id);l&&!l.outputComplete&&(l.output="",l.outputStreaming=!1);return}default:return}}function $o(e,t){const a=e.items.indexOf(t);a>=0&&e.items.splice(a,1)}const Un={input:"M12 15V5m0 0L8 9m4-4l4 4M4 19h16",output:"M12 3v10m0 0l-4-4m4 4l4-4M4 19h16",cacheHit:"M12 21a9 9 0 1 0 0-18 9 9 0 0 0 0 18zm0-5a4 4 0 1 0 0-8 4 4 0 0 0 0 8zm0-3a1 1 0 1 0 0-2 1 1 0 0 0 0 2z",toolCalls:"M14.7 6.3a4 4 0 0 0-5 5L4 17v3h3l5.7-5.7a4 4 0 0 0 5-5l-2.5 2.5-2-2 2.5-2.5z",tps:"M5 18a8 8 0 1 1 14 0M12 12l4-3",elapsed:"M12 21a9 9 0 1 0 0-18 9 9 0 0 0 0 18zm0-14v5l3 2",cost:"M12 21a9 9 0 1 0 0-18 9 9 0 0 0 0 18zm0-15v12m2.6-9.3c-.5-.8-1.5-1.2-2.6-1.2-1.5 0-2.7.8-2.7 2 0 2.7 5.4 1.3 5.4 4 0 1.2-1.2 2-2.7 2-1.2 0-2.2-.5-2.7-1.4",copy:"M9 9h9v9a2 2 0 0 1-2 2H9a2 2 0 0 1-2-2V9zM7 15H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h7a2 2 0 0 1 2 2v1",check:"M5 13l4 4L19 7"},YM=1500;function QM(e){navigator.clipboard?.writeText(e)}function XM(){const[e,t]=y.useState(!1);return{copied:e,flash:l=>{QM(l),t(!0),setTimeout(()=>t(!1),YM)}}}const ZM="rounded p-0.5 text-gray-400 transition-colors hover:bg-gray-100 hover:text-gray-600 dark:hover:bg-gray-800 dark:hover:text-gray-300";function uc({text:e,label:t,className:a=ZM,showCopiedText:l=!1}){const{copied:o,flash:c}=XM();return s.jsx("button",{type:"button",title:o?m.common.copied:t,"aria-label":t,onClick:()=>c(typeof e=="function"?e():e),className:a,children:l&&o?s.jsxs("span",{className:"flex items-center gap-1",children:[s.jsx(qe,{d:Un.check}),m.common.copied]}):s.jsx(qe,{d:o?Un.check:Un.copy})})}function Nr({title:e,description:t,action:a}){return s.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 py-12 text-center",children:[s.jsx("p",{className:"text-sm font-medium text-gray-600 dark:text-gray-300",children:e}),t&&s.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-500",children:t}),a&&s.jsx("div",{className:"mt-2",children:a})]})}const Ww=/[/\\]scratchpad[/\\]([^/\\]+)[/\\]([^/\\]+)$/;function JM(e){if(/^https?:\/\//i.test(e))return e;const t=Ww.exec(e);return t?`/api/sessions/${encodeURIComponent(t[1])}/scratchpad/${encodeURIComponent(t[2])}`:null}function cd(e){if(!e.includes(sM)&&!e.includes(lM))return{text:e,images:[],files:[]};const t=[],a=[],l=[];for(const o of e.split(`
135
- `)){const c=o.trim(),u=cM(c),f=u!==null?JM(u):null;if(f){a.push(f);continue}const p=uM(c);if(p!==null&&Ww.test(p)){l.push(p);continue}t.push(o)}return{text:t.join(`
136
- `).replace(/\n+$/,""),images:a,files:l}}function e3(e){const t=e.split(/[/\\]/);return t[t.length-1]||e}function t3(e,t){const a=t||{};return(e[e.length-1]===""?[...e,""]:e).join((a.padRight?" ":"")+","+(a.padLeft===!1?"":" ")).trim()}const n3=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,a3=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,r3={};function sb(e,t){return(r3.jsx?a3:n3).test(e)}const s3=/[ \t\n\f\r]/g;function l3(e){return typeof e=="object"?e.type==="text"?lb(e.value):!1:lb(e)}function lb(e){return e.replace(s3,"")===""}class dc{constructor(t,a,l){this.normal=a,this.property=t,l&&(this.space=l)}}dc.prototype.normal={};dc.prototype.property={};dc.prototype.space=void 0;function Kw(e,t){const a={},l={};for(const o of e)Object.assign(a,o.property),Object.assign(l,o.normal);return new dc(a,l,t)}function oh(e){return e.toLowerCase()}class va{constructor(t,a){this.attribute=a,this.property=t}}va.prototype.attribute="";va.prototype.booleanish=!1;va.prototype.boolean=!1;va.prototype.commaOrSpaceSeparated=!1;va.prototype.commaSeparated=!1;va.prototype.defined=!1;va.prototype.mustUseProperty=!1;va.prototype.number=!1;va.prototype.overloadedBoolean=!1;va.prototype.property="";va.prototype.spaceSeparated=!1;va.prototype.space=void 0;let i3=0;const et=Nl(),Cn=Nl(),ch=Nl(),Me=Nl(),Ht=Nl(),yl=Nl(),Aa=Nl();function Nl(){return 2**++i3}const uh=Object.freeze(Object.defineProperty({__proto__:null,boolean:et,booleanish:Cn,commaOrSpaceSeparated:Aa,commaSeparated:yl,number:Me,overloadedBoolean:ch,spaceSeparated:Ht},Symbol.toStringTag,{value:"Module"})),ip=Object.keys(uh);class ug extends va{constructor(t,a,l,o){let c=-1;if(super(t,a),ib(this,"space",o),typeof l=="number")for(;++c<ip.length;){const u=ip[c];ib(this,ip[c],(l&uh[u])===uh[u])}}}ug.prototype.defined=!0;function ib(e,t,a){a&&(e[t]=a)}function wi(e){const t={},a={};for(const[l,o]of Object.entries(e.properties)){const c=new ug(l,e.transform(e.attributes||{},l),o,e.space);e.mustUseProperty&&e.mustUseProperty.includes(l)&&(c.mustUseProperty=!0),t[l]=c,a[oh(l)]=l,a[oh(c.attribute)]=l}return new dc(t,a,e.space)}const Yw=wi({properties:{ariaActiveDescendant:null,ariaAtomic:Cn,ariaAutoComplete:null,ariaBusy:Cn,ariaChecked:Cn,ariaColCount:Me,ariaColIndex:Me,ariaColSpan:Me,ariaControls:Ht,ariaCurrent:null,ariaDescribedBy:Ht,ariaDetails:null,ariaDisabled:Cn,ariaDropEffect:Ht,ariaErrorMessage:null,ariaExpanded:Cn,ariaFlowTo:Ht,ariaGrabbed:Cn,ariaHasPopup:null,ariaHidden:Cn,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:Ht,ariaLevel:Me,ariaLive:null,ariaModal:Cn,ariaMultiLine:Cn,ariaMultiSelectable:Cn,ariaOrientation:null,ariaOwns:Ht,ariaPlaceholder:null,ariaPosInSet:Me,ariaPressed:Cn,ariaReadOnly:Cn,ariaRelevant:null,ariaRequired:Cn,ariaRoleDescription:Ht,ariaRowCount:Me,ariaRowIndex:Me,ariaRowSpan:Me,ariaSelected:Cn,ariaSetSize:Me,ariaSort:null,ariaValueMax:Me,ariaValueMin:Me,ariaValueNow:Me,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function Qw(e,t){return t in e?e[t]:t}function Xw(e,t){return Qw(e,t.toLowerCase())}const o3=wi({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:yl,acceptCharset:Ht,accessKey:Ht,action:null,allow:null,allowFullScreen:et,allowPaymentRequest:et,allowUserMedia:et,alpha:et,alt:null,as:null,async:et,autoCapitalize:null,autoComplete:Ht,autoFocus:et,autoPlay:et,blocking:Ht,capture:null,charSet:null,checked:et,cite:null,className:Ht,closedBy:null,colorSpace:null,cols:Me,colSpan:Me,command:null,commandFor:null,content:null,contentEditable:Cn,controls:et,controlsList:Ht,coords:Me|yl,crossOrigin:null,data:null,dateTime:null,decoding:null,default:et,defer:et,dir:null,dirName:null,disabled:et,download:ch,draggable:Cn,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:et,formTarget:null,headers:Ht,height:Me,hidden:ch,high:Me,href:null,hrefLang:null,htmlFor:Ht,httpEquiv:Ht,id:null,imageSizes:null,imageSrcSet:null,inert:et,inputMode:null,integrity:null,is:null,isMap:et,itemId:null,itemProp:Ht,itemRef:Ht,itemScope:et,itemType:Ht,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:et,low:Me,manifest:null,max:null,maxLength:Me,media:null,method:null,min:null,minLength:Me,multiple:et,muted:et,name:null,nonce:null,noModule:et,noValidate:et,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:et,optimum:Me,pattern:null,ping:Ht,placeholder:null,playsInline:et,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:et,referrerPolicy:null,rel:Ht,required:et,reversed:et,rows:Me,rowSpan:Me,sandbox:Ht,scope:null,scoped:et,seamless:et,selected:et,shadowRootClonable:et,shadowRootCustomElementRegistry:et,shadowRootDelegatesFocus:et,shadowRootMode:null,shadowRootSerializable:et,shape:null,size:Me,sizes:null,slot:null,span:Me,spellCheck:Cn,src:null,srcDoc:null,srcLang:null,srcSet:null,start:Me,step:null,style:null,tabIndex:Me,target:null,title:null,translate:null,type:null,typeMustMatch:et,useMap:null,value:Cn,width:Me,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:Ht,axis:null,background:null,bgColor:null,border:Me,borderColor:null,bottomMargin:Me,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:et,declare:et,event:null,face:null,frame:null,frameBorder:null,hSpace:Me,leftMargin:Me,link:null,longDesc:null,lowSrc:null,marginHeight:Me,marginWidth:Me,noResize:et,noHref:et,noShade:et,noWrap:et,object:null,profile:null,prompt:null,rev:null,rightMargin:Me,rules:null,scheme:null,scrolling:Cn,standby:null,summary:null,text:null,topMargin:Me,valueType:null,version:null,vAlign:null,vLink:null,vSpace:Me,allowTransparency:null,autoCorrect:null,autoSave:null,credentialless:et,disablePictureInPicture:et,disableRemotePlayback:et,exportParts:yl,part:Ht,prefix:null,property:null,results:Me,security:null,unselectable:null},space:"html",transform:Xw}),c3=wi({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",maskType:"mask-type",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:Aa,accentHeight:Me,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:Me,amplitude:Me,arabicForm:null,ascent:Me,attributeName:null,attributeType:null,azimuth:Me,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:Me,by:null,calcMode:null,capHeight:Me,className:Ht,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:Me,diffuseConstant:Me,direction:null,display:null,dur:null,divisor:Me,dominantBaseline:null,download:et,dx:null,dy:null,edgeMode:null,editable:null,elevation:Me,enableBackground:null,end:null,event:null,exponent:Me,externalResourcesRequired:null,fill:null,fillOpacity:Me,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:yl,g2:yl,glyphName:yl,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:Me,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:Me,horizOriginX:Me,horizOriginY:Me,id:null,ideographic:Me,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:Me,k:Me,k1:Me,k2:Me,k3:Me,k4:Me,kernelMatrix:Aa,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:Me,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskType:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:Me,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:Me,overlineThickness:Me,paintOrder:null,panose1:null,path:null,pathLength:Me,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:Ht,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:Me,pointsAtY:Me,pointsAtZ:Me,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Aa,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Aa,rev:Aa,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Aa,requiredFeatures:Aa,requiredFonts:Aa,requiredFormats:Aa,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:Me,specularExponent:Me,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:Me,strikethroughThickness:Me,string:null,stroke:null,strokeDashArray:Aa,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:Me,strokeOpacity:Me,strokeWidth:null,style:null,surfaceScale:Me,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:Aa,tabIndex:Me,tableValues:null,target:null,targetX:Me,targetY:Me,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:Aa,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:Me,underlineThickness:Me,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:Me,values:null,vAlphabetic:Me,vMathematical:Me,vectorEffect:null,vHanging:Me,vIdeographic:Me,version:null,vertAdvY:Me,vertOriginX:Me,vertOriginY:Me,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:Me,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:Qw}),Zw=wi({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,t){return"xlink:"+t.slice(5).toLowerCase()}}),Jw=wi({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:Xw}),e2=wi({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),u3={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"},d3=/[A-Z]/g,ob=/-[a-z]/g,f3=/^data[-\w.:]+$/i;function m3(e,t){const a=oh(t);let l=t,o=va;if(a in e.normal)return e.property[e.normal[a]];if(a.length>4&&a.slice(0,4)==="data"&&f3.test(t)){if(t.charAt(4)==="-"){const c=t.slice(5).replace(ob,h3);l="data"+c.charAt(0).toUpperCase()+c.slice(1)}else{const c=t.slice(4);if(!ob.test(c)){let u=c.replace(d3,p3);u.charAt(0)!=="-"&&(u="-"+u),t="data"+u}}o=ug}return new o(l,t)}function p3(e){return"-"+e.toLowerCase()}function h3(e){return e.charAt(1).toUpperCase()}const g3=Kw([Yw,o3,Zw,Jw,e2],"html"),dg=Kw([Yw,c3,Zw,Jw,e2],"svg");function x3(e){return e.join(" ").trim()}var ri={},op,cb;function y3(){if(cb)return op;cb=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,t=/\n/g,a=/^\s*/,l=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,o=/^:\s*/,c=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,u=/^[;\s]*/,f=/^\s+|\s+$/g,p=`
137
- `,h="/",g="*",v="",k="comment",w="declaration";function j(C,M){if(typeof C!="string")throw new TypeError("First argument must be a string");if(!C)return[];M=M||{};var _=1,D=1;function V($){var G=$.match(t);G&&(_+=G.length);var q=$.lastIndexOf(p);D=~q?$.length-q:D+$.length}function F(){var $={line:_,column:D};return function(G){return G.position=new A($),K(),G}}function A($){this.start=$,this.end={line:_,column:D},this.source=M.source}A.prototype.content=C;function P($){var G=new Error(M.source+":"+_+":"+D+": "+$);if(G.reason=$,G.filename=M.source,G.line=_,G.column=D,G.source=C,!M.silent)throw G}function Q($){var G=$.exec(C);if(G){var q=G[0];return V(q),C=C.slice(q.length),G}}function K(){Q(a)}function O($){var G;for($=$||[];G=z();)G!==!1&&$.push(G);return $}function z(){var $=F();if(!(h!=C.charAt(0)||g!=C.charAt(1))){for(var G=2;v!=C.charAt(G)&&(g!=C.charAt(G)||h!=C.charAt(G+1));)++G;if(G+=2,v===C.charAt(G-1))return P("End of comment missing");var q=C.slice(2,G-2);return D+=2,V(q),C=C.slice(G),D+=2,$({type:k,comment:q})}}function I(){var $=F(),G=Q(l);if(G){if(z(),!Q(o))return P("property missing ':'");var q=Q(c),ae=$({type:w,property:E(G[0].replace(e,v)),value:q?E(q[0].replace(e,v)):v});return Q(u),ae}}function B(){var $=[];O($);for(var G;G=I();)G!==!1&&($.push(G),O($));return $}return K(),B()}function E(C){return C?C.replace(f,v):v}return op=j,op}var ub;function v3(){if(ub)return ri;ub=1;var e=ri&&ri.__importDefault||function(l){return l&&l.__esModule?l:{default:l}};Object.defineProperty(ri,"__esModule",{value:!0}),ri.default=a;const t=e(y3());function a(l,o){let c=null;if(!l||typeof l!="string")return c;const u=(0,t.default)(l),f=typeof o=="function";return u.forEach(p=>{if(p.type!=="declaration")return;const{property:h,value:g}=p;f?o(h,g,p):g&&(c=c||{},c[h]=g)}),c}return ri}var bo={},db;function b3(){if(db)return bo;db=1,Object.defineProperty(bo,"__esModule",{value:!0}),bo.camelCase=void 0;var e=/^--[a-zA-Z0-9_-]+$/,t=/-([a-z])/g,a=/^[^-]+$/,l=/^-(webkit|moz|ms|o|khtml)-/,o=/^-(ms)-/,c=function(h){return!h||a.test(h)||e.test(h)},u=function(h,g){return g.toUpperCase()},f=function(h,g){return"".concat(g,"-")},p=function(h,g){return g===void 0&&(g={}),c(h)?h:(h=h.toLowerCase(),g.reactCompat?h=h.replace(o,f):h=h.replace(l,f),h.replace(t,u))};return bo.camelCase=p,bo}var ko,fb;function k3(){if(fb)return ko;fb=1;var e=ko&&ko.__importDefault||function(o){return o&&o.__esModule?o:{default:o}},t=e(v3()),a=b3();function l(o,c){var u={};return!o||typeof o!="string"||(0,t.default)(o,function(f,p){f&&p&&(u[(0,a.camelCase)(f,c)]=p)}),u}return l.default=l,ko=l,ko}var w3=k3();const S3=xk(w3),t2=n2("end"),fg=n2("start");function n2(e){return t;function t(a){const l=a&&a.position&&a.position[e]||{};if(typeof l.line=="number"&&l.line>0&&typeof l.column=="number"&&l.column>0)return{line:l.line,column:l.column,offset:typeof l.offset=="number"&&l.offset>-1?l.offset:void 0}}}function j3(e){const t=fg(e),a=t2(e);if(t&&a)return{start:t,end:a}}function Po(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?mb(e.position):"start"in e||"end"in e?mb(e):"line"in e||"column"in e?dh(e):""}function dh(e){return pb(e&&e.line)+":"+pb(e&&e.column)}function mb(e){return dh(e&&e.start)+"-"+dh(e&&e.end)}function pb(e){return e&&typeof e=="number"?e:1}class Kn extends Error{constructor(t,a,l){super(),typeof a=="string"&&(l=a,a=void 0);let o="",c={},u=!1;if(a&&("line"in a&&"column"in a?c={place:a}:"start"in a&&"end"in a?c={place:a}:"type"in a?c={ancestors:[a],place:a.position}:c={...a}),typeof t=="string"?o=t:!c.cause&&t&&(u=!0,o=t.message,c.cause=t),!c.ruleId&&!c.source&&typeof l=="string"){const p=l.indexOf(":");p===-1?c.ruleId=l:(c.source=l.slice(0,p),c.ruleId=l.slice(p+1))}if(!c.place&&c.ancestors&&c.ancestors){const p=c.ancestors[c.ancestors.length-1];p&&(c.place=p.position)}const f=c.place&&"start"in c.place?c.place.start:c.place;this.ancestors=c.ancestors||void 0,this.cause=c.cause||void 0,this.column=f?f.column:void 0,this.fatal=void 0,this.file="",this.message=o,this.line=f?f.line:void 0,this.name=Po(c.place)||"1:1",this.place=c.place||void 0,this.reason=this.message,this.ruleId=c.ruleId||void 0,this.source=c.source||void 0,this.stack=u&&c.cause&&typeof c.cause.stack=="string"?c.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}Kn.prototype.file="";Kn.prototype.name="";Kn.prototype.reason="";Kn.prototype.message="";Kn.prototype.stack="";Kn.prototype.column=void 0;Kn.prototype.line=void 0;Kn.prototype.ancestors=void 0;Kn.prototype.cause=void 0;Kn.prototype.fatal=void 0;Kn.prototype.place=void 0;Kn.prototype.ruleId=void 0;Kn.prototype.source=void 0;const mg={}.hasOwnProperty,C3=new Map,N3=/[A-Z]/g,T3=new Set(["table","tbody","thead","tfoot","tr"]),M3=new Set(["td","th"]),a2="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function E3(e,t){if(!t||t.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const a=t.filePath||void 0;let l;if(t.development){if(typeof t.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");l=z3(a,t.jsxDEV)}else{if(typeof t.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof t.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");l=D3(a,t.jsx,t.jsxs)}const o={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:l,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:a,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space==="svg"?dg:g3,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},c=r2(o,e,void 0);return c&&typeof c!="string"?c:o.create(e,o.Fragment,{children:c||void 0},void 0)}function r2(e,t,a){if(t.type==="element")return A3(e,t,a);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return R3(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return I3(e,t,a);if(t.type==="mdxjsEsm")return _3(e,t);if(t.type==="root")return L3(e,t,a);if(t.type==="text")return O3(e,t)}function A3(e,t,a){const l=e.schema;let o=l;t.tagName.toLowerCase()==="svg"&&l.space==="html"&&(o=dg,e.schema=o),e.ancestors.push(t);const c=l2(e,t.tagName,!1),u=U3(e,t);let f=hg(e,t);return T3.has(t.tagName)&&(f=f.filter(function(p){return typeof p=="string"?!l3(p):!0})),s2(e,u,c,t),pg(u,f),e.ancestors.pop(),e.schema=l,e.create(t,c,u,a)}function R3(e,t){if(t.data&&t.data.estree&&e.evaluater){const l=t.data.estree.body[0];return l.type,e.evaluater.evaluateExpression(l.expression)}Jo(e,t.position)}function _3(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);Jo(e,t.position)}function I3(e,t,a){const l=e.schema;let o=l;t.name==="svg"&&l.space==="html"&&(o=dg,e.schema=o),e.ancestors.push(t);const c=t.name===null?e.Fragment:l2(e,t.name,!0),u=$3(e,t),f=hg(e,t);return s2(e,u,c,t),pg(u,f),e.ancestors.pop(),e.schema=l,e.create(t,c,u,a)}function L3(e,t,a){const l={};return pg(l,hg(e,t)),e.create(t,e.Fragment,l,a)}function O3(e,t){return t.value}function s2(e,t,a,l){typeof a!="string"&&a!==e.Fragment&&e.passNode&&(t.node=l)}function pg(e,t){if(t.length>0){const a=t.length>1?t:t[0];a&&(e.children=a)}}function D3(e,t,a){return l;function l(o,c,u,f){const h=Array.isArray(u.children)?a:t;return f?h(c,u,f):h(c,u)}}function z3(e,t){return a;function a(l,o,c,u){const f=Array.isArray(c.children),p=fg(l);return t(o,c,u,f,{columnNumber:p?p.column-1:void 0,fileName:e,lineNumber:p?p.line:void 0},void 0)}}function U3(e,t){const a={};let l,o;for(o in t.properties)if(o!=="children"&&mg.call(t.properties,o)){const c=P3(e,o,t.properties[o]);if(c){const[u,f]=c;e.tableCellAlignToStyle&&u==="align"&&typeof f=="string"&&M3.has(t.tagName)?l=f:a[u]=f}}if(l){const c=a.style||(a.style={});c[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=l}return a}function $3(e,t){const a={};for(const l of t.attributes)if(l.type==="mdxJsxExpressionAttribute")if(l.data&&l.data.estree&&e.evaluater){const c=l.data.estree.body[0];c.type;const u=c.expression;u.type;const f=u.properties[0];f.type,Object.assign(a,e.evaluater.evaluateExpression(f.argument))}else Jo(e,t.position);else{const o=l.name;let c;if(l.value&&typeof l.value=="object")if(l.value.data&&l.value.data.estree&&e.evaluater){const f=l.value.data.estree.body[0];f.type,c=e.evaluater.evaluateExpression(f.expression)}else Jo(e,t.position);else c=l.value===null?!0:l.value;a[o]=c}return a}function hg(e,t){const a=[];let l=-1;const o=e.passKeys?new Map:C3;for(;++l<t.children.length;){const c=t.children[l];let u;if(e.passKeys){const p=c.type==="element"?c.tagName:c.type==="mdxJsxFlowElement"||c.type==="mdxJsxTextElement"?c.name:void 0;if(p){const h=o.get(p)||0;u=p+"-"+h,o.set(p,h+1)}}const f=r2(e,c,u);f!==void 0&&a.push(f)}return a}function P3(e,t,a){const l=m3(e.schema,t);if(!(a==null||typeof a=="number"&&Number.isNaN(a))){if(Array.isArray(a)&&(a=l.commaSeparated?t3(a):x3(a)),l.property==="style"){let o=typeof a=="object"?a:B3(e,String(a));return e.stylePropertyNameCase==="css"&&(o=H3(o)),["style",o]}return[e.elementAttributeNameCase==="react"&&l.space?u3[l.property]||l.property:l.attribute,a]}}function B3(e,t){try{return S3(t,{reactCompat:!0})}catch(a){if(e.ignoreInvalidStyle)return{};const l=a,o=new Kn("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:l,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw o.file=e.filePath||void 0,o.url=a2+"#cannot-parse-style-attribute",o}}function l2(e,t,a){let l;if(!a)l={type:"Literal",value:t};else if(t.includes(".")){const o=t.split(".");let c=-1,u;for(;++c<o.length;){const f=sb(o[c])?{type:"Identifier",name:o[c]}:{type:"Literal",value:o[c]};u=u?{type:"MemberExpression",object:u,property:f,computed:!!(c&&f.type==="Literal"),optional:!1}:f}l=u}else l=sb(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(l.type==="Literal"){const o=l.value;return mg.call(e.components,o)?e.components[o]:o}if(e.evaluater)return e.evaluater.evaluateExpression(l);Jo(e)}function Jo(e,t){const a=new Kn("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw a.file=e.filePath||void 0,a.url=a2+"#cannot-handle-mdx-estrees-without-createevaluater",a}function H3(e){const t={};let a;for(a in e)mg.call(e,a)&&(t[F3(a)]=e[a]);return t}function F3(e){let t=e.replace(N3,q3);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function q3(e){return"-"+e.toLowerCase()}const cp={action:["form"],cite:["blockquote","del","ins","q"],data:["object"],formAction:["button","input"],href:["a","area","base","link"],icon:["menuitem"],itemId:null,manifest:["html"],ping:["a","area"],poster:["video"],src:["audio","embed","iframe","img","input","script","source","track","video"]},V3={};function gg(e,t){const a=V3,l=typeof a.includeImageAlt=="boolean"?a.includeImageAlt:!0,o=typeof a.includeHtml=="boolean"?a.includeHtml:!0;return i2(e,l,o)}function i2(e,t,a){if(G3(e)){if("value"in e)return e.type==="html"&&!a?"":e.value;if(t&&"alt"in e&&e.alt)return e.alt;if("children"in e)return hb(e.children,t,a)}return Array.isArray(e)?hb(e,t,a):""}function hb(e,t,a){const l=[];let o=-1;for(;++o<e.length;)l[o]=i2(e[o],t,a);return l.join("")}function G3(e){return!!(e&&typeof e=="object")}const gb=document.createElement("i");function xg(e){const t="&"+e+";";gb.innerHTML=t;const a=gb.textContent;return a.charCodeAt(a.length-1)===59&&e!=="semi"||a===t?!1:a}function _a(e,t,a,l){const o=e.length;let c=0,u;if(t<0?t=-t>o?0:o+t:t=t>o?o:t,a=a>0?a:0,l.length<1e4)u=Array.from(l),u.unshift(t,a),e.splice(...u);else for(a&&e.splice(t,a);c<l.length;)u=l.slice(c,c+1e4),u.unshift(t,0),e.splice(...u),c+=1e4,t+=1e4}function Ja(e,t){return e.length>0?(_a(e,e.length,0,t),e):t}const xb={}.hasOwnProperty;function o2(e){const t={};let a=-1;for(;++a<e.length;)W3(t,e[a]);return t}function W3(e,t){let a;for(a in t){const o=(xb.call(e,a)?e[a]:void 0)||(e[a]={}),c=t[a];let u;if(c)for(u in c){xb.call(o,u)||(o[u]=[]);const f=c[u];K3(o[u],Array.isArray(f)?f:f?[f]:[])}}}function K3(e,t){let a=-1;const l=[];for(;++a<t.length;)(t[a].add==="after"?e:l).push(t[a]);_a(e,0,0,l)}function c2(e,t){const a=Number.parseInt(e,t);return a<9||a===11||a>13&&a<32||a>126&&a<160||a>55295&&a<57344||a>64975&&a<65008||(a&65535)===65535||(a&65535)===65534||a>1114111?"�":String.fromCodePoint(a)}function pr(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const ta=Hs(/[A-Za-z]/),Gn=Hs(/[\dA-Za-z]/),Y3=Hs(/[#-'*+\--9=?A-Z^-~]/);function ud(e){return e!==null&&(e<32||e===127)}const fh=Hs(/\d/),Q3=Hs(/[\dA-Fa-f]/),X3=Hs(/[!-/:-@[-`{-~]/);function Ye(e){return e!==null&&e<-2}function Ft(e){return e!==null&&(e<0||e===32)}function mt(e){return e===-2||e===-1||e===32}const Dd=Hs(new RegExp("\\p{P}|\\p{S}","u")),Sl=Hs(/\s/);function Hs(e){return t;function t(a){return a!==null&&a>-1&&e.test(String.fromCharCode(a))}}function Si(e){const t=[];let a=-1,l=0,o=0;for(;++a<e.length;){const c=e.charCodeAt(a);let u="";if(c===37&&Gn(e.charCodeAt(a+1))&&Gn(e.charCodeAt(a+2)))o=2;else if(c<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(c))||(u=String.fromCharCode(c));else if(c>55295&&c<57344){const f=e.charCodeAt(a+1);c<56320&&f>56319&&f<57344?(u=String.fromCharCode(c,f),o=1):u="�"}else u=String.fromCharCode(c);u&&(t.push(e.slice(l,a),encodeURIComponent(u)),l=a+o+1,u=""),o&&(a+=o,o=0)}return t.join("")+e.slice(l)}function kt(e,t,a,l){const o=l?l-1:Number.POSITIVE_INFINITY;let c=0;return u;function u(p){return mt(p)?(e.enter(a),f(p)):t(p)}function f(p){return mt(p)&&c++<o?(e.consume(p),f):(e.exit(a),t(p))}}const Z3={tokenize:J3};function J3(e){const t=e.attempt(this.parser.constructs.contentInitial,l,o);let a;return t;function l(f){if(f===null){e.consume(f);return}return e.enter("lineEnding"),e.consume(f),e.exit("lineEnding"),kt(e,t,"linePrefix")}function o(f){return e.enter("paragraph"),c(f)}function c(f){const p=e.enter("chunkText",{contentType:"text",previous:a});return a&&(a.next=p),a=p,u(f)}function u(f){if(f===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(f);return}return Ye(f)?(e.consume(f),e.exit("chunkText"),c):(e.consume(f),u)}}const eE={tokenize:tE},yb={tokenize:nE};function tE(e){const t=this,a=[];let l=0,o,c,u;return f;function f(D){if(l<a.length){const V=a[l];return t.containerState=V[1],e.attempt(V[0].continuation,p,h)(D)}return h(D)}function p(D){if(l++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,o&&_();const V=t.events.length;let F=V,A;for(;F--;)if(t.events[F][0]==="exit"&&t.events[F][1].type==="chunkFlow"){A=t.events[F][1].end;break}M(l);let P=V;for(;P<t.events.length;)t.events[P][1].end={...A},P++;return _a(t.events,F+1,0,t.events.slice(V)),t.events.length=P,h(D)}return f(D)}function h(D){if(l===a.length){if(!o)return k(D);if(o.currentConstruct&&o.currentConstruct.concrete)return j(D);t.interrupt=!!(o.currentConstruct&&!o._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(yb,g,v)(D)}function g(D){return o&&_(),M(l),k(D)}function v(D){return t.parser.lazy[t.now().line]=l!==a.length,u=t.now().offset,j(D)}function k(D){return t.containerState={},e.attempt(yb,w,j)(D)}function w(D){return l++,a.push([t.currentConstruct,t.containerState]),k(D)}function j(D){if(D===null){o&&_(),M(0),e.consume(D);return}return o=o||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:o,contentType:"flow",previous:c}),E(D)}function E(D){if(D===null){C(e.exit("chunkFlow"),!0),M(0),e.consume(D);return}return Ye(D)?(e.consume(D),C(e.exit("chunkFlow")),l=0,t.interrupt=void 0,f):(e.consume(D),E)}function C(D,V){const F=t.sliceStream(D);if(V&&F.push(null),D.previous=c,c&&(c.next=D),c=D,o.defineSkip(D.start),o.write(F),t.parser.lazy[D.start.line]){let A=o.events.length;for(;A--;)if(o.events[A][1].start.offset<u&&(!o.events[A][1].end||o.events[A][1].end.offset>u))return;const P=t.events.length;let Q=P,K,O;for(;Q--;)if(t.events[Q][0]==="exit"&&t.events[Q][1].type==="chunkFlow"){if(K){O=t.events[Q][1].end;break}K=!0}for(M(l),A=P;A<t.events.length;)t.events[A][1].end={...O},A++;_a(t.events,Q+1,0,t.events.slice(P)),t.events.length=A}}function M(D){let V=a.length;for(;V-- >D;){const F=a[V];t.containerState=F[1],F[0].exit.call(t,e)}a.length=D}function _(){o.write([null]),c=void 0,o=void 0,t.containerState._closeFlow=void 0}}function nE(e,t,a){return kt(e,e.attempt(this.parser.constructs.document,t,a),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function hi(e){if(e===null||Ft(e)||Sl(e))return 1;if(Dd(e))return 2}function zd(e,t,a){const l=[];let o=-1;for(;++o<e.length;){const c=e[o].resolveAll;c&&!l.includes(c)&&(t=c(t,a),l.push(c))}return t}const mh={name:"attention",resolveAll:aE,tokenize:rE};function aE(e,t){let a=-1,l,o,c,u,f,p,h,g;for(;++a<e.length;)if(e[a][0]==="enter"&&e[a][1].type==="attentionSequence"&&e[a][1]._close){for(l=a;l--;)if(e[l][0]==="exit"&&e[l][1].type==="attentionSequence"&&e[l][1]._open&&t.sliceSerialize(e[l][1]).charCodeAt(0)===t.sliceSerialize(e[a][1]).charCodeAt(0)){if((e[l][1]._close||e[a][1]._open)&&(e[a][1].end.offset-e[a][1].start.offset)%3&&!((e[l][1].end.offset-e[l][1].start.offset+e[a][1].end.offset-e[a][1].start.offset)%3))continue;p=e[l][1].end.offset-e[l][1].start.offset>1&&e[a][1].end.offset-e[a][1].start.offset>1?2:1;const v={...e[l][1].end},k={...e[a][1].start};vb(v,-p),vb(k,p),u={type:p>1?"strongSequence":"emphasisSequence",start:v,end:{...e[l][1].end}},f={type:p>1?"strongSequence":"emphasisSequence",start:{...e[a][1].start},end:k},c={type:p>1?"strongText":"emphasisText",start:{...e[l][1].end},end:{...e[a][1].start}},o={type:p>1?"strong":"emphasis",start:{...u.start},end:{...f.end}},e[l][1].end={...u.start},e[a][1].start={...f.end},h=[],e[l][1].end.offset-e[l][1].start.offset&&(h=Ja(h,[["enter",e[l][1],t],["exit",e[l][1],t]])),h=Ja(h,[["enter",o,t],["enter",u,t],["exit",u,t],["enter",c,t]]),h=Ja(h,zd(t.parser.constructs.insideSpan.null,e.slice(l+1,a),t)),h=Ja(h,[["exit",c,t],["enter",f,t],["exit",f,t],["exit",o,t]]),e[a][1].end.offset-e[a][1].start.offset?(g=2,h=Ja(h,[["enter",e[a][1],t],["exit",e[a][1],t]])):g=0,_a(e,l-1,a-l+3,h),a=l+h.length-g-2;break}}for(a=-1;++a<e.length;)e[a][1].type==="attentionSequence"&&(e[a][1].type="data");return e}function rE(e,t){const a=this.parser.constructs.attentionMarkers.null,l=this.previous,o=hi(l);let c;return u;function u(p){return c=p,e.enter("attentionSequence"),f(p)}function f(p){if(p===c)return e.consume(p),f;const h=e.exit("attentionSequence"),g=hi(p),v=!g||g===2&&o||a.includes(p),k=!o||o===2&&g||a.includes(l);return h._open=!!(c===42?v:v&&(o||!k)),h._close=!!(c===42?k:k&&(g||!v)),t(p)}}function vb(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const sE={name:"autolink",tokenize:lE};function lE(e,t,a){let l=0;return o;function o(w){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(w),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),c}function c(w){return ta(w)?(e.consume(w),u):w===64?a(w):h(w)}function u(w){return w===43||w===45||w===46||Gn(w)?(l=1,f(w)):h(w)}function f(w){return w===58?(e.consume(w),l=0,p):(w===43||w===45||w===46||Gn(w))&&l++<32?(e.consume(w),f):(l=0,h(w))}function p(w){return w===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(w),e.exit("autolinkMarker"),e.exit("autolink"),t):w===null||w===32||w===60||ud(w)?a(w):(e.consume(w),p)}function h(w){return w===64?(e.consume(w),g):Y3(w)?(e.consume(w),h):a(w)}function g(w){return Gn(w)?v(w):a(w)}function v(w){return w===46?(e.consume(w),l=0,g):w===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(w),e.exit("autolinkMarker"),e.exit("autolink"),t):k(w)}function k(w){if((w===45||Gn(w))&&l++<63){const j=w===45?k:v;return e.consume(w),j}return a(w)}}const fc={partial:!0,tokenize:iE};function iE(e,t,a){return l;function l(c){return mt(c)?kt(e,o,"linePrefix")(c):o(c)}function o(c){return c===null||Ye(c)?t(c):a(c)}}const u2={continuation:{tokenize:cE},exit:uE,name:"blockQuote",tokenize:oE};function oE(e,t,a){const l=this;return o;function o(u){if(u===62){const f=l.containerState;return f.open||(e.enter("blockQuote",{_container:!0}),f.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(u),e.exit("blockQuoteMarker"),c}return a(u)}function c(u){return mt(u)?(e.enter("blockQuotePrefixWhitespace"),e.consume(u),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(u))}}function cE(e,t,a){const l=this;return o;function o(u){return mt(u)?kt(e,c,"linePrefix",l.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(u):c(u)}function c(u){return e.attempt(u2,t,a)(u)}}function uE(e){e.exit("blockQuote")}const d2={name:"characterEscape",tokenize:dE};function dE(e,t,a){return l;function l(c){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(c),e.exit("escapeMarker"),o}function o(c){return X3(c)?(e.enter("characterEscapeValue"),e.consume(c),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):a(c)}}const f2={name:"characterReference",tokenize:fE};function fE(e,t,a){const l=this;let o=0,c,u;return f;function f(v){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(v),e.exit("characterReferenceMarker"),p}function p(v){return v===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(v),e.exit("characterReferenceMarkerNumeric"),h):(e.enter("characterReferenceValue"),c=31,u=Gn,g(v))}function h(v){return v===88||v===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(v),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),c=6,u=Q3,g):(e.enter("characterReferenceValue"),c=7,u=fh,g(v))}function g(v){if(v===59&&o){const k=e.exit("characterReferenceValue");return u===Gn&&!xg(l.sliceSerialize(k))?a(v):(e.enter("characterReferenceMarker"),e.consume(v),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return u(v)&&o++<c?(e.consume(v),g):a(v)}}const bb={partial:!0,tokenize:pE},kb={concrete:!0,name:"codeFenced",tokenize:mE};function mE(e,t,a){const l=this,o={partial:!0,tokenize:F};let c=0,u=0,f;return p;function p(A){return h(A)}function h(A){const P=l.events[l.events.length-1];return c=P&&P[1].type==="linePrefix"?P[2].sliceSerialize(P[1],!0).length:0,f=A,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),g(A)}function g(A){return A===f?(u++,e.consume(A),g):u<3?a(A):(e.exit("codeFencedFenceSequence"),mt(A)?kt(e,v,"whitespace")(A):v(A))}function v(A){return A===null||Ye(A)?(e.exit("codeFencedFence"),l.interrupt?t(A):e.check(bb,E,V)(A)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),k(A))}function k(A){return A===null||Ye(A)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),v(A)):mt(A)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),kt(e,w,"whitespace")(A)):A===96&&A===f?a(A):(e.consume(A),k)}function w(A){return A===null||Ye(A)?v(A):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),j(A))}function j(A){return A===null||Ye(A)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),v(A)):A===96&&A===f?a(A):(e.consume(A),j)}function E(A){return e.attempt(o,V,C)(A)}function C(A){return e.enter("lineEnding"),e.consume(A),e.exit("lineEnding"),M}function M(A){return c>0&&mt(A)?kt(e,_,"linePrefix",c+1)(A):_(A)}function _(A){return A===null||Ye(A)?e.check(bb,E,V)(A):(e.enter("codeFlowValue"),D(A))}function D(A){return A===null||Ye(A)?(e.exit("codeFlowValue"),_(A)):(e.consume(A),D)}function V(A){return e.exit("codeFenced"),t(A)}function F(A,P,Q){let K=0;return O;function O(G){return A.enter("lineEnding"),A.consume(G),A.exit("lineEnding"),z}function z(G){return A.enter("codeFencedFence"),mt(G)?kt(A,I,"linePrefix",l.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(G):I(G)}function I(G){return G===f?(A.enter("codeFencedFenceSequence"),B(G)):Q(G)}function B(G){return G===f?(K++,A.consume(G),B):K>=u?(A.exit("codeFencedFenceSequence"),mt(G)?kt(A,$,"whitespace")(G):$(G)):Q(G)}function $(G){return G===null||Ye(G)?(A.exit("codeFencedFence"),P(G)):Q(G)}}}function pE(e,t,a){const l=this;return o;function o(u){return u===null?a(u):(e.enter("lineEnding"),e.consume(u),e.exit("lineEnding"),c)}function c(u){return l.parser.lazy[l.now().line]?a(u):t(u)}}const up={name:"codeIndented",tokenize:gE},hE={partial:!0,tokenize:xE};function gE(e,t,a){const l=this;return o;function o(h){return e.enter("codeIndented"),kt(e,c,"linePrefix",5)(h)}function c(h){const g=l.events[l.events.length-1];return g&&g[1].type==="linePrefix"&&g[2].sliceSerialize(g[1],!0).length>=4?u(h):a(h)}function u(h){return h===null?p(h):Ye(h)?e.attempt(hE,u,p)(h):(e.enter("codeFlowValue"),f(h))}function f(h){return h===null||Ye(h)?(e.exit("codeFlowValue"),u(h)):(e.consume(h),f)}function p(h){return e.exit("codeIndented"),t(h)}}function xE(e,t,a){const l=this;return o;function o(u){return l.parser.lazy[l.now().line]?a(u):Ye(u)?(e.enter("lineEnding"),e.consume(u),e.exit("lineEnding"),o):kt(e,c,"linePrefix",5)(u)}function c(u){const f=l.events[l.events.length-1];return f&&f[1].type==="linePrefix"&&f[2].sliceSerialize(f[1],!0).length>=4?t(u):Ye(u)?o(u):a(u)}}const yE={name:"codeText",previous:bE,resolve:vE,tokenize:kE};function vE(e){let t=e.length-4,a=3,l,o;if((e[a][1].type==="lineEnding"||e[a][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(l=a;++l<t;)if(e[l][1].type==="codeTextData"){e[a][1].type="codeTextPadding",e[t][1].type="codeTextPadding",a+=2,t-=2;break}}for(l=a-1,t++;++l<=t;)o===void 0?l!==t&&e[l][1].type!=="lineEnding"&&(o=l):(l===t||e[l][1].type==="lineEnding")&&(e[o][1].type="codeTextData",l!==o+2&&(e[o][1].end=e[l-1][1].end,e.splice(o+2,l-o-2),t-=l-o-2,l=o+2),o=void 0);return e}function bE(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function kE(e,t,a){let l=0,o,c;return u;function u(v){return e.enter("codeText"),e.enter("codeTextSequence"),f(v)}function f(v){return v===96?(e.consume(v),l++,f):(e.exit("codeTextSequence"),p(v))}function p(v){return v===null?a(v):v===32?(e.enter("space"),e.consume(v),e.exit("space"),p):v===96?(c=e.enter("codeTextSequence"),o=0,g(v)):Ye(v)?(e.enter("lineEnding"),e.consume(v),e.exit("lineEnding"),p):(e.enter("codeTextData"),h(v))}function h(v){return v===null||v===32||v===96||Ye(v)?(e.exit("codeTextData"),p(v)):(e.consume(v),h)}function g(v){return v===96?(e.consume(v),o++,g):o===l?(e.exit("codeTextSequence"),e.exit("codeText"),t(v)):(c.type="codeTextData",h(v))}}class wE{constructor(t){this.left=t?[...t]:[],this.right=[]}get(t){if(t<0||t>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+t+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return t<this.left.length?this.left[t]:this.right[this.right.length-t+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(t,a){const l=a??Number.POSITIVE_INFINITY;return l<this.left.length?this.left.slice(t,l):t>this.left.length?this.right.slice(this.right.length-l+this.left.length,this.right.length-t+this.left.length).reverse():this.left.slice(t).concat(this.right.slice(this.right.length-l+this.left.length).reverse())}splice(t,a,l){const o=a||0;this.setCursor(Math.trunc(t));const c=this.right.splice(this.right.length-o,Number.POSITIVE_INFINITY);return l&&wo(this.left,l),c.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(t){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(t)}pushMany(t){this.setCursor(Number.POSITIVE_INFINITY),wo(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),wo(this.right,t.reverse())}setCursor(t){if(!(t===this.left.length||t>this.left.length&&this.right.length===0||t<0&&this.left.length===0))if(t<this.left.length){const a=this.left.splice(t,Number.POSITIVE_INFINITY);wo(this.right,a.reverse())}else{const a=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);wo(this.left,a.reverse())}}}function wo(e,t){let a=0;if(t.length<1e4)e.push(...t);else for(;a<t.length;)e.push(...t.slice(a,a+1e4)),a+=1e4}function m2(e){const t={};let a=-1,l,o,c,u,f,p,h;const g=new wE(e);for(;++a<g.length;){for(;a in t;)a=t[a];if(l=g.get(a),a&&l[1].type==="chunkFlow"&&g.get(a-1)[1].type==="listItemPrefix"&&(p=l[1]._tokenizer.events,c=0,c<p.length&&p[c][1].type==="lineEndingBlank"&&(c+=2),c<p.length&&p[c][1].type==="content"))for(;++c<p.length&&p[c][1].type!=="content";)p[c][1].type==="chunkText"&&(p[c][1]._isInFirstContentOfListItem=!0,c++);if(l[0]==="enter")l[1].contentType&&(Object.assign(t,SE(g,a)),a=t[a],h=!0);else if(l[1]._container){for(c=a,o=void 0;c--;)if(u=g.get(c),u[1].type==="lineEnding"||u[1].type==="lineEndingBlank")u[0]==="enter"&&(o&&(g.get(o)[1].type="lineEndingBlank"),u[1].type="lineEnding",o=c);else if(!(u[1].type==="linePrefix"||u[1].type==="listItemIndent"))break;o&&(l[1].end={...g.get(o)[1].start},f=g.slice(o,a),f.unshift(l),g.splice(o,a-o+1,f))}}return _a(e,0,Number.POSITIVE_INFINITY,g.slice(0)),!h}function SE(e,t){const a=e.get(t)[1],l=e.get(t)[2];let o=t-1;const c=[];let u=a._tokenizer;u||(u=l.parser[a.contentType](a.start),a._contentTypeTextTrailing&&(u._contentTypeTextTrailing=!0));const f=u.events,p=[],h={};let g,v,k=-1,w=a,j=0,E=0;const C=[E];for(;w;){for(;e.get(++o)[1]!==w;);c.push(o),w._tokenizer||(g=l.sliceStream(w),w.next||g.push(null),v&&u.defineSkip(w.start),w._isInFirstContentOfListItem&&(u._gfmTasklistFirstContentOfListItem=!0),u.write(g),w._isInFirstContentOfListItem&&(u._gfmTasklistFirstContentOfListItem=void 0)),v=w,w=w.next}for(w=a;++k<f.length;)f[k][0]==="exit"&&f[k-1][0]==="enter"&&f[k][1].type===f[k-1][1].type&&f[k][1].start.line!==f[k][1].end.line&&(E=k+1,C.push(E),w._tokenizer=void 0,w.previous=void 0,w=w.next);for(u.events=[],w?(w._tokenizer=void 0,w.previous=void 0):C.pop(),k=C.length;k--;){const M=f.slice(C[k],C[k+1]),_=c.pop();p.push([_,_+M.length-1]),e.splice(_,2,M)}for(p.reverse(),k=-1;++k<p.length;)h[j+p[k][0]]=j+p[k][1],j+=p[k][1]-p[k][0]-1;return h}const jE={resolve:NE,tokenize:TE},CE={partial:!0,tokenize:ME};function NE(e){return m2(e),e}function TE(e,t){let a;return l;function l(f){return e.enter("content"),a=e.enter("chunkContent",{contentType:"content"}),o(f)}function o(f){return f===null?c(f):Ye(f)?e.check(CE,u,c)(f):(e.consume(f),o)}function c(f){return e.exit("chunkContent"),e.exit("content"),t(f)}function u(f){return e.consume(f),e.exit("chunkContent"),a.next=e.enter("chunkContent",{contentType:"content",previous:a}),a=a.next,o}}function ME(e,t,a){const l=this;return o;function o(u){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(u),e.exit("lineEnding"),kt(e,c,"linePrefix")}function c(u){if(u===null||Ye(u))return a(u);const f=l.events[l.events.length-1];return!l.parser.constructs.disable.null.includes("codeIndented")&&f&&f[1].type==="linePrefix"&&f[2].sliceSerialize(f[1],!0).length>=4?t(u):e.interrupt(l.parser.constructs.flow,a,t)(u)}}function p2(e,t,a,l,o,c,u,f,p){const h=p||Number.POSITIVE_INFINITY;let g=0;return v;function v(M){return M===60?(e.enter(l),e.enter(o),e.enter(c),e.consume(M),e.exit(c),k):M===null||M===32||M===41||ud(M)?a(M):(e.enter(l),e.enter(u),e.enter(f),e.enter("chunkString",{contentType:"string"}),E(M))}function k(M){return M===62?(e.enter(c),e.consume(M),e.exit(c),e.exit(o),e.exit(l),t):(e.enter(f),e.enter("chunkString",{contentType:"string"}),w(M))}function w(M){return M===62?(e.exit("chunkString"),e.exit(f),k(M)):M===null||M===60||Ye(M)?a(M):(e.consume(M),M===92?j:w)}function j(M){return M===60||M===62||M===92?(e.consume(M),w):w(M)}function E(M){return!g&&(M===null||M===41||Ft(M))?(e.exit("chunkString"),e.exit(f),e.exit(u),e.exit(l),t(M)):g<h&&M===40?(e.consume(M),g++,E):M===41?(e.consume(M),g--,E):M===null||M===32||M===40||ud(M)?a(M):(e.consume(M),M===92?C:E)}function C(M){return M===40||M===41||M===92?(e.consume(M),E):E(M)}}function h2(e,t,a,l,o,c){const u=this;let f=0,p;return h;function h(w){return e.enter(l),e.enter(o),e.consume(w),e.exit(o),e.enter(c),g}function g(w){return f>999||w===null||w===91||w===93&&!p||w===94&&!f&&"_hiddenFootnoteSupport"in u.parser.constructs?a(w):w===93?(e.exit(c),e.enter(o),e.consume(w),e.exit(o),e.exit(l),t):Ye(w)?(e.enter("lineEnding"),e.consume(w),e.exit("lineEnding"),g):(e.enter("chunkString",{contentType:"string"}),v(w))}function v(w){return w===null||w===91||w===93||Ye(w)||f++>999?(e.exit("chunkString"),g(w)):(e.consume(w),p||(p=!mt(w)),w===92?k:v)}function k(w){return w===91||w===92||w===93?(e.consume(w),f++,v):v(w)}}function g2(e,t,a,l,o,c){let u;return f;function f(k){return k===34||k===39||k===40?(e.enter(l),e.enter(o),e.consume(k),e.exit(o),u=k===40?41:k,p):a(k)}function p(k){return k===u?(e.enter(o),e.consume(k),e.exit(o),e.exit(l),t):(e.enter(c),h(k))}function h(k){return k===u?(e.exit(c),p(u)):k===null?a(k):Ye(k)?(e.enter("lineEnding"),e.consume(k),e.exit("lineEnding"),kt(e,h,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),g(k))}function g(k){return k===u||k===null||Ye(k)?(e.exit("chunkString"),h(k)):(e.consume(k),k===92?v:g)}function v(k){return k===u||k===92?(e.consume(k),g):g(k)}}function Bo(e,t){let a;return l;function l(o){return Ye(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),a=!0,l):mt(o)?kt(e,l,a?"linePrefix":"lineSuffix")(o):t(o)}}const EE={name:"definition",tokenize:RE},AE={partial:!0,tokenize:_E};function RE(e,t,a){const l=this;let o;return c;function c(w){return e.enter("definition"),u(w)}function u(w){return h2.call(l,e,f,a,"definitionLabel","definitionLabelMarker","definitionLabelString")(w)}function f(w){return o=pr(l.sliceSerialize(l.events[l.events.length-1][1]).slice(1,-1)),w===58?(e.enter("definitionMarker"),e.consume(w),e.exit("definitionMarker"),p):a(w)}function p(w){return Ft(w)?Bo(e,h)(w):h(w)}function h(w){return p2(e,g,a,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(w)}function g(w){return e.attempt(AE,v,v)(w)}function v(w){return mt(w)?kt(e,k,"whitespace")(w):k(w)}function k(w){return w===null||Ye(w)?(e.exit("definition"),l.parser.defined.push(o),t(w)):a(w)}}function _E(e,t,a){return l;function l(f){return Ft(f)?Bo(e,o)(f):a(f)}function o(f){return g2(e,c,a,"definitionTitle","definitionTitleMarker","definitionTitleString")(f)}function c(f){return mt(f)?kt(e,u,"whitespace")(f):u(f)}function u(f){return f===null||Ye(f)?t(f):a(f)}}const IE={name:"hardBreakEscape",tokenize:LE};function LE(e,t,a){return l;function l(c){return e.enter("hardBreakEscape"),e.consume(c),o}function o(c){return Ye(c)?(e.exit("hardBreakEscape"),t(c)):a(c)}}const OE={name:"headingAtx",resolve:DE,tokenize:zE};function DE(e,t){let a=e.length-2,l=3,o,c;return e[l][1].type==="whitespace"&&(l+=2),a-2>l&&e[a][1].type==="whitespace"&&(a-=2),e[a][1].type==="atxHeadingSequence"&&(l===a-1||a-4>l&&e[a-2][1].type==="whitespace")&&(a-=l+1===a?2:4),a>l&&(o={type:"atxHeadingText",start:e[l][1].start,end:e[a][1].end},c={type:"chunkText",start:e[l][1].start,end:e[a][1].end,contentType:"text"},_a(e,l,a-l+1,[["enter",o,t],["enter",c,t],["exit",c,t],["exit",o,t]])),e}function zE(e,t,a){let l=0;return o;function o(g){return e.enter("atxHeading"),c(g)}function c(g){return e.enter("atxHeadingSequence"),u(g)}function u(g){return g===35&&l++<6?(e.consume(g),u):g===null||Ft(g)?(e.exit("atxHeadingSequence"),f(g)):a(g)}function f(g){return g===35?(e.enter("atxHeadingSequence"),p(g)):g===null||Ye(g)?(e.exit("atxHeading"),t(g)):mt(g)?kt(e,f,"whitespace")(g):(e.enter("atxHeadingText"),h(g))}function p(g){return g===35?(e.consume(g),p):(e.exit("atxHeadingSequence"),f(g))}function h(g){return g===null||g===35||Ft(g)?(e.exit("atxHeadingText"),f(g)):(e.consume(g),h)}}const UE=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],wb=["pre","script","style","textarea"],$E={concrete:!0,name:"htmlFlow",resolveTo:HE,tokenize:FE},PE={partial:!0,tokenize:VE},BE={partial:!0,tokenize:qE};function HE(e){let t=e.length;for(;t--&&!(e[t][0]==="enter"&&e[t][1].type==="htmlFlow"););return t>1&&e[t-2][1].type==="linePrefix"&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function FE(e,t,a){const l=this;let o,c,u,f,p;return h;function h(S){return g(S)}function g(S){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(S),v}function v(S){return S===33?(e.consume(S),k):S===47?(e.consume(S),c=!0,E):S===63?(e.consume(S),o=3,l.interrupt?t:T):ta(S)?(e.consume(S),u=String.fromCharCode(S),C):a(S)}function k(S){return S===45?(e.consume(S),o=2,w):S===91?(e.consume(S),o=5,f=0,j):ta(S)?(e.consume(S),o=4,l.interrupt?t:T):a(S)}function w(S){return S===45?(e.consume(S),l.interrupt?t:T):a(S)}function j(S){const U="CDATA[";return S===U.charCodeAt(f++)?(e.consume(S),f===U.length?l.interrupt?t:I:j):a(S)}function E(S){return ta(S)?(e.consume(S),u=String.fromCharCode(S),C):a(S)}function C(S){if(S===null||S===47||S===62||Ft(S)){const U=S===47,ee=u.toLowerCase();return!U&&!c&&wb.includes(ee)?(o=1,l.interrupt?t(S):I(S)):UE.includes(u.toLowerCase())?(o=6,U?(e.consume(S),M):l.interrupt?t(S):I(S)):(o=7,l.interrupt&&!l.parser.lazy[l.now().line]?a(S):c?_(S):D(S))}return S===45||Gn(S)?(e.consume(S),u+=String.fromCharCode(S),C):a(S)}function M(S){return S===62?(e.consume(S),l.interrupt?t:I):a(S)}function _(S){return mt(S)?(e.consume(S),_):O(S)}function D(S){return S===47?(e.consume(S),O):S===58||S===95||ta(S)?(e.consume(S),V):mt(S)?(e.consume(S),D):O(S)}function V(S){return S===45||S===46||S===58||S===95||Gn(S)?(e.consume(S),V):F(S)}function F(S){return S===61?(e.consume(S),A):mt(S)?(e.consume(S),F):D(S)}function A(S){return S===null||S===60||S===61||S===62||S===96?a(S):S===34||S===39?(e.consume(S),p=S,P):mt(S)?(e.consume(S),A):Q(S)}function P(S){return S===p?(e.consume(S),p=null,K):S===null||Ye(S)?a(S):(e.consume(S),P)}function Q(S){return S===null||S===34||S===39||S===47||S===60||S===61||S===62||S===96||Ft(S)?F(S):(e.consume(S),Q)}function K(S){return S===47||S===62||mt(S)?D(S):a(S)}function O(S){return S===62?(e.consume(S),z):a(S)}function z(S){return S===null||Ye(S)?I(S):mt(S)?(e.consume(S),z):a(S)}function I(S){return S===45&&o===2?(e.consume(S),q):S===60&&o===1?(e.consume(S),ae):S===62&&o===4?(e.consume(S),R):S===63&&o===3?(e.consume(S),T):S===93&&o===5?(e.consume(S),X):Ye(S)&&(o===6||o===7)?(e.exit("htmlFlowData"),e.check(PE,H,B)(S)):S===null||Ye(S)?(e.exit("htmlFlowData"),B(S)):(e.consume(S),I)}function B(S){return e.check(BE,$,H)(S)}function $(S){return e.enter("lineEnding"),e.consume(S),e.exit("lineEnding"),G}function G(S){return S===null||Ye(S)?B(S):(e.enter("htmlFlowData"),I(S))}function q(S){return S===45?(e.consume(S),T):I(S)}function ae(S){return S===47?(e.consume(S),u="",Z):I(S)}function Z(S){if(S===62){const U=u.toLowerCase();return wb.includes(U)?(e.consume(S),R):I(S)}return ta(S)&&u.length<8?(e.consume(S),u+=String.fromCharCode(S),Z):I(S)}function X(S){return S===93?(e.consume(S),T):I(S)}function T(S){return S===62?(e.consume(S),R):S===45&&o===2?(e.consume(S),T):I(S)}function R(S){return S===null||Ye(S)?(e.exit("htmlFlowData"),H(S)):(e.consume(S),R)}function H(S){return e.exit("htmlFlow"),t(S)}}function qE(e,t,a){const l=this;return o;function o(u){return Ye(u)?(e.enter("lineEnding"),e.consume(u),e.exit("lineEnding"),c):a(u)}function c(u){return l.parser.lazy[l.now().line]?a(u):t(u)}}function VE(e,t,a){return l;function l(o){return e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),e.attempt(fc,t,a)}}const GE={name:"htmlText",tokenize:WE};function WE(e,t,a){const l=this;let o,c,u;return f;function f(T){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(T),p}function p(T){return T===33?(e.consume(T),h):T===47?(e.consume(T),F):T===63?(e.consume(T),D):ta(T)?(e.consume(T),Q):a(T)}function h(T){return T===45?(e.consume(T),g):T===91?(e.consume(T),c=0,j):ta(T)?(e.consume(T),_):a(T)}function g(T){return T===45?(e.consume(T),w):a(T)}function v(T){return T===null?a(T):T===45?(e.consume(T),k):Ye(T)?(u=v,ae(T)):(e.consume(T),v)}function k(T){return T===45?(e.consume(T),w):v(T)}function w(T){return T===62?q(T):T===45?k(T):v(T)}function j(T){const R="CDATA[";return T===R.charCodeAt(c++)?(e.consume(T),c===R.length?E:j):a(T)}function E(T){return T===null?a(T):T===93?(e.consume(T),C):Ye(T)?(u=E,ae(T)):(e.consume(T),E)}function C(T){return T===93?(e.consume(T),M):E(T)}function M(T){return T===62?q(T):T===93?(e.consume(T),M):E(T)}function _(T){return T===null||T===62?q(T):Ye(T)?(u=_,ae(T)):(e.consume(T),_)}function D(T){return T===null?a(T):T===63?(e.consume(T),V):Ye(T)?(u=D,ae(T)):(e.consume(T),D)}function V(T){return T===62?q(T):D(T)}function F(T){return ta(T)?(e.consume(T),A):a(T)}function A(T){return T===45||Gn(T)?(e.consume(T),A):P(T)}function P(T){return Ye(T)?(u=P,ae(T)):mt(T)?(e.consume(T),P):q(T)}function Q(T){return T===45||Gn(T)?(e.consume(T),Q):T===47||T===62||Ft(T)?K(T):a(T)}function K(T){return T===47?(e.consume(T),q):T===58||T===95||ta(T)?(e.consume(T),O):Ye(T)?(u=K,ae(T)):mt(T)?(e.consume(T),K):q(T)}function O(T){return T===45||T===46||T===58||T===95||Gn(T)?(e.consume(T),O):z(T)}function z(T){return T===61?(e.consume(T),I):Ye(T)?(u=z,ae(T)):mt(T)?(e.consume(T),z):K(T)}function I(T){return T===null||T===60||T===61||T===62||T===96?a(T):T===34||T===39?(e.consume(T),o=T,B):Ye(T)?(u=I,ae(T)):mt(T)?(e.consume(T),I):(e.consume(T),$)}function B(T){return T===o?(e.consume(T),o=void 0,G):T===null?a(T):Ye(T)?(u=B,ae(T)):(e.consume(T),B)}function $(T){return T===null||T===34||T===39||T===60||T===61||T===96?a(T):T===47||T===62||Ft(T)?K(T):(e.consume(T),$)}function G(T){return T===47||T===62||Ft(T)?K(T):a(T)}function q(T){return T===62?(e.consume(T),e.exit("htmlTextData"),e.exit("htmlText"),t):a(T)}function ae(T){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(T),e.exit("lineEnding"),Z}function Z(T){return mt(T)?kt(e,X,"linePrefix",l.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(T):X(T)}function X(T){return e.enter("htmlTextData"),u(T)}}const yg={name:"labelEnd",resolveAll:XE,resolveTo:ZE,tokenize:JE},KE={tokenize:eA},YE={tokenize:tA},QE={tokenize:nA};function XE(e){let t=-1;const a=[];for(;++t<e.length;){const l=e[t][1];if(a.push(e[t]),l.type==="labelImage"||l.type==="labelLink"||l.type==="labelEnd"){const o=l.type==="labelImage"?4:2;l.type="data",t+=o}}return e.length!==a.length&&_a(e,0,e.length,a),e}function ZE(e,t){let a=e.length,l=0,o,c,u,f;for(;a--;)if(o=e[a][1],c){if(o.type==="link"||o.type==="labelLink"&&o._inactive)break;e[a][0]==="enter"&&o.type==="labelLink"&&(o._inactive=!0)}else if(u){if(e[a][0]==="enter"&&(o.type==="labelImage"||o.type==="labelLink")&&!o._balanced&&(c=a,o.type!=="labelLink")){l=2;break}}else o.type==="labelEnd"&&(u=a);const p={type:e[c][1].type==="labelLink"?"link":"image",start:{...e[c][1].start},end:{...e[e.length-1][1].end}},h={type:"label",start:{...e[c][1].start},end:{...e[u][1].end}},g={type:"labelText",start:{...e[c+l+2][1].end},end:{...e[u-2][1].start}};return f=[["enter",p,t],["enter",h,t]],f=Ja(f,e.slice(c+1,c+l+3)),f=Ja(f,[["enter",g,t]]),f=Ja(f,zd(t.parser.constructs.insideSpan.null,e.slice(c+l+4,u-3),t)),f=Ja(f,[["exit",g,t],e[u-2],e[u-1],["exit",h,t]]),f=Ja(f,e.slice(u+1)),f=Ja(f,[["exit",p,t]]),_a(e,c,e.length,f),e}function JE(e,t,a){const l=this;let o=l.events.length,c,u;for(;o--;)if((l.events[o][1].type==="labelImage"||l.events[o][1].type==="labelLink")&&!l.events[o][1]._balanced){c=l.events[o][1];break}return f;function f(k){return c?c._inactive?v(k):(u=l.parser.defined.includes(pr(l.sliceSerialize({start:c.end,end:l.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(k),e.exit("labelMarker"),e.exit("labelEnd"),p):a(k)}function p(k){return k===40?e.attempt(KE,g,u?g:v)(k):k===91?e.attempt(YE,g,u?h:v)(k):u?g(k):v(k)}function h(k){return e.attempt(QE,g,v)(k)}function g(k){return t(k)}function v(k){return c._balanced=!0,a(k)}}function eA(e,t,a){return l;function l(v){return e.enter("resource"),e.enter("resourceMarker"),e.consume(v),e.exit("resourceMarker"),o}function o(v){return Ft(v)?Bo(e,c)(v):c(v)}function c(v){return v===41?g(v):p2(e,u,f,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(v)}function u(v){return Ft(v)?Bo(e,p)(v):g(v)}function f(v){return a(v)}function p(v){return v===34||v===39||v===40?g2(e,h,a,"resourceTitle","resourceTitleMarker","resourceTitleString")(v):g(v)}function h(v){return Ft(v)?Bo(e,g)(v):g(v)}function g(v){return v===41?(e.enter("resourceMarker"),e.consume(v),e.exit("resourceMarker"),e.exit("resource"),t):a(v)}}function tA(e,t,a){const l=this;return o;function o(f){return h2.call(l,e,c,u,"reference","referenceMarker","referenceString")(f)}function c(f){return l.parser.defined.includes(pr(l.sliceSerialize(l.events[l.events.length-1][1]).slice(1,-1)))?t(f):a(f)}function u(f){return a(f)}}function nA(e,t,a){return l;function l(c){return e.enter("reference"),e.enter("referenceMarker"),e.consume(c),e.exit("referenceMarker"),o}function o(c){return c===93?(e.enter("referenceMarker"),e.consume(c),e.exit("referenceMarker"),e.exit("reference"),t):a(c)}}const aA={name:"labelStartImage",resolveAll:yg.resolveAll,tokenize:rA};function rA(e,t,a){const l=this;return o;function o(f){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(f),e.exit("labelImageMarker"),c}function c(f){return f===91?(e.enter("labelMarker"),e.consume(f),e.exit("labelMarker"),e.exit("labelImage"),u):a(f)}function u(f){return f===94&&"_hiddenFootnoteSupport"in l.parser.constructs?a(f):t(f)}}const sA={name:"labelStartLink",resolveAll:yg.resolveAll,tokenize:lA};function lA(e,t,a){const l=this;return o;function o(u){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(u),e.exit("labelMarker"),e.exit("labelLink"),c}function c(u){return u===94&&"_hiddenFootnoteSupport"in l.parser.constructs?a(u):t(u)}}const dp={name:"lineEnding",tokenize:iA};function iA(e,t){return a;function a(l){return e.enter("lineEnding"),e.consume(l),e.exit("lineEnding"),kt(e,t,"linePrefix")}}const Zu={name:"thematicBreak",tokenize:oA};function oA(e,t,a){let l=0,o;return c;function c(h){return e.enter("thematicBreak"),u(h)}function u(h){return o=h,f(h)}function f(h){return h===o?(e.enter("thematicBreakSequence"),p(h)):l>=3&&(h===null||Ye(h))?(e.exit("thematicBreak"),t(h)):a(h)}function p(h){return h===o?(e.consume(h),l++,p):(e.exit("thematicBreakSequence"),mt(h)?kt(e,f,"whitespace")(h):f(h))}}const ma={continuation:{tokenize:fA},exit:pA,name:"list",tokenize:dA},cA={partial:!0,tokenize:hA},uA={partial:!0,tokenize:mA};function dA(e,t,a){const l=this,o=l.events[l.events.length-1];let c=o&&o[1].type==="linePrefix"?o[2].sliceSerialize(o[1],!0).length:0,u=0;return f;function f(w){const j=l.containerState.type||(w===42||w===43||w===45?"listUnordered":"listOrdered");if(j==="listUnordered"?!l.containerState.marker||w===l.containerState.marker:fh(w)){if(l.containerState.type||(l.containerState.type=j,e.enter(j,{_container:!0})),j==="listUnordered")return e.enter("listItemPrefix"),w===42||w===45?e.check(Zu,a,h)(w):h(w);if(!l.interrupt||w===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),p(w)}return a(w)}function p(w){return fh(w)&&++u<10?(e.consume(w),p):(!l.interrupt||u<2)&&(l.containerState.marker?w===l.containerState.marker:w===41||w===46)?(e.exit("listItemValue"),h(w)):a(w)}function h(w){return e.enter("listItemMarker"),e.consume(w),e.exit("listItemMarker"),l.containerState.marker=l.containerState.marker||w,e.check(fc,l.interrupt?a:g,e.attempt(cA,k,v))}function g(w){return l.containerState.initialBlankLine=!0,c++,k(w)}function v(w){return mt(w)?(e.enter("listItemPrefixWhitespace"),e.consume(w),e.exit("listItemPrefixWhitespace"),k):a(w)}function k(w){return l.containerState.size=c+l.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(w)}}function fA(e,t,a){const l=this;return l.containerState._closeFlow=void 0,e.check(fc,o,c);function o(f){return l.containerState.furtherBlankLines=l.containerState.furtherBlankLines||l.containerState.initialBlankLine,kt(e,t,"listItemIndent",l.containerState.size+1)(f)}function c(f){return l.containerState.furtherBlankLines||!mt(f)?(l.containerState.furtherBlankLines=void 0,l.containerState.initialBlankLine=void 0,u(f)):(l.containerState.furtherBlankLines=void 0,l.containerState.initialBlankLine=void 0,e.attempt(uA,t,u)(f))}function u(f){return l.containerState._closeFlow=!0,l.interrupt=void 0,kt(e,e.attempt(ma,t,a),"linePrefix",l.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(f)}}function mA(e,t,a){const l=this;return kt(e,o,"listItemIndent",l.containerState.size+1);function o(c){const u=l.events[l.events.length-1];return u&&u[1].type==="listItemIndent"&&u[2].sliceSerialize(u[1],!0).length===l.containerState.size?t(c):a(c)}}function pA(e){e.exit(this.containerState.type)}function hA(e,t,a){const l=this;return kt(e,o,"listItemPrefixWhitespace",l.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function o(c){const u=l.events[l.events.length-1];return!mt(c)&&u&&u[1].type==="listItemPrefixWhitespace"?t(c):a(c)}}const Sb={name:"setextUnderline",resolveTo:gA,tokenize:xA};function gA(e,t){let a=e.length,l,o,c;for(;a--;)if(e[a][0]==="enter"){if(e[a][1].type==="content"){l=a;break}e[a][1].type==="paragraph"&&(o=a)}else e[a][1].type==="content"&&e.splice(a,1),!c&&e[a][1].type==="definition"&&(c=a);const u={type:"setextHeading",start:{...e[l][1].start},end:{...e[e.length-1][1].end}};return e[o][1].type="setextHeadingText",c?(e.splice(o,0,["enter",u,t]),e.splice(c+1,0,["exit",e[l][1],t]),e[l][1].end={...e[c][1].end}):e[l][1]=u,e.push(["exit",u,t]),e}function xA(e,t,a){const l=this;let o;return c;function c(h){let g=l.events.length,v;for(;g--;)if(l.events[g][1].type!=="lineEnding"&&l.events[g][1].type!=="linePrefix"&&l.events[g][1].type!=="content"){v=l.events[g][1].type==="paragraph";break}return!l.parser.lazy[l.now().line]&&(l.interrupt||v)?(e.enter("setextHeadingLine"),o=h,u(h)):a(h)}function u(h){return e.enter("setextHeadingLineSequence"),f(h)}function f(h){return h===o?(e.consume(h),f):(e.exit("setextHeadingLineSequence"),mt(h)?kt(e,p,"lineSuffix")(h):p(h))}function p(h){return h===null||Ye(h)?(e.exit("setextHeadingLine"),t(h)):a(h)}}const yA={tokenize:vA};function vA(e){const t=this,a=e.attempt(fc,l,e.attempt(this.parser.constructs.flowInitial,o,kt(e,e.attempt(this.parser.constructs.flow,o,e.attempt(jE,o)),"linePrefix")));return a;function l(c){if(c===null){e.consume(c);return}return e.enter("lineEndingBlank"),e.consume(c),e.exit("lineEndingBlank"),t.currentConstruct=void 0,a}function o(c){if(c===null){e.consume(c);return}return e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),t.currentConstruct=void 0,a}}const bA={resolveAll:y2()},kA=x2("string"),wA=x2("text");function x2(e){return{resolveAll:y2(e==="text"?SA:void 0),tokenize:t};function t(a){const l=this,o=this.parser.constructs[e],c=a.attempt(o,u,f);return u;function u(g){return h(g)?c(g):f(g)}function f(g){if(g===null){a.consume(g);return}return a.enter("data"),a.consume(g),p}function p(g){return h(g)?(a.exit("data"),c(g)):(a.consume(g),p)}function h(g){if(g===null)return!0;const v=o[g];let k=-1;if(v)for(;++k<v.length;){const w=v[k];if(!w.previous||w.previous.call(l,l.previous))return!0}return!1}}}function y2(e){return t;function t(a,l){let o=-1,c;for(;++o<=a.length;)c===void 0?a[o]&&a[o][1].type==="data"&&(c=o,o++):(!a[o]||a[o][1].type!=="data")&&(o!==c+2&&(a[c][1].end=a[o-1][1].end,a.splice(c+2,o-c-2),o=c+2),c=void 0);return e?e(a,l):a}}function SA(e,t){let a=0;for(;++a<=e.length;)if((a===e.length||e[a][1].type==="lineEnding")&&e[a-1][1].type==="data"){const l=e[a-1][1],o=t.sliceStream(l);let c=o.length,u=-1,f=0,p;for(;c--;){const h=o[c];if(typeof h=="string"){for(u=h.length;h.charCodeAt(u-1)===32;)f++,u--;if(u)break;u=-1}else if(h===-2)p=!0,f++;else if(h!==-1){c++;break}}if(t._contentTypeTextTrailing&&a===e.length&&(f=0),f){const h={type:a===e.length||p||f<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:c?u:l.start._bufferIndex+u,_index:l.start._index+c,line:l.end.line,column:l.end.column-f,offset:l.end.offset-f},end:{...l.end}};l.end={...h.start},l.start.offset===l.end.offset?Object.assign(l,h):(e.splice(a,0,["enter",h,t],["exit",h,t]),a+=2)}a++}return e}const jA={42:ma,43:ma,45:ma,48:ma,49:ma,50:ma,51:ma,52:ma,53:ma,54:ma,55:ma,56:ma,57:ma,62:u2},CA={91:EE},NA={[-2]:up,[-1]:up,32:up},TA={35:OE,42:Zu,45:[Sb,Zu],60:$E,61:Sb,95:Zu,96:kb,126:kb},MA={38:f2,92:d2},EA={[-5]:dp,[-4]:dp,[-3]:dp,33:aA,38:f2,42:mh,60:[sE,GE],91:sA,92:[IE,d2],93:yg,95:mh,96:yE},AA={null:[mh,bA]},RA={null:[42,95]},_A={null:[]},IA=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:RA,contentInitial:CA,disable:_A,document:jA,flow:TA,flowInitial:NA,insideSpan:AA,string:MA,text:EA},Symbol.toStringTag,{value:"Module"}));function LA(e,t,a){let l={_bufferIndex:-1,_index:0,line:a&&a.line||1,column:a&&a.column||1,offset:a&&a.offset||0};const o={},c=[];let u=[],f=[];const p={attempt:P(F),check:P(A),consume:_,enter:D,exit:V,interrupt:P(A,{interrupt:!0})},h={code:null,containerState:{},defineSkip:E,events:[],now:j,parser:e,previous:null,sliceSerialize:k,sliceStream:w,write:v};let g=t.tokenize.call(h,p);return t.resolveAll&&c.push(t),h;function v(z){return u=Ja(u,z),C(),u[u.length-1]!==null?[]:(Q(t,0),h.events=zd(c,h.events,h),h.events)}function k(z,I){return DA(w(z),I)}function w(z){return OA(u,z)}function j(){const{_bufferIndex:z,_index:I,line:B,column:$,offset:G}=l;return{_bufferIndex:z,_index:I,line:B,column:$,offset:G}}function E(z){o[z.line]=z.column,O()}function C(){let z;for(;l._index<u.length;){const I=u[l._index];if(typeof I=="string")for(z=l._index,l._bufferIndex<0&&(l._bufferIndex=0);l._index===z&&l._bufferIndex<I.length;)M(I.charCodeAt(l._bufferIndex));else M(I)}}function M(z){g=g(z)}function _(z){Ye(z)?(l.line++,l.column=1,l.offset+=z===-3?2:1,O()):z!==-1&&(l.column++,l.offset++),l._bufferIndex<0?l._index++:(l._bufferIndex++,l._bufferIndex===u[l._index].length&&(l._bufferIndex=-1,l._index++)),h.previous=z}function D(z,I){const B=I||{};return B.type=z,B.start=j(),h.events.push(["enter",B,h]),f.push(B),B}function V(z){const I=f.pop();return I.end=j(),h.events.push(["exit",I,h]),I}function F(z,I){Q(z,I.from)}function A(z,I){I.restore()}function P(z,I){return B;function B($,G,q){let ae,Z,X,T;return Array.isArray($)?H($):"tokenize"in $?H([$]):R($);function R(ie){return de;function de(me){const ye=me!==null&&ie[me],te=me!==null&&ie.null,be=[...Array.isArray(ye)?ye:ye?[ye]:[],...Array.isArray(te)?te:te?[te]:[]];return H(be)(me)}}function H(ie){return ae=ie,Z=0,ie.length===0?q:S(ie[Z])}function S(ie){return de;function de(me){return T=K(),X=ie,ie.partial||(h.currentConstruct=ie),ie.name&&h.parser.constructs.disable.null.includes(ie.name)?ee():ie.tokenize.call(I?Object.assign(Object.create(h),I):h,p,U,ee)(me)}}function U(ie){return z(X,T),G}function ee(ie){return T.restore(),++Z<ae.length?S(ae[Z]):q}}}function Q(z,I){z.resolveAll&&!c.includes(z)&&c.push(z),z.resolve&&_a(h.events,I,h.events.length-I,z.resolve(h.events.slice(I),h)),z.resolveTo&&(h.events=z.resolveTo(h.events,h))}function K(){const z=j(),I=h.previous,B=h.currentConstruct,$=h.events.length,G=Array.from(f);return{from:$,restore:q};function q(){l=z,h.previous=I,h.currentConstruct=B,h.events.length=$,f=G,O()}}function O(){l.line in o&&l.column<2&&(l.column=o[l.line],l.offset+=o[l.line]-1)}}function OA(e,t){const a=t.start._index,l=t.start._bufferIndex,o=t.end._index,c=t.end._bufferIndex;let u;if(a===o)u=[e[a].slice(l,c)];else{if(u=e.slice(a,o),l>-1){const f=u[0];typeof f=="string"?u[0]=f.slice(l):u.shift()}c>0&&u.push(e[o].slice(0,c))}return u}function DA(e,t){let a=-1;const l=[];let o;for(;++a<e.length;){const c=e[a];let u;if(typeof c=="string")u=c;else switch(c){case-5:{u="\r";break}case-4:{u=`
138
- `;break}case-3:{u=`\r
139
- `;break}case-2:{u=t?" ":" ";break}case-1:{if(!t&&o)continue;u=" ";break}default:u=String.fromCharCode(c)}o=c===-2,l.push(u)}return l.join("")}function zA(e){const l={constructs:o2([IA,...(e||{}).extensions||[]]),content:o(Z3),defined:[],document:o(eE),flow:o(yA),lazy:{},string:o(kA),text:o(wA)};return l;function o(c){return u;function u(f){return LA(l,c,f)}}}function UA(e){for(;!m2(e););return e}const jb=/[\0\t\n\r]/g;function $A(){let e=1,t="",a=!0,l;return o;function o(c,u,f){const p=[];let h,g,v,k,w;for(c=t+(typeof c=="string"?c.toString():new TextDecoder(u||void 0).decode(c)),v=0,t="",a&&(c.charCodeAt(0)===65279&&v++,a=void 0);v<c.length;){if(jb.lastIndex=v,h=jb.exec(c),k=h&&h.index!==void 0?h.index:c.length,w=c.charCodeAt(k),!h){t=c.slice(v);break}if(w===10&&v===k&&l)p.push(-3),l=void 0;else switch(l&&(p.push(-5),l=void 0),v<k&&(p.push(c.slice(v,k)),e+=k-v),w){case 0:{p.push(65533),e++;break}case 9:{for(g=Math.ceil(e/4)*4,p.push(-2);e++<g;)p.push(-1);break}case 10:{p.push(-4),e=1;break}default:l=!0,e=1}v=k+1}return f&&(l&&p.push(-5),t&&p.push(t),p.push(null)),p}}const PA=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function BA(e){return e.replace(PA,HA)}function HA(e,t,a){if(t)return t;if(a.charCodeAt(0)===35){const o=a.charCodeAt(1),c=o===120||o===88;return c2(a.slice(c?2:1),c?16:10)}return xg(a)||e}const v2={}.hasOwnProperty;function FA(e,t,a){return t&&typeof t=="object"&&(a=t,t=void 0),qA(a)(UA(zA(a).document().write($A()(e,t,!0))))}function qA(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:c(rn),autolinkProtocol:K,autolinkEmail:K,atxHeading:c(Ve),blockQuote:c(te),characterEscape:K,characterReference:K,codeFenced:c(be),codeFencedFenceInfo:u,codeFencedFenceMeta:u,codeIndented:c(be,u),codeText:c(Re,u),codeTextData:K,data:K,codeFlowValue:K,definition:c(Fe),definitionDestinationString:u,definitionLabelString:u,definitionTitleString:u,emphasis:c(ce),hardBreakEscape:c(je),hardBreakTrailing:c(je),htmlFlow:c(wt,u),htmlFlowData:K,htmlText:c(wt,u),htmlTextData:K,image:c(an),label:u,link:c(rn),listItem:c(Ut),listItemValue:k,listOrdered:c(sn,v),listUnordered:c(sn),paragraph:c(At),reference:S,referenceString:u,resourceDestinationString:u,resourceTitleString:u,setextHeading:c(Ve),strong:c(fn),thematicBreak:c(nn)},exit:{atxHeading:p(),atxHeadingSequence:F,autolink:p(),autolinkEmail:ye,autolinkProtocol:me,blockQuote:p(),characterEscapeValue:O,characterReferenceMarkerHexadecimal:ee,characterReferenceMarkerNumeric:ee,characterReferenceValue:ie,characterReference:de,codeFenced:p(C),codeFencedFence:E,codeFencedFenceInfo:w,codeFencedFenceMeta:j,codeFlowValue:O,codeIndented:p(M),codeText:p(G),codeTextData:O,data:O,definition:p(),definitionDestinationString:V,definitionLabelString:_,definitionTitleString:D,emphasis:p(),hardBreakEscape:p(I),hardBreakTrailing:p(I),htmlFlow:p(B),htmlFlowData:O,htmlText:p($),htmlTextData:O,image:p(ae),label:X,labelText:Z,lineEnding:z,link:p(q),listItem:p(),listOrdered:p(),listUnordered:p(),paragraph:p(),referenceString:U,resourceDestinationString:T,resourceTitleString:R,resource:H,setextHeading:p(Q),setextHeadingLineSequence:P,setextHeadingText:A,strong:p(),thematicBreak:p()}};b2(t,(e||{}).mdastExtensions||[]);const a={};return l;function l(pe){let Se={type:"root",children:[]};const De={stack:[Se],tokenStack:[],config:t,enter:f,exit:h,buffer:u,resume:g,data:a},ze=[];let Ue=-1;for(;++Ue<pe.length;)if(pe[Ue][1].type==="listOrdered"||pe[Ue][1].type==="listUnordered")if(pe[Ue][0]==="enter")ze.push(Ue);else{const W=ze.pop();Ue=o(pe,W,Ue)}for(Ue=-1;++Ue<pe.length;){const W=t[pe[Ue][0]];v2.call(W,pe[Ue][1].type)&&W[pe[Ue][1].type].call(Object.assign({sliceSerialize:pe[Ue][2].sliceSerialize},De),pe[Ue][1])}if(De.tokenStack.length>0){const W=De.tokenStack[De.tokenStack.length-1];(W[1]||Cb).call(De,void 0,W[0])}for(Se.position={start:Rs(pe.length>0?pe[0][1].start:{line:1,column:1,offset:0}),end:Rs(pe.length>0?pe[pe.length-2][1].end:{line:1,column:1,offset:0})},Ue=-1;++Ue<t.transforms.length;)Se=t.transforms[Ue](Se)||Se;return Se}function o(pe,Se,De){let ze=Se-1,Ue=-1,W=!1,ge,Ne,Te,Pe;for(;++ze<=De;){const We=pe[ze];switch(We[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{We[0]==="enter"?Ue++:Ue--,Pe=void 0;break}case"lineEndingBlank":{We[0]==="enter"&&(ge&&!Pe&&!Ue&&!Te&&(Te=ze),Pe=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:Pe=void 0}if(!Ue&&We[0]==="enter"&&We[1].type==="listItemPrefix"||Ue===-1&&We[0]==="exit"&&(We[1].type==="listUnordered"||We[1].type==="listOrdered")){if(ge){let tt=ze;for(Ne=void 0;tt--;){const it=pe[tt];if(it[1].type==="lineEnding"||it[1].type==="lineEndingBlank"){if(it[0]==="exit")continue;Ne&&(pe[Ne][1].type="lineEndingBlank",W=!0),it[1].type="lineEnding",Ne=tt}else if(!(it[1].type==="linePrefix"||it[1].type==="blockQuotePrefix"||it[1].type==="blockQuotePrefixWhitespace"||it[1].type==="blockQuoteMarker"||it[1].type==="listItemIndent"))break}Te&&(!Ne||Te<Ne)&&(ge._spread=!0),ge.end=Object.assign({},Ne?pe[Ne][1].start:We[1].end),pe.splice(Ne||ze,0,["exit",ge,We[2]]),ze++,De++}if(We[1].type==="listItemPrefix"){const tt={type:"listItem",_spread:!1,start:Object.assign({},We[1].start),end:void 0};ge=tt,pe.splice(ze,0,["enter",tt,We[2]]),ze++,De++,Te=void 0,Pe=!0}}}return pe[Se][1]._spread=W,De}function c(pe,Se){return De;function De(ze){f.call(this,pe(ze),ze),Se&&Se.call(this,ze)}}function u(){this.stack.push({type:"fragment",children:[]})}function f(pe,Se,De){this.stack[this.stack.length-1].children.push(pe),this.stack.push(pe),this.tokenStack.push([Se,De||void 0]),pe.position={start:Rs(Se.start),end:void 0}}function p(pe){return Se;function Se(De){pe&&pe.call(this,De),h.call(this,De)}}function h(pe,Se){const De=this.stack.pop(),ze=this.tokenStack.pop();if(ze)ze[0].type!==pe.type&&(Se?Se.call(this,pe,ze[0]):(ze[1]||Cb).call(this,pe,ze[0]));else throw new Error("Cannot close `"+pe.type+"` ("+Po({start:pe.start,end:pe.end})+"): it’s not open");De.position.end=Rs(pe.end)}function g(){return gg(this.stack.pop())}function v(){this.data.expectingFirstListItemValue=!0}function k(pe){if(this.data.expectingFirstListItemValue){const Se=this.stack[this.stack.length-2];Se.start=Number.parseInt(this.sliceSerialize(pe),10),this.data.expectingFirstListItemValue=void 0}}function w(){const pe=this.resume(),Se=this.stack[this.stack.length-1];Se.lang=pe}function j(){const pe=this.resume(),Se=this.stack[this.stack.length-1];Se.meta=pe}function E(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function C(){const pe=this.resume(),Se=this.stack[this.stack.length-1];Se.value=pe.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function M(){const pe=this.resume(),Se=this.stack[this.stack.length-1];Se.value=pe.replace(/(\r?\n|\r)$/g,"")}function _(pe){const Se=this.resume(),De=this.stack[this.stack.length-1];De.label=Se,De.identifier=pr(this.sliceSerialize(pe)).toLowerCase()}function D(){const pe=this.resume(),Se=this.stack[this.stack.length-1];Se.title=pe}function V(){const pe=this.resume(),Se=this.stack[this.stack.length-1];Se.url=pe}function F(pe){const Se=this.stack[this.stack.length-1];if(!Se.depth){const De=this.sliceSerialize(pe).length;Se.depth=De}}function A(){this.data.setextHeadingSlurpLineEnding=!0}function P(pe){const Se=this.stack[this.stack.length-1];Se.depth=this.sliceSerialize(pe).codePointAt(0)===61?1:2}function Q(){this.data.setextHeadingSlurpLineEnding=void 0}function K(pe){const De=this.stack[this.stack.length-1].children;let ze=De[De.length-1];(!ze||ze.type!=="text")&&(ze=st(),ze.position={start:Rs(pe.start),end:void 0},De.push(ze)),this.stack.push(ze)}function O(pe){const Se=this.stack.pop();Se.value+=this.sliceSerialize(pe),Se.position.end=Rs(pe.end)}function z(pe){const Se=this.stack[this.stack.length-1];if(this.data.atHardBreak){const De=Se.children[Se.children.length-1];De.position.end=Rs(pe.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(Se.type)&&(K.call(this,pe),O.call(this,pe))}function I(){this.data.atHardBreak=!0}function B(){const pe=this.resume(),Se=this.stack[this.stack.length-1];Se.value=pe}function $(){const pe=this.resume(),Se=this.stack[this.stack.length-1];Se.value=pe}function G(){const pe=this.resume(),Se=this.stack[this.stack.length-1];Se.value=pe}function q(){const pe=this.stack[this.stack.length-1];if(this.data.inReference){const Se=this.data.referenceType||"shortcut";pe.type+="Reference",pe.referenceType=Se,delete pe.url,delete pe.title}else delete pe.identifier,delete pe.label;this.data.referenceType=void 0}function ae(){const pe=this.stack[this.stack.length-1];if(this.data.inReference){const Se=this.data.referenceType||"shortcut";pe.type+="Reference",pe.referenceType=Se,delete pe.url,delete pe.title}else delete pe.identifier,delete pe.label;this.data.referenceType=void 0}function Z(pe){const Se=this.sliceSerialize(pe),De=this.stack[this.stack.length-2];De.label=BA(Se),De.identifier=pr(Se).toLowerCase()}function X(){const pe=this.stack[this.stack.length-1],Se=this.resume(),De=this.stack[this.stack.length-1];if(this.data.inReference=!0,De.type==="link"){const ze=pe.children;De.children=ze}else De.alt=Se}function T(){const pe=this.resume(),Se=this.stack[this.stack.length-1];Se.url=pe}function R(){const pe=this.resume(),Se=this.stack[this.stack.length-1];Se.title=pe}function H(){this.data.inReference=void 0}function S(){this.data.referenceType="collapsed"}function U(pe){const Se=this.resume(),De=this.stack[this.stack.length-1];De.label=Se,De.identifier=pr(this.sliceSerialize(pe)).toLowerCase(),this.data.referenceType="full"}function ee(pe){this.data.characterReferenceType=pe.type}function ie(pe){const Se=this.sliceSerialize(pe),De=this.data.characterReferenceType;let ze;De?(ze=c2(Se,De==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):ze=xg(Se);const Ue=this.stack[this.stack.length-1];Ue.value+=ze}function de(pe){const Se=this.stack.pop();Se.position.end=Rs(pe.end)}function me(pe){O.call(this,pe);const Se=this.stack[this.stack.length-1];Se.url=this.sliceSerialize(pe)}function ye(pe){O.call(this,pe);const Se=this.stack[this.stack.length-1];Se.url="mailto:"+this.sliceSerialize(pe)}function te(){return{type:"blockquote",children:[]}}function be(){return{type:"code",lang:null,meta:null,value:""}}function Re(){return{type:"inlineCode",value:""}}function Fe(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function ce(){return{type:"emphasis",children:[]}}function Ve(){return{type:"heading",depth:0,children:[]}}function je(){return{type:"break"}}function wt(){return{type:"html",value:""}}function an(){return{type:"image",title:null,url:"",alt:null}}function rn(){return{type:"link",title:null,url:"",children:[]}}function sn(pe){return{type:"list",ordered:pe.type==="listOrdered",start:null,spread:pe._spread,children:[]}}function Ut(pe){return{type:"listItem",spread:pe._spread,checked:null,children:[]}}function At(){return{type:"paragraph",children:[]}}function fn(){return{type:"strong",children:[]}}function st(){return{type:"text",value:""}}function nn(){return{type:"thematicBreak"}}}function Rs(e){return{line:e.line,column:e.column,offset:e.offset}}function b2(e,t){let a=-1;for(;++a<t.length;){const l=t[a];Array.isArray(l)?b2(e,l):VA(e,l)}}function VA(e,t){let a;for(a in t)if(v2.call(t,a))switch(a){case"canContainEols":{const l=t[a];l&&e[a].push(...l);break}case"transforms":{const l=t[a];l&&e[a].push(...l);break}case"enter":case"exit":{const l=t[a];l&&Object.assign(e[a],l);break}}}function Cb(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+Po({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+Po({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+Po({start:t.start,end:t.end})+") is still open")}function GA(e){const t=this;t.parser=a;function a(l){return FA(l,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function WA(e,t){const a={type:"element",tagName:"blockquote",properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,a),e.applyData(t,a)}function KA(e,t){const a={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,a),[e.applyData(t,a),{type:"text",value:`
140
- `}]}function YA(e,t){const a=t.value?t.value+`
141
- `:"",l={},o=t.lang?t.lang.split(/\s+/):[];o.length>0&&(l.className=["language-"+o[0]]);let c={type:"element",tagName:"code",properties:l,children:[{type:"text",value:a}]};return t.meta&&(c.data={meta:t.meta}),e.patch(t,c),c=e.applyData(t,c),c={type:"element",tagName:"pre",properties:{},children:[c]},e.patch(t,c),c}function QA(e,t){const a={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,a),e.applyData(t,a)}function XA(e,t){const a={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,a),e.applyData(t,a)}function ZA(e,t){const a=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",l=String(t.identifier).toUpperCase(),o=Si(l.toLowerCase()),c=e.footnoteOrder.indexOf(l);let u,f=e.footnoteCounts.get(l);f===void 0?(f=0,e.footnoteOrder.push(l),u=e.footnoteOrder.length):u=c+1,f+=1,e.footnoteCounts.set(l,f);const p={type:"element",tagName:"a",properties:{href:"#"+a+"fn-"+o,id:a+"fnref-"+o+(f>1?"-"+f:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(u)}]};e.patch(t,p);const h={type:"element",tagName:"sup",properties:{},children:[p]};return e.patch(t,h),e.applyData(t,h)}function JA(e,t){const a={type:"element",tagName:"h"+t.depth,properties:{},children:e.all(t)};return e.patch(t,a),e.applyData(t,a)}function e6(e,t){if(e.options.allowDangerousHtml){const a={type:"raw",value:t.value};return e.patch(t,a),e.applyData(t,a)}}function k2(e,t){const a=t.referenceType;let l="]";if(a==="collapsed"?l+="[]":a==="full"&&(l+="["+(t.label||t.identifier)+"]"),t.type==="imageReference")return[{type:"text",value:"!["+t.alt+l}];const o=e.all(t),c=o[0];c&&c.type==="text"?c.value="["+c.value:o.unshift({type:"text",value:"["});const u=o[o.length-1];return u&&u.type==="text"?u.value+=l:o.push({type:"text",value:l}),o}function t6(e,t){const a=String(t.identifier).toUpperCase(),l=e.definitionById.get(a);if(!l)return k2(e,t);const o={src:Si(l.url||""),alt:t.alt};l.title!==null&&l.title!==void 0&&(o.title=l.title);const c={type:"element",tagName:"img",properties:o,children:[]};return e.patch(t,c),e.applyData(t,c)}function n6(e,t){const a={src:Si(t.url)};t.alt!==null&&t.alt!==void 0&&(a.alt=t.alt),t.title!==null&&t.title!==void 0&&(a.title=t.title);const l={type:"element",tagName:"img",properties:a,children:[]};return e.patch(t,l),e.applyData(t,l)}function a6(e,t){const a={type:"text",value:t.value.replace(/\r?\n|\r/g," ")};e.patch(t,a);const l={type:"element",tagName:"code",properties:{},children:[a]};return e.patch(t,l),e.applyData(t,l)}function r6(e,t){const a=String(t.identifier).toUpperCase(),l=e.definitionById.get(a);if(!l)return k2(e,t);const o={href:Si(l.url||"")};l.title!==null&&l.title!==void 0&&(o.title=l.title);const c={type:"element",tagName:"a",properties:o,children:e.all(t)};return e.patch(t,c),e.applyData(t,c)}function s6(e,t){const a={href:Si(t.url)};t.title!==null&&t.title!==void 0&&(a.title=t.title);const l={type:"element",tagName:"a",properties:a,children:e.all(t)};return e.patch(t,l),e.applyData(t,l)}function l6(e,t,a){const l=e.all(t),o=a?i6(a):w2(t),c={},u=[];if(typeof t.checked=="boolean"){const g=l[0];let v;g&&g.type==="element"&&g.tagName==="p"?v=g:(v={type:"element",tagName:"p",properties:{},children:[]},l.unshift(v)),v.children.length>0&&v.children.unshift({type:"text",value:" "}),v.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:t.checked,disabled:!0},children:[]}),c.className=["task-list-item"]}let f=-1;for(;++f<l.length;){const g=l[f];(o||f!==0||g.type!=="element"||g.tagName!=="p")&&u.push({type:"text",value:`
142
- `}),g.type==="element"&&g.tagName==="p"&&!o?u.push(...g.children):u.push(g)}const p=l[l.length-1];p&&(o||p.type!=="element"||p.tagName!=="p")&&u.push({type:"text",value:`
143
- `});const h={type:"element",tagName:"li",properties:c,children:u};return e.patch(t,h),e.applyData(t,h)}function i6(e){let t=!1;if(e.type==="list"){t=e.spread||!1;const a=e.children;let l=-1;for(;!t&&++l<a.length;)t=w2(a[l])}return t}function w2(e){const t=e.spread;return t??e.children.length>1}function o6(e,t){const a={},l=e.all(t);let o=-1;for(typeof t.start=="number"&&t.start!==1&&(a.start=t.start);++o<l.length;){const u=l[o];if(u.type==="element"&&u.tagName==="li"&&u.properties&&Array.isArray(u.properties.className)&&u.properties.className.includes("task-list-item")){a.className=["contains-task-list"];break}}const c={type:"element",tagName:t.ordered?"ol":"ul",properties:a,children:e.wrap(l,!0)};return e.patch(t,c),e.applyData(t,c)}function c6(e,t){const a={type:"element",tagName:"p",properties:{},children:e.all(t)};return e.patch(t,a),e.applyData(t,a)}function u6(e,t){const a={type:"root",children:e.wrap(e.all(t))};return e.patch(t,a),e.applyData(t,a)}function d6(e,t){const a={type:"element",tagName:"strong",properties:{},children:e.all(t)};return e.patch(t,a),e.applyData(t,a)}function f6(e,t){const a=e.all(t),l=a.shift(),o=[];if(l){const u={type:"element",tagName:"thead",properties:{},children:e.wrap([l],!0)};e.patch(t.children[0],u),o.push(u)}if(a.length>0){const u={type:"element",tagName:"tbody",properties:{},children:e.wrap(a,!0)},f=fg(t.children[1]),p=t2(t.children[t.children.length-1]);f&&p&&(u.position={start:f,end:p}),o.push(u)}const c={type:"element",tagName:"table",properties:{},children:e.wrap(o,!0)};return e.patch(t,c),e.applyData(t,c)}function m6(e,t,a){const l=a?a.children:void 0,c=(l?l.indexOf(t):1)===0?"th":"td",u=a&&a.type==="table"?a.align:void 0,f=u?u.length:t.children.length;let p=-1;const h=[];for(;++p<f;){const v=t.children[p],k={},w=u?u[p]:void 0;w&&(k.align=w);let j={type:"element",tagName:c,properties:k,children:[]};v&&(j.children=e.all(v),e.patch(v,j),j=e.applyData(v,j)),h.push(j)}const g={type:"element",tagName:"tr",properties:{},children:e.wrap(h,!0)};return e.patch(t,g),e.applyData(t,g)}function p6(e,t){const a={type:"element",tagName:"td",properties:{},children:e.all(t)};return e.patch(t,a),e.applyData(t,a)}const Nb=9,Tb=32;function h6(e){const t=String(e),a=/\r?\n|\r/g;let l=a.exec(t),o=0;const c=[];for(;l;)c.push(Mb(t.slice(o,l.index),o>0,!0),l[0]),o=l.index+l[0].length,l=a.exec(t);return c.push(Mb(t.slice(o),o>0,!1)),c.join("")}function Mb(e,t,a){let l=0,o=e.length;if(t){let c=e.codePointAt(l);for(;c===Nb||c===Tb;)l++,c=e.codePointAt(l)}if(a){let c=e.codePointAt(o-1);for(;c===Nb||c===Tb;)o--,c=e.codePointAt(o-1)}return o>l?e.slice(l,o):""}function g6(e,t){const a={type:"text",value:h6(String(t.value))};return e.patch(t,a),e.applyData(t,a)}function x6(e,t){const a={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,a),e.applyData(t,a)}const y6={blockquote:WA,break:KA,code:YA,delete:QA,emphasis:XA,footnoteReference:ZA,heading:JA,html:e6,imageReference:t6,image:n6,inlineCode:a6,linkReference:r6,link:s6,listItem:l6,list:o6,paragraph:c6,root:u6,strong:d6,table:f6,tableCell:p6,tableRow:m6,text:g6,thematicBreak:x6,toml:Eu,yaml:Eu,definition:Eu,footnoteDefinition:Eu};function Eu(){}const S2=-1,Ud=0,Ho=1,dd=2,vg=3,bg=4,kg=5,wg=6,j2=7,C2=8,v6=typeof self=="object"?self:globalThis,Eb=(e,t)=>{switch(e){case"Function":case"SharedWorker":case"Worker":case"eval":case"setInterval":case"setTimeout":throw new TypeError("unable to deserialize "+e)}return new v6[e](t)},b6=(e,t)=>{const a=(o,c)=>(e.set(c,o),o),l=o=>{if(e.has(o))return e.get(o);const[c,u]=t[o];switch(c){case Ud:case S2:return a(u,o);case Ho:{const f=a([],o);for(const p of u)f.push(l(p));return f}case dd:{const f=a({},o);for(const[p,h]of u)f[l(p)]=l(h);return f}case vg:return a(new Date(u),o);case bg:{const{source:f,flags:p}=u;return a(new RegExp(f,p),o)}case kg:{const f=a(new Map,o);for(const[p,h]of u)f.set(l(p),l(h));return f}case wg:{const f=a(new Set,o);for(const p of u)f.add(l(p));return f}case j2:{const{name:f,message:p}=u;return a(Eb(f,p),o)}case C2:return a(BigInt(u),o);case"BigInt":return a(Object(BigInt(u)),o);case"ArrayBuffer":return a(new Uint8Array(u).buffer,u);case"DataView":{const{buffer:f}=new Uint8Array(u);return a(new DataView(f),u)}}return a(Eb(c,u),o)};return l},Ab=e=>b6(new Map,e)(0),fl="",{toString:k6}={},{keys:w6}=Object,So=e=>{const t=typeof e;if(t!=="object"||!e)return[Ud,t];const a=k6.call(e).slice(8,-1);switch(a){case"Array":return[Ho,fl];case"Object":return[dd,fl];case"Date":return[vg,fl];case"RegExp":return[bg,fl];case"Map":return[kg,fl];case"Set":return[wg,fl];case"DataView":return[Ho,a]}return a.includes("Array")?[Ho,a]:a.includes("Error")?[j2,a]:[dd,a]},Au=([e,t])=>e===Ud&&(t==="function"||t==="symbol"),S6=(e,t,a,l)=>{const o=(u,f)=>{const p=l.push(u)-1;return a.set(f,p),p},c=u=>{if(a.has(u))return a.get(u);let[f,p]=So(u);switch(f){case Ud:{let g=u;switch(p){case"bigint":f=C2,g=u.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+p);g=null;break;case"undefined":return o([S2],u)}return o([f,g],u)}case Ho:{if(p){let k=u;return p==="DataView"?k=new Uint8Array(u.buffer):p==="ArrayBuffer"&&(k=new Uint8Array(u)),o([p,[...k]],u)}const g=[],v=o([f,g],u);for(const k of u)g.push(c(k));return v}case dd:{if(p)switch(p){case"BigInt":return o([p,u.toString()],u);case"Boolean":case"Number":case"String":return o([p,u.valueOf()],u)}if(t&&"toJSON"in u)return c(u.toJSON());const g=[],v=o([f,g],u);for(const k of w6(u))(e||!Au(So(u[k])))&&g.push([c(k),c(u[k])]);return v}case vg:return o([f,isNaN(u.getTime())?fl:u.toISOString()],u);case bg:{const{source:g,flags:v}=u;return o([f,{source:g,flags:v}],u)}case kg:{const g=[],v=o([f,g],u);for(const[k,w]of u)(e||!(Au(So(k))||Au(So(w))))&&g.push([c(k),c(w)]);return v}case wg:{const g=[],v=o([f,g],u);for(const k of u)(e||!Au(So(k)))&&g.push(c(k));return v}}const{message:h}=u;return o([f,{name:p,message:h}],u)};return c},Rb=(e,{json:t,lossy:a}={})=>{const l=[];return S6(!(t||a),!!t,new Map,l)(e),l},fd=typeof structuredClone=="function"?(e,t)=>t&&("json"in t||"lossy"in t)?Ab(Rb(e,t)):structuredClone(e):(e,t)=>Ab(Rb(e,t));function j6(e,t){const a=[{type:"text",value:"↩"}];return t>1&&a.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(t)}]}),a}function C6(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}function N6(e){const t=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",a=e.options.footnoteBackContent||j6,l=e.options.footnoteBackLabel||C6,o=e.options.footnoteLabel||"Footnotes",c=e.options.footnoteLabelTagName||"h2",u=e.options.footnoteLabelProperties||{className:["sr-only"]},f=[];let p=-1;for(;++p<e.footnoteOrder.length;){const h=e.footnoteById.get(e.footnoteOrder[p]);if(!h)continue;const g=e.all(h),v=String(h.identifier).toUpperCase(),k=Si(v.toLowerCase());let w=0;const j=[],E=e.footnoteCounts.get(v);for(;E!==void 0&&++w<=E;){j.length>0&&j.push({type:"text",value:" "});let _=typeof a=="string"?a:a(p,w);typeof _=="string"&&(_={type:"text",value:_}),j.push({type:"element",tagName:"a",properties:{href:"#"+t+"fnref-"+k+(w>1?"-"+w:""),dataFootnoteBackref:"",ariaLabel:typeof l=="string"?l:l(p,w),className:["data-footnote-backref"]},children:Array.isArray(_)?_:[_]})}const C=g[g.length-1];if(C&&C.type==="element"&&C.tagName==="p"){const _=C.children[C.children.length-1];_&&_.type==="text"?_.value+=" ":C.children.push({type:"text",value:" "}),C.children.push(...j)}else g.push(...j);const M={type:"element",tagName:"li",properties:{id:t+"fn-"+k},children:e.wrap(g,!0)};e.patch(h,M),f.push(M)}if(f.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:c,properties:{...fd(u),id:"footnote-label"},children:[{type:"text",value:o}]},{type:"text",value:`
144
- `},{type:"element",tagName:"ol",properties:{},children:e.wrap(f,!0)},{type:"text",value:`
145
- `}]}}const $d=(function(e){if(e==null)return A6;if(typeof e=="function")return Pd(e);if(typeof e=="object")return Array.isArray(e)?T6(e):M6(e);if(typeof e=="string")return E6(e);throw new Error("Expected function, string, or object as test")});function T6(e){const t=[];let a=-1;for(;++a<e.length;)t[a]=$d(e[a]);return Pd(l);function l(...o){let c=-1;for(;++c<t.length;)if(t[c].apply(this,o))return!0;return!1}}function M6(e){const t=e;return Pd(a);function a(l){const o=l;let c;for(c in e)if(o[c]!==t[c])return!1;return!0}}function E6(e){return Pd(t);function t(a){return a&&a.type===e}}function Pd(e){return t;function t(a,l,o){return!!(R6(a)&&e.call(this,a,typeof l=="number"?l:void 0,o||void 0))}}function A6(){return!0}function R6(e){return e!==null&&typeof e=="object"&&"type"in e}const N2=[],_6=!0,ph=!1,I6="skip";function T2(e,t,a,l){let o;typeof t=="function"&&typeof a!="function"?(l=a,a=t):o=t;const c=$d(o),u=l?-1:1;f(e,void 0,[])();function f(p,h,g){const v=p&&typeof p=="object"?p:{};if(typeof v.type=="string"){const w=typeof v.tagName=="string"?v.tagName:typeof v.name=="string"?v.name:void 0;Object.defineProperty(k,"name",{value:"node ("+(p.type+(w?"<"+w+">":""))+")"})}return k;function k(){let w=N2,j,E,C;if((!t||c(p,h,g[g.length-1]||void 0))&&(w=L6(a(p,g)),w[0]===ph))return w;if("children"in p&&p.children){const M=p;if(M.children&&w[0]!==I6)for(E=(l?M.children.length:-1)+u,C=g.concat(M);E>-1&&E<M.children.length;){const _=M.children[E];if(j=f(_,E,C)(),j[0]===ph)return j;E=typeof j[1]=="number"?j[1]:E+u}}return w}}}function L6(e){return Array.isArray(e)?e:typeof e=="number"?[_6,e]:e==null?N2:[e]}function Sg(e,t,a,l){let o,c,u;typeof t=="function"&&typeof a!="function"?(c=void 0,u=t,o=a):(c=t,u=a,o=l),T2(e,c,f,o);function f(p,h){const g=h[h.length-1],v=g?g.children.indexOf(p):void 0;return u(p,v,g)}}const hh={}.hasOwnProperty,O6={};function D6(e,t){const a=t||O6,l=new Map,o=new Map,c=new Map,u={...y6,...a.handlers},f={all:h,applyData:U6,definitionById:l,footnoteById:o,footnoteCounts:c,footnoteOrder:[],handlers:u,one:p,options:a,patch:z6,wrap:P6};return Sg(e,function(g){if(g.type==="definition"||g.type==="footnoteDefinition"){const v=g.type==="definition"?l:o,k=String(g.identifier).toUpperCase();v.has(k)||v.set(k,g)}}),f;function p(g,v){const k=g.type,w=f.handlers[k];if(hh.call(f.handlers,k)&&w)return w(f,g,v);if(f.options.passThrough&&f.options.passThrough.includes(k)){if("children"in g){const{children:E,...C}=g,M=fd(C);return M.children=f.all(g),M}return fd(g)}return(f.options.unknownHandler||$6)(f,g,v)}function h(g){const v=[];if("children"in g){const k=g.children;let w=-1;for(;++w<k.length;){const j=f.one(k[w],g);if(j){if(w&&k[w-1].type==="break"&&(!Array.isArray(j)&&j.type==="text"&&(j.value=_b(j.value)),!Array.isArray(j)&&j.type==="element")){const E=j.children[0];E&&E.type==="text"&&(E.value=_b(E.value))}Array.isArray(j)?v.push(...j):v.push(j)}}}return v}}function z6(e,t){e.position&&(t.position=j3(e))}function U6(e,t){let a=t;if(e&&e.data){const l=e.data.hName,o=e.data.hChildren,c=e.data.hProperties;if(typeof l=="string")if(a.type==="element")a.tagName=l;else{const u="children"in a?a.children:[a];a={type:"element",tagName:l,properties:{},children:u}}a.type==="element"&&c&&Object.assign(a.properties,fd(c)),"children"in a&&a.children&&o!==null&&o!==void 0&&(a.children=o)}return a}function $6(e,t){const a=t.data||{},l="value"in t&&!(hh.call(a,"hProperties")||hh.call(a,"hChildren"))?{type:"text",value:t.value}:{type:"element",tagName:"div",properties:{},children:e.all(t)};return e.patch(t,l),e.applyData(t,l)}function P6(e,t){const a=[];let l=-1;for(t&&a.push({type:"text",value:`
146
- `});++l<e.length;)l&&a.push({type:"text",value:`
147
- `}),a.push(e[l]);return t&&e.length>0&&a.push({type:"text",value:`
148
- `}),a}function _b(e){let t=0,a=e.charCodeAt(t);for(;a===9||a===32;)t++,a=e.charCodeAt(t);return e.slice(t)}function Ib(e,t){const a=D6(e,t),l=a.one(e,void 0),o=N6(a),c=Array.isArray(l)?{type:"root",children:l}:l||{type:"root",children:[]};return o&&c.children.push({type:"text",value:`
149
- `},o),c}function B6(e,t){return e&&"run"in e?async function(a,l){const o=Ib(a,{file:l,...t});await e.run(o,l)}:function(a,l){return Ib(a,{file:l,...e||t})}}function Lb(e){if(e)throw e}var fp,Ob;function H6(){if(Ob)return fp;Ob=1;var e=Object.prototype.hasOwnProperty,t=Object.prototype.toString,a=Object.defineProperty,l=Object.getOwnPropertyDescriptor,o=function(h){return typeof Array.isArray=="function"?Array.isArray(h):t.call(h)==="[object Array]"},c=function(h){if(!h||t.call(h)!=="[object Object]")return!1;var g=e.call(h,"constructor"),v=h.constructor&&h.constructor.prototype&&e.call(h.constructor.prototype,"isPrototypeOf");if(h.constructor&&!g&&!v)return!1;var k;for(k in h);return typeof k>"u"||e.call(h,k)},u=function(h,g){a&&g.name==="__proto__"?a(h,g.name,{enumerable:!0,configurable:!0,value:g.newValue,writable:!0}):h[g.name]=g.newValue},f=function(h,g){if(g==="__proto__")if(e.call(h,g)){if(l)return l(h,g).value}else return;return h[g]};return fp=function p(){var h,g,v,k,w,j,E=arguments[0],C=1,M=arguments.length,_=!1;for(typeof E=="boolean"&&(_=E,E=arguments[1]||{},C=2),(E==null||typeof E!="object"&&typeof E!="function")&&(E={});C<M;++C)if(h=arguments[C],h!=null)for(g in h)v=f(E,g),k=f(h,g),E!==k&&(_&&k&&(c(k)||(w=o(k)))?(w?(w=!1,j=v&&o(v)?v:[]):j=v&&c(v)?v:{},u(E,{name:g,newValue:p(_,j,k)})):typeof k<"u"&&u(E,{name:g,newValue:k}));return E},fp}var F6=H6();const mp=xk(F6);function gh(e){if(typeof e!="object"||e===null)return!1;const t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function q6(){const e=[],t={run:a,use:l};return t;function a(...o){let c=-1;const u=o.pop();if(typeof u!="function")throw new TypeError("Expected function as last argument, not "+u);f(null,...o);function f(p,...h){const g=e[++c];let v=-1;if(p){u(p);return}for(;++v<o.length;)(h[v]===null||h[v]===void 0)&&(h[v]=o[v]);o=h,g?V6(g,f)(...h):u(null,...h)}}function l(o){if(typeof o!="function")throw new TypeError("Expected `middelware` to be a function, not "+o);return e.push(o),t}}function V6(e,t){let a;return l;function l(...u){const f=e.length>u.length;let p;f&&u.push(o);try{p=e.apply(this,u)}catch(h){const g=h;if(f&&a)throw g;return o(g)}f||(p&&p.then&&typeof p.then=="function"?p.then(c,o):p instanceof Error?o(p):c(p))}function o(u,...f){a||(a=!0,t(u,...f))}function c(u){o(null,u)}}const wr={basename:G6,dirname:W6,extname:K6,join:Y6,sep:"/"};function G6(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');mc(e);let a=0,l=-1,o=e.length,c;if(t===void 0||t.length===0||t.length>e.length){for(;o--;)if(e.codePointAt(o)===47){if(c){a=o+1;break}}else l<0&&(c=!0,l=o+1);return l<0?"":e.slice(a,l)}if(t===e)return"";let u=-1,f=t.length-1;for(;o--;)if(e.codePointAt(o)===47){if(c){a=o+1;break}}else u<0&&(c=!0,u=o+1),f>-1&&(e.codePointAt(o)===t.codePointAt(f--)?f<0&&(l=o):(f=-1,l=u));return a===l?l=u:l<0&&(l=e.length),e.slice(a,l)}function W6(e){if(mc(e),e.length===0)return".";let t=-1,a=e.length,l;for(;--a;)if(e.codePointAt(a)===47){if(l){t=a;break}}else l||(l=!0);return t<0?e.codePointAt(0)===47?"/":".":t===1&&e.codePointAt(0)===47?"//":e.slice(0,t)}function K6(e){mc(e);let t=e.length,a=-1,l=0,o=-1,c=0,u;for(;t--;){const f=e.codePointAt(t);if(f===47){if(u){l=t+1;break}continue}a<0&&(u=!0,a=t+1),f===46?o<0?o=t:c!==1&&(c=1):o>-1&&(c=-1)}return o<0||a<0||c===0||c===1&&o===a-1&&o===l+1?"":e.slice(o,a)}function Y6(...e){let t=-1,a;for(;++t<e.length;)mc(e[t]),e[t]&&(a=a===void 0?e[t]:a+"/"+e[t]);return a===void 0?".":Q6(a)}function Q6(e){mc(e);const t=e.codePointAt(0)===47;let a=X6(e,!t);return a.length===0&&!t&&(a="."),a.length>0&&e.codePointAt(e.length-1)===47&&(a+="/"),t?"/"+a:a}function X6(e,t){let a="",l=0,o=-1,c=0,u=-1,f,p;for(;++u<=e.length;){if(u<e.length)f=e.codePointAt(u);else{if(f===47)break;f=47}if(f===47){if(!(o===u-1||c===1))if(o!==u-1&&c===2){if(a.length<2||l!==2||a.codePointAt(a.length-1)!==46||a.codePointAt(a.length-2)!==46){if(a.length>2){if(p=a.lastIndexOf("/"),p!==a.length-1){p<0?(a="",l=0):(a=a.slice(0,p),l=a.length-1-a.lastIndexOf("/")),o=u,c=0;continue}}else if(a.length>0){a="",l=0,o=u,c=0;continue}}t&&(a=a.length>0?a+"/..":"..",l=2)}else a.length>0?a+="/"+e.slice(o+1,u):a=e.slice(o+1,u),l=u-o-1;o=u,c=0}else f===46&&c>-1?c++:c=-1}return a}function mc(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const Z6={cwd:J6};function J6(){return"/"}function xh(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function eR(e){if(typeof e=="string")e=new URL(e);else if(!xh(e)){const t=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code="ERR_INVALID_ARG_TYPE",t}if(e.protocol!=="file:"){const t=new TypeError("The URL must be of scheme file");throw t.code="ERR_INVALID_URL_SCHEME",t}return tR(e)}function tR(e){if(e.hostname!==""){const l=new TypeError('File URL host must be "localhost" or empty on darwin');throw l.code="ERR_INVALID_FILE_URL_HOST",l}const t=e.pathname;let a=-1;for(;++a<t.length;)if(t.codePointAt(a)===37&&t.codePointAt(a+1)===50){const l=t.codePointAt(a+2);if(l===70||l===102){const o=new TypeError("File URL path must not include encoded / characters");throw o.code="ERR_INVALID_FILE_URL_PATH",o}}return decodeURIComponent(t)}const pp=["history","path","basename","stem","extname","dirname"];class M2{constructor(t){let a;t?xh(t)?a={path:t}:typeof t=="string"||nR(t)?a={value:t}:a=t:a={},this.cwd="cwd"in a?"":Z6.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let l=-1;for(;++l<pp.length;){const c=pp[l];c in a&&a[c]!==void 0&&a[c]!==null&&(this[c]=c==="history"?[...a[c]]:a[c])}let o;for(o in a)pp.includes(o)||(this[o]=a[o])}get basename(){return typeof this.path=="string"?wr.basename(this.path):void 0}set basename(t){gp(t,"basename"),hp(t,"basename"),this.path=wr.join(this.dirname||"",t)}get dirname(){return typeof this.path=="string"?wr.dirname(this.path):void 0}set dirname(t){Db(this.basename,"dirname"),this.path=wr.join(t||"",this.basename)}get extname(){return typeof this.path=="string"?wr.extname(this.path):void 0}set extname(t){if(hp(t,"extname"),Db(this.dirname,"extname"),t){if(t.codePointAt(0)!==46)throw new Error("`extname` must start with `.`");if(t.includes(".",1))throw new Error("`extname` cannot contain multiple dots")}this.path=wr.join(this.dirname,this.stem+(t||""))}get path(){return this.history[this.history.length-1]}set path(t){xh(t)&&(t=eR(t)),gp(t,"path"),this.path!==t&&this.history.push(t)}get stem(){return typeof this.path=="string"?wr.basename(this.path,this.extname):void 0}set stem(t){gp(t,"stem"),hp(t,"stem"),this.path=wr.join(this.dirname||"",t+(this.extname||""))}fail(t,a,l){const o=this.message(t,a,l);throw o.fatal=!0,o}info(t,a,l){const o=this.message(t,a,l);return o.fatal=void 0,o}message(t,a,l){const o=new Kn(t,a,l);return this.path&&(o.name=this.path+":"+o.name,o.file=this.path),o.fatal=!1,this.messages.push(o),o}toString(t){return this.value===void 0?"":typeof this.value=="string"?this.value:new TextDecoder(t||void 0).decode(this.value)}}function hp(e,t){if(e&&e.includes(wr.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+wr.sep+"`")}function gp(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function Db(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}function nR(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const aR=(function(e){const l=this.constructor.prototype,o=l[e],c=function(){return o.apply(c,arguments)};return Object.setPrototypeOf(c,l),c}),rR={}.hasOwnProperty;class jg extends aR{constructor(){super("copy"),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=q6()}copy(){const t=new jg;let a=-1;for(;++a<this.attachers.length;){const l=this.attachers[a];t.use(...l)}return t.data(mp(!0,{},this.namespace)),t}data(t,a){return typeof t=="string"?arguments.length===2?(vp("data",this.frozen),this.namespace[t]=a,this):rR.call(this.namespace,t)&&this.namespace[t]||void 0:t?(vp("data",this.frozen),this.namespace=t,this):this.namespace}freeze(){if(this.frozen)return this;const t=this;for(;++this.freezeIndex<this.attachers.length;){const[a,...l]=this.attachers[this.freezeIndex];if(l[0]===!1)continue;l[0]===!0&&(l[0]=void 0);const o=a.call(t,...l);typeof o=="function"&&this.transformers.use(o)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(t){this.freeze();const a=Ru(t),l=this.parser||this.Parser;return xp("parse",l),l(String(a),a)}process(t,a){const l=this;return this.freeze(),xp("process",this.parser||this.Parser),yp("process",this.compiler||this.Compiler),a?o(void 0,a):new Promise(o);function o(c,u){const f=Ru(t),p=l.parse(f);l.run(p,f,function(g,v,k){if(g||!v||!k)return h(g);const w=v,j=l.stringify(w,k);iR(j)?k.value=j:k.result=j,h(g,k)});function h(g,v){g||!v?u(g):c?c(v):a(void 0,v)}}}processSync(t){let a=!1,l;return this.freeze(),xp("processSync",this.parser||this.Parser),yp("processSync",this.compiler||this.Compiler),this.process(t,o),Ub("processSync","process",a),l;function o(c,u){a=!0,Lb(c),l=u}}run(t,a,l){zb(t),this.freeze();const o=this.transformers;return!l&&typeof a=="function"&&(l=a,a=void 0),l?c(void 0,l):new Promise(c);function c(u,f){const p=Ru(a);o.run(t,p,h);function h(g,v,k){const w=v||t;g?f(g):u?u(w):l(void 0,w,k)}}}runSync(t,a){let l=!1,o;return this.run(t,a,c),Ub("runSync","run",l),o;function c(u,f){Lb(u),o=f,l=!0}}stringify(t,a){this.freeze();const l=Ru(a),o=this.compiler||this.Compiler;return yp("stringify",o),zb(t),o(t,l)}use(t,...a){const l=this.attachers,o=this.namespace;if(vp("use",this.frozen),t!=null)if(typeof t=="function")p(t,a);else if(typeof t=="object")Array.isArray(t)?f(t):u(t);else throw new TypeError("Expected usable value, not `"+t+"`");return this;function c(h){if(typeof h=="function")p(h,[]);else if(typeof h=="object")if(Array.isArray(h)){const[g,...v]=h;p(g,v)}else u(h);else throw new TypeError("Expected usable value, not `"+h+"`")}function u(h){if(!("plugins"in h)&&!("settings"in h))throw new Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");f(h.plugins),h.settings&&(o.settings=mp(!0,o.settings,h.settings))}function f(h){let g=-1;if(h!=null)if(Array.isArray(h))for(;++g<h.length;){const v=h[g];c(v)}else throw new TypeError("Expected a list of plugins, not `"+h+"`")}function p(h,g){let v=-1,k=-1;for(;++v<l.length;)if(l[v][0]===h){k=v;break}if(k===-1)l.push([h,...g]);else if(g.length>0){let[w,...j]=g;const E=l[k][1];gh(E)&&gh(w)&&(w=mp(!0,E,w)),l[k]=[h,w,...j]}}}}const sR=new jg().freeze();function xp(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function yp(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function vp(e,t){if(t)throw new Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function zb(e){if(!gh(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function Ub(e,t,a){if(!a)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function Ru(e){return lR(e)?e:new M2(e)}function lR(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function iR(e){return typeof e=="string"||oR(e)}function oR(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const cR="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",$b=[],Pb={allowDangerousHtml:!0},uR=/^(https?|ircs?|mailto|xmpp)$/i,dR=[{from:"astPlugins",id:"remove-buggy-html-in-markdown-parser"},{from:"allowDangerousHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"allowNode",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowElement"},{from:"allowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowedElements"},{from:"className",id:"remove-classname"},{from:"disallowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"disallowedElements"},{from:"escapeHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"includeElementIndex",id:"#remove-includeelementindex"},{from:"includeNodeIndex",id:"change-includenodeindex-to-includeelementindex"},{from:"linkTarget",id:"remove-linktarget"},{from:"plugins",id:"change-plugins-to-remarkplugins",to:"remarkPlugins"},{from:"rawSourcePos",id:"#remove-rawsourcepos"},{from:"renderers",id:"change-renderers-to-components",to:"components"},{from:"source",id:"change-source-to-children",to:"children"},{from:"sourcePos",id:"#remove-sourcepos"},{from:"transformImageUri",id:"#add-urltransform",to:"urlTransform"},{from:"transformLinkUri",id:"#add-urltransform",to:"urlTransform"}];function pc(e){const t=fR(e),a=mR(e);return pR(t.runSync(t.parse(a),a),e)}function fR(e){const t=e.rehypePlugins||$b,a=e.remarkPlugins||$b,l=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...Pb}:Pb;return sR().use(GA).use(a).use(B6,l).use(t)}function mR(e){const t=e.children||"",a=new M2;return typeof t=="string"&&(a.value=t),a}function pR(e,t){const a=t.allowedElements,l=t.allowElement,o=t.components,c=t.disallowedElements,u=t.skipHtml,f=t.unwrapDisallowed,p=t.urlTransform||hR;for(const g of dR)Object.hasOwn(t,g.from)&&(""+g.from+(g.to?"use `"+g.to+"` instead":"remove it")+cR+g.id,void 0);return Sg(e,h),E3(e,{Fragment:s.Fragment,components:o,ignoreInvalidStyle:!0,jsx:s.jsx,jsxs:s.jsxs,passKeys:!0,passNode:!0});function h(g,v,k){if(g.type==="raw"&&k&&typeof v=="number")return u?k.children.splice(v,1):k.children[v]={type:"text",value:g.value},v;if(g.type==="element"){let w;for(w in cp)if(Object.hasOwn(cp,w)&&Object.hasOwn(g.properties,w)){const j=g.properties[w],E=cp[w];(E===null||E.includes(g.tagName))&&(g.properties[w]=p(String(j||""),w,g))}}if(g.type==="element"){let w=a?!a.includes(g.tagName):c?c.includes(g.tagName):!1;if(!w&&l&&typeof v=="number"&&(w=!l(g,v,k)),w&&k&&typeof v=="number")return f&&g.children?k.children.splice(v,1,...g.children):k.children.splice(v,1),v}}}function hR(e){const t=e.indexOf(":"),a=e.indexOf("?"),l=e.indexOf("#"),o=e.indexOf("/");return t===-1||o!==-1&&t>o||a!==-1&&t>a||l!==-1&&t>l||uR.test(e.slice(0,t))?e:""}function Bb(e,t){const a=String(e);if(typeof t!="string")throw new TypeError("Expected character");let l=0,o=a.indexOf(t);for(;o!==-1;)l++,o=a.indexOf(t,o+t.length);return l}function gR(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function xR(e,t,a){const o=$d((a||{}).ignore||[]),c=yR(t);let u=-1;for(;++u<c.length;)T2(e,"text",f);function f(h,g){let v=-1,k;for(;++v<g.length;){const w=g[v],j=k?k.children:void 0;if(o(w,j?j.indexOf(w):void 0,k))return;k=w}if(k)return p(h,g)}function p(h,g){const v=g[g.length-1],k=c[u][0],w=c[u][1];let j=0;const C=v.children.indexOf(h);let M=!1,_=[];k.lastIndex=0;let D=k.exec(h.value);for(;D;){const V=D.index,F={index:D.index,input:D.input,stack:[...g,h]};let A=w(...D,F);if(typeof A=="string"&&(A=A.length>0?{type:"text",value:A}:void 0),A===!1?k.lastIndex=V+1:(j!==V&&_.push({type:"text",value:h.value.slice(j,V)}),Array.isArray(A)?_.push(...A):A&&_.push(A),j=V+D[0].length,M=!0),!k.global)break;D=k.exec(h.value)}return M?(j<h.value.length&&_.push({type:"text",value:h.value.slice(j)}),v.children.splice(C,1,..._)):_=[h],C+_.length}}function yR(e){const t=[];if(!Array.isArray(e))throw new TypeError("Expected find and replace tuple or list of tuples");const a=!e[0]||Array.isArray(e[0])?e:[e];let l=-1;for(;++l<a.length;){const o=a[l];t.push([vR(o[0]),bR(o[1])])}return t}function vR(e){return typeof e=="string"?new RegExp(gR(e),"g"):e}function bR(e){return typeof e=="function"?e:function(){return e}}const bp="phrasing",kp=["autolink","link","image","label"];function kR(){return{transforms:[MR],enter:{literalAutolink:SR,literalAutolinkEmail:wp,literalAutolinkHttp:wp,literalAutolinkWww:wp},exit:{literalAutolink:TR,literalAutolinkEmail:NR,literalAutolinkHttp:jR,literalAutolinkWww:CR}}}function wR(){return{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:bp,notInConstruct:kp},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:bp,notInConstruct:kp},{character:":",before:"[ps]",after:"\\/",inConstruct:bp,notInConstruct:kp}]}}function SR(e){this.enter({type:"link",title:null,url:"",children:[]},e)}function wp(e){this.config.enter.autolinkProtocol.call(this,e)}function jR(e){this.config.exit.autolinkProtocol.call(this,e)}function CR(e){this.config.exit.data.call(this,e);const t=this.stack[this.stack.length-1];t.type,t.url="http://"+this.sliceSerialize(e)}function NR(e){this.config.exit.autolinkEmail.call(this,e)}function TR(e){this.exit(e)}function MR(e){xR(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,ER],[new RegExp("(?<=^|\\s|\\p{P}|\\p{S})([-.\\w+]+)@([-\\w]+(?:\\.[-\\w]+)+)","gu"),AR]],{ignore:["link","linkReference"]})}function ER(e,t,a,l,o){let c="";if(!E2(o)||(/^w/i.test(t)&&(a=t+a,t="",c="http://"),!RR(a)))return!1;const u=_R(a+l);if(!u[0])return!1;const f={type:"link",title:null,url:c+t+u[0],children:[{type:"text",value:t+u[0]}]};return u[1]?[f,{type:"text",value:u[1]}]:f}function AR(e,t,a,l){return!E2(l,!0)||/[-\d_]$/.test(a)?!1:{type:"link",title:null,url:"mailto:"+t+"@"+a,children:[{type:"text",value:t+"@"+a}]}}function RR(e){const t=e.split(".");return!(t.length<2||t[t.length-1]&&(/_/.test(t[t.length-1])||!/[a-zA-Z\d]/.test(t[t.length-1]))||t[t.length-2]&&(/_/.test(t[t.length-2])||!/[a-zA-Z\d]/.test(t[t.length-2])))}function _R(e){const t=/[!"&'),.:;<>?\]}]+$/.exec(e);if(!t)return[e,void 0];e=e.slice(0,t.index);let a=t[0],l=a.indexOf(")");const o=Bb(e,"(");let c=Bb(e,")");for(;l!==-1&&o>c;)e+=a.slice(0,l+1),a=a.slice(l+1),l=a.indexOf(")"),c++;return[e,a]}function E2(e,t){const a=e.input.charCodeAt(e.index-1);return(e.index===0||Sl(a)||Dd(a))&&(!t||a!==47)}A2.peek=BR;function IR(){this.buffer()}function LR(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function OR(){this.buffer()}function DR(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function zR(e){const t=this.resume(),a=this.stack[this.stack.length-1];a.type,a.identifier=pr(this.sliceSerialize(e)).toLowerCase(),a.label=t}function UR(e){this.exit(e)}function $R(e){const t=this.resume(),a=this.stack[this.stack.length-1];a.type,a.identifier=pr(this.sliceSerialize(e)).toLowerCase(),a.label=t}function PR(e){this.exit(e)}function BR(){return"["}function A2(e,t,a,l){const o=a.createTracker(l);let c=o.move("[^");const u=a.enter("footnoteReference"),f=a.enter("reference");return c+=o.move(a.safe(a.associationId(e),{after:"]",before:c})),f(),u(),c+=o.move("]"),c}function HR(){return{enter:{gfmFootnoteCallString:IR,gfmFootnoteCall:LR,gfmFootnoteDefinitionLabelString:OR,gfmFootnoteDefinition:DR},exit:{gfmFootnoteCallString:zR,gfmFootnoteCall:UR,gfmFootnoteDefinitionLabelString:$R,gfmFootnoteDefinition:PR}}}function FR(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:a,footnoteReference:A2},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]};function a(l,o,c,u){const f=c.createTracker(u);let p=f.move("[^");const h=c.enter("footnoteDefinition"),g=c.enter("label");return p+=f.move(c.safe(c.associationId(l),{before:p,after:"]"})),g(),p+=f.move("]:"),l.children&&l.children.length>0&&(f.shift(4),p+=f.move((t?`
150
- `:" ")+c.indentLines(c.containerFlow(l,f.current()),t?R2:qR))),h(),p}}function qR(e,t,a){return t===0?e:R2(e,t,a)}function R2(e,t,a){return(a?"":" ")+e}const VR=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];_2.peek=QR;function GR(){return{canContainEols:["delete"],enter:{strikethrough:KR},exit:{strikethrough:YR}}}function WR(){return{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:VR}],handlers:{delete:_2}}}function KR(e){this.enter({type:"delete",children:[]},e)}function YR(e){this.exit(e)}function _2(e,t,a,l){const o=a.createTracker(l),c=a.enter("strikethrough");let u=o.move("~~");return u+=a.containerPhrasing(e,{...o.current(),before:u,after:"~"}),u+=o.move("~~"),c(),u}function QR(){return"~"}function XR(e){return e.length}function ZR(e,t){const a=t||{},l=(a.align||[]).concat(),o=a.stringLength||XR,c=[],u=[],f=[],p=[];let h=0,g=-1;for(;++g<e.length;){const E=[],C=[];let M=-1;for(e[g].length>h&&(h=e[g].length);++M<e[g].length;){const _=JR(e[g][M]);if(a.alignDelimiters!==!1){const D=o(_);C[M]=D,(p[M]===void 0||D>p[M])&&(p[M]=D)}E.push(_)}u[g]=E,f[g]=C}let v=-1;if(typeof l=="object"&&"length"in l)for(;++v<h;)c[v]=Hb(l[v]);else{const E=Hb(l);for(;++v<h;)c[v]=E}v=-1;const k=[],w=[];for(;++v<h;){const E=c[v];let C="",M="";E===99?(C=":",M=":"):E===108?C=":":E===114&&(M=":");let _=a.alignDelimiters===!1?1:Math.max(1,p[v]-C.length-M.length);const D=C+"-".repeat(_)+M;a.alignDelimiters!==!1&&(_=C.length+_+M.length,_>p[v]&&(p[v]=_),w[v]=_),k[v]=D}u.splice(1,0,k),f.splice(1,0,w),g=-1;const j=[];for(;++g<u.length;){const E=u[g],C=f[g];v=-1;const M=[];for(;++v<h;){const _=E[v]||"";let D="",V="";if(a.alignDelimiters!==!1){const F=p[v]-(C[v]||0),A=c[v];A===114?D=" ".repeat(F):A===99?F%2?(D=" ".repeat(F/2+.5),V=" ".repeat(F/2-.5)):(D=" ".repeat(F/2),V=D):V=" ".repeat(F)}a.delimiterStart!==!1&&!v&&M.push("|"),a.padding!==!1&&!(a.alignDelimiters===!1&&_==="")&&(a.delimiterStart!==!1||v)&&M.push(" "),a.alignDelimiters!==!1&&M.push(D),M.push(_),a.alignDelimiters!==!1&&M.push(V),a.padding!==!1&&M.push(" "),(a.delimiterEnd!==!1||v!==h-1)&&M.push("|")}j.push(a.delimiterEnd===!1?M.join("").replace(/ +$/,""):M.join(""))}return j.join(`
151
- `)}function JR(e){return e==null?"":String(e)}function Hb(e){const t=typeof e=="string"?e.codePointAt(0):0;return t===67||t===99?99:t===76||t===108?108:t===82||t===114?114:0}function e_(e,t,a,l){const o=a.enter("blockquote"),c=a.createTracker(l);c.move("> "),c.shift(2);const u=a.indentLines(a.containerFlow(e,c.current()),t_);return o(),u}function t_(e,t,a){return">"+(a?"":" ")+e}function n_(e,t){return Fb(e,t.inConstruct,!0)&&!Fb(e,t.notInConstruct,!1)}function Fb(e,t,a){if(typeof t=="string"&&(t=[t]),!t||t.length===0)return a;let l=-1;for(;++l<t.length;)if(e.includes(t[l]))return!0;return!1}function qb(e,t,a,l){let o=-1;for(;++o<a.unsafe.length;)if(a.unsafe[o].character===`
152
- `&&n_(a.stack,a.unsafe[o]))return/[ \t]/.test(l.before)?"":" ";return`\\
153
- `}function a_(e,t){const a=String(e);let l=a.indexOf(t),o=l,c=0,u=0;if(typeof t!="string")throw new TypeError("Expected substring");for(;l!==-1;)l===o?++c>u&&(u=c):c=1,o=l+t.length,l=a.indexOf(t,o);return u}function r_(e,t){return!!(t.options.fences===!1&&e.value&&!e.lang&&/[^ \r\n]/.test(e.value)&&!/^[\t ]*(?:[\r\n]|$)|(?:^|[\r\n])[\t ]*$/.test(e.value))}function s_(e){const t=e.options.fence||"`";if(t!=="`"&&t!=="~")throw new Error("Cannot serialize code with `"+t+"` for `options.fence`, expected `` ` `` or `~`");return t}function l_(e,t,a,l){const o=s_(a),c=e.value||"",u=o==="`"?"GraveAccent":"Tilde";if(r_(e,a)){const v=a.enter("codeIndented"),k=a.indentLines(c,i_);return v(),k}const f=a.createTracker(l),p=o.repeat(Math.max(a_(c,o)+1,3)),h=a.enter("codeFenced");let g=f.move(p);if(e.lang){const v=a.enter(`codeFencedLang${u}`);g+=f.move(a.safe(e.lang,{before:g,after:" ",encode:["`"],...f.current()})),v()}if(e.lang&&e.meta){const v=a.enter(`codeFencedMeta${u}`);g+=f.move(" "),g+=f.move(a.safe(e.meta,{before:g,after:`
154
- `,encode:["`"],...f.current()})),v()}return g+=f.move(`
155
- `),c&&(g+=f.move(c+`
156
- `)),g+=f.move(p),h(),g}function i_(e,t,a){return(a?"":" ")+e}function Cg(e){const t=e.options.quote||'"';if(t!=='"'&&t!=="'")throw new Error("Cannot serialize title with `"+t+"` for `options.quote`, expected `\"`, or `'`");return t}function o_(e,t,a,l){const o=Cg(a),c=o==='"'?"Quote":"Apostrophe",u=a.enter("definition");let f=a.enter("label");const p=a.createTracker(l);let h=p.move("[");return h+=p.move(a.safe(a.associationId(e),{before:h,after:"]",...p.current()})),h+=p.move("]: "),f(),!e.url||/[\0- \u007F]/.test(e.url)?(f=a.enter("destinationLiteral"),h+=p.move("<"),h+=p.move(a.safe(e.url,{before:h,after:">",...p.current()})),h+=p.move(">")):(f=a.enter("destinationRaw"),h+=p.move(a.safe(e.url,{before:h,after:e.title?" ":`
157
- `,...p.current()}))),f(),e.title&&(f=a.enter(`title${c}`),h+=p.move(" "+o),h+=p.move(a.safe(e.title,{before:h,after:o,...p.current()})),h+=p.move(o),f()),u(),h}function c_(e){const t=e.options.emphasis||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize emphasis with `"+t+"` for `options.emphasis`, expected `*`, or `_`");return t}function ec(e){return"&#x"+e.toString(16).toUpperCase()+";"}function md(e,t,a){const l=hi(e),o=hi(t);return l===void 0?o===void 0?a==="_"?{inside:!0,outside:!0}:{inside:!1,outside:!1}:o===1?{inside:!0,outside:!0}:{inside:!1,outside:!0}:l===1?o===void 0?{inside:!1,outside:!1}:o===1?{inside:!0,outside:!0}:{inside:!1,outside:!1}:o===void 0?{inside:!1,outside:!1}:o===1?{inside:!0,outside:!1}:{inside:!1,outside:!1}}I2.peek=u_;function I2(e,t,a,l){const o=c_(a),c=a.enter("emphasis"),u=a.createTracker(l),f=u.move(o);let p=u.move(a.containerPhrasing(e,{after:o,before:f,...u.current()}));const h=p.charCodeAt(0),g=md(l.before.charCodeAt(l.before.length-1),h,o);g.inside&&(p=ec(h)+p.slice(1));const v=p.charCodeAt(p.length-1),k=md(l.after.charCodeAt(0),v,o);k.inside&&(p=p.slice(0,-1)+ec(v));const w=u.move(o);return c(),a.attentionEncodeSurroundingInfo={after:k.outside,before:g.outside},f+p+w}function u_(e,t,a){return a.options.emphasis||"*"}function d_(e,t){let a=!1;return Sg(e,function(l){if("value"in l&&/\r?\n|\r/.test(l.value)||l.type==="break")return a=!0,ph}),!!((!e.depth||e.depth<3)&&gg(e)&&(t.options.setext||a))}function f_(e,t,a,l){const o=Math.max(Math.min(6,e.depth||1),1),c=a.createTracker(l);if(d_(e,a)){const g=a.enter("headingSetext"),v=a.enter("phrasing"),k=a.containerPhrasing(e,{...c.current(),before:`
158
- `,after:`
159
- `});return v(),g(),k+`
160
- `+(o===1?"=":"-").repeat(k.length-(Math.max(k.lastIndexOf("\r"),k.lastIndexOf(`
161
- `))+1))}const u="#".repeat(o),f=a.enter("headingAtx"),p=a.enter("phrasing");c.move(u+" ");let h=a.containerPhrasing(e,{before:"# ",after:`
162
- `,...c.current()});return/^[\t ]/.test(h)&&(h=ec(h.charCodeAt(0))+h.slice(1)),h=h?u+" "+h:u,a.options.closeAtx&&(h+=" "+u),p(),f(),h}L2.peek=m_;function L2(e){return e.value||""}function m_(){return"<"}O2.peek=p_;function O2(e,t,a,l){const o=Cg(a),c=o==='"'?"Quote":"Apostrophe",u=a.enter("image");let f=a.enter("label");const p=a.createTracker(l);let h=p.move("![");return h+=p.move(a.safe(e.alt,{before:h,after:"]",...p.current()})),h+=p.move("]("),f(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(f=a.enter("destinationLiteral"),h+=p.move("<"),h+=p.move(a.safe(e.url,{before:h,after:">",...p.current()})),h+=p.move(">")):(f=a.enter("destinationRaw"),h+=p.move(a.safe(e.url,{before:h,after:e.title?" ":")",...p.current()}))),f(),e.title&&(f=a.enter(`title${c}`),h+=p.move(" "+o),h+=p.move(a.safe(e.title,{before:h,after:o,...p.current()})),h+=p.move(o),f()),h+=p.move(")"),u(),h}function p_(){return"!"}D2.peek=h_;function D2(e,t,a,l){const o=e.referenceType,c=a.enter("imageReference");let u=a.enter("label");const f=a.createTracker(l);let p=f.move("![");const h=a.safe(e.alt,{before:p,after:"]",...f.current()});p+=f.move(h+"]["),u();const g=a.stack;a.stack=[],u=a.enter("reference");const v=a.safe(a.associationId(e),{before:p,after:"]",...f.current()});return u(),a.stack=g,c(),o==="full"||!h||h!==v?p+=f.move(v+"]"):o==="shortcut"?p=p.slice(0,-1):p+=f.move("]"),p}function h_(){return"!"}z2.peek=g_;function z2(e,t,a){let l=e.value||"",o="`",c=-1;for(;new RegExp("(^|[^`])"+o+"([^`]|$)").test(l);)o+="`";for(/[^ \r\n]/.test(l)&&(/^[ \r\n]/.test(l)&&/[ \r\n]$/.test(l)||/^`|`$/.test(l))&&(l=" "+l+" ");++c<a.unsafe.length;){const u=a.unsafe[c],f=a.compilePattern(u);let p;if(u.atBreak)for(;p=f.exec(l);){let h=p.index;l.charCodeAt(h)===10&&l.charCodeAt(h-1)===13&&h--,l=l.slice(0,h)+" "+l.slice(p.index+1)}}return o+l+o}function g_(){return"`"}function U2(e,t){const a=gg(e);return!!(!t.options.resourceLink&&e.url&&!e.title&&e.children&&e.children.length===1&&e.children[0].type==="text"&&(a===e.url||"mailto:"+a===e.url)&&/^[a-z][a-z+.-]+:/i.test(e.url)&&!/[\0- <>\u007F]/.test(e.url))}$2.peek=x_;function $2(e,t,a,l){const o=Cg(a),c=o==='"'?"Quote":"Apostrophe",u=a.createTracker(l);let f,p;if(U2(e,a)){const g=a.stack;a.stack=[],f=a.enter("autolink");let v=u.move("<");return v+=u.move(a.containerPhrasing(e,{before:v,after:">",...u.current()})),v+=u.move(">"),f(),a.stack=g,v}f=a.enter("link"),p=a.enter("label");let h=u.move("[");return h+=u.move(a.containerPhrasing(e,{before:h,after:"](",...u.current()})),h+=u.move("]("),p(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(p=a.enter("destinationLiteral"),h+=u.move("<"),h+=u.move(a.safe(e.url,{before:h,after:">",...u.current()})),h+=u.move(">")):(p=a.enter("destinationRaw"),h+=u.move(a.safe(e.url,{before:h,after:e.title?" ":")",...u.current()}))),p(),e.title&&(p=a.enter(`title${c}`),h+=u.move(" "+o),h+=u.move(a.safe(e.title,{before:h,after:o,...u.current()})),h+=u.move(o),p()),h+=u.move(")"),f(),h}function x_(e,t,a){return U2(e,a)?"<":"["}P2.peek=y_;function P2(e,t,a,l){const o=e.referenceType,c=a.enter("linkReference");let u=a.enter("label");const f=a.createTracker(l);let p=f.move("[");const h=a.containerPhrasing(e,{before:p,after:"]",...f.current()});p+=f.move(h+"]["),u();const g=a.stack;a.stack=[],u=a.enter("reference");const v=a.safe(a.associationId(e),{before:p,after:"]",...f.current()});return u(),a.stack=g,c(),o==="full"||!h||h!==v?p+=f.move(v+"]"):o==="shortcut"?p=p.slice(0,-1):p+=f.move("]"),p}function y_(){return"["}function Ng(e){const t=e.options.bullet||"*";if(t!=="*"&&t!=="+"&&t!=="-")throw new Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function v_(e){const t=Ng(e),a=e.options.bulletOther;if(!a)return t==="*"?"-":"*";if(a!=="*"&&a!=="+"&&a!=="-")throw new Error("Cannot serialize items with `"+a+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(a===t)throw new Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+a+"`) to be different");return a}function b_(e){const t=e.options.bulletOrdered||".";if(t!=="."&&t!==")")throw new Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}function B2(e){const t=e.options.rule||"*";if(t!=="*"&&t!=="-"&&t!=="_")throw new Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}function k_(e,t,a,l){const o=a.enter("list"),c=a.bulletCurrent;let u=e.ordered?b_(a):Ng(a);const f=e.ordered?u==="."?")":".":v_(a);let p=t&&a.bulletLastUsed?u===a.bulletLastUsed:!1;if(!e.ordered){const g=e.children?e.children[0]:void 0;if((u==="*"||u==="-")&&g&&(!g.children||!g.children[0])&&a.stack[a.stack.length-1]==="list"&&a.stack[a.stack.length-2]==="listItem"&&a.stack[a.stack.length-3]==="list"&&a.stack[a.stack.length-4]==="listItem"&&a.indexStack[a.indexStack.length-1]===0&&a.indexStack[a.indexStack.length-2]===0&&a.indexStack[a.indexStack.length-3]===0&&(p=!0),B2(a)===u&&g){let v=-1;for(;++v<e.children.length;){const k=e.children[v];if(k&&k.type==="listItem"&&k.children&&k.children[0]&&k.children[0].type==="thematicBreak"){p=!0;break}}}}p&&(u=f),a.bulletCurrent=u;const h=a.containerFlow(e,l);return a.bulletLastUsed=u,a.bulletCurrent=c,o(),h}function w_(e){const t=e.options.listItemIndent||"one";if(t!=="tab"&&t!=="one"&&t!=="mixed")throw new Error("Cannot serialize items with `"+t+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return t}function S_(e,t,a,l){const o=w_(a);let c=a.bulletCurrent||Ng(a);t&&t.type==="list"&&t.ordered&&(c=(typeof t.start=="number"&&t.start>-1?t.start:1)+(a.options.incrementListMarker===!1?0:t.children.indexOf(e))+c);let u=c.length+1;(o==="tab"||o==="mixed"&&(t&&t.type==="list"&&t.spread||e.spread))&&(u=Math.ceil(u/4)*4);const f=a.createTracker(l);f.move(c+" ".repeat(u-c.length)),f.shift(u);const p=a.enter("listItem"),h=a.indentLines(a.containerFlow(e,f.current()),g);return p(),h;function g(v,k,w){return k?(w?"":" ".repeat(u))+v:(w?c:c+" ".repeat(u-c.length))+v}}function j_(e,t,a,l){const o=a.enter("paragraph"),c=a.enter("phrasing"),u=a.containerPhrasing(e,l);return c(),o(),u}const C_=$d(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function N_(e,t,a,l){return(e.children.some(function(u){return C_(u)})?a.containerPhrasing:a.containerFlow).call(a,e,l)}function T_(e){const t=e.options.strong||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}H2.peek=M_;function H2(e,t,a,l){const o=T_(a),c=a.enter("strong"),u=a.createTracker(l),f=u.move(o+o);let p=u.move(a.containerPhrasing(e,{after:o,before:f,...u.current()}));const h=p.charCodeAt(0),g=md(l.before.charCodeAt(l.before.length-1),h,o);g.inside&&(p=ec(h)+p.slice(1));const v=p.charCodeAt(p.length-1),k=md(l.after.charCodeAt(0),v,o);k.inside&&(p=p.slice(0,-1)+ec(v));const w=u.move(o+o);return c(),a.attentionEncodeSurroundingInfo={after:k.outside,before:g.outside},f+p+w}function M_(e,t,a){return a.options.strong||"*"}function E_(e,t,a,l){return a.safe(e.value,l)}function A_(e){const t=e.options.ruleRepetition||3;if(t<3)throw new Error("Cannot serialize rules with repetition `"+t+"` for `options.ruleRepetition`, expected `3` or more");return t}function R_(e,t,a){const l=(B2(a)+(a.options.ruleSpaces?" ":"")).repeat(A_(a));return a.options.ruleSpaces?l.slice(0,-1):l}const F2={blockquote:e_,break:qb,code:l_,definition:o_,emphasis:I2,hardBreak:qb,heading:f_,html:L2,image:O2,imageReference:D2,inlineCode:z2,link:$2,linkReference:P2,list:k_,listItem:S_,paragraph:j_,root:N_,strong:H2,text:E_,thematicBreak:R_};function __(){return{enter:{table:I_,tableData:Vb,tableHeader:Vb,tableRow:O_},exit:{codeText:D_,table:L_,tableData:Sp,tableHeader:Sp,tableRow:Sp}}}function I_(e){const t=e._align;this.enter({type:"table",align:t.map(function(a){return a==="none"?null:a}),children:[]},e),this.data.inTable=!0}function L_(e){this.exit(e),this.data.inTable=void 0}function O_(e){this.enter({type:"tableRow",children:[]},e)}function Sp(e){this.exit(e)}function Vb(e){this.enter({type:"tableCell",children:[]},e)}function D_(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,z_));const a=this.stack[this.stack.length-1];a.type,a.value=t,this.exit(e)}function z_(e,t){return t==="|"?t:e}function U_(e){const t=e||{},a=t.tableCellPadding,l=t.tablePipeAlign,o=t.stringLength,c=a?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:`
163
- `,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:k,table:u,tableCell:p,tableRow:f}};function u(w,j,E,C){return h(g(w,E,C),w.align)}function f(w,j,E,C){const M=v(w,E,C),_=h([M]);return _.slice(0,_.indexOf(`
164
- `))}function p(w,j,E,C){const M=E.enter("tableCell"),_=E.enter("phrasing"),D=E.containerPhrasing(w,{...C,before:c,after:c});return _(),M(),D}function h(w,j){return ZR(w,{align:j,alignDelimiters:l,padding:a,stringLength:o})}function g(w,j,E){const C=w.children;let M=-1;const _=[],D=j.enter("table");for(;++M<C.length;)_[M]=v(C[M],j,E);return D(),_}function v(w,j,E){const C=w.children;let M=-1;const _=[],D=j.enter("tableRow");for(;++M<C.length;)_[M]=p(C[M],w,j,E);return D(),_}function k(w,j,E){let C=F2.inlineCode(w,j,E);return E.stack.includes("tableCell")&&(C=C.replace(/\|/g,"\\$&")),C}}function $_(){return{exit:{taskListCheckValueChecked:Gb,taskListCheckValueUnchecked:Gb,paragraph:B_}}}function P_(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:H_}}}function Gb(e){const t=this.stack[this.stack.length-2];t.type,t.checked=e.type==="taskListCheckValueChecked"}function B_(e){const t=this.stack[this.stack.length-2];if(t&&t.type==="listItem"&&typeof t.checked=="boolean"){const a=this.stack[this.stack.length-1];a.type;const l=a.children[0];if(l&&l.type==="text"){const o=t.children;let c=-1,u;for(;++c<o.length;){const f=o[c];if(f.type==="paragraph"){u=f;break}}u===a&&(l.value=l.value.slice(1),l.value.length===0?a.children.shift():a.position&&l.position&&typeof l.position.start.offset=="number"&&(l.position.start.column++,l.position.start.offset++,a.position.start=Object.assign({},l.position.start)))}}this.exit(e)}function H_(e,t,a,l){const o=e.children[0],c=typeof e.checked=="boolean"&&o&&o.type==="paragraph",u="["+(e.checked?"x":" ")+"] ",f=a.createTracker(l);c&&f.move(u);let p=F2.listItem(e,t,a,{...l,...f.current()});return c&&(p=p.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,h)),p;function h(g){return g+u}}function F_(){return[kR(),HR(),GR(),__(),$_()]}function q_(e){return{extensions:[wR(),FR(e),WR(),U_(e),P_()]}}const V_={tokenize:X_,partial:!0},q2={tokenize:Z_,partial:!0},V2={tokenize:J_,partial:!0},G2={tokenize:eI,partial:!0},G_={tokenize:tI,partial:!0},W2={name:"wwwAutolink",tokenize:Y_,previous:Y2},K2={name:"protocolAutolink",tokenize:Q_,previous:Q2},es={name:"emailAutolink",tokenize:K_,previous:X2},Ar={};function W_(){return{text:Ar}}let cl=48;for(;cl<123;)Ar[cl]=es,cl++,cl===58?cl=65:cl===91&&(cl=97);Ar[43]=es;Ar[45]=es;Ar[46]=es;Ar[95]=es;Ar[72]=[es,K2];Ar[104]=[es,K2];Ar[87]=[es,W2];Ar[119]=[es,W2];function K_(e,t,a){const l=this;let o,c;return u;function u(v){return!yh(v)||!X2.call(l,l.previous)||Tg(l.events)?a(v):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),f(v))}function f(v){return yh(v)?(e.consume(v),f):v===64?(e.consume(v),p):a(v)}function p(v){return v===46?e.check(G_,g,h)(v):v===45||v===95||Gn(v)?(c=!0,e.consume(v),p):g(v)}function h(v){return e.consume(v),o=!0,p}function g(v){return c&&o&&ta(l.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(v)):a(v)}}function Y_(e,t,a){const l=this;return o;function o(u){return u!==87&&u!==119||!Y2.call(l,l.previous)||Tg(l.events)?a(u):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(V_,e.attempt(q2,e.attempt(V2,c),a),a)(u))}function c(u){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(u)}}function Q_(e,t,a){const l=this;let o="",c=!1;return u;function u(v){return(v===72||v===104)&&Q2.call(l,l.previous)&&!Tg(l.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),o+=String.fromCodePoint(v),e.consume(v),f):a(v)}function f(v){if(ta(v)&&o.length<5)return o+=String.fromCodePoint(v),e.consume(v),f;if(v===58){const k=o.toLowerCase();if(k==="http"||k==="https")return e.consume(v),p}return a(v)}function p(v){return v===47?(e.consume(v),c?h:(c=!0,p)):a(v)}function h(v){return v===null||ud(v)||Ft(v)||Sl(v)||Dd(v)?a(v):e.attempt(q2,e.attempt(V2,g),a)(v)}function g(v){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(v)}}function X_(e,t,a){let l=0;return o;function o(u){return(u===87||u===119)&&l<3?(l++,e.consume(u),o):u===46&&l===3?(e.consume(u),c):a(u)}function c(u){return u===null?a(u):t(u)}}function Z_(e,t,a){let l,o,c;return u;function u(h){return h===46||h===95?e.check(G2,p,f)(h):h===null||Ft(h)||Sl(h)||h!==45&&Dd(h)?p(h):(c=!0,e.consume(h),u)}function f(h){return h===95?l=!0:(o=l,l=void 0),e.consume(h),u}function p(h){return o||l||!c?a(h):t(h)}}function J_(e,t){let a=0,l=0;return o;function o(u){return u===40?(a++,e.consume(u),o):u===41&&l<a?c(u):u===33||u===34||u===38||u===39||u===41||u===42||u===44||u===46||u===58||u===59||u===60||u===63||u===93||u===95||u===126?e.check(G2,t,c)(u):u===null||Ft(u)||Sl(u)?t(u):(e.consume(u),o)}function c(u){return u===41&&l++,e.consume(u),o}}function eI(e,t,a){return l;function l(f){return f===33||f===34||f===39||f===41||f===42||f===44||f===46||f===58||f===59||f===63||f===95||f===126?(e.consume(f),l):f===38?(e.consume(f),c):f===93?(e.consume(f),o):f===60||f===null||Ft(f)||Sl(f)?t(f):a(f)}function o(f){return f===null||f===40||f===91||Ft(f)||Sl(f)?t(f):l(f)}function c(f){return ta(f)?u(f):a(f)}function u(f){return f===59?(e.consume(f),l):ta(f)?(e.consume(f),u):a(f)}}function tI(e,t,a){return l;function l(c){return e.consume(c),o}function o(c){return Gn(c)?a(c):t(c)}}function Y2(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||Ft(e)}function Q2(e){return!ta(e)}function X2(e){return!(e===47||yh(e))}function yh(e){return e===43||e===45||e===46||e===95||Gn(e)}function Tg(e){let t=e.length,a=!1;for(;t--;){const l=e[t][1];if((l.type==="labelLink"||l.type==="labelImage")&&!l._balanced){a=!0;break}if(l._gfmAutolinkLiteralWalkedInto){a=!1;break}}return e.length>0&&!a&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),a}const nI={tokenize:uI,partial:!0};function aI(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:iI,continuation:{tokenize:oI},exit:cI}},text:{91:{name:"gfmFootnoteCall",tokenize:lI},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:rI,resolveTo:sI}}}}function rI(e,t,a){const l=this;let o=l.events.length;const c=l.parser.gfmFootnotes||(l.parser.gfmFootnotes=[]);let u;for(;o--;){const p=l.events[o][1];if(p.type==="labelImage"){u=p;break}if(p.type==="gfmFootnoteCall"||p.type==="labelLink"||p.type==="label"||p.type==="image"||p.type==="link")break}return f;function f(p){if(!u||!u._balanced)return a(p);const h=pr(l.sliceSerialize({start:u.end,end:l.now()}));return h.codePointAt(0)!==94||!c.includes(h.slice(1))?a(p):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(p),e.exit("gfmFootnoteCallLabelMarker"),t(p))}}function sI(e,t){let a=e.length;for(;a--;)if(e[a][1].type==="labelImage"&&e[a][0]==="enter"){e[a][1];break}e[a+1][1].type="data",e[a+3][1].type="gfmFootnoteCallLabelMarker";const l={type:"gfmFootnoteCall",start:Object.assign({},e[a+3][1].start),end:Object.assign({},e[e.length-1][1].end)},o={type:"gfmFootnoteCallMarker",start:Object.assign({},e[a+3][1].end),end:Object.assign({},e[a+3][1].end)};o.end.column++,o.end.offset++,o.end._bufferIndex++;const c={type:"gfmFootnoteCallString",start:Object.assign({},o.end),end:Object.assign({},e[e.length-1][1].start)},u={type:"chunkString",contentType:"string",start:Object.assign({},c.start),end:Object.assign({},c.end)},f=[e[a+1],e[a+2],["enter",l,t],e[a+3],e[a+4],["enter",o,t],["exit",o,t],["enter",c,t],["enter",u,t],["exit",u,t],["exit",c,t],e[e.length-2],e[e.length-1],["exit",l,t]];return e.splice(a,e.length-a+1,...f),e}function lI(e,t,a){const l=this,o=l.parser.gfmFootnotes||(l.parser.gfmFootnotes=[]);let c=0,u;return f;function f(v){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(v),e.exit("gfmFootnoteCallLabelMarker"),p}function p(v){return v!==94?a(v):(e.enter("gfmFootnoteCallMarker"),e.consume(v),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",h)}function h(v){if(c>999||v===93&&!u||v===null||v===91||Ft(v))return a(v);if(v===93){e.exit("chunkString");const k=e.exit("gfmFootnoteCallString");return o.includes(pr(l.sliceSerialize(k)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(v),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):a(v)}return Ft(v)||(u=!0),c++,e.consume(v),v===92?g:h}function g(v){return v===91||v===92||v===93?(e.consume(v),c++,h):h(v)}}function iI(e,t,a){const l=this,o=l.parser.gfmFootnotes||(l.parser.gfmFootnotes=[]);let c,u=0,f;return p;function p(j){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(j),e.exit("gfmFootnoteDefinitionLabelMarker"),h}function h(j){return j===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(j),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",g):a(j)}function g(j){if(u>999||j===93&&!f||j===null||j===91||Ft(j))return a(j);if(j===93){e.exit("chunkString");const E=e.exit("gfmFootnoteDefinitionLabelString");return c=pr(l.sliceSerialize(E)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(j),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),k}return Ft(j)||(f=!0),u++,e.consume(j),j===92?v:g}function v(j){return j===91||j===92||j===93?(e.consume(j),u++,g):g(j)}function k(j){return j===58?(e.enter("definitionMarker"),e.consume(j),e.exit("definitionMarker"),o.includes(c)||o.push(c),kt(e,w,"gfmFootnoteDefinitionWhitespace")):a(j)}function w(j){return t(j)}}function oI(e,t,a){return e.check(fc,t,e.attempt(nI,t,a))}function cI(e){e.exit("gfmFootnoteDefinition")}function uI(e,t,a){const l=this;return kt(e,o,"gfmFootnoteDefinitionIndent",5);function o(c){const u=l.events[l.events.length-1];return u&&u[1].type==="gfmFootnoteDefinitionIndent"&&u[2].sliceSerialize(u[1],!0).length===4?t(c):a(c)}}function dI(e){let a=(e||{}).singleTilde;const l={name:"strikethrough",tokenize:c,resolveAll:o};return a==null&&(a=!0),{text:{126:l},insideSpan:{null:[l]},attentionMarkers:{null:[126]}};function o(u,f){let p=-1;for(;++p<u.length;)if(u[p][0]==="enter"&&u[p][1].type==="strikethroughSequenceTemporary"&&u[p][1]._close){let h=p;for(;h--;)if(u[h][0]==="exit"&&u[h][1].type==="strikethroughSequenceTemporary"&&u[h][1]._open&&u[p][1].end.offset-u[p][1].start.offset===u[h][1].end.offset-u[h][1].start.offset){u[p][1].type="strikethroughSequence",u[h][1].type="strikethroughSequence";const g={type:"strikethrough",start:Object.assign({},u[h][1].start),end:Object.assign({},u[p][1].end)},v={type:"strikethroughText",start:Object.assign({},u[h][1].end),end:Object.assign({},u[p][1].start)},k=[["enter",g,f],["enter",u[h][1],f],["exit",u[h][1],f],["enter",v,f]],w=f.parser.constructs.insideSpan.null;w&&_a(k,k.length,0,zd(w,u.slice(h+1,p),f)),_a(k,k.length,0,[["exit",v,f],["enter",u[p][1],f],["exit",u[p][1],f],["exit",g,f]]),_a(u,h-1,p-h+3,k),p=h+k.length-2;break}}for(p=-1;++p<u.length;)u[p][1].type==="strikethroughSequenceTemporary"&&(u[p][1].type="data");return u}function c(u,f,p){const h=this.previous,g=this.events;let v=0;return k;function k(j){return h===126&&g[g.length-1][1].type!=="characterEscape"?p(j):(u.enter("strikethroughSequenceTemporary"),w(j))}function w(j){const E=hi(h);if(j===126)return v>1?p(j):(u.consume(j),v++,w);if(v<2&&!a)return p(j);const C=u.exit("strikethroughSequenceTemporary"),M=hi(j);return C._open=!M||M===2&&!!E,C._close=!E||E===2&&!!M,f(j)}}}class fI{constructor(){this.map=[]}add(t,a,l){mI(this,t,a,l)}consume(t){if(this.map.sort(function(c,u){return c[0]-u[0]}),this.map.length===0)return;let a=this.map.length;const l=[];for(;a>0;)a-=1,l.push(t.slice(this.map[a][0]+this.map[a][1]),this.map[a][2]),t.length=this.map[a][0];l.push(t.slice()),t.length=0;let o=l.pop();for(;o;){for(const c of o)t.push(c);o=l.pop()}this.map.length=0}}function mI(e,t,a,l){let o=0;if(!(a===0&&l.length===0)){for(;o<e.map.length;){if(e.map[o][0]===t){e.map[o][1]+=a,e.map[o][2].push(...l);return}o+=1}e.map.push([t,a,l])}}function pI(e,t){let a=!1;const l=[];for(;t<e.length;){const o=e[t];if(a){if(o[0]==="enter")o[1].type==="tableContent"&&l.push(e[t+1][1].type==="tableDelimiterMarker"?"left":"none");else if(o[1].type==="tableContent"){if(e[t-1][1].type==="tableDelimiterMarker"){const c=l.length-1;l[c]=l[c]==="left"?"center":"right"}}else if(o[1].type==="tableDelimiterRow")break}else o[0]==="enter"&&o[1].type==="tableDelimiterRow"&&(a=!0);t+=1}return l}function hI(){return{flow:{null:{name:"table",tokenize:gI,resolveAll:xI}}}}function gI(e,t,a){const l=this;let o=0,c=0,u;return f;function f(O){let z=l.events.length-1;for(;z>-1;){const $=l.events[z][1].type;if($==="lineEnding"||$==="linePrefix")z--;else break}const I=z>-1?l.events[z][1].type:null,B=I==="tableHead"||I==="tableRow"?A:p;return B===A&&l.parser.lazy[l.now().line]?a(O):B(O)}function p(O){return e.enter("tableHead"),e.enter("tableRow"),h(O)}function h(O){return O===124||(u=!0,c+=1),g(O)}function g(O){return O===null?a(O):Ye(O)?c>1?(c=0,l.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(O),e.exit("lineEnding"),w):a(O):mt(O)?kt(e,g,"whitespace")(O):(c+=1,u&&(u=!1,o+=1),O===124?(e.enter("tableCellDivider"),e.consume(O),e.exit("tableCellDivider"),u=!0,g):(e.enter("data"),v(O)))}function v(O){return O===null||O===124||Ft(O)?(e.exit("data"),g(O)):(e.consume(O),O===92?k:v)}function k(O){return O===92||O===124?(e.consume(O),v):v(O)}function w(O){return l.interrupt=!1,l.parser.lazy[l.now().line]?a(O):(e.enter("tableDelimiterRow"),u=!1,mt(O)?kt(e,j,"linePrefix",l.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(O):j(O))}function j(O){return O===45||O===58?C(O):O===124?(u=!0,e.enter("tableCellDivider"),e.consume(O),e.exit("tableCellDivider"),E):F(O)}function E(O){return mt(O)?kt(e,C,"whitespace")(O):C(O)}function C(O){return O===58?(c+=1,u=!0,e.enter("tableDelimiterMarker"),e.consume(O),e.exit("tableDelimiterMarker"),M):O===45?(c+=1,M(O)):O===null||Ye(O)?V(O):F(O)}function M(O){return O===45?(e.enter("tableDelimiterFiller"),_(O)):F(O)}function _(O){return O===45?(e.consume(O),_):O===58?(u=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(O),e.exit("tableDelimiterMarker"),D):(e.exit("tableDelimiterFiller"),D(O))}function D(O){return mt(O)?kt(e,V,"whitespace")(O):V(O)}function V(O){return O===124?j(O):O===null||Ye(O)?!u||o!==c?F(O):(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(O)):F(O)}function F(O){return a(O)}function A(O){return e.enter("tableRow"),P(O)}function P(O){return O===124?(e.enter("tableCellDivider"),e.consume(O),e.exit("tableCellDivider"),P):O===null||Ye(O)?(e.exit("tableRow"),t(O)):mt(O)?kt(e,P,"whitespace")(O):(e.enter("data"),Q(O))}function Q(O){return O===null||O===124||Ft(O)?(e.exit("data"),P(O)):(e.consume(O),O===92?K:Q)}function K(O){return O===92||O===124?(e.consume(O),Q):Q(O)}}function xI(e,t){let a=-1,l=!0,o=0,c=[0,0,0,0],u=[0,0,0,0],f=!1,p=0,h,g,v;const k=new fI;for(;++a<e.length;){const w=e[a],j=w[1];w[0]==="enter"?j.type==="tableHead"?(f=!1,p!==0&&(Wb(k,t,p,h,g),g=void 0,p=0),h={type:"table",start:Object.assign({},j.start),end:Object.assign({},j.end)},k.add(a,0,[["enter",h,t]])):j.type==="tableRow"||j.type==="tableDelimiterRow"?(l=!0,v=void 0,c=[0,0,0,0],u=[0,a+1,0,0],f&&(f=!1,g={type:"tableBody",start:Object.assign({},j.start),end:Object.assign({},j.end)},k.add(a,0,[["enter",g,t]])),o=j.type==="tableDelimiterRow"?2:g?3:1):o&&(j.type==="data"||j.type==="tableDelimiterMarker"||j.type==="tableDelimiterFiller")?(l=!1,u[2]===0&&(c[1]!==0&&(u[0]=u[1],v=_u(k,t,c,o,void 0,v),c=[0,0,0,0]),u[2]=a)):j.type==="tableCellDivider"&&(l?l=!1:(c[1]!==0&&(u[0]=u[1],v=_u(k,t,c,o,void 0,v)),c=u,u=[c[1],a,0,0])):j.type==="tableHead"?(f=!0,p=a):j.type==="tableRow"||j.type==="tableDelimiterRow"?(p=a,c[1]!==0?(u[0]=u[1],v=_u(k,t,c,o,a,v)):u[1]!==0&&(v=_u(k,t,u,o,a,v)),o=0):o&&(j.type==="data"||j.type==="tableDelimiterMarker"||j.type==="tableDelimiterFiller")&&(u[3]=a)}for(p!==0&&Wb(k,t,p,h,g),k.consume(t.events),a=-1;++a<t.events.length;){const w=t.events[a];w[0]==="enter"&&w[1].type==="table"&&(w[1]._align=pI(t.events,a))}return e}function _u(e,t,a,l,o,c){const u=l===1?"tableHeader":l===2?"tableDelimiter":"tableData",f="tableContent";a[0]!==0&&(c.end=Object.assign({},oi(t.events,a[0])),e.add(a[0],0,[["exit",c,t]]));const p=oi(t.events,a[1]);if(c={type:u,start:Object.assign({},p),end:Object.assign({},p)},e.add(a[1],0,[["enter",c,t]]),a[2]!==0){const h=oi(t.events,a[2]),g=oi(t.events,a[3]),v={type:f,start:Object.assign({},h),end:Object.assign({},g)};if(e.add(a[2],0,[["enter",v,t]]),l!==2){const k=t.events[a[2]],w=t.events[a[3]];if(k[1].end=Object.assign({},w[1].end),k[1].type="chunkText",k[1].contentType="text",a[3]>a[2]+1){const j=a[2]+1,E=a[3]-a[2]-1;e.add(j,E,[])}}e.add(a[3]+1,0,[["exit",v,t]])}return o!==void 0&&(c.end=Object.assign({},oi(t.events,o)),e.add(o,0,[["exit",c,t]]),c=void 0),c}function Wb(e,t,a,l,o){const c=[],u=oi(t.events,a);o&&(o.end=Object.assign({},u),c.push(["exit",o,t])),l.end=Object.assign({},u),c.push(["exit",l,t]),e.add(a+1,0,c)}function oi(e,t){const a=e[t],l=a[0]==="enter"?"start":"end";return a[1][l]}const yI={name:"tasklistCheck",tokenize:bI};function vI(){return{text:{91:yI}}}function bI(e,t,a){const l=this;return o;function o(p){return l.previous!==null||!l._gfmTasklistFirstContentOfListItem?a(p):(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(p),e.exit("taskListCheckMarker"),c)}function c(p){return Ft(p)?(e.enter("taskListCheckValueUnchecked"),e.consume(p),e.exit("taskListCheckValueUnchecked"),u):p===88||p===120?(e.enter("taskListCheckValueChecked"),e.consume(p),e.exit("taskListCheckValueChecked"),u):a(p)}function u(p){return p===93?(e.enter("taskListCheckMarker"),e.consume(p),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),f):a(p)}function f(p){return Ye(p)?t(p):mt(p)?e.check({tokenize:kI},t,a)(p):a(p)}}function kI(e,t,a){return kt(e,l,"whitespace");function l(o){return o===null?a(o):t(o)}}function wI(e){return o2([W_(),aI(),dI(e),hI(),vI()])}const SI={};function hc(e){const t=this,a=e||SI,l=t.data(),o=l.micromarkExtensions||(l.micromarkExtensions=[]),c=l.fromMarkdownExtensions||(l.fromMarkdownExtensions=[]),u=l.toMarkdownExtensions||(l.toMarkdownExtensions=[]);o.push(wI(a)),c.push(F_()),u.push(q_(a))}const jI="modulepreload",CI=function(e){return"/"+e},Kb={},NI=function(t,a,l){let o=Promise.resolve();if(a&&a.length>0){let p=function(h){return Promise.all(h.map(g=>Promise.resolve(g).then(v=>({status:"fulfilled",value:v}),v=>({status:"rejected",reason:v}))))};document.getElementsByTagName("link");const u=document.querySelector("meta[property=csp-nonce]"),f=u?.nonce||u?.getAttribute("nonce");o=p(a.map(h=>{if(h=CI(h),h in Kb)return;Kb[h]=!0;const g=h.endsWith(".css"),v=g?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${h}"]${v}`))return;const k=document.createElement("link");if(k.rel=g?"stylesheet":jI,g||(k.as="script"),k.crossOrigin="",k.href=h,f&&k.setAttribute("nonce",f),document.head.appendChild(k),g)return new Promise((w,j)=>{k.addEventListener("load",w),k.addEventListener("error",()=>j(new Error(`Unable to preload CSS for ${h}`)))})}))}function c(u){const f=new Event("vite:preloadError",{cancelable:!0});if(f.payload=u,window.dispatchEvent(f),!f.defaultPrevented)throw u}return o.then(u=>{for(const f of u||[])f.status==="rejected"&&c(f.reason);return t().catch(c)})};function Mg({language:e,code:t,highlight:a=!0}){const[l,o]=y.useState(null);return y.useEffect(()=>{if(!a){o(null);return}let c=!0;return NI(()=>import("./index-B3puu-Hr.js"),[]).then(u=>u.codeToHtml(t,{lang:e||"text",themes:{light:"github-light",dark:"github-dark"}})).then(u=>{c&&o(u)}).catch(()=>{c&&o(null)}),()=>{c=!1}},[t,e,a]),s.jsxs("div",{className:"code-block my-2 overflow-hidden rounded-lg border border-gray-200 dark:border-gray-800",children:[s.jsxs("div",{className:"flex items-center justify-between border-b border-gray-200 bg-gray-50 px-3 py-1 dark:border-gray-800 dark:bg-gray-900",children:[s.jsx("span",{className:"font-mono text-xs lowercase text-gray-500 dark:text-gray-400",children:e||"text"}),s.jsx(uc,{text:t,label:m.chat.copyCode})]}),s.jsx("div",{className:"overflow-x-auto bg-white text-[13px] leading-relaxed dark:bg-gray-950",children:l?s.jsx("div",{dangerouslySetInnerHTML:{__html:l}}):s.jsx("pre",{className:"m-0 px-3 py-2.5 font-mono text-gray-800 dark:text-gray-200",children:s.jsx("code",{children:t})})})]})}function TI(e){return typeof e=="string"?e:Array.isArray(e)?e.filter(t=>typeof t=="string").join(""):""}function Z2({children:e,streaming:t}){if(y.isValidElement(e)){const a=e.props,l=/language-([\w+-]+)/.exec(a.className??"")?.[1]??"";return s.jsx(Mg,{language:l,code:TI(a.children).replace(/\n$/,""),highlight:!t})}return s.jsx("pre",{children:e})}function J2({node:e,children:t,...a}){return s.jsx("a",{...a,target:"_blank",rel:"noreferrer",children:t})}const MI={pre:e=>s.jsx(Z2,{streaming:!0,children:e.children}),a:J2},EI={pre:e=>s.jsx(Z2,{streaming:!1,children:e.children}),a:J2},Eg=y.memo(function({text:t,streaming:a=!1}){return s.jsx(pc,{remarkPlugins:[hc],components:a?MI:EI,children:t})});function Zr({src:e,alt:t,className:a}){const[l,o]=y.useState(!1);return s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",className:"block cursor-zoom-in",onClick:()=>o(!0),children:s.jsx("img",{src:e,alt:t,className:a})}),l&&s.jsx(AI,{src:e,alt:t,onClose:()=>o(!1)})]})}function AI({src:e,alt:t,onClose:a}){return y.useEffect(()=>{const l=o=>{o.key==="Escape"&&a()};return window.addEventListener("keydown",l),()=>window.removeEventListener("keydown",l)},[a]),bi.createPortal(s.jsx("div",{className:"anim-fade fixed inset-0 z-50 flex items-center justify-center bg-black/70 p-10",onMouseDown:l=>{l.target===l.currentTarget&&a()},children:s.jsxs("div",{className:"anim-pop relative",children:[s.jsx("button",{type:"button","aria-label":m.common.close,onClick:a,className:"absolute right-2 top-2 flex h-7 w-7 items-center justify-center rounded-full bg-black/50 text-white transition-colors duration-150 hover:bg-black/70",children:s.jsx("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",children:s.jsx("path",{d:"M2 2l10 10M12 2L2 12",strokeWidth:"1.5",strokeLinecap:"round"})})}),s.jsx("img",{src:e,alt:t,className:"max-h-[85vh] max-w-[88vw] rounded-lg border border-gray-200 bg-white dark:border-gray-700 dark:bg-gray-900"})]})}),document.body)}const RI=new Set(["txt","md","json","js","mjs","cjs","ts","tsx","jsx","py","sh","bash","yaml","yml","toml","css","html","htm","csv","log","xml","ini","conf","rs","go","java","c","h","cpp","hpp","sql","rb","php","png","jpg","jpeg","gif","webp","svg","pdf","doc","docx","xls","xlsx","ppt","pptx","zip","tar","gz","mp4","mp3","wav"]),_I=/^[a-z][a-z0-9+.-]*:\/\//i;function II(e){const t=e.trim();if(t.length===0||t.length>200||/\s/.test(t)||_I.test(t)||t.startsWith("www."))return!1;const a=/\.([A-Za-z0-9]{1,8})$/.exec(t);if(!a)return!1;const l=a[1].toLowerCase();return/^\d+$/.test(l)?!1:RI.has(l)}function Ju(e,t){return e===""?t:`${e}/${t}`}const LI=512;function OI(e,t){const a=e.trim();if(a.length===0||a.length>LI||a.startsWith("~"))return null;const l=t!==null&&t.length>0?t:null,o=l!==null&&(l.includes("\\")||/^[A-Za-z]:/.test(l)),c=v=>{if(!o)return v;const k=v.replaceAll("\\","/");return/^[A-Za-z]:/.test(k)?k[0].toLowerCase()+k.slice(1):k},u=c(a),f=l===null?null:c(l),p=u.startsWith("/")||o&&/^[a-z]:/.test(u);let h=u;if(p){if(f===null||!u.startsWith(`${f}/`))return null;h=u.slice(f.length+1)}const g=[];for(const v of h.split("/"))if(!(v===""||v===".")){if(v===".."){if(g.length===0)return null;g.pop();continue}g.push(v)}return g.length>0?g.join("/"):null}const Yb=3;function DI(e){const t=[],a=new Set;for(const l of e.matchAll(/`([^`\n]+)`/g)){const o=l[1].trim();!II(o)||a.has(o)||(a.add(o),t.push(o))}return t}function zI({path:e}){const t=e.lastIndexOf("/"),a=t>=0?e.slice(0,t+1):"",l=t>=0?e.slice(t+1):e;return s.jsxs("span",{className:"flex min-w-0 items-baseline font-mono text-sm",children:[a&&s.jsx("span",{className:"min-w-0 shrink-[9999] truncate text-gray-400 dark:text-gray-500",children:a}),s.jsx("span",{className:"min-w-0 truncate font-semibold text-gray-800 dark:text-gray-100",children:l})]})}function Qb({text:e,workspace:t,statFiles:a,onOpenFile:l}){const o=y.useMemo(()=>{const v=[],k=new Set;for(const w of DI(e)){const j=OI(w,t);j===null||k.has(j)||(k.add(j),v.push(j))}return v},[e,t]),[c,u]=y.useState(null);y.useEffect(()=>{if(u(null),o.length===0)return;let v=!1;return a(o).then(k=>{v||u(o.filter(w=>k.has(w)))}).catch(()=>{}),()=>{v=!0}},[o,a]);const[f,p]=y.useState(!1);if(c===null||c.length===0)return null;const h=f?c:c.slice(0,Yb),g=c.length-h.length;return s.jsxs("div",{className:"anim-msg my-3 overflow-hidden rounded-xl border border-gray-200 bg-white dark:border-gray-800 dark:bg-gray-900",children:[s.jsxs("div",{className:"flex items-center gap-2 border-b border-gray-100 bg-gray-50 px-3 py-2 dark:border-gray-800/60 dark:bg-gray-800/40",children:[s.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7","aria-hidden":!0,className:"shrink-0 text-gray-400",children:s.jsx("path",{d:"M6 3h8l4 4v14H6zM14 3v4h4"})}),s.jsx("span",{className:"min-w-0 flex-1 truncate text-sm font-medium",children:m.chat.filesInMessage(c.length)})]}),s.jsxs("div",{className:"divide-y divide-gray-100 dark:divide-gray-800/60",children:[h.map(v=>s.jsxs("button",{type:"button",title:v,onClick:()=>l(v),className:"group flex w-full cursor-pointer items-center gap-2 px-3 py-2 text-left transition-colors duration-150 hover:bg-gray-50 dark:hover:bg-gray-800/50",children:[s.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7","aria-hidden":!0,className:"shrink-0 text-gray-400",children:s.jsx("path",{d:"M6 3h8l4 4v14H6zM14 3v4h4"})}),s.jsx(zI,{path:v}),s.jsx("span",{className:"min-w-0 flex-1"}),s.jsx("span",{"aria-hidden":!0,className:"shrink-0 text-xs text-gray-400 transition-colors duration-150 group-hover:text-gray-600 dark:text-gray-500 dark:group-hover:text-gray-300",children:m.chat.openPreview})]},v)),(g>0||f)&&c.length>Yb&&s.jsxs("button",{type:"button",onClick:()=>p(v=>!v),className:"flex w-full items-center gap-1.5 px-3 py-2 text-left text-xs text-gray-500 transition-colors duration-150 hover:bg-gray-50 dark:text-gray-400 dark:hover:bg-gray-800/50",children:[f?m.chat.showLess:m.chat.showMoreFiles(g),s.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,className:`transition-transform duration-200 ${f?"rotate-180":""}`,children:s.jsx("path",{d:"m6 9 6 6 6-6"})})]})]})]})}const UI={waiting:"M6 3h12M6 21h12M8 3v3.5L12 10l4-3.5V3M8 21v-3.5L12 14l4 3.5V21",done:"M12 21a9 9 0 1 0 0-18 9 9 0 0 0 0 18zm-3.5-9.2 2.4 2.5 4.6-4.8",failed:"M12 21a9 9 0 1 0 0-18 9 9 0 0 0 0 18zM9 9l6 6m0-6-6 6"},Xb={running:"text-emerald-500 dark:text-emerald-400",waiting:"text-amber-500 dark:text-amber-400",done:"text-gray-400 dark:text-gray-500",failed:"text-red-500 dark:text-red-400"};function Tl({state:e,size:t=13,label:a}){return e==="running"?s.jsx("span",{...a?{title:a,"aria-label":a,role:"status"}:{"aria-hidden":!0},style:{width:t,height:t},className:`inline-block shrink-0 animate-spin rounded-full border-[1.5px] border-current border-t-transparent ${Xb.running}`}):s.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round",...a?{role:"img","aria-label":a}:{"aria-hidden":!0},className:`block shrink-0 ${Xb[e]}`,children:[a&&s.jsx("title",{children:a}),s.jsx("path",{d:UI[e]})]})}function gi({sinceMs:e,offsetMs:t=0}){const[a,l]=y.useState(()=>Date.now());return y.useEffect(()=>{const o=setInterval(()=>l(Date.now()),1e3);return()=>clearInterval(o)},[]),e===void 0?s.jsx("span",{className:"animate-pulse",children:"…"}):s.jsx(s.Fragment,{children:Sw(Math.max(0,t)+Math.max(0,a-e))})}function $I({item:e}){const[t,a]=y.useState(!1),l=y.useRef(null),o=e.stopReason!==void 0&&e.stopReason!=="completed",c=e.streaming?"running":o?"failed":"done",u=e.streaming?m.chat.workRunning:o?e.stopReason:m.chat.workDone;return s.jsxs("div",{ref:l,children:[s.jsxs("button",{type:"button",onClick:()=>{const f=t;a(p=>!p),f&&requestAnimationFrame(()=>l.current?.scrollIntoView({block:"nearest"}))},"aria-expanded":t,className:"sticky top-4 z-[4] flex w-full items-center gap-2 bg-white px-3 py-1.5 text-left transition-colors duration-150 hover:bg-gray-50 dark:bg-gray-900 dark:hover:bg-gray-800",children:[s.jsx(Tl,{state:c,label:u}),s.jsx("span",{className:"shrink-0 text-xs text-gray-500 dark:text-gray-400",children:m.chat.thinking}),s.jsx("span",{className:"shrink-0 font-mono text-xs text-gray-500 dark:text-gray-400",children:e.streaming?s.jsx(gi,{sinceMs:e.startedAtMs}):e.durationMs!==void 0?hn(e.durationMs):null}),o&&s.jsxs("span",{className:"font-mono text-xs text-gray-400",children:["[",e.stopReason,"]"]}),s.jsx("span",{className:"min-w-0 flex-1"}),s.jsx($n,{open:t,className:"text-gray-400"})]}),t&&s.jsx("div",{className:"md-body anim-fade mx-3 mb-2 rounded-md bg-gray-50 px-3 py-2 text-sm leading-relaxed text-gray-600 dark:bg-gray-900/60 dark:text-gray-400",children:s.jsx(Eg,{text:e.thinking,streaming:e.streaming})})]})}const PI=/\x1b(?:\[[0-9:;<=>?]*[ -/]*[@-~]|\][^\x07\x1b]*(?:\x07|\x1b\\)|[@-Z\\^_])/g,BI=/\x1b(?:\[[0-9:;<=>?]*[ -/]*|\][^\x07]*)?$/;function eS(e){return e.includes("\x1B")?e.replace(PI,"").replace(BI,""):e}function HI({onDecide:e}){const[t,a]=y.useState(!1),l=async o=>{a(!0);try{await e(o)}finally{a(!1)}};return s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(we,{size:"sm",variant:"primary",disabled:t,onClick:()=>{l("allow")},children:m.chat.approve}),s.jsx(we,{size:"sm",disabled:t,onClick:()=>{l("deny")},children:m.chat.deny})]})}function tS(e){for(let t=e.length-1;t>=0;t--){const a=e[t].kind;if(a==="user_text"||a==="user_image")return t}return 0}function FI(e){let t=0;for(const a of e)(a.kind==="user_text"||a.kind==="user_image")&&(t+=1);return t}function nS(e,t){try{const a=JSON.parse(e);if(a!==null&&typeof a=="object"){const l=a[t];if(typeof l=="string"&&l.length>0)return l}}catch{}return null}function aS(e){return nS(e,"agent_id")}function qI(e){return nS(e,"description")}function VI(e,t,a){return rS(e.items.slice(tS(e.items)),t,{running:a})}function GI(e,t,a,l){const o=e.items,c=o.findIndex(p=>p.kind==="tool_call"&&p.subagentSessionId===l||p.kind==="subagent"&&p.sessionId===l);if(c===-1)return null;let u=0;for(let p=c;p>=0;p--){const h=o[p].kind;if(h==="user_text"||h==="user_image"){u=p;break}}let f=o.length;for(let p=c+1;p<o.length;p++){const h=o[p].kind;if(h==="user_text"||h==="user_image"){f=p;break}}return rS(o.slice(u,f),t,{running:f===o.length&&a})}function rS(e,t,a){const l=[{sessionId:t,agentId:null,description:null,running:a.running,depth:0,origin:[],parentId:null}],o=new Set([t]),c=(f,p,h,g,v,k,w)=>{if(o.has(f))return;o.add(f);const j=[...v,f],E=p.firstTsMs??p.firstSeenLocalMs,C=p.firstTsMs!==void 0&&p.lastActivityTsMs!==void 0?Math.max(0,p.lastActivityTsMs-p.firstTsMs):p.firstSeenLocalMs!==void 0&&p.lastActivityLocalMs!==void 0?Math.max(0,p.lastActivityLocalMs-p.firstSeenLocalMs):void 0;l.push({sessionId:f,agentId:p.meta?.agentId??k,description:w,running:h,depth:j.length,origin:j,parentId:g,...E!==void 0?{startedMs:E}:{},...C!==void 0?{elapsedMs:C}:{}}),u(p.items,f,j)},u=(f,p,h)=>{for(const g of f)g.kind==="tool_call"&&g.subagent&&g.subagentSessionId?c(g.subagentSessionId,g.subagent,!g.outputComplete,p,h,aS(g.argumentsText),qI(g.argumentsText)):g.kind==="subagent"&&c(g.sessionId,g.model,!1,p,h,null,null)};return u(e,t,[]),l}function WI(e){const t=e.items;for(let a=tS(t);a<t.length;a++){const l=t[a];if(l.kind==="tool_call"&&l.subagent!==void 0||l.kind==="subagent")return!0}return!1}function KI(e,t){if(t.length===0)return null;let a=e;for(const l of t){const o=a.subagents.get(l);if(!o)return null;a=o}return a}const ed=200,Oo=46,jp=32,Zb=10,Iu=6;function YI(e){const t=new Map;for(const g of e){if(g.parentId===null)continue;const v=t.get(g.parentId);v?v.push(g):t.set(g.parentId,[g])}const a=new Map;let l=0;const o=g=>{const v=t.get(g.sessionId)??[];let k;if(v.length===0)k=l++;else{const w=v.map(o);k=(w[0]+w[w.length-1])/2}return a.set(g.sessionId,k),k};for(const g of e)g.parentId===null&&o(g);const c=e.map(g=>({node:g,x:Iu+g.depth*(ed+jp),y:Iu+(a.get(g.sessionId)??0)*(Oo+Zb)})),u=new Map(c.map(g=>[g.node.sessionId,g])),f=[];for(const g of c){if(g.node.parentId===null)continue;const v=u.get(g.node.parentId);if(!v)continue;const k=v.x+ed,w=v.y+Oo/2,j=g.x,E=g.y+Oo/2,C=k+jp/2;f.push({fromId:v.node.sessionId,toId:g.node.sessionId,path:w===E?`M ${k} ${w} H ${j}`:`M ${k} ${w} H ${C} V ${E} H ${j}`})}const p=e.reduce((g,v)=>Math.max(g,v.depth),0),h=Math.max(1,l);return{width:Iu*2+(p+1)*ed+p*jp,height:Iu*2+h*Oo+(h-1)*Zb,nodes:c,edges:f}}function vh(e,t,a){const l=a.find(c=>c.sessionId===e.sessionId),o=e.agentId??l?.agentId??null;if(o!==null){const c=t.find(u=>u.agentId===o);return c?c.name?.length?c.name:c.agentId:o}return l?.title??null}function bh(e){return e.length>8?e.slice(-8):e}function sS({sessionId:e,model:t,running:a,ctx:l,agentId:o=null}){const{agents:c}=Xt(),{sessions:u}=Bs(),f=vh({sessionId:e,agentId:t.meta?.agentId??o},c,u)??m.chat.subagent,p=LM(l.pendingApprovals.keys(),[...l.origin,e]),h=`${m.chat.subagent} ${f}${p?` · ${m.chat.approvalWaiting}`:""}`;return s.jsxs("button",{type:"button","aria-label":h,title:h,onClick:()=>l.onOpenSubagent?.(e,l.origin),className:"flex w-full items-center gap-2 rounded-md border border-gray-200 bg-gray-50 px-3 py-2 text-left transition-colors duration-150 hover:bg-gray-100 dark:border-gray-800 dark:bg-gray-900/60 dark:hover:bg-gray-800/60",children:[s.jsx(xa,{id:t.meta?.agentId??o??e,name:f,size:16}),s.jsx("span",{className:"min-w-0 truncate text-xs font-medium text-gray-700 dark:text-gray-300",children:f}),e&&s.jsx("span",{className:"shrink-0 font-mono text-[10px] text-gray-400 dark:text-gray-500",children:bh(e)}),a&&s.jsx("span",{"aria-hidden":!0,className:"inline-block h-2.5 w-2.5 shrink-0 animate-spin rounded-full border border-gray-400 border-t-transparent"}),p&&s.jsx("span",{"aria-hidden":!0,className:"h-1.5 w-1.5 shrink-0 rounded-full bg-amber-500"}),s.jsx("span",{className:"min-w-0 flex-1"})]})}const Jb=new Set(["exec_command","input_command","run_subagent","input_subagent"]),pd=new Set(["read_file","edit_file","write_file"]);function lS(e){const t=e.split("/").filter(a=>a.length>0);return t.length<=2?e:`…/${t[t.length-2]}/${t[t.length-1]}`}function QI(e,t){if(e==="exec_command"){const a=hd(t,"cmd");if(a!==null)return`$ ${a.value.replace(/\s+/g," ").trim()}`}if(pd.has(e)){const a=hd(t,"file_path");if(a!==null)return lS(a.value.replace(/\s+/g," ").trim())}return t.replace(/\s+/g," ").trim()}function XI(e,t,a=!0){if(Jb.has(e)||pd.has(e)){const l=hd(t,"description");if(l!==null){if(!l.complete&&!a)return null;const o=l.value.replace(/\s+/g," ").trim();if(o)return o}if(Jb.has(e))return null}if(pd.has(e)){const l=hd(t,"file_path");if(l!==null){if(!l.complete&&!a)return null;const o=l.value.replace(/\s+/g," ").trim();if(o)return lS(o)}}return null}function ZI(e,t){if(!pd.has(e))return null;let a;try{a=JSON.parse(t)}catch{return null}if(a===null||typeof a!="object")return null;const l=a,o=[],c=(u,f)=>{f!==void 0&&(typeof f=="string"&&f.includes(`
165
- `)?o.push(`${u}:
166
- ${f}`):o.push(`${u}: ${typeof f=="string"?f:JSON.stringify(f)}`))};return c("file_path",l.file_path),e==="read_file"?(c("offset",l.offset),c("limit",l.limit)):e==="edit_file"?(c("old_string",l.old_string),c("new_string",l.new_string),l.replace_all===!0&&c("replace_all",!0)):e==="write_file"&&c("content",l.content),o.join(`
167
- `)}function hd(e,t){const a=`"${t}"`,l=e.indexOf(a);if(l===-1)return null;let o=l+a.length;for(;/\s/.test(e[o]??"");)o+=1;if(e[o]!==":")return null;for(o+=1;/\s/.test(e[o]??"");)o+=1;if(e[o]!=='"')return null;o+=1;let c="",u=!1;for(;o<e.length;o+=1){const f=e[o];if(u){c+=f==="n"?`
168
- `:f==="t"?" ":f,u=!1;continue}if(f==="\\"){u=!0;continue}if(f==='"')return{value:c,complete:!0};c+=f}return{value:c,complete:!1}}function JI({item:e,ctx:t}){const[a,l]=y.useState(!1),o=y.useRef(!1),c=y.useRef(null),u=t.pendingApprovals.get(pi(t.origin,e.toolCallId)),f=QI(e.name,e.argumentsText),p=y.useMemo(()=>eS(e.output),[e.output]),h=XI(e.name,e.argumentsText,!e.callStreaming),g=e.callComplete&&!e.outputComplete&&!u,v=e.argStartedAtMs!==void 0&&e.callStartedAtMs!==void 0?Math.max(0,e.callStartedAtMs-e.argStartedAtMs):0,k=e.callStopReason!==void 0&&e.callStopReason!=="completed"||e.outputStopReason!==void 0&&e.outputStopReason!=="completed",w=u?"waiting":g||e.callStreaming?"running":k?"failed":"done",j=e.decision?`${e.decision==="allow"?m.chat.decisionAllow:m.chat.decisionDeny} · ${e.decisionSource==="manual"?m.chat.decisionManual:m.chat.decisionAuto}`:null,E=e.decision==="deny"&&e.outputStopReason==="aborted",C=u?m.chat.approvalWaiting:w==="running"?m.chat.workRunning:w==="done"?j??m.chat.workDone:E?j??void 0:e.outputStopReason??e.callStopReason;return s.jsxs("div",{ref:c,children:[s.jsxs("button",{type:"button","aria-expanded":a,onClick:()=>{o.current=!0;const M=a;l(_=>!_),M&&requestAnimationFrame(()=>c.current?.scrollIntoView({block:"nearest"}))},className:"sticky top-4 z-[4] flex w-full items-center gap-2 bg-white px-3 py-1.5 text-left transition-colors duration-150 hover:bg-gray-50 dark:bg-gray-900 dark:hover:bg-gray-800",children:[s.jsx(Tl,{state:w,label:C}),s.jsx("span",{className:"shrink-0 truncate font-mono text-xs font-semibold text-gray-700 dark:text-gray-300",children:e.name||m.chat.unknownTool}),h&&s.jsx("span",{className:"min-w-0 shrink truncate text-xs text-gray-500 dark:text-gray-400",children:h}),s.jsx("span",{className:"shrink-0 font-mono text-xs text-gray-500 dark:text-gray-400",children:e.durationMs!==void 0?hn(e.durationMs):g?s.jsx(gi,{sinceMs:e.approvalAtMs??e.callStartedAtMs,offsetMs:v}):u?v>0?hn(v):null:e.callStreaming?e.argStartedAtMs!==void 0?s.jsx(gi,{sinceMs:e.argStartedAtMs}):s.jsx("span",{className:"animate-pulse",children:"…"}):null}),s.jsx("span",{className:"min-w-0 flex-1"}),s.jsx($n,{open:a,className:"text-gray-400"})]}),u&&s.jsxs("div",{className:"border-t border-gray-100 bg-amber-50 px-3 py-2 dark:border-gray-800 dark:bg-amber-950/30",children:[s.jsxs("div",{className:"mb-2 flex items-start gap-2 sm:items-center",children:[s.jsx("span",{className:"shrink-0 rounded-md bg-white px-1.5 py-0.5 font-mono text-xs font-semibold text-gray-700 dark:bg-gray-900 dark:text-gray-300",children:e.name||m.chat.unknownTool}),s.jsx("span",{className:"min-w-0 flex-1 whitespace-pre-wrap break-all font-mono text-xs text-gray-600 sm:truncate dark:text-gray-400",children:f})]}),(()=>{const M=ZI(e.name,e.argumentsText);return M!==null?s.jsx("pre",{className:"mb-2 max-h-72 overflow-auto whitespace-pre-wrap break-all rounded-md bg-white/70 px-2 py-1.5 text-xs leading-5 text-gray-700 dark:bg-gray-950/40 dark:text-gray-300",children:M}):null})(),s.jsx(HI,{onDecide:M=>t.onApprove(e.toolCallId,M,t.origin)})]}),a&&s.jsxs("div",{className:"anim-fade",children:[e.argumentsText&&s.jsx("pre",{className:"whitespace-pre-wrap break-all border-t border-gray-100 bg-gray-50 px-3 py-2 text-xs text-gray-600 dark:border-gray-800 dark:bg-gray-950/60 dark:text-gray-400",children:e.argumentsText}),(e.output||e.outputStreaming)&&s.jsxs("pre",{className:"max-h-72 overflow-auto whitespace-pre-wrap border-t border-gray-100 px-3 py-2 text-xs leading-5 text-gray-600 dark:border-gray-800 dark:text-gray-300",children:[p,e.outputStreaming&&s.jsx("span",{className:"animate-pulse",children:"▌"})]}),e.images&&e.images.length>0&&s.jsx("div",{className:"flex flex-wrap gap-2 border-t border-gray-100 px-3 py-2 dark:border-gray-800",children:e.images.map((M,_)=>s.jsx(Zr,{src:M,alt:m.chat.toolImageAlt,className:"max-h-40 max-w-full rounded-md border border-gray-200 dark:border-gray-700"},_))})]}),e.subagent&&s.jsx("div",{className:"px-3 pb-2 pt-2",children:s.jsx(sS,{sessionId:e.subagentSessionId??"",model:e.subagent,running:!e.outputComplete,agentId:aS(e.argumentsText),ctx:t})})]})}function gd({state:e,title:t,detail:a,liveSinceMs:l,durationMs:o,children:c}){const[u,f]=y.useState(!1),p=y.useRef(null),h=e==="running",g=c!=null,v=s.jsxs(s.Fragment,{children:[s.jsx(Tl,{state:e,size:12}),s.jsx("span",{className:`shrink-0 text-[11px] font-semibold tracking-wide uppercase ${h?"text-emerald-600 dark:text-emerald-400":"text-gray-500 dark:text-gray-400"}`,children:t}),a!==void 0&&s.jsx("span",{title:a,className:"min-w-0 truncate font-mono text-xs text-gray-400",children:a}),h?l!==void 0&&s.jsx("span",{className:"shrink-0 font-mono text-xs text-gray-400",children:s.jsx(gi,{sinceMs:l})}):o!==void 0&&o>0&&s.jsx("span",{className:"shrink-0 font-mono text-xs text-gray-400",children:hn(o)}),s.jsx("span",{className:"min-w-0 flex-1"}),g&&s.jsx($n,{open:u,className:"text-gray-400"})]});return s.jsxs("div",{ref:p,className:"anim-msg my-2 overflow-clip rounded-md border border-gray-200 bg-white dark:border-gray-800 dark:bg-gray-900",children:[g?s.jsx("button",{type:"button","aria-expanded":u,onClick:()=>{const k=u;f(w=>!w),k&&requestAnimationFrame(()=>p.current?.scrollIntoView({block:"nearest"}))},className:"sticky -top-4 z-[5] flex w-full items-center gap-2 bg-gray-50 px-3 py-2 text-left transition-colors duration-150 hover:bg-gray-100 dark:bg-gray-900 dark:hover:bg-gray-800",children:v}):s.jsx("div",{className:"flex w-full items-center gap-2 bg-gray-50 px-3 py-2 text-left dark:bg-gray-900",children:v}),g&&u&&s.jsx("div",{className:"anim-fade divide-y divide-gray-100 border-t border-gray-200 dark:divide-gray-800/60 dark:border-gray-800",children:c})]})}function e8({item:e}){if(e.running)return s.jsx(gd,{state:"running",title:m.chat.compactionTitle,detail:e.mode,...e.beginTsMs!==void 0?{liveSinceMs:e.beginTsMs}:{}});const t=e.status==="completed";return s.jsx(gd,{state:t?"done":"failed",title:m.chat.compactionTitle,detail:t?m.chat.compactionDone(e.mode):m.chat.compactionFailed(e.status??"failed",e.errorMessage),...e.durationMs!==void 0?{durationMs:e.durationMs}:{}})}function t8(e,t){let a=null;for(const l of t)e.startsWith(`mcp__${l}__`)&&(a===null||l.length>a.length)&&(a=l);return a}function n8({outcome:e,tools:t}){const[a,l]=y.useState(!1),o=e.status==="failed",c=o?e.error!==void 0:t.length>0,u=o?m.chat.mcpServerFailed:m.chat.mcpToolsCount(e.tools??0),f=s.jsxs(s.Fragment,{children:[s.jsx(Tl,{state:o?"failed":"done",size:11}),s.jsx("code",{className:"shrink-0 font-mono text-xs text-gray-700 dark:text-gray-300",children:e.server}),s.jsx("span",{className:"min-w-0 truncate font-mono text-xs text-gray-400",children:u}),e.durationMs>0&&s.jsx("span",{className:"shrink-0 font-mono text-xs text-gray-400",children:hn(e.durationMs)}),s.jsx("span",{className:"min-w-0 flex-1"}),c&&s.jsx($n,{open:a,size:12,className:"text-gray-400"})]});return c?s.jsxs("div",{children:[s.jsx("button",{type:"button","aria-expanded":a,onClick:()=>l(p=>!p),className:"sticky top-4 z-[4] flex w-full items-center gap-2 bg-white px-3 py-1.5 text-left transition-colors duration-150 hover:bg-gray-50 dark:bg-gray-900 dark:hover:bg-gray-800",children:f}),a&&(o?s.jsx("p",{className:"anim-fade px-3 pt-0.5 pb-2 pl-8 font-mono text-xs break-all text-gray-500 dark:text-gray-400",children:e.error}):s.jsx("ul",{className:"anim-fade pb-1",children:t.map(p=>s.jsxs("li",{className:"flex items-baseline gap-2 py-1 pr-3 pl-8",children:[s.jsx("code",{className:"shrink-0 font-mono text-xs text-gray-700 dark:text-gray-300",children:p.name}),p.description!==void 0&&s.jsx("span",{title:p.description,className:"min-w-0 truncate text-xs text-gray-400 dark:text-gray-500",children:p.description})]},p.name))}))]}):s.jsx("div",{className:"flex w-full items-center gap-2 px-3 py-1.5",children:f})}function a8({item:e}){if(e.running)return s.jsx(gd,{state:"running",title:m.chat.mcpConnectTitle,detail:m.chat.mcpServerList(e.servers),...e.beginTsMs!==void 0?{liveSinceMs:e.beginTsMs}:{}});const t=e.aborted||(e.failed?.length??0)>0,a=e.aborted?m.chat.mcpConnectAborted:m.chat.mcpConnectResult(e.toolCount??0,e.failed??[]),l=e.results??[],o=e.tools??[],c=l.map(u=>u.server);return s.jsx(gd,{state:t?"failed":"done",title:m.chat.mcpConnectTitle,detail:a,...e.durationMs!==void 0?{durationMs:e.durationMs}:{},children:l.length>0?l.map(u=>s.jsx(n8,{outcome:u,tools:o.filter(f=>t8(f.name,c)===u.server)},u.server)):void 0})}const Ag=-1,tc="M21 12A9 9 0 1 1 12 3M17 12A5 5 0 1 1 12 7M12 12L15 9V5L18 2V6H22L19 9H15";function Lu(e){const t=e.trim();if(t==="")return Ag;const a=/^(\d+(?:\.\d+)?)([km])?$/i.exec(t);if(!a)return null;const l=a[2]?.toLowerCase()==="m"?1e6:a[2]?.toLowerCase()==="k"?1e3:1,o=Math.round(Number(a[1])*l);return o>0?o:null}const r8="M3 5h18v14H3zM3 16l5-5 4 4 3-3 6 6M15.5 8.5a1 1 0 1 1-2 0 1 1 0 0 1 2 0";function s8({images:e,showFull:t,onExpand:a}){return e.length===0?null:t?s.jsx("div",{className:"mt-1.5 flex max-w-[88%] flex-wrap justify-end gap-1.5 md:max-w-[75%]",children:e.map((l,o)=>s.jsx(Zr,{src:l,alt:m.chat.imageAlt,className:"max-h-40 max-w-full rounded-md"},o))}):s.jsxs("button",{type:"button",onClick:a,className:"mt-1.5 flex items-center gap-1.5 rounded-md border border-gray-200 bg-gray-50 px-2 py-1 text-xs text-gray-500 hover:bg-gray-100 dark:border-gray-700 dark:bg-gray-900 dark:text-gray-400 dark:hover:bg-gray-800",children:[s.jsx(qe,{d:r8,size:12,className:"shrink-0"}),m.chat.goalRoundImages(e.length)]})}function l8({round:e,objective:t,images:a=[]}){const[l,o]=y.useState(!1),c=a.length>0&&(e===1||l);return t!==void 0&&t!==""?s.jsxs("div",{className:"anim-msg my-4 flex flex-col items-end",children:[s.jsx("div",{className:"max-w-[88%] rounded-lg bg-gray-100 px-4 py-2.5 md:max-w-[75%] dark:bg-gray-800",children:s.jsx("p",{className:"wrap-anywhere whitespace-pre-wrap text-base leading-relaxed text-gray-900 dark:text-gray-100",children:t})}),s.jsx(s8,{images:a,showFull:c,onExpand:()=>o(!0)}),s.jsxs("p",{className:"mt-1 flex items-center gap-1.5 px-0.5 text-xs text-gray-400 dark:text-gray-500",children:[s.jsx(qe,{d:tc,size:12,className:"shrink-0"}),m.chat.goalRoundBanner(e)]})]}):s.jsxs("p",{className:"anim-msg my-2 flex w-fit items-center gap-2 rounded-md border border-gray-200 bg-gray-50 px-3 py-2 text-xs text-gray-600 dark:border-gray-800 dark:bg-gray-900 dark:text-gray-400",children:[s.jsx(qe,{d:tc,className:"text-gray-400 dark:text-gray-500"}),m.chat.goalRoundBanner(e)]})}function i8({goal:e}){const t=e.budget>0&&e.budget!==Ag?`${Ct(e.used)}/${Ct(e.budget)}`:Ct(e.used),a=e.status!=="active";return s.jsxs("div",{className:"anim-fade mb-2 flex items-center gap-2 rounded-md border border-gray-200 bg-gray-50 px-3 py-2 text-xs text-gray-600 dark:border-gray-800 dark:bg-gray-900 dark:text-gray-400",children:[s.jsx(qe,{d:tc,className:"shrink-0 text-gray-400 dark:text-gray-500"}),s.jsx("span",{className:"min-w-0 flex-1 truncate",title:e.objective,children:e.objective}),s.jsx("span",{className:"shrink-0 text-gray-400 dark:text-gray-500",children:m.chat.goalProgress(e.rounds,t)}),s.jsx("span",{className:`shrink-0 rounded px-1.5 py-0.5 ${a?e.status==="complete"?"bg-green-100 text-green-700 dark:bg-green-900/40 dark:text-green-400":"bg-amber-100 text-amber-700 dark:bg-amber-900/40 dark:text-amber-400":"bg-gray-200 text-gray-600 dark:bg-gray-800 dark:text-gray-300"}`,children:m.chat.goalStatus[e.status]})]})}function o8(e){return e.agentName&&e.agentName!==e.agentId?`${e.agentName} (${e.agentId})`:e.agentId}const kh="anim-msg my-2 flex w-fit items-center gap-2 rounded-md border border-gray-200 bg-gray-50 px-3 py-2 text-xs text-gray-600 dark:border-gray-800 dark:bg-gray-900 dark:text-gray-400";function c8({origin:e}){const t=Wn(),a=m.chat.handoffFrom(o8(e));if(!e.sessionId)return s.jsx("p",{className:kh,children:a});const l=e.sessionId;return s.jsxs("button",{type:"button",title:m.chat.handoffBack(e.sessionTitle),onClick:()=>t(`/chat/${l}`),className:`${kh} transition-colors hover:bg-gray-100 hover:text-gray-800 dark:hover:bg-gray-800 dark:hover:text-gray-200`,children:[a,s.jsx("span",{"aria-hidden":!0,className:"text-gray-400 dark:text-gray-500",children:"→"})]})}function u8({origin:e}){const t=Wn(),a=e.sessionId;return s.jsxs("button",{type:"button",title:m.chat.handoffBack(e.sessionTitle),onClick:()=>t(`/chat/${a}`),className:`${kh} transition-colors hover:bg-gray-100 hover:text-gray-800 dark:hover:bg-gray-800 dark:hover:text-gray-200`,children:[m.chat.modelSwitchFrom(e.prevModelId),s.jsx("span",{"aria-hidden":!0,className:"text-gray-400 dark:text-gray-500",children:"→"})]})}function d8({origin:e}){return s.jsxs("p",{className:"anim-msg my-2 flex w-fit items-center gap-2 rounded-md border border-gray-200 bg-gray-50 px-3 py-2 text-xs text-gray-600 dark:border-gray-800 dark:bg-gray-900 dark:text-gray-400",children:[m.chat.scheduledFrom(e.name),e.firedAt&&s.jsx("span",{className:"text-gray-400 dark:text-gray-500",children:ha(e.firedAt)})]})}const Rg="M2 3h6a4 4 0 0 1 4 4v14a3 3 0 0 0-3-3H2zM22 3h-6a4 4 0 0 0-4 4v14a3 3 0 0 1 3-3h7z";function f8(e,t,a){return e==="zh"&&a?a:t}function ji(e,t){return e==="zh"?t.shortDescriptionZh||t.shortDescription||t.description:t.shortDescription||t.description}function m8(e,t,a){const l=a.trim().toLowerCase();return l?e.filter(o=>o.name.toLowerCase().includes(l)||ji(t,o).toLowerCase().includes(l)):e}function p8(e,t){return e.map(a=>({name:a.name,cmd:`/${a.name}`,desc:ji(t,a)}))}function e1({names:e}){return s.jsxs("p",{className:"anim-msg my-2 flex w-fit items-center gap-2 rounded-md border border-gray-200 bg-gray-50 px-3 py-2 text-xs text-gray-600 dark:border-gray-800 dark:bg-gray-900 dark:text-gray-400",children:[s.jsx(qe,{d:Rg,className:"text-gray-400 dark:text-gray-500"}),m.chat.skillsBanner(e)]})}const wh="M21.4 11.05l-9.19 9.19a6 6 0 0 1-8.49-8.49l9.2-9.19a4 4 0 0 1 5.65 5.66l-9.19 9.19a2 2 0 0 1-2.83-2.83l8.49-8.48";function t1({files:e}){const t=m.chat.attachedFilesBanner(e.map(e3));return s.jsxs("p",{title:t,className:"flex w-fit max-w-full items-center gap-2 rounded-md border border-gray-200 bg-gray-50 px-3 py-2 text-xs text-gray-600 dark:border-gray-800 dark:bg-gray-900 dark:text-gray-400",children:[s.jsx(qe,{d:wh,className:"shrink-0 text-gray-400 dark:text-gray-500"}),s.jsx("span",{className:"min-w-0 truncate",children:t})]})}const h8=fM,g8=hM;function x8(e,t){const a=t.trim().toLowerCase();return a?e.filter(l=>l.agentId.toLowerCase().includes(a)||(l.name??"").toLowerCase().includes(a)):e}function y8({handoffTarget:e,pendingModel:t,canSwitchModel:a,sessionBusy:l}){return e?"handoff":!t||!a?"post":l?"blocked":"model"}function jo({icon:e,value:t,compactValue:a,label:l,display:o="flex"}){return s.jsxs("span",{title:l,"aria-label":l,className:`${o} items-center gap-1`,children:[s.jsx(qe,{d:e}),a!==void 0&&a!==t?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"sm:hidden",children:a}),s.jsx("span",{className:"hidden sm:inline",children:t})]}):t]})}function v8({stats:e,assistantText:t,cost:a,atMs:l}){const{currency:o}=Ps(),{locale:c}=La(),u=e?.tokensByBucket,f=u?u.cacheRead+u.cacheWrite:0,p=()=>t?.trim()||e===null?t??"":EM(e,{stats:m.chat.statsLabel,input:m.chat.statInput,cached:m.chat.statCached,output:m.chat.statOutput,parenOpen:m.chat.statParenOpen,parenClose:m.chat.statParenClose});return s.jsxs("div",{className:"-mt-2 flex h-5 items-center justify-start gap-x-2 overflow-hidden whitespace-nowrap text-[11px] text-gray-400 transition-opacity duration-150 group-hover:opacity-100 focus-within:opacity-100 sm:gap-x-3 sm:opacity-0 dark:text-gray-500",children:[s.jsxs("span",{className:"no-scrollbar flex min-w-0 items-center gap-x-2 overflow-x-auto sm:gap-x-3",children:[l!==void 0&&s.jsx("span",{children:Nw(l,c)}),e&&u&&s.jsxs(s.Fragment,{children:[s.jsx(jo,{icon:Un.input,value:Ct(f),label:m.chat.statInput}),s.jsx(jo,{icon:Un.output,value:Ct(u.output),label:m.chat.statOutput}),s.jsx(jo,{icon:Un.tps,value:ad(e.outputTps),label:m.chat.statTps,display:"hidden sm:flex"}),a!=null&&s.jsx(jo,{icon:Un.cost,value:hr(a,o),compactValue:hr(a,o,{compact:!0}),label:`${m.common.cost}(${o})`}),s.jsx(jo,{icon:Un.elapsed,value:hn(e.elapsedDeltaMs),compactValue:hn(e.elapsedDeltaMs,{compact:!0}),label:m.chat.statElapsed})]})]}),s.jsx(uc,{text:p,label:m.chat.copyReply,className:"flex h-5 w-5 shrink-0 items-center justify-center rounded transition-colors duration-150 hover:bg-gray-100 hover:text-gray-600 dark:hover:bg-gray-800 dark:hover:text-gray-300"})]})}const b8="M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2M16 7a4 4 0 1 1-8 0 4 4 0 0 1 8 0";function Co({atMs:e,text:t,align:a="left"}){const{locale:l}=La();return s.jsxs("div",{className:`flex h-5 items-center gap-2 transition-opacity duration-150 group-hover:opacity-100 focus-within:opacity-100 sm:opacity-0 ${a==="right"?"justify-end":"justify-start"}`,children:[e!==void 0&&s.jsx("span",{className:"text-[11px] text-gray-400",children:Nw(e,l)}),t!==void 0&&s.jsx(uc,{text:t,label:m.chat.copyMessage})]})}const k8=2e3;function w8({item:e,ctx:t}){const a=e.gaveUp?"gaveUp":e.retrying?"retried":"waiting",l=a==="waiting"&&e.plannedDelayMs!==void 0&&e.plannedDelayMs>=k8&&e.arrivedAtMs!==void 0?e.arrivedAtMs+e.plannedDelayMs:null,[o,c]=y.useState(()=>Date.now()),[u,f]=y.useState(!1);y.useEffect(()=>{if(l===null||Date.now()>=l)return;const k=setInterval(()=>{c(Date.now()),Date.now()>=l&&clearInterval(k)},250);return()=>clearInterval(k)},[l]);const p=l!==null?l-o:0,h=l!==null&&p>0,g=h?Math.ceil(p/1e3):void 0,v=h&&t.origin.length===0&&(t.onRetryNow!==void 0||t.onGiveUp!==void 0);return s.jsxs("p",{className:"anim-msg my-1 flex flex-wrap items-center gap-x-2 gap-y-1 font-mono text-xs text-amber-600 dark:text-amber-500",children:[s.jsx("span",{children:m.chat.reconnect(e.status,a,e.attempt,g)}),v&&s.jsxs("span",{className:"flex shrink-0 items-center gap-1.5",children:[t.onRetryNow&&s.jsx("button",{type:"button",disabled:u,onClick:()=>{f(!0),t.onRetryNow()},className:"rounded border border-amber-300 px-1.5 py-0.5 text-[11px] font-medium text-amber-700 transition-colors duration-150 hover:bg-amber-50 disabled:cursor-not-allowed disabled:opacity-50 dark:border-amber-700 dark:text-amber-400 dark:hover:bg-amber-950/40",children:m.chat.reconnectRetryNow}),t.onGiveUp&&s.jsx("button",{type:"button",disabled:u,onClick:()=>{f(!0),t.onGiveUp()},className:"rounded border border-gray-300 px-1.5 py-0.5 text-[11px] text-gray-500 transition-colors duration-150 hover:bg-gray-100 disabled:cursor-not-allowed disabled:opacity-50 dark:border-gray-600 dark:text-gray-400 dark:hover:bg-gray-800",children:m.chat.reconnectGiveUp})]})]})}function iS({item:e,ctx:t}){switch(e.kind){case"user_text":{const a=Uw(e.text);if(a)return s.jsx(c8,{origin:a});const l=Pw(e.text);if(l)return s.jsx(u8,{origin:l});const o=Bw(e.text),c=o?o.rest:e.text,u=$w(c),f=u?u.rest:c,p=Dw(f),{text:h,images:g,files:v}=cd(p?p.rest:f);return o?s.jsxs(s.Fragment,{children:[p&&s.jsx(e1,{names:p.skills}),s.jsx(l8,{round:o.round,objective:h,images:g})]}):s.jsxs(s.Fragment,{children:[u&&s.jsx(d8,{origin:u.origin}),p&&s.jsx(e1,{names:p.skills}),h&&s.jsxs("div",{className:"anim-msg group my-4 flex flex-col items-end",children:[s.jsx("div",{className:"max-w-[88%] rounded-lg bg-gray-100 px-4 py-2.5 md:max-w-[75%] dark:bg-gray-800",children:s.jsx("p",{className:"wrap-anywhere whitespace-pre-wrap text-base leading-relaxed text-gray-900 dark:text-gray-100",children:h})}),s.jsx(Co,{...e.atMs!==void 0?{atMs:e.atMs}:{},text:h,align:"right"})]}),v.length>0&&s.jsxs("div",{className:"anim-msg group my-4 flex flex-col items-end",children:[s.jsx(t1,{files:v}),s.jsx(Co,{...e.atMs!==void 0?{atMs:e.atMs}:{},align:"right"})]}),g.map((k,w)=>s.jsxs("div",{className:"anim-msg group my-4 flex flex-col items-end",children:[s.jsx("div",{className:"max-w-[88%] rounded-lg bg-gray-100 p-1.5 md:max-w-[75%] dark:bg-gray-800",children:s.jsx(Zr,{src:k,alt:m.chat.imageAlt,className:"max-h-48 max-w-full rounded-md"})}),s.jsx(Co,{...e.atMs!==void 0?{atMs:e.atMs}:{},align:"right"})]},w))]})}case"user_steering":{const{text:a,images:l,files:o}=cd(e.text),c=[...l,...e.images??[]];return s.jsxs("div",{className:"anim-msg group my-2 flex flex-col items-end",children:[s.jsxs("div",{className:"flex max-w-[88%] flex-col gap-1.5 rounded-md border border-gray-200 bg-gray-100 px-3 py-1.5 md:max-w-[75%] dark:border-gray-700 dark:bg-gray-800",children:[s.jsxs("div",{className:"flex items-start gap-1.5",children:[s.jsx(qe,{d:b8,className:"mt-1 shrink-0 text-gray-400 dark:text-gray-500"}),s.jsxs("p",{className:"wrap-anywhere whitespace-pre-wrap text-sm leading-relaxed text-gray-800 dark:text-gray-100",children:[s.jsx("span",{className:"mr-1.5 text-xs font-semibold text-gray-500 dark:text-gray-400",children:m.chat.userSteering}),a]})]}),c.length>0&&s.jsx("div",{className:"flex flex-wrap justify-end gap-1.5",children:c.map((u,f)=>s.jsx(Zr,{src:u,alt:m.chat.imageAlt,className:"max-h-28 max-w-full rounded-md"},f))}),o.length>0&&s.jsx("div",{className:"flex justify-end",children:s.jsx(t1,{files:o})})]}),s.jsx(Co,{...e.atMs!==void 0?{atMs:e.atMs}:{},text:a,align:"right"})]})}case"user_image":return s.jsxs("div",{className:"anim-msg group my-4 flex flex-col items-end",children:[s.jsx("div",{className:"max-w-[88%] rounded-lg bg-gray-100 p-1.5 md:max-w-[75%] dark:bg-gray-800",children:s.jsx(Zr,{src:e.imageUrl,alt:m.chat.imageAlt,className:"max-h-48 max-w-full rounded-md"})}),s.jsx(Co,{...e.atMs!==void 0?{atMs:e.atMs}:{},align:"right"})]});case"assistant_text":return s.jsxs("div",{className:"md-body anim-msg my-3 text-base leading-relaxed text-gray-800 dark:text-gray-100",children:[s.jsx(Eg,{text:e.text,streaming:e.streaming}),e.streaming&&s.jsx("span",{className:"animate-pulse text-gray-400",children:"▌"}),e.stopReason&&e.stopReason!=="completed"&&s.jsxs("span",{className:"ml-1 font-mono text-xs text-gray-400",children:["[",e.stopReason,"]"]}),t.origin.length>0&&!e.streaming&&t.onOpenFile&&t.statFiles&&s.jsx(Qb,{text:e.text,workspace:t.workspace??null,statFiles:t.statFiles,onOpenFile:t.onOpenFile})]});case"thinking":return s.jsx($I,{item:e});case"tool_call":return s.jsx(JI,{item:e,ctx:t});case"subagent":return s.jsx("div",{className:"anim-msg my-2",children:s.jsx(sS,{sessionId:e.sessionId,model:e.model,running:!1,ctx:t})});case"abort":return s.jsx("p",{className:"anim-msg my-1 font-mono text-xs text-gray-500 dark:text-gray-400",children:m.chat.aborted(e.reason)});case"reconnect":return s.jsx(w8,{item:e,ctx:t});case"compaction":return s.jsx(e8,{item:e});case"mcp_connect":return s.jsx(a8,{item:e});case"task_stats":return s.jsxs(s.Fragment,{children:[t.origin.length===0&&t.onOpenFile&&t.statFiles&&e.assistantText.trim()!==""&&s.jsx(Qb,{text:e.assistantText,workspace:t.workspace??null,statFiles:t.statFiles,onOpenFile:t.onOpenFile}),s.jsx(v8,{stats:e.stats,assistantText:e.assistantText,cost:e.stats?t.taskCost?.(e.stats)??null:null,...e.atMs!==void 0?{atMs:e.atMs}:{}})]})}}function S8(e){let t=0,a=0,l,o;const c=p=>{p!==void 0&&(l===void 0||p<l)&&(l=p)},u=(p,h)=>{if(h<=0)return;if(p===void 0){a+=h;return}c(p);const g=p+h;(o===void 0||g>o)&&(o=g)};for(const p of e){if(p.kind==="thinking"){c(p.startedAtMs),p.durationMs!==void 0&&u(p.startedAtMs,p.durationMs);continue}if(p.kind!=="tool_call"||(t+=1,c(p.argStartedAtMs??p.callStartedAtMs??p.approvalAtMs),p.durationMs===void 0))continue;const h=p.argStartedAtMs!==void 0&&p.callStartedAtMs!==void 0?Math.min(p.durationMs,Math.max(0,p.callStartedAtMs-p.argStartedAtMs)):0;u(p.argStartedAtMs,h),u(p.approvalAtMs??p.callStartedAtMs,p.durationMs-h)}const f=l!==void 0&&o!==void 0?o-l:0;return{steps:t,durationMs:f+a,...l!==void 0?{startMs:l}:{}}}function j8(e){return e.kind==="thinking"||e.kind==="tool_call"}function C8(e,t){return e.kind==="thinking"?e.streaming:e.kind==="tool_call"?e.callStreaming||e.outputStreaming||e.callComplete&&!e.outputComplete?!0:t.pendingApprovals.has(pi(t.origin,e.toolCallId)):!1}function N8(e,t){return e.some(a=>a.kind==="tool_call"&&t.pendingApprovals.has(pi(t.origin,a.toolCallId)))}function T8({items:e,ctx:t,isLast:a}){const l=e.some(j=>C8(j,t)),o=a&&t.taskRunning||l,c=N8(e,t),[u,f]=y.useState(a),p=y.useRef(!1),h=y.useRef(null);y.useEffect(()=>{p.current||f(a)},[a]);const g=u||c,{steps:v,durationMs:k,startMs:w}=S8(e);return s.jsxs("div",{ref:h,className:"anim-msg my-2 overflow-clip rounded-md border border-gray-200 bg-white dark:border-gray-800 dark:bg-gray-900",children:[s.jsxs("button",{type:"button","data-group-header":!0,"aria-expanded":g,onClick:()=>{p.current=!0;const j=u&&!c;f(E=>!E),j&&requestAnimationFrame(()=>h.current?.scrollIntoView({block:"nearest"}))},className:"sticky -top-4 z-[5] flex w-full items-center gap-2 bg-gray-50 px-3 py-2 text-left transition-colors duration-150 hover:bg-gray-100 dark:bg-gray-900 dark:hover:bg-gray-800",children:[s.jsx(Tl,{state:o?"running":"done",size:12}),s.jsx("span",{className:`shrink-0 text-[11px] font-semibold uppercase tracking-wide ${o?"text-emerald-600 dark:text-emerald-400":"text-gray-500 dark:text-gray-400"}`,children:o?m.chat.workRunning:m.chat.workDone}),v>0&&s.jsx("span",{className:"hidden shrink-0 font-mono text-xs text-gray-400 sm:inline",children:m.chat.workGroupSteps(v)}),l?w!==void 0&&s.jsx("span",{className:"shrink-0 font-mono text-xs text-gray-400",children:s.jsx(gi,{sinceMs:w})}):k>0&&s.jsx("span",{className:"shrink-0 font-mono text-xs text-gray-400",children:hn(k)}),c&&!g&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"hidden shrink-0 rounded bg-amber-100 px-1 text-[10px] font-medium text-amber-700 sm:inline dark:bg-amber-950/50 dark:text-amber-300",children:m.chat.approvalWaiting}),s.jsx("span",{role:"img",title:m.chat.approvalWaiting,"aria-label":m.chat.approvalWaiting,className:"h-1.5 w-1.5 shrink-0 rounded-full bg-amber-500 sm:hidden"})]}),s.jsx("span",{className:"min-w-0 flex-1"}),s.jsx($n,{open:g,className:"text-gray-400"})]}),g&&s.jsx("div",{className:"anim-fade divide-y divide-gray-100 border-t border-gray-200 dark:divide-gray-800/60 dark:border-gray-800",children:e.map(j=>s.jsx(iS,{item:j,ctx:t},j.id))})]})}function M8(){let e=!0,t=null,a=null;return{get stick(){return e},wheel(l){l<0&&(e=!1)},touchStart(l){a=l},touchMove(l){a!==null&&l>a&&(e=!1),a=l},touchEnd(){a=null},scrolled(l){const o=l.scrollHeight-l.scrollTop-l.clientHeight,c=t;if(t=l.scrollTop,c===null){e=o<80;return}if(l.scrollTop<c&&o>1){e=!1;return}o<80&&(e=!0)},resume(){e=!0,t=null}}}function E8({items:e,ctx:t}){const a=[];let l=[];const o=()=>{l.length>0&&(a.push({type:"group",items:l}),l=[])};for(const h of e)j8(h)?l.push(h):(o(),a.push({type:"single",item:h}));o();const c=(h,g)=>h.type==="group"?s.jsx(T8,{items:h.items,ctx:t,isLast:g===a.length-1},`wg-${h.items[0].id}`):s.jsx(iS,{item:h.item,ctx:t},h.item.id),u=[];let f=[];const p=()=>{if(f.length===0)return;const h=f[0].seg,g=h.type==="group"?h.items[0].id:h.item.id,v=f;f=[],u.push(s.jsx("div",{className:"group",children:v.map(k=>c(k.seg,k.i))},`turn-${g}`))};for(let h=0;h<a.length;h++){const g=a[h];if(g.type==="single"&&(g.item.kind==="user_text"||g.item.kind==="user_image")){p(),u.push(t.origin.length===0?s.jsx("div",{"data-outline-anchor":g.item.id,children:c(g,h)},`anchor-${g.item.id}`):c(g,h));continue}f.push({seg:g,i:h}),g.type==="single"&&g.item.kind==="task_stats"&&p()}return p(),s.jsx(s.Fragment,{children:u})}const A8=300;function oS({items:e,version:t,ctx:a,scrollElRef:l,outline:o,older:c}){const u=y.useRef(null),f=y.useRef(null),p=f.current??=M8(),[h,g]=y.useState(!1),v=y.useRef(!1),k=y.useRef(null),w=()=>{k.current!==null&&(cancelAnimationFrame(k.current),k.current=null),v.current=!1};y.useEffect(()=>()=>w(),[]);const j=y.useRef(null),E=()=>{const A=u.current;g(!v.current&&!p.stick&&A!==null&&A.scrollHeight-A.scrollTop-A.clientHeight>1)},C=y.useRef(c);C.current=c;const M=y.useRef(c?.prependedCount??0),_=y.useRef(0),D=A=>{const P=C.current;!P||!P.hasMore||P.loading||P.error!==null||A.scrollTop<A8&&P.onLoad()},V=()=>{const A=u.current;if(!A)return;const P=j.current;j.current=A.scrollTop,v.current&&P!==null&&A.scrollTop<P-1&&w(),p.scrolled({scrollTop:A.scrollTop,scrollHeight:A.scrollHeight,clientHeight:A.clientHeight}),D(A),E()};y.useLayoutEffect(()=>{const A=u.current,P=c?.prependedCount??0;A&&P>M.current&&!p.stick&&!v.current&&(A.scrollTop+=A.scrollHeight-_.current),M.current=P,A&&(_.current=A.scrollHeight),A&&p.stick&&!v.current&&(A.scrollTop=A.scrollHeight),E()},[t,p,c?.prependedCount]),y.useEffect(()=>{const A=u.current;if(!A||typeof ResizeObserver>"u")return;const P=new ResizeObserver(()=>{_.current=A.scrollHeight,p.stick&&!v.current&&(A.scrollTop=A.scrollHeight),E()});return P.observe(A),A.firstElementChild&&P.observe(A.firstElementChild),()=>P.disconnect()},[p]);const F=()=>{const A=u.current;if(!A)return;if(window.matchMedia("(prefers-reduced-motion: reduce)").matches){p.resume(),A.scrollTop=A.scrollHeight,E();return}w(),v.current=!0,A.scrollHeight-A.clientHeight-A.scrollTop>3*A.clientHeight&&(A.scrollTop=A.scrollHeight-4*A.clientHeight);let Q=performance.now();const K=O=>{k.current=null;const z=u.current;if(!z||!v.current)return;const I=Math.min(.05,Math.max(.001,(O-Q)/1e3));Q=O;const B=z.scrollHeight-z.clientHeight-z.scrollTop;if(B<=1){v.current=!1,p.resume(),z.scrollTop=z.scrollHeight,E();return}const $=Math.max(B*Math.min(1,I*10),3200*I);z.scrollTop+=Math.min($,B),k.current=requestAnimationFrame(K)};k.current=requestAnimationFrame(K),E()};return s.jsxs("div",{className:"relative h-full min-h-0",children:[s.jsx("div",{ref:A=>{u.current=A,l&&(l.current=A)},onScroll:V,onWheel:A=>{p.wheel(A.deltaY),A.deltaY<0&&w(),E()},onTouchStart:A=>{const P=A.touches[0];P&&p.touchStart(P.clientY)},onTouchMove:A=>{const P=A.touches[0];P&&p.touchMove(P.clientY),v.current&&w(),E()},onTouchEnd:()=>p.touchEnd(),className:"anim-fade h-full overflow-y-auto px-4 py-4 md:px-6",children:s.jsxs("div",{className:"mx-auto max-w-3xl",children:[c&&e.length>0&&s.jsx("div",{className:"flex justify-center pb-2",children:c.loading?s.jsxs("span",{className:"flex items-center gap-2 py-1 text-xs text-gray-400 dark:text-gray-500",children:[s.jsx("span",{className:"inline-block h-3 w-3 animate-spin rounded-full border-2 border-gray-400 border-t-transparent"}),m.chat.loadingEarlier]}):c.error!==null?s.jsx("button",{type:"button",onClick:c.onLoad,className:"py-1 text-xs text-red-600 transition-colors duration-150 hover:text-red-700 dark:text-red-400 dark:hover:text-red-300",children:m.chat.loadEarlierRetry}):!c.hasMore&&c.prependedCount>0?s.jsx("span",{className:"py-1 text-xs text-gray-400 dark:text-gray-500",children:m.chat.historyBeginning}):null}),e.length===0?s.jsx(Nr,{title:m.chat.emptyStream}):s.jsx(E8,{items:e,ctx:a})]})}),o,h&&s.jsx("button",{type:"button","aria-label":m.chat.jumpToLatest,title:m.chat.jumpToLatest,onClick:F,className:"anim-pop absolute bottom-3 left-1/2 z-10 -translate-x-1/2 rounded-full border border-gray-300 bg-white p-1.5 text-gray-500 shadow-sm transition-colors duration-150 hover:bg-gray-50 hover:text-gray-900 dark:border-gray-700 dark:bg-gray-900 dark:text-gray-400 dark:hover:bg-gray-800 dark:hover:text-gray-100",children:s.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","aria-hidden":!0,children:s.jsx("path",{d:"M12 5v14M6 13l6 6 6-6",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round"})})})]})}const R8=128e3;function cS(e){const t=typeof e=="string"?Number(e):e;return typeof t=="number"&&Number.isFinite(t)&&t>0?t:R8}const _8=/[\s"'/]on[a-z]+\s*=/i,I8=/href\s*=/i;function L8(e){if(!e)return null;const t=e.trim();if(!/^<svg[\s>]/i.test(t))return null;const a=t.toLowerCase();return a.includes("<script")||a.includes("foreignobject")||I8.test(t)||_8.test(t)?null:t}const Cp=["bg-sky-50 text-sky-600 dark:bg-sky-950/60 dark:text-sky-400","bg-emerald-50 text-emerald-600 dark:bg-emerald-950/60 dark:text-emerald-400","bg-violet-50 text-violet-600 dark:bg-violet-950/60 dark:text-violet-400","bg-amber-50 text-amber-600 dark:bg-amber-950/60 dark:text-amber-400","bg-rose-50 text-rose-600 dark:bg-rose-950/60 dark:text-rose-400","bg-cyan-50 text-cyan-600 dark:bg-cyan-950/60 dark:text-cyan-400","bg-indigo-50 text-indigo-600 dark:bg-indigo-950/60 dark:text-indigo-400","bg-teal-50 text-teal-600 dark:bg-teal-950/60 dark:text-teal-400"],O8={firecrawl:3,"data-analysis":1,"web-design":2,"penguin-sdk":0};function uS(e){const t=O8[e];if(t!==void 0)return Cp[t];let a=0;for(let l=0;l<e.length;l++)a=a*31+e.charCodeAt(l)>>>0;return Cp[a%Cp.length]}function Bd({icon:e,size:t=20,className:a=""}){const l=L8(e);return l?s.jsx("span",{"aria-hidden":!0,style:{width:t,height:t},className:`block shrink-0 [&>svg]:block [&>svg]:h-full [&>svg]:w-full ${a}`,dangerouslySetInnerHTML:{__html:l}}):s.jsx(qe,{d:Rg,size:t,className:a})}const n1={viewBox:"-0.76 -0.47 28.6 28.6",path:s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M26.59,15.92L22.82,13.75C22.92,13.59,22.97,13.4,22.97,13.21L22.97,12.05C22.97,11.66,22.76,11.31,22.43,11.12L21.42,10.54C21.09,10.34,20.68,10.34,20.35,10.54L17.26,12.32C16.93,12.51,16.73,12.86,16.73,13.25L16.73,14.41C16.73,14.79,16.93,15.15,17.26,15.34L24.51,19.53C24.84,19.72,25.25,19.72,25.58,19.53L26.59,18.94C26.92,18.75,27.13,18.4,27.13,18.01L27.13,16.85C27.13,16.47,26.92,16.11,26.59,15.92L26.59,15.92Z"}),s.jsx("path",{d:"M21.88,3.58L18.11,5.75C18.02,5.59,17.89,5.46,17.72,5.36L16.71,4.78C16.38,4.59,15.97,4.59,15.64,4.78L14.63,5.36C14.3,5.55,14.09,5.9,14.09,6.29L14.09,9.86C14.09,10.24,14.3,10.59,14.63,10.78L15.64,11.37C15.97,11.56,16.38,11.56,16.71,11.37L23.96,7.18C24.29,6.99,24.5,6.64,24.5,6.25L24.5,5.09C24.5,4.71,24.29,4.35,23.96,4.16L22.95,3.58C22.62,3.39,22.21,3.39,21.88,3.58L21.88,3.58Z"}),s.jsx("path",{d:"M8.83,1.48L8.83,5.83C8.65,5.83,8.46,5.88,8.3,5.98L7.29,6.56C6.95,6.75,6.75,7.11,6.75,7.49L6.75,8.65C6.75,9.04,6.95,9.39,7.29,9.58L10.37,11.37C10.71,11.56,11.11,11.56,11.45,11.37L12.45,10.78C12.79,10.59,12.99,10.24,12.99,9.85L12.99,1.48C12.99,1.1,12.79,0.75,12.45,0.56L11.45,-0.03C11.11,-0.22,10.71,-0.22,10.37,-0.03L9.37,0.56C9.03,0.75,8.83,1.1,8.83,1.48L8.83,1.48Z"}),s.jsx("path",{d:"M0.5,11.74L4.26,13.91C4.17,14.07,4.12,14.26,4.12,14.45L4.12,15.61C4.12,16,4.32,16.35,4.65,16.54L5.66,17.13C6,17.32,6.4,17.32,6.73,17.13L9.82,15.34C10.15,15.15,10.36,14.8,10.36,14.41L10.36,13.25C10.36,12.87,10.15,12.51,9.82,12.32L2.57,8.14C2.24,7.94,1.84,7.94,1.5,8.14L0.5,8.72C0.16,8.91,-0.04,9.26,-0.04,9.65L-0.04,10.81C-0.04,11.19,0.16,11.55,0.5,11.74Z"}),s.jsx("path",{d:"M5.21,24.08L8.97,21.91C9.07,22.07,9.2,22.21,9.37,22.3L10.38,22.88C10.71,23.08,11.11,23.08,11.45,22.88L12.46,22.3C12.79,22.11,12.99,21.76,12.99,21.37L12.99,17.81C12.99,17.42,12.79,17.07,12.46,16.88L11.45,16.29C11.11,16.1,10.71,16.1,10.38,16.29L3.13,20.48C2.8,20.67,2.59,21.02,2.59,21.41L2.59,22.57C2.59,22.95,2.8,23.31,3.13,23.5L4.14,24.08C4.47,24.28,4.88,24.28,5.21,24.08L5.21,24.08Z"}),s.jsx("path",{d:"M18.26,26.18L18.26,21.83C18.44,21.83,18.63,21.78,18.79,21.68L19.8,21.1C20.13,20.91,20.34,20.56,20.34,20.17L20.34,19.01C20.34,18.62,20.13,18.27,19.8,18.08L16.71,16.3C16.38,16.1,15.97,16.1,15.64,16.3L14.63,16.88C14.3,17.07,14.1,17.42,14.1,17.81L14.1,26.18C14.1,26.56,14.3,26.91,14.63,27.11L15.64,27.69C15.97,27.88,16.38,27.88,16.71,27.69L17.72,27.11C18.05,26.91,18.26,26.56,18.26,26.18L18.26,26.18Z"})]})},D8={anthropic:{path:s.jsx("path",{d:"M17.3041 3.541h-3.6718l6.696 16.918H24Zm-10.6082 0L0 20.459h3.7442l1.3693-3.5527h7.0052l1.3693 3.5528h3.7442L10.5363 3.5409Zm-.3712 10.2232 2.2914-5.9456 2.2914 5.9456Z"})},openai:{path:s.jsx("path",{d:"M22.2819 9.8211a5.9847 5.9847 0 0 0-.5157-4.9108 6.0462 6.0462 0 0 0-6.5098-2.9A6.0651 6.0651 0 0 0 4.9807 4.1818a5.9847 5.9847 0 0 0-3.9977 2.9 6.0462 6.0462 0 0 0 .7427 7.0966 5.98 5.98 0 0 0 .511 4.9107 6.051 6.051 0 0 0 6.5146 2.9001A5.9847 5.9847 0 0 0 13.2599 24a6.0557 6.0557 0 0 0 5.7718-4.2058 5.9894 5.9894 0 0 0 3.9977-2.9001 6.0557 6.0557 0 0 0-.7475-7.0729zm-9.022 12.6081a4.4755 4.4755 0 0 1-2.8764-1.0408l.1419-.0804 4.7783-2.7582a.7948.7948 0 0 0 .3927-.6813v-6.7369l2.02 1.1686a.071.071 0 0 1 .038.052v5.5826a4.504 4.504 0 0 1-4.4945 4.4944zm-9.6607-4.1254a4.4708 4.4708 0 0 1-.5346-3.0137l.142.0852 4.783 2.7582a.7712.7712 0 0 0 .7806 0l5.8428-3.3685v2.3324a.0804.0804 0 0 1-.0332.0615L9.74 19.9502a4.4992 4.4992 0 0 1-6.1408-1.6464zM2.3408 7.8956a4.485 4.485 0 0 1 2.3655-1.9728V11.6a.7664.7664 0 0 0 .3879.6765l5.8144 3.3543-2.0201 1.1685a.0757.0757 0 0 1-.071 0l-4.8303-2.7865A4.504 4.504 0 0 1 2.3408 7.872zm16.5963 3.8558L13.1038 8.364 15.1192 7.2a.0757.0757 0 0 1 .071 0l4.8303 2.7913a4.4944 4.4944 0 0 1-.6765 8.1042v-5.6772a.79.79 0 0 0-.407-.667zm2.0107-3.0231l-.142-.0852-4.7735-2.7818a.7759.7759 0 0 0-.7854 0L9.409 9.2297V6.8974a.0662.0662 0 0 1 .0284-.0615l4.8303-2.7866a4.4992 4.4992 0 0 1 6.6802 4.66zM8.3065 12.863l-2.02-1.1638a.0804.0804 0 0 1-.038-.0567V6.0742a4.4992 4.4992 0 0 1 7.3757-3.4537l-.142.0805L8.704 5.459a.7948.7948 0 0 0-.3927.6813zm1.0976-2.3654l2.602-1.4998 2.6069 1.4998v2.9994l-2.5974 1.4997-2.6067-1.4997Z"})},google:{path:s.jsx("path",{d:"M12 24A14.304 14.304 0 0 0 0 12 14.304 14.304 0 0 0 12 0a14.305 14.305 0 0 0 12 12 14.305 14.305 0 0 0-12 12"})},deepseek:{path:s.jsx("path",{d:"M23.748 4.482c-.254-.124-.364.113-.512.234-.051.039-.094.09-.137.136-.372.397-.806.657-1.373.626-.829-.046-1.537.214-2.163.848-.133-.782-.575-1.248-1.247-1.548-.352-.156-.708-.311-.955-.65-.172-.241-.219-.51-.305-.774-.055-.16-.11-.323-.293-.35-.2-.031-.278.136-.356.276-.313.572-.434 1.202-.422 1.84.027 1.436.633 2.58 1.838 3.393.137.093.172.187.129.323-.082.28-.18.552-.266.833-.055.179-.137.217-.328.14a5.526 5.526 0 0 1-1.736-1.18c-.857-.828-1.631-1.742-2.597-2.458a11.365 11.365 0 0 0-.689-.471c-.985-.957.13-1.743.388-1.836.27-.098.093-.432-.779-.428-.872.004-1.67.295-2.687.684a3.055 3.055 0 0 1-.465.137 9.597 9.597 0 0 0-2.883-.102c-1.885.21-3.39 1.102-4.497 2.623C.082 8.606-.231 10.684.152 12.85c.403 2.284 1.569 4.175 3.36 5.653 1.858 1.533 3.997 2.284 6.438 2.14 1.482-.085 3.133-.284 4.994-1.86.47.234.962.327 1.78.397.63.059 1.236-.03 1.705-.128.735-.156.684-.837.419-.961-2.155-1.004-1.682-.595-2.113-.926 1.096-1.296 2.746-2.642 3.392-7.003.05-.347.007-.565 0-.845-.004-.17.034-.237.23-.256a4.173 4.173 0 0 0 1.545-.475c1.396-.763 1.96-2.015 2.093-3.517.02-.23-.004-.467-.247-.588zM11.581 18c-2.089-1.642-3.102-2.183-3.52-2.16-.392.024-.321.471-.235.763.09.288.207.486.371.739.114.167.192.416-.113.603-.673.416-1.842-.14-1.897-.167-1.361-.802-2.5-1.86-3.301-3.307-.774-1.393-1.224-2.887-1.298-4.482-.02-.386.093-.522.477-.592a4.696 4.696 0 0 1 1.529-.039c2.132.312 3.946 1.265 5.468 2.774.868.86 1.525 1.887 2.202 2.891.72 1.066 1.494 2.082 2.48 2.914.348.292.625.514.891.677-.802.09-2.14.11-3.054-.615zm1-6.44a.306.306 0 0 1 .415-.287.302.302 0 0 1 .2.288.306.306 0 0 1-.31.307.303.303 0 0 1-.304-.308zm3.11 1.596c-.2.081-.399.151-.59.16a1.245 1.245 0 0 1-.798-.254c-.274-.23-.47-.358-.552-.758a1.73 1.73 0 0 1 .016-.588c.07-.327-.008-.537-.239-.727-.187-.156-.426-.199-.688-.199a.559.559 0 0 1-.254-.078c-.11-.054-.2-.19-.114-.358.028-.054.16-.186.191-.21.356-.202.767-.136 1.146.016.352.144.618.408 1.001.782.391.451.462.576.685.914.176.265.336.537.445.848.067.196-.02.354-.25.452z"})},zhipu:{path:s.jsx("path",{d:"M4.6 3.2h14.8a.9.9 0 0 1 .73 1.43L9.9 18.6h9.2a.9.9 0 0 1 0 1.8H4.6a.9.9 0 0 1-.73-1.43L14.1 5.4H4.6a1.1 1.1 0 0 1 0-2.2Z"})},moonshot:{path:s.jsx("path",{d:"m1.053 16.91 9.538 2.55a21 20.981 0 0 0 .06 2.031l5.956 1.592a12 11.99 0 0 1-15.554-6.172m-1.02-5.79 11.352 3.035a21 20.981 0 0 0-.469 2.01l10.817 2.89a12 11.99 0 0 1-1.845 2.004L.658 15.918a12 11.99 0 0 1-.625-4.796m1.593-5.146L13.573 9.17a21 20.981 0 0 0-1.01 1.874l11.297 3.02a21 20.981 0 0 1-.67 2.362l-11.55-3.087L.125 10.26a12 11.99 0 0 1 1.499-4.285ZM6.067 1.58l11.285 3.016a21 20.981 0 0 0-1.688 1.719l7.824 2.091a21 20.981 0 0 1 .513 2.664L2.107 5.218a12 11.99 0 0 1 3.96-3.638M21.68 4.866 7.222 1.003A12 11.99 0 0 1 21.68 4.866"})},openrouter:{path:s.jsx("path",{d:"M16.778 1.844v1.919q-.569-.026-1.138-.032-.708-.008-1.415.037c-1.93.126-4.023.728-6.149 2.237-2.911 2.066-2.731 1.95-4.14 2.75-.396.223-1.342.574-2.185.798-.841.225-1.753.333-1.751.333v4.229s.768.108 1.61.333c.842.224 1.789.575 2.185.799 1.41.798 1.228.683 4.14 2.75 2.126 1.509 4.22 2.11 6.148 2.236.88.058 1.716.041 2.555.005v1.918l7.222-4.168-7.222-4.17v2.176c-.86.038-1.611.065-2.278.021-1.364-.09-2.417-.357-3.979-1.465-2.244-1.593-2.866-2.027-3.68-2.508.889-.518 1.449-.906 3.822-2.59 1.56-1.109 2.614-1.377 3.978-1.466.667-.044 1.418-.017 2.278.02v2.176L24 6.014Z"})},siliconflow:{viewBox:"0 0 53.021 25.354",path:s.jsx("path",{d:"M50.7172 0H27.6622C26.3877 0 25.3586 1.03397 25.3586 2.30358V9.21911C25.3586 10.4935 24.3294 11.5227 23.055 11.5227H2.30357C1.02914 11.5227 0 12.5567 0 13.8263V23.0502C0 24.3246 1.03395 25.3538 2.30357 25.3538H25.3586C26.633 25.3538 27.6622 24.3198 27.6622 23.0502V16.1347C27.6622 14.8602 28.6913 13.8311 29.9657 13.8311H50.7172C51.9916 13.8311 53.0207 12.7971 53.0207 11.5275V2.30358C53.0207 1.02916 51.9868 0 50.7172 0Z"})},"qwen-token-plan":n1,"qwen-pay-as-you-go":n1,fireworks:{viewBox:"0 0 638 315",path:s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M318.563 221.755C300.863 221.755 284.979 211.247 278.206 194.978L196.549 0H244.342L318.842 178.361L393.273 0H441.066L358.92 195.048C352.112 211.247 336.263 221.755 318.563 221.755Z"}),s.jsx("path",{d:"M425.111 314.933C407.481 314.933 391.667 304.494 384.824 288.366C377.947 272.097 381.507 253.524 393.936 240.921L542.657 90.2803L561.229 134.094L425.076 271.748L619.147 270.666L637.72 314.479L425.146 315.003L425.076 314.933H425.111Z"}),s.jsx("path",{d:"M0 314.408L18.5727 270.595L212.643 271.677L76.525 133.988L95.0977 90.1748L243.819 240.816C256.247 253.384 259.843 272.026 252.93 288.26C246.088 304.424 230.203 314.827 212.643 314.827L0.0698221 314.339L0 314.408Z"})]})},custom:{stroke:!0,path:s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M12 2.8 20.5 7.4v9.2L12 21.2 3.5 16.6V7.4L12 2.8Z"}),s.jsx("path",{d:"M3.5 7.4 12 12l8.5-4.6M12 12v9.2"})]})}};function xi({provider:e,className:t}){const a=D8[e];if(!a){const l=Aw(e);return s.jsxs("svg",{viewBox:"0 0 24 24",className:t,style:{"--tile-fg":l.fg,"--tile-fg-dark":l.fgDark},"aria-hidden":!0,children:[s.jsx("rect",{x:"0",y:"0",width:"24",height:"24",rx:"5",fill:l.bg}),s.jsx("text",{x:"12",y:"12",textAnchor:"middle",dominantBaseline:"central",fontSize:"13",fontWeight:"700",className:"[fill:var(--tile-fg)] dark:[fill:var(--tile-fg-dark)]",children:Rw(e)})]})}return s.jsx("svg",{viewBox:a.viewBox??"0 0 24 24",className:t,"aria-hidden":!0,...a.stroke?{fill:"none",stroke:"currentColor",strokeWidth:1.8,strokeLinejoin:"round"}:{fill:"currentColor"},children:a.path})}var _t="https://openrouter.ai/api/v1",Ls="https://api.siliconflow.cn/v1",ci="https://token-plan.cn-beijing.maas.aliyuncs.com/compatible-mode/v1",ui="https://dashscope.aliyuncs.com/compatible-mode/v1",Qr="https://api.fireworks.ai/inference/v1",$s=[{id:"deepseek",label:"DeepSeek",envKey:"DEEPSEEK_API_KEY",envBaseUrlKey:"DEEPSEEK_BASE_URL",apiKeyUrl:"https://platform.deepseek.com/api_keys",modelsUrl:"https://api-docs.deepseek.com/quick_start/pricing"},{id:"openrouter",label:"OpenRouter",envKey:"OPENAI_API_KEY",envBaseUrlKey:"OPENAI_BASE_URL",apiKeyUrl:"https://openrouter.ai/workspaces/default/keys",modelsUrl:"https://openrouter.ai/models",gatewayBaseUrl:_t},{id:"fireworks",label:"Fireworks AI",envKey:"OPENAI_API_KEY",envBaseUrlKey:"OPENAI_BASE_URL",apiKeyUrl:"https://app.fireworks.ai/settings/users/api-keys",modelsUrl:"https://app.fireworks.ai/models",gatewayBaseUrl:Qr},{id:"siliconflow",label:"SiliconFlow",envKey:"OPENAI_API_KEY",envBaseUrlKey:"OPENAI_BASE_URL",apiKeyUrl:"https://cloud.siliconflow.cn/me/account/ak",modelsUrl:"https://cloud.siliconflow.cn/models",gatewayBaseUrl:Ls},{id:"qwen-token-plan",label:"Qwen Token Plan",envKey:"OPENAI_API_KEY",envBaseUrlKey:"OPENAI_BASE_URL",apiKeyUrl:"https://platform.qianwenai.com/pricing/token-plan",modelsUrl:"https://platform.qianwenai.com/docs/token-plan/personal/token-plan-personal-overview",gatewayBaseUrl:ci},{id:"qwen-pay-as-you-go",label:"Qwen Pay-As-You-Go",envKey:"OPENAI_API_KEY",envBaseUrlKey:"OPENAI_BASE_URL",apiKeyUrl:"https://platform.qianwenai.com/docs/api-reference/preparation/api-key",modelsUrl:"https://www.qianwenai.com/models",gatewayBaseUrl:ui},{id:"google",label:"Google Gemini",envKey:"GEMINI_API_KEY",envBaseUrlKey:"GEMINI_BASE_URL",apiKeyUrl:"https://aistudio.google.com/api-keys",modelsUrl:"https://ai.google.dev/gemini-api/docs/models"},{id:"anthropic",label:"Anthropic",envKey:"ANTHROPIC_API_KEY",envBaseUrlKey:"ANTHROPIC_BASE_URL",apiKeyUrl:"https://platform.claude.com/settings/keys",modelsUrl:"https://docs.claude.com/en/docs/about-claude/models/overview"},{id:"openai",label:"OpenAI",envKey:"OPENAI_API_KEY",envBaseUrlKey:"OPENAI_BASE_URL",apiKeyUrl:"https://platform.openai.com/api-keys",modelsUrl:"https://platform.openai.com/docs/models"},{id:"zhipu",label:"Z.AI (GLM)",envKey:"ZAI_API_KEY",envBaseUrlKey:"ZAI_BASE_URL",apiKeyUrl:"https://open.bigmodel.cn/apikey/platform",modelsUrl:"https://docs.z.ai/guides/overview/pricing"},{id:"moonshot",label:"Moonshot (Kimi)",envKey:"MOONSHOT_API_KEY",envBaseUrlKey:"MOONSHOT_BASE_URL",apiKeyUrl:"https://platform.kimi.com/console/api-keys",modelsUrl:"https://platform.kimi.com/docs/pricing"},{id:"custom",label:"Custom",envKey:"OPENAI_API_KEY",envBaseUrlKey:"OPENAI_BASE_URL"}];function dn(e,t,a){const l=o=>Math.round(o/7*1e6)/1e6;return He(l(e),l(t),l(a))}function He(e,t,a){return{unit:"usd_per_mtok",cache_read:e,cache_write:t,output:a}}var dS=[{modelId:"deepseek-v4-flash",displayName:"DeepSeek V4 Flash",provider:"deepseek",contextWindow:1e6,pricing:dn(.02,1,2),supportsVision:!1},{modelId:"deepseek-v4-pro",displayName:"DeepSeek V4 Pro",provider:"deepseek",contextWindow:1e6,pricing:dn(.025,3,6),supportsVision:!1},{modelId:"anthropic/claude-fable-5",displayName:"Claude Fable 5",provider:"openrouter",contextWindow:1e6,pricing:He(1,12.5,50),supportsVision:!0,clientType:"openai",baseUrl:_t},{modelId:"anthropic/claude-opus-5",displayName:"Claude Opus 5",provider:"openrouter",contextWindow:1e6,pricing:He(.5,6.25,25),supportsVision:!0,clientType:"openai",baseUrl:_t},{modelId:"anthropic/claude-opus-4.8",displayName:"Claude Opus 4.8",provider:"openrouter",contextWindow:1e6,pricing:He(.5,6.25,25),supportsVision:!0,clientType:"openai",baseUrl:_t},{modelId:"anthropic/claude-opus-4.7",displayName:"Claude Opus 4.7",provider:"openrouter",contextWindow:1e6,pricing:He(.5,6.25,25),supportsVision:!0,clientType:"openai",baseUrl:_t},{modelId:"anthropic/claude-sonnet-5",displayName:"Claude Sonnet 5",provider:"openrouter",contextWindow:1e6,pricing:He(.2,2.5,10),supportsVision:!0,clientType:"openai",baseUrl:_t},{modelId:"deepseek/deepseek-v4-flash-0731",displayName:"DeepSeek V4 Flash 0731",provider:"openrouter",contextWindow:1e6,pricing:He(.018,.09,.18),supportsVision:!1,clientType:"openai",baseUrl:_t},{modelId:"deepseek/deepseek-v4-flash",displayName:"DeepSeek V4 Flash",provider:"openrouter",contextWindow:1e6,pricing:He(.01764,.0882,.1764),supportsVision:!1,clientType:"openai",baseUrl:_t},{modelId:"deepseek/deepseek-v4-pro",displayName:"DeepSeek V4 Pro",provider:"openrouter",contextWindow:1e6,pricing:He(.003625,.435,.87),supportsVision:!1,clientType:"openai",baseUrl:_t},{modelId:"google/gemini-3.6-flash",displayName:"Gemini 3.6 Flash",provider:"openrouter",contextWindow:1048576,pricing:He(.15,1.5,7.5),supportsVision:!0,clientType:"openai",baseUrl:_t},{modelId:"google/gemini-3.5-flash",displayName:"Gemini 3.5 Flash",provider:"openrouter",contextWindow:1048576,pricing:He(.15,1.5,9),supportsVision:!0,clientType:"openai",baseUrl:_t},{modelId:"google/gemini-3.5-flash-lite",displayName:"Gemini 3.5 Flash-Lite",provider:"openrouter",contextWindow:1048576,pricing:He(.03,.3,2.5),supportsVision:!0,clientType:"openai",baseUrl:_t},{modelId:"inclusionai/ling-3.0-flash:free",displayName:"Ling 3.0 Flash (free)",provider:"openrouter",contextWindow:262144,pricing:He(0,0,0),supportsVision:!1,clientType:"openai",baseUrl:_t},{modelId:"minimax/minimax-m3",displayName:"MiniMax M3",provider:"openrouter",contextWindow:1048576,pricing:He(.06,.3,1.2),supportsVision:!0,clientType:"openai",baseUrl:_t},{modelId:"moonshotai/kimi-k3",displayName:"Kimi K3",provider:"openrouter",contextWindow:1e6,pricing:He(.3,3,15),supportsVision:!0,clientType:"openai",baseUrl:_t},{modelId:"moonshotai/kimi-k2.6",displayName:"Kimi K2.6",provider:"openrouter",contextWindow:262144,pricing:He(.0992,.589,2.48),supportsVision:!0,clientType:"openai",baseUrl:_t},{modelId:"nvidia/nemotron-3-ultra-550b-a55b:free",displayName:"Nemotron 3 Ultra (free)",provider:"openrouter",contextWindow:1e6,pricing:He(0,0,0),supportsVision:!1,clientType:"openai",baseUrl:_t},{modelId:"openai/gpt-5.6-luna",displayName:"GPT-5.6 Luna",provider:"openrouter",contextWindow:1e6,pricing:He(.01,.125,.6),supportsVision:!0,clientType:"openai",baseUrl:_t},{modelId:"openai/gpt-5.6-sol",displayName:"GPT-5.6 Sol",provider:"openrouter",contextWindow:1e6,pricing:He(.5,6.25,30),supportsVision:!0,clientType:"openai",baseUrl:_t},{modelId:"openai/gpt-5.6-terra",displayName:"GPT-5.6 Terra",provider:"openrouter",contextWindow:1e6,pricing:He(.1,1.25,6),supportsVision:!0,clientType:"openai",baseUrl:_t},{modelId:"openai/gpt-5.5",displayName:"GPT-5.5",provider:"openrouter",contextWindow:1e6,pricing:He(.5,5,30),supportsVision:!0,clientType:"openai",baseUrl:_t},{modelId:"openrouter/free",displayName:"Free Models Router",provider:"openrouter",contextWindow:128e3,pricing:He(0,0,0),supportsVision:!1,clientType:"openai",baseUrl:_t},{modelId:"qwen/qwen3.8-max",displayName:"Qwen 3.8 Max",provider:"openrouter",contextWindow:1e6,pricing:He(.25,2.5,6),supportsVision:!0,clientType:"openai",baseUrl:_t},{modelId:"qwen/qwen3.6-35b-a3b",displayName:"Qwen 3.6 35B A3B",provider:"openrouter",contextWindow:262144,pricing:He(.05,.14,1),supportsVision:!0,clientType:"openai",baseUrl:_t},{modelId:"stepfun/step-3.7-flash",displayName:"Step 3.7 Flash",provider:"openrouter",contextWindow:256e3,pricing:He(.04,.2,1.15),supportsVision:!0,clientType:"openai",baseUrl:_t},{modelId:"tencent/hy3",displayName:"Hy3",provider:"openrouter",contextWindow:262144,pricing:He(.033,.132,.528),supportsVision:!1,clientType:"openai",baseUrl:_t},{modelId:"thinkingmachines/inkling",displayName:"Inkling",provider:"openrouter",contextWindow:1e6,pricing:He(.17,1,4.05),supportsVision:!0,clientType:"openai",baseUrl:_t},{modelId:"x-ai/grok-4.5",displayName:"Grok 4.5",provider:"openrouter",contextWindow:5e5,pricing:He(.3,2,6),supportsVision:!0,clientType:"openai",baseUrl:_t},{modelId:"xiaomi/mimo-v2.5",displayName:"MiMo-V2.5",provider:"openrouter",contextWindow:1048576,pricing:He(.0028,.14,.28),supportsVision:!0,clientType:"openai",baseUrl:_t},{modelId:"z-ai/glm-5.2",displayName:"GLM-5.2",provider:"openrouter",contextWindow:1e6,pricing:He(.1261,.679,2.134),supportsVision:!1,clientType:"openai",baseUrl:_t},{modelId:"accounts/fireworks/models/deepseek-v4-flash-0731",displayName:"DeepSeek V4 Flash 0731",provider:"fireworks",contextWindow:1e6,pricing:He(.028,.14,.28),supportsVision:!1,clientType:"openai",baseUrl:Qr},{modelId:"accounts/fireworks/models/deepseek-v4-flash",displayName:"DeepSeek V4 Flash",provider:"fireworks",contextWindow:1e6,pricing:He(.03,.14,.28),supportsVision:!1,clientType:"openai",baseUrl:Qr},{modelId:"accounts/fireworks/models/deepseek-v4-pro",displayName:"DeepSeek V4 Pro",provider:"fireworks",contextWindow:1e6,pricing:He(.15,1.74,3.48),supportsVision:!1,clientType:"openai",baseUrl:Qr},{modelId:"accounts/fireworks/models/glm-5p2",displayName:"GLM-5.2",provider:"fireworks",contextWindow:1e6,pricing:He(.14,1.4,4.4),supportsVision:!1,clientType:"openai",baseUrl:Qr},{modelId:"accounts/fireworks/models/inkling",displayName:"Inkling",provider:"fireworks",contextWindow:1e6,pricing:He(.17,1,4.05),supportsVision:!0,clientType:"openai",baseUrl:Qr},{modelId:"accounts/fireworks/models/kimi-k3",displayName:"Kimi K3",provider:"fireworks",contextWindow:1e6,pricing:He(.3,3,15),supportsVision:!0,clientType:"openai",baseUrl:Qr},{modelId:"accounts/fireworks/models/kimi-k2p7-code",displayName:"Kimi K2.7 Code",provider:"fireworks",contextWindow:262144,pricing:He(.19,.95,4),supportsVision:!0,clientType:"openai",baseUrl:Qr},{modelId:"accounts/fireworks/models/minimax-m3",displayName:"MiniMax M3",provider:"fireworks",contextWindow:524288,pricing:He(.06,.3,1.2),supportsVision:!0,clientType:"openai",baseUrl:Qr},{modelId:"deepseek-ai/DeepSeek-V4-Flash",displayName:"DeepSeek V4 Flash",provider:"siliconflow",contextWindow:1e6,pricing:dn(.02,1,2),supportsVision:!1,clientType:"openai",baseUrl:Ls},{modelId:"deepseek-ai/DeepSeek-V4-Pro",displayName:"DeepSeek V4 Pro",provider:"siliconflow",contextWindow:1e6,pricing:dn(.1,12,24),supportsVision:!1,clientType:"openai",baseUrl:Ls},{modelId:"meituan-longcat/LongCat-2.0",displayName:"LongCat 2.0",provider:"siliconflow",contextWindow:1e6,pricing:dn(.1,5,20),supportsVision:!1,clientType:"openai",baseUrl:Ls},{modelId:"moonshotai/Kimi-K2.7-Code",displayName:"Kimi K2.7 Code",provider:"siliconflow",contextWindow:262144,pricing:dn(1.3,6.5,27),supportsVision:!0,clientType:"openai",baseUrl:Ls},{modelId:"Pro/moonshotai/Kimi-K2.6",displayName:"Kimi K2.6",provider:"siliconflow",contextWindow:262144,pricing:dn(1.1,6.5,27),supportsVision:!0,clientType:"openai",baseUrl:Ls},{modelId:"Qwen/Qwen3.6-35B-A3B",displayName:"Qwen 3.6 35B A3B",provider:"siliconflow",contextWindow:262144,pricing:dn(1.8,1.8,10.8),supportsVision:!0,clientType:"openai",baseUrl:Ls},{modelId:"zai-org/GLM-5.2",displayName:"GLM-5.2",provider:"siliconflow",contextWindow:1e6,pricing:dn(2,8,28),supportsVision:!1,clientType:"openai",baseUrl:Ls},{modelId:"deepseek-v4-flash-0731",displayName:"DeepSeek V4 Flash 0731",provider:"qwen-token-plan",contextWindow:1e6,pricing:dn(.2,1,2),supportsVision:!1,clientType:"openai",baseUrl:ci},{modelId:"deepseek-v4-pro",displayName:"DeepSeek V4 Pro",provider:"qwen-token-plan",contextWindow:1e6,pricing:dn(1,12,24),supportsVision:!1,clientType:"openai",baseUrl:ci},{modelId:"glm-5.2",displayName:"GLM-5.2",provider:"qwen-token-plan",contextWindow:1048576,pricing:dn(2,8,28),supportsVision:!1,clientType:"openai",baseUrl:ci},{modelId:"qwen3.8-max",displayName:"Qwen 3.8 Max",provider:"qwen-token-plan",contextWindow:1e6,pricing:dn(1.5,12,36),supportsVision:!0,clientType:"openai",baseUrl:ci},{modelId:"qwen3.7-plus",displayName:"Qwen 3.7 Plus",provider:"qwen-token-plan",contextWindow:1e6,pricing:dn(.4,2,8),supportsVision:!0,clientType:"openai",baseUrl:ci},{modelId:"deepseek-v4-flash-0731",displayName:"DeepSeek V4 Flash 0731",provider:"qwen-pay-as-you-go",contextWindow:1e6,pricing:dn(.2,1,2),supportsVision:!1,clientType:"openai",baseUrl:ui},{modelId:"kimi/kimi-k3",displayName:"Kimi K3",provider:"qwen-pay-as-you-go",contextWindow:1048576,pricing:dn(2,20,100),supportsVision:!0,clientType:"openai",baseUrl:ui},{modelId:"qwen3.8-max",displayName:"Qwen 3.8 Max",provider:"qwen-pay-as-you-go",contextWindow:1e6,pricing:dn(1.5,12,36),supportsVision:!0,clientType:"openai",baseUrl:ui},{modelId:"qwen3.7-plus",displayName:"Qwen 3.7 Plus",provider:"qwen-pay-as-you-go",contextWindow:1e6,pricing:dn(.4,2,8),supportsVision:!0,clientType:"openai",baseUrl:ui},{modelId:"ZHIPU/GLM-5.2",displayName:"GLM-5.2",provider:"qwen-pay-as-you-go",contextWindow:1048576,pricing:dn(2,8,28),supportsVision:!1,clientType:"openai",baseUrl:ui},{modelId:"gemini-3.6-flash",displayName:"Gemini 3.6 Flash",provider:"google",contextWindow:1048576,pricing:He(.15,1.5,7.5),supportsVision:!0},{modelId:"gemini-3.5-flash",displayName:"Gemini 3.5 Flash",provider:"google",contextWindow:1048576,pricing:He(.15,1.5,9),supportsVision:!0},{modelId:"gemini-3.5-flash-lite",displayName:"Gemini 3.5 Flash-Lite",provider:"google",contextWindow:1048576,pricing:He(.03,.3,2.5),supportsVision:!0},{modelId:"gemini-3.1-flash-lite",displayName:"Gemini 3.1 Flash-Lite",provider:"google",contextWindow:1048576,pricing:He(.025,.25,1.5),supportsVision:!0},{modelId:"gemini-3.1-pro-preview",displayName:"Gemini 3.1 Pro (Preview)",provider:"google",contextWindow:1048576,pricing:He(.2,2,12),supportsVision:!0},{modelId:"gemini-3-flash-preview",displayName:"Gemini 3 Flash (Preview)",provider:"google",contextWindow:1048576,pricing:He(.05,.5,3),supportsVision:!0},{modelId:"claude-fable-5",displayName:"Claude Fable 5",provider:"anthropic",contextWindow:1e6,pricing:He(1,12.5,50),supportsVision:!0},{modelId:"claude-opus-4-8",displayName:"Claude Opus 4.8",provider:"anthropic",contextWindow:1e6,pricing:He(.5,6.25,25),supportsVision:!0},{modelId:"claude-opus-4-7",displayName:"Claude Opus 4.7",provider:"anthropic",contextWindow:1e6,pricing:He(.5,6.25,25),supportsVision:!0},{modelId:"claude-sonnet-5",displayName:"Claude Sonnet 5",provider:"anthropic",contextWindow:1e6,pricing:He(.2,2.5,10),supportsVision:!0},{modelId:"claude-sonnet-4-6",displayName:"Claude Sonnet 4.6",provider:"anthropic",contextWindow:1e6,pricing:He(.3,3.75,15),supportsVision:!0},{modelId:"gpt-5.5",displayName:"GPT-5.5",provider:"openai",contextWindow:105e4,pricing:He(.5,5,30),supportsVision:!0},{modelId:"gpt-5.5-pro",displayName:"GPT-5.5 Pro",provider:"openai",contextWindow:105e4,pricing:He(30,30,180),supportsVision:!0},{modelId:"gpt-5.4",displayName:"GPT-5.4",provider:"openai",contextWindow:105e4,pricing:He(.25,2.5,15),supportsVision:!0},{modelId:"gpt-5.4-mini",displayName:"GPT-5.4 mini",provider:"openai",contextWindow:4e5,pricing:He(.075,.75,4.5),supportsVision:!0},{modelId:"gpt-5.4-nano",displayName:"GPT-5.4 nano",provider:"openai",contextWindow:4e5,pricing:He(.02,.2,1.25),supportsVision:!0},{modelId:"gpt-5.4-pro",displayName:"GPT-5.4 Pro",provider:"openai",contextWindow:105e4,pricing:He(30,30,180),supportsVision:!0},{modelId:"glm-5.2",displayName:"GLM-5.2",provider:"zhipu",contextWindow:1e6,pricing:He(.26,1.4,4.4),supportsVision:!1},{modelId:"glm-5.1",displayName:"GLM-5.1",provider:"zhipu",contextWindow:2e5,pricing:He(.26,1.4,4.4),supportsVision:!1},{modelId:"glm-5",displayName:"GLM-5",provider:"zhipu",contextWindow:2e5,pricing:He(.2,1,3.2),supportsVision:!1},{modelId:"kimi-k3",displayName:"Kimi K3",provider:"moonshot",contextWindow:1048576,pricing:dn(2,20,100),supportsVision:!0},{modelId:"kimi-k2.6",displayName:"Kimi K2.6",provider:"moonshot",contextWindow:262144,pricing:dn(1.1,6.5,27),supportsVision:!0},{modelId:"kimi-k2.5",displayName:"Kimi K2.5",provider:"moonshot",contextWindow:262144,pricing:dn(.7,4,21),supportsVision:!0}];function _g(e,t){return dS.find(a=>a.provider===e&&a.modelId===t)}function Os(e){return $s.find(t=>t.id===e)}function z8(e,t){const a=(t||e).toLowerCase(),l=o=>({envKey:`${o}_API_KEY`,envBaseUrlKey:`${o}_BASE_URL`});if(a.includes("gemini-3")||a.includes("gemini-embedding"))return l("GEMINI");if(a.includes("claude")&&(a.includes("4-7")||a.includes("4-8")||a.includes("-5")||a.includes("4-6")))return l("ANTHROPIC");if(a.includes("gpt-5.4")||a.includes("gpt-5.5"))return l("OPENAI");if(a.includes("glm-5"))return l("ZAI");if(a.includes("kimi-k3")||a.includes("kimi-k2.5")||a.includes("kimi-k2.6"))return l("MOONSHOT");if(a.includes("deepseek-v4"))return l("DEEPSEEK");if(a.includes("openai"))return l("OPENAI")}function U8(){return dS.map(e=>({provider:e.provider,model_id:e.modelId,...e.contextWindow!==void 0?{context_window:e.contextWindow}:{},...e.clientType!==void 0?{client_type:e.clientType}:{},...e.pricing?{pricing:{...e.pricing}}:{},...e.supportsVision?{}:{vision:!1},...e.baseUrl!==void 0?{base_url:e.baseUrl}:{}}))}function a1(e,t){if(e==="openrouter")return`https://openrouter.ai/${t}`;if(e==="qwen-token-plan")return`https://www.qianwenai.com/models/${t}`;if(e==="fireworks"){const a=/^accounts\/([^/]+)\/models\/(.+)$/.exec(t);return a?`https://app.fireworks.ai/models/${a[1]}/${a[2]}`:Os(e)?.modelsUrl}if(e==="qwen-pay-as-you-go")return`https://www.qianwenai.com/models/${encodeURIComponent(t)}`;if(e==="zhipu")return`https://docs.z.ai/guides/llm/${t}`;if(e==="moonshot"){const a=/^kimi-k(\d+)\.(\d+)$/.exec(t);return a?`https://platform.kimi.com/docs/pricing/chat-k${a[1]}${a[2]}`:Os(e)?.modelsUrl}if(e!=="custom")return Os(e)?.modelsUrl}function jt(e,t){return!!e&&!!t&&e.provider===t.provider&&e.modelId===t.modelId}function fS(e){return{id:e,label:e,envKey:"OPENAI_API_KEY",envBaseUrlKey:"OPENAI_BASE_URL"}}function mS(e,t){const a=t.trim().toLowerCase();if(!a)return!0;const l=$s.find(o=>o.id===e.provider);return e.modelId.toLowerCase().includes(a)||(e.displayName??"").toLowerCase().includes(a)||e.provider.toLowerCase().includes(a)||(l?.label??"").toLowerCase().includes(a)}function pS(e,t){const a=t.trim()!=="",l=e.filter(f=>mS(f,t)),o=$s.map(f=>({provider:f,rows:l.filter(p=>p.provider===f.id)})),u=[...new Set(l.map(f=>f.provider).filter(f=>!$s.some(p=>p.id===f)))].sort().map(f=>({provider:fS(f),rows:l.filter(p=>p.provider===f)}));return[...o,...u].filter(f=>f.rows.length>0||!a&&f.provider.id==="custom")}function $8(e){return pS(e,"").flatMap(t=>t.rows)}function Sh(e){return!!e.credential?.apiKeyMasked}function hS(e){return e?[e.cacheRead,e.cacheWrite,e.output].every(t=>typeof t=="string"?t.trim()!==""&&Number(t)===0:t===0):!1}function r1(e,{showAll:t,query:a,selected:l,defaultModel:o}){const c=$8(e);return(t||!c.some(Sh)?c:c.filter(f=>Sh(f)||jt(f,l)||jt(f,o))).filter(f=>mS(f,a))}function Ig({open:e,setOpen:t,leading:a,label:l,labelClassName:o="",muted:c=!1,title:u,ariaLabel:f,ariaHaspopup:p="listbox",disabled:h=!1,menuClass:g,children:v}){return s.jsx(ga,{open:e,setOpen:t,menuClass:g,portal:{direction:"down",align:"left"},button:s.jsxs("button",{type:"button",title:u,"aria-label":f,"aria-haspopup":p,"aria-expanded":e,disabled:h,onClick:()=>t(!e),className:`flex w-full items-center gap-2 text-left ${Rd} ${_d.sm} disabled:cursor-not-allowed disabled:opacity-60`,children:[a,s.jsx("span",{className:`min-w-0 flex-1 truncate ${c?"text-gray-400":""} ${o}`,children:l}),s.jsx(Ad,{className:"text-gray-400"})]}),children:v})}function Fo(e){return e.displayName??e.modelId}const P8="M21 2l-2 2m-7.61 7.61a5.5 5.5 0 1 1-7.778 7.778 5.5 5.5 0 0 1 7.777-7.777zm0 0L15.5 7.5m0 0l3 3L22 7l-3-3m-3.5 3.5L19 4M2 2l20 20";function Lg({items:e,itemKey:t,isCurrent:a,query:l,onQueryChange:o,searchPlaceholder:c,emptyText:u,onPick:f,renderRow:p,footer:h}){const[g,v]=y.useState(-1),k=g>=0&&g<e.length?t(e[g]):null,w=j=>{if(e.length!==0){if(j.key==="ArrowDown"){j.preventDefault(),v(E=>(E+1)%e.length);return}if(j.key==="ArrowUp"){j.preventDefault(),v(E=>E<=0?e.length-1:E-1);return}(j.key==="Enter"&&!j.shiftKey||j.key==="Tab")&&!j.nativeEvent.isComposing&&(j.preventDefault(),f(e[g>=0?g:0]))}};return s.jsxs("div",{className:"contents",onKeyDown:w,children:[s.jsx("div",{className:"border-b border-gray-100 px-2 pb-1.5 pt-0.5 dark:border-gray-800",children:s.jsx("input",{autoFocus:!0,value:l,onChange:j=>{o(j.target.value),v(-1)},placeholder:c,"aria-label":c,...Ld,className:"w-full rounded border border-transparent bg-transparent px-1 py-0.5 text-xs text-gray-700 placeholder:text-gray-400 focus:outline-none dark:text-gray-200 dark:placeholder:text-gray-500"})}),s.jsxs("div",{className:"max-h-56 overflow-y-auto",children:[e.length===0&&s.jsx("p",{className:"px-3 py-1.5 text-xs text-gray-400",children:u}),e.map(j=>{const E=t(j),C=a?.(j)??!1;return s.jsxs("button",{type:"button",ref:E===k?M=>M?.scrollIntoView({block:"nearest"}):void 0,onClick:()=>f(j),className:`flex w-full items-center gap-2 px-3 py-1.5 text-left text-xs transition-colors duration-150 hover:bg-gray-100 dark:hover:bg-gray-800 ${C?"font-medium text-gray-900 dark:text-gray-100":"text-gray-600 dark:text-gray-400"}${E===k?" bg-gray-100 dark:bg-gray-800":""}`,children:[p(j),s.jsx("span",{className:"w-3 shrink-0 text-center text-xs",children:C?"✓":""})]},E)})]}),h]})}function gS({models:e,value:t,defaultModel:a,onPick:l}){const[o,c]=y.useState(""),[u,f]=y.useState(!1),p=r1(e,{showAll:u,query:o,selected:t,defaultModel:a}),h=u?0:r1(e,{showAll:!0,query:o,selected:t,defaultModel:a}).length-p.length;return s.jsx(Lg,{items:p,itemKey:g=>`${g.provider}:${g.modelId}`,isCurrent:g=>jt(g,t),query:o,onQueryChange:c,searchPlaceholder:m.models.searchPlaceholder,emptyText:m.models.noSearchResults,onPick:l,renderRow:g=>s.jsxs(s.Fragment,{children:[s.jsx(xi,{provider:g.provider,className:"h-4 w-4 shrink-0"}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:Fo(g)}),hS(g.pricing)&&s.jsx("span",{className:"shrink-0",children:s.jsx(gn,{tone:"yellow",children:m.models.freeBadge})}),!Sh(g)&&s.jsx("span",{role:"img",title:m.models.noKey,"aria-label":m.models.noKey,className:"shrink-0 text-gray-400 dark:text-gray-500",children:s.jsx(qe,{d:P8,size:13})}),jt(g,a)&&s.jsx("span",{className:"shrink-0 text-xs text-gray-400 dark:text-gray-500",children:m.models.default})]}),...h>0?{footer:s.jsx("div",{className:"border-t border-gray-100 dark:border-gray-800",children:s.jsx("button",{type:"button",onClick:()=>f(!0),className:"flex w-full items-center gap-2 px-3 py-1.5 text-left text-xs text-gray-400 transition-colors duration-150 hover:bg-gray-100 hover:text-gray-600 dark:text-gray-500 dark:hover:bg-gray-800 dark:hover:text-gray-300",children:m.models.showModelsWithoutKey(h)})})}:{}})}function Og({models:e,value:t,defaultModel:a,onChange:l,disabled:o,variant:c="pill"}){const[u,f]=y.useState(!1),p=e.find(k=>jt(k,t)),h=p?Fo(p):t?.modelId??"…",g=s.jsx(xi,{provider:p?.provider??t?.provider??"custom",className:"h-4 w-4 shrink-0"}),v=s.jsx(gS,{models:e,value:t,...a!==void 0?{defaultModel:a}:{},onPick:k=>{l({provider:k.provider,modelId:k.modelId}),f(!1)}});return c==="form"?s.jsx(Ig,{open:u,setOpen:f,leading:g,label:h,title:`${m.chat.chooseModel}:${h}`,ariaLabel:m.chat.chooseModel,ariaHaspopup:"listbox",disabled:o||e.length===0,menuClass:"w-max min-w-56 origin-top-left",children:v}):s.jsx(ga,{open:u,setOpen:f,menuClass:"w-max min-w-56 origin-top-right",portal:{direction:"down",align:"right"},button:s.jsxs("button",{type:"button",title:`${m.chat.chooseModel}:${h}`,"aria-label":m.chat.chooseModel,disabled:o||e.length===0,onClick:()=>f(!u),className:"flex h-8 max-w-44 shrink-0 items-center gap-1.5 rounded-md px-2 text-xs text-gray-500 transition-colors duration-150 hover:bg-gray-100 hover:text-gray-800 disabled:cursor-not-allowed disabled:opacity-50 dark:text-gray-400 dark:hover:bg-gray-800 dark:hover:text-gray-200",children:[g,s.jsx("span",{className:"hidden min-w-0 truncate @md:block",children:h}),s.jsx("svg",{width:"10",height:"10",viewBox:"0 0 12 12",fill:"none",stroke:"currentColor",className:"shrink-0","aria-hidden":!0,children:s.jsx("path",{d:"M3 4.5l3 3 3-3",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})]}),children:v})}const B8=/^[\w-]*$/;function s1(e,t){const a=e.slice(0,t),l=a.lastIndexOf("/");if(l<0||l>0&&!/\s/.test(a[l-1]))return null;const o=a.slice(l+1);if(!B8.test(o))return null;const c=/^[\w-]*/.exec(e.slice(t))[0];return{start:l,end:t+c.length,query:o}}function H8(e,t){const a=e.slice(0,t.start),l=e.slice(t.end),o=a.endsWith(" ")&&l.startsWith(" ")?a+l.slice(1):a+l;return/^\s*$/.test(o)?"":o}const F8=["none","low","medium","high","xhigh"],xS=["low","medium","high","xhigh"];function q8(e,t){return e||(t??"medium")}function V8(e,t){return t&&F8.includes(t)?e[t]??t:null}function G8(e,t,a){const l=e.filter(([o])=>o!=="").map(([o,c])=>({value:o,triggerLabel:o,label:o,description:c}));return a==="none"&&l.push({value:"none",triggerLabel:"none",label:"none",description:t}),l}function yS(e){if(Uw(e)||Pw(e))return null;const t=Bw(e),a=t?t.rest:e,l=$w(a),o=l?l.rest:a,c=Dw(o),{text:u}=cd(c?c.rest:o);return{body:u.trim(),...t?{goalRound:t.round}:{},scheduled:l!==null}}function W8(e){const t=[],a=l=>{l!==""&&t[t.length-1]!==l&&t.push(l)};for(const l of e)if(l.kind==="user_text"){const o=yS(l.text);if(!o||o.scheduled||o.goalRound!==void 0&&o.goalRound>1)continue;a(o.body)}else l.kind==="user_steering"&&a(cd(l.text).text.trim());return t}function K8(e,t,a){if(e.length===0)return null;if(t===null){if(a.trim()!=="")return null;const c=e.length-1,u=e[c];return{nav:{index:c,stash:a,recalled:u},text:u}}if(a!==t.recalled)return null;if(t.index===0)return{nav:t,text:t.recalled};const l=t.index-1,o=e[l];return{nav:{...t,index:l,recalled:o},text:o}}function Y8(e,t,a){if(t===null||a!==t.recalled)return null;if(t.index>=e.length-1)return{nav:null,text:t.stash};const l=t.index+1,o=e[l];return{nav:{...t,index:l,recalled:o},text:o}}function Q8(e,t){return!e.slice(0,t).includes(`
169
- `)}function X8(e,t){return!e.slice(t).includes(`
170
- `)}function Z8(e){if(e.sending)return"disabled";const t=!e.goalOn&&!e.modelAuthDead;return t&&e.canSteerChannel&&!e.hasHandoffTarget&&!e.hasPendingModel&&(e.hasText||e.hasImages||e.hasFiles)&&!e.followUpMode?"steer":t&&e.canQueueChannel&&e.stagedRoute!=="blocked"&&e.hasContent?"queue":"stop"}const J8=["always-ask","read-only","allow-all","deny-all"],l1={"allow-all":"M10.29 3.86 1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0zM12 9v4m0 4h.01","deny-all":"M12 21a9 9 0 1 0 0-18 9 9 0 0 0 0 18zM5.64 5.64l12.72 12.72","read-only":"M2 12s3.5-7 10-7 10 7 10 7-3.5 7-10 7-10-7-10-7zM15 12a3 3 0 1 1-6 0 3 3 0 0 1 6 0z","always-ask":"M12 21a9 9 0 1 0 0-18 9 9 0 0 0 0 18zM9.1 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3m.07 4h.01"};function eL({value:e,onChange:t,disabled:a,direction:l="up"}){const[o,c]=y.useState(!1);return s.jsx(ga,{open:o,setOpen:c,menuClass:"w-max",portal:{direction:l,align:"left"},button:s.jsxs("button",{type:"button","aria-label":m.chat.approvalMode,title:`${m.chat.approvalMode}:${m.chat.approvalModeNames[e]??e}`,disabled:a,onClick:()=>c(u=>!u),className:"flex h-8 max-w-44 shrink-0 items-center gap-1.5 rounded-md px-2 text-xs text-gray-500 transition-colors duration-150 hover:bg-gray-100 hover:text-gray-800 disabled:cursor-not-allowed disabled:opacity-50 dark:text-gray-400 dark:hover:bg-gray-800 dark:hover:text-gray-200",children:[s.jsx("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,className:"shrink-0",children:s.jsx("path",{d:l1[e]})}),s.jsx("span",{className:"hidden min-w-0 truncate @md:block",children:m.chat.approvalModeNames[e]??e}),s.jsx("svg",{width:"10",height:"10",viewBox:"0 0 12 12",fill:"none",stroke:"currentColor",className:"shrink-0","aria-hidden":!0,children:s.jsx("path",{d:"M3 4.5l3 3 3-3",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})]}),children:J8.map(u=>s.jsxs("button",{type:"button",onClick:()=>{t(u),c(!1)},className:`flex w-full items-center gap-2 px-3 py-1.5 text-left text-xs transition-colors duration-150 hover:bg-gray-100 dark:hover:bg-gray-800 ${u===e?"font-medium text-gray-900 dark:text-gray-100":"text-gray-600 dark:text-gray-400"}`,children:[s.jsx("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,className:"shrink-0 text-gray-400 dark:text-gray-500",children:s.jsx("path",{d:l1[u]})}),s.jsx("span",{className:"min-w-0 flex-1 truncate whitespace-nowrap",children:m.chat.approvalModes[u]??u}),s.jsx("span",{className:"w-3 shrink-0 text-center",children:u===e?"✓":""})]},u))})}function tL({agents:e,currentAgentId:t,onPick:a}){const[l,o]=y.useState("");return s.jsx(Lg,{items:x8(e,l),itemKey:c=>c.agentId,isCurrent:c=>c.agentId===t,query:l,onQueryChange:o,searchPlaceholder:m.chat.agentSearchPlaceholder,emptyText:m.chat.agentsNoMatch,onPick:a,renderRow:c=>s.jsxs(s.Fragment,{children:[s.jsx(xa,{id:c.agentId,name:tn(c),size:16,className:"shrink-0 rounded"}),s.jsx("span",{className:"shrink-0 font-mono text-gray-800 dark:text-gray-200",children:c.agentId}),c.name&&c.name!==c.agentId&&s.jsx("span",{className:"min-w-0 flex-1 truncate text-gray-400 dark:text-gray-500",children:c.name})]})})}function i1({panelRef:e,maxHeight:t,title:a,children:l}){return s.jsxs("div",{ref:e,style:{maxHeight:t},className:"anim-pop absolute bottom-full left-0 z-40 mb-1.5 flex w-80 max-w-[calc(100vw-2rem)] flex-col overflow-hidden rounded-md border border-gray-200 bg-white py-1 shadow-lg dark:border-gray-700 dark:bg-gray-900",children:[s.jsx("div",{className:"border-b border-gray-100 px-3 pb-1.5 pt-0.5 text-xs font-semibold text-gray-500 dark:border-gray-800 dark:text-gray-400",children:a}),l]})}const nL="M12 3l1.9 5.1L19 10l-5.1 1.9L12 17l-1.9-5.1L5 10l5.1-1.9L12 3z";function o1({value:e,onChange:t,disabled:a,direction:l="down"}){const[o,c]=y.useState(!1),u=e===null?"…":V8(m.chat.thinkingLevelNames,e)??"—";return s.jsxs(ga,{open:o,setOpen:c,menuClass:"w-max min-w-36",portal:{direction:l,align:"right"},button:s.jsxs("button",{type:"button",title:`${m.chat.thinkingLevel}:${u}`,"aria-label":m.chat.thinkingLevel,disabled:a||e===null,onClick:()=>c(!o),className:"flex h-8 max-w-36 shrink-0 items-center gap-1.5 rounded-md px-2 text-xs text-gray-500 transition-colors duration-150 hover:bg-gray-100 hover:text-gray-800 disabled:cursor-not-allowed disabled:opacity-50 dark:text-gray-400 dark:hover:bg-gray-800 dark:hover:text-gray-200",children:[s.jsx(qe,{d:nL,size:14,className:"shrink-0"}),s.jsx("span",{className:"hidden min-w-0 truncate @md:block",children:u}),s.jsx("svg",{width:"10",height:"10",viewBox:"0 0 12 12",fill:"none",stroke:"currentColor",className:"shrink-0","aria-hidden":!0,children:s.jsx("path",{d:"M3 4.5l3 3 3-3",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})]}),children:[s.jsx("div",{className:"border-b border-gray-100 px-3 pb-1.5 pt-0.5 text-xs font-semibold text-gray-500 dark:border-gray-800 dark:text-gray-400",children:m.chat.thinkingLevel}),xS.map(f=>s.jsxs("button",{type:"button",onClick:()=>{t(f),c(!1)},className:`flex w-full items-center gap-2 px-3 py-1.5 text-left text-xs transition-colors duration-150 hover:bg-gray-100 dark:hover:bg-gray-800 ${f===e?"font-medium text-gray-900 dark:text-gray-100":"text-gray-600 dark:text-gray-400"}`,children:[s.jsx("span",{className:"min-w-0 flex-1 truncate",children:m.chat.thinkingLevelNames[f]??f}),s.jsx("span",{className:"w-3 shrink-0 text-center",children:f===e?"✓":""})]},f))]})}const vS="penguin.steerMode";function aL(){return localStorage.getItem(vS)==="followup"?"followup":"steer"}const rL="M4 21v-7M4 10V3M12 21v-9M12 8V3M20 21v-5M20 12V3M1 14h6M9 8h6M17 16h6";function sL({steerMode:e,onChangeSteerMode:t}){const a=(l,o,c)=>s.jsx("button",{type:"button",title:c,"aria-pressed":e===l,onClick:()=>t(l),className:`h-5 rounded px-1.5 text-xs transition-colors duration-150 ${e===l?"bg-gray-200 font-medium text-gray-800 dark:bg-gray-700 dark:text-gray-100":"text-gray-500 hover:text-gray-800 dark:text-gray-400 dark:hover:text-gray-200"}`,children:o});return s.jsxs("div",{className:"flex w-full items-center gap-2 px-3 py-1 text-xs",children:[s.jsx(qe,{d:rL,size:14,className:"shrink-0 text-gray-400 dark:text-gray-500"}),s.jsx("span",{className:"min-w-0 flex-1 truncate text-gray-600 dark:text-gray-400",children:m.chat.steerModeLabel}),s.jsxs("div",{role:"group","aria-label":m.chat.steerModeLabel,className:"flex shrink-0 items-center gap-0.5",children:[a("steer",m.chat.steerModeSteer,m.chat.steerModeSteerHint),a("followup",m.chat.steerModeFollowUp,m.chat.steerModeFollowUpHint)]})]})}function lL({skills:e,selected:t,onToggle:a,disabled:l,direction:o="up"}){const{locale:c}=La(),[u,f]=y.useState(!1),[p,h]=y.useState(""),g=m8(e,c,p);return s.jsxs(ga,{open:u,setOpen:f,menuClass:"w-[26rem]",portal:{direction:o,align:"left"},button:s.jsxs("button",{type:"button","aria-label":m.chat.skillsSelect,title:m.chat.skillsSelect,disabled:l,onClick:()=>{const v=!u;f(v),v&&h("")},className:"flex h-8 max-w-44 shrink-0 items-center gap-1.5 rounded-md px-2 text-xs text-gray-500 transition-colors duration-150 hover:bg-gray-100 hover:text-gray-800 disabled:cursor-not-allowed disabled:opacity-50 dark:text-gray-400 dark:hover:bg-gray-800 dark:hover:text-gray-200",children:[s.jsx(qe,{d:Rg,size:14,className:"shrink-0"}),s.jsx("span",{className:"hidden min-w-0 truncate @md:block",children:m.chat.skillsSelect}),t.length>0&&s.jsx("span",{className:"shrink-0 rounded-full bg-gray-200/80 px-1.5 py-px font-mono text-[10px] font-semibold text-gray-700 dark:bg-gray-700/60 dark:text-gray-200",children:t.length}),s.jsx("svg",{width:"10",height:"10",viewBox:"0 0 12 12",fill:"none",stroke:"currentColor",className:"shrink-0","aria-hidden":!0,children:s.jsx("path",{d:"M3 4.5l3 3 3-3",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})]}),children:[s.jsx("div",{className:"border-b border-gray-100 px-2 pb-1.5 pt-0.5 dark:border-gray-800",children:s.jsx("input",{autoFocus:!0,value:p,onChange:v=>h(v.target.value),placeholder:m.chat.skillsSearchPlaceholder,"aria-label":m.chat.skillsSearchPlaceholder,...Ld,className:"w-full rounded border border-transparent bg-transparent px-1 py-0.5 text-xs text-gray-700 placeholder:text-gray-400 focus:outline-none dark:text-gray-200 dark:placeholder:text-gray-500"})}),s.jsx("div",{className:"max-h-56 overflow-y-auto",children:e.length===0?s.jsx("p",{className:"px-3 py-1.5 text-xs text-gray-400",children:m.chat.skillsEmptyHint}):g.length===0?s.jsx("p",{className:"px-3 py-1.5 text-xs text-gray-400",children:m.chat.skillsNoMatch}):g.map(v=>{const k=t.includes(v.name);return s.jsxs("button",{type:"button","aria-pressed":k,onClick:()=>a(v.name),className:`flex w-full items-center gap-2 px-3 py-1.5 text-left text-xs transition-colors duration-150 hover:bg-gray-100 dark:hover:bg-gray-800 ${k?"font-medium text-gray-900 dark:text-gray-100":"text-gray-600 dark:text-gray-400"}`,children:[s.jsx(Bd,{icon:v.icon,size:14,className:"shrink-0 text-gray-400 dark:text-gray-500"}),s.jsx("span",{className:"shrink-0 font-mono",children:v.name}),s.jsx("span",{className:"min-w-0 flex-1 truncate text-gray-400 dark:text-gray-500",children:ji(c,v)}),s.jsx("span",{className:"w-3 shrink-0 text-center",children:k?"✓":""})]},v.name)})})]})}const iL="M6 5h12a3 3 0 0 1 3 3v8a3 3 0 0 1-3 3H6a3 3 0 0 1-3-3V8a3 3 0 0 1 3-3zM3 15l5-5 4 4 3-3 6 6";function oL({items:e,footer:t,direction:a="up"}){const[l,o]=y.useState(!1);return s.jsxs(ga,{open:l,setOpen:o,menuClass:"w-72",portal:{direction:a,align:"left"},button:s.jsx("button",{type:"button","aria-label":m.chat.plusMenu,title:m.chat.plusMenu,onClick:()=>o(!l),className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-md text-gray-500 transition-colors duration-150 hover:bg-gray-100 hover:text-gray-800 dark:text-gray-400 dark:hover:bg-gray-800 dark:hover:text-gray-200",children:s.jsx(qe,{d:"M12 5v14M5 12h14",size:15,className:"shrink-0"})}),children:[e.map(c=>s.jsxs("button",{type:"button","aria-pressed":c.active,disabled:c.disabled,onClick:()=>{o(!1),c.onSelect()},className:`flex w-full items-center gap-2 px-3 py-1.5 text-left text-xs transition-colors duration-150 hover:bg-gray-100 disabled:cursor-not-allowed disabled:opacity-50 disabled:hover:bg-transparent dark:hover:bg-gray-800 dark:disabled:hover:bg-transparent ${c.active?"font-medium text-gray-900 dark:text-gray-100":"text-gray-600 dark:text-gray-400"}`,children:[s.jsx(qe,{d:c.icon,size:14,className:"shrink-0 text-gray-400 dark:text-gray-500"}),s.jsx("span",{className:"shrink-0",children:c.label}),s.jsx("span",{className:"min-w-0 flex-1 truncate text-gray-400 dark:text-gray-500",children:c.desc}),s.jsx("span",{className:"w-3 shrink-0 text-center",children:c.active?"✓":""})]},c.key)),t&&s.jsx("div",{className:"mt-1 border-t border-gray-100 pt-1 dark:border-gray-800",children:t})]})}function cL({now:e,window:t,unknown:a=!1}){const l=cS(t),o=a?0:Math.min(1,e/l),c=a||o<=.8?"text-gray-400 dark:text-gray-500":o>.95?"text-red-500":"text-amber-500",u=5,f=2*Math.PI*u;return s.jsxs("span",{title:a?m.chat.contextUnknown:`${m.chat.contextUsage} ${Math.round(o*100)}%`,className:`flex shrink-0 items-center gap-1 font-mono ${c}`,children:[s.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 14 14","aria-hidden":!0,className:"block shrink-0",children:[s.jsx("circle",{cx:"7",cy:"7",r:u,fill:"none",stroke:"currentColor",strokeOpacity:"0.25",strokeWidth:"2"}),s.jsx("circle",{cx:"7",cy:"7",r:u,fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeDasharray:`${f*o} ${f}`,transform:"rotate(-90 7 7)"})]}),s.jsxs("span",{className:"hidden @md:inline",children:[a?"—":Ct(e),"/",Ct(l)]})]})}const uL=10*1024*1024;function dL(e){return new Promise(t=>{const a=new FileReader;a.onload=()=>t(typeof a.result=="string"?a.result:null),a.onerror=()=>t(null),a.readAsDataURL(e)})}function fL(e){const t=[],a=e.text.replace(/\s+/g," ").trim();return a&&t.push(a),e.images>0&&t.push(m.chat.imagesInMessage(e.images)),e.files>0&&t.push(m.chat.filesInMessage(e.files)),t.join(" · ")}function mL(e,t,a){for(const l of t)e.push({type:"image_url",imageUrl:l});for(const l of a)e.push({type:"file",fileName:l.name,dataUrl:l.dataUrl})}function bS({status:e,onSend:t,onSteer:a,steeringDeliveredCount:l,pendingSteering:o=[],onQueueFollowUp:c,queuedFollowUps:u=0,onStop:f,onCompact:p,modelRef:h,models:g,onChangeModel:v,onSwitchModel:k,defaultModel:w,thinkingLevel:j,onChangeThinkingLevel:E,turnThinkingLevel:C,onChangeTurnThinkingLevel:M,contextWindow:_,contextNow:D,contextStale:V=!1,vision:F,approvalMode:A,onChangeApprovalMode:P,modeSaving:Q,autoFocus:K,agents:O,currentAgentId:z,skills:I,initialSkills:B,onSkillsChange:$,onHandoff:G,initialText:q,onTextChange:ae,history:Z=[],initialHandoffTargetId:X,onHandoffTargetChange:T,initialPendingModelRef:R,onPendingModelChange:H,modelAuthDead:S=!1,onOpenModels:U,onRetryModelAuth:ee,onNewSession:ie}){const{locale:de}=La(),[me,ye]=y.useState(q??""),te=y.useRef(me);te.current=me;const[be,Re]=y.useState([]),[Fe,ce]=y.useState([]),[Ve,je]=y.useState(!1),[wt,an]=y.useState(0),[rn,sn]=y.useState(null),[Ut,At]=y.useState(!1),fn=y.useRef(null),[st,nn]=y.useState(!1),pe=y.useRef(null),Se=y.useRef(null),[De,ze]=y.useState(),[Ue,W]=y.useState(null),[ge,Ne]=y.useState(null),[Te,Pe]=y.useState(B??[]),[We,tt]=y.useState(0),it=y.useRef(null),Ce=y.useRef(null),[Oe]=y.useState(()=>window.matchMedia("(max-width: 767px)").matches),Ke=e==="running",vt=e==="compacting",xt=me.trim().length>0||be.length>0||Fe.length>0||Ue!==null||ge!==null||Te.length>0,[St,ln]=y.useState(!1),[$t,Oa]=y.useState(""),[aa,En]=y.useState(!1),[An,ar]=y.useState(""),Yn=St?Lu($t):null,Pn=Lu(An)===null,ba=Yn!==null&&Yn!==Ag?m.chat.goalBudgetValue(Ct(Yn)):m.chat.goalBudgetUnlimited,Da=y8({handoffTarget:Ue!==null,pendingModel:ge!==null,canSwitchModel:k!==void 0,sessionBusy:Ke||vt}),gr=!Ke&&!vt&&!Ve&&!S&&(St?me.trim().length>0&&Fe.length===0&&Yn!==null&&!(aa&&Pn):xt),Bn=y.useCallback(le=>{if(le){ar($t),En(!0);return}Lu(An)!==null&&(Oa(An.trim()),En(!1))},[$t,An]),qt=y.useCallback(()=>{En(!1),it.current?.focus()},[]),Zt=y.useCallback(()=>{Lu(An)!==null&&(Oa(An.trim()),En(!1),it.current?.focus())},[An]),Hn=y.useCallback(le=>{ln(le),En(!1),ar(""),le&&(Oa(""),W(null),T?.(null),Ne(null),H?.(null),ce([]))},[T,H]),[on,Rr]=y.useState(aL),xr=le=>{Rr(le),localStorage.setItem(vS,le)},rr=on==="followup"&&c!==void 0,Qn=Z8({sending:Ve,goalOn:St,modelAuthDead:S,canSteerChannel:a!==void 0,canQueueChannel:c!==void 0,followUpMode:rr,stagedRoute:Da,hasHandoffTarget:Ue!==null,hasPendingModel:ge!==null,hasText:me.trim().length>0,hasImages:be.length>0,hasFiles:Fe.length>0,hasContent:xt}),sr=Ke&&Qn==="steer",ka=Ke&&Qn==="queue",ra=sr||ka,za=Qn==="queue"?m.chat.followUpSend:m.chat.steerSend,yn=Ke&&Qn==="stop",[he,Le]=y.useState(!1),ot=y.useRef(0);y.useEffect(()=>{he&&(!Ke||(l??0)>ot.current)&&Le(!1)},[he,Ke,l]);const rt=y.useCallback(le=>{const Ae=Te.includes(le)?Te.filter(Ze=>Ze!==le):[...Te,le];Pe(Ae),$?.(Ae)},[Te,$]),Rt=y.useRef(null),Vt=y.useMemo(()=>{const le=()=>{const Ae=Rt.current,Ze=Ae?H8(te.current,Ae):"";ye(Ze),ae?.(Ze)};return[{cmd:"/compact",desc:m.chat.compact,run:()=>{le(),p()}},{cmd:"/goal",desc:m.chat.goalModeDesc,run:()=>{le(),Hn(!St)}},...k&&g&&g.length>0?[{cmd:"/model",desc:m.chat.switchModel,run:()=>{le(),At(!0)}}]:[],...G&&O.length>0?[{cmd:"/agent",desc:m.chat.switchAgent,run:()=>{le(),nn(!0)}}]:[],...p8(I,de).map(Ae=>({cmd:Ae.cmd,desc:Ae.desc,run:()=>{le(),rt(Ae.name)}}))]},[p,k,g,O,ae,I,de,rt,Hn,St]),vn=!Ke&&!vt&&!Ut&&!st?s1(me,We):null;Rt.current=vn;const sa=vn&&vn.start!==rn?Vt.filter(le=>le.cmd.startsWith(`/${vn.query}`)):[],Fn=sa.length>0,Xn=sa[Math.min(wt,sa.length-1)];y.useEffect(()=>{if(!Ut&&!st)return;const le=()=>{At(!1),nn(!1),it.current?.focus()},Ae=bt=>{const pt=Ut?fn.current:pe.current;pt&&!pt.contains(bt.target)&&le()},Ze=bt=>{bt.key==="Escape"&&!bt.isComposing&&le()};return window.addEventListener("mousedown",Ae),window.addEventListener("keydown",Ze),()=>{window.removeEventListener("mousedown",Ae),window.removeEventListener("keydown",Ze)}},[Ut,st]);const _n=le=>{Ne(le),H?.(le?{provider:le.provider,modelId:le.modelId}:null)},wa=le=>{if(At(!1),it.current?.focus(),jt(le,h)){_n(null);return}_n(le),W(null),T?.(null),ln(!1)},qn=le=>{nn(!1),W(le),T?.(le.agentId),_n(null),ln(!1),it.current?.focus()},Ml=()=>{Ue!==null&&(W(null),T?.(null)),_n(null)};y.useEffect(()=>{if(!Fn&&!Ut&&!st)return;const le=()=>{const Ae=Se.current;if(!Ae)return;let Ze=0;for(let pt=Ae.parentElement;pt;pt=pt.parentElement)if(getComputedStyle(pt).overflowY!=="visible"){Ze=pt.getBoundingClientRect().top;break}const bt=Ae.getBoundingClientRect().top-Ze-14;ze(Math.max(96,Math.min(320,Math.round(bt))))};return le(),window.addEventListener("resize",le),()=>window.removeEventListener("resize",le)},[Fn,Ut,st]);const Ni=()=>{const le=it.current;le&&(le.style.height="auto",le.style.height=`${Math.min(le.scrollHeight,176)}px`)};y.useLayoutEffect(Ni,[me]),y.useEffect(()=>{const le=Ce.current;le&&me!==le.recalled&&(Ce.current=null)},[me]),y.useEffect(()=>{const le=it.current;if(le&&le.value.length>0){const Ae=le.value.length;le.setSelectionRange(Ae,Ae),le.scrollTop=le.scrollHeight,tt(Ae)}},[]);const ns=y.useRef(!1);y.useEffect(()=>{if(!ns.current&&(ns.current=!0,I.length===0))return;const le=Te.filter(Ae=>I.some(Ze=>Ze.name===Ae));le.length!==Te.length&&(Pe(le),$?.(le))},[I,Te,$]);const ue=Ue!==null||ge!==null||St,_e=y.useRef(!1);y.useEffect(()=>{if(_e.current||!X||O.length===0||(_e.current=!0,ue))return;const le=O.find(Ae=>Ae.agentId===X);le&&W(le)},[O,X,ue]);const ut=y.useRef(!1);y.useEffect(()=>{if(ut.current||!R||!g||g.length===0||(ut.current=!0,ue||!k))return;const le=g.find(Ae=>jt(Ae,R));le&&!jt(le,h)&&Ne(le)},[g,R,h,k,ue]);const Je=async(le=t)=>{const Ae=me.trim();if(St){je(!0);try{const Vs=[{type:"text",text:ah(Te,Ae)}];for(const ss of be)Vs.push({type:"image_url",imageUrl:ss});await t(Vs,{budget:Yn})&&(ye(""),Re([]),Pe([]),Hn(!1))}finally{je(!1),it.current?.focus()}return}if(Da==="blocked")return;const Ze=Da==="model"?ge:null,bt=Ae!==""?Ae:Te.length>0?m.chat.skillsAutoMessage(Te):Ze?m.chat.modelSwitchAutoMessage:Ae,pt=ah(Te,bt),$a=[];pt&&$a.push({type:"text",text:pt}),mL($a,be,Fe),je(!0);try{(Ue?await G(Ue,$a):Ze?await k({provider:Ze.provider,modelId:Ze.modelId},$a):await le($a,null))&&(ye(""),Re([]),ce([]),W(null),Ne(null),Pe([]))}finally{je(!1),it.current?.focus()}},Pt=async()=>{if(Ke){if(ka){await Je(c);return}if(!sr)return;const le=me.trim(),Ae=be,Ze=Fe.map(pt=>({fileName:pt.name,dataUrl:pt.dataUrl}));je(!0);let bt="failed";try{bt=await a(le,Ae,Ze),bt==="queued"&&(ot.current=l??0,Le(!0),ye(""),Re([]),ce([]))}finally{je(!1),it.current?.focus()}bt==="not_running"&&await Je(c??t);return}gr&&await Je()},Wt=le=>{Ce.current=le.nav,ye(le.text),ae?.(le.text),tt(le.text.length),requestAnimationFrame(()=>{const Ae=it.current;Ae&&(Ae.setSelectionRange(Ae.value.length,Ae.value.length),Ae.scrollTop=Ae.scrollHeight)})},Nn=le=>{if(Fn){if(le.key==="ArrowDown"){le.preventDefault(),an(Ae=>(Ae+1)%sa.length);return}if(le.key==="ArrowUp"){le.preventDefault(),an(Ae=>(Ae-1+sa.length)%sa.length);return}if((le.key==="Enter"&&!le.shiftKey||le.key==="Tab")&&!le.nativeEvent.isComposing){le.preventDefault(),Xn?.run();return}if(le.key==="Escape"){sn(vn?.start??null);return}}if((le.key==="ArrowUp"||le.key==="ArrowDown")&&!le.nativeEvent.isComposing){const Ae=le.currentTarget.selectionStart??0,Ze=le.currentTarget.selectionEnd??Ae,bt=le.key==="ArrowUp"?Q8(me,Ae)?K8(Z,Ce.current,me):null:X8(me,Ze)?Y8(Z,Ce.current,me):null;if(bt){le.preventDefault(),Wt(bt);return}}if(le.key==="Backspace"&&(Ue!==null||ge!==null)&&le.currentTarget.selectionStart===0&&le.currentTarget.selectionEnd===0){le.preventDefault(),Ml();return}le.key==="Enter"&&!le.shiftKey&&!le.nativeEvent.isComposing&&(le.preventDefault(),Pt())},bn=le=>{for(const Ae of le){if(!Ae.type.startsWith("image/"))continue;const Ze=new FileReader;Ze.onload=()=>{typeof Ze.result=="string"&&Re(bt=>[...bt,Ze.result])},Ze.readAsDataURL(Ae)}},as=le=>{const Ae=[];for(const Ze of le.clipboardData.items)if(Ze.kind==="file"){const bt=Ze.getAsFile();bt&&Ae.push(bt)}Ae.length>0&&(le.preventDefault(),bn(Ae))},rs=le=>{le.target.files&&bn(le.target.files),le.target.value=""},lr=le=>{if(St)return;const Ae=[];for(const Ze of le){if(Ze.size>uL){Qe(m.chat.attachmentTooLarge(Ze.name));continue}Ae.push(Ze)}Ae.length!==0&&Promise.all(Ae.map(dL)).then(Ze=>{const bt=Ae.flatMap((pt,$a)=>Ze[$a]?[{name:pt.name,size:pt.size,dataUrl:Ze[$a]}]:[]);bt.length>0&&ce(pt=>[...pt,...bt])})},Ti=le=>{le.target.files&&lr(le.target.files),le.target.value=""},qs=y.useRef(null),Ua=y.useRef(null);return s.jsxs("div",{className:"relative",ref:Se,children:[Fn&&s.jsx("div",{style:{maxHeight:De},className:"anim-pop absolute bottom-full left-0 z-40 mb-1.5 w-80 max-w-[calc(100vw-2rem)] overflow-y-auto overscroll-contain rounded-md border border-gray-200 bg-white py-1 shadow-lg dark:border-gray-700 dark:bg-gray-900",children:sa.map((le,Ae)=>s.jsxs("button",{type:"button",ref:le===Xn?Ze=>Ze?.scrollIntoView({block:"nearest"}):void 0,onMouseEnter:()=>an(Ae),onClick:()=>le.run(),className:`flex w-full items-center gap-2 px-3 py-1.5 text-left text-sm ${le===Xn?"bg-gray-100 dark:bg-gray-800":""}`,children:[s.jsx("span",{className:"shrink-0 font-mono text-gray-800 dark:text-gray-200",children:le.cmd}),s.jsx("span",{title:le.desc,className:"min-w-0 flex-1 truncate text-xs text-gray-500 dark:text-gray-400",children:le.desc})]},le.cmd))}),Ut&&g&&s.jsx(i1,{panelRef:fn,maxHeight:De,title:m.chat.switchModelTitle,children:s.jsx(gS,{models:g,value:h,...w!==void 0?{defaultModel:w}:{},onPick:wa})}),st&&s.jsx(i1,{panelRef:pe,maxHeight:De,title:m.chat.switchAgentTitle,children:s.jsx(tL,{agents:O,...z!==void 0?{currentAgentId:z}:{},onPick:qn})}),be.length>0&&s.jsx("div",{className:"mb-2 flex flex-wrap gap-2",children:be.map((le,Ae)=>s.jsxs("div",{className:"anim-pop relative",children:[s.jsx(Zr,{src:le,alt:m.chat.imageAlt,className:"h-16 w-16 rounded-md border border-gray-200 object-cover dark:border-gray-700"}),s.jsx("button",{type:"button","aria-label":m.chat.removeImage,onClick:()=>Re(Ze=>Ze.filter((bt,pt)=>pt!==Ae)),className:"absolute -right-1.5 -top-1.5 flex h-5 w-5 items-center justify-center rounded-full bg-gray-700 text-[10px] text-white transition-colors duration-150 hover:bg-gray-900",children:"×"})]},Ae))}),Fe.length>0&&s.jsx("div",{className:"mb-2 flex flex-wrap gap-2",children:Fe.map((le,Ae)=>s.jsxs("span",{title:le.name,className:"anim-pop flex max-w-56 items-center gap-1.5 rounded-md border border-gray-200 bg-gray-50 py-1 pl-2 pr-1 text-xs text-gray-700 dark:border-gray-700 dark:bg-gray-800 dark:text-gray-200",children:[s.jsx(qe,{d:wh,size:13,className:"shrink-0 text-gray-400 dark:text-gray-500"}),s.jsx("span",{className:"min-w-0 truncate",children:le.name}),s.jsx("span",{className:"shrink-0 font-mono text-[10px] text-gray-400 dark:text-gray-500",children:Xo(le.size)}),s.jsx("button",{type:"button","aria-label":`${m.chat.removeFile} ${le.name}`,onClick:()=>ce(Ze=>Ze.filter((bt,pt)=>pt!==Ae)),className:"shrink-0 rounded p-0.5 text-gray-400 transition-colors duration-150 hover:text-gray-700 dark:hover:text-gray-200",children:"×"})]},Ae))}),!F&&be.length>0&&s.jsx("p",{className:"anim-fade mb-1 text-xs text-gray-400 dark:text-gray-500",children:m.chat.imagesAsPathHint}),Da==="blocked"&&s.jsx("p",{className:"anim-fade mb-1 text-xs text-gray-400 dark:text-gray-500",children:m.chat.modelSwitchBusyHint}),o.length>0?s.jsx("div",{className:"anim-fade mb-1",children:o.map((le,Ae)=>s.jsx("p",{className:"truncate text-xs text-gray-400 dark:text-gray-500",children:m.chat.steerQueuedItem(fL(le))},Ae))}):he&&s.jsx("p",{className:"anim-fade mb-1 text-xs text-gray-400 dark:text-gray-500",children:m.chat.steerQueuedIndicator}),u>0&&s.jsx("p",{className:"anim-fade mb-1 text-xs text-gray-400 dark:text-gray-500",children:m.chat.followUpQueuedChip(u)}),S&&s.jsxs("div",{className:"anim-fade mb-1.5 flex flex-wrap items-center justify-between gap-x-3 gap-y-1.5 rounded-md border border-gray-200 bg-gray-50 px-3 py-2 text-xs text-gray-600 dark:border-gray-700 dark:bg-gray-800/60 dark:text-gray-300",children:[s.jsx("span",{className:"min-w-0 flex-1 basis-56",children:m.chat.modelAuthDead}),s.jsxs("span",{className:"flex shrink-0 flex-wrap items-center gap-1.5",children:[U&&s.jsx("button",{type:"button",onClick:U,className:"shrink-0 rounded-md bg-gray-900 px-2.5 py-1 font-medium text-white transition-colors duration-150 hover:bg-gray-700 dark:bg-gray-100 dark:text-gray-900 dark:hover:bg-gray-300",children:m.chat.modelAuthDeadOpenModels}),ee&&s.jsx("button",{type:"button",onClick:ee,className:"shrink-0 rounded-md border border-gray-300 bg-white px-2.5 py-1 font-medium text-gray-700 transition-colors duration-150 hover:bg-gray-100 dark:border-gray-600 dark:bg-gray-900 dark:text-gray-200 dark:hover:bg-gray-700",children:m.chat.modelAuthDeadRetry}),ie&&s.jsx("button",{type:"button",onClick:ie,className:"shrink-0 rounded-md border border-gray-300 bg-white px-2.5 py-1 font-medium text-gray-700 transition-colors duration-150 hover:bg-gray-100 dark:border-gray-600 dark:bg-gray-900 dark:text-gray-200 dark:hover:bg-gray-700",children:m.chat.modelAuthDeadCta})]})]}),s.jsxs("div",{className:`@container rounded-lg border border-gray-300 bg-white px-2.5 pb-2 pt-2 transition-[border-color,box-shadow] duration-200 focus-within:border-gray-500 focus-within:ring-2 focus-within:ring-gray-400/30 dark:border-gray-700 dark:bg-gray-900 dark:focus-within:border-gray-400${S?" opacity-50 grayscale":""}`,children:[(Ue!==null||ge!==null||Te.length>0||St)&&s.jsxs("div",{className:"mb-1 flex flex-wrap items-center gap-1",children:[St&&s.jsxs("span",{className:"anim-pop flex max-w-full items-center gap-1 rounded-md bg-gray-100 py-0.5 pl-2 pr-1 text-sm text-gray-800 dark:bg-gray-800 dark:text-gray-200",children:[s.jsxs("span",{className:"flex shrink-0 items-center gap-1",title:m.chat.goalModeDesc,children:[s.jsx(qe,{d:tc,size:13,className:"text-gray-500 dark:text-gray-400"}),s.jsx("span",{children:m.chat.goalMode})]}),s.jsx("span",{"aria-hidden":!0,className:"mx-0.5 h-4 w-px shrink-0 bg-gray-300 dark:bg-gray-600"}),s.jsx(ga,{open:aa,setOpen:Bn,onEscape:qt,className:"min-w-0",menuClass:"bottom-full left-1/2 -ml-32 mb-2 w-64 max-w-[calc(100vw-2rem)] origin-bottom",button:s.jsxs("button",{type:"button","aria-label":ba,"aria-expanded":aa,onClick:()=>Bn(!aa),className:"flex h-5 min-w-0 items-center gap-1 rounded px-1.5 text-xs text-gray-600 transition-colors duration-150 hover:bg-white/80 hover:text-gray-900 dark:text-gray-300 dark:hover:bg-gray-700 dark:hover:text-white",children:[s.jsx("span",{className:"truncate",children:ba}),s.jsx("svg",{width:"9",height:"9",viewBox:"0 0 12 12",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",className:"shrink-0","aria-hidden":!0,children:s.jsx("path",{d:"M3 4.5l3 3 3-3"})})]}),children:s.jsxs("div",{className:"px-3 py-2",children:[s.jsx("label",{htmlFor:"goal-budget-input",className:"block text-xs font-medium text-gray-700 dark:text-gray-200",children:m.chat.goalBudgetLabel}),s.jsxs("div",{className:"mt-1.5 flex items-center gap-1.5",children:[s.jsx("input",{id:"goal-budget-input",autoFocus:!0,value:An,onChange:le=>ar(le.target.value),onFocus:le=>le.currentTarget.select(),onKeyDown:le=>{le.key==="Enter"&&(le.preventDefault(),le.stopPropagation(),Zt())},placeholder:m.chat.goalBudgetPlaceholder,"aria-invalid":Pn,"aria-describedby":"goal-budget-hint",...Ld,title:Pn?m.chat.goalBudgetInvalid:m.chat.goalBudgetHint,className:`min-w-0 flex-1 rounded-md border bg-white px-2 py-1 font-mono text-sm leading-5 placeholder:text-gray-400 focus:outline-none focus:ring-2 dark:bg-gray-950 dark:placeholder:text-gray-500 ${Pn?"border-red-400 text-red-600 focus:border-red-500 focus:ring-red-400/20 dark:border-red-500 dark:text-red-400":"border-gray-300 text-gray-800 focus:border-gray-500 focus:ring-gray-400/20 dark:border-gray-700 dark:text-gray-100 dark:focus:border-gray-500"}`}),s.jsx("button",{type:"button","aria-label":m.chat.goalBudgetSave,title:m.chat.goalBudgetSave,disabled:Pn,onClick:Zt,className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-md bg-gray-900 text-white transition-colors duration-150 hover:bg-gray-700 disabled:cursor-not-allowed disabled:opacity-35 dark:bg-gray-100 dark:text-gray-900 dark:hover:bg-white",children:s.jsx(qe,{d:"M5 12l4 4L19 6",size:14})})]}),s.jsx("p",{id:"goal-budget-hint",className:`mt-1.5 text-[11px] leading-4 ${Pn?"text-red-500 dark:text-red-400":"text-gray-400 dark:text-gray-500"}`,children:Pn?m.chat.goalBudgetInvalid:m.chat.goalBudgetHint})]})}),s.jsx("button",{type:"button","aria-label":m.chat.goalRemove,onClick:()=>Hn(!1),className:"shrink-0 rounded p-0.5 text-gray-400 transition-colors duration-150 hover:text-gray-700 dark:hover:text-gray-200",children:"×"})]}),Ue!==null&&s.jsxs("span",{title:m.chat.handoffTargetTitle(tn(Ue)),className:"anim-pop flex max-w-48 items-center gap-1 rounded-md bg-gray-100 py-0.5 pl-2 pr-1 font-mono text-sm text-gray-800 dark:bg-gray-800 dark:text-gray-200",children:[s.jsx(xa,{id:Ue.agentId,name:tn(Ue),size:13,className:"shrink-0 rounded-sm"}),s.jsx("span",{className:"truncate",children:Ue.agentId}),s.jsx("button",{type:"button","aria-label":m.chat.handoffRemove,onClick:()=>{W(null),T?.(null),it.current?.focus()},className:"shrink-0 rounded p-0.5 text-gray-400 transition-colors duration-150 hover:text-gray-700 dark:hover:text-gray-200",children:"×"})]}),ge!==null&&s.jsxs("span",{title:m.chat.modelSwitchTargetTitle(Fo(ge)),className:"anim-pop flex max-w-48 items-center gap-1 rounded-md bg-gray-100 py-0.5 pl-2 pr-1 text-sm text-gray-800 dark:bg-gray-800 dark:text-gray-200",children:[s.jsx(xi,{provider:ge.provider,className:"h-3.5 w-3.5 shrink-0"}),s.jsx("span",{className:"truncate",children:Fo(ge)}),s.jsx("button",{type:"button","aria-label":m.chat.modelSwitchRemove,onClick:()=>{_n(null),it.current?.focus()},className:"shrink-0 rounded p-0.5 text-gray-400 transition-colors duration-150 hover:text-gray-700 dark:hover:text-gray-200",children:"×"})]}),Te.map(le=>{const Ae=I.find(Ze=>Ze.name===le);return s.jsxs("span",{className:"anim-pop flex max-w-48 items-center gap-1 rounded-md bg-gray-100 py-0.5 pl-2 pr-1 font-mono text-sm text-gray-800 dark:bg-gray-800 dark:text-gray-200",...Ae?{title:ji(de,Ae)}:{},children:[s.jsx(Bd,{icon:Ae?.icon,size:13,className:"shrink-0 text-gray-500 dark:text-gray-400"}),s.jsx("span",{className:"truncate",children:le}),s.jsx("button",{type:"button","aria-label":`${m.chat.skillRemove} ${le}`,onClick:()=>rt(le),className:"shrink-0 rounded p-0.5 text-gray-400 transition-colors duration-150 hover:text-gray-700 dark:hover:text-gray-200",children:"×"})]},le)})]}),s.jsx("textarea",{ref:it,rows:2,value:me,autoFocus:K,onChange:le=>{const Ae=le.target.value,Ze=le.target.selectionStart??Ae.length;ye(Ae),ae?.(Ae),tt(Ze),an(0),sn(bt=>{if(bt===null)return null;const pt=s1(Ae,Ze);return pt&&pt.start===bt?bt:null})},onSelect:le=>tt(le.currentTarget.selectionStart??0),onKeyDown:Nn,onPaste:as,disabled:S,placeholder:S?m.chat.modelAuthDeadPlaceholder:Ke&&rr?Oe?m.chat.followUpPlaceholderShort:m.chat.followUpPlaceholder:Ke&&a?Oe?m.chat.steerPlaceholderShort:m.chat.steerPlaceholder:Oe?m.chat.inputPlaceholderShort:m.chat.inputPlaceholder,className:"block max-h-44 min-h-[60px] w-full resize-none bg-transparent px-1 py-0.5 text-base leading-6 placeholder:text-gray-400 focus:outline-none disabled:cursor-not-allowed disabled:opacity-60 dark:placeholder:text-gray-500"}),s.jsxs("div",{className:"mt-1 flex items-center justify-between gap-2 text-xs",children:[s.jsxs("div",{className:"no-scrollbar flex min-w-0 flex-1 items-center gap-2 overflow-x-auto",children:[s.jsx("input",{ref:qs,type:"file",accept:"image/*",multiple:!0,className:"hidden",onChange:rs}),s.jsx("input",{ref:Ua,type:"file",multiple:!0,disabled:St,className:"hidden",onChange:Ti}),s.jsx(oL,{items:[{key:"image",icon:iL,label:m.chat.uploadImage,desc:F&&!St?m.chat.uploadImageDesc:m.chat.imagesAsPathHint,active:be.length>0,onSelect:()=>qs.current?.click()},{key:"file",icon:wh,label:m.chat.uploadFile,desc:m.chat.uploadFileDesc,active:Fe.length>0,disabled:St,onSelect:()=>Ua.current?.click()},{key:"goal",icon:tc,label:m.chat.goalMode,desc:m.chat.goalModeDesc,active:St,disabled:Ke||vt||Ve,onSelect:()=>Hn(!St)}],footer:s.jsx(sL,{steerMode:on,onChangeSteerMode:xr}),direction:g&&v?"down":"up"}),s.jsx(eL,{value:A,onChange:P,disabled:Q,direction:g&&v?"down":"up"}),s.jsx(lL,{skills:I,selected:Te,onToggle:rt,disabled:Ke||vt||Ve,direction:g&&v?"down":"up"}),s.jsx("span",{title:m.chat.slashHint,className:"hidden min-w-0 truncate text-gray-300 @lg:block dark:text-gray-600",children:m.chat.slashHint})]}),s.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[!v&&s.jsx(cL,{now:D,unknown:V,..._!==void 0?{window:_}:{}}),g&&v&&E&&s.jsx(o1,{value:j??null,onChange:E,disabled:Ve}),!v&&M&&s.jsx(o1,{value:C??"",onChange:M,disabled:Ve,direction:"up"}),g&&v?s.jsx(Og,{models:g,value:h,...w!==void 0?{defaultModel:w}:{},onChange:v,disabled:Ve}):s.jsxs("button",{type:"button",title:h?.modelId??"","aria-label":`${m.chat.model} ${h?.modelId??""}`,onClick:()=>Mr(m.chat.modelLockedHint),className:"flex h-8 min-w-0 max-w-44 shrink cursor-pointer items-center gap-1.5 rounded-md px-1 text-gray-400 transition-colors duration-150 hover:text-gray-600 dark:text-gray-500 dark:hover:text-gray-300",children:[s.jsx(xi,{provider:h?.provider??"custom",className:"h-4 w-4 shrink-0"}),s.jsx("span",{className:"hidden min-w-0 truncate @md:block",children:(()=>{const le=g?.find(Ae=>jt(Ae,h));return le?Fo(le):h?.modelId??"…"})()})]}),s.jsx("button",{type:"button",title:yn?m.chat.stop:Ke?za:m.chat.send,"aria-label":yn?m.chat.stop:Ke?za:m.chat.send,disabled:yn?!1:Ke?!ra:!gr,onClick:()=>yn?void f():void Pt(),className:yn?"flex h-8 w-8 shrink-0 items-center justify-center rounded-md bg-red-50 text-red-600 transition-colors duration-150 hover:bg-red-100 dark:bg-red-950/60 dark:text-red-400 dark:hover:bg-red-950":"flex h-8 w-8 shrink-0 items-center justify-center rounded-md bg-gray-900 text-white transition-colors duration-150 hover:bg-gray-700 disabled:cursor-not-allowed disabled:bg-gray-200 disabled:text-gray-400 dark:bg-gray-100 dark:text-gray-900 dark:hover:bg-gray-300 dark:disabled:bg-gray-800 dark:disabled:text-gray-600",children:yn?s.jsx("svg",{width:"14",height:"14",viewBox:"0 0 14 14","aria-hidden":!0,className:"block",children:s.jsx("rect",{x:"2",y:"2",width:"10",height:"10",rx:"2",fill:"currentColor"})}):s.jsx("svg",{width:"17",height:"17",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,className:"block",children:s.jsx("path",{d:"M12 19V5M5 12l7-7 7 7"})})})]})]})]})]})}const c1=500,pL=5;function hL(e,t){return e+t+1}function jh(e,t){return e+t>=pL}const kS=20,gL=20;function xL(e,t,a=kS,l=gL){const o=a+1+l;if(e<=o)return{start:0,end:e};if(t===null||t<0||t>=e)return{start:e-o,end:e};const c=Math.min(Math.max(0,t-a),e-o);return{start:c,end:c+o}}const yL=12,wS=5,SS=48;function vL(e,t){return Math.max(wS,Math.min(yL,Math.floor((e-SS)/Math.max(1,t))))}function bL(e){const t=Math.floor((e-SS)/wS);return Math.min(kS,Math.max(0,Math.floor((t-1)/2)))}function kL(e){const t=[];let a=null,l=!1;for(const o of e){if(o.kind==="user_text"||o.kind==="user_image"){let c="";if(o.kind==="user_text"){const u=yS(o.text);if(!u||u.goalRound!==void 0&&u.goalRound>1){l=!1;continue}c=u.body}l&&a?a.question===""&&c!==""&&(a.question=c):(a={anchorId:o.id,question:c,answer:""},t.push(a)),l=!0;continue}if(l=!1,o.kind==="assistant_text"&&a&&a.answer.length<c1){const c=o.text.trim();c!==""&&(a.answer=(a.answer===""?c:`${a.answer} ${c}`).slice(0,c1))}}return t}function wL(e,t){let a=e.replace(/```[^\n]*/g,"").replace(/!\[([^\]]*)\]\([^)]*\)/g,"$1").replace(/\[([^\]]*)\]\([^)]*\)/g,"$1").replace(/^[ \t]*(?:#{1,6}[ \t]+|>[ \t]?|[-*+][ \t]+|\d+[.)][ \t]+)/gm,"").replace(/[*_`~]/g,"").replace(/\s+/g," ").trim();return a.length>t&&(a=`${a.slice(0,t).trimEnd()}…`),a}const SL="M5 4h14a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2zm4 0v16M12 9h5m-5 4h5",jL=96,CL=1e3,NL=56,TL=48,u1="(hover: hover) and (pointer: fine)";function ML(e,t){const[a,l]=y.useState(()=>window.matchMedia(u1).matches),[o,c]=y.useState({gutterOk:!1,height:0});return y.useEffect(()=>{const u=window.matchMedia(u1),f=p=>l(p.matches);return u.addEventListener("change",f),()=>u.removeEventListener("change",f)},[]),y.useEffect(()=>{const u=e.current;if(!u)return;const f=()=>{const h=parseFloat(getComputedStyle(document.documentElement).fontSize)||16,g=(u.clientWidth-TL*h)/2;c({gutterOk:g>=NL,height:u.clientHeight})};f();const p=new ResizeObserver(f);return p.observe(u),()=>p.disconnect()},[e,t]),{shown:a&&o.gutterOk,height:o.height}}function jS(e,t){const a=e.querySelectorAll("[data-outline-anchor]");if(a.length===0)return null;let l=null,o=null;const c=e.scrollTop+jL;for(const f of a){const p=Number(f.dataset.outlineAnchor);t.has(p)&&(l=p,f.offsetTop<=c&&(o=p))}return e.scrollHeight-e.scrollTop-e.clientHeight<2?l:o}let d1=null,f1;function CS(e,t){const a=e?.querySelector(`[data-outline-anchor="${t}"]`);!e||!a||(e.scrollTo({top:Math.max(0,a.offsetTop-8)}),window.clearTimeout(f1),d1?.classList.remove("outline-flash"),d1=a,a.classList.remove("outline-flash"),a.offsetWidth,a.classList.add("outline-flash"),f1=window.setTimeout(()=>a.classList.remove("outline-flash"),CL))}function m1({edge:e}){return s.jsx("div",{"data-outline-overflow":e,"aria-hidden":!0,className:`flex w-10 flex-col items-start gap-[3px] pl-4 ${e==="above"?"pb-1.5":"pt-1.5"}`,children:[0,1,2].map(t=>s.jsx("span",{className:"h-[2px] w-[2px] rounded-full bg-gray-300 dark:bg-gray-700"},t))})}function NS(e,t,a,l){return e.answer?wL(e.answer,l):a&&e===t[t.length-1]?m.chat.outlineAnswering:""}function EL({entries:e,turnOffset:t=0,version:a,scrollRef:l,running:o,fit:c}){const[u,f]=y.useState(null),[p,h]=y.useState(null),g=y.useRef(null);if(y.useEffect(()=>{const D=l.current;if(!c.shown||!D||!jh(t,e.length))return;const V=new Set(e.map(Q=>Q.anchorId));let F=null;const A=()=>{F=null;const Q=l.current;Q&&f(jS(Q,V))},P=()=>{F??=requestAnimationFrame(A)};return A(),D.addEventListener("scroll",P,{passive:!0}),()=>{D.removeEventListener("scroll",P),F!==null&&cancelAnimationFrame(F)}},[c.shown,l,e.length,t,a]),!c.shown||!jh(t,e.length))return null;const v=D=>{const V=D.currentTarget.getBoundingClientRect();return V.top+V.height/2-(g.current?.getBoundingClientRect().top??0)},k=bL(c.height),{start:w,end:j}=xL(e.length,e.findIndex(D=>D.anchorId===u),k,k),E=e.slice(w,j),C=vL(c.height,E.length),M=p===null?null:E.find(D=>D.anchorId===p.id)??null,_=M===null?"":NS(M,e,o,160);return s.jsxs("nav",{ref:g,"aria-label":m.chat.outlineTitle,className:"pointer-events-none absolute inset-y-0 left-0 z-10 flex flex-col items-start justify-center",children:[s.jsxs("div",{className:"max-h-full overflow-hidden",children:[(w>0||t>0)&&s.jsx(m1,{edge:"above"}),E.map((D,V)=>{const F=D.anchorId===u;return s.jsx("button",{type:"button","data-outline-tick":D.anchorId,"aria-current":F||void 0,"aria-label":m.chat.outlineTickLabel(hL(t,w+V),D.question||m.chat.outlineNoText),style:{height:C},onMouseEnter:A=>h({id:D.anchorId,top:v(A)}),onMouseLeave:()=>h(null),onFocus:A=>h({id:D.anchorId,top:v(A)}),onBlur:()=>h(null),onClick:()=>{CS(l.current,D.anchorId),f(D.anchorId)},className:"group/tick pointer-events-auto flex w-10 items-center pl-2.5",children:s.jsx("span",{className:`h-[2px] rounded-full transition-all duration-150 ${F?"w-5 bg-gray-800 dark:bg-gray-200":"w-3.5 bg-gray-300 group-hover/tick:bg-gray-500 dark:bg-gray-700 dark:group-hover/tick:bg-gray-400"}`})},D.anchorId)}),j<e.length&&s.jsx(m1,{edge:"below"})]}),M&&s.jsxs("div",{"data-outline-card":!0,"aria-hidden":!0,className:"anim-pop pointer-events-none absolute left-10 w-80 -translate-y-1/2 rounded-xl border border-gray-200 bg-white px-4 py-3 shadow-lg dark:border-gray-700 dark:bg-gray-900",style:{top:Math.min(Math.max(p.top,56),Math.max(56,c.height-56))},children:[s.jsx("p",{className:`truncate text-sm ${M.question===""?"italic text-gray-500 dark:text-gray-400":"font-semibold text-gray-900 dark:text-gray-100"}`,children:M.question||m.chat.outlineNoText}),_!==""&&s.jsx("p",{className:`mt-1 line-clamp-3 text-sm leading-snug text-gray-500 dark:text-gray-400 ${M.answer===""?"animate-pulse":""}`,children:_})]})]})}function AL({entries:e,turnOffset:t=0,scrollRef:a,running:l}){const[o,c]=y.useState(!1),[u,f]=y.useState(null);if(!jh(t,e.length))return null;const p=h=>{h&&a.current&&f(jS(a.current,new Set(e.map(g=>g.anchorId)))),c(h)};return s.jsx(ga,{open:o,setOpen:p,menuClass:"right-0 top-full mt-1 w-72 max-w-[calc(100vw-1.5rem)] origin-top-right",button:s.jsx("button",{type:"button",title:m.chat.outlineTitle,"aria-label":m.chat.outlineTitle,onClick:()=>p(!o),className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-gray-500 transition-colors duration-150 hover:bg-gray-100 hover:text-gray-800 dark:text-gray-400 dark:hover:bg-gray-800 dark:hover:text-gray-200",children:s.jsx(qe,{d:SL,size:15})}),children:s.jsx("div",{className:"max-h-[60vh] overflow-y-auto py-1",children:e.map(h=>{const g=NS(h,e,l,80),v=h.anchorId===u;return s.jsxs("button",{type:"button","data-outline-menu-entry":h.anchorId,"aria-current":v||void 0,onClick:()=>{CS(a.current,h.anchorId),c(!1)},className:`block w-full px-3 py-1.5 text-left transition-colors duration-150 ${v?"bg-gray-100 dark:bg-gray-800":"hover:bg-gray-50 dark:hover:bg-gray-800/60"}`,children:[s.jsx("span",{className:`block truncate text-sm ${h.question===""?"italic text-gray-500 dark:text-gray-400":"font-medium text-gray-800 dark:text-gray-200"}`,children:h.question||m.chat.outlineNoText}),g!==""&&s.jsx("span",{className:`mt-0.5 block truncate text-xs text-gray-500 dark:text-gray-400 ${h.answer===""?"animate-pulse":""}`,children:g})]},h.anchorId)})})})}function TS({className:e}){return s.jsx("img",{src:"/penguin-logo.svg",alt:"","aria-hidden":!0,draggable:!1,className:`select-none ${e??"h-9 w-9 rounded-lg"}`})}const Ch=[{id:"webapps",tasks:[{id:"game",skills:["web-design"]},{id:"gamecenter",skills:["web-design"]},{id:"lol",skills:["web-design"]}]},{id:"agents",tasks:[{id:"rag",skills:["penguin-sdk","web-design"]},{id:"agentBenchmarkBuild",skills:[]},{id:"agentOptimization",skills:[]}]}];Ch.flatMap(e=>[...e.tasks]);const RL=["always-ask","read-only","allow-all","deny-all"],jr=(e,t)=>`penguin.chatDraft.${e}.${t}`,MS=(e,t)=>`penguin.chatDraft.session.${e}.${t}`;function p1(e){if(typeof e!="object"||e===null)return;const t=e;if(!(typeof t.provider!="string"||typeof t.modelId!="string"))return{provider:t.provider,modelId:t.modelId}}function _L(e){if(!e)return{};try{return ES(JSON.parse(e))}catch{return{}}}function ES(e){if(typeof e!="object"||e===null)return{};const t=e,a={};typeof t.text=="string"&&(a.text=t.text),typeof t.agentId=="string"&&(a.agentId=t.agentId),typeof t.workspace=="string"&&(a.workspace=t.workspace);const l=p1(t.modelRef);l&&(a.modelRef=l),typeof t.handoffAgentId=="string"&&(a.handoffAgentId=t.handoffAgentId);const o=p1(t.switchModelRef);if(o&&(a.switchModelRef=o),Array.isArray(t.skills)){const c=t.skills.filter(u=>typeof u=="string");c.length>0&&(a.skills=c)}return typeof t.approvalMode=="string"&&RL.includes(t.approvalMode)&&(a.approvalMode=t.approvalMode),a}function Fs(e,t=localStorage){try{return _L(t.getItem(e))}catch{return{}}}function Jr(e,t,a=localStorage){try{a.setItem(e,JSON.stringify(t))}catch{}}function nc(e,t=localStorage){try{t.removeItem(e)}catch{}}function AS(e,t,a=localStorage){const l=jr(e,t),o=Fs(l,a);o.modelRef&&Jr(l,{...o,modelRef:void 0},a)}function IL(e,t,a=localStorage){const l=jr(e,t),o=Fs(l,a);(o.agentId!==void 0||o.workspace!==void 0||o.approvalMode!==void 0)&&Jr(l,{...o,agentId:void 0,workspace:void 0,approvalMode:void 0},a)}const gc=(e,t)=>`penguin.chatDrafts.${e}.${t}`,LL=50,Nh="penguin:draft-flush";function OL(e){if(!e)return[];try{const t=JSON.parse(e);if(!Array.isArray(t))return[];const a=[];for(const l of t){if(typeof l!="object"||l===null)continue;const o=l;typeof o.id!="string"||!o.id.startsWith("draft-")||a.push({id:o.id,savedAt:typeof o.savedAt=="string"?o.savedAt:"",draft:ES(o.draft)})}return a}catch{return[]}}const Th=new Map,Mh=new Set,xd=[];function RS(e){try{return localStorage}catch{return null}}function xc(e,t){const a=Th.get(e);if(a)return a;const l=RS();let o=xd;if(l)try{o=OL(l.getItem(e))}catch{o=xd}return Th.set(e,o),o}function Dg(e,t,a){Th.set(e,t);const l=RS();if(l)try{t.length===0?l.removeItem(e):l.setItem(e,JSON.stringify(t))}catch{}for(const o of Mh)o()}function DL(e){return Mh.add(e),()=>Mh.delete(e)}function zL(e,t){return y.useSyncExternalStore(DL,()=>e&&t?xc(gc(e,t)):xd,()=>xd)}const UL=()=>`draft-${crypto.randomUUID().replace(/-/g,"").slice(0,8)}`;function Ci(e,t,a){typeof window<"u"&&window.dispatchEvent(new Event(Nh));const l=jr(e,t),o=Fs(l,a);if(!o.text||o.text.trim()==="")return null;const c=gc(e,t),u={id:UL(),savedAt:new Date().toISOString(),draft:o};return Dg(c,[u,...xc(c)].slice(0,LL)),o.modelRef?Jr(l,{modelRef:o.modelRef},a):nc(l,a),u.id}function h1(e,t,a,l){return xc(gc(e,t)).find(o=>o.id===a)??null}function $L(e,t,a,l,o){const c=gc(e,t),u=xc(c);u.some(f=>f.id===a)&&Dg(c,u.map(f=>f.id===a?{...f,draft:l}:f))}function _S(e,t,a,l){const o=gc(e,t),c=xc(o);c.some(u=>u.id===a)&&Dg(o,c.filter(u=>u.id!==a))}function IS(e){return((e.draft.text??"").split(`
171
- `).map(a=>a.trim()).find(a=>a!=="")??"").slice(0,80)}const ac="penguin:chat-defaults-changed";function PL(e){window.dispatchEvent(new CustomEvent(ac,{detail:e}))}function LS(e,t){const a=e.detail;return a&&a.projectId===t?a:null}const OS="flex max-w-64 items-center gap-1.5 rounded-full border border-gray-300 bg-white py-1 pl-1.5 pr-2 text-xs text-gray-600 transition-colors duration-150 hover:bg-gray-50 hover:text-gray-900 dark:border-gray-700 dark:bg-gray-900 dark:text-gray-300 dark:hover:bg-gray-800 dark:hover:text-gray-100";function zg({projectId:e,workspace:t,onChange:a,variant:l="pill"}){const[o,c]=y.useState(!1),[u,f]=y.useState({right:!1}),p=y.useRef(!1),[h,g]=y.useState(null),[v,k]=y.useState(!1),[w,j]=y.useState(null),[E,C]=y.useState("");y.useEffect(()=>{C(h?.path??"")},[h]);const M=y.useRef(0),_=y.useCallback((B,$)=>{const G=++M.current;k(!0),j(null),dN(e,B).then(q=>{G===M.current&&g(q)}).catch(q=>{G===M.current&&($?.onError?$.onError():j(Ie(q)))}).finally(()=>{G===M.current&&k(!1)})},[e]),D=B=>{if(B&&!p.current){p.current=!0;const $=t.trim();_($.startsWith("/")?$:"")}},V=B=>{c(B),D(B)},F=B=>{const $=!o;if($){const G=B.currentTarget.getBoundingClientRect(),q=parseFloat(getComputedStyle(document.documentElement).fontSize),ae=12,Z=Math.min(20*q,window.innerWidth-2*q),X=window.innerWidth-ae-G.left,T=G.right-ae;X>=Z?f({right:!1}):T>X?f({right:!0,...T<Z?{maxWidth:T}:{}}):f({right:!1,maxWidth:X})}c($),D($)},A=()=>{const B=E.trim();if(!B||B===h?.path){C(h?.path??"");return}_(B,{onError:()=>{Qe(m.chat.workspaceDirInvalid),C(h?.path??"")}})},P=t.trim(),Q=P?P.split("/").filter(Boolean).pop()??"/":m.chat.workspaceAuto,K=h?.parent??null,O=(h?.entries??[]).filter(B=>!B.name.startsWith(".")),z=B=>s.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",className:`shrink-0 text-gray-400 ${B}`,"aria-hidden":!0,children:s.jsx("path",{d:"M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7z",strokeWidth:"1.6",strokeLinejoin:"round"})}),I=s.jsxs("div",{className:"space-y-1.5 px-2.5 pb-2.5 pt-2",children:[s.jsxs("div",{className:"rounded-md border border-gray-200 dark:border-gray-800",children:[s.jsxs("div",{className:"flex items-center gap-1.5 border-b border-gray-100 px-1.5 py-1 dark:border-gray-800",children:[s.jsx("input",{value:E,placeholder:"…","aria-label":m.chat.workspace,...Ld,onChange:B=>C(B.target.value),onBlur:A,onKeyDown:B=>{B.key==="Enter"&&!B.nativeEvent.isComposing?(B.preventDefault(),A()):B.key==="Escape"&&C(h?.path??"")},className:"min-w-0 flex-1 rounded border border-transparent bg-transparent px-1 py-0.5 font-mono text-xs text-gray-600 focus:border-gray-300 focus:outline-none dark:text-gray-300 dark:focus:border-gray-600"}),s.jsx("button",{type:"button",disabled:!h,onClick:()=>{h&&(a(h.path),c(!1))},className:"shrink-0 rounded border border-gray-300 px-1.5 py-0.5 text-xs text-gray-700 transition-colors duration-150 hover:bg-gray-100 disabled:opacity-50 dark:border-gray-700 dark:text-gray-300 dark:hover:bg-gray-800",children:m.chat.workspaceUseThis})]}),s.jsxs("ul",{className:"max-h-40 overflow-y-auto py-1",children:[K!==null&&s.jsx("li",{children:s.jsxs("button",{type:"button",disabled:v,onClick:()=>_(K),className:"flex w-full items-center gap-2 px-2.5 py-1.5 text-left font-mono text-xs text-gray-500 transition-colors duration-150 hover:bg-gray-100 disabled:opacity-50 dark:text-gray-400 dark:hover:bg-gray-800",children:["↰ ",m.chat.workspaceUp]})}),O.map(B=>s.jsx("li",{children:s.jsxs("button",{type:"button",disabled:v,onClick:()=>_(B.path),className:"flex w-full items-center gap-2 px-2.5 py-1.5 text-left font-mono text-xs text-gray-700 transition-colors duration-150 hover:bg-gray-100 disabled:opacity-50 dark:text-gray-300 dark:hover:bg-gray-800",children:[s.jsx("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",className:"shrink-0 text-gray-400","aria-hidden":!0,children:s.jsx("path",{d:"M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7z",strokeWidth:"1.6",strokeLinejoin:"round"})}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:B.name})]})},B.path)),h&&O.length===0&&s.jsx("li",{className:"px-2.5 py-1.5 text-xs text-gray-400",children:m.chat.workspaceNoSubdirs}),v&&s.jsx("li",{className:"px-2.5 py-1.5 text-xs text-gray-400",children:m.common.loading}),w&&s.jsxs("li",{className:"flex items-center justify-between gap-2 px-2.5 py-1.5 text-xs text-red-500",children:[s.jsx("span",{className:"min-w-0 flex-1 truncate",title:w,children:w}),s.jsx("button",{type:"button",disabled:v,onClick:()=>_(""),className:"shrink-0 rounded border border-gray-300 px-1.5 py-0.5 text-xs text-gray-700 transition-colors duration-150 hover:bg-gray-100 disabled:opacity-50 dark:border-gray-700 dark:text-gray-300 dark:hover:bg-gray-800",children:m.common.retry})]})]})]}),P&&s.jsx("button",{type:"button",onClick:()=>{a(""),c(!1)},className:"text-xs text-gray-500 underline decoration-gray-300 underline-offset-2 transition-colors duration-150 hover:text-gray-800 dark:text-gray-400 dark:hover:text-gray-200",children:m.chat.workspaceClear}),s.jsx("p",{className:"px-0.5 text-xs leading-5 text-gray-400 dark:text-gray-500",children:m.chat.workspaceHint})]});return l==="form"?s.jsx(Ig,{open:o,setOpen:V,leading:z(""),label:Q,...P?{labelClassName:"font-mono"}:{},title:P?`${m.chat.workspace}:${P}`:m.chat.workspaceHint,ariaLabel:m.chat.workspace,ariaHaspopup:"dialog",menuClass:"w-80",children:I}):s.jsx(ga,{open:o,setOpen:c,menuClass:`top-full mt-1 w-80 max-w-[calc(100vw-2rem)] ${u.right?"right-0 origin-top-right":"left-0 origin-top-left"}`,...u.maxWidth!==void 0?{menuStyle:{maxWidth:u.maxWidth}}:{},button:s.jsxs("button",{type:"button",title:P?`${m.chat.workspace}:${P}`:m.chat.workspaceHint,"aria-label":m.chat.workspace,onClick:F,className:OS,children:[z("ml-0.5"),s.jsx("span",{className:`min-w-0 truncate ${P?"font-mono":""}`,children:Q}),s.jsx($n,{open:o,size:12,className:"shrink-0 text-gray-400"})]}),children:I})}const BL=300;function g1(e){try{return sessionStorage.getItem(`penguin.chatRouteApplied.${e}`)}catch{return null}}function x1(e,t){try{sessionStorage.setItem(`penguin.chatRouteApplied.${e}`,t)}catch{}}const HL={webapps:"M3 6a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6zM3 9h18M6 6.5h.01M9 6.5h.01",agents:"M12 3v3m-6 4a6 6 0 0 1 12 0v5a3 3 0 0 1-3 3H9a3 3 0 0 1-3-3v-5zm3 3h.01M15 13h.01"};function FL({projectId:e,models:t,draftId:a}){const l=Wn(),o=ya(),{agents:c,currentAgent:u,setCurrentAgentId:f}=Xt(),{add:p}=Bs(),h=xn().user?.userId??null,[g]=y.useState(()=>a!==void 0&&(!h||h1(h,e,a)===null)),[v]=y.useState(()=>h?a!==void 0?h1(h,e,a)?.draft??{}:Fs(jr(h,e)):{});y.useEffect(()=>{g&&l("/chat/new",{replace:!0})},[g,l]);const[k,w]=y.useState(v.agentId??u?.agentId??null),[j,E]=y.useState(v.workspace??""),[C,M]=y.useState(v.approvalMode??"allow-all"),[_,D]=y.useState(v.modelRef??null),V=y.useRef(v.text??""),F=y.useRef(v.skills??[]),[A,P]=y.useState(null),Q=y.useRef(!1);y.useEffect(()=>{let W=!1;return Ek(e).then(ge=>{!W&&!Q.current&&P(ge)}).catch(()=>{!W&&!Q.current&&P({})}),()=>{W=!0}},[e]);const K=y.useRef({agent:!1,workspace:!1,approval:!1}),O=o.state,z=O?.agentId,I=y.useRef(null),B=y.useRef(!1);y.useEffect(()=>{if(c.length===0)return;const W=ge=>!!ge&&c.some(Ne=>Ne.agentId===ge);if(z&&I.current!==o.key&&g1("agentId")!==o.key&&(I.current=o.key,x1("agentId",o.key),W(z))){w(z);return}if(A?.agentId!==void 0&&!B.current&&(B.current=!0,I.current===null&&v.agentId===void 0&&!K.current.agent&&W(A.agentId))){w(A.agentId);return}W(k)||w((c.find(ge=>ge.agentId==="default_agent")??c[0])?.agentId??null)},[c,k,o.key,z,A,v.agentId]);const $=O?.workspace,G=y.useRef(null);y.useEffect(()=>{$===void 0||G.current===o.key||g1("workspace")===o.key||(G.current=o.key,x1("workspace",o.key),E($))},[o.key,$]);const q=y.useRef(!1);y.useEffect(()=>{A===null||q.current||(q.current=!0,A.workspace!==void 0&&$===void 0&&v.workspace===void 0&&!K.current.workspace&&E(A.workspace),A.approvalMode!==void 0&&v.approvalMode===void 0&&!K.current.approval&&M(A.approvalMode))},[A,$,v.workspace,v.approvalMode]),y.useEffect(()=>{if(!t||_&&t.models.some(ge=>jt(ge,_)))return;const W=t.models[0];D(t.defaultModel??(W?{provider:W.provider,modelId:W.modelId}:null))},[t,_]);const ae=y.useCallback(W=>{if(W.defaults){const ge=W.defaults;Q.current=!0,P(ge),K.current={agent:!1,workspace:!1,approval:!1},E(ge.workspace??""),M(ge.approvalMode??"allow-all"),(Te=>Te!==void 0&&c.some(Pe=>Pe.agentId===Te))(ge.agentId)?w(ge.agentId):c.length>0&&w(u?.agentId??(c.find(Te=>Te.agentId==="default_agent")??c[0])?.agentId??null)}W.defaultModel!==void 0&&D(W.defaultModel)},[c,u]),Z=y.useRef(ae);Z.current=ae,y.useEffect(()=>{const W=ge=>{const Ne=LS(ge,e);Ne&&Z.current(Ne)};return window.addEventListener(ac,W),()=>window.removeEventListener(ac,W)},[e]);const[X,T]=y.useState(null);y.useEffect(()=>{if(T(null),!k)return;let W=!1;return jl(e,k).then(ge=>{W||T(ge.config.model?.thinkingLevel??"")}).catch(()=>{}),()=>{W=!0}},[e,k]);const R=X===null||A===null?null:q8(X,A.thinkingLevel),H=y.useRef(null);H.current=X;const S=y.useCallback(W=>{if(!k||!W)return;const ge=H.current;T(W),kl(e,k,{config:{model:{thinkingLevel:W}}}).catch(Ne=>{T(ge),Qe(Ie(Ne))})},[e,k]),[U,ee]=y.useState([]),[ie,de]=y.useState(!1);y.useEffect(()=>{if(ee(ge=>ge.length>0?[]:ge),de(!1),!k)return;let W=!1;return Cd(e,k).then(ge=>{W||ee(ge.skills)}).catch(()=>{}).finally(()=>{W||de(!0)}),()=>{W=!0}},[e,k]);const me=y.useRef(null),ye=y.useCallback(()=>{me.current!==null&&(window.clearTimeout(me.current),me.current=null)},[]),te=y.useCallback(()=>{if(ye(),!h)return;const W={text:V.current,workspace:j,approvalMode:C};k&&(W.agentId=k),_&&(W.modelRef=_),F.current.length>0&&(W.skills=F.current),a!==void 0?$L(h,e,a,W):Jr(jr(h,e),W)},[ye,h,e,a,k,j,C,_]),be=y.useRef(te);y.useEffect(()=>{be.current=te,te()},[te]);const Re=y.useCallback(W=>{V.current=W,ye(),me.current=window.setTimeout(()=>{me.current=null,be.current()},BL)},[ye]),Fe=y.useCallback(W=>{F.current=W,be.current()},[]);y.useEffect(()=>()=>{me.current!==null&&(window.clearTimeout(me.current),be.current())},[]),y.useEffect(()=>{const W=()=>{me.current!==null&&(window.clearTimeout(me.current),me.current=null,be.current())};return window.addEventListener(Nh,W),()=>window.removeEventListener(Nh,W)},[]);const ce=y.useCallback(()=>{if(ye(),F.current=[],V.current="",!!h){if(a!==void 0){_S(h,e,a);return}_?Jr(jr(h,e),{modelRef:_}):nc(jr(h,e))}},[ye,h,e,a,_]),Ve=W=>{K.current.agent=!0,w(W.agentId),f(W.agentId)},je=y.useCallback(W=>{K.current.workspace=!0,E(W)},[]),wt=y.useCallback(W=>{K.current.approval=!0,M(W)},[]),an=y.useRef(!1),[rn,sn]=y.useState(!1),Ut=y.useCallback(async(W,ge=!1,Ne=null)=>{if(!k||an.current)return!1;an.current=!0,sn(!0);let Te=null;try{const Pe={approvalMode:C};_&&(Pe.modelId=_.modelId,Pe.provider=_.provider),j.trim()&&(Pe.workspace=j.trim());const We=await qp(e,k,Pe);Te=We.session.sessionId;const tt=await Io(Te,{input:W,...Ne?{goal:Ne}:{}});return p(We.session),ge||ce(),l(`/chat/${tt.sessionId}`,{replace:!0}),!0}catch(Pe){return Te&&td(Te).catch(()=>{}),Qe(Ie(Pe,_?{modelId:_.modelId}:{})),!1}finally{an.current=!1,sn(!1)}},[e,k,C,_,j,p,ce,l]),[At,fn]=y.useState(null),st=y.useCallback(async W=>{if(At===null){fn(W.id);try{const ge=W.skills.filter(Ne=>U.some(Te=>Te.name===Ne));await Ut([{type:"text",text:ah(ge,m.chat.exampleTasks[W.id].prompt)}],!0)}finally{fn(null)}}},[At,U,Ut]),[nn,pe]=y.useState(Ch[0].id),Se=c.find(W=>W.agentId===k)??null,De=t?.models.find(W=>jt(W,_)),ze=De?.contextWindow,Ue=De?.vision!==!1;return s.jsxs("div",{className:"anim-fade flex min-h-0 flex-1 flex-col overflow-y-auto px-3 py-6 md:px-4",children:[s.jsx("div",{className:"flex-1"}),s.jsxs("div",{className:"mx-auto w-full max-w-3xl",children:[s.jsxs("div",{className:"mb-10 text-center",children:[s.jsx(TS,{className:"mx-auto mb-1 h-36 w-36 rounded-3xl"}),s.jsx("h1",{className:"text-3xl font-semibold tracking-tight text-gray-900 dark:text-gray-100",children:m.appName}),s.jsx("p",{className:"mt-2 text-base text-gray-400 dark:text-gray-500",children:m.chat.draftSubtitle}),s.jsx(qL,{})]}),s.jsx(bS,{status:"idle",onSend:(W,ge)=>Ut(W,!1,ge),onStop:async()=>{},onCompact:async()=>{},modelRef:_,models:t?.models??[],onChangeModel:D,thinkingLevel:R,onChangeThinkingLevel:S,...t?.defaultModel!==void 0?{defaultModel:t.defaultModel}:{},...ze!==void 0?{contextWindow:ze}:{},contextNow:0,vision:Ue,approvalMode:C,onChangeApprovalMode:wt,modeSaving:!1,autoFocus:!0,agents:c,...k?{currentAgentId:k}:{},skills:U,...v.skills&&v.skills.length>0?{initialSkills:v.skills}:{},onSkillsChange:Fe,initialText:v.text??"",onTextChange:Re}),s.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-2",children:[s.jsx(VL,{agents:c,selected:Se,onSelect:Ve}),s.jsx(zg,{projectId:e,workspace:j,onChange:je})]}),s.jsx("div",{className:"mt-6 space-y-1",children:Ch.map(W=>{const ge=W.id===nn;return s.jsxs("div",{children:[s.jsxs("button",{type:"button","aria-expanded":ge,onClick:()=>pe(W.id),className:`flex w-full items-center gap-2 rounded-lg px-2 py-2 text-left transition-colors duration-150 ${ge?"bg-gray-100 dark:bg-gray-800/70":"hover:bg-gray-100 dark:hover:bg-gray-800/70"}`,children:[s.jsx("span",{className:"shrink-0 text-brand-500 dark:text-brand-400",children:s.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:s.jsx("path",{d:HL[W.id]})})}),s.jsx("span",{className:"min-w-0 flex-1 truncate text-sm font-medium text-gray-700 dark:text-gray-300",children:m.chat.exampleFolders[W.id]}),s.jsx("span",{className:"shrink-0 text-xs text-gray-400 dark:text-gray-500",children:W.tasks.length}),s.jsx($n,{open:ge,size:14,className:"text-gray-400"})]}),ge&&s.jsx("ul",{className:"mt-0.5 space-y-0.5 pl-4",children:W.tasks.map(Ne=>{const Te=m.chat.exampleTasks[Ne.id];return s.jsx("li",{children:s.jsxs("button",{type:"button",title:Te.desc,disabled:At!==null||rn||!ie||!k||!t,onClick:()=>{st(Ne)},className:"flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-sm text-gray-600 transition-colors duration-150 hover:bg-gray-100 hover:text-gray-900 disabled:cursor-default disabled:opacity-60 disabled:hover:bg-transparent dark:text-gray-400 dark:hover:bg-gray-800/70 dark:hover:text-gray-200",children:[s.jsx("span",{className:"min-w-0 flex-1 truncate",children:Te.label}),At===Ne.id&&s.jsx("span",{className:"shrink-0 text-xs text-gray-400",children:m.common.loading})]})},Ne.id)})})]},W.id)})})]}),s.jsx("div",{className:"flex-1"})]})}const y1="ml-1.5 inline-block align-super text-[10px] leading-4 text-gray-400 dark:text-gray-500";function qL(){const{locale:e}=La(),{version:t,update:a}=Jh(!0);if(t===null)return null;const l=t.buildDate;return s.jsxs("p",{className:"mt-1.5 text-xs text-gray-400 dark:text-gray-500",children:[`v${t.version}${l!==null?` · ${m.update.lastUpdated(Cw(l,e))}`:""}`,a!==null&&a.updateAvailable&&a.latestVersion!==null&&(a.releaseUrl!==null?s.jsx("a",{href:a.releaseUrl,target:"_blank",rel:"noopener noreferrer",title:m.update.newVersion(a.latestVersion),"aria-label":m.update.newVersion(a.latestVersion),className:`${y1} hover:underline`,children:m.update.newVersionBadge}):s.jsx("span",{className:y1,children:m.update.newVersionBadge}))]})}function VL({agents:e,selected:t,onSelect:a}){const[l,o]=y.useState(!1);return s.jsx(ga,{open:l,setOpen:o,menuClass:"left-0 top-full mt-1 w-72 max-w-[calc(100vw-2rem)] origin-top-left",button:s.jsxs("button",{type:"button",title:m.chat.chooseAgent,"aria-label":m.chat.chooseAgent,onClick:()=>o(!l),className:OS,children:[t?s.jsx(xa,{id:t.agentId,name:tn(t),size:16,className:"shrink-0 rounded"}):null,s.jsx("span",{className:"min-w-0 truncate",children:t?tn(t):m.common.loading}),s.jsx($n,{open:l,size:12,className:"shrink-0 text-gray-400"})]}),children:s.jsxs("div",{className:"max-h-56 overflow-y-auto",children:[e.length===0&&s.jsx("p",{className:"px-3 py-1.5 text-xs text-gray-400",children:m.common.loading}),e.map(c=>{const u=c.agentId===t?.agentId;return s.jsxs("button",{type:"button","aria-pressed":u,onClick:()=>{a(c),o(!1)},className:"flex w-full items-center gap-2.5 px-3 py-1.5 text-left transition-colors duration-150 hover:bg-gray-100 dark:hover:bg-gray-800",children:[s.jsx(xa,{id:c.agentId,name:tn(c),size:20,className:"shrink-0 rounded"}),s.jsxs("span",{className:"min-w-0 flex-1",children:[s.jsx("span",{className:`block truncate text-xs ${u?"font-medium text-gray-900 dark:text-gray-100":"text-gray-700 dark:text-gray-300"}`,children:tn(c)}),c.description&&s.jsx("span",{className:"block truncate text-[11px] text-gray-400 dark:text-gray-500",children:c.description})]}),s.jsx("span",{className:"w-4 shrink-0 text-center text-xs text-gray-500 dark:text-gray-400",children:u?"✓":""})]},c.agentId)})]})})}function DS(){return{sessionId:null,taskCount:0,sessionCost:null,costUncosted:!1,settledUsd:0,lastLiveUsd:0,liveAtFetchUsd:0,pendingFetchSnapshot:!1,shownUsd:null,shownUncosted:!1}}function GL(e,t,a){e.sessionId===t&&a!==null&&(e.costUncosted=a.hasUncosted,a.cost!=null&&(e.sessionCost=a.cost,e.settledUsd=0,e.pendingFetchSnapshot=!0))}function v1(e){return e.sessionCost!=null||e.settledUsd>0?(e.sessionCost??0)+e.settledUsd:null}function b1(e,t,a,l){return t!=null&&(e.shownUsd=t,e.shownUncosted=a),{costText:t!=null?hr(t,l):null,costUncosted:a}}function WL(e,t){if(t.sessionId!==e.sessionId&&Object.assign(e,DS(),{sessionId:t.sessionId}),t.loading){const f=e.shownUsd??v1(e),p=e.shownUsd!=null?e.shownUncosted:e.costUncosted;return b1(e,f,p,t.currency)}if(t.taskCount<e.taskCount&&(e.taskCount=t.taskCount,e.lastLiveUsd=0,e.liveAtFetchUsd=0),e.pendingFetchSnapshot&&(!t.taskOpen||t.liveUsd!=null)){e.pendingFetchSnapshot=!1;const f=t.taskOpen?t.liveUsd??0:0;e.liveAtFetchUsd=f,e.lastLiveUsd=f}(t.taskCount>e.taskCount||!t.taskOpen&&(e.lastLiveUsd>0||e.liveAtFetchUsd>0))&&(e.settledUsd+=Math.max(0,e.lastLiveUsd-e.liveAtFetchUsd),e.lastLiveUsd=0,e.liveAtFetchUsd=0),e.taskCount=t.taskCount,t.taskOpen&&t.liveUsd!=null&&(e.lastLiveUsd=t.liveUsd);const a=v1(e),l=t.taskOpen&&t.liveUsd!=null?Math.max(0,t.liveUsd-e.liveAtFetchUsd):null,o=l!=null&&(l>0||a!=null)?(a??0)+l:a;let c;o==null||t.taskOpen&&e.shownUsd!=null&&o<e.shownUsd?c=e.shownUsd:c=o;const u=o==null?e.shownUncosted:e.costUncosted;return b1(e,c,u,t.currency)}const Eh={damping:1,response:.35},k1={damping:.8,response:.3};function KL(e,t,a,l,o){const c=2*Math.PI/l.response,u=c*c,f=2*l.damping*c;let p=e,h=t,g=Math.min(o,64);for(;g>0;){const v=Math.min(g,8)/1e3,k=-u*(p-a)-f*h;h+=k*v,p+=h*v,g-=8}return[p,h]}function w1(e,t,a){return Math.abs(e-a)<.5&&Math.abs(t)<5}function YL(e,t){let a=e,l=0,o=e,c=Eh,u,f=0,p=0;const h=()=>{f&&cancelAnimationFrame(f),f=0,p=0,u=void 0},g=v=>{const k=p?v-p:16;if(p=v,[a,l]=KL(a,l,o,c,k),w1(a,l,o)){a=o,l=0,f=0,p=0,t(a);const w=u;u=void 0,w?.();return}t(a),f=requestAnimationFrame(g)};return{get value(){return a},get velocity(){return l},animateTo(v,k,w){if(o=v,c=k,w?.velocity!==void 0&&(l=w.velocity),u=w?.onSettle,w1(a,l,o)){a=o,l=0,t(a);const j=u;u=void 0,j?.();return}f||(f=requestAnimationFrame(g))},stop(){return h(),[a,l]},set(v){h(),a=v,l=0,t(a)},dispose:h}}function QL(e,t=.998){return e/1e3*t/(1-t)}function XL(e,t,a=.55){return e*t*a/(t+a*Math.abs(e))}function ZL(e,t){let a=t[0];for(const l of t)Math.abs(l-e)<Math.abs(a-e)&&(a=l);return a}const JL=.92,eO=.6;function tO(){const[e,t]=y.useState(()=>window.matchMedia("(prefers-reduced-motion: reduce)").matches);return y.useEffect(()=>{const a=window.matchMedia("(prefers-reduced-motion: reduce)"),l=o=>t(o.matches);return a.addEventListener("change",l),()=>a.removeEventListener("change",l)},[]),e}function Ug({open:e,snap:t,onSnapChange:a,onClose:l,title:o,children:c}){const[u,f]=y.useState(e),p=y.useRef(null),h=y.useRef(null),g=y.useRef(null),v=y.useRef(0),k=y.useRef(!1),w=y.useRef(!1),j=y.useRef(null),E=y.useRef([]),C=y.useRef({pointerY:0,sheetY:0}),M=y.useRef(e);M.current=e;const _=y.useRef(null),D=tO(),V=y.useCallback(z=>{const I=v.current||1;p.current&&(p.current.style.transform=`translate3d(0, ${z}px, 0)`),h.current&&(h.current.style.opacity=String(Math.min(1,Math.max(0,1-z/I))))},[]),F=y.useCallback(z=>{const I=v.current;return z==="full"?0:I*(1-eO/JL)},[]);y.useEffect(()=>{e&&f(!0)},[e]),y.useLayoutEffect(()=>{if(!u)return;const z=p.current;z&&(v.current=z.offsetHeight,g.current||(g.current=YL(v.current,V),g.current.set(v.current)))},[u,V]),y.useEffect(()=>{if(!u)return;const z=g.current;if(z)if(e){if(w.current=!1,k.current)return;const I=F(t);if(j.current!==null&&Math.abs(j.current-I)<1)return;if(j.current=I,D){z.set(I);return}z.animateTo(I,Eh)}else{if(w.current=!0,j.current=v.current,D){f(!1);return}z.animateTo(v.current,Eh,{onSettle:()=>f(!1)})}},[u,e,t,D,F]),y.useEffect(()=>{u||(g.current?.dispose(),g.current=null,j.current=null,k.current=!1,w.current=!1)},[u]),y.useEffect(()=>()=>g.current?.dispose(),[]),y.useEffect(()=>{if(!u)return;const z=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=z}},[u]),y.useEffect(()=>{if(!u||!e)return;const z=I=>{I.key==="Escape"&&l()};return window.addEventListener("keydown",z),()=>window.removeEventListener("keydown",z)},[u,e,l]),y.useEffect(()=>{if(u)return _.current=document.activeElement instanceof HTMLElement?document.activeElement:null,()=>_.current?.focus()},[u]),y.useEffect(()=>{if(!u)return;const z=()=>{const I=p.current;if(!I||(v.current=I.offsetHeight,k.current||w.current))return;const B=F(t);j.current=B,g.current?.set(B)};return window.addEventListener("resize",z),()=>window.removeEventListener("resize",z)},[u,t,F]);const A=z=>{if(w.current)return;const I=g.current;if(!I)return;z.currentTarget.setPointerCapture(z.pointerId);const[B]=I.stop();k.current=!0,C.current={pointerY:z.clientY,sheetY:B},E.current=[{y:z.clientY,t:performance.now()}]},P=z=>{if(!k.current)return;const I=g.current;if(!I)return;const B=C.current.sheetY+(z.clientY-C.current.pointerY),$=v.current,G=B<0?-XL(-B,$):Math.min(B,$);I.set(G);const q=performance.now(),ae=E.current;for(ae.push({y:z.clientY,t:q});ae.length>2&&q-ae[0].t>100;)ae.shift()},Q=z=>{k.current=!1;const I=g.current;if(!I)return;const B=v.current,$=F("half"),G=M.current?I.value+QL(z):B,q=ZL(G,[0,$,B]);if(j.current=q,q===B){if(w.current=!0,D){f(!1),l();return}I.animateTo(B,k1,{velocity:z,onSettle:()=>{f(!1),l()}});return}I.animateTo(q,k1,{velocity:z});const ae=q===0?"full":"half";ae!==t&&a?.(ae)},K=()=>{if(!k.current)return;const z=E.current,I=z[z.length-1],B=z[0],$=I&&B?I.t-B.t:0;Q($>0?(I.y-B.y)/$*1e3:0)},O=()=>{k.current&&Q(0)};return u?s.jsxs("div",{className:"fixed inset-0 z-50",role:"dialog","aria-modal":"true","aria-label":o,children:[s.jsx("div",{ref:h,className:`absolute inset-0 bg-black/45 ${D?"anim-fade":""}`,style:{opacity:0},onPointerDown:()=>l()}),s.jsxs("div",{ref:p,className:`absolute inset-x-0 bottom-0 flex h-[92dvh] flex-col overflow-hidden rounded-t-2xl border-t border-gray-200 bg-white shadow-2xl dark:border-gray-800 dark:bg-gray-900 ${D?"anim-fade":""}`,style:{transform:"translate3d(0, 100%, 0)"},children:[s.jsxs("div",{className:"shrink-0 cursor-grab touch-none select-none active:cursor-grabbing",onPointerDown:A,onPointerMove:P,onPointerUp:K,onPointerCancel:O,onLostPointerCapture:O,children:[s.jsx("div",{className:"mx-auto mt-2 h-1 w-9 rounded-full bg-gray-300 dark:bg-gray-600"}),s.jsxs("div",{className:"flex items-center justify-between px-4 pb-2 pt-1.5",children:[s.jsx("span",{className:"text-base font-semibold",children:o??""}),s.jsx(tg,{onClose:l,onPointerDown:z=>z.stopPropagation()})]})]}),s.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto overscroll-contain pb-[env(safe-area-inset-bottom)]",children:c})]})]}):null}function Hd(e){return s.jsx("span",{className:"relative",children:s.jsx("input",{type:"file",className:"sr-only",...e})})}const nO=new Set(["txt","md","json","js","mjs","cjs","ts","tsx","jsx","py","sh","bash","yaml","yml","toml","css","html","htm","csv","log","xml","ini","conf","rs","go","java","c","h","cpp","hpp","sql","rb","php","gitignore","env"]),aO=new Set(["png","jpg","jpeg","gif","webp","svg"]),rO=new Set(["html","htm"]),Ou=256*1024,S1=64*1024,sO={html:"html",htm:"html",css:"css",js:"javascript",mjs:"javascript",cjs:"javascript",jsx:"jsx",ts:"typescript",tsx:"tsx",json:"json",md:"markdown",py:"python",rb:"ruby",php:"php",go:"go",rs:"rust",java:"java",c:"c",h:"c",cpp:"cpp",hpp:"cpp",sh:"shellscript",bash:"shellscript",yml:"yaml",yaml:"yaml",toml:"toml",ini:"ini",conf:"ini",xml:"xml",sql:"sql",log:"log"};function lO(e){return sO[e]??"text"}function j1(e){const t=e.lastIndexOf(".");return t>=0?e.slice(t+1).toLowerCase():e.toLowerCase()}function C1(e){return e.includes("/")?e.slice(0,e.lastIndexOf("/")):""}const N1=/^[a-z][a-z0-9+.-]*:/i;function T1(e,t){const a=t.startsWith("/")||e===""?[]:e.split("/");for(const l of t.split("/"))l===""||l==="."||(l===".."?a.pop():a.push(l));return a.join("/")}const Np="<script>(function(){function mk(){var m={};return{getItem:function(k){return k in m?m[k]:null},setItem:function(k,v){m[k]=String(v)},removeItem:function(k){delete m[k]},clear:function(){m={}},key:function(i){return Object.keys(m)[i]||null},get length(){return Object.keys(m).length}}}['localStorage','sessionStorage'].forEach(function(n){try{window[n].length}catch(e){Object.defineProperty(window,n,{value:mk(),configurable:true})}})})();<\/script>";function iO(e){return/<head[^>]*>/i.test(e)?e.replace(/<head[^>]*>/i,t=>t+Np):/<html[^>]*>/i.test(e)?e.replace(/<html[^>]*>/i,t=>t+Np):Np+e}let Du=0;function M1({session:e,openRequest:t,active:a,onPreviewOpen:l}){const{previewIsolated:o}=xn(),[c,u]=y.useState(""),[f,p]=y.useState(null),[h,g]=y.useState(null),[v,k]=y.useState(null),[w,j]=y.useState(!1),[E,C]=y.useState(null),[M,_]=y.useState(0),[D,V]=y.useState(!1),[F,A]=y.useState("rendered"),[P,Q]=y.useState(null),K=y.useRef(o);K.current=o,y.useEffect(()=>{let T=!1;return g(null),NN(e.sessionId,c).then(R=>{T||p({base:c,res:R})}).catch(R=>{T||g(R instanceof na?R.message:m.files.loadFailed)}),()=>{T=!0}},[e.sessionId,c,M]);const[O,z]=y.useState(e.sessionId);O!==e.sessionId&&(z(e.sessionId),u(""),k(null),p(null),Q(null),Du++);const I=y.useRef(a);y.useEffect(()=>{a&&!I.current&&_(T=>T+1),I.current=a},[a]);const B=y.useRef(l);B.current=l;const $=y.useCallback(async T=>{B.current?.();const R=T.includes("/")?T.slice(T.lastIndexOf("/")+1):T,H=j1(R),S=++Du,U=de=>{S===Du&&k(de)};if(A("rendered"),Q(null),aO.has(H)){U({path:T,name:R,kind:"image",nonce:S});return}if(H==="pdf"){U({path:T,name:R,kind:"pdf",nonce:S});return}const ee=rO.has(H),ie=H==="md";if(!ee&&!nO.has(H)){U({path:T,name:R,kind:"unsupported",nonce:S});return}if(ee&&K.current){U({path:T,name:R,kind:"html",nonce:S});return}try{const de=await fetch(Es(e.sessionId,T),{credentials:"same-origin"});if(!de.ok)throw new Error(String(de.status));const me=await de.text(),ye=me.length>Ou;ie&&me.length>S1&&S===Du&&A("source"),U({path:T,name:R,kind:ee?"html":ie?"md":"text",content:ye?me.slice(0,Ou):me,truncated:ye,nonce:S})}catch{U({path:T,name:R,kind:"unsupported",nonce:S})}},[e.sessionId]);y.useEffect(()=>{if(v?.kind!=="html"||v.content!==void 0||F!=="source"&&o)return;const T=v.path;let R=!1;return Q(null),(async()=>{try{const H=await fetch(Es(e.sessionId,T),{credentials:"same-origin"});if(!H.ok)throw new Error(String(H.status));const S=await H.text();if(R)return;const U=S.length>Ou;k(ee=>ee!==null&&ee.kind==="html"&&ee.path===T&&ee.content===void 0?{...ee,content:U?S.slice(0,Ou):S,truncated:U}:ee)}catch{R||Q(m.files.loadFailed)}})(),()=>{R=!0}},[v,F,o,e.sessionId]);const G=y.useRef(null);y.useEffect(()=>{if(!t||G.current===t)return;G.current=t;const T=t.path,R=T.includes("/")?T.slice(0,T.lastIndexOf("/")):"";u(R),_(H=>H+1),$(T)},[t,$]);const q=T=>{j(!0),g(null),(async()=>{try{for(const R of T){const H=await new Promise((S,U)=>{const ee=new FileReader;ee.onload=()=>{const ie=ee.result;S(ie.slice(ie.indexOf(",")+1))},ee.onerror=()=>U(new Error("read failed")),ee.readAsDataURL(R)});await TN(e.sessionId,Ju(c,R.name),H)}Et(m.files.uploaded),_(R=>R+1)}catch(R){Qe(Ie(R))}finally{j(!1)}})()},ae=T=>{const R=T.target.files?[...T.target.files]:[];if(T.target.value="",R.length===0)return;const H=new Set((f?.res.entries??[]).map(U=>U.name)),S=R.filter(U=>H.has(U.name)).map(U=>U.name);S.length>0?C({files:R,clashes:S}):q(R)},Z=c===""?[]:c.split("/"),X=h===null&&f!==null&&f.base!==c;return v!==null?s.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[s.jsxs("div",{className:"flex shrink-0 flex-wrap items-center gap-2 border-b border-gray-200 px-3 py-2 dark:border-gray-800",children:[s.jsxs("button",{type:"button",onClick:()=>{k(null),_(T=>T+1)},title:m.files.backToList,className:"flex shrink-0 items-center gap-1 rounded-md px-1.5 py-1 text-sm text-gray-500 transition-colors duration-150 hover:bg-gray-100 hover:text-gray-800 dark:text-gray-400 dark:hover:bg-gray-800 dark:hover:text-gray-200",children:[s.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:s.jsx("path",{d:"M15 18l-6-6 6-6"})}),m.files.backToList]}),s.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-sm font-semibold",title:v.path,children:v.name}),(v.kind==="html"||v.kind==="md")&&s.jsx("div",{className:"flex shrink-0 rounded-md bg-gray-100 p-0.5 dark:bg-gray-800",children:[["rendered",m.files.htmlRendered],["source",m.files.htmlSource]].map(([T,R])=>s.jsx("button",{type:"button",onClick:()=>A(T),className:`rounded px-2 py-0.5 text-xs transition-colors duration-150 ${F===T?"bg-white font-medium text-gray-900 shadow-sm dark:bg-gray-600 dark:text-gray-100":"text-gray-500 hover:text-gray-800 dark:text-gray-400 dark:hover:text-gray-200"}`,children:R},T))}),/\.html?$/i.test(v.name)&&s.jsxs("a",{href:Ov(e.sessionId,v.path),target:"_blank",rel:"noopener noreferrer",title:o?void 0:m.files.previewNotIsolatedHint,className:"inline-flex shrink-0 items-center gap-1 rounded-md border border-transparent bg-transparent px-2.5 py-1 text-xs font-medium text-gray-600 transition-colors duration-150 hover:bg-gray-100 hover:text-gray-900 dark:text-gray-300 dark:hover:bg-gray-800 dark:hover:text-gray-100",children:[m.files.openInNewTab,!o&&s.jsx("span",{"aria-label":m.files.previewNotIsolatedHint,className:"text-amber-600 dark:text-amber-500",children:"⚠"})]}),s.jsx("a",{href:Es(e.sessionId,v.path,!0),download:v.name,className:"inline-flex shrink-0 items-center rounded-md border border-transparent bg-transparent px-2.5 py-1 text-xs font-medium text-gray-600 transition-colors duration-150 hover:bg-gray-100 hover:text-gray-900 dark:text-gray-300 dark:hover:bg-gray-800 dark:hover:text-gray-100",children:m.files.download})]}),s.jsx("div",{className:"min-h-0 flex-1 overflow-auto p-3",children:v.kind==="image"?s.jsx("img",{src:Es(e.sessionId,v.path),alt:v.name,className:"max-w-full rounded-md border border-gray-200 dark:border-gray-800"}):v.kind==="pdf"?s.jsx("iframe",{src:Es(e.sessionId,v.path),title:v.name,className:"h-full min-h-[60vh] w-full rounded-md border border-gray-200 dark:border-gray-800"}):v.kind==="html"&&F==="rendered"?o?s.jsx("iframe",{src:Ov(e.sessionId,v.path),title:v.name,sandbox:"allow-scripts allow-same-origin allow-forms allow-popups allow-modals allow-downloads",className:"h-full min-h-[60vh] w-full rounded-md border border-gray-200 bg-white dark:border-gray-800"},v.nonce):v.content===void 0?P!==null?s.jsx("p",{className:"text-sm text-red-600 dark:text-red-400",children:P}):s.jsx(pa,{rows:6}):s.jsx("iframe",{srcDoc:iO(v.content),title:v.name,sandbox:"allow-scripts",className:"h-full min-h-[60vh] w-full rounded-md border border-gray-200 bg-white dark:border-gray-800"}):v.kind==="md"&&F==="rendered"?s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"md-body text-base leading-relaxed text-gray-800 dark:text-gray-100",children:s.jsx(pc,{remarkPlugins:[hc],components:{img:({src:T,alt:R})=>s.jsx("img",{src:typeof T=="string"&&!N1.test(T)?Es(e.sessionId,T1(C1(v.path),T)):T,alt:R??"",loading:"lazy",className:"max-w-full"}),a:({href:T,children:R})=>{if(typeof T!="string"||T.startsWith("#"))return s.jsx("a",{href:T,children:R});if(N1.test(T))return s.jsx("a",{href:T,target:"_blank",rel:"noreferrer",children:R});const H=T1(C1(v.path),T);return s.jsx("a",{href:Es(e.sessionId,H),onClick:S=>{S.preventDefault(),$(H)},children:R})}},children:v.content??""})}),v.truncated&&s.jsxs("p",{className:"mt-1 text-xs text-gray-400",children:["… ",m.files.previewTruncated]})]}):v.kind==="text"||v.kind==="html"||v.kind==="md"?v.content===void 0?P!==null?s.jsx("p",{className:"text-sm text-red-600 dark:text-red-400",children:P}):s.jsx(pa,{rows:6}):s.jsxs(s.Fragment,{children:[s.jsx(Mg,{language:lO(j1(v.name)),code:v.content,highlight:v.content.length<=S1}),v.truncated&&s.jsxs("p",{className:"mt-1 text-xs text-gray-400",children:["… ",m.files.previewTruncated]})]}):s.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:m.files.previewUnsupported})})]}):s.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[s.jsxs("div",{className:"flex shrink-0 flex-wrap items-center gap-1 border-b border-gray-200 px-3 py-2 dark:border-gray-800",children:[s.jsx("button",{type:"button",disabled:X,onClick:()=>{u("")},className:"rounded px-1.5 py-0.5 text-sm text-gray-600 transition-colors duration-150 hover:bg-gray-100 disabled:opacity-50 dark:text-gray-300 dark:hover:bg-gray-800",children:m.files.root}),Z.map((T,R)=>s.jsxs("span",{className:"flex items-center gap-1",children:[s.jsx("span",{className:"text-gray-300 dark:text-gray-700",children:"/"}),s.jsx("button",{type:"button",disabled:X,onClick:()=>u(Z.slice(0,R+1).join("/")),className:"max-w-32 truncate rounded px-1 py-0.5 text-sm text-gray-600 transition-colors duration-150 hover:bg-gray-100 disabled:opacity-50 dark:text-gray-300 dark:hover:bg-gray-800",children:T})]},R)),s.jsx("span",{className:"flex-1"}),s.jsx(ga,{open:D,setOpen:V,menuClass:"right-0 top-full mt-1 w-max max-w-72 origin-top-right",button:s.jsx(we,{size:"sm",variant:D?"primary":"ghost",onClick:()=>V(T=>!T),children:m.files.details}),children:s.jsxs("div",{className:"px-3.5 py-2.5",children:[s.jsx("p",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:m.files.workspacePath}),s.jsx("p",{className:"mt-1 break-all font-mono text-xs leading-5",children:e.workspace})]})}),s.jsx(we,{size:"sm",variant:"ghost",onClick:()=>_(T=>T+1),children:m.files.refresh}),s.jsxs("label",{className:"inline-flex cursor-pointer items-center rounded-md border border-transparent bg-transparent px-2.5 py-1 text-xs font-medium text-gray-600 transition-colors duration-150 focus-within:ring-2 focus-within:ring-gray-400/30 hover:bg-gray-100 hover:text-gray-900 dark:text-gray-300 dark:hover:bg-gray-800 dark:hover:text-gray-100",children:[s.jsx(Hd,{multiple:!0,onChange:ae,disabled:w}),w?m.common.saving:m.files.upload]})]}),s.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto",children:h?s.jsx("p",{className:"px-3 py-3 text-sm text-red-600 dark:text-red-400",children:h}):f===null?s.jsx(pa,{rows:6}):f.res.entries.length===0?s.jsx("p",{className:"px-3 py-3 text-sm text-gray-400",children:m.files.empty}):s.jsx("ul",{"aria-busy":X,className:`divide-y divide-gray-100 dark:divide-gray-800/60 ${X?"opacity-60":""}`,children:f.res.entries.map(T=>s.jsx("li",{children:s.jsxs("div",{className:"group flex items-center gap-2 px-3 py-1.5 transition-colors duration-150 hover:bg-gray-50 dark:hover:bg-gray-800/50",children:[s.jsxs("button",{type:"button",disabled:X,onClick:()=>{const R=Ju(f.base,T.name);T.kind==="dir"?u(R):$(R)},className:"flex min-w-0 flex-1 items-center gap-2 text-left",title:T.name,children:[s.jsx("span",{className:"shrink-0 text-gray-400","aria-hidden":!0,children:T.kind==="dir"?s.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",children:s.jsx("path",{d:"M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"})}):s.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",children:s.jsx("path",{d:"M6 3h8l4 4v14H6zM14 3v4h4"})})}),s.jsx("span",{className:"min-w-0 flex-1 truncate text-sm",children:T.name})]}),s.jsx("span",{className:"shrink-0 font-mono text-xs text-gray-400 dark:text-gray-500",children:T.kind==="file"?Xo(T.sizeBytes):""}),s.jsx("span",{className:"hidden shrink-0 font-mono text-xs text-gray-400 sm:block dark:text-gray-500",children:T.mtime?ha(T.mtime):""}),T.kind==="file"&&s.jsx("a",{href:Es(e.sessionId,Ju(f.base,T.name),!0),download:T.name,title:m.files.download,className:"shrink-0 rounded p-1 text-gray-300 transition-colors duration-150 hover:bg-gray-100 hover:text-gray-700 group-hover:text-gray-400 dark:hover:bg-gray-800 dark:hover:text-gray-200",children:s.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:s.jsx("path",{d:"M12 3v12m0 0l-4-4m4 4l4-4M4 21h16"})})})]})},T.name))})}),s.jsx(Mn,{open:E!==null,title:m.files.overwriteTitle,tone:"primary",confirmLabel:m.files.upload,onClose:()=>C(null),onConfirm:()=>{E&&q(E.files),C(null)},children:s.jsxs("div",{className:"space-y-2",children:[s.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-300",children:m.files.overwriteConfirm(E?.clashes.length??0)}),s.jsx("ul",{className:"max-h-40 overflow-y-auto rounded-md border border-gray-200 px-3 py-1.5 dark:border-gray-800",children:(E?.clashes??[]).map(T=>s.jsx("li",{className:"truncate py-0.5 font-mono text-xs",title:T,children:T},T))})]})})]})}function oO(){return s.jsx("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor","aria-hidden":!0,children:s.jsx("path",{d:"M2 2l10 10M12 2L2 12",strokeWidth:"1.5",strokeLinecap:"round"})})}function cO({session:e,panel:t}){return t.isDocked?s.jsxs(s.Fragment,{children:[t.open&&s.jsx("div",{onMouseDown:t.startResize,onDoubleClick:t.resetWidth,title:m.files.resizeHandle,className:`w-1.5 shrink-0 cursor-col-resize transition-colors duration-150 hover:bg-brand-300/50 dark:hover:bg-brand-700/40 ${t.resizing?"bg-brand-400/60":"bg-transparent"}`}),s.jsx("div",{ref:t.panelRef,style:{width:t.open?t.width:0},inert:!t.open,className:`relative flex min-h-0 shrink-0 flex-col overflow-hidden ${t.open?"border-l border-gray-200 dark:border-gray-800":""} ${t.resizing?"pointer-events-none":"transition-[width] duration-200"}`,children:s.jsxs("div",{style:{width:t.width},className:"flex h-full min-h-0 flex-col",children:[s.jsxs("div",{className:"flex shrink-0 items-center gap-1 px-3 pt-2",children:[s.jsx("h4",{className:"min-w-0 flex-1 truncate text-sm font-semibold",children:m.files.title}),s.jsx("button",{type:"button",onClick:()=>t.setOpen(!1),title:m.common.close,className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-gray-400 transition-colors duration-150 hover:bg-gray-100 hover:text-gray-700 dark:hover:bg-gray-800 dark:hover:text-gray-200",children:s.jsx(oO,{})})]}),s.jsx("div",{className:"min-h-0 flex-1",children:s.jsx(M1,{session:e,openRequest:t.openRequest,active:t.open})})]})})]}):s.jsx(Ug,{open:t.open,snap:t.sheetSnap,onSnapChange:t.setSheetSnap,onClose:()=>t.setOpen(!1),title:m.files.title,children:s.jsx("div",{className:"flex h-full min-h-0 flex-col",children:s.jsx("div",{className:"min-h-0 flex-1",children:s.jsx(M1,{session:e,openRequest:t.openRequest,active:t.open,onPreviewOpen:()=>t.setSheetSnap("full")})})})})}const Fd=320,yd="penguin.panelWidth",uO=["penguin.filesPanelWidth","penguin.subagentsPanelWidth"];function vd(e){return Math.max(Fd,Math.min(720,Math.round(e*.5)))}function zS(e){return Math.min(vd(e),Math.max(Fd,Math.round(e*.4)))}function dO(){try{const e=Number(localStorage.getItem(yd));if(Number.isFinite(e)&&e>0)return e;let t=null;for(const a of uO){const l=Number(localStorage.getItem(a));Number.isFinite(l)&&l>0&&(t=Math.max(t??0,l)),localStorage.removeItem(a)}return t!==null&&localStorage.setItem(yd,String(Math.round(t))),t}catch{return null}}function fO(){const e=dO();return e===null?zS(window.innerWidth):Math.min(vd(window.innerWidth),Math.max(Fd,Math.round(e)))}let bd=null;const Ah=new Set;function zu(){return bd??=fO(),bd}function Tp(e){if(e!==bd){bd=e;for(const t of Ah)t()}}function mO(e){return Ah.add(e),()=>Ah.delete(e)}function US(){const e=y.useSyncExternalStore(mO,zu,zu),[t,a]=y.useState(!1),l=y.useRef(null);y.useEffect(()=>{if(!t)return;const u=p=>{const h=l.current?.getBoundingClientRect(),g=h?h.right:window.innerWidth;Tp(Math.min(vd(window.innerWidth),Math.max(Fd,g-p.clientX)))},f=()=>{a(!1);try{localStorage.setItem(yd,String(Math.round(zu())))}catch{}};return document.body.style.cursor="col-resize",document.body.style.userSelect="none",window.addEventListener("mousemove",u),window.addEventListener("mouseup",f),()=>{document.body.style.cursor="",document.body.style.userSelect="",window.removeEventListener("mousemove",u),window.removeEventListener("mouseup",f)}},[t]);const o=y.useCallback(u=>{u.preventDefault(),a(!0)},[]),c=y.useCallback(()=>{Tp(zS(window.innerWidth));try{localStorage.removeItem(yd)}catch{}},[]);return y.useEffect(()=>{const u=()=>Tp(Math.min(zu(),vd(window.innerWidth)));return window.addEventListener("resize",u),()=>window.removeEventListener("resize",u)},[]),{width:e,resizing:t,startResize:o,resetWidth:c,panelRef:l}}const E1="(min-width: 1024px)";function pO(e){const[t,a]=y.useState(!1),[l,o]=y.useState("half"),[c,u]=y.useState(null),f=y.useCallback(k=>{k&&o("half"),a(k)},[]),p=US(),[h,g]=y.useState(()=>window.matchMedia(E1).matches);y.useEffect(()=>{u(null)},[e]),y.useEffect(()=>{const k=window.matchMedia(E1),w=j=>g(j.matches);return k.addEventListener("change",w),()=>k.removeEventListener("change",w)},[]);const v=y.useCallback(k=>{o("full"),u({path:k})},[]);return{open:t,setOpen:f,sheetSnap:l,setSheetSnap:o,browsePath:v,openRequest:c,isDocked:h,...p}}function hO({nodes:e,selectedId:t,labelFor:a,onSelect:l}){const o=YI(e);return s.jsx("div",{role:"group","aria-label":m.subagentPanel.topologyLabel,className:"overflow-x-auto",children:s.jsxs("div",{className:"relative",style:{width:o.width,height:o.height},children:[s.jsx("svg",{width:o.width,height:o.height,className:"absolute inset-0 text-gray-300 dark:text-gray-700","aria-hidden":!0,children:o.edges.map(c=>s.jsx("path",{d:c.path,fill:"none",stroke:"currentColor",strokeWidth:"1.5"},`${c.fromId}>${c.toId}`))}),o.nodes.map(({node:c,x:u,y:f})=>{const p=a(c),h=c.sessionId===t,g=c.running?m.subagentPanel.nodeRunning:m.subagentPanel.nodeDone,v=c.description!==null?`${p} · ${g}
172
- ${c.description}`:`${p} · ${g}`;return s.jsxs("button",{type:"button","aria-label":`${p} · ${g}`,"aria-pressed":h,title:v,onClick:()=>l(c),style:{left:u,top:f,width:ed,height:Oo},className:`absolute flex flex-col justify-center gap-0.5 rounded-md border bg-white px-2 text-left transition-colors duration-150 dark:bg-gray-900 ${h?"border-brand-500 ring-1 ring-brand-500":"border-gray-200 hover:border-gray-300 hover:bg-gray-50 dark:border-gray-700 dark:hover:border-gray-600 dark:hover:bg-gray-800/60"}`,children:[s.jsxs("span",{className:"flex w-full min-w-0 items-center gap-1.5",children:[s.jsx(xa,{id:c.agentId??c.sessionId,name:p,size:18}),s.jsx("span",{className:"min-w-0 flex-1 truncate text-xs font-medium text-gray-700 dark:text-gray-300",children:p}),c.running?c.startedMs!==void 0&&s.jsx("span",{className:"shrink-0 font-mono text-[10px] text-gray-400 dark:text-gray-500",children:s.jsx(gi,{sinceMs:c.startedMs})}):c.elapsedMs!==void 0&&s.jsx("span",{className:"shrink-0 font-mono text-[10px] text-gray-400 dark:text-gray-500",children:hn(c.elapsedMs)}),s.jsx(Tl,{state:c.running?"running":"done",size:10})]}),c.description!==null&&s.jsx("span",{className:"w-full truncate pl-[24px] text-[10px] leading-tight text-gray-400 dark:text-gray-500",children:c.description})]},c.sessionId)})]})})}function gO({session:e,model:t,version:a,taskRunning:l,ctx:o,focusRequest:c,taskScope:u}){const{agents:f}=Xt(),{sessions:p}=Bs(),[h,g]=y.useState(null);y.useEffect(()=>{c&&g({sessionId:c.sessionId,origin:c.origin})},[c]);const v=y.useMemo(()=>(u?GI(t,e.sessionId,l,u.anchorSessionId):null)??VI(t,e.sessionId,l),[t,a,e.sessionId,l,u]),k=v.find(F=>F.depth>0)??null,w=h??(k?{sessionId:k.sessionId,origin:k.origin}:null),j=F=>{if(F.depth===0){const A=f.find(P=>P.agentId===e.agentId);return A?A.name?.length?A.name:A.agentId:e.agentId}return vh(F,f,p)??bh(F.sessionId)},E=w!==null&&w.origin.length===0,C=w?v.find(F=>F.sessionId===w.sessionId)??null:null,M=w&&!E?KI(t,w.origin):null,_=C?j(C):w?vh({sessionId:w.sessionId,agentId:M?.meta?.agentId??null},f,p)??m.chat.subagent:"",D=C?.running??!1,V=w?{...o,origin:w.origin,taskRunning:D}:null;return s.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[s.jsxs("div",{className:"shrink-0 border-b border-gray-200 px-3 pb-2 pt-1.5 dark:border-gray-800",children:[s.jsx("p",{className:"mb-1.5 text-[11px] font-semibold uppercase tracking-wide text-gray-500 dark:text-gray-400",children:m.subagentPanel.topologyLabel}),v.length>1?s.jsx("div",{className:"max-h-48 overflow-y-auto",children:s.jsx(hO,{nodes:v,selectedId:w?.sessionId??null,labelFor:j,onSelect:F=>g({sessionId:F.sessionId,origin:F.origin})})}):s.jsx("p",{className:"py-1 text-xs text-gray-400 dark:text-gray-500",children:m.subagentPanel.empty})]}),w===null?s.jsx("div",{className:"min-h-0 flex-1",children:s.jsx(Nr,{title:m.subagentPanel.empty})}):E?s.jsx("div",{className:"flex min-h-0 flex-1 items-center justify-center p-4",children:s.jsx("p",{className:"text-sm text-gray-400 dark:text-gray-500",children:m.subagentPanel.mainSessionNote})}):M===null?s.jsx("div",{className:"min-h-0 flex-1",children:s.jsx(Nr,{title:m.subagentPanel.empty})}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex shrink-0 items-center gap-2 border-b border-gray-100 px-3 py-1.5 dark:border-gray-800/60",children:[s.jsx(xa,{id:M.meta?.agentId??w.sessionId,name:_,size:16}),s.jsx("span",{className:"min-w-0 truncate text-xs font-semibold text-gray-700 dark:text-gray-300",children:_}),s.jsx("span",{title:w.sessionId,className:"shrink-0 font-mono text-[10px] text-gray-400 dark:text-gray-500",children:bh(w.sessionId)}),D&&s.jsx(Tl,{state:"running",size:10,label:m.chat.subagentRunning})]}),s.jsx("div",{className:"min-h-0 flex-1",children:V&&s.jsx(oS,{items:M.items,version:a,ctx:V},w.sessionId)})]})]})}function xO(){return s.jsx("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor","aria-hidden":!0,children:s.jsx("path",{d:"M2 2l10 10M12 2L2 12",strokeWidth:"1.5",strokeLinecap:"round"})})}function yO({session:e,panel:t,model:a,version:l,taskRunning:o,ctx:c}){const u=s.jsx(gO,{session:e,model:a,version:l,taskRunning:o,ctx:c,focusRequest:t.focusRequest,taskScope:t.taskScope},e.sessionId);return t.isDocked?s.jsxs(s.Fragment,{children:[t.open&&s.jsx("div",{onMouseDown:t.startResize,onDoubleClick:t.resetWidth,title:m.files.resizeHandle,className:`w-1.5 shrink-0 cursor-col-resize transition-colors duration-150 hover:bg-brand-300/50 dark:hover:bg-brand-700/40 ${t.resizing?"bg-brand-400/60":"bg-transparent"}`}),s.jsx("div",{ref:t.panelRef,style:{width:t.open?t.width:0},inert:!t.open,className:`relative flex min-h-0 shrink-0 flex-col overflow-hidden ${t.open?"border-l border-gray-200 dark:border-gray-800":""} ${t.resizing?"pointer-events-none":"transition-[width] duration-200"}`,children:s.jsxs("div",{style:{width:t.width},className:"flex h-full min-h-0 flex-col",children:[s.jsxs("div",{className:"flex shrink-0 items-center gap-1 px-3 pt-2",children:[s.jsx("h4",{className:"min-w-0 flex-1 truncate text-sm font-semibold",children:m.subagentPanel.title}),s.jsx("button",{type:"button",onClick:()=>t.setOpen(!1),title:m.common.close,className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-gray-400 transition-colors duration-150 hover:bg-gray-100 hover:text-gray-700 dark:hover:bg-gray-800 dark:hover:text-gray-200",children:s.jsx(xO,{})})]}),s.jsx("div",{className:"min-h-0 flex-1",children:u})]})})]}):s.jsx(Ug,{open:t.open,snap:t.sheetSnap,onSnapChange:t.setSheetSnap,onClose:()=>t.setOpen(!1),title:m.subagentPanel.title,children:s.jsx("div",{className:"flex h-full min-h-0 flex-col",children:s.jsx("div",{className:"min-h-0 flex-1",children:u})})})}const A1="(min-width: 1024px)";function vO(){return{sessionId:null,taskCount:0,autoOpenedAt:null}}function bO(e,t){const a=t.sessionId!==e.sessionId,l=!a&&t.taskCount<e.taskCount;return(a||t.taskCount!==e.taskCount)&&(e.sessionId=t.sessionId,e.taskCount=t.taskCount,e.autoOpenedAt=l?t.taskCount:null),t.liveSpawn&&e.autoOpenedAt!==e.taskCount?(e.autoOpenedAt=e.taskCount,"autoOpen"):null}function kO(e){const[t,a]=y.useState(!1),[l,o]=y.useState("half"),[c,u]=y.useState(null),[f,p]=y.useState(null),h=y.useCallback(j=>{j&&(o("half"),p(null)),a(j)},[]),g=US(),[v,k]=y.useState(()=>window.matchMedia(A1).matches);y.useEffect(()=>{u(null),p(null)},[e]),y.useEffect(()=>{const j=window.matchMedia(A1),E=C=>k(C.matches);return j.addEventListener("change",E),()=>j.removeEventListener("change",E)},[]);const w=y.useCallback((j,E)=>{o("full"),p({anchorSessionId:E[0]??j}),u({sessionId:j,origin:E})},[]);return{open:t,setOpen:h,sheetSnap:l,setSheetSnap:o,focusSubagent:w,focusRequest:c,taskScope:f,isDocked:v,...g}}const wO=300;function SO(e){const t=xn().user?.userId??null,a=t&&e?MS(t,e):null,l=y.useMemo(()=>a?Fs(a):{},[a]),o=y.useRef(l.text??""),c=y.useRef(l.handoffAgentId??null),u=y.useRef(l.switchModelRef??null),f=y.useRef(l.skills??[]),p=y.useRef(null),h=y.useCallback(()=>{p.current!==null&&(window.clearTimeout(p.current),p.current=null)},[]),g=y.useCallback(()=>{if(h(),!a)return;const C=o.current,M=c.current,_=u.current,D=f.current;if(!C&&!M&&!_&&D.length===0){nc(a);return}const V={text:C};M&&(V.handoffAgentId=M),_&&(V.switchModelRef=_),D.length>0&&(V.skills=D),Jr(a,V)},[h,a]);y.useEffect(()=>(o.current=l.text??"",c.current=l.handoffAgentId??null,u.current=l.switchModelRef??null,f.current=l.skills??[],()=>{p.current!==null&&(window.clearTimeout(p.current),p.current=null,g())}),[l,g]);const v=y.useCallback(C=>{o.current=C,h(),p.current=window.setTimeout(()=>{p.current=null,g()},wO)},[h,g]),k=y.useCallback(C=>{c.current=C,g()},[g]),w=y.useCallback(C=>{u.current=C,g()},[g]),j=y.useCallback(C=>{f.current=C,g()},[g]),E=y.useCallback(()=>{h(),o.current="",f.current=[],c.current=null,u.current=null,a&&nc(a)},[h,a]);return{initial:l,onTextChange:v,onHandoffTargetChange:k,onPendingModelChange:w,onSkillsChange:j,discard:E}}function Mp(e){const t=e.lastIndexOf("-");if(t<=0)return null;const a=Number.parseInt(e.slice(t+1),10);return!Number.isInteger(a)||a<0?null:{epoch:e.slice(0,t),seq:a}}const Ep=200,jO=100,CO=1e6;function NO(e){const t=e.now??(()=>Date.now()),a=new Set,l=new Map;let o=Lo(a),c=!1,u="buffering",f=[],p=null,h=null,g=0,v=!1,k=[],w=new Map,j=0,E=null,C=null;const M={hasMore:!1,loading:!1,error:null};let _=0;const D=()=>{k=[],w=new Map,j=0,E=null,C=null,M.hasMore=!1,M.loading=!1,M.error=null,_=0},V=I=>{D(),I!==void 0&&(E=I.before??null,C=I.before??null,M.hasMore=I.before!==void 0,_=I.earlierTurns)},F=()=>{l.size!==0&&(l.clear(),e.onPendingChange())},A=(I,B)=>{if(sg(I)&&I.payload.type==="approval_decision"&&l.delete(pi(I.origin,I.payload.tool_call_id))&&e.onPendingChange(),B&&!id(I.payload)&&KM(B,I)){Gw(o,I);return}od(o,I,t())},P=I=>{switch(I.type){case"approval_request":{const B=I.toolCall.payload.tool_call_id,$={toolCall:I.toolCall};if(I.origin&&($.origin=I.origin),l.set(pi(I.origin,B),$),!zM(o,I.origin,B)){const G={...I.toolCall};I.origin&&I.origin.length>0?G.origin=[...I.origin]:delete G.origin,od(o,G,t()),e.onModelChange()}e.onPendingChange();return}case"task_state":{p=I.state,e.onTaskState(I.state),e.onQueuedFollowUps?.(I.queued??0),e.onPendingSteering?.(I.pendingSteering??[]),I.state==="idle"&&(OM(o),F(),e.onModelChange());return}case"resync_required":{Q();return}case"credentials_updated":{o.lastAuthFailureMs=null,e.onModelChange();return}case"hello":return}},Q=async()=>{g+=1,u="buffering",f=[],F(),await O(g,Lo(a),{page:{kind:"tail",limit:Ep},splice:k.length>0})},K=(I,B)=>{const $=Mp(B.cursor);if(!$)return I;const G=h===null?null:Mp(h);if(G!==null&&G.epoch!==$.epoch)return I;const q=[],ae=[];for(const X of I){const T=X.id===null?null:Mp(X.id);T!==null&&T.epoch===$.epoch&&T.seq<=$.seq?(X.kind!=="omni"||!id(X.msg.payload))&&q.push(X):ae.push(X)}const Z=B.fragments.map(X=>({kind:"omni",msg:X,id:null,seeded:!0}));return[...q,...Z,...ae]},O=async(I,B,$={})=>{try{let G=await e.loadMessages($.page);if(c||I!==g)return;if($.splice===!0){const H=G.page?.before??null;if(!(G.page!==void 0&&H!==null&&H===C))if(G.page!==void 0&&H===null)V(G.page);else{if(G=await e.loadMessages(),c||I!==g)return;V(void 0)}}else $.page!==void 0?V(G.page):V(void 0);const{messages:q,live:ae,serverNowMs:Z}=G;B&&(o=B);const X=o;G.page!==void 0&&eb(X.stats,G.page.prior),tb(X,q,t(),Z??null);const T=WM(q,100),R=ae!==void 0?K(f,ae):f;f=[];for(let H=0;H<R.length;H+=1){const S=R[H];if(S.kind==="omni"?A(S.msg,T):P(S.ev),c)return;if(I!==g){f.push(...R.slice(H+1).filter(U=>U.kind!=="omni"||!U.seeded));return}}u="live",p==="idle"&&nb(X),v=!1,e.onError(null),e.onLoading(!1),e.onModelChange()}catch(G){if(c||I!==g)return;v=!0,e.onLoading(!1),e.onError(G instanceof Error?G.message:String(G))}};return{get model(){return o},get prefixItems(){return k},get prefixSubagents(){return w},get outlineOffset(){return _},get older(){return M},get pendingApprovals(){return l},load:()=>(g+=1,O(g,void 0,{page:{kind:"tail",limit:Ep}})),retry:async()=>{c||!v||(e.onError(null),e.onLoading(!0),g+=1,await O(g,Lo(a),{page:{kind:"tail",limit:Ep}}))},loadOlder:async()=>{if(c||u!=="live"||v||M.loading||!M.hasMore||E===null)return;const I=g;M.loading=!0,M.error=null,e.onModelChange();try{const B=await e.loadMessages({kind:"before",cursor:E,limit:jO});if(c||I!==g)return;if(B.page===void 0)throw new Error("windowed history not supported");j+=1;const $=Lo(a);$.nextItemId=-j*CO,eb($.stats,B.page.prior),tb($,B.messages,t(),null),nb($),k=[...$.items,...k];const G=new Map($.subagents);for(const[q,ae]of w)G.set(q,ae);w=G,E=B.page.before??null,M.hasMore=B.page.before!==void 0,_=B.page.earlierTurns}catch(B){if(c||I!==g)return;M.error=B instanceof Error?B.message:String(B)}finally{!c&&I===g&&(M.loading=!1,e.onModelChange())}},handleOmni:(I,B=null)=>{if(!c){if(B!==null&&(h=B),u==="buffering"){f.push({kind:"omni",msg:I,id:B});return}A(I,null),e.onModelChange()}},handleServer:(I,B=null)=>{if(!c){if(B!==null&&(h=B),I.type==="session_title"){e.onSessionTitle?.(I.sessionId,I.title);return}if(I.type==="session_created"){e.onSessionCreated?.(I.sessionId);return}if(I.type==="goal_started"||I.type==="goal_round"||I.type==="goal_finished"){e.onGoalEvent?.(I);return}if(u==="buffering"){I.type==="task_state"&&(p=I.state,e.onTaskState(I.state),e.onQueuedFollowUps?.(I.queued??0),e.onPendingSteering?.(I.pendingSteering??[])),f.push({kind:"server",ev:I,id:B});return}P(I)}},markLocalDecision:I=>{DM(o,I)},resolveApproval:I=>{l.delete(I)&&e.onPendingChange()},dispose:()=>{c=!0}}}const TO=120,MO=new Map,EO=[],AO=new Map,RO={hasMore:!1,loading:!1,error:null};function _O(e,t,a,l){const[o,c]=y.useState(0),[u,f]=y.useState(!0),[p,h]=y.useState(t),[g,v]=y.useState(0),[k,w]=y.useState([]),[j,E]=y.useState(null),[C,M]=y.useState(0),[_,D]=y.useState(null),V=y.useCallback(Z=>{D(X=>Z.type==="goal_started"?{objective:Z.objective,status:"active",budget:Z.budget,used:0,rounds:0}:Z.type==="goal_round"?{objective:X?.objective??"",status:"active",budget:Z.budget,used:Z.used,rounds:Z.round}:{objective:X?.objective??"",status:Z.outcome,budget:X?.budget??-1,used:Z.used,rounds:Z.rounds})},[]),F=y.useRef(a);F.current=a;const A=y.useRef(l);A.current=l;const P=y.useRef(null),Q=y.useRef(null);Q.current===null&&(Q.current=Lo());const K=y.useRef(null),O=y.useRef(null),z=y.useRef(0),I=y.useCallback(()=>{if(K.current!==null||O.current!==null)return;const Z=()=>{z.current=Date.now(),c(T=>T+1)},X=z.current+TO-Date.now();if(X>0){O.current=window.setTimeout(()=>{O.current=null,Z()},X);return}K.current=requestAnimationFrame(()=>{K.current=null,Z()})},[]);y.useEffect(()=>{if(!e){P.current?.dispose(),P.current=null,h("idle"),v(0),w([]),f(!1),E(null),D(null),M(H=>H+1),c(H=>H+1);return}c(H=>H+1),f(!0),E(null),h(t),D(null),v(0),w([]),M(H=>H+1);let Z=!1;const X=()=>{mN(e).then(H=>{Z||!H.goal||H.goal.status!=="active"||D(S=>S??H.goal)}).catch(()=>{})},T=NO({loadMessages:H=>fN(e,H),onTaskState:h,onQueuedFollowUps:v,onPendingSteering:w,onLoading:f,onError:E,onModelChange:I,onPendingChange:()=>M(H=>H+1),onSessionTitle:(H,S)=>F.current?.(H,S),onSessionCreated:()=>A.current?.(),onGoalEvent:V});P.current=T;const R=AT(e,{onOmniMessage:T.handleOmni,onServerEvent:T.handleServer,onOpen:X,onError:H=>{H&&Yu().catch(()=>{})}});return T.load(),()=>{Z=!0,T.dispose(),R.close(),K.current!==null&&(cancelAnimationFrame(K.current),K.current=null),O.current!==null&&(window.clearTimeout(O.current),O.current=null)}},[e]);const B=y.useCallback(Z=>{P.current?.markLocalDecision(Z)},[]),$=y.useCallback(Z=>{P.current?.resolveApproval(Z)},[]),G=y.useCallback(()=>{P.current?.retry()},[]),q=y.useCallback(()=>{P.current?.loadOlder()},[]),ae=y.useCallback(()=>{const Z=P.current?.model;Z&&Z.lastAuthFailureMs!==null&&(Z.lastAuthFailureMs=null,c(X=>X+1))},[]);return{model:P.current?.model??Q.current,prefixItems:P.current?.prefixItems??EO,prefixSubagents:P.current?.prefixSubagents??AO,outlineOffset:P.current?.outlineOffset??0,older:P.current?.older??RO,loadOlder:q,version:o,loading:u,taskState:p,queuedFollowUps:g,pendingSteering:k,lastAuthFailureMs:(P.current?.model??Q.current).lastAuthFailureMs,dismissModelAuthDead:ae,pendingApprovals:P.current?.pendingApprovals??MO,markLocalDecision:B,resolveApproval:$,error:j,retry:G,goal:_}}const No={tokens:"M4 6c0-1.7 3.6-3 8-3s8 1.3 8 3-3.6 3-8 3-8-1.3-8-3zm0 0v12c0 1.7 3.6 3 8 3s8-1.3 8-3V6M4 12c0 1.7 3.6 3 8 3s8-1.3 8-3",cost:"M12 21a9 9 0 1 0 0-18 9 9 0 0 0 0 18zm0-15v12m2.6-9.3c-.5-.8-1.5-1.2-2.6-1.2-1.5 0-2.7.8-2.7 2 0 2.7 5.4 1.3 5.4 4 0 1.2-1.2 2-2.7 2-1.2 0-2.2-.5-2.7-1.4",elapsed:"M12 21a9 9 0 1 0 0-18 9 9 0 0 0 0 18zm0-14v5l3 2",folder:"M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z",services:"M3 5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5zm0 11a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-3zM7 6.5h.01M7 17.5h.01"},IO=15e3,LO=200;function Ap({icon:e,value:t,label:a}){return s.jsxs("span",{title:a,className:"flex shrink-0 items-center gap-1 font-mono text-xs text-gray-500 dark:text-gray-400",children:[s.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:s.jsx("path",{d:e})}),t]})}function OO({sessionId:e}){return s.jsxs("div",{children:[s.jsx("p",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:m.chat.sessionIdLabel}),s.jsxs("div",{className:"flex items-start gap-1.5",children:[s.jsx("span",{className:"min-w-0 flex-1 break-all font-mono text-xs leading-5",children:e}),s.jsx(uc,{text:e,label:m.chat.copySessionId,showCopiedText:!0,className:"flex shrink-0 items-center gap-1 rounded p-0.5 text-xs text-gray-400 transition-colors duration-150 hover:bg-gray-100 hover:text-gray-600 dark:text-gray-500 dark:hover:bg-gray-800 dark:hover:text-gray-300"})]})]})}function DO({stats:e,taskOpen:t,taskStartLocalMs:a}){const[l,o]=y.useState(()=>Date.now());return y.useEffect(()=>{if(!t)return;o(Date.now());const c=setInterval(()=>o(Date.now()),1e3);return()=>clearInterval(c)},[t]),t?s.jsx(s.Fragment,{children:Sw(MM(e,t,a,l))}):s.jsx(s.Fragment,{children:hn(e.sessionElapsedMs)})}function zO(e,t){const a=e.stats;return{tokensText:Ct(a.sessionTotal+a.subagentTotal),costText:t.costText,costUncosted:t.costUncosted,elapsedNode:s.jsx(DO,{stats:a,taskOpen:e.taskOpen,taskStartLocalMs:e.taskStartLocalMs})}}const Ia="new",UO=e=>e!==null&&e.startsWith("draft-")?e:null,R1=100;function $O(){const e=Wn(),t=ya(),a=ew(),{user:l}=xn(),{currency:o}=Ps(),{currentProject:c,currentAgent:u,setCurrentAgentId:f,reloadAgents:p,agents:h}=Xt(),g=c?.projectId??null,v=u?.agentId??null,{sessions:k,loading:w,reload:j,add:E,replace:C,setStatus:M,setTitle:_}=Bs(),D=y.useRef(DS()),V=y.useRef(null),[,F]=y.useState(0),[A,P]=y.useState(!1),[Q,K]=y.useState(!1),[O,z]=y.useState(!1),[I,B]=y.useState(null),[$,G]=y.useState([]),[q,ae]=y.useState(null),[Z,X]=y.useState(null),[T,R]=y.useState(null),[H,S]=y.useState(""),U=a.sessionId??null,ee=pO(U),ie=kO(U),de=y.useRef(null),me=()=>{de.current!==null&&(window.clearTimeout(de.current),de.current=null)};y.useEffect(()=>me,[]);const ye=(he,Le)=>{he.setOpen(!1),he.open&&he.isDocked?de.current=window.setTimeout(()=>{de.current=null,Le(!0)},LO):Le(!0)},te={...ee,setOpen:he=>{me(),he?ye(ie,ee.setOpen):ee.setOpen(!1)}},be={...ie,setOpen:he=>{me(),he?ye(ee,ie.setOpen):ie.setOpen(!1)}},Re=UO(U),Fe=U===Ia||Re!==null,ce=Fe?null:k.find(he=>he.sessionId===U)??null,Ve=ce?{provider:ce.provider,modelId:ce.modelId}:null;Er(ce?ce.title??m.chat.defaultSessionTitle:m.nav.chat);const je=_O(ce?.sessionId??null,ce?.status??"idle",_,()=>{j()}),{initial:wt,onTextChange:an,onHandoffTargetChange:rn,onPendingModelChange:sn,onSkillsChange:Ut,discard:At}=SO(ce?.sessionId??null),fn=y.useMemo(()=>je.prefixItems.length>0?[...je.prefixItems,...je.model.items]:je.model.items,[je.version,U]),st=y.useMemo(()=>W8(fn),[je.version,U]),nn=y.useMemo(()=>kL(fn),[je.version,U]),pe=y.useMemo(()=>je.prefixItems.length>0||je.prefixSubagents.size>0?{...je.model,items:[...fn],subagents:new Map([...je.prefixSubagents,...je.model.subagents])}:je.model,[je.version,U]),Se=y.useRef(null),De=ML(Se,je.version),ze=ce?.sessionId??null,Ue=ce?.agentId??null;y.useEffect(()=>{ze&&Ue&&f(Ue)},[ze,Ue,f]),y.useEffect(()=>{Fe&&(me(),ee.setOpen(!1),ie.setOpen(!1))},[Fe]);const W=y.useRef(vO()),ge=FI(je.model.items),Ne=je.taskState!=="idle"&&WI(je.model);y.useEffect(()=>{bO(W.current,{sessionId:ze,taskCount:ge,liveSpawn:Ne})==="autoOpen"&&ie.isDocked&&!ie.open&&!ee.open&&ie.setOpen(!0)},[ze,ge,Ne]);const[Te,Pe]=y.useState([]);y.useEffect(()=>{if(Pe(Le=>Le.length>0?[]:Le),!g||!Ue)return;let he=!1;return Cd(g,Ue).then(Le=>{he||Pe(Le.skills)}).catch(()=>{}),()=>{he=!0}},[g,Ue]);const[We,tt]=y.useState("");y.useEffect(()=>{if(tt(""),!g||!Ue)return;let he=!1;return jl(g,Ue).then(Le=>{he||tt(Le.config.model?.thinkingLevel??"")}).catch(()=>{}),()=>{he=!0}},[g,Ue]);const[it,Ce]=y.useState(null);y.useEffect(()=>{if(Fe||!U||w||k.some(Le=>Le.sessionId===U))return;let he=!1;return ep(U).then(Le=>{he||E(Le.session)},()=>{he||Ce(U)}),()=>{he=!0}},[Fe,U,w,k,E]),y.useEffect(()=>{if(w||Fe||U&&k.some(Le=>Le.sessionId===U)||U&&it!==U)return;const he=ow(k);e(he?`/chat/${he.sessionId}`:`/chat/${Ia}`,{replace:!0})},[w,Fe,U,it,k,e]),y.useEffect(()=>{ce&&M(ce.sessionId,je.taskState)},[je.taskState,ce,M]);const Oe=y.useRef({id:ze,state:"idle"});y.useEffect(()=>{const he=Oe.current,Le=he.id===ze;Oe.current={id:ze,state:Le?je.taskState:"idle"},!(!Le||ze===null)&&he.state!=="idle"&&je.taskState==="idle"&&(j(),p())},[je.taskState,ze,j,p]);const Ke=y.useRef(new Map);y.useEffect(()=>{V.current=null,S(""),Ke.current=new Map,G([]),X(null),R(null)},[U]);const vt=y.useCallback(async he=>{const Le=ce?.sessionId??null,ot=Ke.current,rt=Le===null?[]:he.filter(Vt=>!ot.has(Vt));if(Le!==null&&rt.length>0)for(let Vt=0;Vt<rt.length;Vt+=R1){const vn=rt.slice(Vt,Vt+R1),sa=MN(Le,vn).then(Fn=>new Set(Fn.existing)).catch(()=>null);for(const Fn of vn){const Xn=sa.then(_n=>_n?.has(Fn)??!1);ot.set(Fn,Xn),Xn.then(_n=>{ot.get(Fn)===Xn&&(_n?ot.set(Fn,!0):ot.delete(Fn))})}}const Rt=new Set;return await Promise.all(he.map(async Vt=>{const vn=ot.get(Vt);(vn===!0||vn instanceof Promise&&await vn)&&Rt.add(Vt)})),Rt},[ce?.sessionId]);y.useEffect(()=>{if(!g||!ce||V.current===ce.sessionId&&je.taskState!=="idle"&&!Q)return;let he=!1;return _k(g,{groupBy:"session",agentId:ce.agentId}).then(Le=>{if(he)return;V.current=ce.sessionId;const ot=Le.groups.find(rt=>rt.key===ce.sessionId);GL(D.current,ce.sessionId,ot??null),X(ot?{cacheRead:ot.cacheRead,cacheWrite:ot.cacheWrite,output:ot.output}:null),F(rt=>rt+1)}).catch(()=>{}),()=>{he=!0}},[g,ce,je.taskState,Q]);const xt=$.filter(he=>he.running).length,St=je.taskState!=="idle"||xt>0||Q&&$.length>0;y.useEffect(()=>{if(!ze)return;let he=!1;const Le=()=>{Lv(ze).then(rt=>{he||G(rt.processes)}).catch(()=>{})};if(Le(),!St)return()=>{he=!0};const ot=window.setInterval(Le,IO);return()=>{he=!0,window.clearInterval(ot)}},[ze,je.taskState,St]);const ln=y.useCallback(async he=>{if(!(!ce||q!==null)){ae(he);try{await xN(ce.sessionId,he)}catch(Le){Le instanceof na&&Le.status===404||Qe(Ie(Le))}finally{ae(null),Lv(ce.sessionId).then(Le=>G(Le.processes)).catch(()=>{})}}},[ce,q]);y.useEffect(()=>{if(!Q||!ze)return;let he=!1;return ep(ze).then(Le=>{he||R(Le.session.tracePath??null)}).catch(()=>{}),()=>{he=!0}},[Q,ze]),y.useEffect(()=>{if(!g)return;let he=!1;return B(null),(async()=>{try{const Le=await mi(g);if(he)return;B(Le);const{prefs:ot}=await Ph();if(he||ot.credentialGuideSeen)return;const rt=Le.models.find(Vt=>jt(Vt,Le.defaultModel));(!Le.defaultModel||!rt?.credential?.apiKeyMasked)&&P(!0),jd({credentialGuideSeen:!0}).catch(()=>{})}catch{}})(),()=>{he=!0}},[g]),y.useEffect(()=>{if(!g)return;let he=!1;const Le=ot=>{const rt=LS(ot,g);!rt||rt.defaultModel===void 0||(B(null),mi(g).then(Rt=>{he||B(Rt)}).catch(()=>{}))};return window.addEventListener(ac,Le),()=>{he=!0,window.removeEventListener(ac,Le)}},[g]);const $t=y.useCallback(async(he,Le)=>{Le!==he&&(await j(),e(`/chat/${Le}`,{replace:!0}))},[j,e]),Oa=y.useCallback(async(he,Le)=>{if(!ce)return!1;try{const ot=await Io(ce.sessionId,{input:he,...Le?{goal:Le}:{},...H?{thinkingLevel:H}:{}});return At(),await $t(ce.sessionId,ot.sessionId),!0}catch(ot){return Qe(Ie(ot,{modelId:ce.modelId})),!1}},[ce,H,At,$t]),aa=y.useCallback(async(he,Le)=>{if(!g||!ce)return!1;const ot=await ep(ce.sessionId).then(Vt=>Vt.session.tracePath).catch(()=>{}),rt={type:"text",text:g8({sessionId:ce.sessionId,...ce.title!==void 0?{sessionTitle:ce.title}:{},...ot!==void 0?{tracePath:ot}:{},workspace:ce.workspace,prevProvider:ce.provider,prevModelId:ce.modelId})};let Rt=null;try{const Vt=await qp(g,ce.agentId,{provider:he.provider,modelId:he.modelId,workspace:ce.workspace,approvalMode:ce.approvalMode});Rt=Vt.session.sessionId;const vn=await Io(Rt,{input:[rt,...Le]});return E(Vt.session),At(),e(`/chat/${vn.sessionId}`),!0}catch(Vt){return Rt&&td(Rt).catch(()=>{}),Qe(Ie(Vt,{modelId:he.modelId})),!1}},[g,ce,E,At,e]),En=y.useCallback(async(he,Le)=>{if(!g||!u||!ce)return!1;const ot={type:"text",text:h8({agentId:u.agentId,...u.name!==void 0?{agentName:u.name}:{},sessionId:ce.sessionId,workspace:ce.workspace,...ce.title!==void 0?{sessionTitle:ce.title}:{}})};let rt=null;try{const Rt=await qp(g,he.agentId,{approvalMode:ce.approvalMode});rt=Rt.session.sessionId;const Vt=await Io(rt,{input:[ot,...Le]});return E(Rt.session),At(),e(`/chat/${Vt.sessionId}`),!0}catch(Rt){return rt&&td(rt).catch(()=>{}),Qe(Ie(Rt,I?.defaultModel?{modelId:I.defaultModel.modelId}:{})),!1}},[g,u,ce,E,At,e,I]),An=y.useCallback(async()=>{ce&&await hN(ce.sessionId).catch(()=>{})},[ce]),ar=y.useCallback(async he=>{if(!ce)return!1;try{const Le=await Io(ce.sessionId,{input:he,queueIfBusy:!0,...H?{thinkingLevel:H}:{}});return At(),await $t(ce.sessionId,Le.sessionId),!0}catch(Le){return Qe(Ie(Le,{modelId:ce.modelId})),!1}},[ce,H,At,$t]),Yn=y.useCallback(async(he,Le=[],ot=[])=>{if(!ce)return"failed";try{return await yN(ce.sessionId,{text:he,...Le.length>0?{images:Le}:{},...ot.length>0?{files:ot}:{}}),At(),"queued"}catch(rt){return rt instanceof na&&rt.status===409?"not_running":(Qe(Ie(rt,{modelId:ce.modelId})),"failed")}},[ce,At]),ts=y.useCallback(async(he,Le,ot)=>{if(!ce)return;je.markLocalDecision(he);const rt=pi(ot,he);try{await pN(ce.sessionId,he,{decision:Le}),je.resolveApproval(rt)}catch(Rt){Rt instanceof na&&Rt.status===404&&je.resolveApproval(rt)}},[ce,je]),Pn=y.useCallback(he=>{!ce||O||(z(!0),Vp(ce.sessionId,{approvalMode:he}).then(Le=>C(Le.session)).catch(Le=>{Qe(Ie(Le))}).finally(()=>z(!1)))},[ce,O,C]),ba=y.useCallback(async()=>{if(ce)try{const he=await vN(ce.sessionId);await $t(ce.sessionId,he.sessionId)}catch(he){Qe(Ie(he,{modelId:ce.modelId}))}},[ce,$t]),Da=y.useCallback(()=>{l&&g&&Ci(l.userId,g),e(`/chat/${Ia}`)},[l,g,e]),gr=y.useCallback(()=>{e("/models")},[e]),Bn=I?.models.find(he=>jt(he,Ve))?.pricing,qt={pendingApprovals:je.pendingApprovals,onApprove:ts,origin:[],taskRunning:je.taskState!=="idle",taskCost:he=>Jv(he.tokensByBucket,Bn),onRetryNow:()=>{ce&&gN(ce.sessionId).catch(()=>{})},onGiveUp:()=>{An()},onOpenFile:he=>{te.setOpen(!0),te.browsePath(he)},onOpenSubagent:(he,Le)=>{be.setOpen(!0),be.focusSubagent(he,[...Le,he])},workspace:ce?.workspace??null,statFiles:vt},Zt=[...je.pendingApprovals.keys()].some(he=>!he.startsWith(" "));if(!g||!v)return s.jsx("div",{className:"p-6",children:s.jsx(en,{className:"h-6 w-64"})});const Hn=je.model.taskOpen?Jv({cacheRead:je.model.stats.taskCacheRead,cacheWrite:je.model.stats.taskCacheWrite,output:je.model.stats.taskOutput},Bn):null,on=zO(je.model,WL(D.current,{sessionId:ce?.sessionId??null,taskCount:ge,taskOpen:je.model.taskOpen,loading:je.loading,liveUsd:Hn,currency:o})),Rr=Z?Z.cacheRead+Z.cacheWrite:0,xr=Z&&Rr>0?`${Math.round(100*Z.cacheRead/Rr)}%`:null,rr=I?.models.find(he=>jt(he,Ve)),Qn=rr?.contextWindow,sr=rr?.vision!==!1,ka=ce!==null&&!je.loading&&!je.error&&je.model.items.length===0,ra=I?.updatedAt!==void 0?Date.parse(I.updatedAt):NaN,za=RM(je.lastAuthFailureMs,Number.isFinite(ra)?ra:null),yn=ce&&s.jsx(bS,{status:je.taskState,modelAuthDead:za,onOpenModels:gr,onRetryModelAuth:je.dismissModelAuthDead,onNewSession:Da,onSend:Oa,onSteer:Yn,steeringDeliveredCount:je.model.items.filter(he=>he.kind==="user_steering").length,pendingSteering:je.pendingSteering,onQueueFollowUp:ar,queuedFollowUps:je.queuedFollowUps,onStop:An,onCompact:ba,modelRef:Ve,...I!==null?{models:I.models}:{},...I?.defaultModel!==void 0?{defaultModel:I.defaultModel}:{},onSwitchModel:aa,turnThinkingLevel:H||We,onChangeTurnThinkingLevel:S,...Qn!==void 0?{contextWindow:Qn}:{},contextNow:je.model.stats.contextNow,contextStale:je.model.stats.contextStale,vision:sr,approvalMode:ce.approvalMode,onChangeApprovalMode:Pn,modeSaving:O,autoFocus:!0,agents:h,currentAgentId:ce.agentId,skills:Te,...wt.skills&&wt.skills.length>0?{initialSkills:wt.skills}:{},onSkillsChange:Ut,onHandoff:En,initialText:wt.text??"",onTextChange:an,history:st,...wt.handoffAgentId?{initialHandoffTargetId:wt.handoffAgentId}:{},onHandoffTargetChange:rn,...wt.switchModelRef?{initialPendingModelRef:wt.switchModelRef}:{},onPendingModelChange:sn});return s.jsxs("div",{className:"flex h-full flex-col bg-white dark:bg-gray-950",children:[ce&&s.jsxs("div",{className:"flex shrink-0 items-center gap-2.5 border-b border-gray-200 px-3 py-2 md:px-4 dark:border-gray-800",children:[s.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[s.jsx("h1",{className:"flex min-w-0 text-[15px] font-semibold",children:s.jsx(ic,{text:ce.title??m.chat.defaultSessionTitle})}),je.taskState==="running"&&s.jsxs("span",{title:m.chat.statusRunning,className:"flex shrink-0 items-center gap-1.5 text-xs text-gray-500 dark:text-gray-400",children:[s.jsx("span",{className:"h-1.5 w-1.5 animate-pulse rounded-full bg-emerald-500"}),s.jsx("span",{className:"hidden sm:inline",children:m.chat.statusRunning})]})]}),s.jsxs("button",{type:"button","aria-expanded":be.open,onClick:()=>be.setOpen(!be.open),title:m.chat.openAgents,"aria-label":m.chat.openAgents,className:`flex h-7 shrink-0 items-center gap-1.5 rounded-md px-2 text-xs font-medium transition-colors duration-150 ${be.open?"bg-gray-100 text-gray-800 dark:bg-gray-800 dark:text-gray-200":"text-gray-500 hover:bg-gray-100 hover:text-gray-800 dark:text-gray-400 dark:hover:bg-gray-800 dark:hover:text-gray-200"}`,children:[s.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7","aria-hidden":!0,children:[s.jsx("circle",{cx:"5",cy:"12",r:"2.5"}),s.jsx("circle",{cx:"19",cy:"5.5",r:"2.5"}),s.jsx("circle",{cx:"19",cy:"18.5",r:"2.5"}),s.jsx("path",{d:"M7.4 11 16.7 6.6M7.4 13l9.3 4.4"})]}),s.jsx("span",{className:"hidden lg:inline",children:m.chat.openAgents}),Zt&&s.jsx("span",{"aria-hidden":!0,className:"h-1.5 w-1.5 rounded-full bg-amber-500"})]}),s.jsxs("button",{type:"button","aria-expanded":te.open,onClick:()=>te.setOpen(!te.open),title:m.chat.openWorkspace,"aria-label":m.chat.openWorkspace,className:`flex h-7 shrink-0 items-center gap-1.5 rounded-md px-2 text-xs font-medium transition-colors duration-150 ${te.open?"bg-gray-100 text-gray-800 dark:bg-gray-800 dark:text-gray-200":"text-gray-500 hover:bg-gray-100 hover:text-gray-800 dark:text-gray-400 dark:hover:bg-gray-800 dark:hover:text-gray-200"}`,children:[s.jsx("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7","aria-hidden":!0,children:s.jsx("path",{d:No.folder})}),s.jsx("span",{className:"hidden lg:inline",children:m.chat.openWorkspace})]}),!De.shown&&s.jsx(AL,{entries:nn,turnOffset:je.outlineOffset,scrollRef:Se,running:je.taskState!=="idle"}),s.jsx(ga,{open:Q,setOpen:K,menuClass:"right-0 top-full mt-1 w-96 max-w-[calc(100vw-1.5rem)] origin-top-right",button:s.jsxs("button",{type:"button",title:m.chat.infoPanel,"aria-label":m.chat.infoPanel,"aria-expanded":Q,onClick:()=>K(!Q),className:`flex h-7 shrink-0 items-center rounded-md transition-colors duration-150 hover:bg-gray-100 dark:hover:bg-gray-800 ${Q?"bg-gray-100 dark:bg-gray-800":""}`,children:[s.jsxs("span",{className:"hidden items-center gap-3 px-2 sm:flex",children:[s.jsx(Ap,{icon:No.tokens,value:on.tokensText,label:`${m.chat.statTokens}(Token)`}),on.costText!=null&&s.jsx(Ap,{icon:No.cost,value:`${on.costText}${on.costUncosted?" *":""}`,label:`${m.common.cost}(${o})${on.costUncosted?` · ${m.usage.uncostedNote}`:""}`}),s.jsx(Ap,{icon:No.elapsed,value:on.elapsedNode,label:m.chat.statElapsed}),xt>0&&s.jsxs("span",{title:m.chat.runningServices(xt),className:"flex shrink-0 items-center gap-1 font-mono text-xs text-emerald-600 dark:text-emerald-400",children:[s.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:s.jsx("path",{d:No.services})}),xt]})]}),s.jsx("span",{className:"flex h-7 w-7 items-center justify-center text-gray-500 sm:hidden dark:text-gray-400",children:s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[s.jsx("circle",{cx:"12",cy:"12",r:"9"}),s.jsx("path",{d:"M12 11v5m0-8h.01"})]})})]}),children:s.jsxs("div",{className:"space-y-3 px-3.5 py-2.5 text-sm",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:m.chat.model}),s.jsxs("p",{className:"truncate text-xs",children:[s.jsx("span",{className:"font-mono",children:ce.modelId}),s.jsx("span",{className:"ml-1.5 text-gray-400 dark:text-gray-500",children:Os(ce.provider)?.label??ce.provider})]})]}),s.jsx(OO,{sessionId:ce.sessionId}),s.jsxs("div",{children:[s.jsx("p",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:m.chat.workspace}),s.jsx("p",{className:"break-all font-mono text-xs leading-5",children:ce.workspace})]}),s.jsxs("div",{children:[s.jsx("p",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:m.common.created}),s.jsx("p",{className:"font-mono text-xs",children:ha(ce.createdAt)})]}),s.jsxs("div",{children:[s.jsx("p",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:m.chat.sessionStats}),s.jsxs("ul",{className:"list-inside list-disc space-y-0.5 font-mono text-xs",children:[s.jsxs("li",{children:[m.chat.statTotalTokens," ",on.tokensText,xr!==null&&`${m.chat.statParenOpen}${m.chat.statCacheHit(xr)}${m.chat.statParenClose}`]}),on.costText!=null&&s.jsxs("li",{children:[m.common.cost," ",on.costText,on.costUncosted?" *":""]}),s.jsxs("li",{children:[m.chat.statElapsed," ",on.elapsedNode]})]})]}),$.length>0&&s.jsxs("div",{children:[s.jsx("p",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:m.chat.processList}),s.jsx("ul",{className:"mt-1 space-y-1.5",children:$.map(he=>s.jsxs("li",{className:"flex items-center gap-2",children:[s.jsx("span",{"aria-hidden":!0,className:`h-1.5 w-1.5 shrink-0 rounded-full ${he.running?"animate-pulse bg-emerald-500":"bg-gray-300 dark:bg-gray-600"}`}),s.jsxs("span",{className:"min-w-0 flex-1",children:[s.jsx("span",{className:"block truncate font-mono text-xs",title:he.cmd,children:he.cmd}),s.jsxs("span",{className:"block text-[11px] text-gray-400 dark:text-gray-500",children:[ha(he.startedAt),he.pid!==null&&` · pid ${he.pid}`]})]}),he.running?s.jsx("button",{type:"button",disabled:q!==null,onClick:()=>{ln(he.processId)},className:"shrink-0 rounded-md border border-gray-200 px-2 py-0.5 text-xs text-gray-600 transition-colors duration-150 hover:border-red-200 hover:bg-red-50 hover:text-red-600 disabled:cursor-default disabled:opacity-60 dark:border-gray-700 dark:text-gray-300 dark:hover:border-red-900 dark:hover:bg-red-950/40 dark:hover:text-red-400",children:q===he.processId?m.common.loading:m.chat.processStop}):s.jsx("span",{className:"shrink-0 text-[11px] text-gray-400 dark:text-gray-500",children:m.chat.processExited})]},he.processId))})]}),T!==null&&s.jsxs("div",{children:[s.jsx("p",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:m.chat.traceFile}),s.jsx("button",{type:"button",onClick:()=>{K(!1),e(`/traces?agentId=${encodeURIComponent(ce.agentId)}&sessionId=${encodeURIComponent(ce.sessionId)}`)},className:"break-all text-left font-mono text-xs leading-5 text-gray-600 underline decoration-gray-300 underline-offset-2 transition-colors duration-150 hover:text-gray-900 dark:text-gray-300 dark:decoration-gray-600 dark:hover:text-gray-100",children:T})]})]})})]}),s.jsxs("div",{className:"flex min-h-0 flex-1",children:[s.jsx("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col",children:Fe?s.jsx(FL,{projectId:g,models:I,...Re!==null?{draftId:Re}:{}},`draft:${g}:${Re??t.key}`):s.jsx("div",{className:"anim-fade flex min-h-0 flex-1 flex-col",children:ce?je.error?s.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6",children:[s.jsxs("p",{className:"text-sm text-red-600 dark:text-red-400",children:[m.chat.historyLoadFailed,":",je.error]}),s.jsx(we,{onClick:je.retry,children:m.common.retry})]}):je.loading?s.jsxs("div",{className:"space-y-3 p-6",children:[s.jsx(en,{className:"h-5 w-1/3"}),s.jsx(en,{className:"h-5 w-2/3"}),s.jsx(en,{className:"h-5 w-1/2"})]}):s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"min-h-0 flex-1",children:ka?s.jsx("div",{className:"flex h-full items-center justify-center px-4",children:s.jsx("p",{className:"text-lg font-medium text-gray-400 dark:text-gray-500",children:m.chat.emptyGreeting})}):s.jsx(oS,{items:fn,version:je.version,ctx:qt,scrollElRef:Se,older:{hasMore:je.older.hasMore,loading:je.older.loading,error:je.older.error,prependedCount:je.prefixItems.length,onLoad:je.loadOlder},outline:s.jsx(EL,{entries:nn,turnOffset:je.outlineOffset,version:je.version,scrollRef:Se,running:je.taskState!=="idle",fit:De})})}),s.jsx("div",{className:"shrink-0 border-t border-gray-200 bg-white px-3 pb-[calc(0.75rem+env(safe-area-inset-bottom))] pt-3 md:pb-3 dark:border-gray-800 dark:bg-gray-950",children:s.jsxs("div",{className:"mx-auto max-w-3xl",children:[je.goal&&s.jsx(i8,{goal:je.goal}),yn]})})]}):w?s.jsx("div",{className:"space-y-3 p-6",children:s.jsx(en,{className:"h-5 w-1/2"})}):s.jsx(Nr,{title:m.chat.noSessions,action:s.jsx(we,{onClick:Da,children:m.nav.newChat})})},ce?.sessionId??"empty")}),ce&&s.jsx(yO,{session:ce,panel:be,model:pe,version:je.version,taskRunning:je.taskState!=="idle",ctx:qt}),ce&&s.jsx(cO,{session:ce,panel:te})]}),s.jsx(Gt,{open:A,title:m.project.noCredentialTitle,onClose:()=>P(!1),footer:s.jsxs(s.Fragment,{children:[s.jsx(we,{onClick:()=>P(!1),children:m.project.later}),s.jsx(we,{variant:"primary",onClick:()=>{P(!1),e("/models")},children:m.project.goToModels})]}),children:s.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-300",children:m.project.noCredentialBody})})]})}const $S=/^[a-z][a-z0-9_]{1,63}$/,_1=/^[a-z][a-z0-9_]{1,31}$/,PO=/^[a-z0-9_]+$/,BO=64,I1=4,L1=16;function PS({open:e,onClose:t,estimatedHeight:a,panelWidth:l}){const o=y.useRef(null),c=y.useRef(null),[u,f]=y.useState(null),p=y.useRef(t);return p.current=t,y.useLayoutEffect(()=>{if(!e||!o.current)return;const h=o.current.getBoundingClientRect(),g=window.innerHeight-h.bottom,v=h.top,k=Math.min(a,window.innerHeight*.7),w=g<k&&v>g,j=l??h.width,E=Math.max(L1,Math.min(h.left,window.innerWidth-j-L1));f({topPx:w?void 0:h.bottom+I1,bottomPx:w?window.innerHeight-h.top+I1:void 0,left:E,triggerWidth:h.width})},[e,a,l]),y.useEffect(()=>{if(!e)return;const h=w=>{const j=w.target;o.current?.contains(j)||c.current?.contains(j)||p.current()},g=w=>{w.key==="Escape"&&(w.stopPropagation(),p.current())},v=w=>{c.current?.contains(w.target)||p.current()},k=()=>p.current();return window.addEventListener("mousedown",h),window.addEventListener("keydown",g,!0),window.addEventListener("scroll",v,!0),window.addEventListener("resize",k),()=>{window.removeEventListener("mousedown",h),window.removeEventListener("keydown",g,!0),window.removeEventListener("scroll",v,!0),window.removeEventListener("resize",k)}},[e]),{triggerRef:o,panelRef:c,position:u}}function HO(e){const t=[];return y.Children.forEach(e,a=>{if(!y.isValidElement(a)||a.type!=="option")return;const l=a.props;t.push({value:l.value!==void 0?String(l.value):"",label:l.children??"",...l.disabled?{disabled:!0}:{}})}),t}const FO=`flex w-full items-center gap-2 text-left ${Rd} disabled:cursor-not-allowed disabled:opacity-60`,qO={base:"text-base",sm:"text-xs"};function Ds({label:e,hint:t,error:a,required:l,size:o="base",className:c,children:u,value:f,onChange:p,disabled:h}){const g=HO(u),v=String(f??""),k=g.find(F=>F.value===v),w=y.useId(),[j,E]=y.useState(!1),{triggerRef:C,panelRef:M,position:_}=PS({open:j,onClose:()=>E(!1),estimatedHeight:g.length*36+8}),D=F=>{E(!1),p?.({target:{value:F}}),C.current?.focus()},V=s.jsxs(s.Fragment,{children:[s.jsxs("button",{ref:C,type:"button",disabled:h,"aria-haspopup":"listbox","aria-expanded":j,"aria-required":l||void 0,"aria-invalid":a?!0:void 0,"aria-describedby":a?w:void 0,onClick:()=>E(F=>!F),className:`${FO} ${_d[o]} ${a?Id:""} ${c??""}`,children:[s.jsx("span",{className:"min-w-0 flex-1 truncate",children:k?.label??g[0]?.label??""}),s.jsx(Ad,{className:"text-gray-400"})]}),j&&_&&bi.createPortal(s.jsx("div",{ref:M,role:"listbox",className:"anim-pop fixed z-[60] max-h-60 overflow-y-auto rounded-md border border-gray-200 bg-white py-1 shadow-lg dark:border-gray-700 dark:bg-gray-900",style:{left:_.left,width:_.triggerWidth,top:_.topPx,bottom:_.bottomPx},children:g.map((F,A)=>s.jsxs("button",{type:"button",role:"option","aria-selected":F.value===v,disabled:F.disabled,onClick:()=>D(F.value),className:`flex items-center ${Iw} ${qO[o]} disabled:opacity-50 ${F.value===v?"bg-gray-100 font-medium text-gray-900 dark:bg-gray-800 dark:text-gray-100":"text-gray-700 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-gray-800"}`,children:[s.jsx("span",{className:"min-w-0 flex-1 truncate",children:F.label}),F.value===v&&s.jsx(vw,{className:"text-gray-500 dark:text-gray-400"})]},`${F.value}-${A}`))}),document.body)]});return s.jsx(oc,{label:e,hint:t,error:a,errorId:w,required:l,children:V})}const VO=["always-ask","read-only","allow-all","deny-all"];function GO({open:e,onClose:t,onCreated:a}){const{user:l}=xn(),o=l&&!l.isAdmin?`${l.userId}-`:"",[c,u]=y.useState(""),[f,p]=y.useState(""),[h,g]=y.useState(void 0),[v,k]=y.useState(!1);y.useEffect(()=>{e&&(u(""),p(""),g(void 0))},[e]);const w=async()=>{const j=o+c.trim();if(!c.trim()){g(m.common.requiredField);return}if(!(o?PO.test(c.trim())&&j.length<=BO:$S.test(j))){g(o?m.project.idPrefixHint:m.project.idHint);return}k(!0),g(void 0);try{const C=await FC({projectId:j,...f.trim()?{name:f.trim()}:{}});a(C.project.projectId)}catch(C){g(Ie(C))}finally{k(!1)}};return s.jsx(Gt,{open:e,title:m.project.createTitle,onClose:t,footer:s.jsxs(s.Fragment,{children:[s.jsx(we,{onClick:t,children:m.common.cancel}),s.jsx(we,{variant:"primary",disabled:v,onClick:()=>{w()},children:m.common.create})]}),children:s.jsxs("div",{className:"space-y-3",children:[o?s.jsxs("div",{children:[s.jsx(er,{required:!0,children:m.project.id}),s.jsxs("div",{className:"flex items-stretch",children:[s.jsx("span",{className:"flex shrink-0 items-center rounded-l-md border border-r-0 border-gray-300 bg-gray-100 px-2 font-mono text-xs text-gray-500 dark:border-gray-700 dark:bg-gray-800 dark:text-gray-400",children:o}),s.jsx(at,{size:"sm",className:"rounded-l-none",value:c,invalid:!!h,onChange:j=>{u(j.target.value),g(void 0)},autoFocus:!0})]}),h?s.jsx(Sr,{children:h}):s.jsx(ld,{children:m.project.idPrefixHint})]}):s.jsx(at,{label:m.project.id,required:!0,size:"sm",value:c,error:h,onChange:j=>{u(j.target.value),g(void 0)},hint:m.project.idHint,autoFocus:!0}),s.jsx(at,{label:m.project.name,size:"sm",value:f,onChange:j=>p(j.target.value)})]})})}function WO({open:e,onClose:t}){const{user:a,desktopMode:l}=xn(),{currentProject:o,setCurrentProjectId:c,projects:u,reloadProjects:f}=Xt(),[p,h]=y.useState(null),[g,v]=y.useState(""),[k,w]=y.useState(null),[j,E]=y.useState(!1),[C,M]=y.useState(""),[_,D]=y.useState(!1),[V,F]=y.useState(void 0),A=o?.projectId,P=o?.role==="owner",Q=o?Yp(o):"";if(y.useEffect(()=>{!e||!A||(h(null),w(null),E(!1),M(Q),F(void 0),l||Jm(A).then(B=>h(B.members)).catch(B=>w(Ie(B))))},[e,A,l]),!o||!A)return null;const K=async()=>{const B=C.trim();if(!(!B||B===Q||_)){D(!0),F(void 0);try{await qC(A,{name:B}),await f()}catch($){F(Ie($))}finally{D(!1)}}},O=async()=>{if(g.trim())try{await GC(A,{userId:g.trim()}),v("");const B=await Jm(A);h(B.members)}catch(B){Qe(Ie(B))}},z=async B=>{try{await WC(A,B);const $=await Jm(A);h($.members)}catch($){Qe(Ie($))}},I=async()=>{try{await VC(A),t();const B=u.find($=>$.projectId!==A);await f(),B&&c(B.projectId)}catch(B){Qe(Ie(B))}};return s.jsxs(Gt,{open:e,title:m.project.settingsTitle,onClose:t,children:[s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{children:[P?s.jsxs(s.Fragment,{children:[s.jsx(er,{children:m.project.displayName}),s.jsxs("div",{className:"flex items-stretch gap-2",children:[s.jsx(at,{size:"sm",className:"min-w-0 flex-1",value:C,invalid:!!V,maxLength:100,onChange:B=>{M(B.target.value),V&&F(void 0)},onKeyDown:B=>{B.key==="Enter"&&K()}}),s.jsx(we,{size:"sm",disabled:_||!C.trim()||C.trim()===Q,onClick:()=>{K()},children:m.common.save})]}),V!==void 0&&s.jsx(Sr,{children:V})]}):s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"mb-1 text-xs font-medium text-gray-500",children:m.project.switcher}),s.jsx("p",{className:"text-sm",children:Q})]}),s.jsx("p",{className:"mt-1 font-mono text-xs text-gray-400",children:A})]}),!l&&s.jsxs("div",{children:[s.jsx("p",{className:"mb-2 text-xs font-medium text-gray-500",children:m.project.members}),k?s.jsx("p",{className:"text-xs text-red-600 dark:text-red-400",children:k}):p===null?s.jsx("p",{className:"text-xs text-gray-400",children:m.common.loading}):s.jsx("div",{className:"overflow-x-auto rounded-md border border-gray-200 dark:border-gray-800",children:s.jsxs("table",{className:"w-full text-xs",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"border-b border-gray-100 bg-gray-50 text-left text-gray-500 dark:border-gray-800 dark:bg-gray-900/60 dark:text-gray-400",children:[s.jsx("th",{className:"whitespace-nowrap px-2.5 py-1.5 font-medium",children:m.common.username}),s.jsx("th",{className:"whitespace-nowrap px-2.5 py-1.5 font-medium",children:m.common.role}),s.jsx("th",{className:"w-20 whitespace-nowrap px-2.5 py-1.5 text-right font-medium",children:m.common.actions})]})}),s.jsxs("tbody",{className:"divide-y divide-gray-100 dark:divide-gray-800/60",children:[p.map(B=>s.jsxs("tr",{children:[s.jsx("td",{className:"whitespace-nowrap px-2.5 py-1.5",children:B.userId}),s.jsx("td",{className:"whitespace-nowrap px-2.5 py-1.5",children:s.jsx(gn,{tone:"gray",children:B.role})}),s.jsx("td",{className:"whitespace-nowrap px-2.5 py-1 text-right",children:P&&B.role!=="owner"&&B.userId!==a?.userId&&s.jsx(we,{size:"sm",variant:"ghost",onClick:()=>{z(B.userId)},children:m.project.removeMember})})]},B.userId)),P&&s.jsxs("tr",{children:[s.jsx("td",{className:"px-2.5 py-1.5",children:s.jsx(at,{placeholder:m.common.username,size:"sm",value:g,onChange:B=>v(B.target.value),onKeyDown:B=>{B.key==="Enter"&&O()}})}),s.jsx("td",{className:"whitespace-nowrap px-2.5 py-1.5",children:s.jsx(gn,{tone:"gray",children:"member"})}),s.jsx("td",{className:"whitespace-nowrap px-2.5 py-1 text-right",children:s.jsx(we,{size:"sm",disabled:!g.trim(),onClick:()=>{O()},children:m.project.addMember})})]})]})]})})]}),s.jsx(KO,{projectId:A,isOwner:P}),P&&s.jsx("div",{className:"border-t border-gray-100 pt-3 dark:border-gray-800",children:A==="default_project"?s.jsx("p",{className:"text-xs text-gray-400",children:m.project.deleteDefaultForbidden}):u.length<=1?s.jsx("p",{className:"text-xs text-gray-400",children:m.project.deleteLastForbidden}):s.jsx(we,{size:"sm",variant:"danger",onClick:()=>E(!0),children:m.project.deleteProject})})]}),s.jsx(Mn,{open:j,title:m.project.deleteProject,onClose:()=>E(!1),onConfirm:()=>{I()},children:s.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-300",children:m.project.deleteConfirm})})]})}function KO({projectId:e,isOwner:t}){const{user:a}=xn(),{agents:l}=Xt(),[o,c]=y.useState(null),[u,f]=y.useState(null),[p,h]=y.useState(null),[g,v]=y.useState(!1),[k,w]=y.useState(""),[j,E]=y.useState(""),[C,M]=y.useState(""),[_,D]=y.useState(""),[V,F]=y.useState(null);y.useEffect(()=>{let z=!1;return Ek(e).then(I=>{z||(c(I),w(I.agentId??""),E(I.workspace??""),M(I.approvalMode??""),D(I.thinkingLevel??""))}).catch(I=>{z||h(Ie(I))}),mi(e).then(I=>{z||(f(I),F(I.defaultModel??null))}).catch(I=>{z||h(Ie(I))}),()=>{z=!0}},[e]);const A=o!==null&&(k!==(o.agentId??"")||j.trim()!==(o.workspace??"")||C!==(o.approvalMode??"")||_!==(o.thinkingLevel??"")),P=u!==null&&V!==null&&!jt(u.defaultModel,V),Q=async()=>{if(g||!A&&!P)return;v(!0);let z=null;try{if(A){const I={...k?{agentId:k}:{},...j.trim()?{workspace:j.trim()}:{},...C?{approvalMode:C}:{},..._?{thinkingLevel:_}:{}},B=await KC(e,I);c(B),a&&IL(a.userId,e),z={projectId:e,defaults:B}}if(P&&V){const I=await QC(e,{provider:V.provider,modelId:V.modelId});f(B=>B&&{...B,defaultModel:I.defaultModel}),a&&AS(a.userId,e),z={...z??{projectId:e},defaultModel:I.defaultModel}}z&&Et(m.common.saved)}catch(I){Qe(Ie(I))}finally{z&&PL(z),v(!1)}},K=o?.agentId?(()=>{const z=l.find(I=>I.agentId===o.agentId);return z?tn(z):o.agentId})():m.project.chatDefaultsNotSet,O=u?.models.find(z=>jt(z,u.defaultModel));return s.jsxs("div",{className:"border-t border-gray-100 pt-3 dark:border-gray-800",children:[s.jsx("p",{className:"text-xs font-medium text-gray-500",children:m.project.chatDefaultsTitle}),s.jsx("p",{className:"mb-2 mt-0.5 text-xs text-gray-400",children:m.project.chatDefaultsHint}),p?s.jsx("p",{className:"text-xs text-red-600 dark:text-red-400",children:p}):o===null||u===null?s.jsx("p",{className:"text-xs text-gray-400",children:m.common.loading}):t?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2",children:[s.jsxs(Ds,{label:m.project.chatDefaultsAgent,size:"sm",value:k,onChange:z=>w(z.target.value),children:[s.jsx("option",{value:"",children:m.project.chatDefaultsNotSet}),l.map(z=>s.jsx("option",{value:z.agentId,children:tn(z)},z.agentId))]}),s.jsxs(Ds,{label:m.chat.approvalMode,size:"sm",value:C,onChange:z=>M(z.target.value),children:[s.jsx("option",{value:"",children:m.project.chatDefaultsApprovalNotSet}),VO.map(z=>s.jsx("option",{value:z,children:m.chat.approvalModeNames[z]??z},z))]}),s.jsxs(Ds,{label:m.chat.thinkingLevel,size:"sm",value:_,onChange:z=>D(z.target.value),children:[s.jsx("option",{value:"",children:m.project.chatDefaultsThinkingNotSet}),xS.map(z=>s.jsx("option",{value:z,children:m.chat.thinkingLevelNames[z]??z},z))]}),s.jsxs("div",{children:[s.jsx(er,{children:m.chat.model}),u.models.length>0?s.jsxs(s.Fragment,{children:[s.jsx(Og,{models:u.models,value:V,defaultModel:u.defaultModel,onChange:F,disabled:g,variant:"form"}),s.jsx(ld,{children:m.project.chatDefaultsModelHint})]}):s.jsx("p",{className:"text-xs text-gray-400",children:m.models.empty})]}),s.jsxs("div",{className:"sm:col-span-2",children:[s.jsx(er,{children:m.chat.workspace}),s.jsx(zg,{projectId:e,workspace:j,onChange:E,variant:"form"}),s.jsx(ld,{children:m.project.chatDefaultsWorkspaceHint})]})]}),s.jsx("div",{className:"mt-3 flex justify-end",children:s.jsx(we,{size:"sm",disabled:g||!A&&!P,onClick:()=>{Q()},children:m.common.save})})]}):s.jsx("div",{className:"space-y-1 text-sm",children:[[m.project.chatDefaultsAgent,K],[m.chat.workspace,o.workspace??m.chat.workspaceAuto],[m.chat.approvalMode,o.approvalMode?m.chat.approvalModeNames[o.approvalMode]??o.approvalMode:m.project.chatDefaultsApprovalNotSet],[m.chat.thinkingLevel,o.thinkingLevel?m.chat.thinkingLevelNames[o.thinkingLevel]??o.thinkingLevel:m.project.chatDefaultsThinkingNotSet],[m.chat.model,O?O.displayName??O.modelId:m.project.chatDefaultsNotSet]].map(([z,I])=>s.jsxs("div",{className:"flex items-baseline gap-2",children:[s.jsx("span",{className:"w-24 shrink-0 text-xs text-gray-500",children:z}),s.jsx("span",{className:"min-w-0 flex-1 break-all",children:I})]},z))})]})}const YO="M2 12s3.6-7 10-7 10 7 10 7-3.6 7-10 7-10-7-10-7zM12 9a3 3 0 1 0 0 6 3 3 0 0 0 0-6z",QO="M3 3l18 18M10.6 5.1A11 11 0 0 1 12 5c6.4 0 10 7 10 7a17.6 17.6 0 0 1-3.2 3.9M6.6 6.6C4 8.3 2 12 2 12s3.6 7 10 7a10 10 0 0 0 4.8-1.2M9.9 9.9a3 3 0 0 0 4.2 4.2";function zs({label:e,hint:t,error:a,invalid:l,required:o,size:c="base",className:u,...f}){const[p,h]=y.useState(!1),g=p?m.auth.hidePassword:m.auth.showPassword,v=y.useId();return s.jsx(oc,{label:e,hint:t,error:a,errorId:v,required:o,children:s.jsxs("div",{className:"relative",children:[s.jsx(at,{...f,required:o,size:c,type:p?"text":"password",invalid:!!a||!!l,"aria-describedby":a?v:void 0,className:`${c==="sm"?"pr-8":"pr-10"} ${u??""}`}),s.jsx("button",{type:"button","aria-label":g,title:g,tabIndex:-1,onClick:()=>h(k=>!k),className:`absolute inset-y-0 right-0 flex items-center justify-center text-gray-400 transition-colors duration-150 hover:text-gray-600 dark:hover:text-gray-300 ${c==="sm"?"w-8":"w-10"}`,children:s.jsx("svg",{width:c==="sm"?14:16,height:c==="sm"?14:16,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:s.jsx("path",{d:p?QO:YO})})})]})})}function BS({open:e,onClose:t}){const{refresh:a,sessionVia:l}=xn(),o=l==="desktop",[c,u]=y.useState(""),[f,p]=y.useState(""),[h,g]=y.useState(""),[v,k]=y.useState({}),[w,j]=y.useState(!1),E=()=>k(M=>M.old||M.new||M.confirm?{}:M);y.useEffect(()=>{e&&(u(""),p(""),g(""),k({}))},[e]);const C=async()=>{const M={};if(!o&&!c&&(M.old=m.common.requiredField),f||(M.new=m.common.requiredField),h||(M.confirm=m.common.requiredField),!M.confirm&&f!==h&&(M.confirm=m.account.passwordMismatch),M.old||M.new||M.confirm){k(M);return}j(!0),k({});try{await OC(o?{newPassword:f}:{oldPassword:c,newPassword:f}),await a(),t()}catch(_){_ instanceof na&&_.code==="invalid_password"?k({new:Ie(_)}):k({old:Ie(_)})}finally{j(!1)}};return s.jsx(Gt,{open:e,title:m.account.changePassword,onClose:t,footer:s.jsxs(s.Fragment,{children:[s.jsx(we,{onClick:t,disabled:w,children:m.common.cancel}),s.jsx(we,{variant:"primary",disabled:w,onClick:()=>{C()},children:m.common.save})]}),children:s.jsxs("div",{className:"space-y-3",children:[!o&&s.jsx(zs,{label:m.account.oldPassword,required:!0,size:"sm",value:c,onChange:M=>{u(M.target.value),E()},error:v.old,autoComplete:"current-password",hint:m.account.oldPasswordHint,autoFocus:!0}),s.jsx(zs,{label:m.account.newPassword,required:!0,size:"sm",value:f,onChange:M=>{p(M.target.value),E()},error:v.new,autoComplete:"new-password",hint:m.auth.passwordHint,autoFocus:o}),s.jsx(zs,{label:m.account.confirmPassword,required:!0,size:"sm",value:h,onChange:M=>{g(M.target.value),E()},error:v.confirm,autoComplete:"new-password"})]})})}function XO({open:e,onClose:t}){const[a,l]=y.useState(null),[o,c]=y.useState(!0),[u,f]=y.useState(!0),[p,h]=y.useState(""),[g,v]=y.useState(null),[k,w]=y.useState(!1);y.useEffect(()=>{if(!e)return;let C=!1;return l(null),v(null),w(!1),PC().then(M=>{C||(l(M.settings),c(M.settings.proxyForApp),f(M.settings.proxyForAgent),h(M.settings.proxyUrl??""))}).catch(M=>{C||Qe(Ie(M))}),()=>{C=!0}},[e]);const j=async()=>{if(a===null||k)return;if(o===a.proxyForApp&&u===a.proxyForAgent&&p.trim()===(a.proxyUrl??"")){Mr(m.common.noChangesToSave);return}w(!0),v(null);try{await BC({proxyForApp:o,proxyForAgent:u,proxyUrl:p}),Et(m.common.saved),t()}catch(M){M instanceof na&&M.code==="invalid_proxy_url"?v(Ie(M)):Qe(Ie(M))}finally{w(!1)}},E=a!==null;return s.jsx(Gt,{open:e,title:m.settings.proxyDialogTitle,onClose:t,footer:s.jsxs(s.Fragment,{children:[s.jsx(we,{onClick:t,disabled:k,children:m.common.cancel}),s.jsx(we,{variant:"primary",disabled:!E||k,onClick:()=>{j()},children:m.common.save})]}),children:s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex items-center justify-between gap-3",children:[s.jsx("span",{className:"text-sm font-medium",children:m.settings.proxyForApp}),s.jsx(wl,{checked:o,onChange:c,disabled:!E})]}),s.jsxs("div",{className:"flex items-center justify-between gap-3",children:[s.jsx("span",{className:"text-sm font-medium",children:m.settings.proxyForAgent}),s.jsx(wl,{checked:u,onChange:f,disabled:!E})]}),s.jsx(at,{label:m.settings.proxyAddress,size:"sm",value:p,placeholder:m.settings.proxyAddressPlaceholder,disabled:!E,...g!==null?{error:g}:{},onChange:C=>{h(C.target.value),g!==null&&v(null)}})]})})}function ZO({open:e,onClose:t,latestVersion:a,releaseUrl:l=null,canUpdate:o,onRunFinished:c}){const[u,f]=y.useState("confirm"),[p,h]=y.useState(null);y.useEffect(()=>{e&&(f("confirm"),h(null))},[e]);const g=()=>{u==="done"&&c?.(),t()},v=async()=>{f("running");try{h(await HN())}catch(w){h({status:"failed",output:Ie(w),needsRestart:!1})}f("done")},k=p===null?null:p.status==="updated"?{text:m.update.updated,className:"text-green-600 dark:text-green-400"}:p.status==="unsupported"?{text:m.update.unsupported,className:"text-amber-600 dark:text-amber-400"}:{text:m.update.failed,className:"text-red-600 dark:text-red-400"};return s.jsx(Gt,{open:e,title:o?m.update.updateNow:a!==null?m.update.newVersion(a):m.update.releaseNotes,onClose:u==="running"?()=>{}:g,footer:u==="done"||!o?s.jsx(we,{onClick:g,children:m.common.close}):s.jsxs(s.Fragment,{children:[s.jsx(we,{onClick:g,disabled:u==="running",children:m.common.cancel}),s.jsx(we,{variant:"primary",disabled:u==="running",onClick:()=>{v()},children:u==="running"?m.update.updating:m.update.updateNow})]}),children:u==="done"&&p!==null&&k!==null?s.jsxs("div",{className:"space-y-3",children:[s.jsx("p",{className:`text-sm font-medium ${k.className}`,children:k.text}),p.status==="updated"&&s.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:m.update.restartHint}),p.output!==""&&s.jsx("pre",{className:"max-h-56 overflow-auto rounded-md bg-gray-100 p-3 text-xs leading-relaxed whitespace-pre-wrap text-gray-700 dark:bg-gray-800 dark:text-gray-300",children:eS(p.output)})]}):s.jsxs("div",{className:"space-y-2",children:[a!==null&&s.jsx("p",{className:"text-sm font-medium",children:m.update.newVersion(a)}),l!==null&&s.jsx("p",{children:s.jsx("a",{href:l,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-brand-600 underline-offset-2 hover:underline dark:text-brand-300",children:m.update.releaseNotes})}),s.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:o?m.update.confirmBody:m.update.adminOnly}),u==="running"&&s.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:m.update.updating})]})})}const Rh="M12 20h9M16.5 3.5a2.1 2.1 0 0 1 3 3L7 19l-4 1 1-4L16.5 3.5z",JO="M12 17v5M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V6h1a2 2 0 0 0 0-4H8a2 2 0 0 0 0 4h1z",si="block w-full px-3.5 py-2 text-left text-sm transition-colors duration-150 hover:bg-gray-100 dark:hover:bg-gray-800",eD=e=>`penguin.sidebarCollapsedGroups.${e}`,tD=e=>`penguin.sidebarPinnedGroups.${e}`;function Uu(e){if(!e)return new Set;try{const t=JSON.parse(localStorage.getItem(e)??"[]");return new Set(Array.isArray(t)?t.filter(a=>typeof a=="string"):[])}catch{return new Set}}function O1(e,t){if(e)try{localStorage.setItem(e,JSON.stringify([...t]))}catch{}}const $u=(e,t)=>`${t}\0${e}`,Rp="\0drafts";function nD({session:e}){return e.status==="running"?s.jsx("span",{title:m.chat.statusRunning,className:"h-1.5 w-1.5 shrink-0 animate-pulse rounded-full bg-emerald-500"}):e.status==="compacting"?s.jsx("span",{title:m.chat.statusCompacting,className:"h-1.5 w-1.5 shrink-0 rounded-full bg-amber-500"}):null}function D1({onNavigate:e,onCollapse:t}){const a=Wn(),{user:l,logout:o,desktopMode:c}=xn(),{mode:u,setMode:f,fontScale:p,setFontScale:h,accent:g,setAccent:v,currency:k,setCurrency:w}=Ps(),{lang:j,locale:E,setLang:C}=La(),{projects:M,currentProject:_,setCurrentProjectId:D,reloadProjects:V,agents:F,currentAgent:A,setCurrentAgentId:P}=Xt(),{sessions:Q,byAgent:K,countsByAgent:O,workspaceCountsByAgent:z,isLoadedFor:I,hasMoreFor:B,loadMoreFor:$,loading:G,remove:q,replace:ae,showCliSessions:Z,setShowCliSessions:X}=Bs(),R=Zk("/chat/:sessionId")?.params.sessionId??null,[H,S]=y.useState(!1),[U,ee]=y.useState(!1),[ie,de]=y.useState(!1),[me,ye]=y.useState(!1),[te,be]=y.useState(!1),[Re,Fe]=y.useState(!1),{version:ce,update:Ve}=Jh(U),je=Ve?.updateAvailable===!0,wt=je?Ve?.latestVersion??null:null,an=ce?.buildDate??null,[rn,sn]=y.useState(!1),Ut=async()=>{if(!rn){sn(!0);try{const ue=zT(await Kv());ue.kind==="disabled"?Mr(m.update.checkDisabled):ue.kind==="failed"?Qe(m.update.checkFailed):ue.kind==="found"?Et(m.update.foundNew(ue.latestVersion)):Et(m.update.upToDate)}catch(ue){Qe(Ie(ue))}finally{sn(!1)}}},[At,fn]=y.useState(!1),st=_?.projectId??null,nn=st===null?null:eD(st),pe=st===null?null:tD(st),[Se,De]=y.useState(pw),[ze,Ue]=y.useState(()=>Uu(nn)),[W,ge]=y.useState(()=>Uu(pe));y.useEffect(()=>{Ue(Uu(nn)),ge(Uu(pe)),Oe(Tu)},[nn,pe]);const[Ne,Te]=y.useState(new Set),[Pe,We]=y.useState(new Set),[tt,it]=y.useState(new Map),[Ce,Oe]=y.useState(Tu),[Ke,vt]=y.useState(null),[xt,St]=y.useState(!1),[ln,$t]=y.useState(null),Oa=zL(l?.userId??null,st),[aa,En]=y.useState(null),[An,ar]=y.useState(""),[Yn,ts]=y.useState(!1),[Pn,ba]=y.useState(null),Da=ue=>{hw(ue),De(ue),Oe(Tu)},gr=y.useMemo(()=>cw(Q),[Q]),Bn=y.useMemo(()=>iw(z),[z]),qt=y.useMemo(()=>Xp(F,ue=>ue.agentId,W),[F,W]),Zt=y.useMemo(()=>Xp(gr,ue=>ue.key,W),[gr,W]),Hn=ue=>Se==="agent"?ue.agentId:nd(ue.workspace),on=ue=>{const _e=new Set(ze);_e.has(ue)?_e.delete(ue):_e.add(ue),Ue(_e),O1(nn,_e)},Rr=ue=>{const _e=new Set(W);_e.has(ue)?_e.delete(ue):_e.add(ue),ge(_e),O1(pe,_e)},xr=(ue,_e)=>`${_e}\0${ue}`,rr=(ue,_e,ut)=>{const Je=xr(ue,_e);We(Pt=>new Set(Pt).add(Je)),$(ut,_e).finally(()=>{We(Pt=>{const Wt=new Set(Pt);return Wt.delete(Je),Wt})})},Qn=(ue,_e,ut)=>{const Je=$u(ue,_e),Pt=!Ne.has(Je);if(Te(Wt=>{const Nn=new Set(Wt);return Pt?Nn.add(Je):Nn.delete(Je),Nn}),Pt){const Wt=ut.filter(Nn=>!I(Nn,_e));Wt.length>0&&$(Wt,_e)}},sr=y.useRef(null);y.useEffect(()=>{if(!R)return;const ue=Q.find(Wt=>Wt.sessionId===R);if(!ue)return;const _e=fr(ue);if(_e==="active"||_e==="archived")return;const ut=`${Se}\0${R}`;if(sr.current===ut)return;sr.current=ut;const Je=Se==="agent"?ue.agentId:nd(ue.workspace),Pt=$u(Je,_e);Te(Wt=>Wt.has(Pt)?Wt:new Set(Wt).add(Pt)),I(ue.agentId,_e)||$([ue.agentId],_e)},[R,Q,Se,I,$]);const ka=async ue=>{!ue.archived&&ue.sessionId===R&&Te(_e=>new Set(_e).add($u(Hn(ue),"archived")));try{const _e=await Vp(ue.sessionId,{archived:!ue.archived});ae(_e.session)}catch{}},ra=async()=>{if(!aa)return;const ue=An.trim();if(ue){ts(!0),ba(null);try{const _e=await Vp(aa.sessionId,{title:ue});ae(_e.session),En(null)}catch(_e){ba(Ie(_e))}finally{ts(!1)}}},za=async()=>{if(!Ke)return;St(!0);const ue=Ke;try{if(await td(ue.sessionId),q(ue.sessionId),l&&nc(MS(l.userId,ue.sessionId)),vt(null),R===ue.sessionId){const _e=(K.get(ue.agentId)??[]).filter(ut=>{const Je=fr(ut);return ut.sessionId!==ue.sessionId&&(Je==="active"||Je==="schedule")});a(_e[0]?`/chat/${_e[0].sessionId}`:"/chat")}}catch(_e){Qe(Ie(_e))}finally{St(!1)}},yn=ue=>{a(ue),e?.()},he=(ue,_e)=>{l&&st&&Ci(l.userId,st),ue&&P(ue);const ut={...ue?{agentId:ue}:{},..._e!==void 0?{workspace:_e}:{}};a(`/chat/${Ia}`,Object.keys(ut).length>0?{state:ut}:void 0),e?.()},Le=()=>{ln&&(l&&st&&_S(l.userId,st,ln.id),R===ln.id&&a(`/chat/${Ia}`),$t(null))},ot=(F.find(ue=>ue.agentId==="default_agent")??F[0])?.agentId,rt=A?.agentId??ot,Rt=ue=>{P(ue.agentId),yn(`/chat/${ue.sessionId}`)},Vt=y.useMemo(()=>new Map(F.map(ue=>[ue.agentId,tn(ue)])),[F]),vn=(ue,_e)=>s.jsx("ul",{className:"space-y-0.5",children:ue.map(ut=>s.jsx(rD,{s:ut,active:ut.sessionId===R,..._e?{agentHint:Vt.get(ut.agentId)??ut.agentId}:{},onOpen:Rt,onRename:Je=>{ba(null),ar(Je.title??""),En(Je)},onDelete:Je=>vt(Je),onToggleArchive:Je=>{ka(Je)}},ut.sessionId))}),sa=(ue,_e,ut,Je,Pt,Wt)=>{const Nn=ut[_e],bn=Math.max(Wt?.[_e]??0,Nn.length);if(bn===0)return null;const as=Nn.length<bn&&Pt.some(rs=>B(rs,_e));return s.jsx(yw,{label:m.chat.folderGroups[_e](bn),open:Ne.has($u(ue,_e)),onToggle:()=>Qn(ue,_e,Pt),more:as,pending:Pe.has(xr(ue,_e)),onMore:()=>rr(ue,_e,Pt),children:vn(Nn,Je)},_e)},Fn=(ue,_e)=>{it(ut=>{const Je=new Map(ut);return Je.set(ue,(ut.get(ue)??pl)+pl),Je}),_e.length>0&&rr(ue,"active",_e)},Xn=(ue,_e,ut,Je,Pt)=>{const Wt=tt.get(ue)??pl,Nn=_e.active.slice(0,Wt),bn=Pt("active"),as=Math.max(Je?.active??0,_e.active.length),rs=_e.active.length>Wt||_e.active.length<as&&bn.some(Ua=>B(Ua,"active")),lr=lc.map(Ua=>sa(ue,Ua,_e,ut,Pt(Ua),Je)),Ti=_e.active.length===0&&lr.every(Ua=>Ua===null),qs=Pe.has(xr(ue,"active"));return s.jsxs(s.Fragment,{children:[Ti?s.jsx("p",{className:"px-2.5 py-1 text-xs text-gray-400 dark:text-gray-600",children:m.chat.noSessions}):vn(Nn,ut),rs&&s.jsx(fi,{label:m.chat.loadMore,pending:qs,onClick:()=>Fn(ue,bn),className:"mt-0.5"}),lr]})},_n=ue=>s.jsx(fi,{label:m.chat.moreGroups(ue-Ce),onClick:()=>Oe(_e=>_e+Tu),className:"mt-1"}),wa=[{to:"/agents",label:m.nav.agents,icon:Za.agents},{to:"/skills",label:m.nav.skills,icon:Za.skills},{to:"/models",label:m.nav.models,icon:Za.models},{to:"/usage",label:m.nav.usage,icon:Za.usage},{to:"/traces",label:m.nav.traces,icon:Za.traces},{to:"/benchmark",label:m.nav.benchmark,icon:Za.benchmark}],qn=[{value:"light",label:m.settings.themeLight},{value:"dark",label:m.settings.themeDark},{value:"system",label:m.settings.followSystem}],Ml=[{value:"en",label:m.settings.langEn},{value:"zh",label:m.settings.langZh},{value:"system",label:m.settings.followSystem}],Ni=[{value:"sm",label:m.settings.fontSmall},{value:"md",label:m.settings.fontMedium},{value:"lg",label:m.settings.fontLarge}],ns=[{value:"USD",label:m.models.currencyUsd},{value:"CNY",label:m.models.currencyCny}];return s.jsxs("div",{className:"flex h-full w-full flex-col",children:[s.jsxs("div",{className:"flex shrink-0 items-center gap-1 px-2 pt-2",children:[t&&s.jsx("button",{type:"button",title:m.nav.collapseSidebar,"aria-label":m.nav.collapseSidebar,onClick:t,className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-md text-gray-400 transition-colors duration-150 hover:bg-gray-200/70 hover:text-gray-800 dark:text-gray-500 dark:hover:bg-gray-800 dark:hover:text-gray-200",children:s.jsx(Jn,{d:"M15 6l-6 6 6 6M4 4v16",size:18})}),s.jsxs(ga,{open:H,setOpen:S,className:"min-w-0 flex-1",menuClass:"left-0 right-0 top-full mt-1 origin-top",button:s.jsxs("button",{type:"button",onClick:()=>S(!H),className:"flex w-full items-center gap-1.5 rounded-md px-2 py-1.5 text-base font-semibold transition-colors duration-150 hover:bg-gray-200/70 dark:hover:bg-gray-800",children:[s.jsx("span",{className:"min-w-0 flex-1 truncate text-left",children:_?Yp(_):m.common.loading}),s.jsx("span",{className:"text-gray-400",children:s.jsx(Ad,{})})]}),children:[M.map(ue=>s.jsxs("button",{type:"button",onClick:()=>{D(ue.projectId),S(!1)},className:`flex w-full items-center justify-between gap-2 px-3.5 py-2 text-left text-sm transition-colors duration-150 hover:bg-gray-100 dark:hover:bg-gray-800 ${ue.projectId===_?.projectId?"font-semibold":""}`,children:[s.jsx("span",{className:"truncate",children:Yp(ue)}),s.jsx(gn,{tone:"gray",children:ue.role})]},ue.projectId)),s.jsxs("div",{className:"mt-1.5 border-t border-gray-100 pt-1.5 dark:border-gray-800",children:[s.jsxs("button",{type:"button",className:si,onClick:()=>{S(!1),de(!0)},children:["+ ",m.project.create]}),_&&s.jsx("button",{type:"button",className:si,onClick:()=>{S(!1),ye(!0)},children:m.project.settings})]})]})]}),s.jsx("div",{className:"shrink-0 px-2 pb-2 pt-2",children:s.jsxs("button",{type:"button",onClick:()=>he(ot),className:`flex w-full items-center gap-2 rounded-md px-2.5 py-1.5 text-sm font-medium transition-colors duration-150 ${R===Ia?"bg-gray-200/70 text-gray-900 dark:bg-gray-800 dark:text-gray-100":"text-gray-600 hover:bg-gray-200/50 hover:text-gray-900 dark:text-gray-400 dark:hover:bg-gray-800/70 dark:hover:text-gray-200"}`,children:[s.jsx("span",{className:"text-gray-500 dark:text-gray-400",children:s.jsx(Jn,{d:Rh})}),m.chat.newSessionMenu]})}),s.jsxs("div",{className:"relative min-h-0 flex-1 overflow-y-auto px-2 pb-2",children:[s.jsx("nav",{className:"space-y-0.5",children:wa.map(ue=>s.jsxs(Zh,{to:ue.to,onClick:()=>e?.(),className:({isActive:_e})=>`flex items-center gap-2 rounded-md px-2.5 py-1.5 text-sm transition-colors duration-150 ${_e?"bg-gray-200/70 font-medium text-gray-900 dark:bg-gray-800 dark:text-gray-100":"text-gray-600 hover:bg-gray-200/50 hover:text-gray-900 dark:text-gray-400 dark:hover:bg-gray-800/70 dark:hover:text-gray-200"}`,children:[s.jsx("span",{className:"text-gray-500 dark:text-gray-400",children:s.jsx(Jn,{d:ue.icon})}),ue.label]},ue.to))}),s.jsxs("div",{className:"-mx-2 mt-3 flex items-center justify-between border-t border-gray-200 px-3 pt-2 dark:border-gray-800",children:[s.jsx("span",{className:"px-1 text-[11px] font-semibold uppercase tracking-wide text-gray-400 dark:text-gray-500",children:m.chat.sessionList}),s.jsx(gw,{value:Se,onChange:Da})]}),Oa.length>0&&s.jsxs("div",{className:"pt-2.5",children:[s.jsx(Uo,{open:!ze.has(Rp),onToggle:()=>on(Rp),icon:s.jsx("span",{className:"shrink-0 text-gray-400 dark:text-gray-500",children:s.jsx(Jn,{d:Rh,size:14})}),label:m.chat.draftGroup,uppercase:!0,count:Oa.length}),!ze.has(Rp)&&s.jsx("ul",{className:"space-y-0.5",children:Oa.map(ue=>s.jsx(aD,{entry:ue,active:ue.id===R,onOpen:()=>yn(`/chat/${ue.id}`),onDelete:()=>$t(ue)},ue.id))})]}),Se==="agent"?G&&F.length===0?s.jsx(pa,{rows:5}):qt.slice(0,Ce).map(ue=>{const _e=Wv(K.get(ue.agentId)??[]),ut=ze.has(ue.agentId),Je=W.has(ue.agentId);return s.jsxs("div",{className:"pt-2.5",children:[s.jsx(Uo,{open:!ut,onToggle:()=>on(ue.agentId),icon:s.jsx(xa,{id:ue.agentId,name:tn(ue),size:18,className:"shrink-0 rounded"}),label:tn(ue),uppercase:!0,actions:s.jsxs(s.Fragment,{children:[s.jsx(z1,{pinned:Je,onToggle:()=>Rr(ue.agentId)}),s.jsx("button",{type:"button",title:m.chat.newSessionMenu,"aria-label":m.chat.newSessionMenu,onClick:()=>he(ue.agentId),className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-gray-400 transition-colors duration-150 hover:bg-gray-200/70 hover:text-gray-800 dark:text-gray-500 dark:hover:bg-gray-800 dark:hover:text-gray-200",children:s.jsx(Jn,{d:"M12 5v14M5 12h14",size:18})}),s.jsx("button",{type:"button",title:m.agent.settings,onClick:()=>yn(`/agents/${ue.agentId}`),className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-gray-400 transition-colors duration-150 hover:bg-gray-200/70 hover:text-gray-800 dark:text-gray-500 dark:hover:bg-gray-800 dark:hover:text-gray-200",children:s.jsx(Jn,{d:kw,size:16})})]})}),ut?null:Xn(ue.agentId,_e,!1,O.get(ue.agentId),()=>[ue.agentId])]},ue.agentId)}):null,Se==="agent"&&qt.length>Ce?_n(qt.length):null,Se==="agent"?null:G&&Q.length===0?s.jsx(pa,{rows:5}):Zt.length===0?s.jsx("p",{className:"px-2.5 pt-3 text-xs text-gray-400 dark:text-gray-600",children:m.chat.noSessions}):Zt.slice(0,Ce).map(ue=>{const _e=Wv(ue.sessions),ut=ze.has(ue.key),Je=W.has(ue.key),Pt=Bn.get(ue.key),Wt=[...new Set(ue.sessions.map(bn=>bn.agentId))],Nn=bn=>[...new Set([...Pt?.agents[bn]??[],...Wt])];return s.jsxs("div",{className:"pt-2.5",children:[s.jsx(Uo,{open:!ut,onToggle:()=>on(ue.key),icon:s.jsx("span",{className:"shrink-0 text-gray-400 dark:text-gray-500",children:s.jsx(Jn,{d:ut?eg:dw,size:15})}),label:ue.temp?m.chat.tempWorkspaces:ue.label,count:Math.max(Pt?.totals.active??0,_e.active.length),...ue.fullPath!==null?{title:ue.fullPath}:{},actions:s.jsxs(s.Fragment,{children:[s.jsx(z1,{pinned:Je,onToggle:()=>Rr(ue.key)}),s.jsx("button",{type:"button",title:m.chat.newSessionInWorkspace,"aria-label":m.chat.newSessionInWorkspace,onClick:()=>he(rt,ue.fullPath??""),className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-gray-400 transition-colors duration-150 hover:bg-gray-200/70 hover:text-gray-800 dark:text-gray-500 dark:hover:bg-gray-800 dark:hover:text-gray-200",children:s.jsx(Jn,{d:"M12 5v14M5 12h14",size:18})})]})}),ut?null:Xn(ue.key,_e,!0,Pt?.totals,Nn)]},ue.key)}),Se==="workspace"&&Zt.length>Ce?_n(Zt.length):null]}),s.jsx("div",{className:"shrink-0 border-t border-gray-200 p-2 dark:border-gray-800",children:s.jsxs(ga,{open:U,setOpen:ee,menuClass:"bottom-full left-0 right-0 mb-1 origin-bottom",button:s.jsxs("button",{type:"button",onClick:()=>ee(!U),...wt!==null?{title:m.update.newVersion(wt),"aria-label":`${l?.userId??""} · ${m.update.newVersion(wt)}`}:{},className:"flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left transition-colors duration-150 hover:bg-gray-200/70 dark:hover:bg-gray-800",children:[s.jsxs("span",{className:"relative flex h-7 w-7 shrink-0 items-center justify-center rounded-full bg-gray-900 text-xs font-bold text-white dark:bg-gray-200 dark:text-gray-900",children:[(l?.userId??"?").slice(0,1).toUpperCase(),je&&s.jsx("span",{"aria-hidden":!0,className:"absolute -right-0.5 -top-0.5 h-2.5 w-2.5 rounded-full border-2 border-gray-50 bg-[var(--accent-bg)] dark:border-gray-900"})]}),s.jsx("span",{className:"min-w-0 flex-1 truncate text-sm font-medium",children:l?.userId}),l?.isAdmin&&s.jsx("span",{className:"text-xs text-gray-400 dark:text-gray-500",children:m.auth.admin})]}),children:[s.jsxs("div",{className:"space-y-2.5 px-3 py-2",children:[s.jsx(li,{label:m.settings.theme,children:s.jsx(gl,{options:qn,value:u,onChange:f})}),s.jsx(li,{label:m.settings.fontSize,children:s.jsx(gl,{options:Ni,value:p,onChange:h})}),s.jsx(li,{label:m.settings.accent,children:s.jsx(sD,{value:g,onChange:v})}),s.jsx(li,{label:m.models.currency,children:s.jsx(gl,{options:ns,value:k,onChange:w,cols:2})}),s.jsx(li,{label:m.settings.language,children:s.jsx(gl,{options:Ml,value:j,onChange:C})}),s.jsx(li,{label:m.settings.showCliSessions,children:s.jsx(wl,{checked:Z,onChange:X})})]}),s.jsxs("div",{className:"mt-1 border-t border-gray-100 pt-1 dark:border-gray-800",children:[s.jsx("button",{type:"button",className:si,onClick:()=>{ee(!1),be(!0)},children:m.account.changePassword}),l?.isAdmin&&s.jsx("button",{type:"button",className:si,onClick:()=>{ee(!1),fn(!0)},children:m.settings.proxyMenu}),!c&&s.jsxs("button",{type:"button",disabled:rn,onClick:()=>{wt!==null?(ee(!1),Fe(!0)):Ut()},...an!==null?{title:m.update.lastUpdated(Cw(an,E))}:{},className:`${si} flex items-center justify-between gap-2 disabled:cursor-default disabled:opacity-60`,children:[s.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[rn&&s.jsx("span",{"aria-hidden":!0,className:"inline-block h-3 w-3 shrink-0 animate-spin rounded-full border-[1.5px] border-current border-t-transparent opacity-70"}),!rn&&wt!==null&&s.jsx("span",{"aria-hidden":!0,className:"h-2 w-2 shrink-0 rounded-full bg-[var(--accent-bg)]"}),s.jsx("span",{className:"min-w-0 truncate",children:rn?m.update.checking:wt!==null?m.update.newVersion(wt):m.update.checkNow})]}),ce!==null&&s.jsx("span",{className:"shrink-0 text-xs text-gray-400 dark:text-gray-500",children:`v${ce.version}`})]}),l?.isAdmin&&!c&&s.jsx("button",{type:"button",className:si,onClick:()=>{ee(!1),yn("/admin/users")},children:m.admin.users}),!c&&s.jsx("button",{type:"button",className:"block w-full px-3.5 py-2 text-left text-sm text-red-600 transition-colors duration-150 hover:bg-red-50 dark:text-red-400 dark:hover:bg-red-950/40",onClick:()=>{ee(!1),o().then(()=>a("/login"))},children:m.auth.logout})]})]})}),s.jsx(BS,{open:te,onClose:()=>be(!1)}),s.jsx(XO,{open:At,onClose:()=>fn(!1)}),s.jsx(ZO,{open:Re,onClose:()=>Fe(!1),latestVersion:wt,releaseUrl:Ve?.releaseUrl??null,canUpdate:l?.isAdmin===!0,onRunFinished:()=>{Kv().catch(()=>{})}}),s.jsx(GO,{open:ie,onClose:()=>de(!1),onCreated:ue=>{de(!1),V().then(()=>D(ue))}}),_&&s.jsx(WO,{open:me,onClose:()=>ye(!1)}),s.jsx(Gt,{open:aa!==null,title:m.chat.renameSession,onClose:()=>Yn?void 0:En(null),footer:s.jsxs(s.Fragment,{children:[s.jsx(we,{onClick:()=>En(null),disabled:Yn,children:m.common.cancel}),s.jsx(we,{variant:"primary",disabled:Yn||!An.trim(),onClick:()=>{ra()},children:m.common.save})]}),children:s.jsx(at,{label:m.chat.renameSessionLabel,value:An,error:Pn??void 0,autoFocus:!0,maxLength:120,onChange:ue=>{ar(ue.target.value),Pn&&ba(null)},onKeyDown:ue=>{ue.key==="Enter"&&An.trim()&&!Yn&&ra()}})}),s.jsx(Mn,{open:Ke!==null,title:m.chat.deleteSession,confirmLabel:m.common.delete,busy:xt,onClose:()=>xt?void 0:vt(null),onConfirm:()=>{za()},children:s.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-300",children:Ke?m.chat.deleteSessionConfirm(Ke.title??m.chat.defaultSessionTitle):""})}),s.jsx(Mn,{open:ln!==null,title:m.chat.deleteDraft,confirmLabel:m.common.delete,onClose:()=>$t(null),onConfirm:Le,children:s.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-300",children:ln?m.chat.deleteDraftConfirm(IS(ln)||m.chat.draftUntitled):""})})]})}function aD({entry:e,active:t,onOpen:a,onDelete:l}){const o=IS(e)||m.chat.draftUntitled;return s.jsx("li",{children:s.jsxs("div",{className:`group flex items-center rounded-md pr-1 transition-colors duration-150 ${t?"bg-gray-200/70 dark:bg-gray-800":"hover:bg-gray-200/50 dark:hover:bg-gray-800/70"}`,children:[s.jsx("button",{type:"button",onClick:a,className:"flex min-w-0 flex-1 items-center gap-1.5 px-2.5 py-1.5 text-left",children:s.jsx(ic,{text:o,className:`min-w-0 flex-1 text-sm ${t?"font-medium text-gray-900 dark:text-gray-100":"text-gray-700 dark:text-gray-300"}`})}),s.jsx("div",{className:"flex shrink-0 items-center",children:s.jsx("button",{type:"button",title:m.chat.deleteDraft,"aria-label":m.chat.deleteDraft,onClick:l,className:"flex h-6 w-6 shrink-0 items-center justify-center rounded text-gray-400 opacity-0 transition-all duration-150 hover:bg-gray-300/60 hover:text-red-600 focus-visible:opacity-100 group-hover:opacity-100 dark:hover:bg-gray-700 dark:hover:text-red-400",children:s.jsx(Jn,{d:"M4 6h16M9 6V4.5A1.5 1.5 0 0 1 10.5 3h3A1.5 1.5 0 0 1 15 4.5V6M6 6v13a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V6M10 10.5v6M14 10.5v6",size:14})})})]})})}function z1({pinned:e,onToggle:t}){return s.jsx("button",{type:"button",title:e?m.nav.unpinGroup:m.nav.pinGroup,"aria-label":m.nav.pinGroup,"aria-pressed":e,onClick:t,className:`flex h-7 w-7 shrink-0 items-center justify-center rounded-md transition-all duration-150 hover:bg-gray-200/70 hover:text-gray-800 dark:hover:bg-gray-800 dark:hover:text-gray-200 ${e?"text-gray-500 dark:text-gray-400":"text-gray-400 opacity-0 focus-visible:opacity-100 group-hover/header:opacity-100 dark:text-gray-500"}`,children:s.jsx(Jn,{d:JO,size:15})})}function rD({s:e,active:t,agentHint:a,onOpen:l,onRename:o,onDelete:c,onToggleArchive:u}){const f="flex h-6 w-6 shrink-0 items-center justify-center rounded text-gray-400 opacity-0 transition-all duration-150 focus-visible:opacity-100 group-hover:opacity-100";return s.jsx("li",{children:s.jsxs("div",{className:`group flex items-center rounded-md pr-1 transition-colors duration-150 ${t?"bg-gray-200/70 dark:bg-gray-800":"hover:bg-gray-200/50 dark:hover:bg-gray-800/70"}`,children:[s.jsxs("button",{type:"button",onClick:()=>l(e),className:"flex min-w-0 flex-1 items-center gap-1.5 px-2.5 py-1.5 text-left",children:[a!==void 0&&s.jsxs("span",{title:a,className:"flex shrink-0 items-center",children:[s.jsx(xa,{id:e.agentId,name:a,size:14,className:"rounded"}),s.jsx("span",{className:"sr-only",children:a})]}),s.jsx(ic,{text:e.title??m.chat.defaultSessionTitle,className:`min-w-0 flex-1 text-sm ${t?"font-medium text-gray-900 dark:text-gray-100":e.archived?"text-gray-400 dark:text-gray-500":"text-gray-700 dark:text-gray-300"}`}),s.jsx(nD,{session:e}),e.pendingApprovalCount>0&&s.jsx("span",{title:m.chat.pendingApprovals(e.pendingApprovalCount),children:s.jsx(gn,{tone:"amber",children:e.pendingApprovalCount})})]}),s.jsxs("div",{className:"flex shrink-0 items-center",children:[s.jsx("button",{type:"button",title:m.chat.renameSession,"aria-label":m.chat.renameSession,onClick:()=>o(e),className:`${f} hover:bg-gray-300/60 hover:text-gray-700 dark:hover:bg-gray-700 dark:hover:text-gray-200`,children:s.jsx(Jn,{d:"M4 20h4L18.5 9.5a2.1 2.1 0 0 0-3-3L5 17v3zM14 7l3 3",size:14})}),s.jsx("button",{type:"button",title:e.archived?m.chat.unarchiveSession:m.chat.archiveSession,"aria-label":e.archived?m.chat.unarchiveSession:m.chat.archiveSession,onClick:()=>u(e),className:`${f} hover:bg-gray-300/60 hover:text-gray-700 dark:hover:bg-gray-700 dark:hover:text-gray-200`,children:s.jsx(Jn,{d:e.archived?"M3 8h18M5 8v11a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1V8M4 8l1.5-3h13L20 8M12 17v-5m-2.5 2L12 11l2.5 3":"M3 8h18M5 8v11a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1V8M4 8l1.5-3h13L20 8M9.5 13.5 12 16l2.5-2.5",size:14})}),s.jsx("button",{type:"button",title:m.chat.deleteSession,"aria-label":m.chat.deleteSession,onClick:()=>c(e),className:`${f} hover:bg-gray-300/60 hover:text-red-600 dark:hover:bg-gray-700 dark:hover:text-red-400`,children:s.jsx(Jn,{d:"M4 6h16M9 6V4.5A1.5 1.5 0 0 1 10.5 3h3A1.5 1.5 0 0 1 15 4.5V6M6 6v13a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V6M10 10.5v6M14 10.5v6",size:14})})]})]})})}function li({label:e,children:t}){return s.jsxs("div",{children:[s.jsx("p",{className:"mb-1 text-[11px] font-medium text-gray-500 dark:text-gray-400",children:e}),t]})}function sD({value:e,onChange:t}){return s.jsx("div",{className:"flex items-center gap-1.5",children:RC.map(a=>s.jsx("button",{type:"button",title:m.settings.accentNames[a.value],"aria-label":m.settings.accentNames[a.value],"aria-pressed":e===a.value,onClick:()=>t(a.value),className:`h-5 w-5 rounded-full border transition-transform duration-150 hover:scale-110 ${e===a.value?"border-gray-500 ring-2 ring-gray-400/50 dark:border-gray-300":"border-transparent"}`,style:{backgroundColor:a.color}},a.value))})}const lD="M8 10h8M8 14h5M21 12a9 9 0 1 1-4.2-7.6L21 4v5h-5",_p=e=>`flex h-8 w-8 items-center justify-center rounded-md transition-colors duration-150 ${e?"bg-gray-200/70 text-gray-900 dark:bg-gray-800 dark:text-gray-100":"text-gray-500 hover:bg-gray-200/70 hover:text-gray-800 dark:text-gray-400 dark:hover:bg-gray-800 dark:hover:text-gray-200"}`;function iD({onExpand:e}){const{user:t}=xn(),a=Wn(),{agents:l,currentProject:o,setCurrentAgentId:c}=Xt(),{sessions:u,loading:f}=Bs(),{update:p}=Jh(!1),h=p?.updateAvailable===!0?p.latestVersion??null:null,g=Zk("/chat/:sessionId")?.params.sessionId??null,v=g!==null&&g!==Ia,k=y.useMemo(()=>ow(u),[u]),w=()=>{k&&(c(k.agentId),a(`/chat/${k.sessionId}`))},j=()=>{t&&o&&Ci(t.userId,o.projectId);const C=(l.find(M=>M.agentId==="default_agent")??l[0])?.agentId;C&&c(C),a(`/chat/${Ia}`,C?{state:{agentId:C}}:void 0)},E=[{to:"/agents",label:m.nav.agents,icon:Za.agents},{to:"/skills",label:m.nav.skills,icon:Za.skills},{to:"/models",label:m.nav.models,icon:Za.models},{to:"/usage",label:m.nav.usage,icon:Za.usage},{to:"/traces",label:m.nav.traces,icon:Za.traces},{to:"/benchmark",label:m.nav.benchmark,icon:Za.benchmark}];return s.jsxs("div",{className:"flex h-full flex-col items-center gap-1 py-2.5",children:[s.jsx("button",{type:"button",title:m.nav.expandSidebar,"aria-label":m.nav.expandSidebar,onClick:e,className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-md text-gray-500 transition-colors duration-150 hover:bg-gray-200/70 hover:text-gray-800 dark:text-gray-400 dark:hover:bg-gray-800 dark:hover:text-gray-200",children:s.jsx(qe,{d:"M9 6l6 6-6 6M20 4v16",size:18})}),s.jsxs("nav",{className:"no-scrollbar mt-1 flex min-h-0 flex-1 flex-col items-center gap-1 overflow-y-auto",children:[s.jsx("button",{type:"button",title:m.nav.lastConversation,"aria-label":m.nav.lastConversation,disabled:!k&&!f,onClick:w,className:k||f?_p(v):"flex h-8 w-8 cursor-not-allowed items-center justify-center rounded-md text-gray-300 dark:text-gray-700",children:s.jsx(qe,{d:lD,size:18})}),s.jsx("button",{type:"button",title:m.chat.newSessionMenu,"aria-label":m.chat.newSessionMenu,onClick:j,className:_p(g===Ia),children:s.jsx(qe,{d:Rh,size:18})}),E.map(C=>s.jsx(Zh,{to:C.to,title:C.label,"aria-label":C.label,className:({isActive:M})=>_p(M),children:s.jsx(qe,{d:C.icon,size:18})},C.to))]}),s.jsxs("button",{type:"button",title:[t?.userId??"",m.nav.expandSidebar].concat(h!==null?[m.update.newVersion(h)]:[]).join(" · "),"aria-label":h!==null?`${t?.userId??""} · ${m.update.newVersion(h)}`:t?.userId??m.auth.admin,onClick:e,className:"relative mt-auto flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-gray-900 text-xs font-bold text-white dark:bg-gray-200 dark:text-gray-900",children:[(t?.userId??"?").slice(0,1).toUpperCase(),h!==null&&s.jsx("span",{"aria-hidden":!0,className:"absolute -right-0.5 -top-0.5 h-2.5 w-2.5 rounded-full border-2 border-gray-50 bg-[var(--accent-bg)] dark:border-gray-900"})]})]})}function oD(){const{user:e,desktopMode:t}=xn();BT();const[a,l]=y.useState(!1),[o,c]=y.useState(!1),[u,f]=y.useState(null),p=!!e?.passwordIsInitial&&!t;y.useEffect(()=>{if(!p)return;let w=!1;return Ph().then(j=>{w||f(j.prefs.initialPasswordBannerDismissed===!0)}).catch(()=>{w||f(!1)}),()=>{w=!0}},[p]);const h=()=>{f(!0),jd({initialPasswordBannerDismissed:!0}).catch(()=>{})},[g,v]=y.useState(()=>localStorage.getItem("penguin.sidebarCollapsed")==="1"),k=()=>v(w=>{const j=!w;return localStorage.setItem("penguin.sidebarCollapsed",j?"1":"0"),j});return s.jsxs("div",{className:"flex h-full",children:[s.jsx("aside",{className:`hidden shrink-0 border-r border-gray-200 bg-gray-50 md:block dark:border-gray-800 dark:bg-gray-900 ${g?"w-12":"w-64 lg:w-72"}`,children:g?s.jsx(iD,{onExpand:k}):s.jsx(D1,{onCollapse:k})}),s.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[s.jsxs("header",{className:"flex h-12 shrink-0 items-center gap-2 border-b border-gray-200 bg-white px-2 md:hidden dark:border-gray-800 dark:bg-gray-950",children:[s.jsx("button",{type:"button","aria-label":m.chat.sessionList,onClick:()=>l(!0),className:"flex h-9 w-9 items-center justify-center rounded-md text-gray-500 transition-colors duration-150 hover:bg-gray-100 hover:text-gray-800 dark:text-gray-400 dark:hover:bg-gray-800 dark:hover:text-gray-200",children:s.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round","aria-hidden":!0,children:s.jsx("path",{d:"M4 6h16M4 12h16M4 18h16"})})}),s.jsx("span",{className:"text-sm font-semibold",children:m.appName})]}),p&&u===!1&&s.jsxs("div",{className:"relative flex shrink-0 items-center justify-center gap-3 border-b border-amber-200 bg-amber-50 px-8 py-1.5 text-xs text-amber-800 dark:border-amber-900/60 dark:bg-amber-950/40 dark:text-amber-300",children:[s.jsx("span",{children:m.account.initialPasswordBanner}),s.jsx("button",{type:"button",className:"shrink-0 font-medium underline underline-offset-2 hover:text-amber-950 dark:hover:text-amber-100",onClick:()=>c(!0),children:m.account.changeNow}),s.jsx("button",{type:"button","aria-label":m.common.close,title:m.common.close,onClick:h,className:"absolute inset-y-0.5 right-1.5 flex items-center rounded-md px-1 text-amber-500 transition-colors duration-150 hover:text-amber-950 dark:text-amber-400/70 dark:hover:text-amber-100",children:s.jsx("svg",{width:"12",height:"12",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor","aria-hidden":!0,children:s.jsx("path",{d:"M2 2l10 10M12 2L2 12",strokeWidth:"1.5",strokeLinecap:"round"})})})]}),s.jsx("main",{className:"min-h-0 flex-1 overflow-hidden",children:s.jsx(G4,{})})]}),s.jsx(BS,{open:o,onClose:()=>c(!1)}),s.jsx(ww,{open:a,side:"left",title:m.appName,onClose:()=>l(!1),children:s.jsx("div",{className:"h-full bg-gray-50 dark:bg-gray-900",children:s.jsx(D1,{onNavigate:()=>l(!1)})})})]})}const $g=1440,Pg=900,_h=3,cD=3,U1=$g/_h,$1=Pg/cD,Pu=28,Bu=14;function uD(e){return()=>{e|=0,e=e+1831565813|0;let t=Math.imul(e^e>>>15,1|e);return t=t+Math.imul(t^t>>>7,61|t)^t,((t^t>>>14)>>>0)/4294967296}}function dD(e,t){return e.x1-Bu<=t.x2&&e.x2+Bu>=t.x1&&e.y1-Bu<=t.y2&&e.y2+Bu>=t.y1}function fD(e,t,a,l){return{x1:Math.min(e,a),y1:Math.min(t,l),x2:Math.max(e,a),y2:Math.max(t,l)}}const mD=[{cell:0,edge:"left"},{cell:1,edge:"top"},{cell:2,edge:"right"},{cell:3,edge:"left"},{cell:5,edge:"right"},{cell:6,edge:"bottom"},{cell:7,edge:"bottom"},{cell:8,edge:"right"}];function pD(){const e=uD(12696599),t=[];for(const{cell:a,edge:l}of mD){const o=a%_h*U1+Pu,c=Math.floor(a/_h)*$1+Pu,u=o+U1-2*Pu,f=c+$1-2*Pu,p=[],h=(D,V,F,A)=>{const P=F[0]>0?u-D:F[0]<0?D-o:F[1]>0?f-V:V-c;for(let Q=Math.min(60+e()*150,P);Q>=40;Q/=2){const K=Math.round(D+F[0]*Q),O=Math.round(V+F[1]*Q),z=fD(D,V,K,O);if(p.every((I,B)=>A.has(B)||!dD(z,I)))return p.push(z),[K,O]}return null},g=(D,V,F)=>(F-D)*(.35+e()*.3)>D-V?1:-1,v=(D,V,F,A,P,Q,K)=>{let[O,z]=[D,V],I=F;const B=[`M${Math.round(O)},${Math.round(z)}`],$=[];for(let G=0;G<A;G+=1){const q=G===0?K:new Set([p.length-1]),ae=h(O,z,I,q);if(!ae)break;[O,z]=ae,B.push(`L${O},${z}`),$.push([O,z]),I=I[0]!==0?[0,g(z,c,f)]:[g(O,o,u),0]}return $.length>=2&&t.push({d:B.join(" "),end:$[$.length-1],dur:P,delay:Q}),$},k=.15+e()*.7,w=l==="left"?0:l==="right"?$g:Math.round(o+(u-o)*k),j=l==="top"?0:l==="bottom"?Pg:Math.round(c+(f-c)*k),E=l==="left"?[1,0]:l==="right"?[-1,0]:l==="top"?[0,1]:[0,-1],C=12+e()*8,M=e()*3.2,_=v(w,j,E,3+Math.floor(e()*3),C,M,new Set);if(a%2===0&&_.length>=3){const[D,V]=_[1],[F,A]=_[2],P=[-Math.sign(F-D),-Math.sign(A-V)];v(D,V,P,2,C,M+1.4,new Set([1,2]))}}return t}const hD=pD();function gD(){return s.jsx("svg",{"aria-hidden":!0,className:"pointer-events-none absolute inset-0 h-full w-full text-slate-500/25 dark:text-cyan-300/15",viewBox:`0 0 ${$g} ${Pg}`,preserveAspectRatio:"xMidYMid slice",fill:"none",children:hD.map((e,t)=>s.jsxs("g",{style:{"--trace-dur":`${e.dur.toFixed(1)}s`},children:[s.jsx("path",{d:e.d,pathLength:1,stroke:"currentColor",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round",className:"login-trace",style:{animationDelay:`${e.delay.toFixed(1)}s`}}),s.jsx("circle",{cx:e.end[0],cy:e.end[1],r:"3",fill:"currentColor",className:"login-via",style:{animationDelay:`${e.delay.toFixed(1)}s`}})]},t))})}function xD(){Er(m.auth.login);const{login:e}=xn(),{mode:t,setMode:a}=Ps(),{lang:l,setLang:o}=La(),c=Wn(),[u,f]=y.useState(""),[p,h]=y.useState(""),[g,v]=y.useState({}),[k,w]=y.useState(!1),j=()=>v(_=>_.userId||_.password||_.form?{}:_),E=async()=>{const _={};if(u.trim()||(_.userId=m.common.requiredField),p||(_.password=m.common.requiredField),_.userId||_.password){v(_);return}w(!0),v({});try{await e(u.trim(),p),c("/chat",{replace:!0})}catch(D){v({form:Ie(D)})}finally{w(!1)}},C=[{value:"light",label:m.settings.themeLight},{value:"dark",label:m.settings.themeDark},{value:"system",label:m.settings.followSystem}],M=[{value:"en",label:m.settings.langEn},{value:"zh",label:m.settings.langZh},{value:"system",label:m.settings.followSystem}];return s.jsxs("div",{className:"relative flex min-h-full items-center justify-center overflow-hidden p-4",children:[s.jsx(gD,{}),s.jsxs("div",{className:"absolute right-4 top-4 flex flex-col items-end gap-1.5 sm:flex-row sm:items-center sm:gap-2",children:[s.jsx("div",{"aria-label":m.settings.language,children:s.jsx(gl,{options:M,value:l,onChange:o})}),s.jsx("div",{"aria-label":m.settings.theme,children:s.jsx(gl,{options:C,value:t,onChange:a})})]}),s.jsxs("div",{className:"anim-rise relative w-full max-w-sm",children:[s.jsx(TS,{className:"mx-auto mb-3 h-16 w-16 rounded-2xl"}),s.jsx("h1",{className:"mb-6 text-center text-3xl font-semibold tracking-tight",children:m.appName}),s.jsxs("div",{className:"rounded-xl border border-gray-200 bg-white p-6 shadow-sm dark:border-gray-800 dark:bg-gray-900",children:[s.jsxs("form",{className:"space-y-4",onSubmit:_=>{_.preventDefault(),E()},children:[s.jsx(at,{label:m.common.username,required:!0,value:u,onChange:_=>{f(_.target.value),j()},error:g.userId,autoComplete:"username",autoFocus:!0}),s.jsx(zs,{label:m.auth.password,required:!0,value:p,onChange:_=>{h(_.target.value),j()},error:g.password,autoComplete:"current-password"}),g.form&&s.jsx("p",{className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700 dark:border-red-900 dark:bg-red-950/50 dark:text-red-300",children:g.form}),s.jsx(we,{type:"submit",variant:"primary",className:"w-full justify-center py-2.5 text-sm font-semibold",disabled:k,children:m.auth.login})]}),s.jsx("p",{className:"mt-4 text-center text-xs text-gray-400 dark:text-gray-500",children:m.auth.defaultAdminNote})]})]})]})}const To=100,_s=30,Ka=2;function yD({data:e,label:t,className:a=""}){const l=Math.max(1,...e),o=e.length>1?(To-2*Ka)/(e.length-1):0,c=e.map((h,g)=>[Ka+g*o,_s-Ka-h/l*(_s-2*Ka)]),u=`${Ka},${_s-Ka} ${To-Ka},${_s-Ka}`,f=c.length>1?c.map(([h,g])=>`${h},${g}`).join(" "):u,p=c.length>1?`${f} ${To-Ka},${_s-Ka} ${Ka},${_s-Ka}`:null;return s.jsxs("svg",{width:To,height:_s,viewBox:`0 0 ${To} ${_s}`,role:"img","aria-label":t,className:`text-emerald-600 dark:text-emerald-500 ${a}`,children:[s.jsx("title",{children:t}),p!==null&&s.jsx("polygon",{points:p,fill:"currentColor",fillOpacity:"0.12"}),s.jsx("polyline",{points:f,fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]})}const vD=new Set(["default_agent"]),ur={newChat:"M12 5v14M5 12h14",trash:"M4 7h16M9 7V5a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2m3 0l-1 13a2 2 0 0 1-2 2H9a2 2 0 0 1-2-2L6 7m4 4v6m4-6v6",sessions:"M8 10h8M8 14h5M21 12a9 9 0 1 1-4-7.5",vaultKeys:"M15.5 7.5l3 3L22 7l-3-3M21 2l-9.6 9.6M13 15.5a5.5 5.5 0 1 1-11 0 5.5 5.5 0 0 1 11 0z",schedules:"M12 21a7 7 0 1 0 0-14 7 7 0 0 0 0 14zm0-10v3l2 1.5M5 3L2.5 5.5M19 3l2.5 2.5",skills:"M12 6.5C10.5 5 8 4.5 4 5v12c4-.5 6.5 0 8 1.5 1.5-1.5 4-2 8-1.5V5c-4-.5-6.5 0-8 1.5zm0 0V18",usage:"M4 20V10m6 10V4m6 16v-7m4 7H2",traces:"M2 12s3.6-7 10-7 10 7 10 7-3.6 7-10 7-10-7-10-7zM12 9a3 3 0 1 0 0 6 3 3 0 0 0 0-6z",memory:"M12 5a3 3 0 1 0-5.997.125 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18ZM12 5a3 3 0 1 1 5.997.125 4 4 0 0 1 2.526 5.77 4 4 0 0 1-.556 6.588A4 4 0 1 1 12 18ZM15 13a4.5 4.5 0 0 1-3-4 4.5 4.5 0 0 1-3 4",kernelUpdate:"M23 4v6h-6M20.49 15a9 9 0 1 1-2.12-9.36L23 10"},Mo="inline-flex shrink-0 cursor-pointer items-center gap-1 tabular-nums transition-colors duration-150 hover:text-gray-800 dark:hover:text-gray-200";function bD(){const e=Wn();Er(m.nav.agents);const{locale:t}=La(),{user:a}=xn(),{currentProject:l,agents:o,agentsLoading:c,reloadAgents:u,setCurrentAgentId:f}=Xt(),[p,h]=y.useState(!1),[g,v]=y.useState(""),[k,w]=y.useState(""),[j,E]=y.useState(""),[C,M]=y.useState(void 0),[_,D]=y.useState(!1),V=()=>{v(""),w(""),E(""),M(void 0),h(!0)},[F,A]=y.useState(null),[P,Q]=y.useState(null),K=l?.projectId,O=async()=>{if(!K)return;const $=g.trim();if(!$){M(m.common.requiredField);return}if(!$S.test($)){M(m.agent.idHint);return}D(!0),M(void 0);try{const G={agentId:$};k.trim()&&(G.name=k.trim()),j.trim()&&(G.description=j.trim());const q=await oN(K,G);h(!1),await u(),f(q.agent.agentId),e(`/agents/${q.agent.agentId}`)}catch(G){M(Ie(G))}finally{D(!1)}},z=$=>{a&&K&&Ci(a.userId,K),f($),e(`/chat/${Ia}`,{state:{agentId:$}})},I=($,G)=>{f($),e(`/agents/${$}?tab=${G}`)},B=async()=>{if(!(!K||!F)){D(!0),Q(null);try{await CN(K,F.agentId),A(null),await u()}catch($){Q(Ie($))}finally{D(!1)}}};return s.jsxs("div",{className:"h-full overflow-y-auto p-4 md:p-6",children:[s.jsxs("div",{className:"mx-auto max-w-5xl",children:[s.jsxs("div",{className:"mb-4 flex items-center justify-between gap-2",children:[s.jsx("h1",{className:"text-xl font-semibold",children:m.agent.listTitle}),s.jsx(we,{variant:"primary",onClick:V,children:m.agent.create})]}),c?s.jsx("div",{className:"space-y-3",children:Array.from({length:4},($,G)=>s.jsxs(Ow,{className:"flex flex-wrap items-center gap-x-6 gap-y-2 px-5 py-4",children:[s.jsxs("div",{className:"min-w-[14rem] flex-1",children:[s.jsx(en,{className:"h-[18px] w-40"}),s.jsx(en,{className:"mt-1.5 h-4 w-2/3"}),s.jsx(en,{className:"mt-1.5 h-4 w-48"})]}),s.jsx(en,{className:"hidden h-9 w-40 md:block"}),s.jsx(en,{className:"h-8 w-52"})]},G))}):o.length===0?s.jsx(Nr,{title:m.common.none}):s.jsx("div",{className:"space-y-3",children:o.map($=>{const G=vD.has($.agentId);return s.jsxs("div",{className:"flex flex-wrap items-center gap-x-6 gap-y-2 rounded-md border border-gray-200 bg-white px-5 py-4 dark:border-gray-800 dark:bg-gray-900",children:[s.jsxs("div",{className:"min-w-[14rem] flex-1",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(xa,{id:$.agentId,name:tn($),size:18,className:"shrink-0 rounded"}),s.jsx("span",{className:"min-w-0 truncate text-base font-bold",children:tn($)}),s.jsx("span",{className:"hidden shrink-0 font-mono text-xs text-gray-400 md:inline dark:text-gray-500",children:$.agentId}),s.jsxs(gn,{tone:"gray",children:["v",$.version]}),$.kernelOutdated&&s.jsx("button",{type:"button",className:"shrink-0 cursor-pointer text-gray-400 transition-colors duration-150 hover:text-gray-600 dark:text-gray-500 dark:hover:text-gray-300",title:m.agent.kernelOutdatedHint,"aria-label":m.agent.kernelOutdatedHint,onClick:()=>I($.agentId,"overview"),children:s.jsx(qe,{d:ur.kernelUpdate,size:12})})]}),s.jsx("p",{className:"mt-1.5 min-h-4 truncate text-xs text-gray-500 dark:text-gray-400",children:$.description??""}),s.jsxs("div",{className:"mt-1.5 flex items-center gap-x-4 text-xs text-gray-500 dark:text-gray-400",children:[s.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1 tabular-nums",title:m.agent.sessionCount($.sessionCount),children:[s.jsx(qe,{d:ur.sessions,size:12}),$.sessionCount]}),s.jsxs("button",{type:"button",className:Mo,title:m.agent.toolCount($.toolCount),"aria-label":m.agent.toolCount($.toolCount),onClick:()=>I($.agentId,"tools"),children:[s.jsx(qe,{d:Un.toolCalls,size:12}),$.toolCount]}),s.jsxs("button",{type:"button",className:Mo,title:m.skills.skillCount($.skillCount),"aria-label":m.skills.skillCount($.skillCount),onClick:()=>I($.agentId,"skills"),children:[s.jsx(qe,{d:ur.skills,size:12}),$.skillCount]}),s.jsxs("button",{type:"button",className:Mo,title:m.agent.memoryCount($.memoryCount),"aria-label":m.agent.memoryCount($.memoryCount),onClick:()=>I($.agentId,"memory"),children:[s.jsx(qe,{d:ur.memory,size:12}),$.memoryCount]}),s.jsxs("button",{type:"button",className:Mo,title:m.agent.vaultKeyCount($.vaultKeyCount),"aria-label":m.agent.vaultKeyCount($.vaultKeyCount),onClick:()=>I($.agentId,"vault"),children:[s.jsx(qe,{d:ur.vaultKeys,size:12}),$.vaultKeyCount]}),s.jsxs("button",{type:"button",className:Mo,title:m.agent.scheduleCount($.scheduleCount),"aria-label":m.agent.scheduleCount($.scheduleCount),onClick:()=>I($.agentId,"schedules"),children:[s.jsx(qe,{d:ur.schedules,size:12}),$.scheduleCount]}),s.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1",title:`${m.agent.updatedAt} ${$.updatedAt?ha($.updatedAt):"—"}`,children:[s.jsx(qe,{d:Un.elapsed,size:12}),$.updatedAt?FT($.updatedAt,t):"—"]})]})]}),s.jsx(yD,{data:$.sessionActivity,label:m.agent.activity($.sessionActivity.length||30),className:"hidden shrink-0 md:block"}),s.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[s.jsxs(we,{size:"sm",variant:"primary",onClick:()=>z($.agentId),children:[s.jsx(qe,{d:ur.newChat}),m.chat.newSessionMenu]}),s.jsxs(we,{size:"sm",onClick:()=>{f($.agentId),e(`/agents/${$.agentId}`)},children:[s.jsx(qe,{d:kw}),m.common.settings]}),s.jsx(we,{size:"icon",title:m.nav.usage,"aria-label":m.nav.usage,onClick:()=>e(`/usage?agentId=${encodeURIComponent($.agentId)}`),children:s.jsx(qe,{d:ur.usage,size:15,className:"text-gray-600 dark:text-gray-300"})}),s.jsx(we,{size:"icon",title:m.nav.traces,"aria-label":m.nav.traces,onClick:()=>e(`/traces?agentId=${encodeURIComponent($.agentId)}`),children:s.jsx(qe,{d:ur.traces,size:15,className:"text-gray-600 dark:text-gray-300"})}),G?s.jsx("span",{role:"img",title:m.agent.builtinUndeletable,"aria-label":m.agent.builtinUndeletable,className:"inline-flex cursor-not-allowed items-center justify-center rounded-md border border-transparent p-1.5 text-gray-300 dark:text-gray-600",children:s.jsx(qe,{d:ur.trash,size:15})}):s.jsx(we,{size:"icon",variant:"danger",title:m.agent.deleteAgent,"aria-label":m.agent.deleteAgent,onClick:()=>A({agentId:$.agentId,name:tn($)}),children:s.jsx(qe,{d:ur.trash,size:15})})]})]},$.agentId)})})]}),s.jsx(Gt,{open:p,title:m.agent.createTitle,onClose:()=>h(!1),footer:s.jsxs(s.Fragment,{children:[s.jsx(we,{onClick:()=>h(!1),children:m.common.cancel}),s.jsx(we,{variant:"primary",disabled:_,onClick:()=>{O()},children:m.common.create})]}),children:s.jsxs("div",{className:"space-y-3",children:[s.jsx(at,{label:m.agent.id,required:!0,size:"sm",value:g,onChange:$=>{v($.target.value),M(void 0)},error:C,hint:m.agent.idHint,autoFocus:!0}),s.jsx(at,{label:m.common.name,size:"sm",value:k,onChange:$=>w($.target.value),hint:m.agent.nameHint}),s.jsx(zn,{label:m.agent.description,size:"sm",rows:3,value:j,onChange:$=>E($.target.value)})]})}),s.jsxs(Mn,{open:F!==null,title:m.agent.deleteAgent,busy:_,onClose:()=>{A(null),Q(null)},onConfirm:()=>{B()},children:[s.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-300",children:F?m.agent.deleteConfirm(F.name):""}),P&&s.jsx("p",{className:"mt-2 text-xs text-red-600 dark:text-red-400",children:P})]})]})}function kD({items:e,active:t,onChange:a}){return s.jsx("div",{role:"tablist",className:"flex max-w-full gap-1 overflow-x-auto overflow-y-hidden border-b border-gray-200 dark:border-gray-800",children:e.map(l=>s.jsx("button",{type:"button",role:"tab","aria-selected":l.key===t,onClick:()=>a(l.key),className:`-mb-px whitespace-nowrap border-b-2 px-3 py-2 text-sm transition-colors duration-150 ${l.key===t?"border-gray-900 font-semibold text-gray-900 dark:border-gray-100 dark:text-gray-100":"border-transparent text-gray-500 hover:border-gray-300 hover:text-gray-800 dark:text-gray-400 dark:hover:border-gray-700 dark:hover:text-gray-200"}`,children:l.label},l.key))})}const wD=288,SD={base:"text-base",sm:"text-xs"},jD={base:"text-xs",sm:"text-[11px]"};function Ih({options:e,value:t,onChange:a,placeholder:l,mono:o,label:c,error:u,required:f,fullWidth:p,size:h="base","aria-label":g}){const[v,k]=y.useState(!1),{triggerRef:w,panelRef:j,position:E}=PS({open:v,onClose:()=>k(!1),estimatedHeight:e.length*48+16,panelWidth:wD}),C=t!=null?e.find(D=>D.value===t):void 0,M=y.useId(),_=s.jsxs(s.Fragment,{children:[s.jsxs("button",{ref:w,type:"button","aria-label":g,"aria-haspopup":"listbox","aria-expanded":v,"aria-required":f||void 0,"aria-invalid":u?!0:void 0,"aria-describedby":u?M:void 0,onClick:()=>k(D=>!D),className:`flex items-center gap-2 ${Rd} ${_d[h]} ${u?Id:""}`+(p?" w-full justify-between":""),children:[s.jsx("span",{className:`min-w-0 truncate ${o?"font-mono":""}`,children:C?.triggerLabel??l??"—"}),s.jsx(Ad,{className:"text-gray-400"})]}),v&&E&&bi.createPortal(s.jsx("div",{ref:j,role:"listbox",style:{position:"fixed",top:E.topPx,bottom:E.bottomPx,left:E.left,minWidth:E.triggerWidth},className:"anim-pop z-[60] max-h-[70vh] w-72 max-w-[calc(100vw-2rem)] overflow-y-auto rounded-md border border-gray-200 bg-white py-1 shadow-lg dark:border-gray-700 dark:bg-gray-900",children:e.map(D=>s.jsxs("button",{type:"button",role:"option","aria-selected":D.value===t,onClick:()=>{a(D.value),k(!1)},className:`block ${Iw} hover:bg-gray-100 dark:hover:bg-gray-800 ${D.value===t?"bg-gray-100 dark:bg-gray-800":""}`,children:[s.jsxs("span",{className:"flex items-center justify-between gap-2",children:[s.jsx("span",{className:`${SD[h]} ${D.value===t?"font-medium text-gray-900 dark:text-gray-100":"text-gray-700 dark:text-gray-300"}`,children:D.label}),D.value===t&&s.jsx(vw,{className:"text-gray-500 dark:text-gray-400"})]}),s.jsx("span",{className:`mt-0.5 block ${jD[h]} text-gray-500 dark:text-gray-400`,children:D.description})]},D.value))}),document.body)]});return s.jsx(oc,{label:c,error:u,errorId:M,required:f,children:_})}const CD=/^(www\.)?(github|gitlab|gitee|bitbucket)\.(com|org)$/i;function ND(e){const t=e.trim();if(/^git@[\w.-]+:/.test(t)||/\.git$/i.test(t))return"repoUrl";if(/^https?:\/\//i.test(t)){try{if(CD.test(new URL(t).hostname))return"repoUrl"}catch{}return"webUrl"}return/^(\/|~\/|\.{1,2}\/|[A-Za-z]:[\\/]|\\\\)/.test(t)?"localPath":/^[A-Za-z@][\w@./-]*\s+\S/.test(t)?"command":"reference"}function Ip(e){return`${m.skills.importPromptLead[ND(e)](e)}
173
- ${m.skills.importPromptTail}`}function TD(e,t,a,l){const o=e.current;if(o&&(o.focus(),document.execCommand?.("insertText",!1,l)))return;const c=o?o.selectionStart:t.length,u=o?o.selectionEnd:t.length;a(t.slice(0,c)+l+t.slice(u)),requestAnimationFrame(()=>{if(!o)return;o.focus();const f=c+l.length;o.setSelectionRange(f,f)})}function Bg({agentId:e,feature:t,strings:a,canEdit:l,onConfigChanged:o}){const{currentProject:c}=Xt(),u=c?.projectId??null,[f,p]=y.useState(null),[h,g]=y.useState(""),[v,k]=y.useState(!1),w=y.useRef(null),{requestSave:j,element:E}=ki(),C=y.useCallback(K=>{const O=K[t];p(O),g(O.prompt)},[t]),M=K=>t==="skills"?{config:{skills:K}}:t==="vault"?{config:{vault:K}}:{config:{schedules:K}},_=async K=>{if(u){k(!0);try{const O=await kl(u,e,M({enabled:K}));C(O.config),Et(m.common.saved),o?.()}catch(O){Qe(Ie(O))}finally{k(!1)}}},D=async()=>{if(!u)return;const K=t==="skills"?eN:t==="vault"?JC:tN;try{const O=await K(u,e);p(O),g(O.prompt),Et(m.common.saved),o?.()}catch(O){Qe(Ie(O))}},V=()=>j(()=>{u&&kl(u,e,M({prompt:h})).then(K=>{C(K.config),Et(m.common.saved),o?.()}).catch(K=>Qe(Ie(K)))}),F=f!==null&&s.jsxs("div",{className:"flex items-center justify-between gap-4 rounded-lg border border-gray-200 px-4 py-3 dark:border-gray-800",children:[s.jsx("p",{className:"text-sm font-medium text-gray-800 dark:text-gray-200",children:a.enable}),s.jsx(wl,{checked:f.enabled,onChange:K=>{_(K)},disabled:v||!l})]}),A=f?.legacySectionPresent===!0,P=f!==null&&!f.templateHasPlaceholder&&s.jsxs("div",{className:"flex items-center justify-between gap-4 rounded-lg border border-amber-300 bg-amber-50 px-4 py-3 dark:border-amber-700 dark:bg-amber-950/40",children:[s.jsx("p",{className:"text-xs text-amber-800 dark:text-amber-300",children:A?a.legacyTemplate??a.templateMissing:a.templateMissing}),l&&s.jsx(we,{size:"sm",className:"shrink-0",onClick:()=>{D()},children:A?a.migrate??a.insertPlaceholder:a.insertPlaceholder})]}),Q=f!==null&&s.jsxs("section",{className:"space-y-2.5 rounded-lg border border-gray-200 p-3.5 dark:border-gray-800",children:[s.jsxs("div",{children:[s.jsx("h3",{className:"text-sm font-semibold text-gray-800 dark:text-gray-200",children:a.promptSection}),s.jsx("p",{className:"mt-0.5 text-xs text-gray-500 dark:text-gray-400",children:a.promptSectionHint})]}),s.jsx(zn,{ref:w,label:a.promptLabel,mono:!0,size:"sm",rows:12,readOnly:!l,value:h,onChange:K=>g(K.target.value)}),s.jsxs("div",{className:"rounded-md border border-gray-200 bg-gray-50 p-3 dark:border-gray-800 dark:bg-gray-900",children:[s.jsx("p",{className:"mb-2 text-xs font-semibold text-gray-500",children:m.agent.placeholdersTitle}),s.jsx("ul",{className:"space-y-1",children:a.promptPlaceholders.map(([K,O])=>s.jsxs("li",{className:"flex items-center gap-3 text-xs",children:[s.jsx("button",{type:"button",disabled:!l,onClick:()=>TD(w,h,g,K),title:m.memory.insertToken,className:"shrink-0 rounded border border-gray-200 bg-white px-1.5 py-0.5 font-mono font-semibold text-gray-800 transition-colors duration-150 hover:border-gray-400 hover:bg-gray-100 disabled:pointer-events-none dark:border-gray-700 dark:bg-gray-800 dark:text-gray-200 dark:hover:border-gray-500 dark:hover:bg-gray-700",children:K}),s.jsx("span",{className:"text-gray-500 dark:text-gray-400",children:O})]},K))})]}),l&&s.jsx("div",{className:"flex justify-end",children:s.jsx(we,{size:"sm",variant:"primary",onClick:V,children:m.common.save})}),E]});return{applyConfig:C,toggleCard:F,alertStrip:P,promptSection:Q}}const MD="inline-flex cursor-pointer items-center justify-center gap-1 rounded-md border border-gray-300 bg-white px-2.5 py-1 text-xs font-medium text-gray-800 transition-colors duration-150 hover:bg-gray-50 focus-within:ring-2 focus-within:ring-gray-400/30 dark:border-gray-700 dark:bg-gray-900 dark:text-gray-200 dark:hover:bg-gray-800",ED="M4 7h16M9 7V5a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2m3 0l-1 13a2 2 0 0 1-2 2H9a2 2 0 0 1-2-2L6 7m4 4v6m4-6v6";function AD({agentId:e,onConfigChanged:t}){const a=Wn(),{locale:l}=La(),o=xn().user?.userId??null,{currentProject:c,agents:u,setCurrentAgentId:f,reloadAgents:p}=Xt(),h=c?.projectId??null,{applyConfig:g,toggleCard:v,alertStrip:k,promptSection:w}=Bg({agentId:e,feature:"skills",strings:m.skills.injection,canEdit:!0,onConfigChanged:t}),[j,E]=y.useState(null),[C,M]=y.useState(null),[_,D]=y.useState(!1),[V,F]=y.useState(null),[A,P]=y.useState(!1),[Q,K]=y.useState(""),[O,z]=y.useState(!1),[I,B]=y.useState(null),[$,G]=y.useState(null),q=y.useCallback(async()=>{if(!(!h||!e)){E(null),M(null);try{const[ye,te]=await Promise.all([Cd(h,e),jl(h,e)]);E(ye.skills),g(te.config)}catch(ye){M(Ie(ye))}}},[h,e,g]);y.useEffect(()=>{q()},[q]);const ae=u.find(ye=>ye.agentId===e),Z=ae?tn(ae):e,X=async ye=>{if(h)try{const te=await fetch(LN(h,e,ye));if(!te.ok){const ce=await te.json().catch(()=>null);throw new na(te.status,ce?.error?.code??"unknown",ce?.error?.message??m.common.unknownError)}const be=/filename\*=UTF-8''([^;]+)/i.exec(te.headers.get("content-disposition")??"")?.[1],Re=URL.createObjectURL(await te.blob()),Fe=document.createElement("a");Fe.href=Re,Fe.download=be?decodeURIComponent(be):`${ye}.zip`,document.body.appendChild(Fe),Fe.click(),Fe.remove(),URL.revokeObjectURL(Re)}catch(te){Qe(Ie(te))}},T=async()=>{if(!(!h||V===null)){D(!0);try{await Ik(h,e,V),Et(m.skills.uninstalledToast(V,Z)),await q(),p()}catch(ye){Qe(Ie(ye))}finally{D(!1),F(null)}}},R=()=>{K(""),B(null),G(null),P(!0)},H=Q.trim(),S=Ip(H||m.skills.importSourceToken),U=()=>{navigator.clipboard.writeText(Ip(H)).then(()=>Et(m.skills.importCopied)).catch(()=>Qe(m.common.unknownError))},ee=()=>{if(o&&h&&H){Ci(o,h);const ye=jr(o,h);Jr(ye,{...Fs(ye),agentId:e,text:Ip(H),skills:[],handoffAgentId:void 0})}f(e),a(`/chat/${Ia}`,{state:{agentId:e}})},ie=async(ye,te,be)=>{if(h){z(!0),B(null);try{await IN(h,e,{dataBase64:ye,...be?{overwrite:!0}:{}}),G(null),P(!1),Et(m.skills.importDoneToast),await q(),p()}catch(Re){if(Re instanceof na&&Re.status===409&&Re.code==="skill_exists"){const Fe=/:\s*([A-Za-z0-9_-]+)$/.exec(Re.message)?.[1]??te;G({dataBase64:ye,name:Fe})}else G(null),B(Ie(Re))}finally{z(!1)}}},de=ye=>{const te=ye.target.files?.[0];if(ye.target.value="",!te)return;B(null);const be=te.name.replace(/\.zip$/i,""),Re=new FileReader;Re.onload=()=>{const Fe=Re.result;ie(Fe.slice(Fe.indexOf(",")+1),be,!1)},Re.onerror=()=>B(m.common.unknownError),Re.readAsDataURL(te)},me=ye=>[`v${ye.version}`,ye.updated?sd(ye.updated,l):null].filter(te=>te!==null).join(" · ");return h?s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex items-start justify-between gap-3",children:[s.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:m.skills.agentTabDesc}),s.jsx(we,{size:"sm",variant:"primary",className:"shrink-0",disabled:j===null,onClick:R,children:m.skills.importSkill})]}),v,k,j===null?s.jsx(pa,{rows:4}):j.length===0?s.jsx("p",{className:"py-2 text-xs text-gray-400 dark:text-gray-500",children:m.skills.agentTabEmpty}):s.jsx("div",{className:"overflow-hidden rounded-md border border-gray-200 bg-white dark:border-gray-800 dark:bg-gray-900",children:j.map(ye=>s.jsxs("div",{className:"flex items-center gap-3 border-b border-gray-100 px-3 py-2.5 transition-colors duration-150 last:border-b-0 hover:bg-gray-50 dark:border-gray-800/60 dark:hover:bg-gray-800/40",children:[s.jsx("span",{className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-lg ${uS(ye.name)}`,children:s.jsx(Bd,{icon:ye.icon,size:20})}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("span",{className:"block truncate font-mono text-[13px] font-semibold",title:ye.name,children:ye.name}),s.jsx("p",{className:"mt-0.5 truncate text-xs text-gray-500 dark:text-gray-400",title:ye.description,children:ji(l,ye)})]}),s.jsx("span",{className:"hidden shrink-0 text-[11px] text-gray-400 sm:block dark:text-gray-500",title:me(ye),children:me(ye)}),s.jsx(we,{size:"icon",title:m.skills.exportSkill,"aria-label":`${m.skills.exportSkill} ${ye.name}`,disabled:_,onClick:()=>{X(ye.name)},children:s.jsx(bw,{size:14,className:"text-gray-600 dark:text-gray-300"})}),s.jsx(we,{size:"icon",variant:"danger",title:m.skills.uninstall,"aria-label":`${m.skills.uninstall} ${ye.name}`,disabled:_,onClick:()=>F(ye.name),children:s.jsx(qe,{d:ED,size:14})})]},ye.name))}),w,s.jsx(Gt,{open:A,title:m.skills.importSkill,onClose:()=>P(!1),widthClass:"sm:max-w-lg",children:s.jsxs("div",{className:"space-y-4",children:[s.jsxs("section",{children:[s.jsx("p",{className:"text-sm font-medium",children:m.skills.importChatTitle}),s.jsx("p",{className:"mt-0.5 text-xs text-gray-500 dark:text-gray-400",children:m.skills.importChatWhy}),s.jsxs("div",{className:"mt-2.5 space-y-2.5",children:[s.jsx(at,{size:"sm",label:m.skills.importSourceLabel,hint:m.skills.importSourceHint,value:Q,onChange:ye=>K(ye.target.value),placeholder:m.skills.importSourcePlaceholder,autoComplete:"off"}),s.jsx(zn,{label:m.skills.importPromptLabel,size:"sm",rows:5,readOnly:!0,value:S,className:"text-gray-600 dark:text-gray-300"}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(we,{size:"sm",disabled:H==="",onClick:U,children:m.skills.importCopyPrompt}),s.jsx(we,{size:"sm",variant:"primary",onClick:ee,children:m.skills.importOpenChat})]})]})]}),s.jsxs("section",{className:"border-t border-gray-200 pt-4 dark:border-gray-800",children:[s.jsx("p",{className:"text-sm font-medium",children:m.skills.importUploadTitle}),s.jsx("p",{className:"mt-0.5 text-xs text-gray-500 dark:text-gray-400",children:m.skills.importUploadDesc}),s.jsxs("label",{className:`${MD} mt-2.5 ${O?"pointer-events-none opacity-60":""}`,children:[s.jsx(Hd,{accept:".zip",disabled:O,onChange:de}),O?m.skills.importUploading:m.skills.importUploadAction]}),I&&s.jsx("p",{className:"mt-1.5 text-xs text-red-600 dark:text-red-400",children:I})]})]})}),s.jsx(Mn,{open:$!==null,title:m.skills.importOverwriteTitle,confirmLabel:m.skills.importOverwriteAction,busy:O,onClose:()=>G(null),onConfirm:()=>{$!==null&&ie($.dataBase64,$.name,!0)},children:s.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-300",children:$!==null?m.skills.importOverwriteBody($.name):""})}),s.jsx(Mn,{open:V!==null,title:V!==null?m.skills.uninstallConfirmTitle(V):"",busy:_,onClose:()=>F(null),onConfirm:()=>{T()},children:s.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-300",children:V!==null?m.skills.uninstallConfirmBody(V,Z):""})}),C&&s.jsx("p",{className:"text-xs text-red-600 dark:text-red-400",children:C})]}):null}function RD(e,t=""){const a=`${m.memory.editPromptLead(e)}
174
- ${m.memory.editPromptTail}`,l=t.trim();return l.length>0?`${a}${l}`:a}function _D(e,t){return`${m.memory.addPromptLead[e]}
175
- ${t.trim()}`}function ID(e){return e.replace(/^\ufeff?---\r?\n[\s\S]*?\r?\n---\r?\n?/,"")}const P1="(min-width: 1024px)",LD="M2 12s3.6-7 10-7 10 7 10 7-3.6 7-10 7-10-7-10-7zM12 9a3 3 0 1 0 0 6 3 3 0 0 0 0-6z",OD="M12 20h9M16.5 3.5a2.1 2.1 0 0 1 3 3L7 19l-4 1 1-4L16.5 3.5z",DD="M4 7h16M9 7V5a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2m3 0l-1 13a2 2 0 0 1-2 2H9a2 2 0 0 1-2-2L6 7m4 4v6m4-6v6",zD="M12 5v14M5 12h14",UD=(e,t,a)=>`penguin.memoryCollapsed.${e}.${t}.${a}`;function B1(e){if(!e)return new Set;try{const t=JSON.parse(localStorage.getItem(e)??"[]");return Array.isArray(t)?new Set(t.filter(a=>typeof a=="string")):new Set}catch{return new Set}}function H1(e,t){if(e)try{localStorage.setItem(e,JSON.stringify([...t]))}catch{}}function $D({agentId:e,onConfigChanged:t}){const a=Wn(),{locale:l}=La(),o=xn().user?.userId??null,{currentProject:c,setCurrentAgentId:u,reloadAgents:f}=Xt(),p=c?.projectId??null,[h,g]=y.useState(!0),[v,k]=y.useState(!0),[w,j]=y.useState(""),[E,C]=y.useState(null),[M,_]=y.useState(null),[D,V]=y.useState(!1),F=o&&p?UD(o,p,e):null,[A,P]=y.useState(()=>B1(F)),[Q,K]=y.useState(""),[O,z]=y.useState(""),I=y.useRef(null),B=y.useRef(null),[$,G]=y.useState("main"),{requestSave:q,element:ae}=ki(),[Z,X]=y.useState(!1),[T,R]=y.useState(null),[H,S]=y.useState(null),[U,ee]=y.useState(""),[ie,de]=y.useState(null),[me,ye]=y.useState(""),[te,be]=y.useState(null),[Re,Fe]=y.useState(()=>window.matchMedia(P1).matches),[ce,Ve]=y.useState("half");y.useEffect(()=>{const Ce=window.matchMedia(P1),Oe=Ke=>Fe(Ke.matches);return Ce.addEventListener("change",Oe),()=>Ce.removeEventListener("change",Oe)},[]),y.useEffect(()=>{P(B1(F))},[F]);const je=Ce=>{const Oe=new Set(A);Oe.delete(Ce)||Oe.add(Ce),H1(F,Oe),P(Oe)},wt=y.useCallback(async()=>{if(!(!p||!e)){C(null),_(null);try{const[Ce,Oe]=await Promise.all([nN(p,e),jl(p,e)]);K(Oe.config.memory.prompt),z(Oe.config.memory.workspacePrompt),g(Ce.enabled),k(Ce.templateHasMemory),j(Ce.memoryDir);const Ke=new Set(Ce.scopes.map(vt=>vt.scopeKey));P(vt=>{const xt=new Set([...vt].filter(St=>Ke.has(St)));return xt.size===vt.size?vt:(H1(F,xt),xt)}),C(await Promise.all(Ce.scopes.map(async vt=>{try{return{scope:vt,files:(await rN(p,e,vt.scopeKey)).files}}catch{return{scope:vt,files:[]}}})))}catch(Ce){_(Ie(Ce))}}},[p,e,F]);y.useEffect(()=>{wt()},[wt]);const an=async Ce=>{if(p){V(!0);try{const Oe=await kl(p,e,{config:{memory:{enabled:Ce}}});g(Oe.config.memory.enabled),Et(m.common.saved),t?.()}catch(Oe){Qe(Ie(Oe))}finally{V(!1)}}},rn=async()=>{if(p)try{const Ce=await aN(p,e);k(Ce.templateHasMemory),Et(m.memory.insertPlaceholderDone),t?.()}catch(Ce){Qe(Ie(Ce))}},sn=(Ce,Oe,Ke,vt)=>{const xt=Ce.current;if(xt&&(xt.focus(),document.execCommand?.("insertText",!1,vt)))return;const St=xt?xt.selectionStart:Oe.length,ln=xt?xt.selectionEnd:Oe.length;Ke(Oe.slice(0,St)+vt+Oe.slice(ln)),requestAnimationFrame(()=>{if(!xt)return;xt.focus();const $t=St+vt.length;xt.setSelectionRange($t,$t)})},Ut=()=>q(()=>{p&&kl(p,e,{config:{memory:{prompt:Q,workspacePrompt:O}}}).then(Ce=>{K(Ce.config.memory.prompt),z(Ce.config.memory.workspacePrompt),Et(m.common.saved),t?.()}).catch(Ce=>Qe(Ie(Ce)))}),At=async(Ce,Oe)=>{if(p)try{const Ke=await sN(p,e,Ce.scopeKey,Oe.name);Ve("half"),R({scope:Ce,file:Ke.file,content:Ke.content}),X(!0)}catch(Ke){Qe(Ie(Ke))}},fn=(Ce,Oe)=>`${w}/${Ce.scopeKey}/${Oe.name}`,st=(Ce,Oe)=>{X(!1),ee(""),S({scope:Ce,file:Oe})},nn=H?RD(H.file.title,U):"",pe=()=>{navigator.clipboard.writeText(nn).then(()=>Et(m.memory.editCopied)).catch(()=>Qe(m.common.unknownError))},Se=(Ce,Oe)=>{if(!o||!p)return;const Ke=jr(o,p);Jr(Ke,{...Fs(Ke),agentId:e,text:Ce,...Oe!==void 0?{workspace:Oe}:{},skills:[],handoffAgentId:void 0}),u(e),a(`/chat/${Ia}`,{state:{agentId:e,...Oe!==void 0?{workspace:Oe}:{}}})},De=()=>{H&&Se(nn,H.scope.workspacePath)},ze=Ce=>{ye(""),de(Ce)},Ue=ie?_D(ie.kind,me):"",W=()=>{navigator.clipboard.writeText(Ue).then(()=>Et(m.memory.editCopied)).catch(()=>Qe(m.common.unknownError))},ge=()=>{ie&&Se(Ue,ie.workspacePath)},Ne=async()=>{if(!p||!te)return;const Ce=te;be(null);try{await lN(p,e,Ce.scope.scopeKey,Ce.file.name),Et(m.memory.deleteDone),T&&T.file.name===Ce.file.name&&X(!1),await wt(),f()}catch(Oe){Qe(Ie(Oe))}};if(M)return s.jsx("p",{className:"text-sm text-red-600 dark:text-red-400",children:M});const Te=Ce=>Ce.kind==="user"?m.memory.userScope:Ce.workspacePath?.split(/[\\/]/).filter(Boolean).at(-1)??Ce.scopeKey,Pe=(Ce,Oe)=>s.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[s.jsx(we,{size:"icon",title:m.memory.view,"aria-label":`${m.memory.view} ${Oe.title}`,onClick:()=>{At(Ce,Oe)},children:s.jsx(qe,{d:LD,size:14,className:"text-gray-600 dark:text-gray-300"})}),s.jsx(we,{size:"icon",title:m.memory.edit,"aria-label":`${m.memory.edit} ${Oe.title}`,onClick:()=>st(Ce,Oe),children:s.jsx(qe,{d:OD,size:14,className:"text-gray-600 dark:text-gray-300"})}),s.jsx(we,{size:"icon",variant:"danger",title:m.memory.delete,"aria-label":`${m.memory.delete} ${Oe.title}`,onClick:()=>be({scope:Ce,file:Oe}),children:s.jsx(qe,{d:DD,size:14})})]}),We=(Ce,Oe)=>s.jsxs("li",{className:"flex items-center gap-3 px-3.5 py-2.5",children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("p",{className:"truncate font-mono text-[13px] font-medium text-gray-800 dark:text-gray-200",children:Oe.title}),Oe.description&&s.jsx("p",{className:"truncate text-xs text-gray-500 dark:text-gray-400",children:Oe.description})]}),s.jsx("span",{className:"shrink-0 text-xs tabular-nums text-gray-400 dark:text-gray-500",children:Oe.updatedAt??sd(Oe.modifiedAt,l)}),Pe(Ce,Oe)]},Oe.name),tt=T&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"text-xs text-gray-400 dark:text-gray-500",children:T.file.updatedAt??sd(T.file.modifiedAt,l)}),T.file.description&&s.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:T.file.description}),s.jsx("div",{className:"md-body border-t border-gray-100 pt-3 text-sm dark:border-gray-800",children:s.jsx(Eg,{text:ID(T.content)})})]}),it=T&&s.jsxs("div",{className:"flex shrink-0 justify-end gap-2 border-t border-gray-200 px-4 py-3 dark:border-gray-800",children:[s.jsx(we,{size:"sm",onClick:()=>st(T.scope,T.file),children:m.memory.edit}),s.jsx(we,{size:"sm",variant:"danger",onClick:()=>be(T),children:m.memory.delete})]});return s.jsxs("div",{className:"space-y-5",children:[s.jsx("p",{className:"text-xs leading-5 text-gray-500 dark:text-gray-400",children:m.memory.desc}),s.jsxs("div",{className:"flex items-center justify-between gap-4 rounded-lg border border-gray-200 px-4 py-3 dark:border-gray-800",children:[s.jsx("p",{className:"text-sm font-medium text-gray-800 dark:text-gray-200",children:m.memory.enable}),s.jsx(wl,{checked:h,onChange:Ce=>{an(Ce)},disabled:D})]}),!v&&s.jsxs("div",{className:"flex items-center justify-between gap-4 rounded-lg border border-amber-300 bg-amber-50 px-4 py-3 dark:border-amber-700 dark:bg-amber-950/40",children:[s.jsx("p",{className:"text-xs text-amber-800 dark:text-amber-300",children:m.memory.templateMissing}),s.jsx(we,{size:"sm",onClick:()=>{rn()},children:m.memory.insertPlaceholder})]}),E===null?s.jsx(pa,{rows:4}):s.jsx("div",{className:h?"space-y-5":"space-y-5 opacity-60",children:E.map(({scope:Ce,files:Oe})=>{const Ke=!A.has(Ce.scopeKey);return s.jsxs("section",{className:"overflow-hidden rounded-lg border border-gray-200 dark:border-gray-800",children:[s.jsxs("div",{className:"flex items-center gap-2 bg-gray-50 pr-2 transition-colors duration-150 hover:bg-gray-100 dark:bg-gray-900/60 dark:hover:bg-gray-800/60",children:[s.jsxs("button",{type:"button","aria-expanded":Ke,onClick:()=>je(Ce.scopeKey),className:"flex min-w-0 flex-1 items-center gap-2.5 px-3.5 py-2.5 text-left",children:[s.jsx("span",{className:"shrink-0 text-sm font-semibold text-gray-800 dark:text-gray-200",children:Te(Ce)}),Ce.kind==="workspace"&&Ce.workspacePath!==void 0&&s.jsx("span",{className:"min-w-0 truncate font-mono text-[11px] text-gray-400 dark:text-gray-500",children:Ce.workspacePath}),s.jsx("span",{className:"min-w-0 flex-1"}),s.jsx("span",{className:"shrink-0 text-xs text-gray-400 dark:text-gray-500",children:m.memory.itemCount(Oe.length)})]}),s.jsx("span",{className:"shrink-0",children:s.jsxs(we,{size:"sm",variant:"ghost",onClick:()=>ze(Ce),children:[s.jsx(qe,{d:zD,size:13}),m.memory.add]})}),s.jsx("button",{type:"button","aria-expanded":Ke,"aria-label":Te(Ce),onClick:()=>je(Ce.scopeKey),className:"shrink-0 p-1.5",children:s.jsx($n,{open:Ke,className:"text-gray-400"})})]}),s.jsx("div",{className:`grid transition-[grid-template-rows] duration-200 ease-out ${Ke?"grid-rows-[1fr]":"grid-rows-[0fr]"}`,children:s.jsx("div",{className:"overflow-hidden",inert:!Ke,children:Oe.length===0?s.jsx("p",{className:"px-4 py-4 text-center text-xs text-gray-400 dark:text-gray-500",children:Ce.kind==="user"?m.memory.emptyUserScope:m.memory.emptyScope}):s.jsx("ul",{className:"divide-y divide-gray-100 border-t border-gray-200 dark:divide-gray-800 dark:border-gray-800",children:Oe.map(vt=>We(Ce,vt))})})})]},Ce.scopeKey)})}),s.jsxs("section",{className:"space-y-2.5 rounded-lg border border-gray-200 p-3.5 dark:border-gray-800",children:[s.jsxs("div",{children:[s.jsx("h3",{className:"text-sm font-semibold text-gray-800 dark:text-gray-200",children:m.memory.promptSection}),s.jsx("p",{className:"mt-0.5 text-xs text-gray-500 dark:text-gray-400",children:m.memory.promptSectionHint})]}),s.jsx(zn,{ref:I,label:m.memory.promptLabel,mono:!0,size:"sm",rows:12,value:Q,onFocus:()=>G("main"),onChange:Ce=>K(Ce.target.value)}),s.jsx(zn,{ref:B,label:m.memory.workspacePromptLabel,mono:!0,size:"sm",rows:6,value:O,onFocus:()=>G("workspace"),onChange:Ce=>z(Ce.target.value)}),s.jsxs("div",{className:"rounded-md border border-gray-200 bg-gray-50 p-3 dark:border-gray-800 dark:bg-gray-900",children:[s.jsx("p",{className:"mb-2 text-xs font-semibold text-gray-500",children:m.agent.placeholdersTitle}),s.jsx("ul",{className:"space-y-1",children:m.memory.promptPlaceholders.map(([Ce,Oe])=>s.jsxs("li",{className:"flex items-center gap-3 text-xs",children:[s.jsx("button",{type:"button",onClick:()=>$==="main"?sn(I,Q,K,Ce):sn(B,O,z,Ce),title:m.memory.insertToken,className:"shrink-0 rounded border border-gray-200 bg-white px-1.5 py-0.5 font-mono font-semibold text-gray-800 transition-colors duration-150 hover:border-gray-400 hover:bg-gray-100 dark:border-gray-700 dark:bg-gray-800 dark:text-gray-200 dark:hover:border-gray-500 dark:hover:bg-gray-700",children:Ce}),s.jsx("span",{className:"text-gray-500 dark:text-gray-400",children:Oe})]},Ce))})]}),s.jsx("div",{className:"flex justify-end",children:s.jsx(we,{size:"sm",variant:"primary",onClick:Ut,children:m.common.save})})]}),ae,Re?s.jsx(ww,{open:Z,side:"right",title:T?.file.title??"",onClose:()=>X(!1),widthClass:"max-w-lg",children:T&&s.jsxs("div",{className:"flex h-full flex-col",children:[s.jsx("div",{className:"flex-1 space-y-3 overflow-y-auto px-4 py-3",children:tt}),it]})}):s.jsx(Ug,{open:Z,snap:ce,onSnapChange:Ve,title:T?.file.title??"",onClose:()=>X(!1),children:T&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"space-y-3 px-4 py-3",children:tt}),it]})}),s.jsx(Gt,{open:H!==null,title:m.memory.editTitle,onClose:()=>S(null),widthClass:"sm:max-w-lg",children:H&&s.jsxs("div",{className:"space-y-2.5",children:[s.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:m.memory.editWhy}),s.jsx("p",{className:"break-all font-mono text-[11px] text-gray-400 dark:text-gray-500",children:fn(H.scope,H.file)}),s.jsx(zn,{label:m.memory.editRequirementLabel,size:"sm",rows:2,value:U,onChange:Ce=>ee(Ce.target.value),placeholder:m.memory.editRequirementPlaceholder}),s.jsx(zn,{label:m.memory.editPromptLabel,size:"sm",rows:6,readOnly:!0,value:nn,className:"text-gray-600 dark:text-gray-300"}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(we,{size:"sm",onClick:pe,children:m.memory.editCopyPrompt}),s.jsx(we,{size:"sm",variant:"primary",onClick:De,children:m.memory.editOpenChat})]})]})}),s.jsx(Gt,{open:ie!==null,title:m.memory.addTitle,onClose:()=>de(null),widthClass:"sm:max-w-lg",children:ie&&s.jsxs("div",{className:"space-y-2.5",children:[s.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:m.memory.addWhy}),s.jsx("p",{className:"break-all font-mono text-[11px] text-gray-400 dark:text-gray-500",children:`${w}/${ie.scopeKey}`}),s.jsx(zn,{label:m.memory.addContentLabel,size:"sm",rows:4,value:me,onChange:Ce=>ye(Ce.target.value),placeholder:m.memory.addContentPlaceholder}),s.jsx(zn,{label:m.memory.editPromptLabel,size:"sm",rows:6,readOnly:!0,value:Ue,className:"text-gray-600 dark:text-gray-300"}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(we,{size:"sm",disabled:me.trim()==="",onClick:W,children:m.memory.editCopyPrompt}),s.jsx(we,{size:"sm",variant:"primary",disabled:me.trim()==="",onClick:ge,children:m.memory.editOpenChat})]})]})}),s.jsx(Mn,{open:te!==null,tone:"danger",title:m.memory.deleteTitle,confirmLabel:m.memory.delete,onClose:()=>be(null),onConfirm:()=>{Ne()},children:s.jsx("p",{className:"text-sm text-gray-700 dark:text-gray-300",children:te?m.memory.deleteConfirm(te.file.title):""})})]})}const Lp="tools.builtin.";function PD(e){const t=m.agent.kernelFields[e];return t!==void 0?t:e.startsWith(Lp)&&e.length>Lp.length?m.agent.kernelFieldTool(e.slice(Lp.length)):e}const BD=/^[A-Za-z_][A-Za-z0-9_]*$/;function HD({agentId:e,onConfigChanged:t}){const{currentProject:a,reloadAgents:l}=Xt(),o=a?.projectId??null,c=a?.role==="owner",{applyConfig:u,toggleCard:f,alertStrip:p,promptSection:h}=Bg({agentId:e,feature:"vault",strings:m.vault.injection,canEdit:c,onConfigChanged:t}),[g,v]=y.useState(null),[k,w]=y.useState(null),[j,E]=y.useState(!1),[C,M]=y.useState(!1),[_,D]=y.useState(""),[V,F]=y.useState(""),[A,P]=y.useState({}),Q=()=>P(X=>X.key||X.value?{}:X),[K,O]=y.useState(null),[z,I]=y.useState(null),B=y.useCallback(async()=>{if(!(!o||!e)){v(null),w(null);try{const[X,T]=await Promise.all([XC(o,e),jl(o,e)]);v(X.entries),u(T.config)}catch(X){w(Ie(X))}}},[o,e,u]);y.useEffect(()=>{B()},[B]);const $=async X=>{if(!o||!e)return m.common.unknownError;E(!0);try{const T=await ZC(o,e,X);return v(T.entries),Et(m.common.saved),l(),null}catch(T){return Ie(T)}finally{E(!1)}},G=X=>(g??[]).filter(T=>T.key!==X).map(T=>({key:T.key})),q=()=>{D(""),F(""),P({}),M(!0)},ae=async()=>{const X=_.trim(),T={};if(X?BD.test(X)||(T.key=m.vault.keyInvalid):T.key=m.common.requiredField,V||(T.value=m.vault.valueRequired),T.key||T.value){P(T);return}if(P({}),z!==X&&(g??[]).some(H=>H.key===X)){I(X);return}I(null);const R=await $({entries:[...G(X),{key:X,value:V}]});if(R!==null){P({key:R});return}M(!1)},Z=async()=>{if(K===null)return;const X=await $({entries:G(K)});X!==null&&Qe(X),O(null)};return o?s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:m.vault.desc}),!c&&s.jsx("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400",children:m.vault.readOnlyHint})]}),f,p,g===null?s.jsx(pa,{rows:4}):g.length===0?s.jsx("p",{className:"py-2 text-xs text-gray-400 dark:text-gray-500",children:m.vault.empty}):s.jsx("div",{className:"overflow-x-auto overflow-y-clip rounded-md border border-gray-200 bg-white dark:border-gray-800 dark:bg-gray-900",children:s.jsxs("table",{className:"w-full min-w-[420px] text-left text-sm",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"border-b border-gray-200 bg-gray-50/80 text-xs text-gray-500 dark:border-gray-800 dark:bg-gray-900",children:[s.jsx("th",{className:"px-3 py-2.5",children:m.vault.key}),s.jsx("th",{className:"px-3 py-2.5",children:m.vault.valueMasked}),s.jsx("th",{className:"px-3 py-2.5"})]})}),s.jsx("tbody",{children:g.map(X=>s.jsxs("tr",{className:"border-b border-gray-100 transition-colors duration-150 last:border-b-0 hover:bg-gray-50 dark:border-gray-800/60 dark:hover:bg-gray-800/40",children:[s.jsx("td",{className:"px-3 py-2 font-mono text-xs",children:X.key}),s.jsx("td",{className:"px-3 py-2 font-mono text-xs text-gray-500 dark:text-gray-400",children:X.valueMasked}),s.jsx("td",{className:"px-3 py-2 text-right",children:c&&s.jsx(we,{size:"sm",variant:"ghost",disabled:j,onClick:()=>O(X.key),children:m.vault.remove})})]},X.key))})]})}),c&&g!==null&&s.jsx(we,{size:"sm",variant:"primary",disabled:j,onClick:q,children:m.vault.add}),h,s.jsx(Gt,{open:C,title:m.vault.addTitle,onClose:()=>M(!1),footer:s.jsxs(s.Fragment,{children:[s.jsx(we,{onClick:()=>M(!1),children:m.common.cancel}),s.jsx(we,{variant:"primary",disabled:j,onClick:()=>{ae()},children:m.vault.add})]}),children:s.jsxs("div",{className:"space-y-3",children:[s.jsx(at,{size:"sm",label:m.vault.key,required:!0,hint:m.vault.keyHint,error:A.key,value:_,onChange:X=>{D(X.target.value),Q()},className:"font-mono",placeholder:"OPENAI_API_KEY",autoComplete:"off"}),s.jsx(zs,{size:"sm",label:m.vault.value,required:!0,error:A.value,value:V,onChange:X=>{F(X.target.value),Q()},className:"font-mono",autoComplete:"off",onKeyDown:X=>{X.key==="Enter"&&!j&&ae()}})]})}),s.jsx(Mn,{open:z!==null,title:m.vault.overwriteTitle,tone:"primary",confirmLabel:m.common.save,busy:j,onClose:()=>I(null),onConfirm:()=>{ae()},children:s.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-300",children:z!==null?m.vault.overwriteConfirm(z):""})}),s.jsx(Mn,{open:K!==null,title:m.vault.deleteTitle,busy:j,onClose:()=>O(null),onConfirm:()=>{Z()},children:s.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-300",children:K!==null?m.vault.deleteConfirm(K):""})}),k&&s.jsx("p",{className:"text-xs text-red-600 dark:text-red-400",children:k})]}):null}const FD={active:"green",disabled:"gray",expired:"amber",done:"brand",missed:"amber",invalid:"red"};function F1(e){if(!e)return"";const t=new Date(e);if(Number.isNaN(t.getTime()))return"";const a=l=>l<10?`0${l}`:`${l}`;return`${t.getFullYear()}-${a(t.getMonth()+1)}-${a(t.getDate())}T${a(t.getHours())}:${a(t.getMinutes())}`}const q1=e=>e.modelId&&e.provider?{provider:e.provider,modelId:e.modelId}:null,qD={editing:null,name:"",prompt:"",enabled:!0,startAt:"",endAt:"",period:"",target:"new",sessionId:"",workspace:"",model:null};function VD(e,t){const a=t.trim().toLowerCase();return a?e.filter(l=>l.sessionId.toLowerCase().includes(a)||(l.title??"").toLowerCase().includes(a)):e}function GD({projectId:e,agentId:t,value:a,onChange:l}){const[o,c]=y.useState(!1),[u,f]=y.useState(""),[p,h]=y.useState(null);y.useEffect(()=>{if(!o||p!==null)return;let k=!1;return Fp(e,t).then(w=>{k||h(w.sessions)}).catch(()=>{k||h([])}),()=>{k=!0}},[o,p,e,t]);const g=p?.find(k=>k.sessionId===a)??null,v=g?g.title??m.chat.defaultSessionTitle:a||m.schedule.chooseSession;return s.jsx(Ig,{open:o,setOpen:c,label:v,muted:!a,title:a?`${m.schedule.sessionId}:${a}`:m.schedule.chooseSession,ariaLabel:m.schedule.chooseSession,ariaHaspopup:"listbox",menuClass:"w-80 origin-top-left",children:p===null?s.jsx("p",{className:"px-3 py-2 text-xs text-gray-400",children:m.common.loading}):p.length===0?s.jsx("p",{className:"px-3 py-2 text-xs text-gray-400",children:m.schedule.sessionEmpty}):s.jsx(Lg,{items:VD(p,u),itemKey:k=>k.sessionId,isCurrent:k=>k.sessionId===a,query:u,onQueryChange:f,searchPlaceholder:m.schedule.sessionSearch,emptyText:m.schedule.sessionNoMatch,onPick:k=>{l(k.sessionId),c(!1)},renderRow:k=>s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"min-w-0 flex-1 truncate text-gray-800 dark:text-gray-200",children:k.title??m.chat.defaultSessionTitle}),s.jsx("span",{className:"shrink-0 font-mono text-[11px] text-gray-400 dark:text-gray-500",children:k.sessionId.slice(-6)})]})})})}function WD({agentId:e,onConfigChanged:t}){const{currentProject:a,reloadAgents:l}=Xt(),o=a?.projectId??null,c=a?.role==="owner",{applyConfig:u,toggleCard:f,alertStrip:p,promptSection:h}=Bg({agentId:e,feature:"schedules",strings:m.schedule.injection,canEdit:c,onConfigChanged:t}),[g,v]=y.useState(null),[k,w]=y.useState(null),[j,E]=y.useState(!1),[C,M]=y.useState(null),[_,D]=y.useState(null),[V,F]=y.useState({}),[A,P]=y.useState(null),[Q,K]=y.useState(null),[O,z]=y.useState([]),[I,B]=y.useState(null),$=y.useCallback(async()=>{if(!(!o||!e)){v(null),w(null);try{const[S,U]=await Promise.all([EN(o,e),jl(o,e)]);v(S),u(U.config)}catch(S){w(Ie(S))}}},[o,e,u]);y.useEffect(()=>{$()},[$]),y.useEffect(()=>{!o||!c||mi(o).then(S=>{z(S.models),B(S.defaultModel??null)}).catch(()=>{z([]),B(null)})},[o,c]);const G=S=>{F(U=>U.name||U.prompt||U.startAt||U.sessionId?{}:U),P(U=>U&&null),M(U=>U===null?U:{...U,...S})},q=S=>{F({}),P(null),M(S),D(S)},ae=async()=>{if(!o||C===null)return;P(null);const S=C.editing??C.name.trim(),U={};if(S||(U.name=m.common.requiredField),C.prompt.trim()||(U.prompt=m.common.requiredField),C.startAt||(U.startAt=m.common.requiredField),C.target==="session"&&!C.sessionId.trim()&&(U.sessionId=m.common.requiredField),U.name||U.prompt||U.startAt||U.sessionId){F(U);return}if(F({}),C.editing!==null&&JSON.stringify(C)===JSON.stringify(_)){Mr(m.common.noChangesToSave);return}const ee={prompt:C.prompt,enabled:C.enabled,startAt:new Date(C.startAt).toISOString(),...C.period.trim()?{period:C.period.trim()}:{},...C.endAt?{endAt:new Date(C.endAt).toISOString()}:{},...C.target==="session"&&C.sessionId.trim()?{sessionId:C.sessionId.trim()}:{},...C.target==="new"&&C.workspace.trim()?{workspace:C.workspace.trim()}:{},...C.target==="new"&&C.model&&!jt(I,C.model)?{modelId:C.model.modelId,provider:C.model.provider}:{}};E(!0);try{C.editing!==null?await Dv(o,e,C.editing,ee):await AN(o,e,{name:S,...ee}),M(null),Et(m.common.saved),await $(),l()}catch(ie){P(Ie(ie))}finally{E(!1)}},Z=async S=>{if(!o)return;E(!0);const U=q1(S);try{await Dv(o,e,S.name,{prompt:S.prompt,enabled:!S.enabled,startAt:S.startAt,...S.period!==void 0?{period:S.period}:{},...S.endAt!==void 0?{endAt:S.endAt}:{},...S.sessionId!==void 0?{sessionId:S.sessionId}:{},...S.workspace!==void 0?{workspace:S.workspace}:{},...U?{modelId:U.modelId,provider:U.provider}:{}}),Et(m.common.saved),await $()}catch(ee){Qe(Ie(ee))}finally{E(!1)}},X=S=>{q({editing:S.name,name:S.name,prompt:S.prompt,enabled:S.enabled,startAt:F1(S.startAt),endAt:F1(S.endAt),period:S.period??"",target:S.sessionId?"session":"new",sessionId:S.sessionId??"",workspace:S.workspace??"",model:q1(S)??I})},T=async()=>{if(!(!o||Q===null)){E(!0);try{await RN(o,e,Q),C?.editing===Q&&M(null),await $(),l()}catch(S){Qe(Ie(S))}finally{E(!1),K(null)}}};if(!o)return null;const R=g?.schedules??[],H=g?.invalidFiles??[];return s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:m.schedule.desc}),!c&&s.jsx("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400",children:m.schedule.readOnlyHint})]}),f,p,g===null?s.jsx(pa,{rows:4}):R.length===0?s.jsx("p",{className:"py-2 text-xs text-gray-400 dark:text-gray-500",children:m.schedule.empty}):s.jsx("div",{className:"overflow-x-auto overflow-y-clip rounded-md border border-gray-200 bg-white dark:border-gray-800 dark:bg-gray-900",children:s.jsxs("table",{className:"w-full min-w-[720px] text-left text-sm",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"border-b border-gray-200 bg-gray-50/80 text-xs text-gray-500 dark:border-gray-800 dark:bg-gray-900",children:[s.jsx("th",{className:"whitespace-nowrap px-3 py-2.5",children:m.common.name}),s.jsx("th",{className:"whitespace-nowrap px-3 py-2.5",children:m.schedule.colStatus}),s.jsx("th",{className:"whitespace-nowrap px-3 py-2.5",children:m.schedule.colPeriod}),s.jsx("th",{className:"whitespace-nowrap px-3 py-2.5",children:m.schedule.colTarget}),s.jsx("th",{className:"whitespace-nowrap px-3 py-2.5",children:m.schedule.colFireTimes}),s.jsx("th",{className:"whitespace-nowrap px-3 py-2.5",children:m.schedule.colQueued}),c&&s.jsx("th",{className:"px-3 py-2.5"})]})}),s.jsx("tbody",{children:R.map(S=>s.jsxs("tr",{className:"border-b border-gray-100 transition-colors duration-150 last:border-b-0 hover:bg-gray-50 dark:border-gray-800/60 dark:hover:bg-gray-800/40",children:[s.jsx("td",{className:"max-w-40 truncate px-3 py-2 font-mono text-xs",title:S.name,children:S.name}),s.jsx("td",{className:"whitespace-nowrap px-3 py-2",children:s.jsx("span",{title:S.invalidReason,children:s.jsx(gn,{tone:FD[S.status],children:m.schedule.statusNames[S.status]??S.status})})}),s.jsx("td",{className:"whitespace-nowrap px-3 py-2 text-xs text-gray-500 dark:text-gray-400",children:S.period!==void 0?s.jsx("span",{className:"font-mono",children:S.period}):m.schedule.once}),s.jsx("td",{className:"max-w-36 truncate px-3 py-2 text-xs text-gray-500 dark:text-gray-400",title:S.sessionId,children:S.sessionId!==void 0?s.jsx("span",{className:"font-mono",children:S.sessionId}):m.schedule.newSession}),s.jsxs("td",{className:"whitespace-nowrap px-3 py-2 text-xs",children:[s.jsx("span",{className:"block text-gray-600 dark:text-gray-300",children:S.nextFireAt?ha(S.nextFireAt):"—"}),s.jsx("span",{className:"block text-gray-400 dark:text-gray-500",children:S.lastFiredAt?ha(S.lastFiredAt):"—"})]}),s.jsx("td",{className:"whitespace-nowrap px-3 py-2",children:S.queued&&s.jsx(gn,{tone:"brand",children:m.schedule.queued})}),c&&s.jsxs("td",{className:"whitespace-nowrap px-3 py-2 text-right",children:[s.jsx(we,{size:"sm",variant:"ghost",disabled:j,onClick:()=>{Z(S)},children:S.enabled?m.schedule.disable:m.schedule.enable}),s.jsx(we,{size:"sm",variant:"ghost",disabled:j,onClick:()=>X(S),children:m.common.edit}),s.jsx(we,{size:"sm",variant:"ghost",disabled:j,onClick:()=>K(S.name),children:m.common.delete})]})]},S.name))})]})}),H.length>0&&s.jsxs("div",{className:"text-xs text-red-600 dark:text-red-400",children:[s.jsx("p",{className:"font-medium",children:m.schedule.invalidFiles}),s.jsx("ul",{className:"mt-0.5 space-y-0.5 font-mono",children:H.map(S=>s.jsxs("li",{children:[S.name,": ",S.error]},S.name))})]}),c&&g!==null&&s.jsx(we,{size:"sm",variant:"primary",disabled:j,onClick:()=>q({...qD,model:I}),children:m.schedule.addTitle}),h,s.jsx(Gt,{open:C!==null,title:C?.editing!=null?m.schedule.editTitle(C.editing):m.schedule.addTitle,onClose:()=>M(null),widthClass:"sm:max-w-lg",footer:s.jsxs(s.Fragment,{children:[s.jsx(we,{onClick:()=>M(null),children:m.common.cancel}),s.jsx(we,{variant:"primary",disabled:j,onClick:()=>{ae()},children:C?.editing!=null?m.common.save:m.common.create})]}),children:C!==null&&s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"grid grid-cols-1 gap-3 md:grid-cols-2",children:[s.jsx(at,{size:"sm",label:m.common.name,required:!0,hint:m.schedule.nameHint,error:V.name,value:C.name,disabled:C.editing!==null,onChange:S=>G({name:S.target.value}),className:"font-mono",placeholder:"daily_report",autoComplete:"off"}),s.jsx(at,{size:"sm",label:m.schedule.period,value:C.period,onChange:S=>G({period:S.target.value}),className:"font-mono",placeholder:m.schedule.periodPlaceholder,autoComplete:"off"}),s.jsx(at,{size:"sm",label:m.schedule.startAt,required:!0,type:"datetime-local",error:V.startAt,value:C.startAt,onChange:S=>G({startAt:S.target.value}),className:"font-mono"}),s.jsx(at,{size:"sm",label:m.schedule.endAt,type:"datetime-local",value:C.endAt,onChange:S=>G({endAt:S.target.value}),className:"font-mono"}),s.jsxs(Ds,{size:"sm",label:m.schedule.target,value:C.target,onChange:S=>G({target:S.target.value}),children:[s.jsx("option",{value:"new",children:m.schedule.targetNew}),s.jsx("option",{value:"session",children:m.schedule.targetSession})]}),C.target==="session"?s.jsxs("div",{children:[s.jsx(er,{required:!0,children:m.schedule.sessionId}),o&&s.jsx(GD,{projectId:o,agentId:e,value:C.sessionId,onChange:S=>G({sessionId:S})}),V.sessionId&&s.jsx(Sr,{children:V.sessionId})]}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{children:[s.jsx(er,{children:m.schedule.model}),O.length>0?s.jsx(Og,{models:O,value:C.model,...I?{defaultModel:I}:{},onChange:S=>G({model:S}),disabled:j,variant:"form"}):s.jsx("p",{className:"text-xs text-gray-400",children:m.schedule.modelDefault})]}),s.jsxs("div",{children:[s.jsx(er,{children:m.schedule.workspace}),s.jsx(zg,{projectId:o??"",workspace:C.workspace,onChange:S=>G({workspace:S}),variant:"form"})]})]})]}),s.jsx(zn,{label:m.schedule.prompt,required:!0,size:"sm",rows:4,error:V.prompt,value:C.prompt,onChange:S=>G({prompt:S.target.value})}),s.jsxs("label",{className:"flex items-center gap-1.5 text-xs text-gray-600 dark:text-gray-300",children:[s.jsx("input",{type:"checkbox",checked:C.enabled,onChange:S=>G({enabled:S.target.checked})}),m.schedule.enabled]}),A&&s.jsx("p",{className:"text-xs text-red-600 dark:text-red-400",children:A})]})}),s.jsx(Mn,{open:Q!==null,title:m.schedule.deleteTitle,busy:j,onClose:()=>K(null),onConfirm:()=>{T()},children:s.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-300",children:Q!==null?m.schedule.deleteConfirm(Q):""})}),k&&s.jsx("p",{className:"text-xs text-red-600 dark:text-red-400",children:k})]})}const KD=/^[A-Za-z0-9][A-Za-z0-9_-]*$/,vl={connectTimeoutMs:1e4,timeoutMs:12e4,maxOutputLength:16e3},YD=new Set(["transport","command","args","env","cwd","url","headers","connectTimeoutMs","timeoutMs","maxOutputLength"]);function QD(){return{name:"",transport:"http",command:"",argsText:"",envText:"",cwd:"",url:"",headersText:"",connectTimeoutMs:String(vl.connectTimeoutMs),timeoutMs:String(vl.timeoutMs),maxOutputLength:String(vl.maxOutputLength),extras:{}}}function V1(e,t){return e===null||typeof e!="object"?"":Object.entries(e).map(([a,l])=>`${a}${t}${String(l)}`).join(`
176
- `)}function HS(e){const t=e.config;return t.transport==="http"||t.transport==="sse"||t.transport==="stdio"?t.transport:typeof t.url=="string"?"http":"stdio"}function XD(e){const t=e.config,a=HS(e),l={};for(const[o,c]of Object.entries(t))YD.has(o)||(l[o]=c);return{name:e.name,transport:a,command:typeof t.command=="string"?t.command:"",argsText:Array.isArray(t.args)?t.args.map(o=>String(o)).join(`
177
- `):"",envText:V1(t.env,"="),cwd:typeof t.cwd=="string"?t.cwd:"",url:typeof t.url=="string"?t.url:"",headersText:V1(t.headers,": "),connectTimeoutMs:String(typeof t.connectTimeoutMs=="number"?t.connectTimeoutMs:vl.connectTimeoutMs),timeoutMs:String(typeof t.timeoutMs=="number"?t.timeoutMs:vl.timeoutMs),maxOutputLength:String(typeof t.maxOutputLength=="number"?t.maxOutputLength:vl.maxOutputLength),extras:l}}function G1(e,t){const a={},l=e.split(`
178
- `);for(const[o,c]of l.entries()){const u=c.trim();if(u==="")continue;const f=u.indexOf(t),p=f>=0?u.slice(0,f).trim():"";if(f<0||p==="")return{ok:!1,line:o+1};a[p]=u.slice(f+1).trim()}return{ok:!0,map:a}}function ZD(e){const t=e.trim();if(t==="")return{ok:!0,value:void 0};const a=Number(t);return!Number.isInteger(a)||a<=0?{ok:!1,error:{code:"number"}}:{ok:!0,value:a}}function W1(e){const t={},a=e.name.trim();a===""?t.name={code:"required"}:KD.test(a)||(t.name={code:"name_charset"});const l={...e.extras,transport:e.transport};if(e.transport==="stdio"){const o=e.command.trim();o===""?t.command={code:"required"}:l.command=o;const c=e.argsText.split(`
179
- `).map(p=>p.trim()).filter(p=>p!=="");c.length>0&&(l.args=c);const u=G1(e.envText,"=");u.ok?Object.keys(u.map).length>0&&(l.env=u.map):t.env={code:"kv_line",line:u.line};const f=e.cwd.trim();f!==""&&(l.cwd=f)}else{const o=e.url.trim();if(o==="")t.url={code:"required"};else try{const u=new URL(o);u.protocol!=="http:"&&u.protocol!=="https:"?t.url={code:"url_invalid"}:l.url=o}catch{t.url={code:"url_invalid"}}const c=G1(e.headersText,":");c.ok?Object.keys(c.map).length>0&&(l.headers=c.map):t.headers={code:"kv_line",line:c.line}}for(const o of["connectTimeoutMs","timeoutMs","maxOutputLength"]){const c=ZD(e[o]);c.ok?c.value!==void 0&&c.value!==vl[o]&&(l[o]=c.value):t[o]=c.error}return Object.keys(t).length>0?{ok:!1,errors:t}:{ok:!0,server:{name:a,config:l}}}function Is(e){if(e)switch(e.code){case"required":return m.common.requiredField;case"name_charset":return m.agent.mcpNameInvalid;case"url_invalid":return m.agent.mcpUrlInvalid;case"kv_line":return m.agent.mcpLineInvalid(e.line??1);case"number":return m.agent.mcpNumberInvalid;case"duplicate":return m.agent.mcpDuplicateName}}function JD(e){const t=e.config;if(typeof t.url=="string")return t.url;const a=typeof t.command=="string"?t.command:"",l=Array.isArray(t.args)?t.args.map(o=>String(o)).join(" "):"";return l?`${a} ${l}`:a}function e7({result:e}){return e===void 0?null:e==="pending"?s.jsx("span",{className:"text-[11px] whitespace-nowrap text-gray-400",children:m.agent.mcpTestPending}):e.ok?s.jsx("span",{className:"text-[11px] font-medium whitespace-nowrap text-emerald-600 dark:text-emerald-400",children:m.agent.mcpTestBadge(e.tools?.length??0,e.latencyMs)}):s.jsx("span",{title:e.error,className:"text-[11px] font-medium whitespace-nowrap text-red-600 dark:text-red-400",children:m.agent.mcpTestBadgeFail})}function t7({agentId:e,initial:t}){const{currentProject:a}=Xt(),l=a?.projectId??null,[o,c]=y.useState(t),[u,f]=y.useState(!1),[p,h]=y.useState(null),[g,v]=y.useState(null),[k,w]=y.useState({}),[j,E]=y.useState(null),[C,M]=y.useState(null),[_,D]=y.useState(!1),[V,F]=y.useState(!1),[A,P]=y.useState(!1),[Q,K]=y.useState(new Map),O=[{value:"http",label:"http"},{value:"stdio",label:"stdio"},{value:"sse",label:"sse"}],z={http:m.agent.mcpTransportHttp,stdio:m.agent.mcpTransportStdio,sse:m.agent.mcpTransportSse},I=async S=>{if(!l||!e)return m.common.unknownError;f(!0);try{const U=await kl(l,e,{config:{mcpServers:S}});return c(U.config.mcpServers),Et(m.common.saved),null}catch(U){return Ie(U)}finally{f(!1)}},B=()=>{h(QD()),v(null),w({}),E(null)},$=S=>{const U=o[S];U&&(h(XD(U)),v(S),w({}),E(null))},G=()=>{h(null),v(null)},q=S=>{h(U=>U&&{...U,...S}),w({}),E(null)},ae=async()=>{if(!p||!l)return;const S=W1(p);if(!S.ok){w(S.errors);return}D(!0);try{const U=await Iv(l,e,S.server);U.ok?Et(m.agent.mcpTestOk(U.tools?.length??0,U.latencyMs)):Qe(m.agent.mcpTestFail(U.error??m.common.unknownError))}catch(U){Qe(m.agent.mcpTestFail(Ie(U)))}finally{D(!1)}},Z=async()=>{if(l){P(!0);try{for(const S of o){K(ee=>new Map(ee).set(S.name,"pending"));let U;try{U=await Iv(l,e,S)}catch(ee){U={ok:!1,error:Ie(ee)}}K(ee=>new Map(ee).set(S.name,U))}}finally{P(!1)}}},X=async()=>{if(!p)return;const S=W1(p);if(!S.ok){w(S.errors);return}if(o.some((de,me)=>me!==g&&de.name===S.server.name)){w({name:{code:"duplicate"}});return}const ee=g===null?[...o,S.server]:o.map((de,me)=>me===g?S.server:de),ie=await I(ee);if(ie!==null){E(ie);return}G()},T=async()=>{if(C===null)return;const S=await I(o.filter((U,ee)=>ee!==C));S!==null&&Qe(S),M(null)};if(!l)return null;const R=p!==null&&(p.transport==="stdio"?p.command.trim()!=="":p.url.trim()!==""),H=Q.size>0;return s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("p",{className:"mb-1 text-xs font-medium text-gray-500",children:m.agent.mcpServers}),s.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:m.agent.mcpDesc})]}),o.length===0?s.jsx("p",{className:"py-2 text-xs text-gray-400 dark:text-gray-500",children:m.agent.mcpEmpty}):s.jsx("div",{className:"overflow-x-auto overflow-y-clip rounded-md border border-gray-200 bg-white dark:border-gray-800 dark:bg-gray-900",children:s.jsxs("table",{className:"w-full min-w-[520px] text-left text-sm",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"border-b border-gray-200 bg-gray-50/80 text-xs text-gray-500 dark:border-gray-800 dark:bg-gray-900",children:[s.jsx("th",{className:"px-3 py-2.5",children:m.agent.mcpName}),s.jsx("th",{className:"px-3 py-2.5",children:m.agent.mcpTransport}),s.jsx("th",{className:"px-3 py-2.5",children:m.agent.mcpTarget}),H&&s.jsx("th",{className:"px-3 py-2.5"}),s.jsx("th",{className:"px-3 py-1 text-right font-normal whitespace-nowrap",children:s.jsx(we,{size:"sm",variant:"ghost",disabled:u||A,onClick:()=>F(!0),children:A?m.agent.mcpTestPending:m.agent.mcpTest})})]})}),s.jsx("tbody",{children:o.map((S,U)=>s.jsxs("tr",{className:"border-b border-gray-100 transition-colors duration-150 last:border-b-0 hover:bg-gray-50 dark:border-gray-800/60 dark:hover:bg-gray-800/40",children:[s.jsx("td",{className:"px-3 py-2 font-mono text-xs",children:S.name}),s.jsx("td",{className:"px-3 py-2 font-mono text-xs text-gray-500 dark:text-gray-400",children:HS(S)}),s.jsx("td",{className:"max-w-[360px] truncate px-3 py-2 font-mono text-xs text-gray-500 dark:text-gray-400",children:JD(S)}),H&&s.jsx("td",{className:"px-3 py-2 text-right",children:s.jsx(e7,{result:Q.get(S.name)})}),s.jsxs("td",{className:"px-3 py-2 text-right whitespace-nowrap",children:[s.jsx(we,{size:"sm",variant:"ghost",disabled:u,onClick:()=>$(U),children:m.common.edit}),s.jsx(we,{size:"sm",variant:"ghost",disabled:u,onClick:()=>M(U),children:m.agent.mcpRemove})]})]},S.name))})]})}),s.jsx(we,{size:"sm",variant:"primary",disabled:u,onClick:B,children:m.agent.mcpAdd}),s.jsx(Gt,{open:p!==null,title:g===null?m.agent.mcpAdd:m.agent.mcpEditTitle,onClose:G,footer:s.jsxs(s.Fragment,{children:[s.jsx(we,{onClick:G,children:m.common.cancel}),s.jsx(we,{variant:"primary",disabled:u,onClick:()=>{X()},children:m.common.save})]}),children:p&&s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsx(gl,{options:O,value:p.transport,onChange:S=>q({transport:S})}),s.jsx("p",{className:"text-xs text-gray-400 dark:text-gray-500",children:z[p.transport]})]}),s.jsx("div",{className:"flex flex-wrap items-center gap-2",children:s.jsx(we,{size:"sm",disabled:_||u||!R,onClick:()=>{ae()},children:_?m.agent.mcpTesting:m.agent.mcpTest})}),s.jsx(at,{size:"sm",label:m.agent.mcpName,required:!0,hint:m.agent.mcpNameHint,error:Is(k.name),value:p.name,onChange:S=>q({name:S.target.value}),className:"font-mono",placeholder:"filesystem",autoComplete:"off"}),p.transport==="stdio"?s.jsxs(s.Fragment,{children:[s.jsx(at,{size:"sm",label:m.agent.mcpCommand,required:!0,error:Is(k.command),value:p.command,onChange:S=>q({command:S.target.value}),className:"font-mono",placeholder:"npx",autoComplete:"off"}),s.jsx(zn,{size:"sm",mono:!0,label:m.agent.mcpArgs,hint:m.agent.mcpArgsHint,rows:3,value:p.argsText,onChange:S=>q({argsText:S.target.value}),placeholder:`-y
180
- @modelcontextprotocol/server-filesystem
181
- .`}),s.jsx(zn,{size:"sm",mono:!0,label:m.agent.mcpEnv,hint:m.agent.mcpEnvHint,error:Is(k.env),rows:2,value:p.envText,onChange:S=>q({envText:S.target.value}),placeholder:"API_TOKEN=..."}),s.jsx(at,{size:"sm",label:m.agent.mcpCwd,hint:m.agent.mcpCwdHint,value:p.cwd,onChange:S=>q({cwd:S.target.value}),className:"font-mono",autoComplete:"off"})]}):s.jsxs(s.Fragment,{children:[s.jsx(at,{size:"sm",label:m.agent.mcpUrl,required:!0,error:Is(k.url),value:p.url,onChange:S=>q({url:S.target.value}),className:"font-mono",placeholder:"https://example.com/mcp",autoComplete:"off"}),s.jsx(zn,{size:"sm",mono:!0,label:m.agent.mcpHeaders,hint:m.agent.mcpHeadersHint,error:Is(k.headers),rows:2,value:p.headersText,onChange:S=>q({headersText:S.target.value}),placeholder:"Authorization: Bearer ..."})]}),s.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[s.jsx(at,{size:"sm",label:m.agent.mcpConnectTimeout,error:Is(k.connectTimeoutMs),value:p.connectTimeoutMs,inputMode:"numeric",onChange:S=>q({connectTimeoutMs:S.target.value}),className:"font-mono",autoComplete:"off"}),s.jsx(at,{size:"sm",label:m.agent.toolTimeout,error:Is(k.timeoutMs),value:p.timeoutMs,inputMode:"numeric",onChange:S=>q({timeoutMs:S.target.value}),className:"font-mono",autoComplete:"off"}),s.jsx(at,{size:"sm",label:m.agent.toolMaxOutput,error:Is(k.maxOutputLength),value:p.maxOutputLength,inputMode:"numeric",onChange:S=>q({maxOutputLength:S.target.value}),className:"font-mono",autoComplete:"off"})]}),s.jsx("p",{className:"text-xs text-gray-400 dark:text-gray-500",children:m.agent.mcpBudgetsHint}),j&&s.jsx("p",{className:"text-xs text-red-600 dark:text-red-400",children:j})]})}),s.jsx(Gt,{open:V,title:m.agent.mcpTest,onClose:()=>F(!1),footer:s.jsxs(s.Fragment,{children:[s.jsx(we,{onClick:()=>F(!1),children:m.common.cancel}),s.jsx(we,{variant:"primary",onClick:()=>{F(!1),Z()},children:m.agent.mcpTestAllStart})]}),children:s.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-300",children:m.agent.mcpTestAllConfirm(o.length)})}),s.jsx(Mn,{open:C!==null,title:m.agent.mcpDeleteTitle,busy:u,onClose:()=>M(null),onConfirm:()=>{T()},children:s.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-300",children:C!==null?m.agent.mcpDeleteConfirm(o[C]?.name??""):""})})]})}function n7(e){return e.filter(([t])=>t!=="").map(([t,a])=>({value:t,triggerLabel:t,label:t,description:a}))}function Eo(e){const t=e.trim();if(!t)return;const a=Number(t);return Number.isFinite(a)?a:void 0}function ml(e){return e===void 0?"":String(e)}function a7(e,t,a){return t.some(l=>l.key===e)?e:a}function r7(){const e=[{key:"overview",label:m.agent.tabOverview},{key:"prompt",label:m.agent.tabPrompt},{key:"runtime",label:m.agent.tabRuntime},{key:"tools",label:m.agent.tabTools},{key:"skills",label:m.agent.tabSkills},{key:"memory",label:m.agent.tabMemory},{key:"vault",label:m.agent.tabVault},{key:"schedules",label:m.agent.tabSchedules}],t=Wn(),l=ew().agentId??"";Er(m.agent.settings);const{currentProject:o,reloadAgents:c}=Xt(),u=o?.projectId??null,[f,p]=y.useState(null),[h,g]=Ed(),[v,k]=y.useState(()=>a7(h.get("tab"),e,"overview")),w=y.useCallback(A=>{k(A),g(P=>{const Q=new URLSearchParams(P);return Q.set("tab",A),Q},{replace:!0})},[g]),[j,E]=y.useState(null),C=y.useCallback(A=>{!u||!l||(A?.keepStale||p(null),E(null),jl(u,l).then(p).catch(P=>E(Ie(P))))},[u,l]);y.useEffect(()=>{C()},[C]);const M=y.useCallback(()=>C({keepStale:!0}),[C]),_=y.useCallback(A=>{Et(m.agent.importDone(A)),C(),c()},[C,c]),D=y.useCallback(()=>{Et(m.agent.resetConfigDone),C(),c()},[C,c]),V=y.useCallback(()=>{C({keepStale:!0}),c()},[C,c]),F=y.useCallback(async A=>{if(!(!u||!l))try{const P=await kl(u,l,A);p(P),Et(m.common.saved),(A.config?.name!==void 0||A.config?.description!==void 0||A.config?.toolsBuiltin!==void 0)&&c()}catch(P){Qe(Ie(P))}},[u,l,c]);return u?j&&!f?s.jsx("p",{className:"p-6 text-sm text-red-600 dark:text-red-400",children:j}):f?s.jsx("div",{className:"no-scrollbar relative h-full overflow-y-auto p-4 md:p-6",children:s.jsxs("div",{className:"mx-auto max-w-3xl",children:[s.jsxs(we,{variant:"ghost",size:"sm",onClick:()=>t("/agents"),className:"-ml-2 mb-3 text-gray-500 dark:text-gray-400",children:[s.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[s.jsx("path",{d:"M15 18l-6-6 6-6"}),s.jsx("path",{d:"M9 12h12"})]}),m.agent.backToList]}),s.jsx("h1",{className:"mb-1 text-xl font-semibold",children:f.config.name??l}),s.jsx("p",{className:"mb-4 font-mono text-xs text-gray-400",children:l}),s.jsx(kD,{items:e,active:v,onChange:w}),s.jsxs("div",{className:"py-4",children:[v==="overview"&&s.jsx(l7,{data:f,agentId:l,onSave:F,onImported:_,onConfigReset:D,onKernelUpdated:V}),v==="prompt"&&s.jsx(i7,{data:f,onSave:F}),v==="memory"&&s.jsx($D,{agentId:l,onConfigChanged:M}),v==="runtime"&&s.jsx(o7,{data:f,onSave:F}),v==="tools"&&s.jsxs("div",{className:"space-y-8",children:[s.jsx(c7,{data:f,onSave:F}),s.jsx(t7,{agentId:l,initial:f.config.mcpServers})]}),v==="skills"&&s.jsx(AD,{agentId:l,onConfigChanged:M}),v==="vault"&&s.jsx(HD,{agentId:l,onConfigChanged:M}),v==="schedules"&&s.jsx(WD,{agentId:l,onConfigChanged:M})]})]})}):s.jsxs("div",{className:"space-y-3 p-6",children:[s.jsx(en,{className:"h-6 w-64"}),s.jsx(en,{className:"h-32 w-full"})]}):null}const K1="inline-flex cursor-pointer items-center justify-center gap-1 rounded-md border border-gray-300 bg-white px-2.5 py-1 text-xs font-medium text-gray-800 transition-colors duration-150 hover:bg-gray-50 focus-within:ring-2 focus-within:ring-gray-400/30 dark:border-gray-700 dark:bg-gray-900 dark:text-gray-200 dark:hover:bg-gray-800",s7="M23 4v6h-6M20.49 15a9 9 0 1 1-2.12-9.36L23 10";function l7({data:e,agentId:t,onSave:a,onImported:l,onConfigReset:o,onKernelUpdated:c}){const{currentProject:u}=Xt(),f=u?.projectId??null,p=u?.role==="owner",[h,g]=y.useState(e.config.name??""),[v,k]=y.useState(e.config.description??""),[w,j]=y.useState(!1),[E,C]=y.useState(null),[M,_]=y.useState(null),[D,V]=y.useState(!1),[F,A]=y.useState(!1),[P,Q]=y.useState(!1),[K,O]=y.useState(!1),[z,I]=y.useState(null),{requestSave:B,element:$}=ki(),G=async()=>{if(f){A(!0);try{await cN(f,t),V(!1),o()}catch(T){Qe(Ie(T))}finally{A(!1)}}},q=async()=>{if(f){O(!0);try{const T=await uN(f,t);Q(!1),I(T),Et(m.agent.kernelUpdateDone(T.kernelVersion,T.advanced.length)),c()}catch(T){Qe(Ie(T))}finally{O(!1)}}},ae=()=>{const T={};if(h.trim()!==(e.config.name??"")&&(T.name=h.trim()),v.trim()!==(e.config.description??"")&&(T.description=v.trim()),Object.keys(T).length===0){Mr(m.common.noChangesToSave);return}B(()=>{a({config:T})})},Z=async(T,R)=>{if(f){j(!0),C(null);try{const H=await PN(f,t,{dataBase64:T,...R?{confirm:!0}:{}});_(null),l(H.version)}catch(H){H instanceof na&&H.status===409&&H.code==="version_conflict"?_(T):(_(null),C(Ie(H)))}finally{j(!1)}}},X=T=>{const R=T.target.files?.[0];if(T.target.value="",!R)return;C(null);const H=new FileReader;H.onload=()=>{const S=H.result;Z(S.slice(S.indexOf(",")+1),!1)},H.onerror=()=>C(m.common.unknownError),H.readAsDataURL(R)};return s.jsxs("div",{className:"space-y-4",children:[s.jsx(at,{size:"sm",label:m.common.name,value:h,onChange:T=>g(T.target.value)}),s.jsx(zn,{label:m.agent.description,size:"sm",rows:3,value:v,onChange:T=>k(T.target.value)}),s.jsx(we,{size:"sm",variant:"primary",onClick:ae,children:m.common.save}),$,s.jsxs("section",{className:"border-t border-gray-200 pt-4 dark:border-gray-800",children:[s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-x-4 gap-y-2",children:[s.jsx("p",{className:"text-sm font-medium",children:m.agent.stateTitle}),s.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[f&&s.jsx("a",{href:$N(f,t),download:!0,className:K1,children:m.agent.exportSnapshot}),p&&s.jsxs("label",{className:`${K1} ${w?"pointer-events-none opacity-60":""}`,children:[s.jsx(Hd,{accept:".tar.gz,.tgz",disabled:w,onChange:X}),w?m.agent.importing:m.agent.importSnapshot]})]})]}),s.jsx("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400",children:m.agent.transferDesc}),s.jsxs("div",{className:"mt-3 space-y-2.5",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:m.agent.stateVersion}),s.jsxs("p",{className:"mt-0.5 font-mono text-sm font-semibold",children:["v",e.config.version]})]}),s.jsxs("div",{children:[s.jsx("p",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:m.agent.stateDir}),s.jsxs("div",{className:"flex items-start gap-1.5",children:[s.jsx("span",{title:e.stateDir,className:"min-w-0 flex-1 break-all font-mono text-xs leading-5",children:e.stateDir}),s.jsx(uc,{text:e.stateDir,label:m.agent.copyStateDir,showCopiedText:!0,className:"flex shrink-0 items-center gap-1 rounded p-0.5 text-xs text-gray-400 transition-colors duration-150 hover:bg-gray-100 hover:text-gray-600 dark:text-gray-500 dark:hover:bg-gray-800 dark:hover:text-gray-300"})]})]})]}),E&&s.jsx("p",{className:"mt-1.5 text-xs text-red-600 dark:text-red-400",children:E})]}),s.jsxs("section",{className:"border-t border-gray-200 pt-4 dark:border-gray-800",children:[s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-x-4 gap-y-2",children:[s.jsx("p",{className:"text-sm font-medium",children:m.agent.kernelTitle}),s.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[s.jsx(we,{size:"sm",disabled:K||!e.config.kernelOutdated,onClick:()=>Q(!0),children:m.agent.kernelUpdateAction}),s.jsx(we,{size:"sm",variant:"danger",disabled:F,onClick:()=>V(!0),children:m.agent.resetConfigAction})]})]}),s.jsx("p",{className:"mt-2.5 flex flex-wrap items-baseline gap-x-1.5 gap-y-0.5 text-sm",children:e.config.kernelOutdated?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:m.agent.kernelCurrent}),s.jsx("span",{className:"font-mono font-semibold",children:e.config.kernelVersion??m.agent.kernelLegacy}),s.jsxs("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:["· ",m.agent.kernelLatest]}),s.jsx("span",{className:"font-mono font-semibold",children:e.config.kernelLatest}),s.jsx("span",{role:"img",title:m.agent.kernelOutdatedHint,"aria-label":m.agent.kernelOutdatedHint,className:"self-center text-gray-500 dark:text-gray-400",children:s.jsx(qe,{d:s7,size:12})})]}):s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"font-mono font-semibold",children:e.config.kernelVersion}),s.jsxs("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:["· ",m.agent.kernelUpToDate]})]})}),z!==null&&z.kept.length>0&&s.jsxs("p",{className:"mt-2 text-xs text-gray-500 dark:text-gray-400",children:[m.agent.kernelUpdateKeptIntro,z.kept.map(PD).join(m.agent.kernelListSeparator)]})]}),s.jsx(Mn,{open:M!==null,title:m.agent.importConflictTitle,busy:w,onClose:()=>_(null),onConfirm:()=>{M!==null&&Z(M,!0)},children:s.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-300",children:m.agent.importConflictBody})}),s.jsx(Mn,{open:P,title:m.agent.kernelUpdateTitle,busy:K,tone:"primary",onClose:()=>Q(!1),onConfirm:()=>{q()},confirmLabel:m.agent.kernelUpdateAction,children:s.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-300",children:m.agent.kernelUpdateConfirmBody})}),s.jsx(Mn,{open:D,title:m.agent.resetConfigTitle,busy:F,onClose:()=>V(!1),onConfirm:()=>{G()},confirmLabel:m.agent.resetConfigAction,children:s.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-300",children:m.agent.resetConfigConfirmBody})})]})}function i7({data:e,onSave:t}){const[a,l]=y.useState(e.agentsMd),[o,c]=y.useState(e.config.systemPrompt),u=y.useRef(null),{requestSave:f,element:p}=ki(),h=()=>{const v={};if(a!==e.agentsMd&&(v.agentsMd=a),o!==e.config.systemPrompt&&(v.config={systemPrompt:o}),v.agentsMd===void 0&&v.config===void 0){Mr(m.common.noChangesToSave);return}f(()=>{t(v)})},g=v=>{const k=u.current;if(k&&(k.focus(),document.execCommand?.("insertText",!1,v)))return;const w=k?k.selectionStart:o.length,j=k?k.selectionEnd:o.length;c(o.slice(0,w)+v+o.slice(j)),requestAnimationFrame(()=>{if(!k)return;k.focus();const E=w+v.length;k.setSelectionRange(E,E)})};return s.jsxs("div",{className:"space-y-4",children:[s.jsx(zn,{label:m.agent.agentsMd,mono:!0,size:"sm",rows:14,value:a,onChange:v=>l(v.target.value)}),s.jsx(zn,{ref:u,label:m.agent.systemPrompt,mono:!0,size:"sm",rows:12,value:o,onChange:v=>c(v.target.value)}),s.jsxs("div",{className:"rounded-md border border-gray-200 bg-gray-50 p-3 dark:border-gray-800 dark:bg-gray-900",children:[s.jsx("p",{className:"mb-2 text-xs font-semibold text-gray-500",children:m.agent.placeholdersTitle}),s.jsx("ul",{className:"space-y-1",children:m.agent.placeholders.map(([v,k])=>s.jsxs("li",{className:"flex items-center gap-3 text-xs",children:[s.jsx("button",{type:"button",onClick:()=>g(v),title:m.agent.insertPlaceholder,className:"shrink-0 rounded border border-gray-200 bg-white px-1.5 py-0.5 font-mono font-semibold text-gray-800 transition-colors duration-150 hover:border-gray-400 hover:bg-gray-100 dark:border-gray-700 dark:bg-gray-800 dark:text-gray-200 dark:hover:border-gray-500 dark:hover:bg-gray-700",children:v}),s.jsx("span",{className:"text-gray-500 dark:text-gray-400",children:k})]},v))})]}),s.jsx(we,{size:"sm",variant:"primary",onClick:h,children:m.common.save}),p]})}function o7({data:e,onSave:t}){const a=e.config,[l,o]=y.useState(ml(a.maxTurns)),[c,u]=y.useState(ml(a.model?.maxTokens)),[f,p]=y.useState(a.model?.thinkingLevel??""),[h,g]=y.useState(ml(a.model?.timeoutMs)),[v,k]=y.useState(ml(a.compaction?.maxContextLength)),[w,j]=y.useState(ml(a.compaction?.maxSessionTurns)),[E,C]=y.useState(a.compaction?.mode??""),[M,_]=y.useState(a.compaction?.prompt??""),[D,V]=y.useState({}),F=()=>V(z=>z.maxTurns||z.timeoutMs?{}:z),{requestSave:A,element:P}=ki(),Q=()=>{V({});const z={},I=Eo(l);if(I!==void 0&&I!==a.maxTurns){if(I<=0&&I!==-1){V({maxTurns:m.agent.maxTurnsInvalid});return}z.maxTurns=I}const B={},$=Eo(c);$!==void 0&&$!==a.model?.maxTokens&&(B.maxTokens=$),f&&f!==(a.model?.thinkingLevel??"")&&(B.thinkingLevel=f);const G=Eo(h);if(G!==void 0&&G!==a.model?.timeoutMs){if(G<=0&&G!==-1){V({timeoutMs:m.agent.timeoutInvalid});return}B.timeoutMs=G}Object.keys(B).length>0&&(z.model=B);const q={},ae=Eo(v);ae!==void 0&&ae!==a.compaction?.maxContextLength&&(q.maxContextLength=ae);const Z=Eo(w);if(Z!==void 0&&Z!==a.compaction?.maxSessionTurns&&(q.maxSessionTurns=Z),E&&E!==(a.compaction?.mode??"")&&(q.mode=E),M!==(a.compaction?.prompt??"")&&(q.prompt=M),Object.keys(q).length>0&&(z.compaction=q),Object.keys(z).length===0){Mr(m.common.noChangesToSave);return}A(()=>{t({config:z})})},K=G8(m.agent.thinkingLevelOptions,m.agent.thinkingLevelNoneKept,a.model?.thinkingLevel),O=n7(m.agent.compactionModeOptions);return s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"overflow-hidden rounded-md border border-gray-200 bg-white dark:border-gray-800 dark:bg-gray-900",children:[s.jsx("div",{className:"p-3",children:s.jsxs("div",{className:"grid grid-cols-1 gap-3 md:grid-cols-2",children:[s.jsx(at,{label:m.agent.maxTurns,size:"sm",value:l,error:D.maxTurns,onChange:z=>{o(z.target.value),F()},inputMode:"numeric",className:"font-mono"}),s.jsx(at,{label:m.agent.maxTokens,size:"sm",value:c,onChange:z=>u(z.target.value),inputMode:"numeric",className:"font-mono"}),s.jsx(Ih,{label:m.agent.thinkingLevel,fullWidth:!0,size:"sm",placeholder:m.agent.defaultValue,value:f,onChange:p,options:K}),s.jsx(at,{label:m.agent.timeoutMs,hint:m.agent.timeoutMsHint,size:"sm",value:h,error:D.timeoutMs,onChange:z=>{g(z.target.value),F()},inputMode:"numeric",className:"font-mono"})]})}),s.jsx("div",{className:"border-t border-b border-gray-200 bg-gray-50/80 px-3 py-2 text-xs font-semibold text-gray-500 dark:border-gray-800 dark:bg-gray-900",children:m.agent.compaction}),s.jsx("div",{className:"p-3",children:s.jsxs("div",{className:"grid grid-cols-1 gap-3 md:grid-cols-3",children:[s.jsx(at,{label:m.agent.maxContextLength,hint:m.agent.maxContextLengthHint,size:"sm",value:v,onChange:z=>k(z.target.value),inputMode:"numeric",className:"font-mono"}),s.jsx(at,{label:m.agent.maxSessionTurns,hint:m.agent.maxSessionTurnsHint,size:"sm",value:w,onChange:z=>j(z.target.value),inputMode:"numeric",className:"font-mono"}),s.jsx(Ih,{label:m.agent.compactionMode,fullWidth:!0,size:"sm",placeholder:m.agent.defaultValue,value:E,onChange:C,options:O})]})}),s.jsx("div",{className:"border-t border-b border-gray-200 bg-gray-50/80 px-3 py-2 text-xs font-semibold text-gray-500 dark:border-gray-800 dark:bg-gray-900",children:m.agent.compactionPrompt}),s.jsx("div",{className:"p-3",children:s.jsx(zn,{"aria-label":m.agent.compactionPrompt,mono:!0,size:"sm",rows:4,value:M,onChange:z=>_(z.target.value)})})]}),s.jsx(we,{size:"sm",variant:"primary",onClick:Q,children:m.common.save}),P]})}function c7({data:e,onSave:t}){const a=[{value:"r",triggerLabel:"r",label:m.agent.permissionReadLabel,description:m.agent.permissionReadDescription},{value:"rw",triggerLabel:"rw",label:m.agent.permissionReadWriteLabel,description:m.agent.permissionReadWriteDescription}],[l,o]=y.useState(()=>e.config.toolsBuiltin.map(k=>({base:{...k},timeoutMs:ml(k.timeoutMs),maxOutputLength:ml(k.maxOutputLength)}))),[c,u]=y.useState({}),{requestSave:f,element:p}=ki(),h=(k,w)=>{o(j=>j.map((E,C)=>C===k?{...E,...w}:E)),u(j=>{const E=`${k}-timeoutMs`,C=`${k}-maxOutputLength`;if(!j[E]&&!j[C])return j;const M={...j};return delete M[E],delete M[C],M})},g=()=>{const k={},w=[];for(const[C,M]of l.entries()){const _={...M.base};delete _.timeoutMs,delete _.maxOutputLength;const D=M.timeoutMs.trim();if(D){const A=Number(D);!Number.isInteger(A)||A<=0&&A!==-1?k[`${C}-timeoutMs`]=m.agent.toolFieldInvalid(M.base.name,"timeoutMs"):_.timeoutMs=A}const V=M.maxOutputLength.trim();if(V){const A=Number(V);!Number.isInteger(A)||A<=0&&A!==-1?k[`${C}-maxOutputLength`]=m.agent.toolFieldInvalid(M.base.name,"maxOutputLength"):_.maxOutputLength=A}const F=e.config.toolsBuiltin[C];_.call_description===!0&&F?.call_description===void 0&&delete _.call_description,w.push(_)}if(Object.keys(k).length>0){u(k);return}u({});const j=e.config.toolsBuiltin;if(!(w.length!==j.length||w.some((C,M)=>{const _=j[M];return C.permission!==_.permission||C.timeoutMs!==_.timeoutMs||C.maxOutputLength!==_.maxOutputLength||C.call_description!==_.call_description}))){Mr(m.common.noChangesToSave);return}f(()=>{t({config:{toolsBuiltin:w}})})},v=k=>{const w=k.parameters?.properties;return w!=null&&w.description!==void 0};return s.jsxs("div",{className:"space-y-4",children:[s.jsx("div",{className:"overflow-x-auto overflow-y-clip rounded-md border border-gray-200 bg-white dark:border-gray-800 dark:bg-gray-900",children:s.jsxs("table",{className:"w-full min-w-[640px] text-left text-sm",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"border-b border-gray-200 bg-gray-50/80 text-xs text-gray-500 dark:border-gray-800 dark:bg-gray-900",children:[s.jsx("th",{className:"px-3 py-2",children:m.common.name}),s.jsx("th",{className:"px-3 py-2",children:m.agent.toolPermission}),s.jsx("th",{className:"px-3 py-2",children:m.agent.toolTimeout}),s.jsx("th",{className:"px-3 py-2",children:m.agent.toolMaxOutput}),s.jsx("th",{className:"px-3 py-2",children:m.agent.toolCallDescription})]})}),s.jsx("tbody",{children:l.map((k,w)=>s.jsxs("tr",{className:"border-b border-gray-100 dark:border-gray-800/60",children:[s.jsx("td",{className:"px-3 py-2 align-top font-mono text-xs",children:k.base.name}),s.jsx("td",{className:"px-3 py-2 align-top",children:s.jsx(Ih,{mono:!0,size:"sm","aria-label":m.agent.toolPermission,placeholder:m.agent.defaultValue,options:a,value:k.base.permission,onChange:j=>h(w,{base:{...k.base,permission:j}})})}),s.jsx("td",{className:"px-3 py-2 align-top",children:s.jsx(at,{size:"sm",value:k.timeoutMs,error:c[`${w}-timeoutMs`],inputMode:"numeric",className:"font-mono",onChange:j=>h(w,{timeoutMs:j.target.value})})}),s.jsx("td",{className:"px-3 py-2 align-top",children:s.jsx(at,{size:"sm",value:k.maxOutputLength,error:c[`${w}-maxOutputLength`],inputMode:"numeric",className:"font-mono",onChange:j=>h(w,{maxOutputLength:j.target.value})})}),s.jsx("td",{className:"px-3 py-2 align-top",children:v(k.base)?s.jsx(wl,{checked:k.base.call_description!==!1,onChange:j=>h(w,{base:{...k.base,call_description:j}}),"aria-label":`${k.base.name} ${m.agent.toolCallDescription}`}):s.jsx("span",{className:"text-xs text-gray-300 dark:text-gray-600",children:"—"})})]},k.base.name))})]})}),s.jsx("p",{className:"text-xs text-gray-400 dark:text-gray-500",children:m.agent.callDescriptionHint}),s.jsx(we,{size:"sm",variant:"primary",onClick:g,children:m.common.save}),p]})}const u7="M22 2 11 13M22 2 15 22 11 13 2 9 22 2",d7="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4M7 10l5 5 5-5M12 15V3",f7="M23 4v6h-6M20.49 15a9 9 0 1 1-2.12-9.36L23 10";function m7(e,t,a,l){return e.filter(o=>{const c=t.get(o)?.get(a);return c!==void 0&&c<l})}function p7(){Er(m.nav.skills);const e=Wn(),{locale:t}=La(),a=xn().user?.userId??null,{currentProject:l,agents:o,currentAgent:c,setCurrentAgentId:u}=Xt(),f=l?.projectId??null,[p,h]=y.useState(null),[g,v]=y.useState(null),[k,w]=y.useState(new Map),[j,E]=y.useState(new Set);y.useEffect(()=>{let A=!1;return v(null),_N().then(P=>{A||h(P.groups)}).catch(P=>{A||v(Ie(P))}),()=>{A=!0}},[]);const C=o.map(A=>A.agentId).join(",");y.useEffect(()=>{if(w(new Map),!f||C==="")return;let A=!1;const P=C.split(",");return Promise.all(P.map(async Q=>{try{const K=await Cd(f,Q);return[Q,new Map(K.skills.map(O=>[O.name,O.version]))]}catch{return[Q,new Map]}})).then(Q=>{A||w(K=>{const O=new Map(Q);for(const[z,I]of K)O.set(z,I);return O})}),()=>{A=!0}},[f,C]);const M=(A,P,Q)=>w(K=>{const O=new Map(K),z=new Map(O.get(A)??[]);return Q!==void 0?z.set(P,Q):z.delete(P),O.set(A,z),O}),_=(A,P)=>w(Q=>new Map(Q).set(A,new Map(P.map(K=>[K.name,K.version])))),D=async(A,P,Q,K)=>{if(!f)return;const O=k.get(A)?.get(P);M(A,P,Q?K:void 0);const z=o.find(B=>B.agentId===A),I=z?tn(z):A;try{if(Q){const B=await zv(f,A,[P]);_(A,B.skills),Et(m.skills.installedToast(P,I))}else await Ik(f,A,P),Et(m.skills.uninstalledToast(P,I))}catch(B){if(!Q&&B instanceof na&&B.status===404)return;M(A,P,O),Qe(Ie(B))}},V=async(A,P)=>{if(!f||P.length===0)return;const K=(await Promise.allSettled(P.map(async O=>{const z=await zv(f,O,[A]);_(O,z.skills)}))).find(O=>O.status==="rejected");K?Qe(Ie(K.reason)):Et(m.skills.updatedToast(A,P.length))},F=A=>{const P=c?.agentId;if(P){if(a&&f){Ci(a,f);const Q=jr(a,f);Jr(Q,{...Fs(Q),agentId:P,text:m.skills.quickInvokeText(A),skills:[A],handoffAgentId:void 0})}u(P),e(`/chat/${Ia}`,{state:{agentId:P}})}};return s.jsx("div",{className:"h-full overflow-y-auto p-4 md:p-6",children:s.jsxs("div",{className:"mx-auto max-w-5xl",children:[s.jsx("h1",{className:"text-xl font-semibold",children:m.skills.pageTitle}),s.jsx("p",{className:"mt-1 text-sm text-gray-500 dark:text-gray-400",children:m.skills.pageDesc}),g?s.jsxs("div",{className:"mt-6 flex items-center gap-3",children:[s.jsx("p",{className:"text-sm text-red-600 dark:text-red-400",children:g}),s.jsx(we,{size:"sm",onClick:()=>window.location.reload(),children:m.common.retry})]}):p===null?s.jsx("div",{className:"mt-6 grid gap-2.5 sm:grid-cols-2",children:Array.from({length:4},(A,P)=>s.jsxs(Ow,{className:"p-4",children:[s.jsx(en,{className:"h-4 w-32"}),s.jsx(en,{className:"mt-2 h-4 w-3/4"}),s.jsx(en,{className:"mt-3 h-6 w-36"})]},P))}):s.jsx("div",{className:"mt-6 space-y-3",children:p.map(A=>{const P=!j.has(A.id);return s.jsxs("section",{className:"overflow-hidden rounded-md bg-white dark:bg-gray-900",children:[s.jsxs("button",{type:"button","aria-expanded":P,onClick:()=>E(Q=>{const K=new Set(Q);return K.has(A.id)?K.delete(A.id):K.add(A.id),K}),className:"flex w-full items-center gap-2.5 bg-gray-50 px-3 py-2.5 text-left transition-colors duration-150 hover:bg-gray-100 dark:bg-gray-900/60 dark:hover:bg-gray-800/60",children:[s.jsx("span",{className:"min-w-0 truncate text-sm font-semibold",children:f8(t,A.title,A.titleZh)}),s.jsx("span",{className:"shrink-0 whitespace-nowrap font-mono text-xs text-gray-400",children:m.skills.skillCount(A.skills.length)}),s.jsx("span",{className:"min-w-0 flex-1"}),s.jsx($n,{open:P,className:"text-gray-400"})]}),s.jsx("div",{className:`grid transition-[grid-template-rows] duration-200 ease-out ${P?"grid-rows-[1fr]":"grid-rows-[0fr]"}`,children:s.jsx("div",{className:"overflow-hidden",inert:!P,children:s.jsx("div",{className:`grid gap-2.5 p-2.5 transition-opacity duration-200 sm:grid-cols-2 ${P?"opacity-100":"opacity-0"}`,children:A.skills.map(Q=>s.jsx(h7,{skill:Q,installed:k,onQuickInvoke:F,onToggleInstall:D,onUpdateOutdated:V},Q.name))})})})]},A.id)})})]})})}function h7({skill:e,installed:t,onQuickInvoke:a,onToggleInstall:l,onUpdateOutdated:o}){const{locale:c}=La(),{agents:u,currentAgent:f}=Xt(),[p,h]=y.useState(!1),[g,v]=y.useState(null),[k,w]=y.useState(!1),[j,E]=y.useState(null),C=async()=>{g&&(w(!0),await o(e.name,g),w(!1),v(null))},M=j!==null?u.find(K=>K.agentId===j):void 0,_=M?tn(M):void 0;let D=0;for(const K of t.values())K.has(e.name)&&(D+=1);const V=m7(u.map(K=>K.agentId),t,e.name,e.version),F=f!==null&&(t.get(f.agentId)?.has(e.name)??!1),A=ji(c,e),P=e.description,Q=[`v${e.version}`,e.updated?sd(e.updated,c):null,m.skills.usedByAgents(D)].filter(K=>K!==null).join(" · ");return s.jsxs("div",{className:"flex h-full items-center gap-3 rounded-md p-4 transition-colors hover:bg-gray-100/70 dark:hover:bg-gray-800/60",children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("span",{className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-lg ${uS(e.name)}`,children:s.jsx(Bd,{icon:e.icon,size:20})}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("span",{className:"block truncate font-mono text-[13px] font-semibold",title:e.name,children:e.name}),s.jsx("p",{className:"mt-0.5 truncate text-xs leading-5 text-gray-500 dark:text-gray-400",title:P,children:A})]})]}),s.jsx("p",{className:"mt-2.5 truncate text-[11px] text-gray-400 dark:text-gray-500",title:Q,children:Q})]}),s.jsxs("div",{className:"flex shrink-0 items-center justify-center gap-1.5",children:[V.length>0&&s.jsx(we,{size:"sm",variant:"secondary",className:"h-8 w-8 shrink-0 justify-center p-0","aria-label":`${m.skills.updateOutdated(V.length)} ${e.name}`,title:m.skills.updateOutdated(V.length),onClick:()=>v(V),children:s.jsx(qe,{d:f7,size:13})}),s.jsx(we,{size:"sm",className:"h-8 w-8 shrink-0 justify-center p-0","aria-label":`${m.skills.quickInvoke} ${e.name}`,title:F?m.skills.quickInvoke:m.skills.quickInvokeNeedsInstall,disabled:!F,onClick:()=>a(e.name),children:s.jsx(qe,{d:u7,size:15})}),s.jsx(we,{size:"sm",className:"h-8 w-8 shrink-0 justify-center p-0","aria-label":`${m.skills.manageInstall} ${e.name}`,title:m.skills.manageInstall,onClick:()=>h(!0),children:s.jsx(qe,{d:d7,size:15})})]}),p&&s.jsx(Gt,{open:!0,title:m.skills.manageInstallTitle(e.name),onClose:()=>h(!1),children:s.jsxs("div",{className:"space-y-0.5",children:[u.length===0&&s.jsx("p",{className:"py-1.5 text-xs text-gray-400",children:m.common.loading}),u.map(K=>s.jsx(g7,{agentId:K.agentId,name:tn(K),installed:t.get(K.agentId)?.has(e.name)??!1,outdated:V.includes(K.agentId),onToggle:O=>{O?l(K.agentId,e.name,!0,e.version):E(K.agentId)},onUpdate:()=>v([K.agentId])},K.agentId))]})}),g&&s.jsx(Mn,{open:!0,title:m.skills.updateConfirmTitle(e.name),tone:"primary",confirmLabel:m.skills.updateAction,busy:k,onClose:()=>v(null),onConfirm:()=>{C()},children:s.jsxs("div",{className:"space-y-3",children:[s.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-300",children:m.skills.updateConfirmWarning(e.name)}),s.jsx("ul",{className:"divide-y divide-gray-100 overflow-hidden rounded-md border border-gray-200 dark:divide-gray-800 dark:border-gray-800",children:g.map(K=>{const O=t.get(K)?.get(e.name),z=u.find(I=>I.agentId===K);return s.jsxs("li",{className:"flex items-center justify-between gap-3 px-3 py-1.5 text-xs",children:[s.jsx("span",{className:"min-w-0 truncate",children:z?tn(z):K}),s.jsxs("span",{className:"shrink-0 font-mono text-gray-500 dark:text-gray-400",children:["v",O??"?"," → v",e.version]})]},K)})})]})}),j!==null&&s.jsx(Mn,{open:!0,title:m.skills.uninstallConfirmTitle(e.name),confirmLabel:m.skills.uninstall,onClose:()=>E(null),onConfirm:()=>{const K=j;E(null),l(K,e.name,!1,e.version)},children:s.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-300",children:m.skills.uninstallConfirmBody(e.name,_??j)})})]})}function g7({agentId:e,name:t,installed:a,outdated:l,onToggle:o,onUpdate:c}){return s.jsxs("div",{className:"flex items-center gap-2 rounded-md px-1.5 py-1.5 transition-colors duration-150 hover:bg-gray-50 dark:hover:bg-gray-800/60",children:[s.jsx(xa,{id:e,name:t,size:22,className:"shrink-0 rounded"}),s.jsx("span",{className:"min-w-0 flex-1 truncate text-sm",title:e,children:t}),a&&l&&s.jsx(we,{size:"sm",variant:"secondary",className:"shrink-0","aria-label":`${m.skills.updateAction} ${e}`,onClick:c,children:m.skills.updateAction}),a?s.jsxs(we,{size:"sm",variant:"ghost",className:"group shrink-0","aria-label":`${m.skills.uninstall} ${e}`,onClick:()=>o(!1),children:[s.jsx("span",{className:"group-hover:hidden",children:m.skills.installed}),s.jsx("span",{className:"hidden text-red-600 group-hover:inline dark:text-red-400",children:m.skills.uninstall})]}):s.jsx(we,{size:"sm",className:"shrink-0","aria-label":`${m.skills.install} ${e}`,onClick:()=>o(!0),children:m.skills.install})]})}function x7(e,t){const a=t.trim().toLowerCase();if(a.includes("openai"))return"/chat/completions";if(a.includes("claude"))return"/v1/messages";if(a.includes("gemini"))return"/v1beta/models";if(a.includes("gpt"))return"/responses";if(a!=="")return"/chat/completions";switch(e){case"anthropic":return"/v1/messages";case"openai":return"/responses";case"google":return"/v1beta/models";default:return"/chat/completions"}}function Op(){return new Set(["deepseek"])}function y7(e,t,a){return a||e.has(t)}function v7(e,t){const a=new Set(e);return a.has(t)?a.delete(t):a.add(t),a}const FS=e=>`penguin.modelsExpandedGroups.${e}`;function b7(e){return JSON.stringify([...e])}function k7(e){if(e===null)return null;try{const t=JSON.parse(e);return Array.isArray(t)?new Set(t.filter(a=>typeof a=="string")):null}catch{return null}}function Y1(e,t=localStorage){if(e===null)return Op();try{return k7(t.getItem(FS(e)))??Op()}catch{return Op()}}function w7(e,t,a=localStorage){if(e!==null)try{a.setItem(FS(e),b7(t))}catch{}}function qS(e){return{vision:e.vision!==!1,contextWindow:e.context_window!==void 0?String(e.context_window):"",clientType:e.client_type??"",cacheRead:e.pricing?String(e.pricing.cache_read):"",cacheWrite:e.pricing?String(e.pricing.cache_write):"",output:e.pricing?String(e.pricing.output):"",baseUrl:e.base_url??""}}function S7(e){return{provider:e.provider,modelId:e.model_id,original:null,...qS(e),maxTokens:"",originalBaseUrl:"",apiKeyInput:"",clearApiKey:!1}}function j7(e,t=U8()){const a=(f,p)=>`${f}\0${p}`,l=new Map(e.map((f,p)=>[a(f.provider,f.modelId),p])),o=[...e];let c=0,u=0;for(const f of t){const p=l.get(a(f.provider,f.model_id));if(p===void 0){o.push(S7(f)),c+=1;continue}const h=o[p],g=qS(f);Object.keys(g).some(k=>h[k]!==g[k])&&(o[p]={...h,...g},u+=1)}return{rows:o,added:c,updated:u}}function C7(e){return e<1e3?"green":e<=3e3?"yellow":"red"}function N7(e){return e>=40?"green":e>=15?"yellow":"red"}const VS={USD:"$",CNY:"¥"};function Q1(e){return Number.isFinite(e)?String(Math.round(e*1e6)/1e6):"0"}function Lh(e){return Number.isFinite(e)?String(Math.round(e*1e4)/1e4):"0"}function Dp(e,t){const a=Number(e||"0"),l=t==="CNY"?a*$h:a;return`${VS[t]}${Lh(l)}`}function ii(e,t){const a=e.trim();if(!a)return"";const l=Number(a);return Number.isFinite(l)?Lh(t==="CNY"?l*$h:l):a}function zp(e,t){const a=e.trim();if(!a)return"";const l=Number(a);return Number.isFinite(l)?Q1(t==="CNY"?l/$h:l):a}const T7="M12 5v14M5 12h14",M7="M21 2l-2 2m-7.61 7.61a5.5 5.5 0 1 1-7.778 7.778 5.5 5.5 0 0 1 7.777-7.777zm0 0L15.5 7.5m0 0l3 3L22 7l-3-3m-3.5 3.5L19 4",E7="M12 14l3.5-3.5M20.49 17A10 10 0 1 0 3.5 17",A7="M12 22a10 10 0 1 0 0-20 10 10 0 0 0 0 20ZM12 7v5l3.5 2",R7="M13 2 3 14h9l-1 8 10-12h-9l1-8Z",X1={green:"text-green-600 dark:text-green-400",yellow:"text-amber-600 dark:text-amber-400",red:"text-red-600 dark:text-red-400"},Z1=(e,t)=>`${e}\0${t}`,Up=128e3;function J1(e){return e.replace(/[^\d]/g,"")}function _7(e){const t=e.replace(/[^\d.]/g,""),a=t.indexOf(".");return a===-1?t:t.slice(0,a+1)+t.slice(a+1).replace(/\./g,"")}function Qa(e){return{provider:e.provider,modelId:e.modelId}}function I7(e){const{editing:t,ref:a,action:l,defaultModel:o,visionModel:c}=e,u=t===null,f=!u&&!jt(t,a)?t:null,p=h=>jt(h,f)?a:h;return{defaultModel:l==="setDefault"||u&&!o?a:p(o),visionModel:l==="setVisionModel"?a:p(c)}}function L7(e){return e.original!==null&&_g(e.original.provider,e.original.modelId)!==void 0}function O7(e){return!e.clearApiKey&&(!!e.apiKeyInput.trim()||!!e.credential?.apiKeyMasked)}function ek(e){const t={provider:e.provider,modelId:e.modelId,original:{provider:e.provider,modelId:e.modelId},vision:e.vision!==!1,contextWindow:e.contextWindow!==void 0?String(e.contextWindow):"",maxTokens:e.maxTokens!==void 0?String(e.maxTokens):"",clientType:e.clientType??"",cacheRead:e.pricing?String(e.pricing.cacheRead):"",cacheWrite:e.pricing?String(e.pricing.cacheWrite):"",output:e.pricing?String(e.pricing.output):"",baseUrl:e.credential?.baseUrl??"",originalBaseUrl:e.credential?.baseUrl??"",apiKeyInput:"",clearApiKey:!1};return e.displayName!==void 0&&(t.displayName=e.displayName),e.envKey!==void 0&&(t.envKey=e.envKey),e.credential&&(t.credential=e.credential),t}function D7(e){const t={provider:e.provider,modelId:e.modelId};e.original&&!jt(e.original,Qa(e))&&(t.renamedFrom=e.original),e.displayName?.trim()&&(t.displayName=e.displayName.trim());const a=Number(e.contextWindow.trim());e.contextWindow.trim()&&Number.isFinite(a)&&(t.contextWindow=a),e.clientType.trim()&&(t.clientType=e.clientType.trim()),e.vision||(t.vision=!1);const l=Number(e.maxTokens.trim());e.maxTokens.trim()&&Number.isFinite(l)&&l>0&&(t.maxTokens=l);const o=Number(e.cacheRead.trim()),c=Number(e.cacheWrite.trim()),u=Number(e.output.trim());e.cacheRead.trim()&&e.cacheWrite.trim()&&e.output.trim()&&Number.isFinite(o)&&Number.isFinite(c)&&Number.isFinite(u)&&(t.pricing={cacheRead:o,cacheWrite:c,output:u}),e.apiKeyInput.trim()&&(t.apiKey=e.apiKeyInput.trim()),e.clearApiKey&&(t.clearApiKey=!0);const f=e.baseUrl.trim();return f!==e.originalBaseUrl&&(t.baseUrl=f||null),t}function z7(){Er(m.models.title);const{currentProject:e}=Xt(),t=e?.projectId??null,a=e?.role==="owner",l=xn().user?.userId??null,[o,c]=y.useState(new Map),[u,f]=y.useState(null),[p,h]=y.useState(null),[g,v]=y.useState(null),[k,w]=y.useState(void 0),[j,E]=y.useState(void 0),[C,M]=y.useState(null),[_,D]=y.useState(null),[V,F]=y.useState(""),[A,P]=y.useState(()=>Y1(t));y.useEffect(()=>{P(Y1(t))},[t]);const[Q,K]=y.useState(null),[O,z]=y.useState(!1),[I,B]=y.useState(""),[$,G]=y.useState(null),[q,ae]=y.useState(null),[Z,X]=y.useState(!1),{currency:T}=Ps(),R=y.useCallback(async()=>{if(t){v(null),ae(null),c(new Map);try{const te=await mi(t);v(te.models.map(ek)),w(te.defaultModel),E(te.visionModel)}catch(te){ae(Ie(te))}}},[t]);y.useEffect(()=>{R()},[R]);const H=async(te,be,Re,Fe)=>{if(!t)return!1;X(!0);const ce=Re&&te.some(Ve=>jt(Qa(Ve),Re)&&Ve.vision)?Re:void 0;try{const Ve={models:te.map(D7)};be&&(Ve.defaultModel=be),ce&&(Ve.visionModel=ce);const je=await YC(t,Ve);return v(je.models.map(ek)),w(je.defaultModel),E(je.visionModel),l&&je.defaultModel&&!jt(je.defaultModel,k)&&AS(l,t),Et(Fe??m.common.saved),!0}catch(Ve){return v(te),be!==void 0&&w(be),ce!==void 0&&E(ce),Qe(Ie(Ve)),!1}finally{X(!1)}},S=y.useMemo(()=>g?pS(g,V):[],[g,V]),U=V.trim()!=="",ee=async()=>{if(!g)return;const te=j7(g);if(te.added===0&&te.updated===0){Mr(m.models.syncUpToDate);return}await H(te.rows,k,j,m.models.syncDone(te.added,te.updated))},ie=async te=>{if(!t||!g)return;const be=g.filter(Re=>Re.provider===te);h(te);try{for(const Re of be){const Fe=Z1(Re.provider,Re.modelId);c(ce=>new Map(ce).set(Fe,"pending"));try{const ce=await Ak(t,{provider:Re.provider,modelId:Re.modelId,speed:!0});c(Ve=>new Map(Ve).set(Fe,ce))}catch(ce){c(Ve=>new Map(Ve).set(Fe,{ok:!1,message:Ie(ce)}))}}}finally{h(null)}},de=()=>{const te=I.trim();if(!/^[a-z0-9][a-z0-9_-]{0,31}$/.test(te)){G(m.models.groupNameInvalid);return}if($s.some(be=>be.id===te)||g?.some(be=>be.provider===te)){G(m.models.groupNameExists);return}z(!1),B(""),D(te)},me=C!==null?g?.find(te=>jt(Qa(te),C)):void 0;if(!t)return null;const ye=te=>{if(U)return;const be=v7(A,te);P(be),w7(t,be)};return s.jsxs("div",{className:"h-full overflow-y-auto p-4 md:p-6",children:[s.jsxs("div",{className:"mx-auto max-w-5xl",children:[s.jsxs("div",{className:"mb-4 flex flex-wrap items-center justify-between gap-2",children:[s.jsxs("div",{children:[s.jsx("h1",{className:"text-xl font-semibold",children:m.models.title}),!a&&s.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:m.models.readOnlyHint})]}),s.jsxs("div",{className:"flex min-w-0 max-w-full grow items-center gap-2 sm:grow-0",children:[s.jsx("div",{className:"min-w-0 flex-1 sm:w-56 sm:flex-none",children:s.jsx(at,{size:"sm",value:V,onChange:te=>F(te.target.value),placeholder:m.models.searchPlaceholder})}),a&&s.jsx(we,{size:"sm",onClick:()=>{ee()},disabled:Z||g===null,title:m.models.syncCatalogHint,children:m.models.syncCatalog})]})]}),g===null?s.jsx(pa,{rows:4}):g.length===0?s.jsx(Nr,{title:m.models.empty,action:a&&s.jsx(we,{onClick:()=>D("custom"),children:m.models.addCustom})}):S.length===0?s.jsx(Nr,{title:m.models.noSearchResults}):s.jsxs("div",{className:"space-y-3",children:[S.map(te=>{const be=y7(A,te.provider.id,U);return s.jsxs("section",{className:"overflow-hidden rounded-md border border-gray-200 bg-white dark:border-gray-800 dark:bg-gray-900",children:[s.jsxs("div",{className:"flex items-center gap-2 bg-gray-50 pr-2 transition-colors duration-150 hover:bg-gray-100 dark:bg-gray-900/60 dark:hover:bg-gray-800/60",children:[s.jsxs("button",{type:"button","aria-expanded":be,onClick:()=>ye(te.provider.id),className:"flex min-w-0 flex-1 items-center gap-2.5 px-3 py-2.5 text-left",children:[s.jsx(xi,{provider:te.provider.id,className:"h-5 w-5 shrink-0 text-gray-700 dark:text-gray-300"}),s.jsx("span",{className:"min-w-0 truncate text-sm font-semibold",children:te.provider.label}),s.jsx("span",{className:"shrink-0 whitespace-nowrap font-mono text-xs text-gray-400",children:m.models.modelCount(te.rows.length)})]}),a&&s.jsx("span",{className:"shrink-0",children:s.jsxs(we,{size:"sm",variant:"ghost",disabled:Z,onClick:()=>D(te.provider.id),children:[s.jsx(qe,{d:T7,size:13}),m.models.addToGroup]})}),a&&te.provider.id!=="custom"&&s.jsx("span",{className:"hidden shrink-0 sm:block",children:s.jsxs(we,{size:"sm",variant:"ghost",disabled:Z,onClick:()=>K(te.provider.id),children:[s.jsx(qe,{d:M7,size:13}),m.models.groupApiKey]})}),a&&s.jsxs(we,{size:"sm",variant:"ghost",className:"shrink-0",disabled:Z||p!==null,"aria-label":`${m.models.speedTest} ${te.provider.label}`,title:p===te.provider.id?m.models.speedPending:m.models.speedTest,onClick:()=>f(te.provider.id),children:[s.jsx(qe,{d:E7,size:13}),s.jsx("span",{className:"hidden sm:inline",children:p===te.provider.id?m.models.speedPending:m.models.speedTest})]}),te.provider.apiKeyUrl&&s.jsxs("a",{href:te.provider.apiKeyUrl,target:"_blank",rel:"noreferrer noopener",className:"hidden shrink-0 whitespace-nowrap text-xs text-brand-600 underline-offset-2 hover:underline sm:inline dark:text-brand-300",children:[m.models.getApiKey," ↗"]}),s.jsx("button",{type:"button","aria-expanded":be,"aria-label":te.provider.label,onClick:()=>ye(te.provider.id),className:"shrink-0 p-1.5",children:s.jsx($n,{open:be,className:"text-gray-400"})})]}),s.jsx("div",{className:`grid transition-[grid-template-rows] duration-200 ease-out ${be?"grid-rows-[1fr]":"grid-rows-[0fr]"}`,children:s.jsx("div",{className:"overflow-hidden",inert:!be,children:s.jsx("div",{className:`grid gap-2 border-t border-gray-200 p-2.5 transition-opacity duration-200 sm:grid-cols-2 lg:grid-cols-3 dark:border-gray-800 ${be?"opacity-100":"opacity-0"}`,children:te.rows.length===0?s.jsx("p",{className:"col-span-full py-1 text-center text-xs text-gray-400 dark:text-gray-500",children:m.models.groupEmptyHint}):te.rows.map(Re=>s.jsx(U7,{row:Re,currency:T,isDefault:jt(Qa(Re),k),isVisionModel:jt(Qa(Re),j),speed:o.get(Z1(Re.provider,Re.modelId)),onOpen:()=>M(Qa(Re))},`${Re.provider}:${Re.modelId}`))})})})]},te.provider.id)}),a&&V.trim()===""&&s.jsxs("button",{type:"button",onClick:()=>{B(""),G(null),z(!0)},className:"w-full rounded-md border border-dashed border-gray-300 px-3 py-2.5 text-sm text-gray-500 transition-colors hover:border-gray-400 hover:text-gray-700 dark:border-gray-700 dark:text-gray-400 dark:hover:border-gray-600 dark:hover:text-gray-200",children:["+ ",m.models.addGroup]})]}),q&&s.jsx("p",{className:"mt-3 text-xs text-red-600 dark:text-red-400",children:q})]}),g&&Q&&s.jsx(H7,{provider:$s.find(te=>te.id===Q)??fS(Q),count:g.filter(te=>te.provider===Q).length,onClose:()=>K(null),onSubmit:te=>{const be=Q;K(null);const Re=g.filter(ce=>ce.provider===be);if(Re.length===0)return;const Fe=g.map(ce=>ce.provider===be?{...ce,apiKeyInput:te,clearApiKey:!1}:ce);H(Fe,k,j,m.models.groupKeyApplied(Re.length))}}),u!==null&&s.jsxs(Gt,{open:!0,title:m.models.speedTestTitle,onClose:()=>f(null),children:[s.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-300",children:m.models.speedTestConfirm(g?.filter(te=>te.provider===u).length??0)}),s.jsxs("div",{className:"mt-4 flex justify-end gap-2",children:[s.jsx(we,{onClick:()=>f(null),children:m.common.cancel}),s.jsx(we,{variant:"primary",onClick:()=>{const te=u;f(null),te&&ie(te)},children:m.models.speedTestStart})]})]}),O&&s.jsxs(Gt,{open:!0,title:m.models.addGroupTitle,onClose:()=>z(!1),widthClass:"sm:max-w-sm",footer:s.jsxs(s.Fragment,{children:[s.jsx(we,{onClick:()=>z(!1),children:m.common.cancel}),s.jsx(we,{variant:"primary",onClick:de,children:m.common.confirm})]}),children:[s.jsxs("label",{className:"block",children:[s.jsx(at,{size:"sm",label:m.models.groupNameLabel,required:!0,value:I,invalid:!!$,onChange:te=>{B(te.target.value),G(null)},onKeyDown:te=>{te.key==="Enter"&&de()},placeholder:m.models.groupNameHint,className:"font-mono",autoFocus:!0}),$&&s.jsx(Sr,{children:$})]}),s.jsx("p",{className:"mt-2 text-xs text-gray-500 dark:text-gray-400",children:m.models.addGroupDesc})]}),g&&(_!==null||me)&&s.jsx(B7,{projectId:t,row:_!==null?null:me??null,addProvider:_??"custom",existingRefs:g.map(Qa),currency:T,canEdit:a,isDefault:me!==void 0&&jt(Qa(me),k),isVisionModel:me!==void 0&&jt(Qa(me),j),onClose:()=>{M(null),D(null)},onSubmit:(te,be)=>{const Re=_!==null;if(M(null),D(null),be==="remove"){const Ve=te.original;H(g.filter(je=>!jt(Qa(je),Ve)),jt(Ve,k)?void 0:k,jt(Ve,j)?void 0:j);return}const Fe=Re?[...g,te]:g.map(Ve=>jt(Qa(Ve),C)?te:Ve),ce=I7({editing:Re?null:C,ref:Qa(te),action:be,defaultModel:k,visionModel:j});H(Fe,ce.defaultModel,ce.visionModel)}})]})}function U7({row:e,currency:t,isDefault:a,isVisionModel:l,speed:o,onOpen:c}){const u=e.cacheRead||e.cacheWrite||e.output,f=[e.contextWindow?Ct(Number(e.contextWindow)):null,u?`${Dp(e.cacheRead,t)} / ${Dp(e.cacheWrite,t)} / ${Dp(e.output,t)}`:null,e.credential?.apiKeyMasked&&!e.clearApiKey?e.credential.apiKeyMasked:O7(e)?m.models.keyConfigured:m.models.noKey].filter(h=>h!==null),p=o==="pending"?s.jsx("span",{className:"shrink-0 text-[11px] text-gray-400",children:m.models.speedPending}):o?o.ok?s.jsxs("span",{className:"flex shrink-0 items-center gap-1.5 text-[11px] font-medium",children:[o.ttftMs!==void 0&&s.jsxs("span",{className:`flex items-center gap-0.5 ${X1[C7(o.ttftMs)]}`,title:m.models.ttftTitle,children:[s.jsx(qe,{d:A7,size:11}),Math.round(o.ttftMs),"ms"]}),o.tps!==void 0&&s.jsxs("span",{className:`flex items-center gap-0.5 ${X1[N7(o.tps)]}`,title:m.models.tpsTitle,children:[s.jsx(qe,{d:R7,size:11}),o.tps," tok/s"]})]}):s.jsx("span",{className:"shrink-0 text-[11px] font-medium text-red-600 dark:text-red-400",title:o.message,children:m.models.speedFailed}):null;return s.jsxs("button",{type:"button",onClick:c,className:"flex w-full flex-col gap-0.5 rounded-md border border-gray-200 px-3 py-2.5 text-left transition-colors duration-150 hover:border-gray-300 hover:bg-gray-50 dark:border-gray-800 dark:hover:border-gray-700 dark:hover:bg-gray-800/40",children:[s.jsxs("span",{className:"flex flex-wrap items-center gap-1.5",children:[s.jsx("span",{className:"text-sm font-medium",children:e.displayName??e.modelId}),a&&s.jsx(gn,{tone:"brand",children:m.models.default}),hS(e)&&s.jsx(gn,{tone:"yellow",children:m.models.freeBadge}),e.vision&&s.jsx(gn,{tone:"green",children:m.models.visionBadge}),l&&s.jsx(gn,{tone:"amber",children:m.models.visionModelBadge})]}),e.displayName!==void 0&&s.jsx("span",{className:"truncate font-mono text-[11px] text-gray-500 dark:text-gray-400",children:e.modelId}),s.jsxs("span",{className:"flex w-full items-center gap-1.5",children:[s.jsx("span",{className:"min-w-0 flex-1 truncate text-[11px] text-gray-400 dark:text-gray-500",children:f.join(" · ")}),p]})]})}const $7={save:()=>m.models.confirmSaveTitle,setDefault:()=>m.models.confirmDefaultTitle,setVisionModel:()=>m.models.confirmVisionModelTitle,remove:()=>m.models.confirmDeleteTitle},P7={save:e=>m.models.confirmSave(e),setDefault:e=>m.models.confirmDefault(e),setVisionModel:e=>m.models.confirmVisionModel(e),remove:e=>m.models.confirmDelete(e)};function B7({projectId:e,row:t,addProvider:a,existingRefs:l,currency:o,canEdit:c,isDefault:u,isVisionModel:f,onClose:p,onSubmit:h}){const[g,v]=y.useState(()=>{if(t)return{...t,cacheRead:ii(t.cacheRead,o),cacheWrite:ii(t.cacheWrite,o),output:ii(t.output,o)};const Z=Os(a),X=Z!==void 0&&Z.id!=="custom"&&Z.gatewayBaseUrl===void 0;return{provider:a,modelId:"",original:null,vision:!0,contextWindow:"",maxTokens:"",clientType:X?"":"openai",cacheRead:"",cacheWrite:"",output:"",baseUrl:Z?.gatewayBaseUrl??"",originalBaseUrl:"",apiKeyInput:"",clearApiKey:!1}}),[k,w]=y.useState({}),[j,E]=y.useState(!1),[C,M]=y.useState(null),_=t===null,D=t!==null&&L7(t),V=Z=>{v(X=>({...X,...Z})),w(X=>{const T={...X};for(const R of Object.keys(Z))delete T[R];return T})},F=async()=>{E(!0);try{const Z=g.apiKeyInput.trim(),X=g.baseUrl.trim(),T={provider:g.provider,modelId:g.modelId.trim(),baseUrl:X||null};Z?T.apiKey=Z:g.clearApiKey&&(T.clearApiKey=!0),g.clientType.trim()&&(T.clientType=g.clientType.trim());const R=await Ak(e,T);R.ok?Et(m.models.testOk(R.latencyMs??0)):Qe(m.models.testFailed(R.message??""))}catch(Z){Qe(m.models.testFailed(Ie(Z)))}finally{E(!1)}},A=g.clientType.trim().toLowerCase().includes("openai")||g.provider==="custom"||Os(g.provider)===void 0,P=!D&&A,Q=x7(g.provider,g.clientType),K=()=>{const Z=g.modelId.trim(),X={provider:g.provider,modelId:Z},T=g.baseUrl.trim(),R={};Z?!jt(X,g.original)&&l.some(ie=>jt(ie,X))&&(R.modelId=m.models.modelIdExists):R.modelId=m.common.requiredField,P&&!T&&(R.baseUrl=m.models.baseUrlRequired);const H=[["cacheRead",g.cacheRead.trim()],["cacheWrite",g.cacheWrite.trim()],["output",g.output.trim()]],S=H.filter(([,ie])=>ie!=="").length;for(const[ie,de]of H)de===""&&S>0?R[ie]=m.models.pricingAllOrNone:de!==""&&!Number.isFinite(Number(de))&&(R[ie]=m.models.pricingInvalid);const U=g.contextWindow.trim();U&&!Number.isFinite(Number(U))&&(R.contextWindow=m.models.contextWindowInvalid);const ee=g.maxTokens.trim();return ee&&!(Number.isInteger(Number(ee))&&Number(ee)>0)&&(R.maxTokens=m.models.maxTokensInvalid),Object.keys(R).length>0?(w(R),null):(w({}),{...g,modelId:Z,contextWindow:!D&&!U?String(Up):g.contextWindow,cacheRead:zp(g.cacheRead,o),cacheWrite:zp(g.cacheWrite,o),output:zp(g.output,o)})},O=Z=>{const X=K();X&&h(X,Z)},z=Os(g.provider),I=z8(g.modelId.trim(),g.clientType.trim()||void 0)?.envKey,B=z!==void 0&&z.id!=="custom"&&z.gatewayBaseUrl===void 0,$=_&&B&&!g.clientType.trim()&&g.modelId.trim()!==""&&I===void 0,G=s.jsxs(s.Fragment,{children:[s.jsxs("label",{className:"block",children:[s.jsxs("span",{className:"mb-1 flex items-baseline justify-between gap-2",children:[s.jsxs("span",{className:"text-xs font-semibold text-gray-600 dark:text-gray-400",children:[m.models.modelId,s.jsx("span",{className:"ml-0.5 text-red-500 dark:text-red-400","aria-hidden":!0,children:"*"})]}),s.jsx("span",{className:"flex shrink-0 items-baseline gap-2.5",children:z?.modelsUrl&&s.jsxs("a",{href:z.modelsUrl,target:"_blank",rel:"noreferrer noopener",className:"shrink-0 text-xs text-brand-600 underline-offset-2 hover:underline dark:text-brand-300",children:[m.models.getModelIds," ↗"]})})]}),s.jsx(at,{size:"sm",required:!0,value:g.modelId,disabled:!c,invalid:!!k.modelId,onChange:Z=>V({modelId:Z.target.value}),className:"font-mono",autoFocus:_,placeholder:m.models.modelIdHint}),k.modelId&&s.jsx(Sr,{children:k.modelId}),$&&s.jsx("span",{className:"mt-1 block text-xs text-amber-600 dark:text-amber-400",children:m.models.autoRouteNone})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[s.jsx(at,{size:"sm",label:m.models.displayName,value:g.displayName??"",disabled:!c,onChange:Z=>V({displayName:Z.target.value}),placeholder:m.models.displayNameHint}),s.jsxs(Ds,{size:"sm",label:m.models.providerGroup,value:g.provider,disabled:!c,onChange:Z=>V({provider:Z.target.value}),children:[$s.map(Z=>s.jsx("option",{value:Z.id,children:Z.label},Z.id)),[...new Set(l.map(Z=>Z.provider).concat(g.provider))].filter(Z=>!$s.some(X=>X.id===Z)).sort().map(Z=>s.jsx("option",{value:Z,children:Z},Z))]})]})]}),q=g.credential?.apiKeyMasked?m.models.apiKeyKeepHint:I?m.models.apiKeyEnvHint(I):m.models.apiKeyKeepHint,ae=!g.credential?.apiKeyMasked&&I&&I===z?.envKey?m.models.providerEnvNotes[g.provider]:void 0;return s.jsxs(Gt,{open:!0,title:_?B?m.models.addTitleVendor:m.models.addTitle:m.models.editTitle,onClose:p,widthClass:"sm:max-w-lg",footer:s.jsxs(s.Fragment,{children:[s.jsx(we,{onClick:p,children:m.common.cancel}),c&&s.jsx(we,{variant:"primary",onClick:()=>{if(!K())return;if(_||t===null){O("save");return}const Z={...t,cacheRead:ii(t.cacheRead,o),cacheWrite:ii(t.cacheWrite,o),output:ii(t.output,o)};if(JSON.stringify(g)===JSON.stringify(Z)){Mr(m.common.noChangesToSave);return}M("save")},children:m.common.confirm})]}),children:[s.jsxs("div",{className:"space-y-3",children:[!_&&s.jsxs("div",{className:"flex items-center gap-2.5 rounded-md bg-gray-50 px-3 py-2 dark:bg-gray-800/60",children:[s.jsx(xi,{provider:g.provider,className:"h-6 w-6 shrink-0 text-gray-700 dark:text-gray-300"}),s.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[s.jsxs("span",{className:"flex flex-wrap items-center gap-1.5 text-sm font-medium",children:[g.displayName??g.modelId,u&&s.jsx(gn,{tone:"brand",children:m.models.default}),g.vision&&s.jsx(gn,{tone:"green",children:m.models.visionBadge}),f&&s.jsx(gn,{tone:"amber",children:m.models.visionModelBadge})]}),g.displayName!==void 0&&s.jsx("span",{className:"truncate font-mono text-xs text-gray-500 dark:text-gray-400",children:g.modelId})]}),t&&a1(t.provider,t.modelId)&&s.jsxs("a",{href:a1(t.provider,t.modelId),target:"_blank",rel:"noreferrer noopener",className:"inline-flex shrink-0 items-center gap-1 rounded-md border border-gray-300 bg-white px-2.5 py-1 text-xs font-medium text-gray-800 transition-colors duration-150 hover:bg-gray-50 dark:border-gray-700 dark:bg-gray-900 dark:text-gray-200 dark:hover:bg-gray-800",children:[m.models.homepage,s.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,className:"shrink-0",children:s.jsx("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6M15 3h6v6M10 14 21 3"})})]})]}),_&&s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:B&&z?m.models.vendorProtocolHint(z.label):m.models.addProtocolHint}),G]}),c&&s.jsx("div",{className:"space-y-1.5",children:s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsx(we,{size:"sm",disabled:j||!g.modelId.trim(),onClick:()=>{F()},children:j?m.models.testing:m.models.testConnection}),!_&&!u&&s.jsx(we,{size:"sm",onClick:()=>M("setDefault"),children:m.models.setDefault}),!_&&g.vision&&!f&&s.jsx(we,{size:"sm",title:m.models.visionModelHint,onClick:()=>M("setVisionModel"),children:m.models.setVisionModel}),!_&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"min-w-0 flex-1"}),s.jsx(we,{size:"sm",variant:"danger",onClick:()=>M("remove"),children:m.models.remove})]})]})}),s.jsxs("div",{className:"block",children:[s.jsxs("span",{className:"mb-1 flex items-baseline justify-between gap-2",children:[s.jsx("span",{className:"text-xs font-semibold text-gray-600 dark:text-gray-400",children:m.models.apiKey}),z?.apiKeyUrl&&s.jsxs("a",{href:z.apiKeyUrl,target:"_blank",rel:"noreferrer noopener",className:"shrink-0 text-xs text-brand-600 underline-offset-2 hover:underline dark:text-brand-300",children:[m.models.getApiKey," ↗"]})]}),s.jsx(zs,{size:"sm",value:g.apiKeyInput,disabled:!c,onChange:Z=>V({apiKeyInput:Z.target.value,clearApiKey:!1}),className:"font-mono",autoComplete:"off",autoFocus:!_,placeholder:q})]}),ae&&s.jsx("p",{className:"text-xs text-gray-400 dark:text-gray-500",children:ae}),g.credential?.apiKeyMasked&&!g.apiKeyInput&&s.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-gray-500 dark:text-gray-400",children:[s.jsx("span",{className:"font-mono",children:g.credential.apiKeyMasked}),g.credential.createdAt&&s.jsxs("span",{className:"text-gray-400",children:[m.common.created," ",ha(g.credential.createdAt)]}),c&&s.jsxs("label",{className:"flex items-center gap-1.5",children:[s.jsx("input",{type:"checkbox",checked:g.clearApiKey,onChange:Z=>V({clearApiKey:Z.target.checked})}),m.models.clearApiKey]})]}),s.jsxs("label",{className:"block",children:[s.jsx(er,{required:P,children:m.models.baseUrl}),s.jsxs("span",{className:"relative block",children:[s.jsx(at,{size:"sm",required:P,value:g.baseUrl,disabled:!c,invalid:!!k.baseUrl,onChange:Z=>V({baseUrl:Z.target.value}),className:"font-mono",style:{paddingRight:`calc(${Q.length}ch + 1.25rem)`},title:m.models.baseUrlSuffixTitle,placeholder:D?m.models.baseUrlHint:"https://…"}),s.jsx("span",{className:"pointer-events-none absolute inset-y-0 right-2 flex items-center font-mono text-xs text-gray-400",children:Q})]}),k.baseUrl&&s.jsx(Sr,{children:k.baseUrl})]}),s.jsxs("div",{className:"grid grid-cols-2 items-start gap-2",children:[s.jsxs("label",{className:"block",children:[s.jsx(er,{children:m.models.contextWindow}),s.jsxs("span",{className:"relative block",children:[s.jsx(at,{size:"sm",value:g.contextWindow,inputMode:"numeric",disabled:!c,invalid:!!k.contextWindow,onChange:Z=>V({contextWindow:J1(Z.target.value)}),className:"pr-12 font-mono",title:D?m.models.contextWindowHint:m.models.contextWindowDefaultHint(Up),placeholder:D?m.models.contextWindowHint:m.models.contextWindowDefaultHint(Up)}),s.jsx("span",{className:"pointer-events-none absolute inset-y-0 right-2 flex items-center text-xs text-gray-400",children:m.models.tokenUnit})]}),k.contextWindow&&s.jsx(Sr,{children:k.contextWindow})]}),s.jsxs("label",{className:"block",children:[s.jsx(er,{children:m.models.maxTokens}),s.jsxs("span",{className:"relative block",children:[s.jsx(at,{size:"sm",value:g.maxTokens,inputMode:"numeric",disabled:!c,invalid:!!k.maxTokens,onChange:Z=>V({maxTokens:J1(Z.target.value)}),className:"pr-12 font-mono",title:m.models.maxTokensTitle,placeholder:m.models.maxTokensHint}),s.jsx("span",{className:"pointer-events-none absolute inset-y-0 right-2 flex items-center text-xs text-gray-400",children:m.models.tokenUnit})]}),k.maxTokens&&s.jsx(Sr,{children:k.maxTokens})]})]}),s.jsx("div",{className:"grid grid-cols-3 items-start gap-2",children:[["cacheRead",m.models.priceCacheRead,g.cacheRead],["cacheWrite",m.models.priceCacheWrite,g.cacheWrite],["output",m.models.priceOutput,g.output]].map(([Z,X,T])=>s.jsxs("label",{className:"block",children:[s.jsx(er,{children:X}),s.jsxs("span",{className:"relative block",children:[s.jsx("span",{className:"pointer-events-none absolute inset-y-0 left-2 flex items-center text-xs text-gray-400",children:VS[o]}),s.jsx(at,{size:"sm",value:T,inputMode:"decimal",disabled:!c,invalid:!!k[Z],onChange:R=>V({[Z]:_7(R.target.value)}),className:"pl-4 pr-11 text-right font-mono"}),s.jsx("span",{className:"pointer-events-none absolute inset-y-0 right-2 flex items-center text-xs text-gray-400",children:m.models.priceUnitShort})]}),k[Z]&&s.jsx(Sr,{children:k[Z]})]},Z))}),!_&&G,!_&&!D&&g.clientType&&g.clientType!=="openai"&&s.jsx("p",{className:"text-xs text-gray-400 dark:text-gray-500",children:m.models.clientTypeLocked(g.clientType)}),!D&&s.jsxs("div",{children:[s.jsxs("label",{className:`inline-flex items-center gap-2 ${c?"cursor-pointer":"cursor-not-allowed"}`,children:[s.jsx("span",{className:"text-xs font-semibold text-gray-600 dark:text-gray-400",children:m.models.vision}),s.jsx(wl,{checked:g.vision,disabled:!c,onChange:Z=>V({vision:Z}),"aria-label":m.models.vision})]}),!g.vision&&s.jsx("p",{className:"mt-1 text-xs text-gray-400 dark:text-gray-500",children:m.models.visionOffProxyHint})]})]}),C&&s.jsx(Mn,{open:!0,title:$7[C](),tone:C==="remove"?"danger":"primary",onClose:()=>M(null),onConfirm:()=>{const Z=C;M(null),O(Z)},children:s.jsx("p",{className:"text-sm text-gray-700 dark:text-gray-300",children:P7[C](g.displayName??g.modelId)})})]})}function H7({provider:e,count:t,onClose:a,onSubmit:l}){const[o,c]=y.useState("");return s.jsx(Gt,{open:!0,title:m.models.groupApiKeyTitle(e.label),onClose:a,footer:s.jsxs(s.Fragment,{children:[s.jsx(we,{onClick:a,children:m.common.cancel}),s.jsx(we,{variant:"primary",disabled:!o.trim(),onClick:()=>l(o.trim()),children:m.common.confirm})]}),children:s.jsxs("div",{className:"space-y-2",children:[s.jsx(at,{size:"sm",label:m.models.apiKey,required:!0,type:"password",value:o,onChange:u=>c(u.target.value),className:"font-mono",autoComplete:"off",autoFocus:!0,placeholder:m.models.apiKeyEnvHint(e.envKey)}),s.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:m.models.groupApiKeyHint(t)}),m.models.providerEnvNotes[e.id]&&s.jsx("p",{className:"text-xs text-gray-400 dark:text-gray-500",children:m.models.providerEnvNotes[e.id]}),e.apiKeyUrl&&s.jsxs("a",{href:e.apiKeyUrl,target:"_blank",rel:"noreferrer noopener",className:"inline-block text-xs text-brand-600 underline-offset-2 hover:underline dark:text-brand-300",children:[m.models.getApiKey," ↗"]})]})})}const Do=200,bl=46,kd=8,qo=10,F7=22;function GS(e,t,a){return WS(e,0,t,a)}function WS(e,t,a,l){const o=Math.max(0,l-bl-kd),c=Do-qo-F7,u=e>0?o/e:o,f=a-t;return{n:e,min:t,max:a,w:l,innerW:o,innerH:c,step:u,x:p=>bl+u*p+u/2,y:p=>qo+c*(1-(f>0?(p-t)/f:0))}}function q7(e,t){return t.map((a,l)=>`${l===0?"M":"L"}${e.x(l)},${e.y(a)}`).join(" ")}function V7(e,t){const a=t.length;if(a===0)return"";const l=e.y(0),o=[];for(let c=0;c<a;c++)o.push(`${c===0?"M":"L"}${e.x(c)},${e.y(t[c])}`);return o.push(`L${e.x(a-1)},${l}`),o.push(`L${e.x(0)},${l}`),o.push("Z"),o.join(" ")}function G7(e){return e<=0?[]:e===1?[0]:e===2?[0,1]:[0,Math.floor((e-1)/2),e-1]}const W7=40;function K7(e,t){if(e<=0)return[];const a=t>0?Math.max(1,Math.ceil(W7/t)):e,l=[];for(let o=0;o<e;o+=a)l.push(o);return l}function Y7(e,t){return t>0?e/t:1}const Hu=12;function Q7(e,t,a,l,o){let c=e+Hu;c+a>o.right&&(c=e-Hu-a);let u=t+Hu;return u+l>o.bottom&&(u=t-Hu-l),{left:Math.max(o.left,Math.min(c,o.right-a)),top:Math.max(0,Math.min(u,o.bottom-l))}}const $p=25,X7=8;function Z7(e,t){const a=Math.max(0,e-bl-kd),l=2*$p*t;return l<=a?{barW:$p,chartW:e,scroll:!1}:{barW:$p,chartW:bl+l+kd,scroll:!0}}function J7(e,t,a){const l=e.length;if(l===0)return[];if(t<=l*a)return e.map(()=>t/l);const o=new Set;for(;;){const c=t-o.size*a,u=e.reduce((h,g,v)=>o.has(v)?h:h+g,0),f=h=>u>0?e[h]/u*c:c/(l-o.size),p=e.findIndex((h,g)=>!o.has(g)&&f(g)<a);if(p<0)return e.map((h,g)=>o.has(g)?a:f(g));o.add(p)}}const e9=["output","cacheWrite","cacheRead"];function t9(e,t){const a=e9.map(p=>({key:p,value:t[p]})).filter(p=>p.value>0);if(a.length===0)return[];const l=[];let o=0;for(const p of a){const h=e.y(o);o+=p.value;const g=e.y(o);l.push({y:g,h:h-g})}const c=e.y(0),u=J7(l.map(p=>p.h),c-e.y(o),X7);let f=c;return a.map((p,h)=>{const g=u[h],v={key:p.key,value:p.value,y:l[h].y,h:l[h].h,hitY:f-g,hitH:g};return f-=g,v})}const KS=Math.PI*2,wd=e=>Math.round(e*100)/100;function Fu(e,t,a,l){const o=l-Math.PI/2;return[wd(e+a*Math.cos(o)),wd(t+a*Math.sin(o))]}function n9(e,t,a,l,o){if(o-l>=KS-1e-9){const[g,v]=Fu(e,t,a,0),[k,w]=Fu(e,t,a,Math.PI);return`M${g},${v} A${a},${a} 0 1 1 ${k},${w} A${a},${a} 0 1 1 ${g},${v} Z`}const[c,u]=Fu(e,t,a,l),[f,p]=Fu(e,t,a,o),h=o-l>Math.PI?1:0;return`M${wd(e)},${wd(t)} L${c},${u} A${a},${a} 0 ${h} 1 ${f},${p} Z`}function a9(e,t,a,l){const o=e.reduce((f,p)=>f+Math.max(0,p),0);if(o<=0)return[];const c=[];let u=0;return e.forEach((f,p)=>{if(f<=0)return;const h=f/o,g=u+h*KS;c.push({index:p,value:f,frac:h,start:u,end:g,path:n9(t,a,l,u,g)}),u=g}),c}function Hg(){const e=y.useRef(null),[t,a]=y.useState(0);return y.useLayoutEffect(()=>{const l=e.current;if(!l)return;const o=()=>a(Math.floor(l.getBoundingClientRect().width));o();const c=new ResizeObserver(o);return c.observe(l),()=>c.disconnect()},[]),[e,t]}function Fg({geom:e,fmtY:t,dates:a,hover:l,onHover:o,bubble:c,hitLayer:u,labels:f,yTicks:p,hoverLine:h=!0,scrollToEnd:g=!1,children:v}){const{x:k,y:w,w:j,innerH:E,step:C,min:M,max:_}=e,D=p??[0,.25,.5,.75,1].map(I=>M+(_-M)*I),V=f??G7(a.length),F=y.useRef(null);y.useLayoutEffect(()=>{const I=F.current;!g||!I||(I.scrollLeft=I.scrollWidth-I.clientWidth)},[g,j,a.length]);const A=y.useRef(null),P=y.useRef(null),Q=y.useRef(null),K=y.useRef(0),O=()=>{const I=P.current,B=A.current,$=F.current,G=Q.current;if(!I||!B||!$||!G)return;const q=B.getBoundingClientRect(),ae=Q7(G.cx-q.left,G.cy-q.top,I.offsetWidth,I.offsetHeight,{left:$.scrollLeft,right:$.scrollLeft+$.clientWidth,bottom:Do});I.style.left=`${ae.left}px`,I.style.top=`${ae.top}px`,I.style.visibility="visible"},z=()=>{K.current||(K.current=requestAnimationFrame(()=>{K.current=0,O()}))};return y.useEffect(()=>()=>cancelAnimationFrame(K.current),[]),y.useLayoutEffect(O,[c,l]),s.jsxs("div",{ref:F,className:"relative overflow-x-auto",children:[s.jsxs("svg",{ref:A,viewBox:`0 0 ${j} ${Do}`,width:j,height:Do,className:"text-gray-600 dark:text-gray-400",role:"img",onMouseLeave:()=>{o(null),Q.current=null},onMouseMove:I=>{Q.current={cx:I.clientX,cy:I.clientY},z()},children:[D.map((I,B)=>s.jsxs("g",{children:[s.jsx("line",{x1:bl,x2:j-kd,y1:w(I),y2:w(I),className:"stroke-gray-200 dark:stroke-gray-800",strokeWidth:1}),s.jsx("text",{x:bl-6,y:w(I)+3,textAnchor:"end",className:"fill-gray-400 dark:fill-gray-500",fontSize:9,children:t(I)})]},B)),h&&l!==null&&a[l]&&s.jsx("line",{x1:k(l),x2:k(l),y1:qo,y2:qo+E,className:"stroke-gray-300 dark:stroke-gray-700",strokeWidth:1}),v,V.map(I=>{const B=a[I];return B?s.jsx("text",{x:k(I),y:Do-6,textAnchor:"middle",className:"fill-gray-400 dark:fill-gray-500",fontSize:9,children:B.slice(5)},I):null}),u??a.map((I,B)=>s.jsx("rect",{x:bl+C*B,y:qo,width:C,height:E,fill:"transparent",className:"cursor-crosshair",onMouseEnter:()=>o(B)},`hit-${B}`))]}),c&&l!==null&&a[l]&&s.jsx("div",{ref:P,className:"pointer-events-none absolute rounded border border-gray-200 bg-white px-2 py-1 text-xs whitespace-nowrap shadow-sm dark:border-gray-700 dark:bg-gray-900",style:{left:0,top:0,visibility:"hidden"},children:c(l)})]})}function r9({points:e,currency:t="USD"}){const[a,l]=y.useState(null),[o,c]=Hg(),u=e.map(g=>g.cost??0),f=Math.max(1e-9,...u),p=GS(e.length,f,c),h=e.map(g=>g.date);return s.jsx("div",{ref:o,children:c>0&&s.jsx(Fg,{geom:p,fmtY:g=>hr(g,t),dates:h,hover:a,onHover:l,bubble:g=>{const v=e[g];return s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"text-gray-400",children:v.date}),s.jsx("p",{className:"font-mono",children:hr(v.cost,t)})]})},children:s.jsxs("g",{children:[s.jsx("path",{d:V7(p,u),className:"fill-current",stroke:"none",opacity:a!==null?.06:.1}),s.jsx("path",{d:q7(p,u),fill:"none",stroke:"currentColor",strokeWidth:2,opacity:a!==null?.35:1}),e.map((g,v)=>s.jsx("circle",{cx:p.x(v),cy:p.y(g.cost??0),r:a===v?4:2.5,className:"fill-current",opacity:a!==null&&a!==v?.25:1},g.date))]})})})}const Vo={cacheRead:"#7dd3fc",cacheWrite:"#0ea5e9",output:"#0369a1"},tk=[{fill:"fill-violet-500 dark:fill-violet-400",swatch:"bg-violet-500 dark:bg-violet-400"},{fill:"fill-sky-500 dark:fill-sky-400",swatch:"bg-sky-500 dark:bg-sky-400"},{fill:"fill-amber-500 dark:fill-amber-400",swatch:"bg-amber-500 dark:bg-amber-400"},{fill:"fill-rose-500 dark:fill-rose-400",swatch:"bg-rose-500 dark:bg-rose-400"},{fill:"fill-emerald-500 dark:fill-emerald-400",swatch:"bg-emerald-500 dark:bg-emerald-400"},{fill:"fill-cyan-500 dark:fill-cyan-400",swatch:"bg-cyan-500 dark:bg-cyan-400"},{fill:"fill-fuchsia-500 dark:fill-fuchsia-400",swatch:"bg-fuchsia-500 dark:bg-fuchsia-400"}];function nk(e){return tk[e%tk.length]}const ak=[{text:"text-violet-500",swatch:"bg-violet-500"},{text:"text-amber-500 dark:text-amber-600",swatch:"bg-amber-500 dark:bg-amber-600"},{text:"text-sky-500 dark:text-sky-600",swatch:"bg-sky-500 dark:bg-sky-600"},{text:"text-rose-500",swatch:"bg-rose-500"}];function YS(e){return ak[e%ak.length]}function qd({text:e}){return s.jsx("p",{className:"py-6 text-center text-xs text-gray-400",children:e??m.usage.empty})}function s9(e){return e==="cacheRead"?m.usage.colCacheRead:e==="cacheWrite"?m.usage.colCacheWrite:m.usage.colOutput}const QS="opacity-25",qu=160,l9=75;function i9({data:e}){const[t,a]=y.useState(null),l=e.reduce((p,h)=>p+h.requests,0);if(e.length===0||l<=0)return s.jsx(qd,{});const o=[...e].sort((p,h)=>h.requests-p.requests),c=a9(o.map(p=>p.requests),qu/2,qu/2,l9),u=p=>`${Math.round(p/l*100)}%`,f=p=>t!==null&&t!==p?QS:"";return s.jsxs("div",{className:"flex items-center gap-3",onMouseLeave:()=>a(null),children:[s.jsx("svg",{viewBox:`0 0 ${qu} ${qu}`,className:"h-40 w-40 shrink-0",role:"img","aria-label":m.usage.chartAgentCalls,children:c.map(p=>{const h=o[p.index];return s.jsx("path",{d:p.path,onMouseEnter:()=>a(p.index),className:`cursor-pointer ${nk(p.index).fill} transition-opacity duration-150 ${f(p.index)}`,children:s.jsx("title",{children:`${h.agentId} · ${h.requests} ${m.usage.requests} · ${u(h.requests)}`})},h.agentId)})}),s.jsx("ul",{className:"flex max-h-40 min-w-0 flex-1 flex-col gap-1 overflow-y-auto",children:o.map((p,h)=>s.jsxs("li",{onMouseEnter:()=>a(p.requests>0?h:null),title:`${p.agentId} · ${p.requests} ${m.usage.requests} · ${Ct(p.total)}`,className:`flex cursor-pointer items-center gap-1.5 text-[10px] transition-opacity duration-150 ${f(h)}`,children:[s.jsx("span",{className:`inline-block h-2 w-2 shrink-0 rounded-sm ${nk(h).swatch}`}),s.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-gray-500 dark:text-gray-400",children:p.agentId}),s.jsx("span",{className:"shrink-0 font-mono tabular-nums text-gray-500 dark:text-gray-400",children:p.requests}),s.jsx("span",{className:"w-8 shrink-0 text-right font-mono tabular-nums text-gray-400 dark:text-gray-500",children:u(p.requests)})]},p.agentId))})]})}function o9({dimmed:e,onEnter:t,title:a,label:l,value:o,children:c}){return s.jsxs("div",{onMouseEnter:t,className:`flex cursor-pointer items-center gap-2 transition-opacity duration-150 ${e?QS:""}`,title:a,children:[s.jsx("span",{className:"w-24 shrink-0 truncate font-mono text-[10px] text-gray-500 dark:text-gray-400",children:l}),c,s.jsx("span",{className:"w-10 shrink-0 text-right font-mono text-[10px] tabular-nums text-gray-500 dark:text-gray-400",children:o})]})}function c9(e){return _g(e.provider,e.modelId)?.displayName??e.modelId}function u9(e){const t=[`${e.completed}/${e.total}`];e.failed>0&&t.push(`failed ${e.failed}`),e.timeout>0&&t.push(`timeout ${e.timeout}`),e.malformed>0&&t.push(`malformed ${e.malformed}`),e.aborted>0&&t.push(`${m.usage.successAborted} ${e.aborted}`);const a=Os(e.provider)?.label??e.provider;return`${e.modelId} · ${a} · ${t.join(" · ")}`}function d9({data:e}){const[t,a]=y.useState(null);return e.length===0?s.jsx(qd,{}):s.jsx("div",{className:"flex flex-col gap-1.5",onMouseLeave:()=>a(null),children:e.map((l,o)=>{const c=Y7(l.completed,l.total),u=Math.round(c*100);return s.jsx(o9,{dimmed:t!==null&&t!==o,onEnter:()=>a(o),title:u9(l),label:c9(l),value:`${u}%`,children:s.jsx("div",{className:"h-3 min-w-0 flex-1 overflow-hidden rounded-sm bg-gray-200 dark:bg-gray-800",children:s.jsx("div",{className:"h-full rounded-sm bg-sky-500 dark:bg-sky-400",style:{width:`${c*100}%`}})})},`${l.provider}:${l.modelId}`)})})}function f9({trend:e,legend:t}){const[a,l]=y.useState(null),[o,c]=Hg();if(e.length===0)return s.jsx(qd,{});const u=e.map(E=>E.cacheRead+E.cacheWrite+E.output),f=Math.max(1,...u),{barW:p,chartW:h,scroll:g}=Z7(c,e.length),v=GS(e.length,f,h),k=e.map(E=>E.date),w=e.map(E=>t9(v,E)),j=(E,C)=>a!==null&&!(a.i===E&&a.key===C)||t!=null&&t!==C;return s.jsx("div",{ref:o,children:c>0&&s.jsx(Fg,{geom:v,fmtY:E=>Ct(Math.round(E)),dates:k,hover:a?.i??null,labels:K7(e.length,v.step),hoverLine:!1,scrollToEnd:g,onHover:E=>{E===null&&l(null)},bubble:E=>{const C=e[E],M=a?.key;if(!M)return null;const _=M==="cacheRead"?jw(C.cacheRead,C.cacheWrite):null;return s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"text-gray-400",children:C.date}),s.jsxs("p",{className:"font-mono",children:[s9(M)," ",Ct(C[M])]}),_!==null&&s.jsxs("p",{className:"font-mono",children:[m.traces.hitRate," ",ng(_)]})]})},hitLayer:e.map((E,C)=>w[C].map(M=>s.jsx("rect",{x:v.x(C)-p/2,y:M.hitY,width:p,height:M.hitH,fill:"transparent",className:"cursor-pointer",onMouseEnter:()=>l({i:C,key:M.key}),onMouseLeave:()=>l(null)},`hit-${E.date}-${M.key}`))),children:e.map((E,C)=>w[C].map(M=>s.jsx("rect",{x:v.x(C)-p/2,y:M.y,width:p,height:M.h,fill:Vo[M.key],className:"transition-opacity duration-150",opacity:j(C,M.key)?.2:1},`${E.date}-${M.key}`)))})})}function m9({active:e,onHover:t}){const a=[["cacheRead",m.usage.colCacheRead],["cacheWrite",m.usage.colCacheWrite],["output",m.usage.colOutput]];return s.jsx("div",{className:"flex flex-wrap gap-x-3 gap-y-1",children:a.map(([l,o])=>s.jsxs("button",{type:"button",onMouseEnter:()=>t?.(l),onMouseLeave:()=>t?.(null),className:`flex items-center gap-1 text-[10px] text-gray-500 transition-opacity duration-150 dark:text-gray-400 ${e!=null&&e!==l?"opacity-30":""}`,children:[s.jsx("span",{className:"inline-block h-2 w-3 rounded-sm",style:{backgroundColor:Vo[l]}}),o]},l))})}function p9(e){return e==="unexpected"?m.usage.errorsUnexpected:m.usage.errorsExpected}function h9(e){return e==="unexpected"?"unexpected":"expected"}const g9={environment:"env"};function rk(e,t){return`[${g9[e]??e}] ${t}`}function Vu({label:e,value:t,alert:a,muted:l}){const o=a?"text-rose-600 dark:text-rose-400":l?"text-gray-500 dark:text-gray-400":"text-gray-900 dark:text-gray-100";return s.jsxs("div",{className:"flex items-baseline gap-1.5",children:[s.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:e}),s.jsx("span",{className:`font-mono text-sm font-semibold tabular-nums ${o}`,children:t})]})}function Gu({children:e,className:t=""}){return s.jsx("th",{className:`py-1.5 pr-2 font-medium ${t}`,children:e})}function x9({errors:e,projectId:t,filters:a}){const{total:l,unexpected:o,topCode:c,recent:u}=e,f=Math.max(1,u.length),[p,h]=y.useState(0),[g,v]=y.useState(u),[k,w]=y.useState(l),[j,E]=y.useState(null),[C,M]=y.useState(!1);y.useEffect(()=>h(0),[u]),y.useEffect(()=>{if(p===0){v(u),w(l),E(null);return}let A=!1;return M(!0),E(null),jN(t,{offset:p*f,limit:f,...a}).then(P=>{A||(v(P.items),w(P.total))}).catch(P=>{A||E(Ie(P))}).finally(()=>{A||M(!1)}),()=>{A=!0}},[p,f,t,a,u,l]);const _=Math.max(1,Math.ceil(k/f)),[D,V]=y.useState(new Set);y.useEffect(()=>V(new Set),[g]);const F=A=>V(P=>{const Q=new Set(P);return Q.has(A)?Q.delete(A):Q.add(A),Q});return s.jsxs("div",{children:[s.jsxs("div",{className:"flex flex-wrap items-baseline gap-x-6 gap-y-1.5",children:[s.jsx(Vu,{label:m.usage.errorsTotal,value:String(l)}),s.jsx(Vu,{label:m.usage.errorsUnexpected,value:String(o),alert:o>0,muted:o===0}),s.jsx(Vu,{label:m.usage.errorsExpected,value:String(l-o),muted:!0}),c&&s.jsx(Vu,{label:m.usage.errorsTopCode,value:`${rk(c.source,c.code)} ×${c.count}`})]}),g.length===0?s.jsx(qd,{text:m.usage.errorsEmpty}):s.jsx("div",{className:"mt-2.5 max-h-72 overflow-y-auto border-t border-gray-200 dark:border-gray-800",children:s.jsxs("table",{className:"w-full table-fixed text-xs",children:[s.jsx("thead",{className:"sticky top-0 bg-white text-left text-gray-400 dark:bg-gray-900 dark:text-gray-500",children:s.jsxs("tr",{children:[s.jsx(Gu,{className:"w-32",children:m.common.time}),s.jsx(Gu,{className:"w-72",children:m.usage.errorsColCode}),s.jsx(Gu,{className:"w-20",children:m.usage.errorsColKind}),s.jsx(Gu,{children:m.usage.errorsColMessage})]})}),s.jsx("tbody",{children:g.map((A,P)=>{const Q=h9(A.kind);return s.jsxs("tr",{className:"border-t border-gray-100 dark:border-gray-800/60",children:[s.jsx("td",{className:"py-1.5 pr-2 align-top font-mono tabular-nums text-gray-400",children:ha(A.ts)}),s.jsx("td",{className:"py-1.5 pr-2 align-top font-mono text-gray-500 dark:text-gray-400",children:s.jsx("span",{className:"block break-words",children:rk(A.source,A.code)})}),s.jsx("td",{className:"py-1.5 pr-2 align-top",children:s.jsx(gn,{tone:Q==="unexpected"?"red":"gray",children:p9(Q)})}),s.jsx("td",{className:"py-1.5 align-top text-gray-500 dark:text-gray-400",children:s.jsx("button",{type:"button",title:A.message,onClick:()=>F(P),className:`block w-full cursor-pointer text-left transition-colors hover:text-gray-700 dark:hover:text-gray-300 ${D.has(P)?"whitespace-pre-wrap break-words":"truncate"}`,children:A.message})})]},`${A.ts}-${P}`)})})]})}),(_>1||p>0)&&s.jsxs("div",{className:"mt-2 flex items-center justify-end gap-2 text-xs text-gray-500 dark:text-gray-400",children:[j!==null&&s.jsx("span",{className:"mr-auto text-rose-500",children:j}),s.jsx("span",{className:"tabular-nums",children:m.usage.errorsPageOf(p+1,_,k)}),s.jsx(sk,{label:m.usage.errorsNewer,disabled:p===0||C,onClick:()=>h(A=>Math.max(0,A-1))}),s.jsx(sk,{label:m.usage.errorsOlder,disabled:p+1>=_||C,onClick:()=>h(A=>A+1)})]})]})}function sk({label:e,disabled:t,onClick:a}){return s.jsx("button",{type:"button",disabled:t,onClick:a,className:"rounded-md border border-gray-200 px-2 py-0.5 transition-colors duration-150 hover:bg-gray-100 disabled:cursor-not-allowed disabled:opacity-40 disabled:hover:bg-transparent dark:border-gray-800 dark:hover:bg-gray-800/60 dark:disabled:hover:bg-transparent",children:e})}function lk(e){const t=a=>a<10?`0${a}`:`${a}`;return`${e.getFullYear()}-${t(e.getMonth()+1)}-${t(e.getDate())}`}function Pp({label:e,value:t,muted:a,sup:l}){const o=a?"text-gray-500 dark:text-gray-400":"text-gray-900 dark:text-gray-100";return s.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[s.jsxs("span",{className:"shrink-0 text-xs text-gray-500 dark:text-gray-400",children:[e,l&&s.jsx("sup",{className:"ml-px",children:"*"})]}),s.jsx("span",{className:`min-w-0 truncate font-mono text-sm font-semibold tabular-nums ${o}`,children:t})]})}function Bp({title:e,bucket:t,currency:a}){return s.jsxs("div",{className:"rounded-md border border-gray-200 bg-white p-3 dark:border-gray-800 dark:bg-gray-900",children:[s.jsx("p",{className:"mb-1.5 text-xs font-medium text-gray-500 dark:text-gray-400",children:e}),s.jsxs("div",{className:"space-y-0.5",children:[s.jsx(Pp,{label:m.usage.tokens,value:Ct(t.total)}),s.jsx(Pp,{label:m.usage.requests,value:String(t.requests),muted:!0}),s.jsx(Pp,{label:m.common.cost,value:hr(t.cost,a),sup:t.hasUncosted})]})]})}function Ao({title:e,extra:t,children:a}){return s.jsxs("div",{className:"rounded-md border border-gray-200 bg-white p-3 dark:border-gray-800 dark:bg-gray-900",children:[s.jsxs("div",{className:"mb-2 flex flex-wrap items-center justify-between gap-x-2 gap-y-1",children:[s.jsx("p",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:e}),t]}),a]})}function y9(){Er(m.usage.title);const{currency:e}=Ps(),{currentProject:t}=Xt(),a=t?.projectId??null,[l]=Ed(),o=l.get("agentId"),[c,u]=y.useState(o??""),[f,p]=y.useState(null);y.useEffect(()=>{u(o??"")},[o]);const[h,g]=y.useState(()=>{const O=new Date;return O.setDate(O.getDate()-29),lk(O)}),[v,k]=y.useState(()=>lk(new Date)),[w,j]=y.useState(null),[E,C]=y.useState(null),[M,_]=y.useState(null),D=y.useCallback(async()=>{if(a){C(null);try{const O=await _k(a,{from:h,to:v,groupBy:"date",...c?{agentId:c}:{},...f?{provider:f.provider,modelId:f.modelId}:{}});j(O)}catch(O){C(Ie(O))}}},[a,h,v,c,f?.provider,f?.modelId]);y.useEffect(()=>{j(null),D()},[D]);const V=y.useMemo(()=>({from:h,to:v,...c?{agentId:c}:{}}),[h,v,c]);if(!a)return null;const F=w?.models??[],A=f?F.findIndex(O=>O.provider===f.provider&&O.modelId===f.modelId):-1,P=A>=0?String(A):"",Q=w?.summary,K=(Q?.today.hasUncosted??!1)||(Q?.last7d.hasUncosted??!1)||(Q?.total.hasUncosted??!1);return s.jsx("div",{className:"h-full overflow-y-auto p-4 md:p-6",children:s.jsxs("div",{className:"mx-auto max-w-5xl space-y-4",children:[s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[s.jsx("h1",{className:"text-xl font-semibold",children:m.usage.title}),s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsx("div",{className:"w-32",children:s.jsxs(Ds,{size:"sm",value:c,onChange:O=>u(O.target.value),children:[s.jsx("option",{value:"",children:m.usage.filterAllAgents}),c&&!(w?.agentIds??[]).includes(c)&&s.jsx("option",{value:c,children:c}),(w?.agentIds??[]).map(O=>s.jsx("option",{value:O,children:O},O))]})}),s.jsx("div",{className:"w-32",children:s.jsxs(Ds,{size:"sm",value:P,onChange:O=>{const z=O.target.value;p(z===""?null:F[Number(z)]??null)},children:[s.jsx("option",{value:"",children:m.usage.filterAllModels}),F.map((O,z)=>s.jsx("option",{value:String(z),children:_g(O.provider,O.modelId)?.displayName??O.modelId},`${O.provider}:${O.modelId}`))]})}),s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx(at,{size:"sm",type:"date","aria-label":m.usage.from,value:h,onChange:O=>g(O.target.value)}),s.jsx("span",{className:"shrink-0 text-gray-400","aria-hidden":!0,children:"–"}),s.jsx(at,{size:"sm",type:"date","aria-label":m.usage.to,value:v,onChange:O=>k(O.target.value)})]})]})]}),w?s.jsxs("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-3",children:[s.jsx(Bp,{title:m.usage.today,bucket:w.summary.today,currency:e}),s.jsx(Bp,{title:m.usage.last7d,bucket:w.summary.last7d,currency:e}),s.jsx(Bp,{title:m.usage.total,bucket:w.summary.total,currency:e})]}):s.jsxs("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-3",children:[s.jsx(en,{className:"h-24"}),s.jsx(en,{className:"h-24"}),s.jsx(en,{className:"h-24"})]}),w?s.jsxs("div",{className:"grid grid-cols-1 gap-3 lg:grid-cols-2",children:[s.jsx(Ao,{title:m.usage.chartAgentCalls,children:s.jsx(i9,{data:w.byAgent})}),s.jsx(Ao,{title:m.usage.chartSuccessRate,children:s.jsx(d9,{data:w.success})}),s.jsx(Ao,{title:m.usage.chartTokenTrend,extra:s.jsx(m9,{active:M,onHover:_}),children:s.jsx(f9,{trend:w.trend,legend:M})}),s.jsx(Ao,{title:m.usage.chartCostTrend,children:s.jsx(r9,{points:w.trend,currency:e})})]}):s.jsx(en,{className:"h-64"}),w&&s.jsx(Ao,{title:m.usage.errors,children:s.jsx(x9,{errors:w.errors,projectId:a,filters:V})}),K&&s.jsx("p",{className:"text-xs text-gray-400",children:m.usage.uncostedNote}),E&&s.jsx("p",{className:"text-xs text-red-600 dark:text-red-400",children:E})]})})}function v9({cacheRead:e,cacheWrite:t,output:a,max:l,size:o=44}){const c=e+t+a,u=Math.max(2,Math.round(o*.16)),f=o/2,p=(o-u)/2,h=2*Math.PI*p,g=Math.max(l,c,1),v=l>0?c/l:0,k=v>.95?"text-red-500":v>.8?"text-amber-500":"text-gray-300 dark:text-gray-700",w=[{key:"cacheRead",value:e,color:Vo.cacheRead,label:m.usage.colCacheRead},{key:"cacheWrite",value:t,color:Vo.cacheWrite,label:m.usage.colCacheWrite},{key:"output",value:a,color:Vo.output,label:m.usage.colOutput}],j=`${m.chat.contextUsage} ${Ct(c)}/${Ct(l)}`+w.map(C=>` · ${C.label} ${Ct(C.value)}`).join("");let E=0;return s.jsxs("svg",{width:o,height:o,viewBox:`0 0 ${o} ${o}`,className:`block shrink-0 ${k}`,role:"img","aria-label":j,children:[s.jsx("title",{children:j}),s.jsx("circle",{cx:f,cy:f,r:p,fill:"none",stroke:"currentColor",strokeOpacity:.35,strokeWidth:u}),w.map(C=>{if(C.value<=0)return null;const M=C.value/g*h,_=-(E/g)*h;return E+=C.value,s.jsx("circle",{cx:f,cy:f,r:p,fill:"none",stroke:C.color,strokeWidth:u,strokeDasharray:`${M} ${h}`,strokeDashoffset:_,transform:`rotate(-90 ${f} ${f})`},C.key)})]})}const Ra={thinking:"bg-violet-500 dark:bg-violet-400",text:"bg-sky-500 dark:bg-sky-400",toolgen:"bg-amber-500 dark:bg-amber-400",approvalWait:"bg-rose-400 dark:bg-rose-300",exec:"bg-emerald-500 dark:bg-emerald-400",other:"bg-gray-400 dark:bg-gray-500"},Sd="sticky left-0 z-10 flex h-4 w-[5.5rem] shrink-0 items-center justify-end bg-white pr-2 dark:bg-gray-950",Oh="truncate font-mono text-[11px]",ik=.25,Dh=24,b9=1/Dh,Kr=(e,t,a)=>Math.min(a,Math.max(t,e));function k9(e){return e==="thinking"?Ra.thinking:e==="text"?Ra.text:Ra.toolgen}function w9(e){return e==="thinking"?m.traces.kindThinking:e==="text"?m.traces.kindModelReply:m.traces.kindToolGen}function S9(e){return e==="thinking"?"thinking":e==="text"?"text":"toolgen"}function ul(e){if(e===void 0)return null;const t=Date.parse(e);return Number.isFinite(t)?t:null}function j9(e,t,a){const l=new Map,o=u=>{let f=l.get(u);return f||(f={segs:[],spans:[],others:[]},l.set(u,f)),f};for(const u of e){const f=ul(u.startTs),p=ul(u.endTs);f===null||p===null||o(u.taskIndex).segs.push({kind:u.kind,...u.name!==void 0?{name:u.name}:{},ts:u.endTs,startMs:f,endMs:p})}for(const u of t){const f=ul(u.callTs);f!==null&&o(u.taskIndex).spans.push({name:u.name||u.toolCallId,toolCallId:u.toolCallId,callTs:u.callTs,...u.approvalTs!==void 0?{approvalTsRaw:u.approvalTs}:{},...u.outputTs!==void 0?{outputTsRaw:u.outputTs}:{},callMs:f,approvalMs:ul(u.approvalTs),outputMs:ul(u.outputTs),failed:u.stopReason!==void 0&&u.stopReason!=="completed",...u.stopReason!==void 0?{status:u.stopReason}:{},...u.decision!==void 0?{decision:u.decision}:{}})}for(const u of a){const f=ul(u.startTs),p=ul(u.endTs);f===null||p===null||o(u.taskIndex).others.push({key:u.key,name:u.name,ts:u.endTs,startMs:f,endMs:p,failed:u.failed===!0})}const c=[];for(const[u,{segs:f,spans:p,others:h}]of[...l.entries()].sort((g,v)=>g[0]-v[0])){if(f.length===0&&p.length===0&&h.length===0)continue;const g=[...f.map(C=>C.startMs),...p.map(C=>C.callMs),...h.map(C=>C.startMs)],v=[...f.map(C=>C.endMs),...p.map(C=>C.outputMs??C.approvalMs??C.callMs),...h.map(C=>C.endMs)],k=Math.min(...g),w=Math.max(...v,...g),j=Math.max(1,w-k);p.sort((C,M)=>C.callMs-M.callMs),h.sort((C,M)=>C.startMs-M.startMs);const E=[...new Set(p.map(C=>C.name))];c.push({taskIndex:u,segs:f,spans:p,others:h,t0:k,total:j,toolNames:E})}return c}function zh({children:e}){return s.jsx("div",{className:"relative h-4 min-w-0 flex-1 overflow-hidden bg-gray-100 dark:bg-gray-800/60",children:e})}function C9({label:e,children:t}){return s.jsxs("div",{className:"flex items-center",children:[s.jsx("span",{className:`${Sd} text-gray-400 dark:text-gray-500`,title:e,children:s.jsx("span",{className:Oh,children:e})}),s.jsx(zh,{children:t})]})}function N9({total:e}){const t=[0,.25,.5,.75,1];return s.jsxs("div",{className:"flex items-center",children:[s.jsx("span",{className:Sd}),s.jsx("div",{className:"relative h-4 min-w-0 flex-1",children:t.map((a,l)=>s.jsx("span",{className:`absolute top-0 font-mono text-[11px] text-gray-400 dark:text-gray-500 ${l===0?"":l===t.length-1?"-translate-x-full":"-translate-x-1/2"}`,style:{left:`${a*100}%`},children:hn(a*e)},l))})]})}function T9({segments:e,toolSpans:t,otherSpans:a=[],highlight:l,onHighlight:o,onJump:c,hideTaskLabel:u=!1}){const f=y.useMemo(()=>j9(e,t,a),[e,t,a]),{firstBarKeyByTs:p,barKeys:h}=y.useMemo(()=>{const S=new Map,U=new Set,ee=(ie,de)=>{U.add(de),S.has(ie)||S.set(ie,de)};for(const ie of f){ie.segs.forEach((de,me)=>ee(de.ts,`s-${ie.taskIndex}-${me}`));for(const de of ie.spans)de.approvalMs!==null&&de.approvalMs>de.callMs&&ee(de.approvalTsRaw??de.callTs,`w-${de.toolCallId}`),de.approvalMs===null&&de.outputMs===null?ee(de.callTs,`p-${de.toolCallId}`):ee(de.outputTsRaw??de.callTs,`e-${de.toolCallId}`);for(const de of ie.others)ee(de.ts,`o-${de.key}`)}return{firstBarKeyByTs:S,barKeys:U}},[f]),[g,v]=y.useState(null),[k,w]=y.useState(1),[j,E]=y.useState({left:0,width:1}),C=y.useRef(null),M=y.useRef(null),_=y.useRef(j);_.current=j;const D=y.useRef(k);D.current=k;const V=y.useRef(null),F=y.useRef(null),A=y.useCallback(()=>{const S=C.current;if(!S)return;const U=S.scrollWidth||1;E({left:S.scrollLeft/U,width:Math.min(1,S.clientWidth/U)})},[]);if(y.useLayoutEffect(()=>{const S=C.current;if(S){if(V.current){const U=S.scrollWidth-S.clientWidth;S.scrollLeft=Kr(V.current(S),0,Math.max(0,U)),V.current=null}A()}},[k,f,A]),y.useLayoutEffect(()=>{const S=C.current;if(!S||typeof ResizeObserver>"u")return;const U=new ResizeObserver(()=>A());return U.observe(S),()=>U.disconnect()},[A]),y.useLayoutEffect(()=>()=>F.current?.(),[]),f.length===0)return s.jsx("p",{className:"text-xs text-gray-400",children:m.common.none});const P=l?.ts,Q=l?.key,K=(S,U)=>o?.(U?{ts:U,key:S}:null),O=()=>o?.(null),z=Q??(P!==void 0?p.get(P):void 0),I=z!==void 0&&h.has(z)?z:void 0,B=I!==void 0,$=S=>I===S,G=(S,U)=>g!==null&&!U||B&&!S?"opacity-15":"",q=(S,U,ee,ie)=>{const de=Kr((S-ee)/ie*100,0,100),me=Kr((U-S)/ie*100,0,100-de);return de>=100?{left:"100%",width:"0%",marginLeft:"-2px"}:{left:`${de}%`,width:`${me}%`}},ae=[{key:"thinking",className:Ra.thinking,label:m.traces.kindThinking},{key:"text",className:Ra.text,label:m.traces.kindModelReply},{key:"toolgen",className:Ra.toolgen,label:m.traces.kindToolGen},{key:"approvalWait",className:Ra.approvalWait,label:m.traces.legendApprovalWait},{key:"exec",className:Ra.exec,label:m.traces.legendToolExec},{key:"other",className:Ra.other,label:m.traces.legendOther}],Z=(S,U)=>{const ee=Kr(U,b9,1),ie=Kr(1/ee,ik,Dh),de=Kr(S,0,1-ee);V.current=me=>de*me.scrollWidth,w(ie)},X=S=>{S.preventDefault();const U=M.current,ee=C.current;if(!U||!ee)return;const ie=U.getBoundingClientRect().width||1,de=S.clientX,me=ee.scrollLeft,ye=Math.max(0,ee.scrollWidth-ee.clientWidth),te=Re=>{const Fe=(Re.clientX-de)/ie;ee.scrollLeft=Kr(me+Fe*ee.scrollWidth,0,ye),A()},be=()=>{window.removeEventListener("pointermove",te),window.removeEventListener("pointerup",be),window.removeEventListener("pointercancel",be),F.current=null};window.addEventListener("pointermove",te),window.addEventListener("pointerup",be),window.addEventListener("pointercancel",be),F.current=be},T=S=>U=>{U.preventDefault(),U.stopPropagation();const ee=M.current;if(!ee)return;const ie=ee.getBoundingClientRect(),de=ye=>{const te=Kr((ye.clientX-ie.left)/(ie.width||1),0,1),be=_.current;if(S==="right")Z(be.left,te-be.left);else{const Re=be.left+be.width;Z(te,Re-te)}},me=()=>{window.removeEventListener("pointermove",de),window.removeEventListener("pointerup",me),window.removeEventListener("pointercancel",me),F.current=null};window.addEventListener("pointermove",de),window.addEventListener("pointerup",me),window.addEventListener("pointercancel",me),F.current=me},R=()=>{V.current=()=>0,w(1)},H=S=>{const U=C.current,ee=Kr(D.current*S,ik,Dh);if(ee!==D.current){if(U){const ie=U.clientWidth/2,de=(U.scrollLeft+ie)/(U.scrollWidth||1);V.current=me=>de*me.scrollWidth-ie}w(ee)}};return s.jsxs("div",{className:"space-y-3",children:[s.jsx("div",{ref:C,className:"no-scrollbar overflow-x-auto overflow-y-hidden",children:s.jsx("div",{className:"space-y-4",style:{width:`${k*100}%`},children:f.map(S=>s.jsxs("div",{className:"space-y-1",children:[!u&&s.jsxs("div",{className:"flex items-center gap-2 pl-[5.5rem]",children:[s.jsx("span",{className:"rounded bg-gray-100 px-1.5 py-0.5 text-[11px] font-medium text-gray-500 dark:bg-gray-800 dark:text-gray-400",children:m.traces.task(S.taskIndex+1)}),s.jsx("span",{className:"font-mono text-[11px] text-gray-400",children:hn(S.total)})]}),s.jsx(C9,{label:m.traces.laneLLM,children:S.segs.map((U,ee)=>{const ie=S9(U.kind),de=g===null||g===ie,me=`s-${S.taskIndex}-${ee}`,ye=$(me);return s.jsx("span",{onMouseEnter:()=>K(me,U.ts),onMouseLeave:O,onClick:()=>c?.(U.ts),title:`${w9(U.kind)}${U.name?` ${U.name}`:""} · ${hn(U.endMs-U.startMs)}`,className:`absolute inset-y-0 min-w-[2px] cursor-pointer ${k9(U.kind)} ${G(ye,de)}`,style:q(U.startMs,U.endMs,S.t0,S.total)},ee)})}),S.spans.map(U=>{const ee=U.approvalMs??U.callMs,ie=U.outputMs===null,de=U.outputMs??S.t0+S.total,me=U.approvalTsRaw??U.callTs,ye=U.outputTsRaw??U.callTs;return s.jsxs("div",{className:"flex items-center",children:[s.jsx("span",{className:`${Sd} text-gray-500 dark:text-gray-400`,title:U.name,children:s.jsx("span",{className:Oh,children:U.name})}),s.jsxs(zh,{children:[U.approvalMs!==null&&U.approvalMs>U.callMs&&s.jsx("span",{onMouseEnter:()=>K(`w-${U.toolCallId}`,me),onMouseLeave:O,onClick:()=>c?.(me),title:`${U.name} · ${m.traces.legendApprovalWait}${U.decision?` (${U.decision})`:""} · ${hn(U.approvalMs-U.callMs)}`,className:`absolute inset-y-0 min-w-[2px] cursor-pointer ${Ra.approvalWait} ${G($(`w-${U.toolCallId}`),g===null||g==="approvalWait")}`,style:q(U.callMs,U.approvalMs,S.t0,S.total)}),U.approvalMs===null&&ie?(()=>{const te=G($(`p-${U.toolCallId}`),g===null||g==="approvalWait");return s.jsx("span",{onMouseEnter:()=>K(`p-${U.toolCallId}`,U.callTs),onMouseLeave:O,onClick:()=>c?.(U.callTs),title:`${U.name} · ${m.traces.legendApprovalWait} · ${m.traces.inProgress}`,className:`absolute inset-y-0 min-w-[2px] cursor-pointer ${Ra.approvalWait} ${te||"animate-pulse"}`,style:q(U.callMs,de,S.t0,S.total)})})():(()=>{const te=G($(`e-${U.toolCallId}`),g===null||g==="exec"),be=ie&&!te;return s.jsx("span",{onMouseEnter:()=>K(`e-${U.toolCallId}`,ye),onMouseLeave:O,onClick:()=>c?.(ye),title:`${U.name} · ${m.traces.legendToolExec} · ${ie?m.traces.inProgress:hn(de-ee)}${U.failed?` · ${U.status}`:""}`,className:`absolute inset-y-0 min-w-[2px] cursor-pointer ${Ra.exec} ${U.failed?"ring-1 ring-red-500":""} ${be?"animate-pulse opacity-70":te}`,style:q(ee,de,S.t0,S.total)})})()]})]},U.toolCallId)}),S.others.map(U=>{const ee=G($(`o-${U.key}`),g===null||g==="other");return s.jsxs("div",{className:"flex items-center",children:[s.jsx("span",{className:`${Sd} text-gray-500 dark:text-gray-400`,title:U.name,children:s.jsx("span",{className:Oh,children:U.name})}),s.jsx(zh,{children:s.jsx("span",{onMouseEnter:()=>K(`o-${U.key}`,U.ts),onMouseLeave:O,onClick:()=>c?.(U.ts),title:`${U.name} · ${m.traces.legendOther} · ${hn(U.endMs-U.startMs)}`,className:`absolute inset-y-0 min-w-[2px] cursor-pointer ${Ra.other} ${U.failed?"ring-1 ring-red-500":""} ${ee}`,style:q(U.startMs,U.endMs,S.t0,S.total)})})]},U.key)}),s.jsx(N9,{total:S.total})]},S.taskIndex))})}),s.jsx("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 border-t border-gray-100 pt-2.5 dark:border-gray-800",children:ae.map(S=>s.jsxs("button",{type:"button",onMouseEnter:()=>v(S.key),onMouseLeave:()=>v(null),className:`flex items-center gap-1 px-1 font-mono text-[11px] text-gray-500 transition-opacity duration-150 dark:text-gray-400 ${g!==null&&g!==S.key?"opacity-30":""}`,children:[s.jsx("span",{className:`inline-block h-2 w-3 rounded-sm ${S.className}`}),S.label]},S.key))}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"shrink-0 text-[11px] text-gray-400",children:m.traces.zoom}),s.jsx("button",{type:"button","aria-label":m.traces.zoomOut,title:m.traces.zoomOut,onClick:()=>H(1/1.4),className:"flex h-4 w-4 shrink-0 items-center justify-center rounded border border-gray-200 text-gray-500 transition-colors duration-150 hover:bg-gray-100 dark:border-gray-700 dark:text-gray-400 dark:hover:bg-gray-800",children:s.jsx("span",{className:"text-[11px] leading-none",children:"−"})}),s.jsx("div",{ref:M,onDoubleClick:R,title:m.traces.zoomReset,className:"relative h-3 min-w-0 flex-1 rounded bg-gray-100 dark:bg-gray-800",children:s.jsxs("div",{role:"scrollbar","aria-label":m.traces.zoom,onPointerDown:X,className:"absolute inset-y-0 flex cursor-grab items-center justify-between rounded bg-gray-400/70 active:cursor-grabbing dark:bg-gray-500/70",style:{left:`${j.left*100}%`,width:`${Math.max(j.width*100,3)}%`},children:[s.jsx("span",{onPointerDown:T("left"),className:"h-full w-1.5 shrink-0 cursor-ew-resize rounded-l bg-gray-500/80 dark:bg-gray-400/80"}),s.jsx("span",{onPointerDown:T("right"),className:"h-full w-1.5 shrink-0 cursor-ew-resize rounded-r bg-gray-500/80 dark:bg-gray-400/80"})]})}),s.jsx("button",{type:"button","aria-label":m.traces.zoomIn,title:m.traces.zoomIn,onClick:()=>H(1.4),className:"flex h-4 w-4 shrink-0 items-center justify-center rounded border border-gray-200 text-gray-500 transition-colors duration-150 hover:bg-gray-100 dark:border-gray-700 dark:text-gray-400 dark:hover:bg-gray-800",children:s.jsx("span",{className:"text-[11px] leading-none",children:"+"})}),s.jsxs("span",{className:"w-9 shrink-0 text-right font-mono text-[11px] tabular-nums text-gray-400",children:[k.toFixed(2),"×"]})]}),o&&s.jsx("p",{className:"text-[11px] text-gray-400 dark:text-gray-600",children:m.traces.linkHint})]})}function M9(e){return e==="session_meta"?"brand":e==="model_msg"?"gray":"amber"}const E9={text:"M8 10h8M8 14h5M21 12a9 9 0 1 1-4-7.5",thinking:"M9 18h6M10 21h4M12 3a6 6 0 0 0-3 11v2h6v-2a6 6 0 0 0-3-11z",image_url:"M3 5h18v14H3zM3 15l5-5 4 4 3-3 6 6",inline_data:"M3 5h18v14H3zM3 15l5-5 4 4 3-3 6 6",tool_call:"M14.7 6.3a4 4 0 0 0-5 5L4 17v3h3l5.7-5.7a4 4 0 0 0 5-5l-2.5 2.5-2-2 2.5-2.5z",tool_call_output:"M4 6l4 4-4 4M12 18h8",token_usage:"M4 20V10m6 10V4m6 16v-7m4 7H2",request_begin:"M5 12h14M13 6l6 6-6 6",request_end:"M19 12H5M11 6l-6 6 6 6",approval_decision:"M9 12l2 2 4-4M12 3l7 3v6c0 4.5-3 7.5-7 9-4-1.5-7-4.5-7-9V6z",compaction_begin:"M8 3H4v4M16 3h4v4M8 21H4v-4M16 21h4v-4M9 12h6",compaction_end:"M8 3H4v4M16 3h4v4M8 21H4v-4M16 21h4v-4M9 12h6",abort:"M6 6h12v12H6z",subagent:"M12 3v6m0 0l-5 4v8m5-12l5 4v8M4 21h16",mcp_connect_begin:"M9 7V3m6 4V3M7 7h10v4a5 5 0 0 1-10 0zM12 16v5",mcp_connect_end:"M9 7V3m6 4V3M7 7h10v4a5 5 0 0 1-10 0zM12 16v5",tool_list_ready:"M14.7 6.3a4 4 0 0 0-5 5L4 17v3h3l5.7-5.7a4 4 0 0 0 5-5l-2.5 2.5-2-2 2.5-2.5z"},A9="M12 8v5m0 3h.01M12 21a9 9 0 1 0 0-18 9 9 0 0 0 0 18z";function R9({type:e}){return s.jsx("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round",className:"shrink-0 text-gray-400 dark:text-gray-500","aria-hidden":!0,children:s.jsx("path",{d:E9[e]??A9})})}function _9(e){const t=e.payload;switch(t.type){case void 0:return"";case"text":return`${String(t.role)}: ${String(t.text??"").slice(0,120)}`;case"thinking":return String(t.thinking??"").slice(0,120);case"image_url":return"[image]";case"inline_data":return`[image] ${String(t.mime_type??"")}`;case"tool_call":return`${String(t.name)} ${String(t.arguments??"").slice(0,100)}`;case"tool_call_output":{const a=String(t.output??"").slice(0,120);return Array.isArray(t.images)&&t.images.length>0?`[image] ${a}`:a}case"token_usage":{const a=t.request,l=t.session;return`request.total=${a?.total??0} session.total=${l?.total??0}`}case"request_end":return`status=${String(t.status)}`;case"approval_decision":return`${String(t.decision)} · ${String(t.tool_call_id)}`;case"compaction_begin":case"compaction_end":return`${String(t.mode)} (${String(t.reason)})${t.status?` · ${String(t.status)}`:""}`;case"mcp_connect_begin":return Array.isArray(t.servers)?t.servers.map(String).join(", "):"";case"mcp_connect_end":{const l=(Array.isArray(t.results)?t.results:[]).map(o=>`${String(o.server)}:${String(o.status)}(${String(o.duration_ms)}ms)`);return[String(t.status??""),l.join(" ")].filter(Boolean).join(" · ")}case"tool_list_ready":return Array.isArray(t.tools)?m.traces.toolDefs(t.tools.length):"";case"abort":return t.reason!=null?String(t.reason):"";case"goal_finished":return`${String(t.outcome)} · rounds=${String(t.rounds)} · tokens=${String(t.tokens_used)}`;case"subagent":return String(t.session_id??"");default:return e.type==="session_meta"?`${String(t.session_id??"")} · ${String(t.model_id??"")}`:""}}function I9(e){const t=e.payload;return t.stop_reason??t.status}const zo="max-h-72 overflow-auto whitespace-pre-wrap break-words rounded bg-gray-100 px-2.5 py-2 text-xs dark:bg-gray-800/70";function L9({p:e}){const t=e.request??{},a=e.session??{},l=(o,c)=>s.jsxs("tr",{children:[s.jsx("td",{className:"pr-3 text-gray-400",children:o}),s.jsx("td",{className:"pr-3 text-right font-mono",children:Ct(c.cache_read??0)}),s.jsx("td",{className:"pr-3 text-right font-mono",children:Ct(c.cache_write??0)}),s.jsx("td",{className:"pr-3 text-right font-mono",children:Ct(c.output??0)}),s.jsx("td",{className:"text-right font-mono",children:Ct(c.total??0)})]});return s.jsxs("table",{className:"text-xs",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"text-gray-400",children:[s.jsx("th",{}),s.jsx("th",{className:"pr-3 text-right font-normal",children:"cacheRead"}),s.jsx("th",{className:"pr-3 text-right font-normal",children:"cacheWrite"}),s.jsx("th",{className:"pr-3 text-right font-normal",children:"output"}),s.jsx("th",{className:"text-right font-normal",children:"total"})]})}),s.jsxs("tbody",{children:[l("request",t),l("session",a)]})]})}const XS="cursor-pointer text-xs font-medium text-gray-500 marker:text-gray-400 hover:text-gray-800 dark:text-gray-400 dark:hover:text-gray-200";function O9({p:e}){const t=[["session_id",String(e.session_id??"")],["source",String(e.source??"")],["model_id",String(e.model_id??"")],["context_window",String(e.model_context_window??"")],...typeof e.thinking_level=="string"&&e.thinking_level?[["thinking_level",e.thinking_level]]:[],["agent_state",String(e.agent_state??"")],["workspace",String(e.workspace??"")]],a=String(e.system_prompt??"");return s.jsxs("div",{className:"space-y-2.5",children:[s.jsx("dl",{className:"grid grid-cols-[auto_minmax(0,1fr)] gap-x-3 gap-y-0.5 text-xs",children:t.map(([l,o])=>s.jsxs(y.Fragment,{children:[s.jsx("dt",{className:"text-gray-400",children:l}),s.jsx("dd",{className:"min-w-0 break-all font-mono text-gray-700 dark:text-gray-300",children:o||"—"})]},l))}),a.trim()&&s.jsxs("details",{children:[s.jsx("summary",{className:XS,children:m.traces.systemPrompt}),s.jsx("div",{className:"md-body mt-1.5 max-h-96 overflow-auto rounded bg-gray-100 px-2.5 py-2 text-sm leading-relaxed text-gray-700 dark:bg-gray-800/70 dark:text-gray-300",children:s.jsx(pc,{remarkPlugins:[hc],children:a})})]})]})}function D9({schema:e}){const t=e.properties!==null&&typeof e.properties=="object"?e.properties:null;if(!t||Object.keys(t).length===0)return s.jsx("pre",{className:`${zo} mt-1`,children:JSON.stringify(e,null,2)});const a=new Set(Array.isArray(e.required)?e.required.map(String):[]),l=o=>{if(Array.isArray(o.enum))return o.enum.map(String).join(" | ");const c=typeof o.type=="string"?o.type:"object";if(c==="array"){const u=o.items;return`${u!==null&&typeof u=="object"?l(u):"unknown"}[]`}return c};return s.jsx("table",{className:"mt-1 w-full text-xs",children:s.jsx("tbody",{children:Object.entries(t).map(([o,c])=>s.jsxs("tr",{className:"align-top",children:[s.jsxs("td",{className:"whitespace-nowrap pr-3 font-mono text-gray-700 dark:text-gray-300",children:[o,a.has(o)&&s.jsx("span",{className:"ml-0.5 text-red-500",children:"*"})]}),s.jsx("td",{className:"whitespace-nowrap pr-3 font-mono text-gray-400 dark:text-gray-500",children:l(c)}),s.jsx("td",{className:"text-gray-500 dark:text-gray-400",children:typeof c.description=="string"?c.description:""})]},o))})})}function z9({p:e}){const t=Array.isArray(e.tools)?e.tools:[];return t.length===0?s.jsx("p",{className:"text-xs text-gray-400",children:"—"}):s.jsx("ul",{className:"divide-y divide-gray-100 rounded-md border border-gray-200 dark:divide-gray-800/60 dark:border-gray-800",children:t.map((a,l)=>s.jsxs("li",{className:"px-2.5 py-1.5 text-xs",children:[s.jsx("span",{className:"font-mono font-semibold text-gray-700 dark:text-gray-300",children:a.name??"—"}),a.description&&s.jsx("p",{className:"mt-0.5 text-gray-500 dark:text-gray-400",children:a.description}),a.parameters!==null&&typeof a.parameters=="object"&&s.jsxs("details",{className:"mt-1",children:[s.jsx("summary",{className:XS,children:m.traces.toolParams}),s.jsx(D9,{schema:a.parameters})]})]},l))})}function U9({msg:e}){const t=e.payload;if(e.type==="session_meta")return s.jsx(O9,{p:t});if(t.type==="tool_list_ready")return s.jsx(z9,{p:t});switch(t.type){case"text":case"thinking":{const a=String(t.text??t.thinking??"");return a.trim()?s.jsx("div",{className:"md-body text-sm leading-relaxed text-gray-700 dark:text-gray-300",children:s.jsx(pc,{remarkPlugins:[hc],children:a})}):s.jsx("p",{className:"text-xs text-gray-400",children:"—"})}case"image_url":return s.jsx(Zr,{src:String(t.image_url??""),alt:"trace",className:"max-h-48 max-w-full rounded-md"});case"inline_data":return s.jsx(Zr,{src:`data:${String(t.mime_type??"")};base64,${String(t.data??"")}`,alt:"trace",className:"max-h-48 max-w-full rounded-md"});case"tool_call":return s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("p",{className:"font-mono text-xs font-semibold text-gray-700 dark:text-gray-300",children:String(t.name??"")}),s.jsx("pre",{className:zo,children:String(t.arguments??"")})]});case"tool_call_output":{const a=Array.isArray(t.images)?t.images:[];return a.length===0?s.jsx("pre",{className:zo,children:String(t.output??"")}):s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("pre",{className:zo,children:String(t.output??"")}),s.jsx("div",{className:"flex flex-wrap gap-2",children:a.map((l,o)=>s.jsx(Zr,{src:l,alt:"trace",className:"max-h-48 max-w-full rounded-md"},o))})]})}case"token_usage":return s.jsx(L9,{p:t});default:return s.jsx("pre",{className:zo,children:JSON.stringify(t,null,2)})}}function $9({msg:e,rowKey:t,matched:a,onHighlight:l}){const[o,c]=y.useState(!1),u=e.payload.type??e.type,f=I9(e);return s.jsxs("li",{"data-trace-row":t,children:[s.jsxs("button",{type:"button",onClick:()=>c(p=>!p),onMouseEnter:()=>l?.({ts:e.timestamp,rowKey:t}),onMouseLeave:()=>l?.(null),className:`flex w-full items-center gap-2 px-3 py-1.5 text-left transition-colors duration-150 ${a?"bg-amber-50 dark:bg-amber-950/40":"hover:bg-gray-50 dark:hover:bg-gray-800/50"}`,children:[s.jsx("span",{className:"shrink-0 font-mono text-[11px] text-gray-400",children:qT(e.timestamp)}),s.jsx(R9,{type:u}),s.jsx(gn,{tone:M9(e.type),children:u}),e.origin&&e.origin.length>0&&s.jsx(gn,{tone:"brand",children:"origin"}),s.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-xs text-gray-500 dark:text-gray-400",children:_9(e)})]}),o&&s.jsxs("div",{className:"border-t border-gray-100 bg-gray-50/60 px-3 py-2 dark:border-gray-800 dark:bg-gray-900/40",children:[s.jsx(U9,{msg:e}),f&&s.jsx("div",{className:"mt-1.5 flex justify-end",children:s.jsx(gn,{tone:JT(f),children:f})})]})]})}const ok=()=>({cacheRead:0,cacheWrite:0,output:0}),P9=2500,ck=(e,t)=>`${e}-${t}`;function Yr({label:e,value:t}){return s.jsxs("div",{className:"flex items-baseline justify-between gap-3 py-0.5",children:[s.jsx("span",{className:"shrink-0 text-[11px] text-gray-400",children:e}),s.jsx("span",{className:"truncate font-mono text-sm font-semibold tabular-nums",children:t})]})}const ZS=e=>e.cacheRead+e.cacheWrite,JS=e=>jw(e.cacheRead,e.cacheWrite),ej="flex shrink-0 items-center font-mono text-[11px] tabular-nums text-gray-500 dark:text-gray-400";function Ro({icon:e,value:t,label:a}){return s.jsxs("span",{title:a,"aria-label":a,className:`${ej} gap-1`,children:[s.jsx(qe,{d:e,className:"text-gray-400"}),t]})}function B9({buckets:e}){const t=ZS(e),a=`${m.traces.cacheHit} ${Ct(e.cacheRead)} · ${m.traces.hitRate} ${ng(JS(e))}`;return s.jsxs("span",{"aria-label":`${m.traces.taskInput} ${Ct(t)} · ${a}`,className:ej,children:[s.jsxs("span",{title:m.traces.taskInput,className:"flex items-center gap-1",children:[s.jsx(qe,{d:Un.input,className:"text-gray-400"}),Ct(t)]}),s.jsxs("span",{title:a,className:"ml-1 flex items-center gap-0.5 text-gray-400",children:[s.jsx("span",{children:"("}),s.jsx(qe,{d:Un.cacheHit}),s.jsx("span",{children:Ct(e.cacheRead)}),s.jsx("span",{children:")"})]})]})}function H9({projectId:e,agentId:t,sessionId:a,index:l,highlight:o,onHighlight:c}){const{currency:u}=Ps(),[f,p]=y.useState(null),[h,g]=y.useState([]),[v,k]=y.useState(0),[w,j]=y.useState(0),[E,C]=y.useState(null),[M,_]=y.useState(null),[D,V]=y.useState(new Set),[F,A]=y.useState(null),P=y.useRef(null),Q=y.useRef(null);y.useEffect(()=>()=>{Q.current&&clearTimeout(Q.current)},[]),y.useEffect(()=>{p(null),g([]),_(null),V(new Set),A(null);let R=!1;return Promise.all([kN(e,t,a,l),bN(e,t,a,l,0,1e3),mi(e).catch(()=>null)]).then(([H,S,U])=>{R||(p(H),g(S.events),k(S.offset),j(S.total),C(U))}).catch(H=>{R||_(Ie(H))}),()=>{R=!0}},[e,t,a,l]);const K=y.useMemo(()=>{const R=h.find(S=>S.type==="session_meta"),H=R?R.payload:void 0;if(!(!H?.model_id||!H.provider))return E?.models.find(S=>S.modelId===H.model_id&&S.provider===H.provider)?.pricing},[h,E]),O=R=>K?(R.cacheRead*K.cacheRead+R.cacheWrite*K.cacheWrite+R.output*K.output)/1e6:null,z=y.useMemo(()=>{const R=h.find(H=>H.type==="session_meta");return cS(R?R.payload.model_context_window:void 0)},[h]),{tasks:I,global:B,statsByTask:$,globalLlmMs:G}=y.useMemo(()=>{const R={buckets:ok(),toolCalls:0},H=new Map;if(!f)return{tasks:[],global:R,statsByTask:H,globalLlmMs:0};const S=new Map;for(const te of f.tasks){const be=Date.parse(te.startTs),Re=Date.parse(te.endTs);Number.isFinite(be)&&Number.isFinite(Re)&&S.set(te.taskIndex,{min:be,max:Re})}const U=new Map,ee=te=>{let be=U.get(te);if(!be){const Re=S.get(te);be={taskIndex:te,segments:[],spans:[],otherSpans:[],messages:[],toolCalls:0,durationMs:Re?Math.max(0,Re.max-Re.min):0},U.set(te,be)}return be};for(const te of f.tasks)ee(te.taskIndex);for(const te of f.modelSegments)ee(te.taskIndex).segments.push(te);for(const te of f.toolSpans){const be=ee(te.taskIndex);be.spans.push(te),be.toolCalls+=1}for(const te of f.otherSpans??[])ee(te.taskIndex).otherSpans.push(te);const ie=te=>{for(const be of f.tasks)if(te>=be.messageFrom&&te<=be.messageTo)return be.taskIndex;return null};for(let te=0;te<h.length;te++){const be=h[te];if(be.origin&&be.origin.length>0)continue;const Re=ie(v+te);Re!==null&&ee(Re).messages.push(be)}R.toolCalls=f.toolSpans.length;const de=new Map(f.tasks.map(te=>[te.taskIndex,te]));for(const te of f.tasks)R.buckets.cacheRead+=te.tokens.cacheRead,R.buckets.cacheWrite+=te.tokens.cacheWrite,R.buckets.output+=te.tokens.output;const me=f.tasks.reduce((te,be)=>te+be.llmMs,0);return{tasks:[...U.values()].sort((te,be)=>te.taskIndex-be.taskIndex),global:R,statsByTask:de,globalLlmMs:me}},[f,h,v]);if(M)return s.jsx("p",{className:"text-xs text-red-600 dark:text-red-400",children:M});if(!f)return s.jsx(en,{className:"h-40"});const q=f.elapsedMs,ae=R=>V(H=>{const S=new Set(H);return S.has(R)?S.delete(R):S.add(R),S}),Z=R=>{for(const H of I){const S=H.messages.findIndex(U=>U.timestamp===R);if(S>=0)return ck(H.taskIndex,S)}return null},X=o?.rowKey??(o?.ts!==void 0?Z(o.ts):null),T=R=>{const H=Z(R);H!==null&&(A(H),requestAnimationFrame(()=>{P.current?.querySelector(`[data-trace-row="${H}"]`)?.scrollIntoView({block:"center",behavior:"smooth"})}),Q.current&&clearTimeout(Q.current),Q.current=setTimeout(()=>A(null),P9))};return s.jsxs("div",{ref:P,className:"space-y-4",children:[s.jsxs("div",{className:"rounded-md border border-gray-200 p-3 dark:border-gray-800",children:[s.jsx("p",{className:"mb-2 text-xs font-semibold text-gray-500",children:m.traces.globalSummary}),s.jsxs("div",{className:"grid grid-cols-1 gap-x-8 gap-y-4 sm:grid-cols-3",children:[s.jsxs("div",{children:[s.jsx(Yr,{label:m.traces.tasksLabel,value:String(f.tasks.length)}),s.jsx(Yr,{label:m.traces.toolCalls,value:String(B.toolCalls)}),s.jsx(Yr,{label:m.traces.compactions,value:String(f.compactionCount)})]}),s.jsxs("div",{children:[s.jsx(Yr,{label:m.chat.statInput,value:Ct(ZS(B.buckets))}),s.jsx(Yr,{label:m.traces.cacheHit,value:`${Ct(B.buckets.cacheRead)} · ${ng(JS(B.buckets))}`}),s.jsx(Yr,{label:m.chat.statOutput,value:Ct(B.buckets.output)})]}),s.jsxs("div",{children:[s.jsx(Yr,{label:m.common.cost,value:hr(O(B.buckets),u)}),s.jsx(Yr,{label:m.chat.statElapsed,value:hn(Math.max(0,q))}),s.jsx(Yr,{label:m.chat.statTps,value:ad(eh(B.buckets.output,G))})]})]})]}),I.map(R=>{const H=!D.has(R.taskIndex),S=$.get(R.taskIndex),U=S?.context,ee=S?.tokens??ok();return s.jsxs("div",{className:"overflow-hidden rounded-md border border-gray-200 dark:border-gray-800",children:[s.jsxs("button",{type:"button",onClick:()=>ae(R.taskIndex),"aria-expanded":H,className:"flex w-full items-center gap-2 bg-gray-50 px-3 py-2 text-left transition-colors duration-150 hover:bg-gray-100 dark:bg-gray-900 dark:hover:bg-gray-800/60",children:[s.jsx($n,{open:H,size:13,className:"text-gray-400"}),s.jsx("span",{className:"shrink-0 text-sm font-semibold",children:m.traces.task(R.taskIndex+1)}),S?.compaction===!0&&s.jsx("span",{className:"shrink-0 rounded bg-gray-100 px-1.5 py-0.5 text-[10px] font-medium text-gray-500 dark:bg-gray-800 dark:text-gray-400",children:m.traces.compactionRound}),s.jsx("span",{className:"min-w-0 flex-1"}),s.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-x-3 gap-y-1",children:[s.jsx(Ro,{icon:Un.toolCalls,value:String(R.toolCalls),label:m.traces.toolCalls}),s.jsx(B9,{buckets:ee}),s.jsx(Ro,{icon:Un.output,value:Ct(ee.output),label:m.traces.taskOutput}),s.jsx(Ro,{icon:Un.cost,value:hr(O(ee),u),label:`${m.common.cost}(${u})`}),s.jsx(Ro,{icon:Un.elapsed,value:hn(R.durationMs),label:m.chat.statElapsed}),s.jsx(Ro,{icon:Un.tps,value:ad(eh(ee.output,S?.llmMs??0)),label:m.chat.statTps})]}),U&&s.jsx(v9,{cacheRead:U.cacheRead,cacheWrite:U.cacheWrite,output:U.output,max:z,size:22})]}),H&&s.jsxs("div",{className:"space-y-3 p-3",children:[(R.segments.length>0||R.spans.length>0||R.otherSpans.length>0)&&s.jsxs("div",{className:"rounded-md border border-gray-100 p-2 dark:border-gray-800/60",children:[s.jsx("p",{className:"mb-1.5 text-[11px] font-medium text-gray-500",children:m.traces.timeline}),s.jsx(T9,{segments:R.segments,toolSpans:R.spans,otherSpans:R.otherSpans,highlight:o,onHighlight:c,onJump:T,hideTaskLabel:!0})]}),s.jsxs("div",{children:[s.jsxs("p",{className:"mb-1.5 text-[11px] font-medium text-gray-500",children:[m.traces.messages,"(",R.messages.length,")"]}),R.messages.length===0?s.jsx("p",{className:"text-xs text-gray-400",children:m.common.none}):s.jsx("ul",{className:"divide-y divide-gray-100 rounded-md border border-gray-200 dark:divide-gray-800/60 dark:border-gray-800",children:R.messages.map((ie,de)=>{const me=ck(R.taskIndex,de);return s.jsx($9,{msg:ie,rowKey:me,matched:me===X||me===F,onHighlight:ye=>c(ye)},de)})})]})]})]},R.taskIndex)}),h.length<w&&s.jsx("p",{className:"text-xs text-gray-400",children:m.traces.truncatedNote(h.length,w)})]})}const Go=20,_o=15;function tj(e){if(e.sessions)return e.sessions.map(a=>({sessionId:a.sessionId,...a.title!==void 0?{title:a.title}:{},category:a.category,workspace:a.workspace,files:[...a.files].sort((l,o)=>o.index-l.index)}));const t=new Map;for(const a of e.dates)for(const l of a.sessions){const o=t.get(l.sessionId)??[];for(const c of l.files)o.push({index:c.index,date:a.date,sizeBytes:c.sizeBytes});t.set(l.sessionId,o)}return[...t.entries()].sort((a,l)=>l[0].localeCompare(a[0])).map(([a,l])=>({sessionId:a,category:"active",workspace:"",files:l.sort((o,c)=>c.index-o.index)}))}function uk(e){const t={active:[],subagent:[],schedule:[],archived:[]};for(const a of e)t[a.category].push(a);return t}const Ya=(e,t)=>`${e}\0${t}`;function F9(e,t=!1){const[a,l]=y.useState(new Map),[o,c]=y.useState(new Map),[u,f]=y.useState(new Map),[p,h]=y.useState(new Map),[g,v]=y.useState(new Map),[k,w]=y.useState(new Set),j=y.useRef(0),E=y.useRef(new Set),C=y.useRef(o);C.current=o;const M=y.useRef(u);M.current=u,y.useEffect(()=>{j.current+=1,E.current.clear();const O=new Map;C.current=O,l(new Map),c(O),f(new Map),h(new Map),v(new Map),w(new Set)},[e,t]);const _=y.useCallback(async(O,z,I,B)=>{const $=await Rk(O,z,{offset:B,limit:Go+1,category:I,...t?{cli:!0}:{}}),G=Qp(tj($),Go);return{agentId:z,category:I,items:G.items.map(q=>({...q,agentId:z})),hasMore:G.hasMore,...$.counts!==void 0?{counts:$.counts}:{},...$.workspaceCounts!==void 0?{workspaceCounts:$.workspaceCounts}:{}}},[t]),D=y.useCallback((O,z)=>{l(I=>{const B=new Map(I);if(z!==void 0)for(const[$,G]of I)G.agentId===z&&B.delete($);for(const $ of O)for(const G of $.items)B.set(G.sessionId,G);return B}),c(I=>{const B=new Map(I);if(z!==void 0)for(const $ of I.keys())$.startsWith(`${z}\0`)&&B.delete($);for(const $ of O){const G=Ya($.agentId,$.category);B.set(G,{hasMore:$.hasMore,fetched:(z===void 0?I.get(G)?.fetched??0:0)+$.items.length})}return B});for(const I of O)I.counts&&f(B=>new Map(B).set(I.agentId,I.counts)),I.workspaceCounts&&h(B=>new Map(B).set(I.agentId,I.workspaceCounts))},[]),V=y.useCallback(O=>{if(!e)return;const z=[...new Set(O)].filter(B=>{const $=Ya(B,"active");return!C.current.has($)&&!E.current.has($)});if(z.length===0)return;const I=j.current;for(const B of z)E.current.add(Ya(B,"active"));w(B=>{const $=new Set(B);for(const G of z)$.add(Ya(G,"active"));return $}),v(B=>{if(!z.some(G=>B.has(G)))return B;const $=new Map(B);for(const G of z)$.delete(G);return $}),Promise.all(z.map(async B=>{try{return await _(e,B,"active",0)}catch($){return I===j.current&&v(G=>new Map(G).set(B,Ie($))),null}})).then(B=>{for(const $ of z)E.current.delete(Ya($,"active"));w($=>{const G=new Set($);for(const q of z)G.delete(Ya(q,"active"));return G}),I===j.current&&D(B.filter($=>$!==null))})},[e,_,D]),F=y.useCallback(async(O,z)=>{if(!e)return;const I=[...new Set(O)].filter(G=>{const q=C.current.get(Ya(G,z));return q===void 0?(M.current.get(G)?.[z]??0)>0:q.hasMore});if(I.length===0)return;const B=j.current,$=await Promise.all(I.map(async G=>{const q=C.current.get(Ya(G,z))?.fetched??0;try{return await _(e,G,z,q)}catch{return null}}));B===j.current&&D($.filter(G=>G!==null))},[e,_,D]),A=y.useCallback(async O=>{if(!e)return;const z=["active",...lc.filter($=>C.current.has(Ya(O,$)))],I=j.current,B=await Promise.all(z.map(async $=>{try{return await _(e,O,$,0)}catch{return null}}));I===j.current&&D(B.filter($=>$!==null),O)},[e,_,D]),P=y.useCallback((O,z)=>o.has(Ya(O,z)),[o]),Q=y.useCallback((O,z)=>k.has(Ya(O,z)),[k]),K=y.useCallback((O,z)=>{const I=o.get(Ya(O,z));return I!==void 0?I.hasMore:(u.get(O)?.[z]??0)>0},[o,u]);return y.useMemo(()=>{const O=new Map;for(const I of a.values()){const B=O.get(I.agentId);B?B.push(I):O.set(I.agentId,[I])}for(const I of O.values())I.sort((B,$)=>$.sessionId.localeCompare(B.sessionId));const z=[...O.values()].flat();return{rowsByAgent:O,allRows:z,countsByAgent:u,workspaceCountsByAgent:p,errorByAgent:g,isLoadedFor:P,isPendingFor:Q,hasMoreFor:K,ensureFirstFor:V,loadMoreFor:F,refreshAgent:A}},[a,u,p,g,P,Q,K,V,F,A])}const q9=14*1024*1024,Hp=10,dk=(e,t)=>`${t}\0${e}`;function V9(){Er(m.traces.title);const{currentProject:e,agents:t,agentsLoading:a}=Xt(),{byAgent:l,showCliSessions:o}=Bs(),c=e?.projectId??null,u=F9(c,o),[f]=Ed(),p=f.get("agentId"),h=f.get("sessionId"),[g,v]=y.useState(pw),k=p!==null?"agent":g,[w,j]=y.useState(null),[E,C]=y.useState(null),[M,_]=y.useState(_o),[D,V]=y.useState(new Map),[F,A]=y.useState(null),[P,Q]=y.useState(new Set),[K,O]=y.useState(new Set),[z,I]=y.useState(new Set),[B,$]=y.useState(!1),[G,q]=y.useState(""),[ae,Z]=y.useState(null),[X,T]=y.useState(!1),[R,H]=y.useState(null),S=y.useRef(null),U=W=>{hw(W),v(W),_(_o)};y.useEffect(()=>{j(null),C(null),_(_o),V(new Map),A(null),Q(new Set),O(new Set)},[c]),y.useEffect(()=>{H(null)},[w,E]),y.useEffect(()=>{T(!1)},[w]);const ee=y.useMemo(()=>{const W=new Map;for(const ge of l.values())for(const Ne of ge)Ne.title!==void 0&&W.set(Ne.sessionId,Ne.title);return W},[l]),ie=y.useCallback((W,ge)=>ee.get(W)??ge??m.chat.defaultSessionTitle,[ee]),de=y.useMemo(()=>new Map(t.map(W=>[W.agentId,tn(W)])),[t]),me=y.useMemo(()=>Xp(t,W=>W.agentId,new Set(p===null?[]:[p])),[t,p]),ye=y.useMemo(()=>{if(F!==null)return F;const W=p??me[0]?.agentId;return new Set(W===void 0?[]:[W])},[F,p,me]),te=W=>{const ge=new Set(ye);ge.has(W)?ge.delete(W):ge.add(W),A(ge)},be=W=>{Q(ge=>{const Ne=new Set(ge);return Ne.has(W)?Ne.delete(W):Ne.add(W),Ne})},Re=u.ensureFirstFor;y.useEffect(()=>{if(!c||k!=="agent")return;const W=me.slice(0,M).map(ge=>ge.agentId).filter(ge=>ye.has(ge));W.length>0&&Re(W)},[c,k,me,M,ye,Re]),y.useEffect(()=>{!c||k!=="workspace"||t.length===0||Re(t.map(W=>W.agentId))},[c,k,t,Re]);const Fe=y.useMemo(()=>cw(u.allRows.map(W=>({...W,createdAt:W.sessionId}))),[u.allRows]),ce=y.useMemo(()=>iw(u.workspaceCountsByAgent),[u.workspaceCountsByAgent]),Ve=y.useCallback(W=>{j({agentId:W.agentId,sessionId:W.sessionId,...W.title!==void 0?{title:W.title}:{},files:W.files}),C(W.files[0]?.index??null)},[]),je=y.useCallback((W,ge)=>{c&&Rk(c,W).then(Ne=>{const Te=tj(Ne).find(Pe=>Pe.sessionId===ge);Te&&Ve({...Te,agentId:W})}).catch(()=>{})},[c,Ve]),wt=y.useRef(!1);y.useEffect(()=>{if(wt.current||!h||!p||!u.isLoadedFor(p,"active"))return;wt.current=!0;const W=u.rowsByAgent.get(p)?.find(ge=>ge.sessionId===h);W?Ve(W):je(p,h)},[u,h,p,Ve,je]),y.useEffect(()=>{const W=S.current;if(W===null)return;const ge=u.rowsByAgent.get(W.agentId);if(ge===void 0)return;S.current=null;const Ne=ge.find(Te=>Te.sessionId===W.sessionId);Ne?Ve(Ne):je(W.agentId,W.sessionId)},[u,Ve,je]);const an=async(W,ge)=>{if(c){Z(W);try{const Ne=await SN(c,W,{dataBase64:ge});S.current={agentId:W,sessionId:Ne.sessionId},ye.has(W)||te(W),await u.refreshAgent(W)}catch(Ne){Qe(Ie(Ne))}finally{Z(null)}}},rn=W=>{const ge=G,Ne=W.target.files?.[0];if(W.target.value="",!Ne||ge==="")return;if(Ne.size>q9){Qe(m.traces.fileTooLarge);return}$(!1);const Te=new FileReader;Te.onload=()=>{const Pe=Te.result;an(ge,Pe.slice(Pe.indexOf(",")+1))},Te.onerror=()=>Qe(m.common.unknownError),Te.readAsDataURL(Ne)},sn=()=>{q(p??me[0]?.agentId??""),$(!0)},Ut=(W,ge)=>`${ge}\0${W}`,At=(W,ge,Ne)=>{const Te=Ut(W,ge);I(Pe=>new Set(Pe).add(Te)),u.loadMoreFor(Ne,ge).finally(()=>{I(Pe=>{const We=new Set(Pe);return We.delete(Te),We})})},fn=(W,ge,Ne)=>{const Te=dk(W,ge),Pe=!K.has(Te);if(O(We=>{const tt=new Set(We);return Pe?tt.add(Te):tt.delete(Te),tt}),Pe){const We=Ne.filter(tt=>!u.isLoadedFor(tt,ge));We.length>0&&u.loadMoreFor(We,ge)}},st=(W,ge)=>s.jsx("ul",{className:"space-y-0.5",children:W.map(Ne=>{const Te=w?.sessionId===Ne.sessionId,Pe=de.get(Ne.agentId)??Ne.agentId;return s.jsx("li",{children:s.jsxs("button",{type:"button",onClick:()=>Ve(Ne),className:`flex w-full items-center gap-1.5 rounded-md px-2.5 py-1.5 text-left transition-colors duration-150 ${Te?"bg-gray-200/70 dark:bg-gray-800":"hover:bg-gray-200/50 dark:hover:bg-gray-800/70"}`,children:[ge&&s.jsxs("span",{title:Pe,className:"flex shrink-0 items-center",children:[s.jsx(xa,{id:Ne.agentId,name:Pe,size:14,className:"rounded"}),s.jsx("span",{className:"sr-only",children:Pe})]}),s.jsx(ic,{text:ie(Ne.sessionId,Ne.title),className:`min-w-0 flex-1 text-sm ${Te?"font-medium text-gray-900 dark:text-gray-100":"text-gray-700 dark:text-gray-300"}`}),s.jsx("span",{className:"shrink-0 font-mono text-[11px] text-gray-400",children:Ne.files.length})]})},Ne.sessionId)})}),nn=(W,ge,Ne,Te,Pe,We)=>{const tt=Ne[ge],it=Math.max(We?.[ge]??0,tt.length);if(it===0)return null;const Ce=tt.length<it&&Pe.some(Oe=>u.hasMoreFor(Oe,ge));return s.jsx(yw,{label:m.chat.folderGroups[ge](it),open:K.has(dk(W,ge)),onToggle:()=>fn(W,ge,Pe),more:Ce,pending:z.has(Ut(W,ge)),onMore:()=>At(W,ge,Pe),children:st(tt,Te)},ge)},pe=(W,ge)=>{V(Ne=>{const Te=new Map(Ne);return Te.set(W,(Ne.get(W)??Go)+Go),Te}),ge.length>0&&At(W,"active",ge)},Se=(W,ge,Ne,Te,Pe,We)=>{const tt=uk(ge),it=D.get(W)??Go,Ce=tt.active.slice(0,it),Oe=Pe("active"),Ke=Math.max(Te?.active??0,tt.active.length),vt=tt.active.length>it||tt.active.length<Ke&&Oe.some($t=>u.hasMoreFor($t,"active")),xt=lc.map($t=>nn(W,$t,tt,Ne,Pe($t),Te)),St=tt.active.length===0&&xt.every($t=>$t===null),ln=z.has(Ut(W,"active"));return s.jsxs(s.Fragment,{children:[St?s.jsx("p",{className:"px-2.5 py-1 text-xs text-gray-400 dark:text-gray-600",children:We}):st(Ce,Ne),vt&&s.jsx(fi,{label:m.chat.loadMore,pending:ln,onClick:()=>pe(W,Oe),className:"mt-0.5"}),xt]})};if(!c)return null;const De=w===null?null:w.files.find(W=>W.index===E)??w.files[0]??null,ze=w===null||X?null:w.files.slice(0,Hp),Ue=u.allRows.length===0&&t.some(W=>u.isPendingFor(W.agentId,"active"));return s.jsxs("div",{className:"flex h-full flex-col md:flex-row",children:[s.jsxs("aside",{className:"relative max-h-52 shrink-0 overflow-y-auto border-b border-gray-200 bg-gray-50 px-1 py-2 md:max-h-none md:w-72 md:border-b-0 md:border-r dark:border-gray-800 dark:bg-gray-900",children:[s.jsxs("div",{className:"flex items-center justify-between px-3 pb-1",children:[s.jsx("p",{className:"text-xs font-bold uppercase tracking-wide text-gray-500",children:m.traces.title}),s.jsxs("div",{className:"flex items-center gap-0.5",children:[e?.role==="owner"&&s.jsx("button",{type:"button",title:ae!==null?m.traces.importing:m.traces.importTrace,"aria-label":ae!==null?m.traces.importing:m.traces.importTrace,disabled:ae!==null,onClick:sn,className:"flex h-6 w-6 shrink-0 items-center justify-center rounded-md text-gray-400 transition-colors duration-150 hover:bg-gray-200/50 hover:text-gray-700 disabled:opacity-60 dark:text-gray-500 dark:hover:bg-gray-800/70 dark:hover:text-gray-300",children:s.jsx(Yv,{size:14})}),p===null&&s.jsx(gw,{value:g,onChange:U})]})]}),a||k==="workspace"&&Ue?s.jsx(pa,{rows:4}):k==="agent"?s.jsxs(s.Fragment,{children:[me.slice(0,M).map(W=>{const ge=ye.has(W.agentId),Ne=tn(W),Te=u.errorByAgent.get(W.agentId),Pe=u.isLoadedFor(W.agentId,"active");return s.jsxs("div",{className:"pt-2.5",children:[s.jsx(Uo,{open:ge,onToggle:()=>te(W.agentId),icon:s.jsx(xa,{id:W.agentId,name:Ne,size:18,className:"shrink-0 rounded"}),label:Ne,uppercase:!0}),ge&&s.jsxs("div",{className:"anim-fade",children:[Te!==void 0&&s.jsx("p",{className:"px-2.5 py-1 text-xs text-red-500",children:Te}),!Pe&&Te===void 0&&s.jsx("p",{className:"px-2.5 py-1 text-xs text-gray-400",children:m.common.loading}),Pe&&Se(W.agentId,u.rowsByAgent.get(W.agentId)??[],!1,u.countsByAgent.get(W.agentId),()=>[W.agentId],m.traces.empty)]})]},W.agentId)}),me.length>M&&s.jsx(fi,{label:m.chat.moreGroups(me.length-M),onClick:()=>_(W=>W+_o),className:"mt-1"})]}):Fe.length===0?s.jsx("p",{className:"px-2.5 pt-3 text-xs text-gray-400 dark:text-gray-600",children:m.chat.noSessions}):s.jsxs(s.Fragment,{children:[Fe.slice(0,M).map(W=>{const ge=P.has(W.key),Ne=uk(W.sessions),Te=ce.get(W.key),Pe=[...new Set(W.sessions.map(tt=>tt.agentId))],We=tt=>[...new Set([...Te?.agents[tt]??[],...Pe])];return s.jsxs("div",{className:"pt-2.5",children:[s.jsx(Uo,{open:!ge,onToggle:()=>be(W.key),icon:s.jsx("span",{className:"shrink-0 text-gray-400 dark:text-gray-500",children:s.jsx(Jn,{d:ge?eg:dw,size:15})}),label:W.temp?m.chat.tempWorkspaces:W.label,count:Math.max(Te?.totals.active??0,Ne.active.length),...W.fullPath!==null?{title:W.fullPath}:{}}),ge?null:Se(W.key,W.sessions,!0,Te?.totals,We,m.chat.noSessions)]},W.key)}),Fe.length>M&&s.jsx(fi,{label:m.chat.moreGroups(Fe.length-M),onClick:()=>_(W=>W+_o),className:"mt-1"})]})]}),s.jsx("section",{className:"min-w-0 flex-1 overflow-y-auto p-3 md:p-4",children:w&&De?s.jsxs("div",{className:"mx-auto max-w-4xl space-y-4",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsx("p",{className:"min-w-0 flex-1 truncate text-sm font-semibold",children:ie(w.sessionId,w.title)}),s.jsxs("div",{className:"flex flex-wrap items-center gap-1",children:[s.jsx("span",{className:"mr-1 text-xs text-gray-400",children:m.traces.filesTitle}),(ze??w.files).map(W=>s.jsxs("button",{type:"button",onClick:()=>C(W.index),title:`${W.date} · ${Xo(W.sizeBytes)}`,className:`rounded-md border px-2 py-0.5 font-mono text-xs transition-colors duration-150 ${W.index===De.index?"border-gray-400 bg-gray-200/70 font-semibold text-gray-900 dark:border-gray-600 dark:bg-gray-800 dark:text-gray-100":"border-gray-200 text-gray-500 hover:bg-gray-100 dark:border-gray-800 dark:text-gray-400 dark:hover:bg-gray-800/60"}`,children:["#",String(W.index).padStart(3,"0")]},W.index)),ze!==null&&w.files.length>Hp&&s.jsxs("button",{type:"button",title:m.chat.loadMore,"aria-label":m.chat.loadMore,onClick:()=>T(!0),className:"rounded-md border border-gray-200 px-2 py-0.5 font-mono text-xs text-gray-500 transition-colors duration-150 hover:bg-gray-100 dark:border-gray-800 dark:text-gray-400 dark:hover:bg-gray-800/60",children:["+",w.files.length-Hp]})]})]}),s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsxs("p",{className:"min-w-0 flex-1 truncate font-mono text-xs text-gray-400",children:[De.date," · ",Xo(De.sizeBytes)]}),s.jsxs("a",{href:wN(c,w.agentId,w.sessionId,De.index),download:!0,className:"inline-flex shrink-0 items-center gap-1 rounded-md border border-gray-200 px-2 py-0.5 text-xs text-gray-500 transition-colors duration-150 hover:bg-gray-100 dark:border-gray-800 dark:text-gray-400 dark:hover:bg-gray-800/60",children:[s.jsx(bw,{size:12}),m.traces.exportFile]})]}),s.jsx(H9,{projectId:c,agentId:w.agentId,sessionId:w.sessionId,index:De.index,highlight:R,onHighlight:H})]}):s.jsx(Nr,{title:m.traces.selectSession})}),s.jsx(Gt,{open:B,title:m.traces.importTrace,onClose:()=>$(!1),children:s.jsxs("div",{className:"space-y-4",children:[s.jsx(Ds,{label:m.traces.importAgent,value:G,onChange:W=>q(W.target.value),children:t.map(W=>s.jsx("option",{value:W.agentId,children:tn(W)},W.agentId))}),s.jsx("div",{className:"flex justify-end",children:s.jsxs("label",{className:"inline-flex cursor-pointer items-center justify-center gap-1 rounded-md border border-[var(--accent-bg)] bg-[var(--accent-bg)] px-3 py-1.5 text-sm font-medium text-[var(--accent-fg)] transition-opacity hover:opacity-90",children:[s.jsx(Hd,{accept:".jsonl",onChange:rn}),s.jsx(Yv,{size:14}),m.traces.importPickFile]})})]})})]})}function nj(e){return e.map(t=>typeof t.score=="number"&&Number.isFinite(t.score)?t.score:null)}const Wu=0,Ku=100,fk=10,G9=[1,2,2.5,5,10,20];function W9(e){const t=e.filter(g=>g!==null&&g>=Wu&&g<=Ku);if(t.length===0)return{min:Wu,max:Ku,ticks:[0,20,40,60,80,100]};const a=Math.min(...t),l=Math.max(...t),o=Math.max(Wu,a-fk),c=Math.min(Ku,l+fk),u=G9.find(g=>(c-o)/g<=5),f=Math.max(Wu,Math.floor(o/u)*u),p=Math.min(Ku,Math.ceil(c/u)*u),h=Array.from({length:Math.round((p-f)/u)+1},(g,v)=>f+v*u);return{min:f,max:p,ticks:h}}function K9(e){const t=[];let a=[];return e.forEach((l,o)=>{if(l===null){a.length>0&&t.push(a),a=[];return}a.push({index:o,value:l})}),a.length>0&&t.push(a),t}function Y9(e){const t=new Map;e.forEach((l,o)=>{const c=l.modelId!==void 0&&l.modelId!=="",u=c?`${l.modelId}\0${l.thinkingLevel??""}`:"";let f=t.get(u);f||(f={key:u,...c&&l.modelId!==void 0?{modelId:l.modelId}:{},...c&&l.thinkingLevel!==void 0?{thinkingLevel:l.thinkingLevel}:{},indices:[]},t.set(u,f)),f.indices.push(o)});const a=[...t.values()];return[...a.filter(l=>l.key!==""),...a.filter(l=>l.key==="")]}function Q9(e,t){const a=new Set(t.indices);return nj(e).map((l,o)=>a.has(o)?l:null)}const X9=new Set(["txt","md","json","js","mjs","cjs","ts","tsx","jsx","py","sh","bash","yaml","yml","toml","css","html","htm","csv","log","xml","ini","conf","sql","svg"]),Z9=new Set(["png","jpg","jpeg","gif","webp"]),mk=/^[a-z][a-z0-9+.-]*:/i,J9=64*1024;function aj(e){const t=e.lastIndexOf(".");return t>=0?e.slice(t+1).toLowerCase():e.toLowerCase()}function pk(e){return e.includes("/")?e.slice(0,e.lastIndexOf("/")):""}function hk(e,t){const a=t.startsWith("/")||e===""?[]:e.split("/");for(const l of t.split("/"))l===""||l==="."||(l===".."?a.pop():a.push(l));return a.join("/")}function ez(e){const t=aj(e);return{json:"json",md:"markdown",js:"javascript",mjs:"javascript",cjs:"javascript",jsx:"jsx",ts:"typescript",tsx:"tsx",py:"python",sh:"shellscript",bash:"shellscript",yaml:"yaml",yml:"yaml",toml:"toml",css:"css",html:"html",htm:"html",xml:"xml",sql:"sql",svg:"xml"}[t]??"text"}function gk({projectId:e,agentId:t,benchmarkId:a,caseSummary:l,material:o,label:c,hiddenLabel:u,defaultOpen:f=!1,autoPreviewReadme:p=!1,onPreview:h}){const[g,v]=y.useState(f),[k,w]=y.useState(""),[j,E]=y.useState(null),[C,M]=y.useState(null),_=y.useRef(!1);y.useEffect(()=>{if(!g)return;E(null),M(null);let F=!1;return zN(e,t,a,l.id,k,o).then(A=>{if(!F&&(E({base:k,res:A}),p&&k===""&&!_.current)){_.current=!0;const P=A.entries.find(Q=>Q.kind==="file"&&Q.name.toLowerCase()==="readme.md");P&&h(o,P.name)}}).catch(A=>{F||M(Ie(A))}),()=>{F=!0}},[e,t,a,l.id,o,p,h,g,k]);const D=k===""?[]:k.split("/"),V=F=>{if(j===null)return;const A=Ju(j.base,F.name);if(F.kind==="dir"){w(A);return}h(o,A)};return s.jsxs("div",{className:"border-b border-gray-200 last:border-b-0 dark:border-gray-800",children:[s.jsxs("button",{type:"button","aria-expanded":g,onClick:()=>v(F=>!F),className:"flex w-full items-center gap-2 px-3 py-2 text-left hover:bg-gray-100 dark:hover:bg-gray-800/60",children:[s.jsx("span",{className:"text-xs text-gray-400",children:g?"▾":"▸"}),s.jsx("span",{className:"min-w-0 flex-1 text-sm font-medium",children:c}),u&&s.jsx("span",{className:"shrink-0 rounded bg-gray-200/70 px-1.5 py-0.5 text-[10px] text-gray-500 dark:bg-gray-800 dark:text-gray-400",children:u})]}),g&&s.jsxs("div",{children:[D.length>0&&s.jsxs("div",{className:"flex flex-wrap items-center gap-1 border-t border-gray-100 px-5 py-1.5 dark:border-gray-800/70",children:[s.jsx("button",{type:"button",onClick:()=>w(""),className:"rounded px-1 py-0.5 text-xs text-gray-500 hover:bg-gray-100 dark:hover:bg-gray-800",children:c}),D.map((F,A)=>s.jsxs("span",{className:"flex min-w-0 items-center gap-1",children:[s.jsx("span",{className:"text-gray-300 dark:text-gray-700",children:"/"}),s.jsx("button",{type:"button",onClick:()=>w(D.slice(0,A+1).join("/")),className:"max-w-24 truncate rounded px-1 py-0.5 text-xs text-gray-500 hover:bg-gray-100 dark:hover:bg-gray-800",children:F})]},`${F}-${A}`))]}),C&&s.jsx("p",{className:"px-6 py-2 text-xs text-red-500",children:C}),!j&&!C&&s.jsx(pa,{rows:3}),j?.res.entries.length===0&&s.jsx("p",{className:"px-6 py-2 text-xs text-gray-400",children:m.files.empty}),j?.res.entries.map(F=>s.jsxs("button",{type:"button",onClick:()=>V(F),className:"flex w-full items-center gap-2 border-t border-gray-100 px-6 py-2 text-left hover:bg-gray-100 dark:border-gray-800/70 dark:hover:bg-gray-800/60",children:[s.jsx("span",{className:"text-sm text-gray-400",children:F.kind==="dir"?"▸":"·"}),s.jsx("span",{className:"min-w-0 flex-1 truncate text-sm",children:F.name}),F.kind==="file"&&s.jsx("span",{className:"shrink-0 text-[11px] text-gray-400",children:Xo(F.sizeBytes)})]},`${F.kind}/${F.name}`))]})]})}function tz({projectId:e,agentId:t,benchmarkId:a,caseSummary:l}){const[o,c]=y.useState(null),u=y.useRef(0),f=y.useCallback((k,w,j)=>UN(e,t,a,l.id,w,k,j),[e,t,a,l.id]),p=y.useCallback(async(k,w)=>{const j=++u.current,E=w.includes("/")?w.slice(w.lastIndexOf("/")+1):w,C=aj(E);if(Z9.has(C)){c({material:k,path:w,name:E,kind:"image"});return}if(C==="pdf"){c({material:k,path:w,name:E,kind:"pdf"});return}const M=C==="md";if(!X9.has(C)){c({material:k,path:w,name:E,kind:"unsupported"});return}c({material:k,path:w,name:E,kind:M?"md":"text",loading:!0});try{const _=await fetch(f(k,w,{preview:!0}),{credentials:"same-origin"});if(!_.ok)throw new Error(String(_.status));const D=await _.text();if(j!==u.current)return;c({material:k,path:w,name:E,kind:M?"md":"text",content:D,truncated:_.headers.get("x-content-truncated")==="1"})}catch(_){if(j!==u.current)return;c({material:k,path:w,name:E,kind:M?"md":"text",error:Ie(_)})}},[f]),h=o?f(o.material,o.path,{download:!0}):null,g=o?.material==="rubric"?m.benchmark.rubric:m.benchmark.taskMaterials,v={img:({src:k,alt:w})=>s.jsx("img",{src:typeof k=="string"&&!mk.test(k)?f(o?.material??"statement",hk(pk(o?.path??""),k)):k,alt:w??"",loading:"lazy",className:"max-w-full"}),a:({href:k,children:w})=>{if(typeof k!="string"||k.startsWith("#"))return s.jsx("a",{href:k,children:w});if(mk.test(k))return s.jsx("a",{href:k,target:"_blank",rel:"noreferrer",children:w});const j=hk(pk(o?.path??""),k),E=o?.material??"statement";return s.jsx("a",{href:f(E,j),onClick:C=>{C.preventDefault(),p(E,j)},children:w})}};return s.jsxs("div",{className:"grid min-h-[58vh] overflow-hidden rounded-md border border-gray-200 md:grid-cols-[240px_minmax(0,1fr)] dark:border-gray-800",children:[s.jsx("aside",{className:"border-b border-gray-200 bg-gray-50/60 md:border-b-0 md:border-r dark:border-gray-800 dark:bg-gray-950/30",children:s.jsxs("div",{className:"max-h-44 overflow-y-auto md:max-h-[53vh]",children:[s.jsx(gk,{projectId:e,agentId:t,benchmarkId:a,caseSummary:l,material:"statement",label:m.benchmark.taskMaterials,defaultOpen:!0,autoPreviewReadme:!0,onPreview:p}),s.jsx(gk,{projectId:e,agentId:t,benchmarkId:a,caseSummary:l,material:"rubric",label:m.benchmark.rubric,hiddenLabel:m.benchmark.agentHidden,defaultOpen:!0,onPreview:p})]})}),s.jsxs("section",{className:"min-w-0",children:[s.jsxs("div",{className:"flex min-h-11 flex-wrap items-center gap-2 border-b border-gray-200 px-3 py-2 dark:border-gray-800",children:[s.jsx("div",{className:"min-w-0 flex-1",children:s.jsx("p",{className:"truncate font-mono text-xs text-gray-500",children:o?`${g} / ${o.path}`:l.id})}),h&&o&&s.jsx("a",{href:h,download:o.name,className:"rounded-md px-2.5 py-1 text-xs font-medium text-gray-600 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-gray-800",children:m.files.download})]}),s.jsx("div",{className:"max-h-[52vh] min-h-[52vh] overflow-auto p-3",children:o?o.loading?s.jsx(pa,{rows:8}):o.error?s.jsx("p",{className:"text-sm text-red-500",children:o.error}):o.kind==="image"?s.jsx("img",{src:f(o.material,o.path),alt:o.name,loading:"lazy",className:"max-w-full rounded-md border border-gray-200 dark:border-gray-800"}):o.kind==="pdf"?s.jsx("iframe",{src:f(o.material,o.path),title:o.name,className:"h-[50vh] w-full rounded-md border border-gray-200 dark:border-gray-800"}):o.kind==="md"?s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"md-body text-sm text-gray-800 dark:text-gray-100",children:s.jsx(pc,{remarkPlugins:[hc],components:v,children:o.content??""})}),o.truncated&&s.jsx("p",{className:"mt-2 text-xs text-gray-400",children:m.files.previewTruncated})]}):o.kind==="text"?s.jsxs(s.Fragment,{children:[s.jsx(Mg,{language:ez(o.name),code:o.content??"",highlight:(o.content?.length??0)<=J9}),o.truncated&&s.jsx("p",{className:"mt-2 text-xs text-gray-400",children:m.files.previewTruncated})]}):s.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:m.files.previewUnsupported}):s.jsx("p",{className:"text-sm text-gray-400",children:m.benchmark.caseFileUnavailable})})]})]})}function nz({projectId:e,agentId:t,name:a,defaultOpen:l,selection:o,onSelect:c}){const[u,f]=y.useState(l),[p,h]=y.useState(null),[g,v]=y.useState(null);return y.useEffect(()=>{!u||p||ON(e,t).then(k=>h(k.benchmarks)).catch(k=>v(Ie(k)))},[u,p,e,t]),s.jsxs("li",{className:"pt-2.5",children:[s.jsx("div",{className:"flex items-center px-1 pb-0.5",children:s.jsxs("button",{type:"button",onClick:()=>f(k=>!k),"aria-label":u?m.nav.collapseGroup:m.nav.expandGroup,className:"flex min-w-0 flex-1 items-center gap-1 rounded px-1 py-0.5 text-left transition-colors duration-150 hover:bg-gray-200/50 dark:hover:bg-gray-800/50",children:[s.jsx(xa,{id:t,name:a,size:18,className:"shrink-0 rounded"}),s.jsx("span",{className:"min-w-0 truncate text-xs font-semibold uppercase tracking-wide text-gray-500 dark:text-gray-400",children:a}),s.jsx($n,{open:u,size:12,className:"text-gray-400"}),s.jsx("span",{className:"min-w-0 flex-1"})]})}),u&&s.jsxs("div",{className:"anim-fade",children:[g&&s.jsx("p",{className:"px-2.5 py-1 text-xs text-red-500",children:g}),!p&&!g&&s.jsx("p",{className:"px-2.5 py-1 text-xs text-gray-400",children:m.common.loading}),p&&p.length===0&&s.jsx("p",{className:"px-2.5 py-1 text-xs text-gray-400 dark:text-gray-600",children:m.benchmark.emptyAgent}),s.jsx("ul",{className:"space-y-0.5",children:p?.map(k=>{const w=o?.agentId===t&&o.benchmark.id===k.id;return s.jsx("li",{children:s.jsxs("button",{type:"button",onClick:()=>c({agentId:t,benchmark:k}),className:`flex w-full items-center gap-1.5 rounded-md px-2.5 py-1.5 text-left transition-colors duration-150 ${w?"bg-gray-200/70 dark:bg-gray-800":"hover:bg-gray-200/50 dark:hover:bg-gray-800/70"}`,children:[s.jsx(ic,{text:k.title,className:`min-w-0 flex-1 text-sm ${w?"font-medium text-gray-900 dark:text-gray-100":"text-gray-700 dark:text-gray-300"}`}),s.jsx("span",{className:"shrink-0 font-mono text-[11px] text-gray-400",children:k.caseCount})]})},k.id)})})]})]})}function az({evaluations:e,series:t}){const[a,l]=y.useState(null),[o,c]=Hg(),u=nj(e),f=W9(u),p=WS(e.length,f.min,f.max,c),h=e.map(g=>ha(g.time));return s.jsx("div",{ref:o,children:c>0&&s.jsx(Fg,{geom:p,fmtY:Qo,dates:h,hover:a,onHover:l,yTicks:f.ticks,bubble:g=>{const v=e[g],k=u[g]??null;return s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"text-gray-400",children:ha(v.time)}),s.jsxs("p",{className:"font-mono",children:[k===null?"—":Qo(k),v.version!==void 0&&s.jsxs("span",{className:"ml-1.5 text-gray-400",children:["v",v.version]})]}),s.jsxs("p",{className:"font-mono text-gray-400",children:[v.modelId," · ",v.thinkingLevel]})]})},children:t.map((g,v)=>{const k=K9(Q9(e,g));return s.jsx("g",{className:g.modelId?YS(v).text:"text-gray-400 dark:text-gray-500",children:k.map((w,j)=>{const E=w.map((C,M)=>`${M===0?"M":"L"}${p.x(C.index)},${p.y(C.value)}`).join(" ");return s.jsxs("g",{children:[w.length>1&&s.jsx("path",{d:E,fill:"none",stroke:"currentColor",strokeWidth:2,opacity:a!==null?.35:1}),w.map(C=>s.jsx("circle",{cx:p.x(C.index),cy:p.y(C.value),r:a===C.index?4:2.5,className:"fill-current",opacity:a!==null&&a!==C.index?.25:1},C.index))]},j)})},g.key===""?"unlabeled":g.key)})})})}function rz({evaluations:e}){const t=Y9(e),a=l=>l.modelId?l.thinkingLevel?`${l.modelId} · ${l.thinkingLevel}`:l.modelId:m.benchmark.legendUnlabeled;return s.jsxs("div",{children:[s.jsx("p",{className:"mb-1 text-xs font-semibold text-gray-500",children:m.benchmark.trendTitle(m.benchmark.colScore)}),t.length>=2&&s.jsx("div",{className:"mb-1.5 flex flex-wrap items-center gap-x-3 gap-y-1",children:t.map((l,o)=>s.jsxs("span",{className:"flex items-center gap-1.5 text-[11px] text-gray-500 dark:text-gray-400",children:[s.jsx("span",{className:`inline-block h-2 w-2 shrink-0 rounded-sm ${l.modelId?YS(o).swatch:"bg-gray-400 dark:bg-gray-500"}`}),s.jsx("span",{className:"font-mono",children:a(l)})]},l.key===""?"unlabeled":l.key))}),s.jsx(az,{evaluations:e,series:t})]})}const dl="px-3 py-2";function sz({agentId:e,evaluation:t,caseTitles:a,onOpenCase:l,currency:o}){const[c,u]=y.useState(!1);return s.jsxs(s.Fragment,{children:[s.jsxs("tr",{onClick:()=>u(f=>!f),className:"cursor-pointer border-b border-gray-100 transition-colors duration-150 last:border-b-0 hover:bg-gray-50 dark:border-gray-800/60 dark:hover:bg-gray-800/40",children:[s.jsx("td",{className:dl,children:s.jsxs("span",{className:"flex items-center gap-1.5 text-xs",children:[s.jsx($n,{open:c,size:12,className:"text-gray-400"}),ha(t.time)]})}),s.jsx("td",{className:`${dl} font-mono text-xs text-gray-500 dark:text-gray-400`,children:t.version!==void 0?`v${t.version}`:"—"}),s.jsx("td",{className:`${dl} max-w-40 truncate font-mono text-xs text-gray-500 dark:text-gray-400`,title:t.provider,children:t.modelId}),s.jsx("td",{className:`${dl} font-mono text-xs text-gray-500 dark:text-gray-400`,children:t.thinkingLevel}),s.jsx("td",{className:`${dl} font-mono text-xs font-semibold tabular-nums`,children:Qo(t.score)}),s.jsx("td",{className:`${dl} font-mono text-xs tabular-nums text-gray-500 dark:text-gray-400`,children:hr(t.cost,o)}),s.jsx("td",{className:`${dl} font-mono text-xs tabular-nums text-gray-500 dark:text-gray-400`,children:t.durationMs!==void 0?hn(t.durationMs):"—"})]}),c&&s.jsx("tr",{className:"border-b border-gray-100 last:border-b-0 dark:border-gray-800/60",children:s.jsxs("td",{colSpan:7,className:"bg-gray-50/80 px-3 py-2 dark:bg-gray-950/40",children:[(t.summaryTitle||t.summary)&&s.jsxs("div",{className:"mb-2",children:[t.summaryTitle?s.jsx("p",{className:"text-xs font-semibold text-gray-700 dark:text-gray-200",children:t.summaryTitle}):s.jsx("p",{className:"text-xs font-semibold text-gray-500",children:m.benchmark.summaryLabel}),t.summary&&s.jsx("p",{className:"mt-0.5 whitespace-pre-wrap text-xs text-gray-600 dark:text-gray-300",children:t.summary})]}),s.jsxs("table",{className:"w-full text-left",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"text-xs text-gray-500",children:[s.jsx("th",{className:"px-2 py-1 font-medium",children:m.benchmark.colCase}),s.jsx("th",{className:"px-2 py-1 font-medium",children:m.benchmark.colScore}),s.jsx("th",{className:"px-2 py-1 font-medium",children:m.common.cost}),s.jsx("th",{className:"px-2 py-1 font-medium",children:m.benchmark.colDuration}),s.jsx("th",{className:"px-2 py-1 font-medium",children:m.benchmark.colSession})]})}),s.jsx("tbody",{children:t.cases.map(f=>s.jsx(iz,{agentId:e,caseScore:f,title:a.get(f.case),onOpenCase:a.has(f.case)?l:void 0,currency:o},f.case))})]})]})})]})}function lz({agentId:e,sessionId:t}){return t?s.jsx(Xh,{to:`/traces?agentId=${encodeURIComponent(e)}&sessionId=${encodeURIComponent(t)}`,className:"font-mono text-gray-600 underline decoration-gray-300 underline-offset-2 hover:text-gray-900 dark:text-gray-300 dark:decoration-gray-600 dark:hover:text-gray-100",title:t,children:t}):s.jsx("span",{className:"text-gray-400",children:"—"})}function iz({agentId:e,caseScore:t,title:a,onOpenCase:l,currency:o}){const[c,u]=y.useState(!1),f=t.runs;return s.jsxs(s.Fragment,{children:[s.jsxs("tr",{onClick:()=>u(p=>!p),className:"cursor-pointer text-xs transition-colors duration-150 hover:bg-gray-100/70 dark:hover:bg-gray-800/40",children:[s.jsx("td",{className:"px-2 py-1",children:s.jsxs("span",{className:"flex items-start gap-1.5",children:[s.jsx($n,{open:c,size:12,className:"text-gray-400"}),s.jsxs("span",{className:"min-w-0",children:[l?s.jsx("button",{type:"button",className:"block text-left font-medium text-gray-800 hover:underline dark:text-gray-200",onClick:p=>{p.stopPropagation(),l(t.case)},children:a??t.case}):s.jsx("span",{className:"block font-medium text-gray-800 dark:text-gray-200",children:a??t.case}),a&&a!==t.case&&s.jsx("span",{className:"block font-mono text-[11px] text-gray-400",children:t.case})]})]})}),s.jsx("td",{className:"px-2 py-1 font-mono tabular-nums",children:Qo(t.score)}),s.jsx("td",{className:"px-2 py-1 font-mono tabular-nums text-gray-500 dark:text-gray-400",children:hr(t.cost,o)}),s.jsx("td",{className:"px-2 py-1 font-mono tabular-nums text-gray-500 dark:text-gray-400",children:t.durationMs!==void 0?hn(t.durationMs):"—"}),s.jsx("td",{className:"px-2 py-1",children:s.jsx("span",{className:"text-gray-400",children:"—"})})]}),c&&f.map((p,h)=>s.jsxs("tr",{className:"text-xs text-gray-500 dark:text-gray-400",children:[s.jsxs("td",{className:"py-1 pl-7 pr-2 font-mono",children:[m.benchmark.colRun," #",h+1]}),s.jsx("td",{className:"px-2 py-1 font-mono tabular-nums",children:Qo(p.score)}),s.jsx("td",{className:"px-2 py-1 font-mono tabular-nums",children:hr(p.cost,o)}),s.jsx("td",{className:"px-2 py-1 font-mono tabular-nums",children:p.durationMs!==void 0?hn(p.durationMs):"—"}),s.jsx("td",{className:"px-2 py-1",children:s.jsx(lz,{agentId:e,...p.sessionId?{sessionId:p.sessionId}:{}})})]},h))]})}function oz({cases:e,error:t,onOpenCase:a}){return s.jsxs("div",{children:[s.jsx("p",{className:"mb-1 text-xs font-semibold text-gray-500",children:m.benchmark.cases}),s.jsxs("div",{className:"overflow-hidden rounded-md border border-gray-200 bg-white dark:border-gray-800 dark:bg-gray-900",children:[t&&s.jsx("p",{className:"px-3 py-2 text-xs text-red-500",children:t}),!e&&!t&&s.jsx("p",{className:"px-3 py-2 text-xs text-gray-400",children:m.common.loading}),e?.map(l=>s.jsxs("button",{type:"button",onClick:()=>a(l.id),className:"flex w-full items-center gap-3 border-b border-gray-100 px-3 py-2 text-left transition-colors last:border-b-0 hover:bg-gray-50 dark:border-gray-800/70 dark:hover:bg-gray-800/50",children:[s.jsxs("span",{className:"min-w-0 flex-1",children:[s.jsx("span",{className:"block text-sm font-medium text-gray-800 dark:text-gray-200",children:l.title}),s.jsx("span",{className:"block truncate font-mono text-[11px] text-gray-400",children:l.id})]}),s.jsx("span",{className:"shrink-0 rounded-md px-2.5 py-1 text-xs font-medium text-gray-600 dark:text-gray-300",children:m.benchmark.viewCase})]},l.id))]})]})}function cz(){Er(m.benchmark.title);const{currentProject:e,agents:t,agentsLoading:a}=Xt(),{currency:l}=Ps(),o=e?.projectId??null,[c]=Ed(),u=c.get("agentId"),[f,p]=y.useState(null),[h,g]=y.useState(null),[v,k]=y.useState(null),[w,j]=y.useState(null);if(y.useEffect(()=>{p(null)},[o]),y.useEffect(()=>{if(g(null),k(null),j(null),!o||!f)return;let D=!1;return DN(o,f.agentId,f.benchmark.id).then(V=>{D||g(V.cases)}).catch(V=>{D||k(Ie(V))}),()=>{D=!0}},[o,f]),!o)return null;const E=f?.benchmark??null,C=E?[...E.evaluations]:[],M=new Map(h?.map(D=>[D.id,D.title])??[]),_=h?.find(D=>D.id===w)??null;return s.jsxs("div",{className:"flex h-full flex-col md:flex-row",children:[s.jsxs("aside",{className:"max-h-52 shrink-0 overflow-y-auto border-b border-gray-200 bg-gray-50 px-1 py-2 md:max-h-none md:w-72 md:border-b-0 md:border-r dark:border-gray-800 dark:bg-gray-900",children:[s.jsx("p",{className:"px-3 pb-1 text-xs font-bold uppercase tracking-wide text-gray-500",children:m.benchmark.title}),a?s.jsx(pa,{rows:4}):s.jsx("ul",{children:t.map(D=>s.jsx(nz,{projectId:o,agentId:D.agentId,name:tn(D),defaultOpen:u===null||u===D.agentId,selection:f,onSelect:p},D.agentId))})]}),s.jsx("section",{className:"min-w-0 flex-1 overflow-y-auto p-3 md:p-4",children:f&&E?s.jsxs("div",{className:"mx-auto max-w-4xl space-y-4",children:[s.jsxs("div",{children:[s.jsxs("div",{className:"flex flex-wrap items-baseline gap-x-2 gap-y-1",children:[s.jsx("h1",{className:"min-w-0 truncate text-lg font-semibold",children:E.title}),s.jsx("span",{className:"text-xs text-gray-500",children:m.benchmark.caseCount(E.caseCount)})]}),E.description&&s.jsx("p",{className:"mt-1 text-sm text-gray-500 dark:text-gray-400",children:E.description})]}),s.jsx(oz,{cases:h,error:v,onOpenCase:j}),C.length===0?s.jsx(Nr,{title:m.benchmark.noEvaluations}):s.jsxs(s.Fragment,{children:[s.jsx(rz,{evaluations:C}),s.jsxs("div",{children:[s.jsx("p",{className:"mb-1 text-xs font-semibold text-gray-500",children:m.benchmark.evaluations}),s.jsx("div",{className:"overflow-x-auto overflow-y-clip rounded-md border border-gray-200 bg-white dark:border-gray-800 dark:bg-gray-900",children:s.jsxs("table",{className:"w-full min-w-[720px] text-left text-sm",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"border-b border-gray-200 bg-gray-50/80 text-xs text-gray-500 dark:border-gray-800 dark:bg-gray-900",children:[s.jsx("th",{className:"px-3 py-2.5",children:m.common.time}),s.jsx("th",{className:"px-3 py-2.5",children:m.benchmark.colVersion}),s.jsx("th",{className:"px-3 py-2.5",children:m.benchmark.colModel}),s.jsx("th",{className:"px-3 py-2.5",children:m.benchmark.colThinkingLevel}),s.jsx("th",{className:"px-3 py-2.5",children:m.benchmark.colScore}),s.jsx("th",{className:"px-3 py-2.5",children:m.common.cost}),s.jsx("th",{className:"px-3 py-2.5",children:m.benchmark.colDuration})]})}),s.jsx("tbody",{children:[...C].reverse().map((D,V)=>s.jsx(sz,{agentId:f.agentId,evaluation:D,caseTitles:M,onOpenCase:j,currency:l},V))})]})})]})]}),_&&s.jsx(Gt,{open:!0,title:_.title,widthClass:"sm:max-w-6xl",onClose:()=>j(null),children:s.jsx(tz,{projectId:o,agentId:f.agentId,benchmarkId:E.id,caseSummary:_})})]},`${f.agentId}/${E.id}`):s.jsx(Nr,{title:m.benchmark.selectBenchmark})})]})}function uz(){Er(m.admin.users);const{user:e,desktopMode:t}=xn(),[a,l]=y.useState(null),[o,c]=y.useState(null),[u,f]=y.useState(!1),[p,h]=y.useState(null),[g,v]=y.useState(null),k=y.useCallback(async()=>{try{l((await DC()).users),c(null)}catch(w){c(Ie(w))}},[]);return y.useEffect(()=>{e?.isAdmin&&!t&&k()},[e?.isAdmin,t,k]),e&&(!e.isAdmin||t)?s.jsx(Yo,{to:"/chat",replace:!0}):s.jsxs("div",{className:"h-full overflow-y-auto p-4 md:p-6",children:[s.jsxs("div",{className:"mx-auto max-w-3xl",children:[s.jsxs("div",{className:"mb-4 flex items-center justify-between",children:[s.jsx("h1",{className:"text-xl font-semibold",children:m.admin.users}),s.jsx(we,{variant:"primary",onClick:()=>f(!0),children:m.admin.createUser})]}),a===null?s.jsx("p",{className:"text-sm text-gray-400",children:m.common.loading}):s.jsx("div",{className:"overflow-x-auto rounded-lg border border-gray-200 dark:border-gray-800",children:s.jsxs("table",{className:"w-full text-sm",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"border-b border-gray-100 bg-gray-50 text-left text-xs text-gray-500 dark:border-gray-800 dark:bg-gray-900/60 dark:text-gray-400",children:[s.jsx("th",{className:"whitespace-nowrap px-3 py-2 font-medium",children:m.common.username}),s.jsx("th",{className:"whitespace-nowrap px-3 py-2 font-medium",children:m.common.role}),s.jsx("th",{className:"whitespace-nowrap px-3 py-2 font-medium",children:m.common.created}),s.jsx("th",{className:"whitespace-nowrap px-3 py-2 text-right font-medium",children:m.common.actions})]})}),s.jsx("tbody",{className:"divide-y divide-gray-100 dark:divide-gray-800/60",children:a.map(w=>s.jsxs("tr",{children:[s.jsxs("td",{className:"whitespace-nowrap px-3 py-2 font-medium",children:[w.userId,w.passwordIsInitial&&s.jsx("span",{className:"ml-2 align-middle",children:s.jsx(gn,{tone:"gray",children:m.admin.initialPasswordFlag})})]}),s.jsx("td",{className:"whitespace-nowrap px-3 py-2",children:s.jsx(gn,{tone:"gray",children:w.isAdmin?m.admin.roleAdmin:m.admin.roleUser})}),s.jsx("td",{className:"whitespace-nowrap px-3 py-2 text-gray-500 dark:text-gray-400",children:ha(w.createdAt)}),s.jsxs("td",{className:"whitespace-nowrap px-3 py-1.5 text-right",children:[s.jsx(we,{size:"sm",variant:"ghost",onClick:()=>h(w),children:m.admin.resetPassword}),!w.isAdmin&&s.jsx(we,{size:"sm",variant:"ghost",onClick:()=>v(w),children:m.common.delete})]})]},w.userId))})]})}),o&&s.jsx("p",{className:"mt-2 text-xs text-red-600 dark:text-red-400",children:o})]}),s.jsx(dz,{open:u,onClose:()=>f(!1),onDone:()=>{f(!1),k()}}),s.jsx(fz,{user:p,onClose:()=>h(null)}),s.jsx(mz,{user:g,onClose:()=>v(null),onDone:()=>{v(null),k()}})]})}function dz({open:e,onClose:t,onDone:a}){const[l,o]=y.useState(""),[c,u]=y.useState(""),[f,p]=y.useState({}),[h,g]=y.useState(!1),v=()=>p(w=>w.userId||w.password?{}:w);y.useEffect(()=>{e&&(o(""),u(""),p({}))},[e]);const k=async()=>{const w=l.trim(),j={};if(w?_1.test(w)||(j.userId=m.auth.usernameHint):j.userId=m.common.requiredField,c||(j.password=m.common.requiredField),j.userId||j.password){p(j);return}g(!0),p({});try{await zC({userId:w,password:c}),a()}catch(E){E instanceof na&&E.code==="invalid_password"?p({password:Ie(E)}):p({userId:Ie(E)})}finally{g(!1)}};return s.jsx(Gt,{open:e,title:m.admin.createUser,onClose:t,footer:s.jsxs(s.Fragment,{children:[s.jsx(we,{onClick:t,disabled:h,children:m.common.cancel}),s.jsx(we,{variant:"primary",disabled:h,onClick:()=>{k()},children:m.common.create})]}),children:s.jsxs("div",{className:"space-y-3",children:[s.jsx(at,{label:m.common.username,required:!0,size:"sm",value:l,onChange:w=>{o(w.target.value),v()},error:f.userId,hint:m.auth.usernameHint,autoFocus:!0}),s.jsx(zs,{label:m.admin.initialPassword,required:!0,size:"sm",value:c,onChange:w=>{u(w.target.value),v()},error:f.password,autoComplete:"new-password",hint:m.auth.passwordHint}),_1.test(l.trim())&&s.jsx("p",{className:"text-xs text-gray-400 dark:text-gray-500",children:m.admin.defaultProjectNote(`${l.trim()}-default_project`)})]})})}function fz({user:e,onClose:t}){const[a,l]=y.useState(""),[o,c]=y.useState(void 0),[u,f]=y.useState(!1);y.useEffect(()=>{e&&(l(""),c(void 0))},[e]);const p=async()=>{if(e){if(!a){c(m.common.requiredField);return}f(!0),c(void 0);try{await UC(e.userId,{password:a}),t()}catch(h){c(Ie(h))}finally{f(!1)}}};return s.jsx(Gt,{open:e!==null,title:e?m.admin.resetPasswordTitle(e.userId):"",onClose:t,footer:s.jsxs(s.Fragment,{children:[s.jsx(we,{onClick:t,disabled:u,children:m.common.cancel}),s.jsx(we,{variant:"primary",disabled:u,onClick:()=>{p()},children:m.common.save})]}),children:s.jsxs("div",{className:"space-y-3",children:[s.jsx(zs,{label:m.admin.initialPassword,required:!0,size:"sm",value:a,onChange:h=>{l(h.target.value),c(void 0)},error:o,autoComplete:"new-password",hint:m.auth.passwordHint,autoFocus:!0}),s.jsx("p",{className:"text-xs text-gray-400 dark:text-gray-500",children:m.admin.resetPasswordNote})]})})}function mz({user:e,onClose:t,onDone:a}){const[l,o]=y.useState(!1),[c,u]=y.useState(null),[f,p]=y.useState(!1);y.useEffect(()=>{e&&(o(!1),u(null))},[e]);const h=async()=>{if(e){p(!0),u(null);try{await $C(e.userId),a()}catch(g){u(Ie(g))}finally{p(!1)}}};return s.jsx(Gt,{open:e!==null,title:e?m.admin.deleteUserTitle(e.userId):"",onClose:t,footer:s.jsxs(s.Fragment,{children:[s.jsx(we,{onClick:t,disabled:f,children:m.common.cancel}),l?s.jsx(we,{variant:"danger",disabled:f,onClick:()=>{h()},children:m.common.confirm}):s.jsx(we,{variant:"danger",onClick:()=>o(!0),children:m.common.delete})]}),children:s.jsxs("div",{className:"space-y-2",children:[s.jsx("p",{className:"text-sm text-red-600 dark:text-red-400",children:e?m.admin.deleteUserConfirm(e.userId):""}),c&&s.jsx("p",{className:"text-xs text-red-600 dark:text-red-400",children:c})]})})}function pz(){const{user:e}=xn();return e===void 0?null:e===null?s.jsx(Yo,{to:"/login",replace:!0}):s.jsx(ET,{children:s.jsx(DT,{children:s.jsx(oD,{})})})}function hz(){const{user:e}=xn();return e?s.jsx(Yo,{to:"/chat",replace:!0}):s.jsx(xD,{})}function gz(){return s.jsx(bT,{children:s.jsxs(K4,{children:[s.jsx(fa,{path:"/login",element:s.jsx(hz,{})}),s.jsxs(fa,{element:s.jsx(pz,{}),children:[s.jsx(fa,{index:!0,element:s.jsx(Yo,{to:"/chat",replace:!0})}),s.jsx(fa,{path:"/chat/:sessionId?",element:s.jsx($O,{})}),s.jsx(fa,{path:"/agents",element:s.jsx(bD,{})}),s.jsx(fa,{path:"/agents/:agentId",element:s.jsx(r7,{})}),s.jsx(fa,{path:"/skills",element:s.jsx(p7,{})}),s.jsx(fa,{path:"/models",element:s.jsx(z7,{})}),s.jsx(fa,{path:"/usage",element:s.jsx(y9,{})}),s.jsx(fa,{path:"/traces",element:s.jsx(V9,{})}),s.jsx(fa,{path:"/benchmark",element:s.jsx(cz,{})}),s.jsx(fa,{path:"/admin/users",element:s.jsx(uz,{})}),s.jsx(fa,{path:"*",element:s.jsx(Yo,{to:"/chat",replace:!0})})]})]})})}function xz(){return s.jsx(wC,{children:s.jsx(AC,{children:s.jsx(FN,{children:s.jsxs(SC,{children:[s.jsx(gz,{}),s.jsx(XT,{})]})})})})}const rj=document.getElementById("root");if(!rj)throw new Error("#root mount point not found");hC.createRoot(rj).render(s.jsx(y.StrictMode,{children:s.jsx(xz,{})}));export{NI as _,t3 as a,x3 as b,Bb as c,m3 as f,g3 as h,dg as s,l3 as w};