solace-agent-mesh 1.11.2__py3-none-any.whl

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 (624) hide show
  1. solace_agent_mesh/__init__.py +0 -0
  2. solace_agent_mesh/agent/__init__.py +0 -0
  3. solace_agent_mesh/agent/adk/__init__.py +0 -0
  4. solace_agent_mesh/agent/adk/adk_llm.txt +226 -0
  5. solace_agent_mesh/agent/adk/adk_llm_detail.txt +566 -0
  6. solace_agent_mesh/agent/adk/alembic/README +74 -0
  7. solace_agent_mesh/agent/adk/alembic/env.py +77 -0
  8. solace_agent_mesh/agent/adk/alembic/script.py.mako +28 -0
  9. solace_agent_mesh/agent/adk/alembic/versions/e2902798564d_adk_session_db_upgrade.py +52 -0
  10. solace_agent_mesh/agent/adk/alembic.ini +112 -0
  11. solace_agent_mesh/agent/adk/app_llm_agent.py +52 -0
  12. solace_agent_mesh/agent/adk/artifacts/__init__.py +1 -0
  13. solace_agent_mesh/agent/adk/artifacts/artifacts_llm.txt +171 -0
  14. solace_agent_mesh/agent/adk/artifacts/filesystem_artifact_service.py +545 -0
  15. solace_agent_mesh/agent/adk/artifacts/s3_artifact_service.py +609 -0
  16. solace_agent_mesh/agent/adk/callbacks.py +2318 -0
  17. solace_agent_mesh/agent/adk/embed_resolving_mcp_toolset.py +406 -0
  18. solace_agent_mesh/agent/adk/intelligent_mcp_callbacks.py +415 -0
  19. solace_agent_mesh/agent/adk/mcp_content_processor.py +666 -0
  20. solace_agent_mesh/agent/adk/models/lite_llm.py +1026 -0
  21. solace_agent_mesh/agent/adk/models/models_llm.txt +189 -0
  22. solace_agent_mesh/agent/adk/models/oauth2_token_manager.py +132 -0
  23. solace_agent_mesh/agent/adk/runner.py +390 -0
  24. solace_agent_mesh/agent/adk/schema_migration.py +88 -0
  25. solace_agent_mesh/agent/adk/services.py +468 -0
  26. solace_agent_mesh/agent/adk/setup.py +1325 -0
  27. solace_agent_mesh/agent/adk/stream_parser.py +415 -0
  28. solace_agent_mesh/agent/adk/tool_wrapper.py +165 -0
  29. solace_agent_mesh/agent/agent_llm.txt +369 -0
  30. solace_agent_mesh/agent/agent_llm_detail.txt +1702 -0
  31. solace_agent_mesh/agent/protocol/__init__.py +0 -0
  32. solace_agent_mesh/agent/protocol/event_handlers.py +2041 -0
  33. solace_agent_mesh/agent/protocol/protocol_llm.txt +81 -0
  34. solace_agent_mesh/agent/protocol/protocol_llm_detail.txt +92 -0
  35. solace_agent_mesh/agent/proxies/__init__.py +0 -0
  36. solace_agent_mesh/agent/proxies/a2a/__init__.py +3 -0
  37. solace_agent_mesh/agent/proxies/a2a/a2a_llm.txt +190 -0
  38. solace_agent_mesh/agent/proxies/a2a/app.py +56 -0
  39. solace_agent_mesh/agent/proxies/a2a/component.py +1585 -0
  40. solace_agent_mesh/agent/proxies/a2a/config.py +216 -0
  41. solace_agent_mesh/agent/proxies/a2a/oauth_token_cache.py +104 -0
  42. solace_agent_mesh/agent/proxies/base/__init__.py +3 -0
  43. solace_agent_mesh/agent/proxies/base/app.py +100 -0
  44. solace_agent_mesh/agent/proxies/base/base_llm.txt +148 -0
  45. solace_agent_mesh/agent/proxies/base/component.py +816 -0
  46. solace_agent_mesh/agent/proxies/base/config.py +85 -0
  47. solace_agent_mesh/agent/proxies/base/proxy_task_context.py +19 -0
  48. solace_agent_mesh/agent/proxies/proxies_llm.txt +283 -0
  49. solace_agent_mesh/agent/sac/__init__.py +0 -0
  50. solace_agent_mesh/agent/sac/app.py +595 -0
  51. solace_agent_mesh/agent/sac/component.py +3668 -0
  52. solace_agent_mesh/agent/sac/patch_adk.py +103 -0
  53. solace_agent_mesh/agent/sac/sac_llm.txt +189 -0
  54. solace_agent_mesh/agent/sac/sac_llm_detail.txt +200 -0
  55. solace_agent_mesh/agent/sac/task_execution_context.py +415 -0
  56. solace_agent_mesh/agent/testing/__init__.py +3 -0
  57. solace_agent_mesh/agent/testing/debug_utils.py +135 -0
  58. solace_agent_mesh/agent/testing/testing_llm.txt +58 -0
  59. solace_agent_mesh/agent/testing/testing_llm_detail.txt +68 -0
  60. solace_agent_mesh/agent/tools/__init__.py +16 -0
  61. solace_agent_mesh/agent/tools/audio_tools.py +1740 -0
  62. solace_agent_mesh/agent/tools/builtin_artifact_tools.py +2500 -0
  63. solace_agent_mesh/agent/tools/builtin_data_analysis_tools.py +244 -0
  64. solace_agent_mesh/agent/tools/dynamic_tool.py +396 -0
  65. solace_agent_mesh/agent/tools/general_agent_tools.py +572 -0
  66. solace_agent_mesh/agent/tools/image_tools.py +1185 -0
  67. solace_agent_mesh/agent/tools/peer_agent_tool.py +363 -0
  68. solace_agent_mesh/agent/tools/registry.py +38 -0
  69. solace_agent_mesh/agent/tools/test_tools.py +136 -0
  70. solace_agent_mesh/agent/tools/time_tools.py +126 -0
  71. solace_agent_mesh/agent/tools/tool_config_types.py +93 -0
  72. solace_agent_mesh/agent/tools/tool_definition.py +53 -0
  73. solace_agent_mesh/agent/tools/tools_llm.txt +276 -0
  74. solace_agent_mesh/agent/tools/tools_llm_detail.txt +275 -0
  75. solace_agent_mesh/agent/tools/web_tools.py +392 -0
  76. solace_agent_mesh/agent/utils/__init__.py +0 -0
  77. solace_agent_mesh/agent/utils/artifact_helpers.py +1353 -0
  78. solace_agent_mesh/agent/utils/config_parser.py +49 -0
  79. solace_agent_mesh/agent/utils/context_helpers.py +77 -0
  80. solace_agent_mesh/agent/utils/utils_llm.txt +152 -0
  81. solace_agent_mesh/agent/utils/utils_llm_detail.txt +149 -0
  82. solace_agent_mesh/assets/docs/404.html +16 -0
  83. solace_agent_mesh/assets/docs/assets/css/styles.8162edfb.css +1 -0
  84. solace_agent_mesh/assets/docs/assets/images/Solace_AI_Framework_With_Broker-85f0a306a9bcdd20b390b7a949f6d862.png +0 -0
  85. solace_agent_mesh/assets/docs/assets/images/sam-enterprise-credentials-b269f095349473118b2b33bdfcc40122.png +0 -0
  86. solace_agent_mesh/assets/docs/assets/js/032c2d61.f3d37824.js +1 -0
  87. solace_agent_mesh/assets/docs/assets/js/05749d90.19ac4f35.js +1 -0
  88. solace_agent_mesh/assets/docs/assets/js/0bcf40b7.c019ad46.js +1 -0
  89. solace_agent_mesh/assets/docs/assets/js/1001.0182a8bd.js +1 -0
  90. solace_agent_mesh/assets/docs/assets/js/1039.0bd46aa1.js +1 -0
  91. solace_agent_mesh/assets/docs/assets/js/149.b797a808.js +1 -0
  92. solace_agent_mesh/assets/docs/assets/js/15ba94aa.92fea363.js +1 -0
  93. solace_agent_mesh/assets/docs/assets/js/15e40e79.434bb30f.js +1 -0
  94. solace_agent_mesh/assets/docs/assets/js/165.6a39807d.js +2 -0
  95. solace_agent_mesh/assets/docs/assets/js/165.6a39807d.js.LICENSE.txt +9 -0
  96. solace_agent_mesh/assets/docs/assets/js/17896441.e612dfb4.js +1 -0
  97. solace_agent_mesh/assets/docs/assets/js/2130.ab9fd314.js +1 -0
  98. solace_agent_mesh/assets/docs/assets/js/2131ec11.5c7a1f6e.js +1 -0
  99. solace_agent_mesh/assets/docs/assets/js/2237.5e477fc6.js +1 -0
  100. solace_agent_mesh/assets/docs/assets/js/2279.550aa580.js +2 -0
  101. solace_agent_mesh/assets/docs/assets/js/2279.550aa580.js.LICENSE.txt +13 -0
  102. solace_agent_mesh/assets/docs/assets/js/2334.1cf50a20.js +1 -0
  103. solace_agent_mesh/assets/docs/assets/js/240a0364.9ad94d1b.js +1 -0
  104. solace_agent_mesh/assets/docs/assets/js/2987107d.a80604f9.js +1 -0
  105. solace_agent_mesh/assets/docs/assets/js/2e32b5e0.33f5d75b.js +1 -0
  106. solace_agent_mesh/assets/docs/assets/js/3219.adc1d663.js +1 -0
  107. solace_agent_mesh/assets/docs/assets/js/341393d4.0fac2613.js +1 -0
  108. solace_agent_mesh/assets/docs/assets/js/3624.0eaa1fd0.js +1 -0
  109. solace_agent_mesh/assets/docs/assets/js/375.708d48db.js +1 -0
  110. solace_agent_mesh/assets/docs/assets/js/3834.b6cd790e.js +1 -0
  111. solace_agent_mesh/assets/docs/assets/js/3a6c6137.f5940cfa.js +1 -0
  112. solace_agent_mesh/assets/docs/assets/js/3ac1795d.28b7c67b.js +1 -0
  113. solace_agent_mesh/assets/docs/assets/js/3ff0015d.2ddc75c0.js +1 -0
  114. solace_agent_mesh/assets/docs/assets/js/41adc471.48b12a4e.js +1 -0
  115. solace_agent_mesh/assets/docs/assets/js/4250.95455b28.js +1 -0
  116. solace_agent_mesh/assets/docs/assets/js/4356.d169ab5b.js +1 -0
  117. solace_agent_mesh/assets/docs/assets/js/4458.518e66fa.js +1 -0
  118. solace_agent_mesh/assets/docs/assets/js/4488.c7cc3442.js +1 -0
  119. solace_agent_mesh/assets/docs/assets/js/4494.6ee23046.js +1 -0
  120. solace_agent_mesh/assets/docs/assets/js/4855.fc4444b6.js +1 -0
  121. solace_agent_mesh/assets/docs/assets/js/4866.22daefc0.js +1 -0
  122. solace_agent_mesh/assets/docs/assets/js/4950.ca4caeda.js +1 -0
  123. solace_agent_mesh/assets/docs/assets/js/509e993c.a1fbf45a.js +1 -0
  124. solace_agent_mesh/assets/docs/assets/js/5388.7a136447.js +1 -0
  125. solace_agent_mesh/assets/docs/assets/js/547e15cc.2f7790c1.js +1 -0
  126. solace_agent_mesh/assets/docs/assets/js/55b7b518.29d6e75d.js +1 -0
  127. solace_agent_mesh/assets/docs/assets/js/5607.081356f8.js +1 -0
  128. solace_agent_mesh/assets/docs/assets/js/5864.b0d0e9de.js +1 -0
  129. solace_agent_mesh/assets/docs/assets/js/5c2bd65f.90a87880.js +1 -0
  130. solace_agent_mesh/assets/docs/assets/js/5e95c892.558d5167.js +1 -0
  131. solace_agent_mesh/assets/docs/assets/js/6063ff4c.ef84f702.js +1 -0
  132. solace_agent_mesh/assets/docs/assets/js/60702c0e.a8bdd79b.js +1 -0
  133. solace_agent_mesh/assets/docs/assets/js/6143.0a1464c9.js +1 -0
  134. solace_agent_mesh/assets/docs/assets/js/631738c7.fa471607.js +1 -0
  135. solace_agent_mesh/assets/docs/assets/js/6395.e9c73649.js +1 -0
  136. solace_agent_mesh/assets/docs/assets/js/64195356.c498c4d0.js +1 -0
  137. solace_agent_mesh/assets/docs/assets/js/66d4869e.b77431fc.js +1 -0
  138. solace_agent_mesh/assets/docs/assets/js/6796.51d2c9b7.js +1 -0
  139. solace_agent_mesh/assets/docs/assets/js/6976.379be23b.js +1 -0
  140. solace_agent_mesh/assets/docs/assets/js/6978.ee0b945c.js +1 -0
  141. solace_agent_mesh/assets/docs/assets/js/6a520c9d.b6e3f2ce.js +1 -0
  142. solace_agent_mesh/assets/docs/assets/js/6aaedf65.7253541d.js +1 -0
  143. solace_agent_mesh/assets/docs/assets/js/6ad8f0bd.a5b36a60.js +1 -0
  144. solace_agent_mesh/assets/docs/assets/js/6d84eae0.fd23ba4a.js +1 -0
  145. solace_agent_mesh/assets/docs/assets/js/6fdfefc7.99de744e.js +1 -0
  146. solace_agent_mesh/assets/docs/assets/js/7040.cb436723.js +1 -0
  147. solace_agent_mesh/assets/docs/assets/js/7195.412f418a.js +1 -0
  148. solace_agent_mesh/assets/docs/assets/js/71da7b71.374b9d54.js +1 -0
  149. solace_agent_mesh/assets/docs/assets/js/722f809d.965da774.js +1 -0
  150. solace_agent_mesh/assets/docs/assets/js/7280.3fb73bdb.js +1 -0
  151. solace_agent_mesh/assets/docs/assets/js/742f027b.46c07808.js +1 -0
  152. solace_agent_mesh/assets/docs/assets/js/77cf947d.48cb18a2.js +1 -0
  153. solace_agent_mesh/assets/docs/assets/js/7845.e33e7c4c.js +1 -0
  154. solace_agent_mesh/assets/docs/assets/js/7900.69516146.js +1 -0
  155. solace_agent_mesh/assets/docs/assets/js/8024126c.fa0e7186.js +1 -0
  156. solace_agent_mesh/assets/docs/assets/js/81a99df0.2484b8d9.js +1 -0
  157. solace_agent_mesh/assets/docs/assets/js/82fbfb93.161823a5.js +1 -0
  158. solace_agent_mesh/assets/docs/assets/js/8356.8a379c04.js +1 -0
  159. solace_agent_mesh/assets/docs/assets/js/8567.4732c6b7.js +1 -0
  160. solace_agent_mesh/assets/docs/assets/js/8573.cb04eda5.js +1 -0
  161. solace_agent_mesh/assets/docs/assets/js/8577.1d54e766.js +1 -0
  162. solace_agent_mesh/assets/docs/assets/js/8591.5d015485.js +2 -0
  163. solace_agent_mesh/assets/docs/assets/js/8591.5d015485.js.LICENSE.txt +61 -0
  164. solace_agent_mesh/assets/docs/assets/js/8709.7ecd4047.js +1 -0
  165. solace_agent_mesh/assets/docs/assets/js/8731.6c1dbf0c.js +1 -0
  166. solace_agent_mesh/assets/docs/assets/js/8908.f9d1b506.js +1 -0
  167. solace_agent_mesh/assets/docs/assets/js/8b032486.91a91afc.js +1 -0
  168. solace_agent_mesh/assets/docs/assets/js/9157.b4093d07.js +1 -0
  169. solace_agent_mesh/assets/docs/assets/js/924ffdeb.975e428a.js +1 -0
  170. solace_agent_mesh/assets/docs/assets/js/9278.a4fd875d.js +1 -0
  171. solace_agent_mesh/assets/docs/assets/js/945fb41e.6f4cdffd.js +1 -0
  172. solace_agent_mesh/assets/docs/assets/js/94e8668d.16083b3f.js +1 -0
  173. solace_agent_mesh/assets/docs/assets/js/9616.b75c2f6d.js +1 -0
  174. solace_agent_mesh/assets/docs/assets/js/9793.c6d16376.js +1 -0
  175. solace_agent_mesh/assets/docs/assets/js/9bb13469.b2333011.js +1 -0
  176. solace_agent_mesh/assets/docs/assets/js/9e9d0a82.570c057b.js +1 -0
  177. solace_agent_mesh/assets/docs/assets/js/a7bd4aaa.2204d2f7.js +1 -0
  178. solace_agent_mesh/assets/docs/assets/js/a94703ab.3e5fbcb3.js +1 -0
  179. solace_agent_mesh/assets/docs/assets/js/ab9708a8.245ae0ef.js +1 -0
  180. solace_agent_mesh/assets/docs/assets/js/aba21aa0.c42a534c.js +1 -0
  181. solace_agent_mesh/assets/docs/assets/js/ad71b5ed.af3ecfd1.js +1 -0
  182. solace_agent_mesh/assets/docs/assets/js/ad87452a.9d73dad6.js +1 -0
  183. solace_agent_mesh/assets/docs/assets/js/c198a0dc.8f31f867.js +1 -0
  184. solace_agent_mesh/assets/docs/assets/js/c93cbaa0.0e0d8baf.js +1 -0
  185. solace_agent_mesh/assets/docs/assets/js/cab03b5b.6a073091.js +1 -0
  186. solace_agent_mesh/assets/docs/assets/js/cbe2e9ea.07e170dd.js +1 -0
  187. solace_agent_mesh/assets/docs/assets/js/ceb2a7a6.5d92d7d0.js +1 -0
  188. solace_agent_mesh/assets/docs/assets/js/da0b5bad.b62f7b08.js +1 -0
  189. solace_agent_mesh/assets/docs/assets/js/db5d6442.3daf1696.js +1 -0
  190. solace_agent_mesh/assets/docs/assets/js/db924877.e98d12a1.js +1 -0
  191. solace_agent_mesh/assets/docs/assets/js/dd817ffc.c37a755e.js +1 -0
  192. solace_agent_mesh/assets/docs/assets/js/dd81e2b8.b682e9c2.js +1 -0
  193. solace_agent_mesh/assets/docs/assets/js/de5f4c65.e8241890.js +1 -0
  194. solace_agent_mesh/assets/docs/assets/js/de915948.44a432bc.js +1 -0
  195. solace_agent_mesh/assets/docs/assets/js/e04b235d.52cb25ed.js +1 -0
  196. solace_agent_mesh/assets/docs/assets/js/e1b6eeb4.b1068f9b.js +1 -0
  197. solace_agent_mesh/assets/docs/assets/js/e3d9abda.1476f570.js +1 -0
  198. solace_agent_mesh/assets/docs/assets/js/e6f9706b.4488e34c.js +1 -0
  199. solace_agent_mesh/assets/docs/assets/js/e92d0134.3bda61dd.js +1 -0
  200. solace_agent_mesh/assets/docs/assets/js/f284c35a.250993bf.js +1 -0
  201. solace_agent_mesh/assets/docs/assets/js/ff4d71f2.74710fc1.js +1 -0
  202. solace_agent_mesh/assets/docs/assets/js/main.7acf7ace.js +2 -0
  203. solace_agent_mesh/assets/docs/assets/js/main.7acf7ace.js.LICENSE.txt +81 -0
  204. solace_agent_mesh/assets/docs/assets/js/runtime~main.9e0813a2.js +1 -0
  205. solace_agent_mesh/assets/docs/docs/documentation/components/agents/index.html +154 -0
  206. solace_agent_mesh/assets/docs/docs/documentation/components/builtin-tools/artifact-management/index.html +99 -0
  207. solace_agent_mesh/assets/docs/docs/documentation/components/builtin-tools/audio-tools/index.html +90 -0
  208. solace_agent_mesh/assets/docs/docs/documentation/components/builtin-tools/data-analysis-tools/index.html +107 -0
  209. solace_agent_mesh/assets/docs/docs/documentation/components/builtin-tools/embeds/index.html +166 -0
  210. solace_agent_mesh/assets/docs/docs/documentation/components/builtin-tools/index.html +101 -0
  211. solace_agent_mesh/assets/docs/docs/documentation/components/cli/index.html +219 -0
  212. solace_agent_mesh/assets/docs/docs/documentation/components/gateways/index.html +92 -0
  213. solace_agent_mesh/assets/docs/docs/documentation/components/index.html +29 -0
  214. solace_agent_mesh/assets/docs/docs/documentation/components/orchestrator/index.html +55 -0
  215. solace_agent_mesh/assets/docs/docs/documentation/components/plugins/index.html +110 -0
  216. solace_agent_mesh/assets/docs/docs/documentation/components/projects/index.html +182 -0
  217. solace_agent_mesh/assets/docs/docs/documentation/components/prompts/index.html +147 -0
  218. solace_agent_mesh/assets/docs/docs/documentation/components/proxies/index.html +345 -0
  219. solace_agent_mesh/assets/docs/docs/documentation/components/speech/index.html +52 -0
  220. solace_agent_mesh/assets/docs/docs/documentation/deploying/debugging/index.html +83 -0
  221. solace_agent_mesh/assets/docs/docs/documentation/deploying/deployment-options/index.html +84 -0
  222. solace_agent_mesh/assets/docs/docs/documentation/deploying/index.html +25 -0
  223. solace_agent_mesh/assets/docs/docs/documentation/deploying/kubernetes-deployment/index.html +47 -0
  224. solace_agent_mesh/assets/docs/docs/documentation/deploying/logging/index.html +85 -0
  225. solace_agent_mesh/assets/docs/docs/documentation/deploying/observability/index.html +60 -0
  226. solace_agent_mesh/assets/docs/docs/documentation/deploying/proxy_configuration/index.html +49 -0
  227. solace_agent_mesh/assets/docs/docs/documentation/developing/create-agents/index.html +144 -0
  228. solace_agent_mesh/assets/docs/docs/documentation/developing/create-gateways/index.html +191 -0
  229. solace_agent_mesh/assets/docs/docs/documentation/developing/creating-python-tools/index.html +128 -0
  230. solace_agent_mesh/assets/docs/docs/documentation/developing/creating-service-providers/index.html +54 -0
  231. solace_agent_mesh/assets/docs/docs/documentation/developing/evaluations/index.html +135 -0
  232. solace_agent_mesh/assets/docs/docs/documentation/developing/index.html +34 -0
  233. solace_agent_mesh/assets/docs/docs/documentation/developing/structure/index.html +55 -0
  234. solace_agent_mesh/assets/docs/docs/documentation/developing/tutorials/bedrock-agents/index.html +267 -0
  235. solace_agent_mesh/assets/docs/docs/documentation/developing/tutorials/custom-agent/index.html +142 -0
  236. solace_agent_mesh/assets/docs/docs/documentation/developing/tutorials/event-mesh-gateway/index.html +116 -0
  237. solace_agent_mesh/assets/docs/docs/documentation/developing/tutorials/mcp-integration/index.html +86 -0
  238. solace_agent_mesh/assets/docs/docs/documentation/developing/tutorials/mongodb-integration/index.html +164 -0
  239. solace_agent_mesh/assets/docs/docs/documentation/developing/tutorials/rag-integration/index.html +140 -0
  240. solace_agent_mesh/assets/docs/docs/documentation/developing/tutorials/rest-gateway/index.html +57 -0
  241. solace_agent_mesh/assets/docs/docs/documentation/developing/tutorials/slack-integration/index.html +72 -0
  242. solace_agent_mesh/assets/docs/docs/documentation/developing/tutorials/sql-database/index.html +102 -0
  243. solace_agent_mesh/assets/docs/docs/documentation/developing/tutorials/teams-integration/index.html +115 -0
  244. solace_agent_mesh/assets/docs/docs/documentation/enterprise/agent-builder/index.html +86 -0
  245. solace_agent_mesh/assets/docs/docs/documentation/enterprise/connectors/index.html +67 -0
  246. solace_agent_mesh/assets/docs/docs/documentation/enterprise/index.html +37 -0
  247. solace_agent_mesh/assets/docs/docs/documentation/enterprise/installation/index.html +86 -0
  248. solace_agent_mesh/assets/docs/docs/documentation/enterprise/openapi-tools/index.html +324 -0
  249. solace_agent_mesh/assets/docs/docs/documentation/enterprise/rbac-setup-guide/index.html +247 -0
  250. solace_agent_mesh/assets/docs/docs/documentation/enterprise/secure-user-delegated-access/index.html +440 -0
  251. solace_agent_mesh/assets/docs/docs/documentation/enterprise/single-sign-on/index.html +184 -0
  252. solace_agent_mesh/assets/docs/docs/documentation/enterprise/wheel-installation/index.html +62 -0
  253. solace_agent_mesh/assets/docs/docs/documentation/getting-started/architecture/index.html +75 -0
  254. solace_agent_mesh/assets/docs/docs/documentation/getting-started/index.html +54 -0
  255. solace_agent_mesh/assets/docs/docs/documentation/getting-started/introduction/index.html +85 -0
  256. solace_agent_mesh/assets/docs/docs/documentation/getting-started/try-agent-mesh/index.html +41 -0
  257. solace_agent_mesh/assets/docs/docs/documentation/installing-and-configuring/artifact-storage/index.html +290 -0
  258. solace_agent_mesh/assets/docs/docs/documentation/installing-and-configuring/configurations/index.html +78 -0
  259. solace_agent_mesh/assets/docs/docs/documentation/installing-and-configuring/index.html +25 -0
  260. solace_agent_mesh/assets/docs/docs/documentation/installing-and-configuring/installation/index.html +78 -0
  261. solace_agent_mesh/assets/docs/docs/documentation/installing-and-configuring/large_language_models/index.html +160 -0
  262. solace_agent_mesh/assets/docs/docs/documentation/installing-and-configuring/run-project/index.html +142 -0
  263. solace_agent_mesh/assets/docs/docs/documentation/installing-and-configuring/session-storage/index.html +251 -0
  264. solace_agent_mesh/assets/docs/docs/documentation/installing-and-configuring/user-feedback/index.html +88 -0
  265. solace_agent_mesh/assets/docs/docs/documentation/migrations/a2a-upgrade/a2a-gateway-upgrade-to-0.3.0/index.html +100 -0
  266. solace_agent_mesh/assets/docs/docs/documentation/migrations/a2a-upgrade/a2a-technical-migration-map/index.html +52 -0
  267. solace_agent_mesh/assets/docs/img/Solace_AI_Framework_With_Broker.png +0 -0
  268. solace_agent_mesh/assets/docs/img/logo.png +0 -0
  269. solace_agent_mesh/assets/docs/img/sac-flows.png +0 -0
  270. solace_agent_mesh/assets/docs/img/sac_parts_of_a_component.png +0 -0
  271. solace_agent_mesh/assets/docs/img/sam-enterprise-credentials.png +0 -0
  272. solace_agent_mesh/assets/docs/img/solace-logo-text.svg +18 -0
  273. solace_agent_mesh/assets/docs/img/solace-logo.png +0 -0
  274. solace_agent_mesh/assets/docs/lunr-index-1765810064709.json +1 -0
  275. solace_agent_mesh/assets/docs/lunr-index.json +1 -0
  276. solace_agent_mesh/assets/docs/search-doc-1765810064709.json +1 -0
  277. solace_agent_mesh/assets/docs/search-doc.json +1 -0
  278. solace_agent_mesh/assets/docs/sitemap.xml +1 -0
  279. solace_agent_mesh/cli/__init__.py +1 -0
  280. solace_agent_mesh/cli/commands/__init__.py +0 -0
  281. solace_agent_mesh/cli/commands/add_cmd/__init__.py +15 -0
  282. solace_agent_mesh/cli/commands/add_cmd/add_cmd_llm.txt +250 -0
  283. solace_agent_mesh/cli/commands/add_cmd/agent_cmd.py +729 -0
  284. solace_agent_mesh/cli/commands/add_cmd/gateway_cmd.py +322 -0
  285. solace_agent_mesh/cli/commands/add_cmd/web_add_agent_step.py +102 -0
  286. solace_agent_mesh/cli/commands/add_cmd/web_add_gateway_step.py +114 -0
  287. solace_agent_mesh/cli/commands/docs_cmd.py +60 -0
  288. solace_agent_mesh/cli/commands/eval_cmd.py +46 -0
  289. solace_agent_mesh/cli/commands/init_cmd/__init__.py +439 -0
  290. solace_agent_mesh/cli/commands/init_cmd/broker_step.py +201 -0
  291. solace_agent_mesh/cli/commands/init_cmd/database_step.py +91 -0
  292. solace_agent_mesh/cli/commands/init_cmd/directory_step.py +28 -0
  293. solace_agent_mesh/cli/commands/init_cmd/env_step.py +238 -0
  294. solace_agent_mesh/cli/commands/init_cmd/init_cmd_llm.txt +365 -0
  295. solace_agent_mesh/cli/commands/init_cmd/orchestrator_step.py +464 -0
  296. solace_agent_mesh/cli/commands/init_cmd/project_files_step.py +38 -0
  297. solace_agent_mesh/cli/commands/init_cmd/web_init_step.py +119 -0
  298. solace_agent_mesh/cli/commands/init_cmd/webui_gateway_step.py +215 -0
  299. solace_agent_mesh/cli/commands/plugin_cmd/__init__.py +20 -0
  300. solace_agent_mesh/cli/commands/plugin_cmd/add_cmd.py +137 -0
  301. solace_agent_mesh/cli/commands/plugin_cmd/build_cmd.py +86 -0
  302. solace_agent_mesh/cli/commands/plugin_cmd/catalog_cmd.py +144 -0
  303. solace_agent_mesh/cli/commands/plugin_cmd/create_cmd.py +306 -0
  304. solace_agent_mesh/cli/commands/plugin_cmd/install_cmd.py +283 -0
  305. solace_agent_mesh/cli/commands/plugin_cmd/official_registry.py +175 -0
  306. solace_agent_mesh/cli/commands/plugin_cmd/plugin_cmd_llm.txt +305 -0
  307. solace_agent_mesh/cli/commands/run_cmd.py +215 -0
  308. solace_agent_mesh/cli/main.py +52 -0
  309. solace_agent_mesh/cli/utils.py +262 -0
  310. solace_agent_mesh/client/webui/frontend/static/assets/authCallback-Dj3JtK42.js +1 -0
  311. solace_agent_mesh/client/webui/frontend/static/assets/client-ZKk9kEJ5.js +25 -0
  312. solace_agent_mesh/client/webui/frontend/static/assets/favicon-BLgzUch9.ico +0 -0
  313. solace_agent_mesh/client/webui/frontend/static/assets/main-BcUaNZ-Q.css +1 -0
  314. solace_agent_mesh/client/webui/frontend/static/assets/main-vjch4RYc.js +435 -0
  315. solace_agent_mesh/client/webui/frontend/static/assets/vendor-BNV4kZN0.js +535 -0
  316. solace_agent_mesh/client/webui/frontend/static/auth-callback.html +15 -0
  317. solace_agent_mesh/client/webui/frontend/static/index.html +16 -0
  318. solace_agent_mesh/client/webui/frontend/static/mockServiceWorker.js +336 -0
  319. solace_agent_mesh/client/webui/frontend/static/ui-version.json +6 -0
  320. solace_agent_mesh/common/__init__.py +1 -0
  321. solace_agent_mesh/common/a2a/__init__.py +241 -0
  322. solace_agent_mesh/common/a2a/a2a_llm.txt +175 -0
  323. solace_agent_mesh/common/a2a/a2a_llm_detail.txt +193 -0
  324. solace_agent_mesh/common/a2a/artifact.py +368 -0
  325. solace_agent_mesh/common/a2a/events.py +213 -0
  326. solace_agent_mesh/common/a2a/message.py +375 -0
  327. solace_agent_mesh/common/a2a/protocol.py +689 -0
  328. solace_agent_mesh/common/a2a/task.py +127 -0
  329. solace_agent_mesh/common/a2a/translation.py +655 -0
  330. solace_agent_mesh/common/a2a/types.py +55 -0
  331. solace_agent_mesh/common/a2a_spec/a2a.json +2576 -0
  332. solace_agent_mesh/common/a2a_spec/a2a_spec_llm.txt +445 -0
  333. solace_agent_mesh/common/a2a_spec/a2a_spec_llm_detail.txt +736 -0
  334. solace_agent_mesh/common/a2a_spec/schemas/agent_progress_update.json +18 -0
  335. solace_agent_mesh/common/a2a_spec/schemas/artifact_creation_progress.json +48 -0
  336. solace_agent_mesh/common/a2a_spec/schemas/feedback_event.json +51 -0
  337. solace_agent_mesh/common/a2a_spec/schemas/llm_invocation.json +41 -0
  338. solace_agent_mesh/common/a2a_spec/schemas/schemas_llm.txt +330 -0
  339. solace_agent_mesh/common/a2a_spec/schemas/tool_invocation_start.json +26 -0
  340. solace_agent_mesh/common/a2a_spec/schemas/tool_result.json +48 -0
  341. solace_agent_mesh/common/agent_registry.py +122 -0
  342. solace_agent_mesh/common/common_llm.txt +230 -0
  343. solace_agent_mesh/common/common_llm_detail.txt +2562 -0
  344. solace_agent_mesh/common/constants.py +6 -0
  345. solace_agent_mesh/common/data_parts.py +150 -0
  346. solace_agent_mesh/common/exceptions.py +49 -0
  347. solace_agent_mesh/common/middleware/__init__.py +12 -0
  348. solace_agent_mesh/common/middleware/config_resolver.py +132 -0
  349. solace_agent_mesh/common/middleware/middleware_llm.txt +174 -0
  350. solace_agent_mesh/common/middleware/middleware_llm_detail.txt +185 -0
  351. solace_agent_mesh/common/middleware/registry.py +127 -0
  352. solace_agent_mesh/common/oauth/__init__.py +17 -0
  353. solace_agent_mesh/common/oauth/oauth_client.py +408 -0
  354. solace_agent_mesh/common/oauth/utils.py +50 -0
  355. solace_agent_mesh/common/sac/__init__.py +0 -0
  356. solace_agent_mesh/common/sac/sac_llm.txt +71 -0
  357. solace_agent_mesh/common/sac/sac_llm_detail.txt +82 -0
  358. solace_agent_mesh/common/sac/sam_component_base.py +730 -0
  359. solace_agent_mesh/common/sam_events/__init__.py +9 -0
  360. solace_agent_mesh/common/sam_events/event_service.py +208 -0
  361. solace_agent_mesh/common/sam_events/sam_events_llm.txt +104 -0
  362. solace_agent_mesh/common/sam_events/sam_events_llm_detail.txt +115 -0
  363. solace_agent_mesh/common/services/__init__.py +4 -0
  364. solace_agent_mesh/common/services/employee_service.py +164 -0
  365. solace_agent_mesh/common/services/identity_service.py +134 -0
  366. solace_agent_mesh/common/services/providers/__init__.py +4 -0
  367. solace_agent_mesh/common/services/providers/local_file_identity_service.py +151 -0
  368. solace_agent_mesh/common/services/providers/providers_llm.txt +81 -0
  369. solace_agent_mesh/common/services/services_llm.txt +368 -0
  370. solace_agent_mesh/common/services/services_llm_detail.txt +459 -0
  371. solace_agent_mesh/common/utils/__init__.py +7 -0
  372. solace_agent_mesh/common/utils/artifact_utils.py +31 -0
  373. solace_agent_mesh/common/utils/asyncio_macos_fix.py +88 -0
  374. solace_agent_mesh/common/utils/embeds/__init__.py +33 -0
  375. solace_agent_mesh/common/utils/embeds/constants.py +56 -0
  376. solace_agent_mesh/common/utils/embeds/converter.py +447 -0
  377. solace_agent_mesh/common/utils/embeds/embeds_llm.txt +220 -0
  378. solace_agent_mesh/common/utils/embeds/evaluators.py +395 -0
  379. solace_agent_mesh/common/utils/embeds/modifiers.py +793 -0
  380. solace_agent_mesh/common/utils/embeds/resolver.py +967 -0
  381. solace_agent_mesh/common/utils/embeds/types.py +23 -0
  382. solace_agent_mesh/common/utils/in_memory_cache.py +108 -0
  383. solace_agent_mesh/common/utils/initializer.py +52 -0
  384. solace_agent_mesh/common/utils/log_formatters.py +64 -0
  385. solace_agent_mesh/common/utils/message_utils.py +80 -0
  386. solace_agent_mesh/common/utils/mime_helpers.py +172 -0
  387. solace_agent_mesh/common/utils/push_notification_auth.py +135 -0
  388. solace_agent_mesh/common/utils/pydantic_utils.py +159 -0
  389. solace_agent_mesh/common/utils/rbac_utils.py +69 -0
  390. solace_agent_mesh/common/utils/templates/__init__.py +8 -0
  391. solace_agent_mesh/common/utils/templates/liquid_renderer.py +210 -0
  392. solace_agent_mesh/common/utils/templates/template_resolver.py +161 -0
  393. solace_agent_mesh/common/utils/type_utils.py +28 -0
  394. solace_agent_mesh/common/utils/utils_llm.txt +335 -0
  395. solace_agent_mesh/common/utils/utils_llm_detail.txt +572 -0
  396. solace_agent_mesh/config_portal/__init__.py +0 -0
  397. solace_agent_mesh/config_portal/backend/__init__.py +0 -0
  398. solace_agent_mesh/config_portal/backend/common.py +77 -0
  399. solace_agent_mesh/config_portal/backend/plugin_catalog/__init__.py +0 -0
  400. solace_agent_mesh/config_portal/backend/plugin_catalog/constants.py +24 -0
  401. solace_agent_mesh/config_portal/backend/plugin_catalog/models.py +49 -0
  402. solace_agent_mesh/config_portal/backend/plugin_catalog/registry_manager.py +166 -0
  403. solace_agent_mesh/config_portal/backend/plugin_catalog/scraper.py +521 -0
  404. solace_agent_mesh/config_portal/backend/plugin_catalog_server.py +217 -0
  405. solace_agent_mesh/config_portal/backend/server.py +644 -0
  406. solace_agent_mesh/config_portal/frontend/static/client/Solace_community_logo.png +0 -0
  407. solace_agent_mesh/config_portal/frontend/static/client/assets/_index-DiOiAjzL.js +103 -0
  408. solace_agent_mesh/config_portal/frontend/static/client/assets/components-Rk0n-9cK.js +140 -0
  409. solace_agent_mesh/config_portal/frontend/static/client/assets/entry.client-mvZjNKiz.js +19 -0
  410. solace_agent_mesh/config_portal/frontend/static/client/assets/index-DzNKzXrc.js +68 -0
  411. solace_agent_mesh/config_portal/frontend/static/client/assets/manifest-ba77705e.js +1 -0
  412. solace_agent_mesh/config_portal/frontend/static/client/assets/root-B17tZKK7.css +1 -0
  413. solace_agent_mesh/config_portal/frontend/static/client/assets/root-V2BeTIUc.js +10 -0
  414. solace_agent_mesh/config_portal/frontend/static/client/favicon.ico +0 -0
  415. solace_agent_mesh/config_portal/frontend/static/client/index.html +7 -0
  416. solace_agent_mesh/core_a2a/__init__.py +1 -0
  417. solace_agent_mesh/core_a2a/core_a2a_llm.txt +90 -0
  418. solace_agent_mesh/core_a2a/core_a2a_llm_detail.txt +101 -0
  419. solace_agent_mesh/core_a2a/service.py +307 -0
  420. solace_agent_mesh/evaluation/__init__.py +0 -0
  421. solace_agent_mesh/evaluation/evaluator.py +691 -0
  422. solace_agent_mesh/evaluation/message_organizer.py +553 -0
  423. solace_agent_mesh/evaluation/report/benchmark_info.html +35 -0
  424. solace_agent_mesh/evaluation/report/chart_section.html +141 -0
  425. solace_agent_mesh/evaluation/report/detailed_breakdown.html +28 -0
  426. solace_agent_mesh/evaluation/report/modal.html +59 -0
  427. solace_agent_mesh/evaluation/report/modal_chart_functions.js +411 -0
  428. solace_agent_mesh/evaluation/report/modal_script.js +296 -0
  429. solace_agent_mesh/evaluation/report/modal_styles.css +340 -0
  430. solace_agent_mesh/evaluation/report/performance_metrics_styles.css +93 -0
  431. solace_agent_mesh/evaluation/report/templates/footer.html +2 -0
  432. solace_agent_mesh/evaluation/report/templates/header.html +340 -0
  433. solace_agent_mesh/evaluation/report_data_processor.py +970 -0
  434. solace_agent_mesh/evaluation/report_generator.py +607 -0
  435. solace_agent_mesh/evaluation/run.py +954 -0
  436. solace_agent_mesh/evaluation/shared/__init__.py +92 -0
  437. solace_agent_mesh/evaluation/shared/constants.py +47 -0
  438. solace_agent_mesh/evaluation/shared/exceptions.py +50 -0
  439. solace_agent_mesh/evaluation/shared/helpers.py +35 -0
  440. solace_agent_mesh/evaluation/shared/test_case_loader.py +167 -0
  441. solace_agent_mesh/evaluation/shared/test_suite_loader.py +280 -0
  442. solace_agent_mesh/evaluation/subscriber.py +776 -0
  443. solace_agent_mesh/evaluation/summary_builder.py +880 -0
  444. solace_agent_mesh/gateway/__init__.py +0 -0
  445. solace_agent_mesh/gateway/adapter/__init__.py +1 -0
  446. solace_agent_mesh/gateway/adapter/base.py +143 -0
  447. solace_agent_mesh/gateway/adapter/types.py +221 -0
  448. solace_agent_mesh/gateway/base/__init__.py +1 -0
  449. solace_agent_mesh/gateway/base/app.py +345 -0
  450. solace_agent_mesh/gateway/base/base_llm.txt +226 -0
  451. solace_agent_mesh/gateway/base/base_llm_detail.txt +235 -0
  452. solace_agent_mesh/gateway/base/component.py +2030 -0
  453. solace_agent_mesh/gateway/base/task_context.py +75 -0
  454. solace_agent_mesh/gateway/gateway_llm.txt +369 -0
  455. solace_agent_mesh/gateway/gateway_llm_detail.txt +3885 -0
  456. solace_agent_mesh/gateway/generic/__init__.py +1 -0
  457. solace_agent_mesh/gateway/generic/app.py +50 -0
  458. solace_agent_mesh/gateway/generic/component.py +727 -0
  459. solace_agent_mesh/gateway/http_sse/__init__.py +0 -0
  460. solace_agent_mesh/gateway/http_sse/alembic/alembic_llm.txt +345 -0
  461. solace_agent_mesh/gateway/http_sse/alembic/env.py +87 -0
  462. solace_agent_mesh/gateway/http_sse/alembic/script.py.mako +28 -0
  463. solace_agent_mesh/gateway/http_sse/alembic/versions/20250910_d5b3f8f2e9a0_create_initial_database.py +58 -0
  464. solace_agent_mesh/gateway/http_sse/alembic/versions/20250911_b1c2d3e4f5g6_add_database_indexes.py +83 -0
  465. solace_agent_mesh/gateway/http_sse/alembic/versions/20250916_f6e7d8c9b0a1_convert_timestamps_to_epoch_and_align_columns.py +412 -0
  466. solace_agent_mesh/gateway/http_sse/alembic/versions/20251006_98882922fa59_add_tasks_events_feedback_chat_tasks.py +190 -0
  467. solace_agent_mesh/gateway/http_sse/alembic/versions/20251015_add_session_performance_indexes.py +70 -0
  468. solace_agent_mesh/gateway/http_sse/alembic/versions/20251023_add_project_users_table.py +72 -0
  469. solace_agent_mesh/gateway/http_sse/alembic/versions/20251023_add_soft_delete_and_search.py +109 -0
  470. solace_agent_mesh/gateway/http_sse/alembic/versions/20251024_add_default_agent_to_projects.py +26 -0
  471. solace_agent_mesh/gateway/http_sse/alembic/versions/20251024_add_projects_table.py +135 -0
  472. solace_agent_mesh/gateway/http_sse/alembic/versions/20251108_create_prompt_tables_with_sharing.py +154 -0
  473. solace_agent_mesh/gateway/http_sse/alembic/versions/20251115_add_parent_task_id.py +32 -0
  474. solace_agent_mesh/gateway/http_sse/alembic/versions/20251126_add_background_task_fields.py +47 -0
  475. solace_agent_mesh/gateway/http_sse/alembic/versions/20251202_add_versioned_fields_to_prompts.py +52 -0
  476. solace_agent_mesh/gateway/http_sse/alembic/versions/versions_llm.txt +161 -0
  477. solace_agent_mesh/gateway/http_sse/alembic.ini +109 -0
  478. solace_agent_mesh/gateway/http_sse/app.py +351 -0
  479. solace_agent_mesh/gateway/http_sse/component.py +2360 -0
  480. solace_agent_mesh/gateway/http_sse/components/__init__.py +7 -0
  481. solace_agent_mesh/gateway/http_sse/components/components_llm.txt +105 -0
  482. solace_agent_mesh/gateway/http_sse/components/task_logger_forwarder.py +109 -0
  483. solace_agent_mesh/gateway/http_sse/components/visualization_forwarder_component.py +110 -0
  484. solace_agent_mesh/gateway/http_sse/dependencies.py +653 -0
  485. solace_agent_mesh/gateway/http_sse/http_sse_llm.txt +299 -0
  486. solace_agent_mesh/gateway/http_sse/http_sse_llm_detail.txt +3278 -0
  487. solace_agent_mesh/gateway/http_sse/main.py +789 -0
  488. solace_agent_mesh/gateway/http_sse/repository/__init__.py +46 -0
  489. solace_agent_mesh/gateway/http_sse/repository/chat_task_repository.py +102 -0
  490. solace_agent_mesh/gateway/http_sse/repository/entities/__init__.py +11 -0
  491. solace_agent_mesh/gateway/http_sse/repository/entities/chat_task.py +75 -0
  492. solace_agent_mesh/gateway/http_sse/repository/entities/entities_llm.txt +221 -0
  493. solace_agent_mesh/gateway/http_sse/repository/entities/feedback.py +20 -0
  494. solace_agent_mesh/gateway/http_sse/repository/entities/project.py +81 -0
  495. solace_agent_mesh/gateway/http_sse/repository/entities/project_user.py +47 -0
  496. solace_agent_mesh/gateway/http_sse/repository/entities/session.py +66 -0
  497. solace_agent_mesh/gateway/http_sse/repository/entities/session_history.py +0 -0
  498. solace_agent_mesh/gateway/http_sse/repository/entities/task.py +32 -0
  499. solace_agent_mesh/gateway/http_sse/repository/entities/task_event.py +21 -0
  500. solace_agent_mesh/gateway/http_sse/repository/feedback_repository.py +125 -0
  501. solace_agent_mesh/gateway/http_sse/repository/interfaces.py +239 -0
  502. solace_agent_mesh/gateway/http_sse/repository/models/__init__.py +34 -0
  503. solace_agent_mesh/gateway/http_sse/repository/models/base.py +7 -0
  504. solace_agent_mesh/gateway/http_sse/repository/models/chat_task_model.py +31 -0
  505. solace_agent_mesh/gateway/http_sse/repository/models/feedback_model.py +21 -0
  506. solace_agent_mesh/gateway/http_sse/repository/models/models_llm.txt +257 -0
  507. solace_agent_mesh/gateway/http_sse/repository/models/project_model.py +51 -0
  508. solace_agent_mesh/gateway/http_sse/repository/models/project_user_model.py +75 -0
  509. solace_agent_mesh/gateway/http_sse/repository/models/prompt_model.py +159 -0
  510. solace_agent_mesh/gateway/http_sse/repository/models/session_model.py +53 -0
  511. solace_agent_mesh/gateway/http_sse/repository/models/task_event_model.py +25 -0
  512. solace_agent_mesh/gateway/http_sse/repository/models/task_model.py +39 -0
  513. solace_agent_mesh/gateway/http_sse/repository/project_repository.py +172 -0
  514. solace_agent_mesh/gateway/http_sse/repository/project_user_repository.py +186 -0
  515. solace_agent_mesh/gateway/http_sse/repository/repository_llm.txt +308 -0
  516. solace_agent_mesh/gateway/http_sse/repository/session_repository.py +268 -0
  517. solace_agent_mesh/gateway/http_sse/repository/task_repository.py +248 -0
  518. solace_agent_mesh/gateway/http_sse/routers/__init__.py +4 -0
  519. solace_agent_mesh/gateway/http_sse/routers/agent_cards.py +74 -0
  520. solace_agent_mesh/gateway/http_sse/routers/artifacts.py +1137 -0
  521. solace_agent_mesh/gateway/http_sse/routers/auth.py +311 -0
  522. solace_agent_mesh/gateway/http_sse/routers/config.py +371 -0
  523. solace_agent_mesh/gateway/http_sse/routers/dto/__init__.py +10 -0
  524. solace_agent_mesh/gateway/http_sse/routers/dto/dto_llm.txt +450 -0
  525. solace_agent_mesh/gateway/http_sse/routers/dto/project_dto.py +69 -0
  526. solace_agent_mesh/gateway/http_sse/routers/dto/prompt_dto.py +255 -0
  527. solace_agent_mesh/gateway/http_sse/routers/dto/requests/__init__.py +15 -0
  528. solace_agent_mesh/gateway/http_sse/routers/dto/requests/project_requests.py +48 -0
  529. solace_agent_mesh/gateway/http_sse/routers/dto/requests/requests_llm.txt +133 -0
  530. solace_agent_mesh/gateway/http_sse/routers/dto/requests/session_requests.py +33 -0
  531. solace_agent_mesh/gateway/http_sse/routers/dto/requests/task_requests.py +58 -0
  532. solace_agent_mesh/gateway/http_sse/routers/dto/responses/__init__.py +18 -0
  533. solace_agent_mesh/gateway/http_sse/routers/dto/responses/base_responses.py +42 -0
  534. solace_agent_mesh/gateway/http_sse/routers/dto/responses/project_responses.py +31 -0
  535. solace_agent_mesh/gateway/http_sse/routers/dto/responses/responses_llm.txt +123 -0
  536. solace_agent_mesh/gateway/http_sse/routers/dto/responses/session_responses.py +33 -0
  537. solace_agent_mesh/gateway/http_sse/routers/dto/responses/task_responses.py +30 -0
  538. solace_agent_mesh/gateway/http_sse/routers/dto/responses/version_responses.py +31 -0
  539. solace_agent_mesh/gateway/http_sse/routers/feedback.py +168 -0
  540. solace_agent_mesh/gateway/http_sse/routers/people.py +38 -0
  541. solace_agent_mesh/gateway/http_sse/routers/projects.py +767 -0
  542. solace_agent_mesh/gateway/http_sse/routers/prompts.py +1415 -0
  543. solace_agent_mesh/gateway/http_sse/routers/routers_llm.txt +312 -0
  544. solace_agent_mesh/gateway/http_sse/routers/sessions.py +634 -0
  545. solace_agent_mesh/gateway/http_sse/routers/speech.py +355 -0
  546. solace_agent_mesh/gateway/http_sse/routers/sse.py +230 -0
  547. solace_agent_mesh/gateway/http_sse/routers/tasks.py +1089 -0
  548. solace_agent_mesh/gateway/http_sse/routers/users.py +83 -0
  549. solace_agent_mesh/gateway/http_sse/routers/version.py +343 -0
  550. solace_agent_mesh/gateway/http_sse/routers/visualization.py +1220 -0
  551. solace_agent_mesh/gateway/http_sse/services/__init__.py +4 -0
  552. solace_agent_mesh/gateway/http_sse/services/agent_card_service.py +71 -0
  553. solace_agent_mesh/gateway/http_sse/services/audio_service.py +1227 -0
  554. solace_agent_mesh/gateway/http_sse/services/background_task_monitor.py +186 -0
  555. solace_agent_mesh/gateway/http_sse/services/data_retention_service.py +273 -0
  556. solace_agent_mesh/gateway/http_sse/services/feedback_service.py +250 -0
  557. solace_agent_mesh/gateway/http_sse/services/people_service.py +78 -0
  558. solace_agent_mesh/gateway/http_sse/services/project_service.py +930 -0
  559. solace_agent_mesh/gateway/http_sse/services/prompt_builder_assistant.py +303 -0
  560. solace_agent_mesh/gateway/http_sse/services/services_llm.txt +303 -0
  561. solace_agent_mesh/gateway/http_sse/services/session_service.py +702 -0
  562. solace_agent_mesh/gateway/http_sse/services/task_logger_service.py +593 -0
  563. solace_agent_mesh/gateway/http_sse/services/task_service.py +119 -0
  564. solace_agent_mesh/gateway/http_sse/session_manager.py +219 -0
  565. solace_agent_mesh/gateway/http_sse/shared/__init__.py +146 -0
  566. solace_agent_mesh/gateway/http_sse/shared/auth_utils.py +29 -0
  567. solace_agent_mesh/gateway/http_sse/shared/base_repository.py +252 -0
  568. solace_agent_mesh/gateway/http_sse/shared/database_exceptions.py +274 -0
  569. solace_agent_mesh/gateway/http_sse/shared/database_helpers.py +43 -0
  570. solace_agent_mesh/gateway/http_sse/shared/enums.py +40 -0
  571. solace_agent_mesh/gateway/http_sse/shared/error_dto.py +107 -0
  572. solace_agent_mesh/gateway/http_sse/shared/exception_handlers.py +217 -0
  573. solace_agent_mesh/gateway/http_sse/shared/exceptions.py +192 -0
  574. solace_agent_mesh/gateway/http_sse/shared/pagination.py +138 -0
  575. solace_agent_mesh/gateway/http_sse/shared/response_utils.py +134 -0
  576. solace_agent_mesh/gateway/http_sse/shared/shared_llm.txt +319 -0
  577. solace_agent_mesh/gateway/http_sse/shared/timestamp_utils.py +97 -0
  578. solace_agent_mesh/gateway/http_sse/shared/types.py +50 -0
  579. solace_agent_mesh/gateway/http_sse/shared/utils.py +22 -0
  580. solace_agent_mesh/gateway/http_sse/sse_event_buffer.py +88 -0
  581. solace_agent_mesh/gateway/http_sse/sse_manager.py +491 -0
  582. solace_agent_mesh/gateway/http_sse/utils/__init__.py +1 -0
  583. solace_agent_mesh/gateway/http_sse/utils/artifact_copy_utils.py +370 -0
  584. solace_agent_mesh/gateway/http_sse/utils/stim_utils.py +72 -0
  585. solace_agent_mesh/gateway/http_sse/utils/utils_llm.txt +47 -0
  586. solace_agent_mesh/llm.txt +228 -0
  587. solace_agent_mesh/llm_detail.txt +2835 -0
  588. solace_agent_mesh/services/__init__.py +0 -0
  589. solace_agent_mesh/services/platform/__init__.py +18 -0
  590. solace_agent_mesh/services/platform/alembic/env.py +85 -0
  591. solace_agent_mesh/services/platform/alembic/script.py.mako +28 -0
  592. solace_agent_mesh/services/platform/alembic.ini +109 -0
  593. solace_agent_mesh/services/platform/api/__init__.py +3 -0
  594. solace_agent_mesh/services/platform/api/dependencies.py +147 -0
  595. solace_agent_mesh/services/platform/api/main.py +280 -0
  596. solace_agent_mesh/services/platform/api/middleware.py +51 -0
  597. solace_agent_mesh/services/platform/api/routers/__init__.py +24 -0
  598. solace_agent_mesh/services/platform/app.py +114 -0
  599. solace_agent_mesh/services/platform/component.py +235 -0
  600. solace_agent_mesh/solace_agent_mesh_llm.txt +362 -0
  601. solace_agent_mesh/solace_agent_mesh_llm_detail.txt +8599 -0
  602. solace_agent_mesh/templates/agent_template.yaml +53 -0
  603. solace_agent_mesh/templates/eval_backend_template.yaml +54 -0
  604. solace_agent_mesh/templates/gateway_app_template.py +75 -0
  605. solace_agent_mesh/templates/gateway_component_template.py +484 -0
  606. solace_agent_mesh/templates/gateway_config_template.yaml +38 -0
  607. solace_agent_mesh/templates/logging_config_template.yaml +48 -0
  608. solace_agent_mesh/templates/main_orchestrator.yaml +66 -0
  609. solace_agent_mesh/templates/plugin_agent_config_template.yaml +122 -0
  610. solace_agent_mesh/templates/plugin_custom_config_template.yaml +27 -0
  611. solace_agent_mesh/templates/plugin_custom_template.py +10 -0
  612. solace_agent_mesh/templates/plugin_gateway_config_template.yaml +60 -0
  613. solace_agent_mesh/templates/plugin_pyproject_template.toml +32 -0
  614. solace_agent_mesh/templates/plugin_readme_template.md +12 -0
  615. solace_agent_mesh/templates/plugin_tool_config_template.yaml +109 -0
  616. solace_agent_mesh/templates/plugin_tools_template.py +224 -0
  617. solace_agent_mesh/templates/shared_config.yaml +112 -0
  618. solace_agent_mesh/templates/templates_llm.txt +147 -0
  619. solace_agent_mesh/templates/webui.yaml +177 -0
  620. solace_agent_mesh-1.11.2.dist-info/METADATA +504 -0
  621. solace_agent_mesh-1.11.2.dist-info/RECORD +624 -0
  622. solace_agent_mesh-1.11.2.dist-info/WHEEL +4 -0
  623. solace_agent_mesh-1.11.2.dist-info/entry_points.txt +3 -0
  624. solace_agent_mesh-1.11.2.dist-info/licenses/LICENSE +201 -0
@@ -0,0 +1,435 @@
1
+ var U1=Object.defineProperty;var B1=(e,t,n)=>t in e?U1(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Ih=(e,t,n)=>B1(e,typeof t!="symbol"?t+"":t,n);import{c as V1}from"./client-ZKk9kEJ5.js";import{r as d,a as ia,j as s,c as Ig,R as Bd,b as W1,N as ol,S as Vd,d as Rt,L as fr,X as po,E as H1,F as $u,e as La,f as zu,g as wr,h as Rg,i as Uu,k as Bu,C as Pg,l as ml,m as la,n as Vu,A as Mg,T as Wd,o as Hd,M as Dg,p as Wu,q as Z1,s as G1,t as Rh,u as Og,I as ti,v as fo,w as ts,P as ns,x as Lg,B as Y1,y as Fg,z as $g,D as Zd,G as Ph,H as Mh,J as Dh,K as Fa,O as zg,Q as Co,U as Hl,V as Zl,W as Oh,Y as Lh,Z as K1,_ as Ug,$ as Fh,a0 as q1,a1 as X1,a2 as J1,a3 as gl,a4 as Q1,a5 as eC,a6 as Mo,a7 as tC,a8 as ro,a9 as nC,aa as rs,ab as xl,ac as Gl,ad as rC,ae as $h,af as oC,ag as Bg,ah as Vg,ai as sC,aj as In,ak as Rn,al as Wg,am as aC,an as zh,ao as Uh,ap as Zc,aq as vl,ar as iC,as as lC,at as cC,au as uC,av as dC,aw as fC,ax as hC,ay as pC,az as mC,aA as gC,aB as Hg,aC as xC,aD as Zg,aE as vC,aF as wC,aG as Gg,aH as Yg,aI as Gs,aJ as Kg,aK as bC,aL as yC,aM as Fs,aN as CC,aO as Ni,aP as SC}from"./vendor-BNV4kZN0.js";/**
2
+ * react-router v7.9.3
3
+ *
4
+ * Copyright (c) Remix Software Inc.
5
+ *
6
+ * This source code is licensed under the MIT license found in the
7
+ * LICENSE.md file in the root directory of this source tree.
8
+ *
9
+ * @license MIT
10
+ */var qg=e=>{throw TypeError(e)},_C=(e,t,n)=>t.has(e)||qg("Cannot "+n),Gc=(e,t,n)=>(_C(e,t,"read from private field"),n?n.call(e):t.get(e)),kC=(e,t,n)=>t.has(e)?qg("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Bh="popstate";function EC(e={}){function t(o,a){let{pathname:i="/",search:l="",hash:c=""}=So(o.location.hash.substring(1));return!i.startsWith("/")&&!i.startsWith(".")&&(i="/"+i),$a("",{pathname:i,search:l,hash:c},a.state&&a.state.usr||null,a.state&&a.state.key||"default")}function n(o,a){let i=o.document.querySelector("base"),l="";if(i&&i.getAttribute("href")){let c=o.location.href,u=c.indexOf("#");l=u===-1?c:c.slice(0,u)}return l+"#"+(typeof a=="string"?a:Do(a))}function r(o,a){an(o.pathname.charAt(0)==="/",`relative pathnames are not supported in hash history.push(${JSON.stringify(a)})`)}return NC(t,n,r,e)}function _t(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function an(e,t){if(!e){typeof console<"u"&&console.warn(t);try{throw new Error(t)}catch{}}}function jC(){return Math.random().toString(36).substring(2,10)}function Vh(e,t){return{usr:e.state,key:e.key,idx:t}}function $a(e,t,n=null,r){return{pathname:typeof e=="string"?e:e.pathname,search:"",hash:"",...typeof t=="string"?So(t):t,state:n,key:t&&t.key||r||jC()}}function Do({pathname:e="/",search:t="",hash:n=""}){return t&&t!=="?"&&(e+=t.charAt(0)==="?"?t:"?"+t),n&&n!=="#"&&(e+=n.charAt(0)==="#"?n:"#"+n),e}function So(e){let t={};if(e){let n=e.indexOf("#");n>=0&&(t.hash=e.substring(n),e=e.substring(0,n));let r=e.indexOf("?");r>=0&&(t.search=e.substring(r),e=e.substring(0,r)),e&&(t.pathname=e)}return t}function NC(e,t,n,r={}){let{window:o=document.defaultView,v5Compat:a=!1}=r,i=o.history,l="POP",c=null,u=f();u==null&&(u=0,i.replaceState({...i.state,idx:u},""));function f(){return(i.state||{idx:null}).idx}function h(){l="POP";let w=f(),v=w==null?null:w-u;u=w,c&&c({action:l,location:g.location,delta:v})}function m(w,v){l="PUSH";let b=$a(g.location,w,v);n&&n(b,w),u=f()+1;let C=Vh(b,u),S=g.createHref(b);try{i.pushState(C,"",S)}catch(E){if(E instanceof DOMException&&E.name==="DataCloneError")throw E;o.location.assign(S)}a&&c&&c({action:l,location:g.location,delta:1})}function p(w,v){l="REPLACE";let b=$a(g.location,w,v);n&&n(b,w),u=f();let C=Vh(b,u),S=g.createHref(b);i.replaceState(C,"",S),a&&c&&c({action:l,location:g.location,delta:0})}function x(w){return Xg(w)}let g={get action(){return l},get location(){return e(o,i)},listen(w){if(c)throw new Error("A history only accepts one active listener");return o.addEventListener(Bh,h),c=w,()=>{o.removeEventListener(Bh,h),c=null}},createHref(w){return t(o,w)},createURL:x,encodeLocation(w){let v=x(w);return{pathname:v.pathname,search:v.search,hash:v.hash}},push:m,replace:p,go(w){return i.go(w)}};return g}function Xg(e,t=!1){let n="http://localhost";typeof window<"u"&&(n=window.location.origin!=="null"?window.location.origin:window.location.href),_t(n,"No window.location.(origin|href) available to create URL");let r=typeof e=="string"?e:Do(e);return r=r.replace(/ $/,"%20"),!t&&r.startsWith("//")&&(r=n+r),new URL(r,n)}var Na,Wh=class{constructor(e){if(kC(this,Na,new Map),e)for(let[t,n]of e)this.set(t,n)}get(e){if(Gc(this,Na).has(e))return Gc(this,Na).get(e);if(e.defaultValue!==void 0)return e.defaultValue;throw new Error("No value found for context")}set(e,t){Gc(this,Na).set(e,t)}};Na=new WeakMap;var TC=new Set(["lazy","caseSensitive","path","id","index","children"]);function AC(e){return TC.has(e)}var IC=new Set(["lazy","caseSensitive","path","id","index","middleware","children"]);function RC(e){return IC.has(e)}function PC(e){return e.index===!0}function za(e,t,n=[],r={},o=!1){return e.map((a,i)=>{let l=[...n,String(i)],c=typeof a.id=="string"?a.id:l.join("-");if(_t(a.index!==!0||!a.children,"Cannot specify children on an index route"),_t(o||!r[c],`Found a route id collision on id "${c}". Route id's must be globally unique within Data Router usages`),PC(a)){let u={...a,...t(a),id:c};return r[c]=u,u}else{let u={...a,...t(a),id:c,children:void 0};return r[c]=u,a.children&&(u.children=za(a.children,t,l,r,o)),u}})}function No(e,t,n="/"){return sl(e,t,n,!1)}function sl(e,t,n,r){let o=typeof t=="string"?So(t):t,a=tr(o.pathname||"/",n);if(a==null)return null;let i=Jg(e);DC(i);let l=null;for(let c=0;l==null&&c<i.length;++c){let u=ZC(a);l=WC(i[c],u,r)}return l}function MC(e,t){let{route:n,pathname:r,params:o}=e;return{id:n.id,pathname:r,params:o,data:t[n.id],loaderData:t[n.id],handle:n.handle}}function Jg(e,t=[],n=[],r="",o=!1){let a=(i,l,c=o,u)=>{let f={relativePath:u===void 0?i.path||"":u,caseSensitive:i.caseSensitive===!0,childrenIndex:l,route:i};if(f.relativePath.startsWith("/")){if(!f.relativePath.startsWith(r)&&c)return;_t(f.relativePath.startsWith(r),`Absolute route path "${f.relativePath}" nested under path "${r}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),f.relativePath=f.relativePath.slice(r.length)}let h=Jr([r,f.relativePath]),m=n.concat(f);i.children&&i.children.length>0&&(_t(i.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${h}".`),Jg(i.children,t,m,h,c)),!(i.path==null&&!i.index)&&t.push({path:h,score:BC(h,i.index),routesMeta:m})};return e.forEach((i,l)=>{var c;if(i.path===""||!((c=i.path)!=null&&c.includes("?")))a(i,l);else for(let u of Qg(i.path))a(i,l,!0,u)}),t}function Qg(e){let t=e.split("/");if(t.length===0)return[];let[n,...r]=t,o=n.endsWith("?"),a=n.replace(/\?$/,"");if(r.length===0)return o?[a,""]:[a];let i=Qg(r.join("/")),l=[];return l.push(...i.map(c=>c===""?a:[a,c].join("/"))),o&&l.push(...i),l.map(c=>e.startsWith("/")&&c===""?"/":c)}function DC(e){e.sort((t,n)=>t.score!==n.score?n.score-t.score:VC(t.routesMeta.map(r=>r.childrenIndex),n.routesMeta.map(r=>r.childrenIndex)))}var OC=/^:[\w-]+$/,LC=3,FC=2,$C=1,zC=10,UC=-2,Hh=e=>e==="*";function BC(e,t){let n=e.split("/"),r=n.length;return n.some(Hh)&&(r+=UC),t&&(r+=FC),n.filter(o=>!Hh(o)).reduce((o,a)=>o+(OC.test(a)?LC:a===""?$C:zC),r)}function VC(e,t){return e.length===t.length&&e.slice(0,-1).every((r,o)=>r===t[o])?e[e.length-1]-t[t.length-1]:0}function WC(e,t,n=!1){let{routesMeta:r}=e,o={},a="/",i=[];for(let l=0;l<r.length;++l){let c=r[l],u=l===r.length-1,f=a==="/"?t:t.slice(a.length)||"/",h=wl({path:c.relativePath,caseSensitive:c.caseSensitive,end:u},f),m=c.route;if(!h&&u&&n&&!r[r.length-1].route.index&&(h=wl({path:c.relativePath,caseSensitive:c.caseSensitive,end:!1},f)),!h)return null;Object.assign(o,h.params),i.push({params:o,pathname:Jr([a,h.pathname]),pathnameBase:qC(Jr([a,h.pathnameBase])),route:m}),h.pathnameBase!=="/"&&(a=Jr([a,h.pathnameBase]))}return i}function wl(e,t){typeof e=="string"&&(e={path:e,caseSensitive:!1,end:!0});let[n,r]=HC(e.path,e.caseSensitive,e.end),o=t.match(n);if(!o)return null;let a=o[0],i=a.replace(/(.)\/+$/,"$1"),l=o.slice(1);return{params:r.reduce((u,{paramName:f,isOptional:h},m)=>{if(f==="*"){let x=l[m]||"";i=a.slice(0,a.length-x.length).replace(/(.)\/+$/,"$1")}const p=l[m];return h&&!p?u[f]=void 0:u[f]=(p||"").replace(/%2F/g,"/"),u},{}),pathname:a,pathnameBase:i,pattern:e}}function HC(e,t=!1,n=!0){an(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 r=[],o="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(i,l,c)=>(r.push({paramName:l,isOptional:c!=null}),c?"/?([^\\/]+)?":"/([^\\/]+)")).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return e.endsWith("*")?(r.push({paramName:"*"}),o+=e==="*"||e==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?o+="\\/*$":e!==""&&e!=="/"&&(o+="(?:(?=\\/|$))"),[new RegExp(o,t?void 0:"i"),r]}function ZC(e){try{return e.split("/").map(t=>decodeURIComponent(t).replace(/\//g,"%2F")).join("/")}catch(t){return an(!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 tr(e,t){if(t==="/")return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let n=t.endsWith("/")?t.length-1:t.length,r=e.charAt(n);return r&&r!=="/"?null:e.slice(n)||"/"}function GC({basename:e,pathname:t}){return t==="/"?e:Jr([e,t])}function YC(e,t="/"){let{pathname:n,search:r="",hash:o=""}=typeof e=="string"?So(e):e;return{pathname:n?n.startsWith("/")?n:KC(n,t):t,search:XC(r),hash:JC(o)}}function KC(e,t){let n=t.replace(/\/+$/,"").split("/");return e.split("/").forEach(o=>{o===".."?n.length>1&&n.pop():o!=="."&&n.push(o)}),n.length>1?n.join("/"):"/"}function Yc(e,t,n,r){return`Cannot include a '${e}' character in a manually specified \`to.${t}\` field [${JSON.stringify(r)}]. Please separate it out to the \`to.${n}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`}function ex(e){return e.filter((t,n)=>n===0||t.route.path&&t.route.path.length>0)}function Yl(e){let t=ex(e);return t.map((n,r)=>r===t.length-1?n.pathname:n.pathnameBase)}function Kl(e,t,n,r=!1){let o;typeof e=="string"?o=So(e):(o={...e},_t(!o.pathname||!o.pathname.includes("?"),Yc("?","pathname","search",o)),_t(!o.pathname||!o.pathname.includes("#"),Yc("#","pathname","hash",o)),_t(!o.search||!o.search.includes("#"),Yc("#","search","hash",o)));let a=e===""||o.pathname==="",i=a?"/":o.pathname,l;if(i==null)l=n;else{let h=t.length-1;if(!r&&i.startsWith("..")){let m=i.split("/");for(;m[0]==="..";)m.shift(),h-=1;o.pathname=m.join("/")}l=h>=0?t[h]:"/"}let c=YC(o,l),u=i&&i!=="/"&&i.endsWith("/"),f=(a||i===".")&&n.endsWith("/");return!c.pathname.endsWith("/")&&(u||f)&&(c.pathname+="/"),c}var Jr=e=>e.join("/").replace(/\/\/+/g,"/"),qC=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/"),XC=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,JC=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e,bl=class{constructor(e,t,n,r=!1){this.status=e,this.statusText=t||"",this.internal=r,n instanceof Error?(this.data=n.toString(),this.error=n):this.data=n}};function Ua(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}var tx=["POST","PUT","PATCH","DELETE"],QC=new Set(tx),eS=["GET",...tx],tS=new Set(eS),nS=new Set([301,302,303,307,308]),rS=new Set([307,308]),Kc={state:"idle",location:void 0,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0},oS={state:"idle",data:void 0,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0},Ts={state:"unblocked",proceed:void 0,reset:void 0,location:void 0},sS=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Gd=e=>sS.test(e),aS=e=>({hasErrorBoundary:!!e.hasErrorBoundary}),nx="remix-router-transitions",rx=Symbol("ResetLoaderData");function iS(e){const t=e.window?e.window:typeof window<"u"?window:void 0,n=typeof t<"u"&&typeof t.document<"u"&&typeof t.document.createElement<"u";_t(e.routes.length>0,"You must provide a non-empty routes array to createRouter");let r=e.hydrationRouteProperties||[],o=e.mapRouteProperties||aS,a={},i=za(e.routes,o,void 0,a),l,c=e.basename||"/";c.startsWith("/")||(c=`/${c}`);let u=e.dataStrategy||fS,f={...e.future},h=null,m=new Set,p=null,x=null,g=null,w=e.hydrationData!=null,v=No(i,e.history.location,c),b=!1,C=null,S;if(v==null&&!e.patchRoutesOnNavigation){let ee=vr(404,{pathname:e.history.location.pathname}),{matches:le,route:fe}=Ti(i);S=!0,v=le,C={[fe.id]:ee}}else if(v&&!e.hydrationData&&ft(v,i,e.history.location.pathname).active&&(v=null),v)if(v.some(ee=>ee.route.lazy))S=!1;else if(!v.some(ee=>Yd(ee.route)))S=!0;else{let ee=e.hydrationData?e.hydrationData.loaderData:null,le=e.hydrationData?e.hydrationData.errors:null;if(le){let fe=v.findIndex(be=>le[be.route.id]!==void 0);S=v.slice(0,fe+1).every(be=>!Zu(be.route,ee,le))}else S=v.every(fe=>!Zu(fe.route,ee,le))}else{S=!1,v=[];let ee=ft(null,i,e.history.location.pathname);ee.active&&ee.matches&&(b=!0,v=ee.matches)}let E,_={historyAction:e.history.action,location:e.history.location,matches:v,initialized:S,navigation:Kc,restoreScrollPosition:e.hydrationData!=null?!1:null,preventScrollReset:!1,revalidation:"idle",loaderData:e.hydrationData&&e.hydrationData.loaderData||{},actionData:e.hydrationData&&e.hydrationData.actionData||null,errors:e.hydrationData&&e.hydrationData.errors||C,fetchers:new Map,blockers:new Map},j="POP",A=!1,P,O=!1,B=new Map,N=null,M=!1,y=!1,T=new Set,R=new Map,z=0,F=-1,I=new Map,J=new Set,L=new Map,D=new Map,W=new Set,G=new Map,V,Q=null;function X(){if(h=e.history.listen(({action:ee,location:le,delta:fe})=>{if(V){V(),V=void 0;return}an(G.size===0||fe!=null,"You are trying to use a blocker on a POP navigation to a location that was not created by @remix-run/router. This will fail silently in production. This can happen if you are navigating outside the router via `window.history.pushState`/`window.location.hash` instead of using router navigation APIs. This can also happen if you are using createHashRouter and the user manually changes the URL.");let be=Me({currentLocation:_.location,nextLocation:le,historyAction:ee});if(be&&fe!=null){let _e=new Promise(Fe=>{V=Fe});e.history.go(fe*-1),Pe(be,{state:"blocked",location:le,proceed(){Pe(be,{state:"proceeding",proceed:void 0,reset:void 0,location:le}),_e.then(()=>e.history.go(fe))},reset(){let Fe=new Map(_.blockers);Fe.set(be,Ts),ne({blockers:Fe})}});return}return k(ee,le)}),n){jS(t,B);let ee=()=>NS(t,B);t.addEventListener("pagehide",ee),N=()=>t.removeEventListener("pagehide",ee)}return _.initialized||k("POP",_.location,{initialHydration:!0}),E}function K(){h&&h(),N&&N(),m.clear(),P&&P.abort(),_.fetchers.forEach((ee,le)=>Pt(le)),_.blockers.forEach((ee,le)=>ve(le))}function q(ee){return m.add(ee),()=>m.delete(ee)}function ne(ee,le={}){ee.matches&&(ee.matches=ee.matches.map(_e=>{let Fe=a[_e.route.id],He=_e.route;return He.element!==Fe.element||He.errorElement!==Fe.errorElement||He.hydrateFallbackElement!==Fe.hydrateFallbackElement?{..._e,route:Fe}:_e})),_={..._,...ee};let fe=[],be=[];_.fetchers.forEach((_e,Fe)=>{_e.state==="idle"&&(W.has(Fe)?fe.push(Fe):be.push(Fe))}),W.forEach(_e=>{!_.fetchers.has(_e)&&!R.has(_e)&&fe.push(_e)}),[...m].forEach(_e=>_e(_,{deletedFetchers:fe,viewTransitionOpts:le.viewTransitionOpts,flushSync:le.flushSync===!0})),fe.forEach(_e=>Pt(_e)),be.forEach(_e=>_.fetchers.delete(_e))}function de(ee,le,{flushSync:fe}={}){var Se,je;let be=_.actionData!=null&&_.navigation.formMethod!=null&&Qn(_.navigation.formMethod)&&_.navigation.state==="loading"&&((Se=ee.state)==null?void 0:Se._isRedirect)!==!0,_e;le.actionData?Object.keys(le.actionData).length>0?_e=le.actionData:_e=null:be?_e=_.actionData:_e=null;let Fe=le.loaderData?tp(_.loaderData,le.loaderData,le.matches||[],le.errors):_.loaderData,He=_.blockers;He.size>0&&(He=new Map(He),He.forEach((De,Ze)=>He.set(Ze,Ts)));let Le=M?!1:We(ee,le.matches||_.matches),Ve=A===!0||_.navigation.formMethod!=null&&Qn(_.navigation.formMethod)&&((je=ee.state)==null?void 0:je._isRedirect)!==!0;l&&(i=l,l=void 0),M||j==="POP"||(j==="PUSH"?e.history.push(ee,ee.state):j==="REPLACE"&&e.history.replace(ee,ee.state));let Xe;if(j==="POP"){let De=B.get(_.location.pathname);De&&De.has(ee.pathname)?Xe={currentLocation:_.location,nextLocation:ee}:B.has(ee.pathname)&&(Xe={currentLocation:ee,nextLocation:_.location})}else if(O){let De=B.get(_.location.pathname);De?De.add(ee.pathname):(De=new Set([ee.pathname]),B.set(_.location.pathname,De)),Xe={currentLocation:_.location,nextLocation:ee}}ne({...le,actionData:_e,loaderData:Fe,historyAction:j,location:ee,initialized:!0,navigation:Kc,revalidation:"idle",restoreScrollPosition:Le,preventScrollReset:Ve,blockers:He},{viewTransitionOpts:Xe,flushSync:fe===!0}),j="POP",A=!1,O=!1,M=!1,y=!1,Q==null||Q.resolve(),Q=null}async function se(ee,le){if(typeof ee=="number"){e.history.go(ee);return}let fe=Hu(_.location,_.matches,c,ee,le==null?void 0:le.fromRouteId,le==null?void 0:le.relative),{path:be,submission:_e,error:Fe}=Zh(!1,fe,le),He=_.location,Le=$a(_.location,be,le&&le.state);Le={...Le,...e.history.encodeLocation(Le)};let Ve=le&&le.replace!=null?le.replace:void 0,Xe="PUSH";Ve===!0?Xe="REPLACE":Ve===!1||_e!=null&&Qn(_e.formMethod)&&_e.formAction===_.location.pathname+_.location.search&&(Xe="REPLACE");let Se=le&&"preventScrollReset"in le?le.preventScrollReset===!0:void 0,je=(le&&le.flushSync)===!0,De=Me({currentLocation:He,nextLocation:Le,historyAction:Xe});if(De){Pe(De,{state:"blocked",location:Le,proceed(){Pe(De,{state:"proceeding",proceed:void 0,reset:void 0,location:Le}),se(ee,le)},reset(){let Ze=new Map(_.blockers);Ze.set(De,Ts),ne({blockers:Ze})}});return}await k(Xe,Le,{submission:_e,pendingError:Fe,preventScrollReset:Se,replace:le&&le.replace,enableViewTransition:le&&le.viewTransition,flushSync:je})}function me(){Q||(Q=TS()),ae(),ne({revalidation:"loading"});let ee=Q.promise;return _.navigation.state==="submitting"?ee:_.navigation.state==="idle"?(k(_.historyAction,_.location,{startUninterruptedRevalidation:!0}),ee):(k(j||_.historyAction,_.navigation.location,{overrideNavigation:_.navigation,enableViewTransition:O===!0}),ee)}async function k(ee,le,fe){P&&P.abort(),P=null,j=ee,M=(fe&&fe.startUninterruptedRevalidation)===!0,it(_.location,_.matches),A=(fe&&fe.preventScrollReset)===!0,O=(fe&&fe.enableViewTransition)===!0;let be=l||i,_e=fe&&fe.overrideNavigation,Fe=fe!=null&&fe.initialHydration&&_.matches&&_.matches.length>0&&!b?_.matches:No(be,le,c),He=(fe&&fe.flushSync)===!0;if(Fe&&_.initialized&&!y&&bS(_.location,le)&&!(fe&&fe.submission&&Qn(fe.submission.formMethod))){de(le,{matches:Fe},{flushSync:He});return}let Le=ft(Fe,be,le.pathname);if(Le.active&&Le.matches&&(Fe=Le.matches),!Fe){let{error:At,notFoundMatches:ke,route:te}=Oe(le.pathname);de(le,{matches:ke,loaderData:{},errors:{[te.id]:At}},{flushSync:He});return}P=new AbortController;let Ve=As(e.history,le,P.signal,fe&&fe.submission),Xe=e.getContext?await e.getContext():new Wh,Se;if(fe&&fe.pendingError)Se=[To(Fe).route.id,{type:"error",error:fe.pendingError}];else if(fe&&fe.submission&&Qn(fe.submission.formMethod)){let At=await oe(Ve,le,fe.submission,Fe,Xe,Le.active,fe&&fe.initialHydration===!0,{replace:fe.replace,flushSync:He});if(At.shortCircuited)return;if(At.pendingActionResult){let[ke,te]=At.pendingActionResult;if(lr(te)&&Ua(te.error)&&te.error.status===404){P=null,de(le,{matches:At.matches,loaderData:{},errors:{[ke]:te.error}});return}}Fe=At.matches||Fe,Se=At.pendingActionResult,_e=qc(le,fe.submission),He=!1,Le.active=!1,Ve=As(e.history,Ve.url,Ve.signal)}let{shortCircuited:je,matches:De,loaderData:Ze,errors:yt}=await ie(Ve,le,Fe,Xe,Le.active,_e,fe&&fe.submission,fe&&fe.fetcherSubmission,fe&&fe.replace,fe&&fe.initialHydration===!0,He,Se);je||(P=null,de(le,{matches:De||Fe,...np(Se),loaderData:Ze,errors:yt}))}async function oe(ee,le,fe,be,_e,Fe,He,Le={}){ae();let Ve=kS(le,fe);if(ne({navigation:Ve},{flushSync:Le.flushSync===!0}),Fe){let je=await Et(be,le.pathname,ee.signal);if(je.type==="aborted")return{shortCircuited:!0};if(je.type==="error"){if(je.partialMatches.length===0){let{matches:Ze,route:yt}=Ti(i);return{matches:Ze,pendingActionResult:[yt.id,{type:"error",error:je.error}]}}let De=To(je.partialMatches).route.id;return{matches:je.partialMatches,pendingActionResult:[De,{type:"error",error:je.error}]}}else if(je.matches)be=je.matches;else{let{notFoundMatches:De,error:Ze,route:yt}=Oe(le.pathname);return{matches:De,pendingActionResult:[yt.id,{type:"error",error:Ze}]}}}let Xe,Se=al(be,le);if(!Se.route.action&&!Se.route.lazy)Xe={type:"error",error:vr(405,{method:ee.method,pathname:le.pathname,routeId:Se.route.id})};else{let je=$s(o,a,ee,be,Se,He?[]:r,_e),De=await ce(ee,je,_e,null);if(Xe=De[Se.route.id],!Xe){for(let Ze of be)if(De[Ze.route.id]){Xe=De[Ze.route.id];break}}if(ee.signal.aborted)return{shortCircuited:!0}}if(Xo(Xe)){let je;return Le&&Le.replace!=null?je=Le.replace:je=Jh(Xe.response.headers.get("Location"),new URL(ee.url),c)===_.location.pathname+_.location.search,await H(ee,Xe,!0,{submission:fe,replace:je}),{shortCircuited:!0}}if(lr(Xe)){let je=To(be,Se.route.id);return(Le&&Le.replace)!==!0&&(j="PUSH"),{matches:be,pendingActionResult:[je.route.id,Xe,Se.route.id]}}return{matches:be,pendingActionResult:[Se.route.id,Xe]}}async function ie(ee,le,fe,be,_e,Fe,He,Le,Ve,Xe,Se,je){let De=Fe||qc(le,He),Ze=He||Le||op(De),yt=!M&&!Xe;if(_e){if(yt){let Lt=Z(je);ne({navigation:De,...Lt!==void 0?{actionData:Lt}:{}},{flushSync:Se})}let Qe=await Et(fe,le.pathname,ee.signal);if(Qe.type==="aborted")return{shortCircuited:!0};if(Qe.type==="error"){if(Qe.partialMatches.length===0){let{matches:or,route:gr}=Ti(i);return{matches:or,loaderData:{},errors:{[gr.id]:Qe.error}}}let Lt=To(Qe.partialMatches).route.id;return{matches:Qe.partialMatches,loaderData:{},errors:{[Lt]:Qe.error}}}else if(Qe.matches)fe=Qe.matches;else{let{error:Lt,notFoundMatches:or,route:gr}=Oe(le.pathname);return{matches:or,loaderData:{},errors:{[gr.id]:Lt}}}}let At=l||i,{dsMatches:ke,revalidatingFetchers:te}=Gh(ee,be,o,a,e.history,_,fe,Ze,le,Xe?[]:r,Xe===!0,y,T,W,L,J,At,c,e.patchRoutesOnNavigation!=null,je);if(F=++z,!e.dataStrategy&&!ke.some(Qe=>Qe.shouldLoad)&&!ke.some(Qe=>Qe.route.middleware&&Qe.route.middleware.length>0)&&te.length===0){let Qe=$t();return de(le,{matches:fe,loaderData:{},errors:je&&lr(je[1])?{[je[0]]:je[1].error}:null,...np(je),...Qe?{fetchers:new Map(_.fetchers)}:{}},{flushSync:Se}),{shortCircuited:!0}}if(yt){let Qe={};if(!_e){Qe.navigation=De;let Lt=Z(je);Lt!==void 0&&(Qe.actionData=Lt)}te.length>0&&(Qe.fetchers=U(te)),ne(Qe,{flushSync:Se})}te.forEach(Qe=>{Mt(Qe.key),Qe.controller&&R.set(Qe.key,Qe.controller)});let ge=()=>te.forEach(Qe=>Mt(Qe.key));P&&P.signal.addEventListener("abort",ge);let{loaderResults:Ie,fetcherResults:$e}=await ue(ke,te,ee,be);if(ee.signal.aborted)return{shortCircuited:!0};P&&P.signal.removeEventListener("abort",ge),te.forEach(Qe=>R.delete(Qe.key));let nt=Ai(Ie);if(nt)return await H(ee,nt.result,!0,{replace:Ve}),{shortCircuited:!0};if(nt=Ai($e),nt)return J.add(nt.key),await H(ee,nt.result,!0,{replace:Ve}),{shortCircuited:!0};let{loaderData:wt,errors:Ot}=ep(_,fe,Ie,je,te,$e);Xe&&_.errors&&(Ot={..._.errors,...Ot});let Ct=$t(),Tt=Wt(F),pn=Ct||Tt||te.length>0;return{matches:fe,loaderData:wt,errors:Ot,...pn?{fetchers:new Map(_.fetchers)}:{}}}function Z(ee){if(ee&&!lr(ee[1]))return{[ee[0]]:ee[1].data};if(_.actionData)return Object.keys(_.actionData).length===0?null:_.actionData}function U(ee){return ee.forEach(le=>{let fe=_.fetchers.get(le.key),be=xa(void 0,fe?fe.data:void 0);_.fetchers.set(le.key,be)}),new Map(_.fetchers)}async function re(ee,le,fe,be){Mt(ee);let _e=(be&&be.flushSync)===!0,Fe=l||i,He=Hu(_.location,_.matches,c,fe,le,be==null?void 0:be.relative),Le=No(Fe,He,c),Ve=ft(Le,Fe,He);if(Ve.active&&Ve.matches&&(Le=Ve.matches),!Le){Te(ee,le,vr(404,{pathname:He}),{flushSync:_e});return}let{path:Xe,submission:Se,error:je}=Zh(!0,He,be);if(je){Te(ee,le,je,{flushSync:_e});return}let De=e.getContext?await e.getContext():new Wh,Ze=(be&&be.preventScrollReset)===!0;if(Se&&Qn(Se.formMethod)){await $(ee,le,Xe,Le,De,Ve.active,_e,Ze,Se);return}L.set(ee,{routeId:le,path:Xe}),await Y(ee,le,Xe,Le,De,Ve.active,_e,Ze,Se)}async function $(ee,le,fe,be,_e,Fe,He,Le,Ve){ae(),L.delete(ee);let Xe=_.fetchers.get(ee);pe(ee,ES(Ve,Xe),{flushSync:He});let Se=new AbortController,je=As(e.history,fe,Se.signal,Ve);if(Fe){let xt=await Et(be,new URL(je.url).pathname,je.signal,ee);if(xt.type==="aborted")return;if(xt.type==="error"){Te(ee,le,xt.error,{flushSync:He});return}else if(xt.matches)be=xt.matches;else{Te(ee,le,vr(404,{pathname:fe}),{flushSync:He});return}}let De=al(be,fe);if(!De.route.action&&!De.route.lazy){let xt=vr(405,{method:Ve.formMethod,pathname:fe,routeId:le});Te(ee,le,xt,{flushSync:He});return}R.set(ee,Se);let Ze=z,yt=$s(o,a,je,be,De,r,_e),ke=(await ce(je,yt,_e,ee))[De.route.id];if(je.signal.aborted){R.get(ee)===Se&&R.delete(ee);return}if(W.has(ee)){if(Xo(ke)||lr(ke)){pe(ee,io(void 0));return}}else{if(Xo(ke))if(R.delete(ee),F>Ze){pe(ee,io(void 0));return}else return J.add(ee),pe(ee,xa(Ve)),H(je,ke,!1,{fetcherSubmission:Ve,preventScrollReset:Le});if(lr(ke)){Te(ee,le,ke.error);return}}let te=_.navigation.location||_.location,ge=As(e.history,te,Se.signal),Ie=l||i,$e=_.navigation.state!=="idle"?No(Ie,_.navigation.location,c):_.matches;_t($e,"Didn't find any matches after fetcher action");let nt=++z;I.set(ee,nt);let wt=xa(Ve,ke.data);_.fetchers.set(ee,wt);let{dsMatches:Ot,revalidatingFetchers:Ct}=Gh(ge,_e,o,a,e.history,_,$e,Ve,te,r,!1,y,T,W,L,J,Ie,c,e.patchRoutesOnNavigation!=null,[De.route.id,ke]);Ct.filter(xt=>xt.key!==ee).forEach(xt=>{let zn=xt.key,kr=_.fetchers.get(zn),sr=xa(void 0,kr?kr.data:void 0);_.fetchers.set(zn,sr),Mt(zn),xt.controller&&R.set(zn,xt.controller)}),ne({fetchers:new Map(_.fetchers)});let Tt=()=>Ct.forEach(xt=>Mt(xt.key));Se.signal.addEventListener("abort",Tt);let{loaderResults:pn,fetcherResults:Qe}=await ue(Ot,Ct,ge,_e);if(Se.signal.aborted)return;if(Se.signal.removeEventListener("abort",Tt),I.delete(ee),R.delete(ee),Ct.forEach(xt=>R.delete(xt.key)),_.fetchers.has(ee)){let xt=io(ke.data);_.fetchers.set(ee,xt)}let Lt=Ai(pn);if(Lt)return H(ge,Lt.result,!1,{preventScrollReset:Le});if(Lt=Ai(Qe),Lt)return J.add(Lt.key),H(ge,Lt.result,!1,{preventScrollReset:Le});let{loaderData:or,errors:gr}=ep(_,$e,pn,void 0,Ct,Qe);Wt(nt),_.navigation.state==="loading"&&nt>F?(_t(j,"Expected pending action"),P&&P.abort(),de(_.navigation.location,{matches:$e,loaderData:or,errors:gr,fetchers:new Map(_.fetchers)})):(ne({errors:gr,loaderData:tp(_.loaderData,or,$e,gr),fetchers:new Map(_.fetchers)}),y=!1)}async function Y(ee,le,fe,be,_e,Fe,He,Le,Ve){let Xe=_.fetchers.get(ee);pe(ee,xa(Ve,Xe?Xe.data:void 0),{flushSync:He});let Se=new AbortController,je=As(e.history,fe,Se.signal);if(Fe){let te=await Et(be,new URL(je.url).pathname,je.signal,ee);if(te.type==="aborted")return;if(te.type==="error"){Te(ee,le,te.error,{flushSync:He});return}else if(te.matches)be=te.matches;else{Te(ee,le,vr(404,{pathname:fe}),{flushSync:He});return}}let De=al(be,fe);R.set(ee,Se);let Ze=z,yt=$s(o,a,je,be,De,r,_e),ke=(await ce(je,yt,_e,ee))[De.route.id];if(R.get(ee)===Se&&R.delete(ee),!je.signal.aborted){if(W.has(ee)){pe(ee,io(void 0));return}if(Xo(ke))if(F>Ze){pe(ee,io(void 0));return}else{J.add(ee),await H(je,ke,!1,{preventScrollReset:Le});return}if(lr(ke)){Te(ee,le,ke.error);return}pe(ee,io(ke.data))}}async function H(ee,le,fe,{submission:be,fetcherSubmission:_e,preventScrollReset:Fe,replace:He}={}){le.response.headers.has("X-Remix-Revalidate")&&(y=!0);let Le=le.response.headers.get("Location");_t(Le,"Expected a Location header on the redirect Response"),Le=Jh(Le,new URL(ee.url),c);let Ve=$a(_.location,Le,{_isRedirect:!0});if(n){let yt=!1;if(le.response.headers.has("X-Remix-Reload-Document"))yt=!0;else if(Gd(Le)){const At=Xg(Le,!0);yt=At.origin!==t.location.origin||tr(At.pathname,c)==null}if(yt){He?t.location.replace(Le):t.location.assign(Le);return}}P=null;let Xe=He===!0||le.response.headers.has("X-Remix-Replace")?"REPLACE":"PUSH",{formMethod:Se,formAction:je,formEncType:De}=_.navigation;!be&&!_e&&Se&&je&&De&&(be=op(_.navigation));let Ze=be||_e;if(rS.has(le.response.status)&&Ze&&Qn(Ze.formMethod))await k(Xe,Ve,{submission:{...Ze,formAction:Le},preventScrollReset:Fe||A,enableViewTransition:fe?O:void 0});else{let yt=qc(Ve,be);await k(Xe,Ve,{overrideNavigation:yt,fetcherSubmission:_e,preventScrollReset:Fe||A,enableViewTransition:fe?O:void 0})}}async function ce(ee,le,fe,be){let _e,Fe={};try{_e=await pS(u,ee,le,be,fe,!1)}catch(He){return le.filter(Le=>Le.shouldLoad).forEach(Le=>{Fe[Le.route.id]={type:"error",error:He}}),Fe}if(ee.signal.aborted)return Fe;for(let[He,Le]of Object.entries(_e))if(SS(Le)){let Ve=Le.result;Fe[He]={type:"redirect",response:vS(Ve,ee,He,le,c)}}else Fe[He]=await xS(Le);return Fe}async function ue(ee,le,fe,be){let _e=ce(fe,ee,be,null),Fe=Promise.all(le.map(async Ve=>{if(Ve.matches&&Ve.match&&Ve.request&&Ve.controller){let Se=(await ce(Ve.request,Ve.matches,be,Ve.key))[Ve.match.route.id];return{[Ve.key]:Se}}else return Promise.resolve({[Ve.key]:{type:"error",error:vr(404,{pathname:Ve.path})}})})),He=await _e,Le=(await Fe).reduce((Ve,Xe)=>Object.assign(Ve,Xe),{});return{loaderResults:He,fetcherResults:Le}}function ae(){y=!0,L.forEach((ee,le)=>{R.has(le)&&T.add(le),Mt(le)})}function pe(ee,le,fe={}){_.fetchers.set(ee,le),ne({fetchers:new Map(_.fetchers)},{flushSync:(fe&&fe.flushSync)===!0})}function Te(ee,le,fe,be={}){let _e=To(_.matches,le);Pt(ee),ne({errors:{[_e.route.id]:fe},fetchers:new Map(_.fetchers)},{flushSync:(be&&be.flushSync)===!0})}function Ae(ee){return D.set(ee,(D.get(ee)||0)+1),W.has(ee)&&W.delete(ee),_.fetchers.get(ee)||oS}function gt(ee,le){Mt(ee,le==null?void 0:le.reason),pe(ee,io(null))}function Pt(ee){let le=_.fetchers.get(ee);R.has(ee)&&!(le&&le.state==="loading"&&I.has(ee))&&Mt(ee),L.delete(ee),I.delete(ee),J.delete(ee),W.delete(ee),T.delete(ee),_.fetchers.delete(ee)}function Nt(ee){let le=(D.get(ee)||0)-1;le<=0?(D.delete(ee),W.add(ee)):D.set(ee,le),ne({fetchers:new Map(_.fetchers)})}function Mt(ee,le){let fe=R.get(ee);fe&&(fe.abort(le),R.delete(ee))}function ct(ee){for(let le of ee){let fe=Ae(le),be=io(fe.data);_.fetchers.set(le,be)}}function $t(){let ee=[],le=!1;for(let fe of J){let be=_.fetchers.get(fe);_t(be,`Expected fetcher: ${fe}`),be.state==="loading"&&(J.delete(fe),ee.push(fe),le=!0)}return ct(ee),le}function Wt(ee){let le=[];for(let[fe,be]of I)if(be<ee){let _e=_.fetchers.get(fe);_t(_e,`Expected fetcher: ${fe}`),_e.state==="loading"&&(Mt(fe),I.delete(fe),le.push(fe))}return ct(le),le.length>0}function Dt(ee,le){let fe=_.blockers.get(ee)||Ts;return G.get(ee)!==le&&G.set(ee,le),fe}function ve(ee){_.blockers.delete(ee),G.delete(ee)}function Pe(ee,le){let fe=_.blockers.get(ee)||Ts;_t(fe.state==="unblocked"&&le.state==="blocked"||fe.state==="blocked"&&le.state==="blocked"||fe.state==="blocked"&&le.state==="proceeding"||fe.state==="blocked"&&le.state==="unblocked"||fe.state==="proceeding"&&le.state==="unblocked",`Invalid blocker state transition: ${fe.state} -> ${le.state}`);let be=new Map(_.blockers);be.set(ee,le),ne({blockers:be})}function Me({currentLocation:ee,nextLocation:le,historyAction:fe}){if(G.size===0)return;G.size>1&&an(!1,"A router only supports one blocker at a time");let be=Array.from(G.entries()),[_e,Fe]=be[be.length-1],He=_.blockers.get(_e);if(!(He&&He.state==="proceeding")&&Fe({currentLocation:ee,nextLocation:le,historyAction:fe}))return _e}function Oe(ee){let le=vr(404,{pathname:ee}),fe=l||i,{matches:be,route:_e}=Ti(fe);return{notFoundMatches:be,route:_e,error:le}}function at(ee,le,fe){if(p=ee,g=le,x=fe||null,!w&&_.navigation===Kc){w=!0;let be=We(_.location,_.matches);be!=null&&ne({restoreScrollPosition:be})}return()=>{p=null,g=null,x=null}}function Ue(ee,le){return x&&x(ee,le.map(be=>MC(be,_.loaderData)))||ee.key}function it(ee,le){if(p&&g){let fe=Ue(ee,le);p[fe]=g()}}function We(ee,le){if(p){let fe=Ue(ee,le),be=p[fe];if(typeof be=="number")return be}return null}function ft(ee,le,fe){if(e.patchRoutesOnNavigation)if(ee){if(Object.keys(ee[0].params).length>0)return{active:!0,matches:sl(le,fe,c,!0)}}else return{active:!0,matches:sl(le,fe,c,!0)||[]};return{active:!1,matches:null}}async function Et(ee,le,fe,be){if(!e.patchRoutesOnNavigation)return{type:"success",matches:ee};let _e=ee;for(;;){let Fe=l==null,He=l||i,Le=a;try{await e.patchRoutesOnNavigation({signal:fe,path:le,matches:_e,fetcherKey:be,patch:(Se,je)=>{fe.aborted||Yh(Se,je,He,Le,o,!1)}})}catch(Se){return{type:"error",error:Se,partialMatches:_e}}finally{Fe&&!fe.aborted&&(i=[...i])}if(fe.aborted)return{type:"aborted"};let Ve=No(He,le,c);if(Ve)return{type:"success",matches:Ve};let Xe=sl(He,le,c,!0);if(!Xe||_e.length===Xe.length&&_e.every((Se,je)=>Se.route.id===Xe[je].route.id))return{type:"success",matches:null};_e=Xe}}function hn(ee){a={},l=za(ee,o,void 0,a)}function Dn(ee,le,fe=!1){let be=l==null;Yh(ee,le,l||i,a,o,fe),be&&(i=[...i],ne({}))}return E={get basename(){return c},get future(){return f},get state(){return _},get routes(){return i},get window(){return t},initialize:X,subscribe:q,enableScrollRestoration:at,navigate:se,fetch:re,revalidate:me,createHref:ee=>e.history.createHref(ee),encodeLocation:ee=>e.history.encodeLocation(ee),getFetcher:Ae,resetFetcher:gt,deleteFetcher:Nt,dispose:K,getBlocker:Dt,deleteBlocker:ve,patchRoutes:Dn,_internalFetchControllers:R,_internalSetRoutes:hn,_internalSetStateDoNotUseOrYouWillBreakYourApp(ee){ne(ee)}},E}function lS(e){return e!=null&&("formData"in e&&e.formData!=null||"body"in e&&e.body!==void 0)}function Hu(e,t,n,r,o,a){let i,l;if(o){i=[];for(let u of t)if(i.push(u),u.route.id===o){l=u;break}}else i=t,l=t[t.length-1];let c=Kl(r||".",Yl(i),tr(e.pathname,n)||e.pathname,a==="path");if(r==null&&(c.search=e.search,c.hash=e.hash),(r==null||r===""||r===".")&&l){let u=Kd(c.search);if(l.route.index&&!u)c.search=c.search?c.search.replace(/^\?/,"?index&"):"?index";else if(!l.route.index&&u){let f=new URLSearchParams(c.search),h=f.getAll("index");f.delete("index"),h.filter(p=>p).forEach(p=>f.append("index",p));let m=f.toString();c.search=m?`?${m}`:""}}return n!=="/"&&(c.pathname=GC({basename:n,pathname:c.pathname})),Do(c)}function Zh(e,t,n){if(!n||!lS(n))return{path:t};if(n.formMethod&&!_S(n.formMethod))return{path:t,error:vr(405,{method:n.formMethod})};let r=()=>({path:t,error:vr(400,{type:"invalid-body"})}),a=(n.formMethod||"get").toUpperCase(),i=cx(t);if(n.body!==void 0){if(n.formEncType==="text/plain"){if(!Qn(a))return r();let h=typeof n.body=="string"?n.body:n.body instanceof FormData||n.body instanceof URLSearchParams?Array.from(n.body.entries()).reduce((m,[p,x])=>`${m}${p}=${x}
11
+ `,""):String(n.body);return{path:t,submission:{formMethod:a,formAction:i,formEncType:n.formEncType,formData:void 0,json:void 0,text:h}}}else if(n.formEncType==="application/json"){if(!Qn(a))return r();try{let h=typeof n.body=="string"?JSON.parse(n.body):n.body;return{path:t,submission:{formMethod:a,formAction:i,formEncType:n.formEncType,formData:void 0,json:h,text:void 0}}}catch{return r()}}}_t(typeof FormData=="function","FormData is not available in this environment");let l,c;if(n.formData)l=Yu(n.formData),c=n.formData;else if(n.body instanceof FormData)l=Yu(n.body),c=n.body;else if(n.body instanceof URLSearchParams)l=n.body,c=Qh(l);else if(n.body==null)l=new URLSearchParams,c=new FormData;else try{l=new URLSearchParams(n.body),c=Qh(l)}catch{return r()}let u={formMethod:a,formAction:i,formEncType:n&&n.formEncType||"application/x-www-form-urlencoded",formData:c,json:void 0,text:void 0};if(Qn(u.formMethod))return{path:t,submission:u};let f=So(t);return e&&f.search&&Kd(f.search)&&l.append("index",""),f.search=`?${l}`,{path:Do(f),submission:u}}function Gh(e,t,n,r,o,a,i,l,c,u,f,h,m,p,x,g,w,v,b,C){var M;let S=C?lr(C[1])?C[1].error:C[1].data:void 0,E=o.createURL(a.location),_=o.createURL(c),j;if(f&&a.errors){let y=Object.keys(a.errors)[0];j=i.findIndex(T=>T.route.id===y)}else if(C&&lr(C[1])){let y=C[0];j=i.findIndex(T=>T.route.id===y)-1}let A=C?C[1].statusCode:void 0,P=A&&A>=400,O={currentUrl:E,currentParams:((M=a.matches[0])==null?void 0:M.params)||{},nextUrl:_,nextParams:i[0].params,...l,actionResult:S,actionStatus:A},B=i.map((y,T)=>{let{route:R}=y,z=null;if(j!=null&&T>j?z=!1:R.lazy?z=!0:Yd(R)?f?z=Zu(R,a.loaderData,a.errors):cS(a.loaderData,a.matches[T],y)&&(z=!0):z=!1,z!==null)return Gu(n,r,e,y,u,t,z);let F=P?!1:h||E.pathname+E.search===_.pathname+_.search||E.search!==_.search||uS(a.matches[T],y),I={...O,defaultShouldRevalidate:F},J=yl(y,I);return Gu(n,r,e,y,u,t,J,I)}),N=[];return x.forEach((y,T)=>{if(f||!i.some(W=>W.route.id===y.routeId)||p.has(T))return;let R=a.fetchers.get(T),z=R&&R.state!=="idle"&&R.data===void 0,F=No(w,y.path,v);if(!F){if(b&&z)return;N.push({key:T,routeId:y.routeId,path:y.path,matches:null,match:null,request:null,controller:null});return}if(g.has(T))return;let I=al(F,y.path),J=new AbortController,L=As(o,y.path,J.signal),D=null;if(m.has(T))m.delete(T),D=$s(n,r,L,F,I,u,t);else if(z)h&&(D=$s(n,r,L,F,I,u,t));else{let W={...O,defaultShouldRevalidate:P?!1:h};yl(I,W)&&(D=$s(n,r,L,F,I,u,t,W))}D&&N.push({key:T,routeId:y.routeId,path:y.path,matches:D,match:I,request:L,controller:J})}),{dsMatches:B,revalidatingFetchers:N}}function Yd(e){return e.loader!=null||e.middleware!=null&&e.middleware.length>0}function Zu(e,t,n){if(e.lazy)return!0;if(!Yd(e))return!1;let r=t!=null&&e.id in t,o=n!=null&&n[e.id]!==void 0;return!r&&o?!1:typeof e.loader=="function"&&e.loader.hydrate===!0?!0:!r&&!o}function cS(e,t,n){let r=!t||n.route.id!==t.route.id,o=!e.hasOwnProperty(n.route.id);return r||o}function uS(e,t){let n=e.route.path;return e.pathname!==t.pathname||n!=null&&n.endsWith("*")&&e.params["*"]!==t.params["*"]}function yl(e,t){if(e.route.shouldRevalidate){let n=e.route.shouldRevalidate(t);if(typeof n=="boolean")return n}return t.defaultShouldRevalidate}function Yh(e,t,n,r,o,a){let i;if(e){let u=r[e];_t(u,`No route found to patch children into: routeId = ${e}`),u.children||(u.children=[]),i=u.children}else i=n;let l=[],c=[];if(t.forEach(u=>{let f=i.find(h=>ox(u,h));f?c.push({existingRoute:f,newRoute:u}):l.push(u)}),l.length>0){let u=za(l,o,[e||"_","patch",String((i==null?void 0:i.length)||"0")],r);i.push(...u)}if(a&&c.length>0)for(let u=0;u<c.length;u++){let{existingRoute:f,newRoute:h}=c[u],m=f,[p]=za([h],o,[],{},!0);Object.assign(m,{element:p.element?p.element:m.element,errorElement:p.errorElement?p.errorElement:m.errorElement,hydrateFallbackElement:p.hydrateFallbackElement?p.hydrateFallbackElement:m.hydrateFallbackElement})}}function ox(e,t){return"id"in e&&"id"in t&&e.id===t.id?!0:e.index===t.index&&e.path===t.path&&e.caseSensitive===t.caseSensitive?(!e.children||e.children.length===0)&&(!t.children||t.children.length===0)?!0:e.children.every((n,r)=>{var o;return(o=t.children)==null?void 0:o.some(a=>ox(n,a))}):!1}var Kh=new WeakMap,sx=({key:e,route:t,manifest:n,mapRouteProperties:r})=>{let o=n[t.id];if(_t(o,"No route found in manifest"),!o.lazy||typeof o.lazy!="object")return;let a=o.lazy[e];if(!a)return;let i=Kh.get(o);i||(i={},Kh.set(o,i));let l=i[e];if(l)return l;let c=(async()=>{let u=AC(e),h=o[e]!==void 0&&e!=="hasErrorBoundary";if(u)an(!u,"Route property "+e+" is not a supported lazy route property. This property will be ignored."),i[e]=Promise.resolve();else if(h)an(!1,`Route "${o.id}" has a static property "${e}" defined. The lazy property will be ignored.`);else{let m=await a();m!=null&&(Object.assign(o,{[e]:m}),Object.assign(o,r(o)))}typeof o.lazy=="object"&&(o.lazy[e]=void 0,Object.values(o.lazy).every(m=>m===void 0)&&(o.lazy=void 0))})();return i[e]=c,c},qh=new WeakMap;function dS(e,t,n,r,o){let a=n[e.id];if(_t(a,"No route found in manifest"),!e.lazy)return{lazyRoutePromise:void 0,lazyHandlerPromise:void 0};if(typeof e.lazy=="function"){let f=qh.get(a);if(f)return{lazyRoutePromise:f,lazyHandlerPromise:f};let h=(async()=>{_t(typeof e.lazy=="function","No lazy route function found");let m=await e.lazy(),p={};for(let x in m){let g=m[x];if(g===void 0)continue;let w=RC(x),b=a[x]!==void 0&&x!=="hasErrorBoundary";w?an(!w,"Route property "+x+" is not a supported property to be returned from a lazy route function. This property will be ignored."):b?an(!b,`Route "${a.id}" has a static property "${x}" defined but its lazy function is also returning a value for this property. The lazy route property "${x}" will be ignored.`):p[x]=g}Object.assign(a,p),Object.assign(a,{...r(a),lazy:void 0})})();return qh.set(a,h),h.catch(()=>{}),{lazyRoutePromise:h,lazyHandlerPromise:h}}let i=Object.keys(e.lazy),l=[],c;for(let f of i){if(o&&o.includes(f))continue;let h=sx({key:f,route:e,manifest:n,mapRouteProperties:r});h&&(l.push(h),f===t&&(c=h))}let u=l.length>0?Promise.all(l).then(()=>{}):void 0;return u==null||u.catch(()=>{}),c==null||c.catch(()=>{}),{lazyRoutePromise:u,lazyHandlerPromise:c}}async function Xh(e){let t=e.matches.filter(o=>o.shouldLoad),n={};return(await Promise.all(t.map(o=>o.resolve()))).forEach((o,a)=>{n[t[a].route.id]=o}),n}async function fS(e){return e.matches.some(t=>t.route.middleware)?ax(e,()=>Xh(e)):Xh(e)}function ax(e,t){return hS(e,t,r=>r,yS,n);function n(r,o,a){if(a)return Promise.resolve(Object.assign(a.value,{[o]:{type:"error",result:r}}));{let{matches:i}=e,l=Math.min(Math.max(i.findIndex(u=>u.route.id===o),0),Math.max(i.findIndex(u=>u.unstable_shouldCallHandler()),0)),c=To(i,i[l].route.id).route.id;return Promise.resolve({[c]:{type:"error",result:r}})}}}async function hS(e,t,n,r,o){let{matches:a,request:i,params:l,context:c}=e,u=a.flatMap(h=>h.route.middleware?h.route.middleware.map(m=>[h.route.id,m]):[]);return await ix({request:i,params:l,context:c},u,t,n,r,o)}async function ix(e,t,n,r,o,a,i=0){let{request:l}=e;if(l.signal.aborted)throw l.signal.reason??new Error(`Request aborted: ${l.method} ${l.url}`);let c=t[i];if(!c)return await n();let[u,f]=c,h,m=async()=>{if(h)throw new Error("You may only call `next()` once per middleware");try{return h={value:await ix(e,t,n,r,o,a,i+1)},h.value}catch(p){return h={value:await a(p,u,h)},h.value}};try{let p=await f(e,m),x=p!=null?r(p):void 0;return o(x)?x:h?x??h.value:(h={value:await m()},h.value)}catch(p){return await a(p,u,h)}}function lx(e,t,n,r,o){let a=sx({key:"middleware",route:r.route,manifest:t,mapRouteProperties:e}),i=dS(r.route,Qn(n.method)?"action":"loader",t,e,o);return{middleware:a,route:i.lazyRoutePromise,handler:i.lazyHandlerPromise}}function Gu(e,t,n,r,o,a,i,l=null){let c=!1,u=lx(e,t,n,r,o);return{...r,_lazyPromises:u,shouldLoad:i,unstable_shouldRevalidateArgs:l,unstable_shouldCallHandler(f){return c=!0,l?typeof f=="boolean"?yl(r,{...l,defaultShouldRevalidate:f}):yl(r,l):i},resolve(f){let{lazy:h,loader:m,middleware:p}=r.route,x=c||i||f&&!Qn(n.method)&&(h||m),g=p&&p.length>0&&!m&&!h;return x&&!g?mS({request:n,match:r,lazyHandlerPromise:u==null?void 0:u.handler,lazyRoutePromise:u==null?void 0:u.route,handlerOverride:f,scopedContext:a}):Promise.resolve({type:"data",result:void 0})}}}function $s(e,t,n,r,o,a,i,l=null){return r.map(c=>c.route.id!==o.route.id?{...c,shouldLoad:!1,unstable_shouldRevalidateArgs:l,unstable_shouldCallHandler:()=>!1,_lazyPromises:lx(e,t,n,c,a),resolve:()=>Promise.resolve({type:"data",result:void 0})}:Gu(e,t,n,c,a,i,!0,l))}async function pS(e,t,n,r,o,a){n.some(u=>{var f;return(f=u._lazyPromises)==null?void 0:f.middleware})&&await Promise.all(n.map(u=>{var f;return(f=u._lazyPromises)==null?void 0:f.middleware}));let i={request:t,params:n[0].params,context:o,matches:n},c=await e({...i,fetcherKey:r,runClientMiddleware:u=>{let f=i;return ax(f,()=>u({...f,fetcherKey:r,runClientMiddleware:()=>{throw new Error("Cannot call `runClientMiddleware()` from within an `runClientMiddleware` handler")}}))}});try{await Promise.all(n.flatMap(u=>{var f,h;return[(f=u._lazyPromises)==null?void 0:f.handler,(h=u._lazyPromises)==null?void 0:h.route]}))}catch{}return c}async function mS({request:e,match:t,lazyHandlerPromise:n,lazyRoutePromise:r,handlerOverride:o,scopedContext:a}){let i,l,c=Qn(e.method),u=c?"action":"loader",f=h=>{let m,p=new Promise((w,v)=>m=v);l=()=>m(),e.signal.addEventListener("abort",l);let x=w=>typeof h!="function"?Promise.reject(new Error(`You cannot call the handler for a route which defines a boolean "${u}" [routeId: ${t.route.id}]`)):h({request:e,params:t.params,context:a},...w!==void 0?[w]:[]),g=(async()=>{try{return{type:"data",result:await(o?o(v=>x(v)):x())}}catch(w){return{type:"error",result:w}}})();return Promise.race([g,p])};try{let h=c?t.route.action:t.route.loader;if(n||r)if(h){let m,[p]=await Promise.all([f(h).catch(x=>{m=x}),n,r]);if(m!==void 0)throw m;i=p}else{await n;let m=c?t.route.action:t.route.loader;if(m)[i]=await Promise.all([f(m),r]);else if(u==="action"){let p=new URL(e.url),x=p.pathname+p.search;throw vr(405,{method:e.method,pathname:x,routeId:t.route.id})}else return{type:"data",result:void 0}}else if(h)i=await f(h);else{let m=new URL(e.url),p=m.pathname+m.search;throw vr(404,{pathname:p})}}catch(h){return{type:"error",result:h}}finally{l&&e.signal.removeEventListener("abort",l)}return i}async function gS(e){let t=e.headers.get("Content-Type");return t&&/\bapplication\/json\b/.test(t)?e.body==null?null:e.json():e.text()}async function xS(e){var r,o,a,i,l,c;let{result:t,type:n}=e;if(ux(t)){let u;try{u=await gS(t)}catch(f){return{type:"error",error:f}}return n==="error"?{type:"error",error:new bl(t.status,t.statusText,u),statusCode:t.status,headers:t.headers}:{type:"data",data:u,statusCode:t.status,headers:t.headers}}return n==="error"?rp(t)?t.data instanceof Error?{type:"error",error:t.data,statusCode:(r=t.init)==null?void 0:r.status,headers:(o=t.init)!=null&&o.headers?new Headers(t.init.headers):void 0}:{type:"error",error:new bl(((a=t.init)==null?void 0:a.status)||500,void 0,t.data),statusCode:Ua(t)?t.status:void 0,headers:(i=t.init)!=null&&i.headers?new Headers(t.init.headers):void 0}:{type:"error",error:t,statusCode:Ua(t)?t.status:void 0}:rp(t)?{type:"data",data:t.data,statusCode:(l=t.init)==null?void 0:l.status,headers:(c=t.init)!=null&&c.headers?new Headers(t.init.headers):void 0}:{type:"data",data:t}}function vS(e,t,n,r,o){let a=e.headers.get("Location");if(_t(a,"Redirects returned/thrown from loaders/actions must have a Location header"),!Gd(a)){let i=r.slice(0,r.findIndex(l=>l.route.id===n)+1);a=Hu(new URL(t.url),i,o,a),e.headers.set("Location",a)}return e}function Jh(e,t,n){if(Gd(e)){let r=e,o=r.startsWith("//")?new URL(t.protocol+r):new URL(r),a=tr(o.pathname,n)!=null;if(o.origin===t.origin&&a)return o.pathname+o.search+o.hash}return e}function As(e,t,n,r){let o=e.createURL(cx(t)).toString(),a={signal:n};if(r&&Qn(r.formMethod)){let{formMethod:i,formEncType:l}=r;a.method=i.toUpperCase(),l==="application/json"?(a.headers=new Headers({"Content-Type":l}),a.body=JSON.stringify(r.json)):l==="text/plain"?a.body=r.text:l==="application/x-www-form-urlencoded"&&r.formData?a.body=Yu(r.formData):a.body=r.formData}return new Request(o,a)}function Yu(e){let t=new URLSearchParams;for(let[n,r]of e.entries())t.append(n,typeof r=="string"?r:r.name);return t}function Qh(e){let t=new FormData;for(let[n,r]of e.entries())t.append(n,r);return t}function wS(e,t,n,r=!1,o=!1){let a={},i=null,l,c=!1,u={},f=n&&lr(n[1])?n[1].error:void 0;return e.forEach(h=>{if(!(h.route.id in t))return;let m=h.route.id,p=t[m];if(_t(!Xo(p),"Cannot handle redirect results in processLoaderData"),lr(p)){let x=p.error;if(f!==void 0&&(x=f,f=void 0),i=i||{},o)i[m]=x;else{let g=To(e,m);i[g.route.id]==null&&(i[g.route.id]=x)}r||(a[m]=rx),c||(c=!0,l=Ua(p.error)?p.error.status:500),p.headers&&(u[m]=p.headers)}else a[m]=p.data,p.statusCode&&p.statusCode!==200&&!c&&(l=p.statusCode),p.headers&&(u[m]=p.headers)}),f!==void 0&&n&&(i={[n[0]]:f},n[2]&&(a[n[2]]=void 0)),{loaderData:a,errors:i,statusCode:l||200,loaderHeaders:u}}function ep(e,t,n,r,o,a){let{loaderData:i,errors:l}=wS(t,n,r);return o.filter(c=>!c.matches||c.matches.some(u=>u.shouldLoad)).forEach(c=>{let{key:u,match:f,controller:h}=c;if(h&&h.signal.aborted)return;let m=a[u];if(_t(m,"Did not find corresponding fetcher result"),lr(m)){let p=To(e.matches,f==null?void 0:f.route.id);l&&l[p.route.id]||(l={...l,[p.route.id]:m.error}),e.fetchers.delete(u)}else if(Xo(m))_t(!1,"Unhandled fetcher revalidation redirect");else{let p=io(m.data);e.fetchers.set(u,p)}}),{loaderData:i,errors:l}}function tp(e,t,n,r){let o=Object.entries(t).filter(([,a])=>a!==rx).reduce((a,[i,l])=>(a[i]=l,a),{});for(let a of n){let i=a.route.id;if(!t.hasOwnProperty(i)&&e.hasOwnProperty(i)&&a.route.loader&&(o[i]=e[i]),r&&r.hasOwnProperty(i))break}return o}function np(e){return e?lr(e[1])?{actionData:{}}:{actionData:{[e[0]]:e[1].data}}:{}}function To(e,t){return(t?e.slice(0,e.findIndex(r=>r.route.id===t)+1):[...e]).reverse().find(r=>r.route.hasErrorBoundary===!0)||e[0]}function Ti(e){let t=e.length===1?e[0]:e.find(n=>n.index||!n.path||n.path==="/")||{id:"__shim-error-route__"};return{matches:[{params:{},pathname:"",pathnameBase:"",route:t}],route:t}}function vr(e,{pathname:t,routeId:n,method:r,type:o,message:a}={}){let i="Unknown Server Error",l="Unknown @remix-run/router error";return e===400?(i="Bad Request",r&&t&&n?l=`You made a ${r} request to "${t}" but did not provide a \`loader\` for route "${n}", so there is no way to handle the request.`:o==="invalid-body"&&(l="Unable to encode submission body")):e===403?(i="Forbidden",l=`Route "${n}" does not match URL "${t}"`):e===404?(i="Not Found",l=`No route matches URL "${t}"`):e===405&&(i="Method Not Allowed",r&&t&&n?l=`You made a ${r.toUpperCase()} request to "${t}" but did not provide an \`action\` for route "${n}", so there is no way to handle the request.`:r&&(l=`Invalid request method "${r.toUpperCase()}"`)),new bl(e||500,i,new Error(l),!0)}function Ai(e){let t=Object.entries(e);for(let n=t.length-1;n>=0;n--){let[r,o]=t[n];if(Xo(o))return{key:r,result:o}}}function cx(e){let t=typeof e=="string"?So(e):e;return Do({...t,hash:""})}function bS(e,t){return e.pathname!==t.pathname||e.search!==t.search?!1:e.hash===""?t.hash!=="":e.hash===t.hash?!0:t.hash!==""}function yS(e){return e!=null&&typeof e=="object"&&Object.entries(e).every(([t,n])=>typeof t=="string"&&CS(n))}function CS(e){return e!=null&&typeof e=="object"&&"type"in e&&"result"in e&&(e.type==="data"||e.type==="error")}function SS(e){return ux(e.result)&&nS.has(e.result.status)}function lr(e){return e.type==="error"}function Xo(e){return(e&&e.type)==="redirect"}function rp(e){return typeof e=="object"&&e!=null&&"type"in e&&"data"in e&&"init"in e&&e.type==="DataWithResponseInit"}function ux(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.headers=="object"&&typeof e.body<"u"}function _S(e){return tS.has(e.toUpperCase())}function Qn(e){return QC.has(e.toUpperCase())}function Kd(e){return new URLSearchParams(e).getAll("index").some(t=>t==="")}function al(e,t){let n=typeof t=="string"?So(t).search:t.search;if(e[e.length-1].route.index&&Kd(n||""))return e[e.length-1];let r=ex(e);return r[r.length-1]}function op(e){let{formMethod:t,formAction:n,formEncType:r,text:o,formData:a,json:i}=e;if(!(!t||!n||!r)){if(o!=null)return{formMethod:t,formAction:n,formEncType:r,formData:void 0,json:void 0,text:o};if(a!=null)return{formMethod:t,formAction:n,formEncType:r,formData:a,json:void 0,text:void 0};if(i!==void 0)return{formMethod:t,formAction:n,formEncType:r,formData:void 0,json:i,text:void 0}}}function qc(e,t){return t?{state:"loading",location:e,formMethod:t.formMethod,formAction:t.formAction,formEncType:t.formEncType,formData:t.formData,json:t.json,text:t.text}:{state:"loading",location:e,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0}}function kS(e,t){return{state:"submitting",location:e,formMethod:t.formMethod,formAction:t.formAction,formEncType:t.formEncType,formData:t.formData,json:t.json,text:t.text}}function xa(e,t){return e?{state:"loading",formMethod:e.formMethod,formAction:e.formAction,formEncType:e.formEncType,formData:e.formData,json:e.json,text:e.text,data:t}:{state:"loading",formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0,data:t}}function ES(e,t){return{state:"submitting",formMethod:e.formMethod,formAction:e.formAction,formEncType:e.formEncType,formData:e.formData,json:e.json,text:e.text,data:t?t.data:void 0}}function io(e){return{state:"idle",formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0,data:e}}function jS(e,t){try{let n=e.sessionStorage.getItem(nx);if(n){let r=JSON.parse(n);for(let[o,a]of Object.entries(r||{}))a&&Array.isArray(a)&&t.set(o,new Set(a||[]))}}catch{}}function NS(e,t){if(t.size>0){let n={};for(let[r,o]of t)n[r]=[...o];try{e.sessionStorage.setItem(nx,JSON.stringify(n))}catch(r){an(!1,`Failed to save applied view transitions in sessionStorage (${r}).`)}}}function TS(){let e,t,n=new Promise((r,o)=>{e=async a=>{r(a);try{await n}catch{}},t=async a=>{o(a);try{await n}catch{}}});return{promise:n,resolve:e,reject:t}}var ms=d.createContext(null);ms.displayName="DataRouter";var ni=d.createContext(null);ni.displayName="DataRouterState";d.createContext(!1);var qd=d.createContext({isTransitioning:!1});qd.displayName="ViewTransition";var dx=d.createContext(new Map);dx.displayName="Fetchers";var AS=d.createContext(null);AS.displayName="Await";var Ur=d.createContext(null);Ur.displayName="Navigation";var ql=d.createContext(null);ql.displayName="Location";var Br=d.createContext({outlet:null,matches:[],isDataRoute:!1});Br.displayName="Route";var Xd=d.createContext(null);Xd.displayName="RouteError";function IS(e,{relative:t}={}){_t(ca(),"useHref() may be used only in the context of a <Router> component.");let{basename:n,navigator:r}=d.useContext(Ur),{hash:o,pathname:a,search:i}=ri(e,{relative:t}),l=a;return n!=="/"&&(l=a==="/"?n:Jr([n,a])),r.createHref({pathname:l,search:i,hash:o})}function ca(){return d.useContext(ql)!=null}function Vr(){return _t(ca(),"useLocation() may be used only in the context of a <Router> component."),d.useContext(ql).location}var fx="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function hx(e){d.useContext(Ur).static||d.useLayoutEffect(e)}function zo(){let{isDataRoute:e}=d.useContext(Br);return e?ZS():RS()}function RS(){_t(ca(),"useNavigate() may be used only in the context of a <Router> component.");let e=d.useContext(ms),{basename:t,navigator:n}=d.useContext(Ur),{matches:r}=d.useContext(Br),{pathname:o}=Vr(),a=JSON.stringify(Yl(r)),i=d.useRef(!1);return hx(()=>{i.current=!0}),d.useCallback((c,u={})=>{if(an(i.current,fx),!i.current)return;if(typeof c=="number"){n.go(c);return}let f=Kl(c,JSON.parse(a),o,u.relative==="path");e==null&&t!=="/"&&(f.pathname=f.pathname==="/"?t:Jr([t,f.pathname])),(u.replace?n.replace:n.push)(f,u.state,u)},[t,n,a,o,e])}var PS=d.createContext(null);function MS(e){let t=d.useContext(Br).outlet;return d.useMemo(()=>t&&d.createElement(PS.Provider,{value:e},t),[t,e])}function ri(e,{relative:t}={}){let{matches:n}=d.useContext(Br),{pathname:r}=Vr(),o=JSON.stringify(Yl(n));return d.useMemo(()=>Kl(e,JSON.parse(o),r,t==="path"),[e,o,r,t])}function DS(e,t,n,r,o){_t(ca(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:a}=d.useContext(Ur),{matches:i}=d.useContext(Br),l=i[i.length-1],c=l?l.params:{},u=l?l.pathname:"/",f=l?l.pathnameBase:"/",h=l&&l.route;{let b=h&&h.path||"";gx(u,!h||b.endsWith("*")||b.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${u}" (under <Route path="${b}">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render.
12
+
13
+ Please change the parent <Route path="${b}"> to <Route path="${b==="/"?"*":`${b}/*`}">.`)}let m=Vr(),p;p=m;let x=p.pathname||"/",g=x;if(f!=="/"){let b=f.replace(/^\//,"").split("/");g="/"+x.replace(/^\//,"").split("/").slice(b.length).join("/")}let w=No(e,{pathname:g});return an(h||w!=null,`No routes matched location "${p.pathname}${p.search}${p.hash}" `),an(w==null||w[w.length-1].route.element!==void 0||w[w.length-1].route.Component!==void 0||w[w.length-1].route.lazy!==void 0,`Matched leaf route at location "${p.pathname}${p.search}${p.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`),zS(w&&w.map(b=>Object.assign({},b,{params:Object.assign({},c,b.params),pathname:Jr([f,a.encodeLocation?a.encodeLocation(b.pathname.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:b.pathname]),pathnameBase:b.pathnameBase==="/"?f:Jr([f,a.encodeLocation?a.encodeLocation(b.pathnameBase.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:b.pathnameBase])})),i,n,r,o)}function OS(){let e=VS(),t=Ua(e)?`${e.status} ${e.statusText}`:e instanceof Error?e.message:JSON.stringify(e),n=e instanceof Error?e.stack:null,r="rgba(200,200,200, 0.5)",o={padding:"0.5rem",backgroundColor:r},a={padding:"2px 4px",backgroundColor:r},i=null;return console.error("Error handled by React Router default ErrorBoundary:",e),i=d.createElement(d.Fragment,null,d.createElement("p",null,"💿 Hey developer 👋"),d.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",d.createElement("code",{style:a},"ErrorBoundary")," or"," ",d.createElement("code",{style:a},"errorElement")," prop on your route.")),d.createElement(d.Fragment,null,d.createElement("h2",null,"Unexpected Application Error!"),d.createElement("h3",{style:{fontStyle:"italic"}},t),n?d.createElement("pre",{style:o},n):null,i)}var LS=d.createElement(OS,null),FS=class extends d.Component{constructor(e){super(e),this.state={location:e.location,revalidation:e.revalidation,error:e.error}}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.unstable_onError?this.props.unstable_onError(e,t):console.error("React Router caught the following error during render",e)}render(){return this.state.error!==void 0?d.createElement(Br.Provider,{value:this.props.routeContext},d.createElement(Xd.Provider,{value:this.state.error,children:this.props.component})):this.props.children}};function $S({routeContext:e,match:t,children:n}){let r=d.useContext(ms);return r&&r.static&&r.staticContext&&(t.route.errorElement||t.route.ErrorBoundary)&&(r.staticContext._deepestRenderedBoundaryId=t.route.id),d.createElement(Br.Provider,{value:e},n)}function zS(e,t=[],n=null,r=null,o=null){if(e==null){if(!n)return null;if(n.errors)e=n.matches;else if(t.length===0&&!n.initialized&&n.matches.length>0)e=n.matches;else return null}let a=e,i=n==null?void 0:n.errors;if(i!=null){let u=a.findIndex(f=>f.route.id&&(i==null?void 0:i[f.route.id])!==void 0);_t(u>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(i).join(",")}`),a=a.slice(0,Math.min(a.length,u+1))}let l=!1,c=-1;if(n)for(let u=0;u<a.length;u++){let f=a[u];if((f.route.HydrateFallback||f.route.hydrateFallbackElement)&&(c=u),f.route.id){let{loaderData:h,errors:m}=n,p=f.route.loader&&!h.hasOwnProperty(f.route.id)&&(!m||m[f.route.id]===void 0);if(f.route.lazy||p){l=!0,c>=0?a=a.slice(0,c+1):a=[a[0]];break}}}return a.reduceRight((u,f,h)=>{let m,p=!1,x=null,g=null;n&&(m=i&&f.route.id?i[f.route.id]:void 0,x=f.route.errorElement||LS,l&&(c<0&&h===0?(gx("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),p=!0,g=null):c===h&&(p=!0,g=f.route.hydrateFallbackElement||null)));let w=t.concat(a.slice(0,h+1)),v=()=>{let b;return m?b=x:p?b=g:f.route.Component?b=d.createElement(f.route.Component,null):f.route.element?b=f.route.element:b=u,d.createElement($S,{match:f,routeContext:{outlet:u,matches:w,isDataRoute:n!=null},children:b})};return n&&(f.route.ErrorBoundary||f.route.errorElement||h===0)?d.createElement(FS,{location:n.location,revalidation:n.revalidation,component:x,error:m,children:v(),routeContext:{outlet:null,matches:w,isDataRoute:!0},unstable_onError:r}):v()},null)}function Jd(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function px(e){let t=d.useContext(ms);return _t(t,Jd(e)),t}function Qd(e){let t=d.useContext(ni);return _t(t,Jd(e)),t}function US(e){let t=d.useContext(Br);return _t(t,Jd(e)),t}function Xl(e){let t=US(e),n=t.matches[t.matches.length-1];return _t(n.route.id,`${e} can only be used on routes that contain a unique "id"`),n.route.id}function BS(){return Xl("useRouteId")}function mx(){let e=Qd("useLoaderData"),t=Xl("useLoaderData");return e.loaderData[t]}function VS(){var r;let e=d.useContext(Xd),t=Qd("useRouteError"),n=Xl("useRouteError");return e!==void 0?e:(r=t.errors)==null?void 0:r[n]}var WS=0;function HS(e){let{router:t,basename:n}=px("useBlocker"),r=Qd("useBlocker"),[o,a]=d.useState(""),i=d.useCallback(l=>{if(typeof e!="function")return!!e;if(n==="/")return e(l);let{currentLocation:c,nextLocation:u,historyAction:f}=l;return e({currentLocation:{...c,pathname:tr(c.pathname,n)||c.pathname},nextLocation:{...u,pathname:tr(u.pathname,n)||u.pathname},historyAction:f})},[n,e]);return d.useEffect(()=>{let l=String(++WS);return a(l),()=>t.deleteBlocker(l)},[t]),d.useEffect(()=>{o!==""&&t.getBlocker(o,i)},[t,o,i]),o&&r.blockers.has(o)?r.blockers.get(o):Ts}function ZS(){let{router:e}=px("useNavigate"),t=Xl("useNavigate"),n=d.useRef(!1);return hx(()=>{n.current=!0}),d.useCallback(async(o,a={})=>{an(n.current,fx),n.current&&(typeof o=="number"?e.navigate(o):await e.navigate(o,{fromRouteId:t,...a}))},[e,t])}var sp={};function gx(e,t,n){!t&&!sp[e]&&(sp[e]=!0,an(!1,n))}var ap={};function ip(e,t){!e&&!ap[t]&&(ap[t]=!0,console.warn(t))}function GS(e){let t={hasErrorBoundary:e.hasErrorBoundary||e.ErrorBoundary!=null||e.errorElement!=null};return e.Component&&(e.element&&an(!1,"You should not include both `Component` and `element` on your route - `Component` will be used."),Object.assign(t,{element:d.createElement(e.Component),Component:void 0})),e.HydrateFallback&&(e.hydrateFallbackElement&&an(!1,"You should not include both `HydrateFallback` and `hydrateFallbackElement` on your route - `HydrateFallback` will be used."),Object.assign(t,{hydrateFallbackElement:d.createElement(e.HydrateFallback),HydrateFallback:void 0})),e.ErrorBoundary&&(e.errorElement&&an(!1,"You should not include both `ErrorBoundary` and `errorElement` on your route - `ErrorBoundary` will be used."),Object.assign(t,{errorElement:d.createElement(e.ErrorBoundary),ErrorBoundary:void 0})),t}var YS=["HydrateFallback","hydrateFallbackElement"],KS=class{constructor(){this.status="pending",this.promise=new Promise((e,t)=>{this.resolve=n=>{this.status==="pending"&&(this.status="resolved",e(n))},this.reject=n=>{this.status==="pending"&&(this.status="rejected",t(n))}})}};function qS({router:e,flushSync:t,unstable_onError:n}){let[r,o]=d.useState(e.state),[a,i]=d.useState(),[l,c]=d.useState({isTransitioning:!1}),[u,f]=d.useState(),[h,m]=d.useState(),[p,x]=d.useState(),g=d.useRef(new Map),w=d.useCallback(E=>{o(_=>(E.errors&&n&&Object.entries(E.errors).forEach(([j,A])=>{var P;((P=_.errors)==null?void 0:P[j])!==A&&n(A)}),E))},[n]),v=d.useCallback((E,{deletedFetchers:_,flushSync:j,viewTransitionOpts:A})=>{E.fetchers.forEach((O,B)=>{O.data!==void 0&&g.current.set(B,O.data)}),_.forEach(O=>g.current.delete(O)),ip(j===!1||t!=null,'You provided the `flushSync` option to a router update, but you are not using the `<RouterProvider>` from `react-router/dom` so `ReactDOM.flushSync()` is unavailable. Please update your app to `import { RouterProvider } from "react-router/dom"` and ensure you have `react-dom` installed as a dependency to use the `flushSync` option.');let P=e.window!=null&&e.window.document!=null&&typeof e.window.document.startViewTransition=="function";if(ip(A==null||P,"You provided the `viewTransition` option to a router update, but you do not appear to be running in a DOM environment as `window.startViewTransition` is not available."),!A||!P){t&&j?t(()=>w(E)):d.startTransition(()=>w(E));return}if(t&&j){t(()=>{h&&(u&&u.resolve(),h.skipTransition()),c({isTransitioning:!0,flushSync:!0,currentLocation:A.currentLocation,nextLocation:A.nextLocation})});let O=e.window.document.startViewTransition(()=>{t(()=>w(E))});O.finished.finally(()=>{t(()=>{f(void 0),m(void 0),i(void 0),c({isTransitioning:!1})})}),t(()=>m(O));return}h?(u&&u.resolve(),h.skipTransition(),x({state:E,currentLocation:A.currentLocation,nextLocation:A.nextLocation})):(i(E),c({isTransitioning:!0,flushSync:!1,currentLocation:A.currentLocation,nextLocation:A.nextLocation}))},[e.window,t,h,u,w]);d.useLayoutEffect(()=>e.subscribe(v),[e,v]),d.useEffect(()=>{l.isTransitioning&&!l.flushSync&&f(new KS)},[l]),d.useEffect(()=>{if(u&&a&&e.window){let E=a,_=u.promise,j=e.window.document.startViewTransition(async()=>{d.startTransition(()=>w(E)),await _});j.finished.finally(()=>{f(void 0),m(void 0),i(void 0),c({isTransitioning:!1})}),m(j)}},[a,u,e.window,w]),d.useEffect(()=>{u&&a&&r.location.key===a.location.key&&u.resolve()},[u,h,r.location,a]),d.useEffect(()=>{!l.isTransitioning&&p&&(i(p.state),c({isTransitioning:!0,flushSync:!1,currentLocation:p.currentLocation,nextLocation:p.nextLocation}),x(void 0))},[l.isTransitioning,p]);let b=d.useMemo(()=>({createHref:e.createHref,encodeLocation:e.encodeLocation,go:E=>e.navigate(E),push:(E,_,j)=>e.navigate(E,{state:_,preventScrollReset:j==null?void 0:j.preventScrollReset}),replace:(E,_,j)=>e.navigate(E,{replace:!0,state:_,preventScrollReset:j==null?void 0:j.preventScrollReset})}),[e]),C=e.basename||"/",S=d.useMemo(()=>({router:e,navigator:b,static:!1,basename:C,unstable_onError:n}),[e,b,C,n]);return d.createElement(d.Fragment,null,d.createElement(ms.Provider,{value:S},d.createElement(ni.Provider,{value:r},d.createElement(dx.Provider,{value:g.current},d.createElement(qd.Provider,{value:l},d.createElement(e_,{basename:C,location:r.location,navigationType:r.historyAction,navigator:b},d.createElement(XS,{routes:e.routes,future:e.future,state:r,unstable_onError:n})))))),null)}var XS=d.memo(JS);function JS({routes:e,future:t,state:n,unstable_onError:r}){return DS(e,void 0,n,r,t)}function lp({to:e,replace:t,state:n,relative:r}){_t(ca(),"<Navigate> may be used only in the context of a <Router> component.");let{static:o}=d.useContext(Ur);an(!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:a}=d.useContext(Br),{pathname:i}=Vr(),l=zo(),c=Kl(e,Yl(a),i,r==="path"),u=JSON.stringify(c);return d.useEffect(()=>{l(JSON.parse(u),{replace:t,state:n,relative:r})},[l,u,r,t,n]),null}function QS(e){return MS(e.context)}function e_({basename:e="/",children:t=null,location:n,navigationType:r="POP",navigator:o,static:a=!1}){_t(!ca(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let i=e.replace(/^\/*/,"/"),l=d.useMemo(()=>({basename:i,navigator:o,static:a,future:{}}),[i,o,a]);typeof n=="string"&&(n=So(n));let{pathname:c="/",search:u="",hash:f="",state:h=null,key:m="default"}=n,p=d.useMemo(()=>{let x=tr(c,i);return x==null?null:{location:{pathname:x,search:u,hash:f,state:h,key:m},navigationType:r}},[i,c,u,f,h,m,r]);return an(p!=null,`<Router basename="${i}"> is not able to match the URL "${c}${u}${f}" because it does not start with the basename, so the <Router> won't render anything.`),p==null?null:d.createElement(Ur.Provider,{value:l},d.createElement(ql.Provider,{children:t,value:p}))}var il="get",ll="application/x-www-form-urlencoded";function Jl(e){return e!=null&&typeof e.tagName=="string"}function t_(e){return Jl(e)&&e.tagName.toLowerCase()==="button"}function n_(e){return Jl(e)&&e.tagName.toLowerCase()==="form"}function r_(e){return Jl(e)&&e.tagName.toLowerCase()==="input"}function o_(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function s_(e,t){return e.button===0&&(!t||t==="_self")&&!o_(e)}var Ii=null;function a_(){if(Ii===null)try{new FormData(document.createElement("form"),0),Ii=!1}catch{Ii=!0}return Ii}var i_=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function Xc(e){return e!=null&&!i_.has(e)?(an(!1,`"${e}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${ll}"`),null):e}function l_(e,t){let n,r,o,a,i;if(n_(e)){let l=e.getAttribute("action");r=l?tr(l,t):null,n=e.getAttribute("method")||il,o=Xc(e.getAttribute("enctype"))||ll,a=new FormData(e)}else if(t_(e)||r_(e)&&(e.type==="submit"||e.type==="image")){let l=e.form;if(l==null)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let c=e.getAttribute("formaction")||l.getAttribute("action");if(r=c?tr(c,t):null,n=e.getAttribute("formmethod")||l.getAttribute("method")||il,o=Xc(e.getAttribute("formenctype"))||Xc(l.getAttribute("enctype"))||ll,a=new FormData(l,e),!a_()){let{name:u,type:f,value:h}=e;if(f==="image"){let m=u?`${u}.`:"";a.append(`${m}x`,"0"),a.append(`${m}y`,"0")}else u&&a.append(u,h)}}else{if(Jl(e))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');n=il,r=null,o=ll,i=e}return a&&o==="text/plain"&&(i=a,a=void 0),{action:r,method:n.toLowerCase(),encType:o,formData:a,body:i}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function ef(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function c_(e,t,n){let r=typeof e=="string"?new URL(e,typeof window>"u"?"server://singlefetch/":window.location.origin):e;return r.pathname==="/"?r.pathname=`_root.${n}`:t&&tr(r.pathname,t)==="/"?r.pathname=`${t.replace(/\/$/,"")}/_root.${n}`:r.pathname=`${r.pathname.replace(/\/$/,"")}.${n}`,r}async function u_(e,t){if(e.id in t)return t[e.id];try{let n=await import(e.module);return t[e.id]=n,n}catch(n){return console.error(`Error loading route module \`${e.module}\`, reloading page...`),console.error(n),window.__reactRouterContext&&window.__reactRouterContext.isSpaMode,window.location.reload(),new Promise(()=>{})}}function d_(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 f_(e,t,n){let r=await Promise.all(e.map(async o=>{let a=t.routes[o.route.id];if(a){let i=await u_(a,n);return i.links?i.links():[]}return[]}));return g_(r.flat(1).filter(d_).filter(o=>o.rel==="stylesheet"||o.rel==="preload").map(o=>o.rel==="stylesheet"?{...o,rel:"prefetch",as:"style"}:{...o,rel:"prefetch"}))}function cp(e,t,n,r,o,a){let i=(c,u)=>n[u]?c.route.id!==n[u].route.id:!0,l=(c,u)=>{var f;return n[u].pathname!==c.pathname||((f=n[u].route.path)==null?void 0:f.endsWith("*"))&&n[u].params["*"]!==c.params["*"]};return a==="assets"?t.filter((c,u)=>i(c,u)||l(c,u)):a==="data"?t.filter((c,u)=>{var h;let f=r.routes[c.route.id];if(!f||!f.hasLoader)return!1;if(i(c,u)||l(c,u))return!0;if(c.route.shouldRevalidate){let m=c.route.shouldRevalidate({currentUrl:new URL(o.pathname+o.search+o.hash,window.origin),currentParams:((h=n[0])==null?void 0:h.params)||{},nextUrl:new URL(e,window.origin),nextParams:c.params,defaultShouldRevalidate:!0});if(typeof m=="boolean")return m}return!0}):[]}function h_(e,t,{includeHydrateFallback:n}={}){return p_(e.map(r=>{let o=t.routes[r.route.id];if(!o)return[];let a=[o.module];return o.clientActionModule&&(a=a.concat(o.clientActionModule)),o.clientLoaderModule&&(a=a.concat(o.clientLoaderModule)),n&&o.hydrateFallbackModule&&(a=a.concat(o.hydrateFallbackModule)),o.imports&&(a=a.concat(o.imports)),a}).flat(1))}function p_(e){return[...new Set(e)]}function m_(e){let t={},n=Object.keys(e).sort();for(let r of n)t[r]=e[r];return t}function g_(e,t){let n=new Set;return new Set(t),e.reduce((r,o)=>{let a=JSON.stringify(m_(o));return n.has(a)||(n.add(a),r.push({key:a,link:o})),r},[])}function xx(){let e=d.useContext(ms);return ef(e,"You must render this element inside a <DataRouterContext.Provider> element"),e}function x_(){let e=d.useContext(ni);return ef(e,"You must render this element inside a <DataRouterStateContext.Provider> element"),e}var tf=d.createContext(void 0);tf.displayName="FrameworkContext";function vx(){let e=d.useContext(tf);return ef(e,"You must render this element inside a <HydratedRouter> element"),e}function v_(e,t){let n=d.useContext(tf),[r,o]=d.useState(!1),[a,i]=d.useState(!1),{onFocus:l,onBlur:c,onMouseEnter:u,onMouseLeave:f,onTouchStart:h}=t,m=d.useRef(null);d.useEffect(()=>{if(e==="render"&&i(!0),e==="viewport"){let g=v=>{v.forEach(b=>{i(b.isIntersecting)})},w=new IntersectionObserver(g,{threshold:.5});return m.current&&w.observe(m.current),()=>{w.disconnect()}}},[e]),d.useEffect(()=>{if(r){let g=setTimeout(()=>{i(!0)},100);return()=>{clearTimeout(g)}}},[r]);let p=()=>{o(!0)},x=()=>{o(!1),i(!1)};return n?e!=="intent"?[a,m,{}]:[a,m,{onFocus:va(l,p),onBlur:va(c,x),onMouseEnter:va(u,p),onMouseLeave:va(f,x),onTouchStart:va(h,p)}]:[!1,m,{}]}function va(e,t){return n=>{e&&e(n),n.defaultPrevented||t(n)}}function w_({page:e,...t}){let{router:n}=xx(),r=d.useMemo(()=>No(n.routes,e,n.basename),[n.routes,e,n.basename]);return r?d.createElement(y_,{page:e,matches:r,...t}):null}function b_(e){let{manifest:t,routeModules:n}=vx(),[r,o]=d.useState([]);return d.useEffect(()=>{let a=!1;return f_(e,t,n).then(i=>{a||o(i)}),()=>{a=!0}},[e,t,n]),r}function y_({page:e,matches:t,...n}){let r=Vr(),{manifest:o,routeModules:a}=vx(),{basename:i}=xx(),{loaderData:l,matches:c}=x_(),u=d.useMemo(()=>cp(e,t,c,o,r,"data"),[e,t,c,o,r]),f=d.useMemo(()=>cp(e,t,c,o,r,"assets"),[e,t,c,o,r]),h=d.useMemo(()=>{if(e===r.pathname+r.search+r.hash)return[];let x=new Set,g=!1;if(t.forEach(v=>{var C;let b=o.routes[v.route.id];!b||!b.hasLoader||(!u.some(S=>S.route.id===v.route.id)&&v.route.id in l&&((C=a[v.route.id])!=null&&C.shouldRevalidate)||b.hasClientLoader?g=!0:x.add(v.route.id))}),x.size===0)return[];let w=c_(e,i,"data");return g&&x.size>0&&w.searchParams.set("_routes",t.filter(v=>x.has(v.route.id)).map(v=>v.route.id).join(",")),[w.pathname+w.search]},[i,l,r,o,u,t,e,a]),m=d.useMemo(()=>h_(f,o),[f,o]),p=b_(f);return d.createElement(d.Fragment,null,h.map(x=>d.createElement("link",{key:x,rel:"prefetch",as:"fetch",href:x,...n})),m.map(x=>d.createElement("link",{key:x,rel:"modulepreload",href:x,...n})),p.map(({key:x,link:g})=>d.createElement("link",{key:x,nonce:n.nonce,...g})))}function C_(...e){return t=>{e.forEach(n=>{typeof n=="function"?n(t):n!=null&&(n.current=t)})}}var wx=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{wx&&(window.__reactRouterVersion="7.9.3")}catch{}function S_(e,t){return iS({basename:t==null?void 0:t.basename,getContext:t==null?void 0:t.getContext,future:t==null?void 0:t.future,history:EC({window:t==null?void 0:t.window}),hydrationData:__(),routes:e,mapRouteProperties:GS,hydrationRouteProperties:YS,dataStrategy:t==null?void 0:t.dataStrategy,patchRoutesOnNavigation:t==null?void 0:t.patchRoutesOnNavigation,window:t==null?void 0:t.window}).initialize()}function __(){let e=window==null?void 0:window.__staticRouterHydrationData;return e&&e.errors&&(e={...e,errors:k_(e.errors)}),e}function k_(e){if(!e)return null;let t=Object.entries(e),n={};for(let[r,o]of t)if(o&&o.__type==="RouteErrorResponse")n[r]=new bl(o.status,o.statusText,o.data,o.internal===!0);else if(o&&o.__type==="Error"){if(o.__subType){let a=window[o.__subType];if(typeof a=="function")try{let i=new a(o.message);i.stack="",n[r]=i}catch{}}if(n[r]==null){let a=new Error(o.message);a.stack="",n[r]=a}}else n[r]=o;return n}var bx=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,yx=d.forwardRef(function({onClick:t,discover:n="render",prefetch:r="none",relative:o,reloadDocument:a,replace:i,state:l,target:c,to:u,preventScrollReset:f,viewTransition:h,...m},p){let{basename:x}=d.useContext(Ur),g=typeof u=="string"&&bx.test(u),w,v=!1;if(typeof u=="string"&&g&&(w=u,wx))try{let P=new URL(window.location.href),O=u.startsWith("//")?new URL(P.protocol+u):new URL(u),B=tr(O.pathname,x);O.origin===P.origin&&B!=null?u=B+O.search+O.hash:v=!0}catch{an(!1,`<Link to="${u}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}let b=IS(u,{relative:o}),[C,S,E]=v_(r,m),_=T_(u,{replace:i,state:l,target:c,preventScrollReset:f,relative:o,viewTransition:h});function j(P){t&&t(P),P.defaultPrevented||_(P)}let A=d.createElement("a",{...m,...E,href:w||b,onClick:v||a?t:j,ref:C_(p,S),target:c,"data-discover":!g&&n==="render"?"true":void 0});return C&&!g?d.createElement(d.Fragment,null,A,d.createElement(w_,{page:b})):A});yx.displayName="Link";var E_=d.forwardRef(function({"aria-current":t="page",caseSensitive:n=!1,className:r="",end:o=!1,style:a,to:i,viewTransition:l,children:c,...u},f){let h=ri(i,{relative:u.relative}),m=Vr(),p=d.useContext(ni),{navigator:x,basename:g}=d.useContext(Ur),w=p!=null&&M_(h)&&l===!0,v=x.encodeLocation?x.encodeLocation(h).pathname:h.pathname,b=m.pathname,C=p&&p.navigation&&p.navigation.location?p.navigation.location.pathname:null;n||(b=b.toLowerCase(),C=C?C.toLowerCase():null,v=v.toLowerCase()),C&&g&&(C=tr(C,g)||C);const S=v!=="/"&&v.endsWith("/")?v.length-1:v.length;let E=b===v||!o&&b.startsWith(v)&&b.charAt(S)==="/",_=C!=null&&(C===v||!o&&C.startsWith(v)&&C.charAt(v.length)==="/"),j={isActive:E,isPending:_,isTransitioning:w},A=E?t:void 0,P;typeof r=="function"?P=r(j):P=[r,E?"active":null,_?"pending":null,w?"transitioning":null].filter(Boolean).join(" ");let O=typeof a=="function"?a(j):a;return d.createElement(yx,{...u,"aria-current":A,className:P,ref:f,style:O,to:i,viewTransition:l},typeof c=="function"?c(j):c)});E_.displayName="NavLink";var j_=d.forwardRef(({discover:e="render",fetcherKey:t,navigate:n,reloadDocument:r,replace:o,state:a,method:i=il,action:l,onSubmit:c,relative:u,preventScrollReset:f,viewTransition:h,...m},p)=>{let x=R_(),g=P_(l,{relative:u}),w=i.toLowerCase()==="get"?"get":"post",v=typeof l=="string"&&bx.test(l),b=C=>{if(c&&c(C),C.defaultPrevented)return;C.preventDefault();let S=C.nativeEvent.submitter,E=(S==null?void 0:S.getAttribute("formmethod"))||i;x(S||C.currentTarget,{fetcherKey:t,method:E,navigate:n,replace:o,state:a,relative:u,preventScrollReset:f,viewTransition:h})};return d.createElement("form",{ref:p,method:w,action:g,onSubmit:r?c:b,...m,"data-discover":!v&&e==="render"?"true":void 0})});j_.displayName="Form";function N_(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Cx(e){let t=d.useContext(ms);return _t(t,N_(e)),t}function T_(e,{target:t,replace:n,state:r,preventScrollReset:o,relative:a,viewTransition:i}={}){let l=zo(),c=Vr(),u=ri(e,{relative:a});return d.useCallback(f=>{if(s_(f,t)){f.preventDefault();let h=n!==void 0?n:Do(c)===Do(u);l(e,{replace:h,state:r,preventScrollReset:o,relative:a,viewTransition:i})}},[c,l,u,n,r,t,e,o,a,i])}var A_=0,I_=()=>`__${String(++A_)}__`;function R_(){let{router:e}=Cx("useSubmit"),{basename:t}=d.useContext(Ur),n=BS();return d.useCallback(async(r,o={})=>{let{action:a,method:i,encType:l,formData:c,body:u}=l_(r,t);if(o.navigate===!1){let f=o.fetcherKey||I_();await e.fetch(f,n,o.action||a,{preventScrollReset:o.preventScrollReset,formData:c,body:u,formMethod:o.method||i,formEncType:o.encType||l,flushSync:o.flushSync})}else await e.navigate(o.action||a,{preventScrollReset:o.preventScrollReset,formData:c,body:u,formMethod:o.method||i,formEncType:o.encType||l,replace:o.replace,state:o.state,fromRouteId:n,flushSync:o.flushSync,viewTransition:o.viewTransition})},[e,t,n])}function P_(e,{relative:t}={}){let{basename:n}=d.useContext(Ur),r=d.useContext(Br);_t(r,"useFormAction must be used inside a RouteContext");let[o]=r.matches.slice(-1),a={...ri(e||".",{relative:t})},i=Vr();if(e==null){a.search=i.search;let l=new URLSearchParams(a.search),c=l.getAll("index");if(c.some(f=>f==="")){l.delete("index"),c.filter(h=>h).forEach(h=>l.append("index",h));let f=l.toString();a.search=f?`?${f}`:""}}return(!e||e===".")&&o.route.index&&(a.search=a.search?a.search.replace(/^\?/,"?index&"):"?index"),n!=="/"&&(a.pathname=a.pathname==="/"?n:Jr([n,a.pathname])),Do(a)}function M_(e,{relative:t}={}){let n=d.useContext(qd);_t(n!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:r}=Cx("useViewTransitionState"),o=ri(e,{relative:t});if(!n.isTransitioning)return!1;let a=tr(n.currentLocation.pathname,r)||n.currentLocation.pathname,i=tr(n.nextLocation.pathname,r)||n.nextLocation.pathname;return wl(o.pathname,i)!=null||wl(o.pathname,a)!=null}function D_(e){return d.createElement(qS,{flushSync:ia.flushSync,...e})}const Sx=d.createContext(void 0),_x=()=>{const e=d.useContext(Sx);if(!e)throw new Error("useTextSelection must be used within TextSelectionProvider");return e},O_=({children:e})=>{const[t,n]=d.useState({selectedText:null,selectionRange:null,menuPosition:null,sourceMessageId:null,isMenuOpen:!1}),r=d.useCallback((l,c,u,f)=>{n({selectedText:l,selectionRange:c,menuPosition:f,sourceMessageId:u,isMenuOpen:!0})},[]),o=d.useCallback(()=>{n({selectedText:null,selectionRange:null,menuPosition:null,sourceMessageId:null,isMenuOpen:!1})},[]),a=d.useCallback(()=>{t.selectedText&&(window.dispatchEvent(new CustomEvent("follow-up-question",{detail:{text:t.selectedText}})),o())},[t.selectedText,o]),i={...t,setSelection:r,clearSelection:o,handleFollowUpQuestion:a};return s.jsx(Sx.Provider,{value:i,children:e})};function up(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function Ql(...e){return t=>{let n=!1;const r=e.map(o=>{const a=up(o,t);return!n&&typeof a=="function"&&(n=!0),a});if(n)return()=>{for(let o=0;o<r.length;o++){const a=r[o];typeof a=="function"?a():up(e[o],null)}}}}function mt(...e){return d.useCallback(Ql(...e),e)}function Oo(e){const t=L_(e),n=d.forwardRef((r,o)=>{const{children:a,...i}=r,l=d.Children.toArray(a),c=l.find($_);if(c){const u=c.props.children,f=l.map(h=>h===c?d.Children.count(u)>1?d.Children.only(null):d.isValidElement(u)?u.props.children:null:h);return s.jsx(t,{...i,ref:o,children:d.isValidElement(u)?d.cloneElement(u,void 0,f):null})}return s.jsx(t,{...i,ref:o,children:a})});return n.displayName=`${e}.Slot`,n}var kx=Oo("Slot");function L_(e){const t=d.forwardRef((n,r)=>{const{children:o,...a}=n;if(d.isValidElement(o)){const i=U_(o),l=z_(a,o.props);return o.type!==d.Fragment&&(l.ref=r?Ql(r,i):i),d.cloneElement(o,l)}return d.Children.count(o)>1?d.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var Ex=Symbol("radix.slottable");function F_(e){const t=({children:n})=>s.jsx(s.Fragment,{children:n});return t.displayName=`${e}.Slottable`,t.__radixId=Ex,t}function $_(e){return d.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===Ex}function z_(e,t){const n={...t};for(const r in t){const o=e[r],a=t[r];/^on[A-Z]/.test(r)?o&&a?n[r]=(...l)=>{const c=a(...l);return o(...l),c}:o&&(n[r]=o):r==="style"?n[r]={...o,...a}:r==="className"&&(n[r]=[o,a].filter(Boolean).join(" "))}return{...e,...n}}function U_(e){var r,o;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(o=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}const dp=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,fp=Ig,Uo=(e,t)=>n=>{var r;if((t==null?void 0:t.variants)==null)return fp(e,n==null?void 0:n.class,n==null?void 0:n.className);const{variants:o,defaultVariants:a}=t,i=Object.keys(o).map(u=>{const f=n==null?void 0:n[u],h=a==null?void 0:a[u];if(f===null)return null;const m=dp(f)||dp(h);return o[u][m]}),l=n&&Object.entries(n).reduce((u,f)=>{let[h,m]=f;return m===void 0||(u[h]=m),u},{}),c=t==null||(r=t.compoundVariants)===null||r===void 0?void 0:r.reduce((u,f)=>{let{class:h,className:m,...p}=f;return Object.entries(p).every(x=>{let[g,w]=x;return Array.isArray(w)?w.includes({...a,...l}[g]):{...a,...l}[g]===w})?[...u,h,m]:u},[]);return fp(e,i,c,n==null?void 0:n.class,n==null?void 0:n.className)},nf=()=>localStorage.getItem("access_token"),B_=()=>localStorage.getItem("refresh_token"),V_=(e,t)=>{localStorage.setItem("access_token",e),localStorage.setItem("refresh_token",t)},W_=()=>{localStorage.removeItem("access_token"),localStorage.removeItem("refresh_token")},H_=async()=>{const e=B_();if(!e)return null;const t=await fetch("/api/v1/auth/refresh",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({refresh_token:e})});if(t.ok){const n=await t.json();return V_(n.access_token,n.refresh_token),n.access_token}return W_(),window.location.href="/api/v1/auth/login",null},Z_=async e=>{const t=`An unknown error occurred. HTTP status: ${e.status}.`;try{const n=await e.json();return n.message||n.detail||t}catch{return t}},Yt=(e,t="An unknown error occurred")=>e instanceof Error?e.message??t:t,pt=async(e,t={})=>{const n=nf();if(!n)return fetch(e,t);const r=await fetch(e,{...t,headers:{...t.headers,Authorization:`Bearer ${n}`}});if(r.status===401){const o=await H_();if(o)return fetch(e,{...t,headers:{...t.headers,Authorization:`Bearer ${o}`}})}return r},vn=async(e,t={})=>{const n=await pt(e,t);if(!n.ok)throw new Error(await Z_(n));return n},_n=async(e,t={})=>{try{return await(await vn(e,t)).json()}catch(n){throw new Error(await Yt(n,"Failed to parse JSON data"))}},G_=async e=>{const t=await pt("/api/v1/feedback",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!t.ok){const n=await t.json().catch(()=>({detail:"Failed to submit feedback"}));throw new Error(n.detail||"Failed to submit feedback")}return t.json()},rf="-",Y_=e=>{const t=q_(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:i=>{const l=i.split(rf);return l[0]===""&&l.length!==1&&l.shift(),jx(l,t)||K_(i)},getConflictingClassGroupIds:(i,l)=>{const c=n[i]||[];return l&&r[i]?[...c,...r[i]]:c}}},jx=(e,t)=>{var i;if(e.length===0)return t.classGroupId;const n=e[0],r=t.nextPart.get(n),o=r?jx(e.slice(1),r):void 0;if(o)return o;if(t.validators.length===0)return;const a=e.join(rf);return(i=t.validators.find(({validator:l})=>l(a)))==null?void 0:i.classGroupId},hp=/^\[(.+)\]$/,K_=e=>{if(hp.test(e)){const t=hp.exec(e)[1],n=t==null?void 0:t.substring(0,t.indexOf(":"));if(n)return"arbitrary.."+n}},q_=e=>{const{theme:t,classGroups:n}=e,r={nextPart:new Map,validators:[]};for(const o in n)Ku(n[o],r,o,t);return r},Ku=(e,t,n,r)=>{e.forEach(o=>{if(typeof o=="string"){const a=o===""?t:pp(t,o);a.classGroupId=n;return}if(typeof o=="function"){if(X_(o)){Ku(o(r),t,n,r);return}t.validators.push({validator:o,classGroupId:n});return}Object.entries(o).forEach(([a,i])=>{Ku(i,pp(t,a),n,r)})})},pp=(e,t)=>{let n=e;return t.split(rf).forEach(r=>{n.nextPart.has(r)||n.nextPart.set(r,{nextPart:new Map,validators:[]}),n=n.nextPart.get(r)}),n},X_=e=>e.isThemeGetter,J_=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,n=new Map,r=new Map;const o=(a,i)=>{n.set(a,i),t++,t>e&&(t=0,r=n,n=new Map)};return{get(a){let i=n.get(a);if(i!==void 0)return i;if((i=r.get(a))!==void 0)return o(a,i),i},set(a,i){n.has(a)?n.set(a,i):o(a,i)}}},qu="!",Xu=":",Q_=Xu.length,ek=e=>{const{prefix:t,experimentalParseClassName:n}=e;let r=o=>{const a=[];let i=0,l=0,c=0,u;for(let x=0;x<o.length;x++){let g=o[x];if(i===0&&l===0){if(g===Xu){a.push(o.slice(c,x)),c=x+Q_;continue}if(g==="/"){u=x;continue}}g==="["?i++:g==="]"?i--:g==="("?l++:g===")"&&l--}const f=a.length===0?o:o.substring(c),h=tk(f),m=h!==f,p=u&&u>c?u-c:void 0;return{modifiers:a,hasImportantModifier:m,baseClassName:h,maybePostfixModifierPosition:p}};if(t){const o=t+Xu,a=r;r=i=>i.startsWith(o)?a(i.substring(o.length)):{isExternal:!0,modifiers:[],hasImportantModifier:!1,baseClassName:i,maybePostfixModifierPosition:void 0}}if(n){const o=r;r=a=>n({className:a,parseClassName:o})}return r},tk=e=>e.endsWith(qu)?e.substring(0,e.length-1):e.startsWith(qu)?e.substring(1):e,nk=e=>{const t=Object.fromEntries(e.orderSensitiveModifiers.map(r=>[r,!0]));return r=>{if(r.length<=1)return r;const o=[];let a=[];return r.forEach(i=>{i[0]==="["||t[i]?(o.push(...a.sort(),i),a=[]):a.push(i)}),o.push(...a.sort()),o}},rk=e=>({cache:J_(e.cacheSize),parseClassName:ek(e),sortModifiers:nk(e),...Y_(e)}),ok=/\s+/,sk=(e,t)=>{const{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:o,sortModifiers:a}=t,i=[],l=e.trim().split(ok);let c="";for(let u=l.length-1;u>=0;u-=1){const f=l[u],{isExternal:h,modifiers:m,hasImportantModifier:p,baseClassName:x,maybePostfixModifierPosition:g}=n(f);if(h){c=f+(c.length>0?" "+c:c);continue}let w=!!g,v=r(w?x.substring(0,g):x);if(!v){if(!w){c=f+(c.length>0?" "+c:c);continue}if(v=r(x),!v){c=f+(c.length>0?" "+c:c);continue}w=!1}const b=a(m).join(":"),C=p?b+qu:b,S=C+v;if(i.includes(S))continue;i.push(S);const E=o(v,w);for(let _=0;_<E.length;++_){const j=E[_];i.push(C+j)}c=f+(c.length>0?" "+c:c)}return c};function ak(){let e=0,t,n,r="";for(;e<arguments.length;)(t=arguments[e++])&&(n=Nx(t))&&(r&&(r+=" "),r+=n);return r}const Nx=e=>{if(typeof e=="string")return e;let t,n="";for(let r=0;r<e.length;r++)e[r]&&(t=Nx(e[r]))&&(n&&(n+=" "),n+=t);return n};function ik(e,...t){let n,r,o,a=i;function i(c){const u=t.reduce((f,h)=>h(f),e());return n=rk(u),r=n.cache.get,o=n.cache.set,a=l,l(c)}function l(c){const u=r(c);if(u)return u;const f=sk(c,n);return o(c,f),f}return function(){return a(ak.apply(null,arguments))}}const Sn=e=>{const t=n=>n[e]||[];return t.isThemeGetter=!0,t},Tx=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,Ax=/^\((?:(\w[\w-]*):)?(.+)\)$/i,lk=/^\d+\/\d+$/,ck=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,uk=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,dk=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,fk=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,hk=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Cs=e=>lk.test(e),bt=e=>!!e&&!Number.isNaN(Number(e)),Eo=e=>!!e&&Number.isInteger(Number(e)),Jc=e=>e.endsWith("%")&&bt(e.slice(0,-1)),so=e=>ck.test(e),pk=()=>!0,mk=e=>uk.test(e)&&!dk.test(e),Ix=()=>!1,gk=e=>fk.test(e),xk=e=>hk.test(e),vk=e=>!Ye(e)&&!Ke(e),wk=e=>ua(e,Mx,Ix),Ye=e=>Tx.test(e),Ko=e=>ua(e,Dx,mk),Qc=e=>ua(e,_k,bt),mp=e=>ua(e,Rx,Ix),bk=e=>ua(e,Px,xk),Ri=e=>ua(e,Ox,gk),Ke=e=>Ax.test(e),wa=e=>da(e,Dx),yk=e=>da(e,kk),gp=e=>da(e,Rx),Ck=e=>da(e,Mx),Sk=e=>da(e,Px),Pi=e=>da(e,Ox,!0),ua=(e,t,n)=>{const r=Tx.exec(e);return r?r[1]?t(r[1]):n(r[2]):!1},da=(e,t,n=!1)=>{const r=Ax.exec(e);return r?r[1]?t(r[1]):n:!1},Rx=e=>e==="position"||e==="percentage",Px=e=>e==="image"||e==="url",Mx=e=>e==="length"||e==="size"||e==="bg-size",Dx=e=>e==="length",_k=e=>e==="number",kk=e=>e==="family-name",Ox=e=>e==="shadow",Ek=()=>{const e=Sn("color"),t=Sn("font"),n=Sn("text"),r=Sn("font-weight"),o=Sn("tracking"),a=Sn("leading"),i=Sn("breakpoint"),l=Sn("container"),c=Sn("spacing"),u=Sn("radius"),f=Sn("shadow"),h=Sn("inset-shadow"),m=Sn("text-shadow"),p=Sn("drop-shadow"),x=Sn("blur"),g=Sn("perspective"),w=Sn("aspect"),v=Sn("ease"),b=Sn("animate"),C=()=>["auto","avoid","all","avoid-page","page","left","right","column"],S=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],E=()=>[...S(),Ke,Ye],_=()=>["auto","hidden","clip","visible","scroll"],j=()=>["auto","contain","none"],A=()=>[Ke,Ye,c],P=()=>[Cs,"full","auto",...A()],O=()=>[Eo,"none","subgrid",Ke,Ye],B=()=>["auto",{span:["full",Eo,Ke,Ye]},Eo,Ke,Ye],N=()=>[Eo,"auto",Ke,Ye],M=()=>["auto","min","max","fr",Ke,Ye],y=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],T=()=>["start","end","center","stretch","center-safe","end-safe"],R=()=>["auto",...A()],z=()=>[Cs,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...A()],F=()=>[e,Ke,Ye],I=()=>[...S(),gp,mp,{position:[Ke,Ye]}],J=()=>["no-repeat",{repeat:["","x","y","space","round"]}],L=()=>["auto","cover","contain",Ck,wk,{size:[Ke,Ye]}],D=()=>[Jc,wa,Ko],W=()=>["","none","full",u,Ke,Ye],G=()=>["",bt,wa,Ko],V=()=>["solid","dashed","dotted","double"],Q=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],X=()=>[bt,Jc,gp,mp],K=()=>["","none",x,Ke,Ye],q=()=>["none",bt,Ke,Ye],ne=()=>["none",bt,Ke,Ye],de=()=>[bt,Ke,Ye],se=()=>[Cs,"full",...A()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[so],breakpoint:[so],color:[pk],container:[so],"drop-shadow":[so],ease:["in","out","in-out"],font:[vk],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[so],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[so],shadow:[so],spacing:["px",bt],text:[so],"text-shadow":[so],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",Cs,Ye,Ke,w]}],container:["container"],columns:[{columns:[bt,Ye,Ke,l]}],"break-after":[{"break-after":C()}],"break-before":[{"break-before":C()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:E()}],overflow:[{overflow:_()}],"overflow-x":[{"overflow-x":_()}],"overflow-y":[{"overflow-y":_()}],overscroll:[{overscroll:j()}],"overscroll-x":[{"overscroll-x":j()}],"overscroll-y":[{"overscroll-y":j()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:P()}],"inset-x":[{"inset-x":P()}],"inset-y":[{"inset-y":P()}],start:[{start:P()}],end:[{end:P()}],top:[{top:P()}],right:[{right:P()}],bottom:[{bottom:P()}],left:[{left:P()}],visibility:["visible","invisible","collapse"],z:[{z:[Eo,"auto",Ke,Ye]}],basis:[{basis:[Cs,"full","auto",l,...A()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[bt,Cs,"auto","initial","none",Ye]}],grow:[{grow:["",bt,Ke,Ye]}],shrink:[{shrink:["",bt,Ke,Ye]}],order:[{order:[Eo,"first","last","none",Ke,Ye]}],"grid-cols":[{"grid-cols":O()}],"col-start-end":[{col:B()}],"col-start":[{"col-start":N()}],"col-end":[{"col-end":N()}],"grid-rows":[{"grid-rows":O()}],"row-start-end":[{row:B()}],"row-start":[{"row-start":N()}],"row-end":[{"row-end":N()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":M()}],"auto-rows":[{"auto-rows":M()}],gap:[{gap:A()}],"gap-x":[{"gap-x":A()}],"gap-y":[{"gap-y":A()}],"justify-content":[{justify:[...y(),"normal"]}],"justify-items":[{"justify-items":[...T(),"normal"]}],"justify-self":[{"justify-self":["auto",...T()]}],"align-content":[{content:["normal",...y()]}],"align-items":[{items:[...T(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...T(),{baseline:["","last"]}]}],"place-content":[{"place-content":y()}],"place-items":[{"place-items":[...T(),"baseline"]}],"place-self":[{"place-self":["auto",...T()]}],p:[{p:A()}],px:[{px:A()}],py:[{py:A()}],ps:[{ps:A()}],pe:[{pe:A()}],pt:[{pt:A()}],pr:[{pr:A()}],pb:[{pb:A()}],pl:[{pl:A()}],m:[{m:R()}],mx:[{mx:R()}],my:[{my:R()}],ms:[{ms:R()}],me:[{me:R()}],mt:[{mt:R()}],mr:[{mr:R()}],mb:[{mb:R()}],ml:[{ml:R()}],"space-x":[{"space-x":A()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":A()}],"space-y-reverse":["space-y-reverse"],size:[{size:z()}],w:[{w:[l,"screen",...z()]}],"min-w":[{"min-w":[l,"screen","none",...z()]}],"max-w":[{"max-w":[l,"screen","none","prose",{screen:[i]},...z()]}],h:[{h:["screen","lh",...z()]}],"min-h":[{"min-h":["screen","lh","none",...z()]}],"max-h":[{"max-h":["screen","lh",...z()]}],"font-size":[{text:["base",n,wa,Ko]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[r,Ke,Qc]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",Jc,Ye]}],"font-family":[{font:[yk,Ye,t]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[o,Ke,Ye]}],"line-clamp":[{"line-clamp":[bt,"none",Ke,Qc]}],leading:[{leading:[a,...A()]}],"list-image":[{"list-image":["none",Ke,Ye]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",Ke,Ye]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:F()}],"text-color":[{text:F()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...V(),"wavy"]}],"text-decoration-thickness":[{decoration:[bt,"from-font","auto",Ke,Ko]}],"text-decoration-color":[{decoration:F()}],"underline-offset":[{"underline-offset":[bt,"auto",Ke,Ye]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:A()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",Ke,Ye]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",Ke,Ye]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:I()}],"bg-repeat":[{bg:J()}],"bg-size":[{bg:L()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},Eo,Ke,Ye],radial:["",Ke,Ye],conic:[Eo,Ke,Ye]},Sk,bk]}],"bg-color":[{bg:F()}],"gradient-from-pos":[{from:D()}],"gradient-via-pos":[{via:D()}],"gradient-to-pos":[{to:D()}],"gradient-from":[{from:F()}],"gradient-via":[{via:F()}],"gradient-to":[{to:F()}],rounded:[{rounded:W()}],"rounded-s":[{"rounded-s":W()}],"rounded-e":[{"rounded-e":W()}],"rounded-t":[{"rounded-t":W()}],"rounded-r":[{"rounded-r":W()}],"rounded-b":[{"rounded-b":W()}],"rounded-l":[{"rounded-l":W()}],"rounded-ss":[{"rounded-ss":W()}],"rounded-se":[{"rounded-se":W()}],"rounded-ee":[{"rounded-ee":W()}],"rounded-es":[{"rounded-es":W()}],"rounded-tl":[{"rounded-tl":W()}],"rounded-tr":[{"rounded-tr":W()}],"rounded-br":[{"rounded-br":W()}],"rounded-bl":[{"rounded-bl":W()}],"border-w":[{border:G()}],"border-w-x":[{"border-x":G()}],"border-w-y":[{"border-y":G()}],"border-w-s":[{"border-s":G()}],"border-w-e":[{"border-e":G()}],"border-w-t":[{"border-t":G()}],"border-w-r":[{"border-r":G()}],"border-w-b":[{"border-b":G()}],"border-w-l":[{"border-l":G()}],"divide-x":[{"divide-x":G()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":G()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...V(),"hidden","none"]}],"divide-style":[{divide:[...V(),"hidden","none"]}],"border-color":[{border:F()}],"border-color-x":[{"border-x":F()}],"border-color-y":[{"border-y":F()}],"border-color-s":[{"border-s":F()}],"border-color-e":[{"border-e":F()}],"border-color-t":[{"border-t":F()}],"border-color-r":[{"border-r":F()}],"border-color-b":[{"border-b":F()}],"border-color-l":[{"border-l":F()}],"divide-color":[{divide:F()}],"outline-style":[{outline:[...V(),"none","hidden"]}],"outline-offset":[{"outline-offset":[bt,Ke,Ye]}],"outline-w":[{outline:["",bt,wa,Ko]}],"outline-color":[{outline:F()}],shadow:[{shadow:["","none",f,Pi,Ri]}],"shadow-color":[{shadow:F()}],"inset-shadow":[{"inset-shadow":["none",h,Pi,Ri]}],"inset-shadow-color":[{"inset-shadow":F()}],"ring-w":[{ring:G()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:F()}],"ring-offset-w":[{"ring-offset":[bt,Ko]}],"ring-offset-color":[{"ring-offset":F()}],"inset-ring-w":[{"inset-ring":G()}],"inset-ring-color":[{"inset-ring":F()}],"text-shadow":[{"text-shadow":["none",m,Pi,Ri]}],"text-shadow-color":[{"text-shadow":F()}],opacity:[{opacity:[bt,Ke,Ye]}],"mix-blend":[{"mix-blend":[...Q(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":Q()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[bt]}],"mask-image-linear-from-pos":[{"mask-linear-from":X()}],"mask-image-linear-to-pos":[{"mask-linear-to":X()}],"mask-image-linear-from-color":[{"mask-linear-from":F()}],"mask-image-linear-to-color":[{"mask-linear-to":F()}],"mask-image-t-from-pos":[{"mask-t-from":X()}],"mask-image-t-to-pos":[{"mask-t-to":X()}],"mask-image-t-from-color":[{"mask-t-from":F()}],"mask-image-t-to-color":[{"mask-t-to":F()}],"mask-image-r-from-pos":[{"mask-r-from":X()}],"mask-image-r-to-pos":[{"mask-r-to":X()}],"mask-image-r-from-color":[{"mask-r-from":F()}],"mask-image-r-to-color":[{"mask-r-to":F()}],"mask-image-b-from-pos":[{"mask-b-from":X()}],"mask-image-b-to-pos":[{"mask-b-to":X()}],"mask-image-b-from-color":[{"mask-b-from":F()}],"mask-image-b-to-color":[{"mask-b-to":F()}],"mask-image-l-from-pos":[{"mask-l-from":X()}],"mask-image-l-to-pos":[{"mask-l-to":X()}],"mask-image-l-from-color":[{"mask-l-from":F()}],"mask-image-l-to-color":[{"mask-l-to":F()}],"mask-image-x-from-pos":[{"mask-x-from":X()}],"mask-image-x-to-pos":[{"mask-x-to":X()}],"mask-image-x-from-color":[{"mask-x-from":F()}],"mask-image-x-to-color":[{"mask-x-to":F()}],"mask-image-y-from-pos":[{"mask-y-from":X()}],"mask-image-y-to-pos":[{"mask-y-to":X()}],"mask-image-y-from-color":[{"mask-y-from":F()}],"mask-image-y-to-color":[{"mask-y-to":F()}],"mask-image-radial":[{"mask-radial":[Ke,Ye]}],"mask-image-radial-from-pos":[{"mask-radial-from":X()}],"mask-image-radial-to-pos":[{"mask-radial-to":X()}],"mask-image-radial-from-color":[{"mask-radial-from":F()}],"mask-image-radial-to-color":[{"mask-radial-to":F()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":S()}],"mask-image-conic-pos":[{"mask-conic":[bt]}],"mask-image-conic-from-pos":[{"mask-conic-from":X()}],"mask-image-conic-to-pos":[{"mask-conic-to":X()}],"mask-image-conic-from-color":[{"mask-conic-from":F()}],"mask-image-conic-to-color":[{"mask-conic-to":F()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:I()}],"mask-repeat":[{mask:J()}],"mask-size":[{mask:L()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",Ke,Ye]}],filter:[{filter:["","none",Ke,Ye]}],blur:[{blur:K()}],brightness:[{brightness:[bt,Ke,Ye]}],contrast:[{contrast:[bt,Ke,Ye]}],"drop-shadow":[{"drop-shadow":["","none",p,Pi,Ri]}],"drop-shadow-color":[{"drop-shadow":F()}],grayscale:[{grayscale:["",bt,Ke,Ye]}],"hue-rotate":[{"hue-rotate":[bt,Ke,Ye]}],invert:[{invert:["",bt,Ke,Ye]}],saturate:[{saturate:[bt,Ke,Ye]}],sepia:[{sepia:["",bt,Ke,Ye]}],"backdrop-filter":[{"backdrop-filter":["","none",Ke,Ye]}],"backdrop-blur":[{"backdrop-blur":K()}],"backdrop-brightness":[{"backdrop-brightness":[bt,Ke,Ye]}],"backdrop-contrast":[{"backdrop-contrast":[bt,Ke,Ye]}],"backdrop-grayscale":[{"backdrop-grayscale":["",bt,Ke,Ye]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[bt,Ke,Ye]}],"backdrop-invert":[{"backdrop-invert":["",bt,Ke,Ye]}],"backdrop-opacity":[{"backdrop-opacity":[bt,Ke,Ye]}],"backdrop-saturate":[{"backdrop-saturate":[bt,Ke,Ye]}],"backdrop-sepia":[{"backdrop-sepia":["",bt,Ke,Ye]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":A()}],"border-spacing-x":[{"border-spacing-x":A()}],"border-spacing-y":[{"border-spacing-y":A()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",Ke,Ye]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[bt,"initial",Ke,Ye]}],ease:[{ease:["linear","initial",v,Ke,Ye]}],delay:[{delay:[bt,Ke,Ye]}],animate:[{animate:["none",b,Ke,Ye]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[g,Ke,Ye]}],"perspective-origin":[{"perspective-origin":E()}],rotate:[{rotate:q()}],"rotate-x":[{"rotate-x":q()}],"rotate-y":[{"rotate-y":q()}],"rotate-z":[{"rotate-z":q()}],scale:[{scale:ne()}],"scale-x":[{"scale-x":ne()}],"scale-y":[{"scale-y":ne()}],"scale-z":[{"scale-z":ne()}],"scale-3d":["scale-3d"],skew:[{skew:de()}],"skew-x":[{"skew-x":de()}],"skew-y":[{"skew-y":de()}],transform:[{transform:[Ke,Ye,"","none","gpu","cpu"]}],"transform-origin":[{origin:E()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:se()}],"translate-x":[{"translate-x":se()}],"translate-y":[{"translate-y":se()}],"translate-z":[{"translate-z":se()}],"translate-none":["translate-none"],accent:[{accent:F()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:F()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",Ke,Ye]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":A()}],"scroll-mx":[{"scroll-mx":A()}],"scroll-my":[{"scroll-my":A()}],"scroll-ms":[{"scroll-ms":A()}],"scroll-me":[{"scroll-me":A()}],"scroll-mt":[{"scroll-mt":A()}],"scroll-mr":[{"scroll-mr":A()}],"scroll-mb":[{"scroll-mb":A()}],"scroll-ml":[{"scroll-ml":A()}],"scroll-p":[{"scroll-p":A()}],"scroll-px":[{"scroll-px":A()}],"scroll-py":[{"scroll-py":A()}],"scroll-ps":[{"scroll-ps":A()}],"scroll-pe":[{"scroll-pe":A()}],"scroll-pt":[{"scroll-pt":A()}],"scroll-pr":[{"scroll-pr":A()}],"scroll-pb":[{"scroll-pb":A()}],"scroll-pl":[{"scroll-pl":A()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",Ke,Ye]}],fill:[{fill:["none",...F()]}],"stroke-w":[{stroke:[bt,wa,Ko,Qc]}],stroke:[{stroke:["none",...F()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},jk=ik(Ek);function ze(...e){return jk(Ig(e))}const Ju=e=>{try{const t=new URL(e);if(t.protocol!=="artifact:")return null;const n=t.pathname.split("/").filter(a=>a),r=n[n.length-1],o=t.searchParams.get("version");return{filename:r,version:o}}catch(t){return console.error("Invalid artifact URI:",t),null}},oi=(e,t)=>{try{const n=URL.createObjectURL(e),r=document.createElement("a");r.href=n,r.download=t||"download",document.body.appendChild(r),r.click(),document.body.removeChild(r),URL.revokeObjectURL(n)}catch(n){console.error("Error downloading blob:",n)}},Lx=async(e,t,n)=>{try{let r,o=e.name;if(e.content){const a=atob(e.content),i=new Array(a.length);for(let c=0;c<a.length;c++)i[c]=a.charCodeAt(c);const l=new Uint8Array(i);r=new Blob([l],{type:e.mime_type||"application/octet-stream"})}else if(e.uri){const a=Ju(e.uri);if(!a)throw new Error(`Invalid or unhandled URI format: ${e.uri}`);o=a.filename;const i=a.version||"latest";let l;t&&t.trim()&&t!=="null"&&t!=="undefined"?l=`/api/v1/artifacts/${encodeURIComponent(t)}/${encodeURIComponent(o)}/versions/${i}`:n?l=`/api/v1/artifacts/null/${encodeURIComponent(o)}/versions/${i}?project_id=${n}`:l=`/api/v1/artifacts/null/${encodeURIComponent(o)}/versions/${i}`;const c=await pt(l,{credentials:"include"});if(!c.ok)throw new Error(`Failed to download file: ${c.statusText}`);r=await c.blob()}else throw new Error("File has no content or URI to download.");oi(r,o)}catch(r){console.error("Error creating download link:",r)}},si=(e,t=2)=>{if(e===0)return"0 Bytes";if(e<0||!Number.isFinite(e))return"Invalid size";const n=1024,r=t<0?0:t,o=["Bytes","KB","MB","GB","TB","PB","EB","ZB","YB"],a=Math.floor(Math.log(e)/Math.log(n));return parseFloat((e/Math.pow(n,a)).toFixed(r))+" "+o[a]},Ys=e=>{if(!e)return"N/A";try{const t=new Date(e);if(isNaN(t.getTime()))return"N/A";const r=Math.floor((new Date().getTime()-t.getTime())/1e3),o=Math.floor(r/60),a=Math.floor(o/60),i=Math.floor(a/24);return r<60?`${r}s ago`:o<60?`${o}m ago`:a<24?`${a}h ago`:i===1?"Yesterday":i<7?`${i}d ago`:t.toLocaleDateString()}catch(t){return console.error("Error formatting date:",t),"Invalid date"}},of=e=>{if(!e)return"N/A";try{const t=new Date(e);return isNaN(t.getTime())?"N/A":t.toLocaleString()}catch{return"N/A"}};function Ks(e){const t=/\{\{([^}]+)\}\}/g,n=e.matchAll(t),r=new Set;for(const o of n)r.add(o[1].trim());return Array.from(r)}function Nk(e,t){let n=e;for(const[r,o]of Object.entries(t)){const a=new RegExp(`\\{\\{\\s*${r}\\s*\\}\\}`,"g");n=n.replace(a,o)}return n}function Tk(e){return!e||e.trim().length===0?{valid:!1,error:"Prompt text cannot be empty"}:e.length>1e4?{valid:!1,error:"Prompt text exceeds maximum length of 10,000 characters"}:{valid:!0}}function Qu(e){return new Date(e).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}const xp=(e="")=>`
14
+ break-words
15
+ leading-[24px]
16
+
17
+ /* Typography */
18
+ [&_h1]:text-2xl [&_h1]:font-bold [&_h1]:mb-4 [&_h1]:mt-6 [&_h1]:text-foreground
19
+ [&_h2]:text-xl [&_h2]:font-bold [&_h2]:mb-3 [&_h2]:mt-5 [&_h2]:text-foreground
20
+ [&_h3]:text-lg [&_h3]:font-semibold [&_h3]:mb-2 [&_h3]:mt-4 [&_h3]:text-foreground
21
+ [&_h4]:text-base [&_h4]:font-semibold [&_h4]:mb-2 [&_h4]:mt-3 [&_h4]:text-foreground
22
+ [&_h5]:text-sm [&_h5]:font-semibold [&_h5]:mb-1 [&_h5]:mt-2 [&_h5]:text-foreground
23
+ [&_h6]:text-xs [&_h6]:font-semibold [&_h6]:mb-1 [&_h6]:mt-2 [&_h6]:text-foreground
24
+
25
+ /* Paragraphs */
26
+ [&_p]:leading-[24px] [&_p]:text-foreground [&_p]:whitespace-pre-wrap [&_p]:mb-6
27
+ [&_p:last-child]:mb-0
28
+ [&_li>p]:mb-0
29
+
30
+ /* Text formatting */
31
+ [&_strong]:font-semibold [&_strong]:text-foreground
32
+ [&_em]:italic
33
+ [&_del]:line-through [&_del]:text-foreground
34
+
35
+ /* Links */
36
+ [&_a]:text-[var(--color-primary-wMain)] [&_a]:underline [&_a]:decoration-[var(--color-primary-wMain)] dark:[&_a]:text-[var(--color-primary-w20)] dark:[&_a]:decoration-[var(--color-primary-w20)]
37
+ [&_a:hover]:text-[var(--color-primary-w100)] [&_a:hover]:decoration-[var(--color-primary-w100)] dark:[&_a:hover]:text-[var(--color-primary-w10)] dark:[&_a:hover]:decoration-[var(--color-primary-w10)]
38
+
39
+ /* Lists */
40
+ [&_ul]:mb-4 [&_ul]:pl-6 [&_ul]:list-disc [&_ul]:space-y-1
41
+ [&_ol]:mb-4 [&_ol]:pl-6 [&_ol]:list-decimal [&_ol]:space-y-1
42
+ [&_li]:text-foreground [&_li]:leading-[24px]
43
+ [&_ul_ul]:mt-1 [&_ul_ul]:mb-1
44
+ [&_ol_ol]:mt-1 [&_ol_ol]:mb-1
45
+ [&_ul:last-child]:mb-0
46
+ [&_ol:last-child]:mb-0
47
+
48
+ /* Code - inline code only (code blocks handled by CodeBlock component) */
49
+ [&_code]:bg-transparent [&_code]:py-0.5 [&_code]:rounded
50
+ [&_code]:text-sm [&_code]:font-mono [&_code]:font-semibold [&_code]:text-foreground [&_code]:break-words
51
+
52
+ /* Blockquotes */
53
+ [&_blockquote]:border-l-4 [&_blockquote]:border-border [&_blockquote]:pl-4
54
+ [&_blockquote]:py-2 [&_blockquote]:mb-4 [&_blockquote]:italic
55
+ [&_blockquote]:text-foreground [&_blockquote]:bg-transparent
56
+ [&_blockquote:last-child]:mb-0
57
+
58
+ /* Tables */
59
+ [&_table]:w-full [&_table]:mb-4 [&_table]:border-collapse [&_table]:table-fixed [&_table]:max-w-full
60
+ [&_th]:border [&_th]:border-border [&_th]:px-3 [&_th]:py-2 [&_th]:break-words
61
+ [&_th]:bg-transparent [&_th]:font-semibold [&_th]:text-left
62
+ [&_td]:border [&_td]:border-border [&_td]:px-3 [&_td]:py-2 [&_td]:break-words
63
+ [&_tr:nth-child(even)]:bg-transparent
64
+ [&_table:last-child]:mb-0
65
+
66
+ /* Horizontal rules */
67
+ [&_hr]:border-0 [&_hr]:border-t [&_hr]:border-border [&_hr]:my-6
68
+ [&_hr:last-child]:mb-0
69
+
70
+ /* Images */
71
+ [&_img]:max-w-full [&_img]:h-auto [&_img]:rounded [&_img]:my-2 [&_img]:object-contain
72
+ [&_img:last-child]:mb-0
73
+
74
+ ${e}
75
+ `.trim().replace(/\s+/g," "),Ak=(e="")=>`
76
+ /* Buttons - "important" overrides for flow controls */
77
+ [&>button]:bg-[var(--color-background-w10)]
78
+ [&>button]:dark:!bg-[var(--color-background-w100)]
79
+ [&>button]:hover:bg-[var(--color-background-w20)]
80
+ [&>button]:dark:hover:!bg-[var(--color-primary-w60)]
81
+ [&>button]:text-[var(--color-primary-text-wMain)]
82
+ [&>button]:dark:text-[var(--color-primary-text-w10)]
83
+ [&>button]:!border
84
+ [&>button]:!border-[var(--color-secondary-w40)]
85
+ [&>button]:dark:!border-[var(--color-secondary-w70)]
86
+
87
+ ${e}
88
+ `.trim().replace(/\s+/g," ");function Ht(e,t,{checkForDefaultPrevented:n=!0}={}){return function(o){if(e==null||e(o),n===!1||!o.defaultPrevented)return t==null?void 0:t(o)}}function Ik(e,t){const n=d.createContext(t),r=a=>{const{children:i,...l}=a,c=d.useMemo(()=>l,Object.values(l));return s.jsx(n.Provider,{value:c,children:i})};r.displayName=e+"Provider";function o(a){const i=d.useContext(n);if(i)return i;if(t!==void 0)return t;throw new Error(`\`${a}\` must be used within \`${e}\``)}return[r,o]}function mr(e,t=[]){let n=[];function r(a,i){const l=d.createContext(i),c=n.length;n=[...n,i];const u=h=>{var v;const{scope:m,children:p,...x}=h,g=((v=m==null?void 0:m[e])==null?void 0:v[c])||l,w=d.useMemo(()=>x,Object.values(x));return s.jsx(g.Provider,{value:w,children:p})};u.displayName=a+"Provider";function f(h,m){var g;const p=((g=m==null?void 0:m[e])==null?void 0:g[c])||l,x=d.useContext(p);if(x)return x;if(i!==void 0)return i;throw new Error(`\`${h}\` must be used within \`${a}\``)}return[u,f]}const o=()=>{const a=n.map(i=>d.createContext(i));return function(l){const c=(l==null?void 0:l[e])||a;return d.useMemo(()=>({[`__scope${e}`]:{...l,[e]:c}}),[l,c])}};return o.scopeName=e,[r,Rk(o,...t)]}function Rk(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(a){const i=r.reduce((l,{useScope:c,scopeName:u})=>{const h=c(a)[`__scope${u}`];return{...l,...h}},{});return d.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return n.scopeName=t.scopeName,n}var Pk=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],rt=Pk.reduce((e,t)=>{const n=Oo(`Primitive.${t}`),r=d.forwardRef((o,a)=>{const{asChild:i,...l}=o,c=i?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),s.jsx(c,{...l,ref:a})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function ec(e,t){e&&ia.flushSync(()=>e.dispatchEvent(t))}function Mn(e){const t=d.useRef(e);return d.useEffect(()=>{t.current=e}),d.useMemo(()=>(...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[])}function sf(e,t=globalThis==null?void 0:globalThis.document){const n=Mn(e);d.useEffect(()=>{const r=o=>{o.key==="Escape"&&n(o)};return t.addEventListener("keydown",r,{capture:!0}),()=>t.removeEventListener("keydown",r,{capture:!0})},[n,t])}var Mk="DismissableLayer",ed="dismissableLayer.update",Dk="dismissableLayer.pointerDownOutside",Ok="dismissableLayer.focusOutside",vp,Fx=d.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),tc=d.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:a,onInteractOutside:i,onDismiss:l,...c}=e,u=d.useContext(Fx),[f,h]=d.useState(null),m=(f==null?void 0:f.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,p]=d.useState({}),x=mt(t,j=>h(j)),g=Array.from(u.layers),[w]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),v=g.indexOf(w),b=f?g.indexOf(f):-1,C=u.layersWithOutsidePointerEventsDisabled.size>0,S=b>=v,E=$k(j=>{const A=j.target,P=[...u.branches].some(O=>O.contains(A));!S||P||(o==null||o(j),i==null||i(j),j.defaultPrevented||l==null||l())},m),_=zk(j=>{const A=j.target;[...u.branches].some(O=>O.contains(A))||(a==null||a(j),i==null||i(j),j.defaultPrevented||l==null||l())},m);return sf(j=>{b===u.layers.size-1&&(r==null||r(j),!j.defaultPrevented&&l&&(j.preventDefault(),l()))},m),d.useEffect(()=>{if(f)return n&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(vp=m.body.style.pointerEvents,m.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(f)),u.layers.add(f),wp(),()=>{n&&u.layersWithOutsidePointerEventsDisabled.size===1&&(m.body.style.pointerEvents=vp)}},[f,m,n,u]),d.useEffect(()=>()=>{f&&(u.layers.delete(f),u.layersWithOutsidePointerEventsDisabled.delete(f),wp())},[f,u]),d.useEffect(()=>{const j=()=>p({});return document.addEventListener(ed,j),()=>document.removeEventListener(ed,j)},[]),s.jsx(rt.div,{...c,ref:x,style:{pointerEvents:C?S?"auto":"none":void 0,...e.style},onFocusCapture:Ht(e.onFocusCapture,_.onFocusCapture),onBlurCapture:Ht(e.onBlurCapture,_.onBlurCapture),onPointerDownCapture:Ht(e.onPointerDownCapture,E.onPointerDownCapture)})});tc.displayName=Mk;var Lk="DismissableLayerBranch",Fk=d.forwardRef((e,t)=>{const n=d.useContext(Fx),r=d.useRef(null),o=mt(t,r);return d.useEffect(()=>{const a=r.current;if(a)return n.branches.add(a),()=>{n.branches.delete(a)}},[n.branches]),s.jsx(rt.div,{...e,ref:o})});Fk.displayName=Lk;function $k(e,t=globalThis==null?void 0:globalThis.document){const n=Mn(e),r=d.useRef(!1),o=d.useRef(()=>{});return d.useEffect(()=>{const a=l=>{if(l.target&&!r.current){let c=function(){$x(Dk,n,u,{discrete:!0})};const u={originalEvent:l};l.pointerType==="touch"?(t.removeEventListener("click",o.current),o.current=c,t.addEventListener("click",o.current,{once:!0})):c()}else t.removeEventListener("click",o.current);r.current=!1},i=window.setTimeout(()=>{t.addEventListener("pointerdown",a)},0);return()=>{window.clearTimeout(i),t.removeEventListener("pointerdown",a),t.removeEventListener("click",o.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}function zk(e,t=globalThis==null?void 0:globalThis.document){const n=Mn(e),r=d.useRef(!1);return d.useEffect(()=>{const o=a=>{a.target&&!r.current&&$x(Ok,n,{originalEvent:a},{discrete:!1})};return t.addEventListener("focusin",o),()=>t.removeEventListener("focusin",o)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function wp(){const e=new CustomEvent(ed);document.dispatchEvent(e)}function $x(e,t,n,{discrete:r}){const o=n.originalEvent.target,a=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&o.addEventListener(e,t,{once:!0}),r?ec(o,a):o.dispatchEvent(a)}var ln=globalThis!=null&&globalThis.document?d.useLayoutEffect:()=>{},Uk=Bd[" useId ".trim().toString()]||(()=>{}),Bk=0;function hr(e){const[t,n]=d.useState(Uk());return ln(()=>{n(r=>r??String(Bk++))},[e]),t?`radix-${t}`:""}const Vk=["top","right","bottom","left"],Lo=Math.min,cr=Math.max,Cl=Math.round,Mi=Math.floor,Qr=e=>({x:e,y:e}),Wk={left:"right",right:"left",bottom:"top",top:"bottom"},Hk={start:"end",end:"start"};function td(e,t,n){return cr(e,Lo(t,n))}function mo(e,t){return typeof e=="function"?e(t):e}function go(e){return e.split("-")[0]}function fa(e){return e.split("-")[1]}function af(e){return e==="x"?"y":"x"}function lf(e){return e==="y"?"height":"width"}const Zk=new Set(["top","bottom"]);function qr(e){return Zk.has(go(e))?"y":"x"}function cf(e){return af(qr(e))}function Gk(e,t,n){n===void 0&&(n=!1);const r=fa(e),o=cf(e),a=lf(o);let i=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[a]>t.floating[a]&&(i=Sl(i)),[i,Sl(i)]}function Yk(e){const t=Sl(e);return[nd(e),t,nd(t)]}function nd(e){return e.replace(/start|end/g,t=>Hk[t])}const bp=["left","right"],yp=["right","left"],Kk=["top","bottom"],qk=["bottom","top"];function Xk(e,t,n){switch(e){case"top":case"bottom":return n?t?yp:bp:t?bp:yp;case"left":case"right":return t?Kk:qk;default:return[]}}function Jk(e,t,n,r){const o=fa(e);let a=Xk(go(e),n==="start",r);return o&&(a=a.map(i=>i+"-"+o),t&&(a=a.concat(a.map(nd)))),a}function Sl(e){return e.replace(/left|right|bottom|top/g,t=>Wk[t])}function Qk(e){return{top:0,right:0,bottom:0,left:0,...e}}function zx(e){return typeof e!="number"?Qk(e):{top:e,right:e,bottom:e,left:e}}function _l(e){const{x:t,y:n,width:r,height:o}=e;return{width:r,height:o,top:n,left:t,right:t+r,bottom:n+o,x:t,y:n}}function Cp(e,t,n){let{reference:r,floating:o}=e;const a=qr(t),i=cf(t),l=lf(i),c=go(t),u=a==="y",f=r.x+r.width/2-o.width/2,h=r.y+r.height/2-o.height/2,m=r[l]/2-o[l]/2;let p;switch(c){case"top":p={x:f,y:r.y-o.height};break;case"bottom":p={x:f,y:r.y+r.height};break;case"right":p={x:r.x+r.width,y:h};break;case"left":p={x:r.x-o.width,y:h};break;default:p={x:r.x,y:r.y}}switch(fa(t)){case"start":p[i]-=m*(n&&u?-1:1);break;case"end":p[i]+=m*(n&&u?-1:1);break}return p}const e2=async(e,t,n)=>{const{placement:r="bottom",strategy:o="absolute",middleware:a=[],platform:i}=n,l=a.filter(Boolean),c=await(i.isRTL==null?void 0:i.isRTL(t));let u=await i.getElementRects({reference:e,floating:t,strategy:o}),{x:f,y:h}=Cp(u,r,c),m=r,p={},x=0;for(let g=0;g<l.length;g++){const{name:w,fn:v}=l[g],{x:b,y:C,data:S,reset:E}=await v({x:f,y:h,initialPlacement:r,placement:m,strategy:o,middlewareData:p,rects:u,platform:i,elements:{reference:e,floating:t}});f=b??f,h=C??h,p={...p,[w]:{...p[w],...S}},E&&x<=50&&(x++,typeof E=="object"&&(E.placement&&(m=E.placement),E.rects&&(u=E.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:o}):E.rects),{x:f,y:h}=Cp(u,m,c)),g=-1)}return{x:f,y:h,placement:m,strategy:o,middlewareData:p}};async function Ba(e,t){var n;t===void 0&&(t={});const{x:r,y:o,platform:a,rects:i,elements:l,strategy:c}=e,{boundary:u="clippingAncestors",rootBoundary:f="viewport",elementContext:h="floating",altBoundary:m=!1,padding:p=0}=mo(t,e),x=zx(p),w=l[m?h==="floating"?"reference":"floating":h],v=_l(await a.getClippingRect({element:(n=await(a.isElement==null?void 0:a.isElement(w)))==null||n?w:w.contextElement||await(a.getDocumentElement==null?void 0:a.getDocumentElement(l.floating)),boundary:u,rootBoundary:f,strategy:c})),b=h==="floating"?{x:r,y:o,width:i.floating.width,height:i.floating.height}:i.reference,C=await(a.getOffsetParent==null?void 0:a.getOffsetParent(l.floating)),S=await(a.isElement==null?void 0:a.isElement(C))?await(a.getScale==null?void 0:a.getScale(C))||{x:1,y:1}:{x:1,y:1},E=_l(a.convertOffsetParentRelativeRectToViewportRelativeRect?await a.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:b,offsetParent:C,strategy:c}):b);return{top:(v.top-E.top+x.top)/S.y,bottom:(E.bottom-v.bottom+x.bottom)/S.y,left:(v.left-E.left+x.left)/S.x,right:(E.right-v.right+x.right)/S.x}}const t2=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:o,rects:a,platform:i,elements:l,middlewareData:c}=t,{element:u,padding:f=0}=mo(e,t)||{};if(u==null)return{};const h=zx(f),m={x:n,y:r},p=cf(o),x=lf(p),g=await i.getDimensions(u),w=p==="y",v=w?"top":"left",b=w?"bottom":"right",C=w?"clientHeight":"clientWidth",S=a.reference[x]+a.reference[p]-m[p]-a.floating[x],E=m[p]-a.reference[p],_=await(i.getOffsetParent==null?void 0:i.getOffsetParent(u));let j=_?_[C]:0;(!j||!await(i.isElement==null?void 0:i.isElement(_)))&&(j=l.floating[C]||a.floating[x]);const A=S/2-E/2,P=j/2-g[x]/2-1,O=Lo(h[v],P),B=Lo(h[b],P),N=O,M=j-g[x]-B,y=j/2-g[x]/2+A,T=td(N,y,M),R=!c.arrow&&fa(o)!=null&&y!==T&&a.reference[x]/2-(y<N?O:B)-g[x]/2<0,z=R?y<N?y-N:y-M:0;return{[p]:m[p]+z,data:{[p]:T,centerOffset:y-T-z,...R&&{alignmentOffset:z}},reset:R}}}),n2=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:o,middlewareData:a,rects:i,initialPlacement:l,platform:c,elements:u}=t,{mainAxis:f=!0,crossAxis:h=!0,fallbackPlacements:m,fallbackStrategy:p="bestFit",fallbackAxisSideDirection:x="none",flipAlignment:g=!0,...w}=mo(e,t);if((n=a.arrow)!=null&&n.alignmentOffset)return{};const v=go(o),b=qr(l),C=go(l)===l,S=await(c.isRTL==null?void 0:c.isRTL(u.floating)),E=m||(C||!g?[Sl(l)]:Yk(l)),_=x!=="none";!m&&_&&E.push(...Jk(l,g,x,S));const j=[l,...E],A=await Ba(t,w),P=[];let O=((r=a.flip)==null?void 0:r.overflows)||[];if(f&&P.push(A[v]),h){const y=Gk(o,i,S);P.push(A[y[0]],A[y[1]])}if(O=[...O,{placement:o,overflows:P}],!P.every(y=>y<=0)){var B,N;const y=(((B=a.flip)==null?void 0:B.index)||0)+1,T=j[y];if(T&&(!(h==="alignment"?b!==qr(T):!1)||O.every(F=>qr(F.placement)===b?F.overflows[0]>0:!0)))return{data:{index:y,overflows:O},reset:{placement:T}};let R=(N=O.filter(z=>z.overflows[0]<=0).sort((z,F)=>z.overflows[1]-F.overflows[1])[0])==null?void 0:N.placement;if(!R)switch(p){case"bestFit":{var M;const z=(M=O.filter(F=>{if(_){const I=qr(F.placement);return I===b||I==="y"}return!0}).map(F=>[F.placement,F.overflows.filter(I=>I>0).reduce((I,J)=>I+J,0)]).sort((F,I)=>F[1]-I[1])[0])==null?void 0:M[0];z&&(R=z);break}case"initialPlacement":R=l;break}if(o!==R)return{reset:{placement:R}}}return{}}}};function Sp(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function _p(e){return Vk.some(t=>e[t]>=0)}const r2=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n}=t,{strategy:r="referenceHidden",...o}=mo(e,t);switch(r){case"referenceHidden":{const a=await Ba(t,{...o,elementContext:"reference"}),i=Sp(a,n.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:_p(i)}}}case"escaped":{const a=await Ba(t,{...o,altBoundary:!0}),i=Sp(a,n.floating);return{data:{escapedOffsets:i,escaped:_p(i)}}}default:return{}}}}},Ux=new Set(["left","top"]);async function o2(e,t){const{placement:n,platform:r,elements:o}=e,a=await(r.isRTL==null?void 0:r.isRTL(o.floating)),i=go(n),l=fa(n),c=qr(n)==="y",u=Ux.has(i)?-1:1,f=a&&c?-1:1,h=mo(t,e);let{mainAxis:m,crossAxis:p,alignmentAxis:x}=typeof h=="number"?{mainAxis:h,crossAxis:0,alignmentAxis:null}:{mainAxis:h.mainAxis||0,crossAxis:h.crossAxis||0,alignmentAxis:h.alignmentAxis};return l&&typeof x=="number"&&(p=l==="end"?x*-1:x),c?{x:p*f,y:m*u}:{x:m*u,y:p*f}}const s2=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:o,y:a,placement:i,middlewareData:l}=t,c=await o2(t,e);return i===((n=l.offset)==null?void 0:n.placement)&&(r=l.arrow)!=null&&r.alignmentOffset?{}:{x:o+c.x,y:a+c.y,data:{...c,placement:i}}}}},a2=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:o}=t,{mainAxis:a=!0,crossAxis:i=!1,limiter:l={fn:w=>{let{x:v,y:b}=w;return{x:v,y:b}}},...c}=mo(e,t),u={x:n,y:r},f=await Ba(t,c),h=qr(go(o)),m=af(h);let p=u[m],x=u[h];if(a){const w=m==="y"?"top":"left",v=m==="y"?"bottom":"right",b=p+f[w],C=p-f[v];p=td(b,p,C)}if(i){const w=h==="y"?"top":"left",v=h==="y"?"bottom":"right",b=x+f[w],C=x-f[v];x=td(b,x,C)}const g=l.fn({...t,[m]:p,[h]:x});return{...g,data:{x:g.x-n,y:g.y-r,enabled:{[m]:a,[h]:i}}}}}},i2=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:o,rects:a,middlewareData:i}=t,{offset:l=0,mainAxis:c=!0,crossAxis:u=!0}=mo(e,t),f={x:n,y:r},h=qr(o),m=af(h);let p=f[m],x=f[h];const g=mo(l,t),w=typeof g=="number"?{mainAxis:g,crossAxis:0}:{mainAxis:0,crossAxis:0,...g};if(c){const C=m==="y"?"height":"width",S=a.reference[m]-a.floating[C]+w.mainAxis,E=a.reference[m]+a.reference[C]-w.mainAxis;p<S?p=S:p>E&&(p=E)}if(u){var v,b;const C=m==="y"?"width":"height",S=Ux.has(go(o)),E=a.reference[h]-a.floating[C]+(S&&((v=i.offset)==null?void 0:v[h])||0)+(S?0:w.crossAxis),_=a.reference[h]+a.reference[C]+(S?0:((b=i.offset)==null?void 0:b[h])||0)-(S?w.crossAxis:0);x<E?x=E:x>_&&(x=_)}return{[m]:p,[h]:x}}}},l2=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,r;const{placement:o,rects:a,platform:i,elements:l}=t,{apply:c=()=>{},...u}=mo(e,t),f=await Ba(t,u),h=go(o),m=fa(o),p=qr(o)==="y",{width:x,height:g}=a.floating;let w,v;h==="top"||h==="bottom"?(w=h,v=m===(await(i.isRTL==null?void 0:i.isRTL(l.floating))?"start":"end")?"left":"right"):(v=h,w=m==="end"?"top":"bottom");const b=g-f.top-f.bottom,C=x-f.left-f.right,S=Lo(g-f[w],b),E=Lo(x-f[v],C),_=!t.middlewareData.shift;let j=S,A=E;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(A=C),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(j=b),_&&!m){const O=cr(f.left,0),B=cr(f.right,0),N=cr(f.top,0),M=cr(f.bottom,0);p?A=x-2*(O!==0||B!==0?O+B:cr(f.left,f.right)):j=g-2*(N!==0||M!==0?N+M:cr(f.top,f.bottom))}await c({...t,availableWidth:A,availableHeight:j});const P=await i.getDimensions(l.floating);return x!==P.width||g!==P.height?{reset:{rects:!0}}:{}}}};function nc(){return typeof window<"u"}function ha(e){return Bx(e)?(e.nodeName||"").toLowerCase():"#document"}function pr(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function oo(e){var t;return(t=(Bx(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function Bx(e){return nc()?e instanceof Node||e instanceof pr(e).Node:!1}function Fr(e){return nc()?e instanceof Element||e instanceof pr(e).Element:!1}function to(e){return nc()?e instanceof HTMLElement||e instanceof pr(e).HTMLElement:!1}function kp(e){return!nc()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof pr(e).ShadowRoot}const c2=new Set(["inline","contents"]);function ai(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=$r(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!c2.has(o)}const u2=new Set(["table","td","th"]);function d2(e){return u2.has(ha(e))}const f2=[":popover-open",":modal"];function rc(e){return f2.some(t=>{try{return e.matches(t)}catch{return!1}})}const h2=["transform","translate","scale","rotate","perspective"],p2=["transform","translate","scale","rotate","perspective","filter"],m2=["paint","layout","strict","content"];function uf(e){const t=df(),n=Fr(e)?$r(e):e;return h2.some(r=>n[r]?n[r]!=="none":!1)||(n.containerType?n.containerType!=="normal":!1)||!t&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!t&&(n.filter?n.filter!=="none":!1)||p2.some(r=>(n.willChange||"").includes(r))||m2.some(r=>(n.contain||"").includes(r))}function g2(e){let t=Fo(e);for(;to(t)&&!qs(t);){if(uf(t))return t;if(rc(t))return null;t=Fo(t)}return null}function df(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const x2=new Set(["html","body","#document"]);function qs(e){return x2.has(ha(e))}function $r(e){return pr(e).getComputedStyle(e)}function oc(e){return Fr(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Fo(e){if(ha(e)==="html")return e;const t=e.assignedSlot||e.parentNode||kp(e)&&e.host||oo(e);return kp(t)?t.host:t}function Vx(e){const t=Fo(e);return qs(t)?e.ownerDocument?e.ownerDocument.body:e.body:to(t)&&ai(t)?t:Vx(t)}function Va(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=Vx(e),a=o===((r=e.ownerDocument)==null?void 0:r.body),i=pr(o);if(a){const l=rd(i);return t.concat(i,i.visualViewport||[],ai(o)?o:[],l&&n?Va(l):[])}return t.concat(o,Va(o,[],n))}function rd(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Wx(e){const t=$r(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=to(e),a=o?e.offsetWidth:n,i=o?e.offsetHeight:r,l=Cl(n)!==a||Cl(r)!==i;return l&&(n=a,r=i),{width:n,height:r,$:l}}function ff(e){return Fr(e)?e:e.contextElement}function zs(e){const t=ff(e);if(!to(t))return Qr(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:a}=Wx(t);let i=(a?Cl(n.width):n.width)/r,l=(a?Cl(n.height):n.height)/o;return(!i||!Number.isFinite(i))&&(i=1),(!l||!Number.isFinite(l))&&(l=1),{x:i,y:l}}const v2=Qr(0);function Hx(e){const t=pr(e);return!df()||!t.visualViewport?v2:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function w2(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==pr(e)?!1:t}function os(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),a=ff(e);let i=Qr(1);t&&(r?Fr(r)&&(i=zs(r)):i=zs(e));const l=w2(a,n,r)?Hx(a):Qr(0);let c=(o.left+l.x)/i.x,u=(o.top+l.y)/i.y,f=o.width/i.x,h=o.height/i.y;if(a){const m=pr(a),p=r&&Fr(r)?pr(r):r;let x=m,g=rd(x);for(;g&&r&&p!==x;){const w=zs(g),v=g.getBoundingClientRect(),b=$r(g),C=v.left+(g.clientLeft+parseFloat(b.paddingLeft))*w.x,S=v.top+(g.clientTop+parseFloat(b.paddingTop))*w.y;c*=w.x,u*=w.y,f*=w.x,h*=w.y,c+=C,u+=S,x=pr(g),g=rd(x)}}return _l({width:f,height:h,x:c,y:u})}function sc(e,t){const n=oc(e).scrollLeft;return t?t.left+n:os(oo(e)).left+n}function Zx(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-sc(e,n),o=n.top+t.scrollTop;return{x:r,y:o}}function b2(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const a=o==="fixed",i=oo(r),l=t?rc(t.floating):!1;if(r===i||l&&a)return n;let c={scrollLeft:0,scrollTop:0},u=Qr(1);const f=Qr(0),h=to(r);if((h||!h&&!a)&&((ha(r)!=="body"||ai(i))&&(c=oc(r)),to(r))){const p=os(r);u=zs(r),f.x=p.x+r.clientLeft,f.y=p.y+r.clientTop}const m=i&&!h&&!a?Zx(i,c):Qr(0);return{width:n.width*u.x,height:n.height*u.y,x:n.x*u.x-c.scrollLeft*u.x+f.x+m.x,y:n.y*u.y-c.scrollTop*u.y+f.y+m.y}}function y2(e){return Array.from(e.getClientRects())}function C2(e){const t=oo(e),n=oc(e),r=e.ownerDocument.body,o=cr(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),a=cr(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let i=-n.scrollLeft+sc(e);const l=-n.scrollTop;return $r(r).direction==="rtl"&&(i+=cr(t.clientWidth,r.clientWidth)-o),{width:o,height:a,x:i,y:l}}const Ep=25;function S2(e,t){const n=pr(e),r=oo(e),o=n.visualViewport;let a=r.clientWidth,i=r.clientHeight,l=0,c=0;if(o){a=o.width,i=o.height;const f=df();(!f||f&&t==="fixed")&&(l=o.offsetLeft,c=o.offsetTop)}const u=sc(r);if(u<=0){const f=r.ownerDocument,h=f.body,m=getComputedStyle(h),p=f.compatMode==="CSS1Compat"&&parseFloat(m.marginLeft)+parseFloat(m.marginRight)||0,x=Math.abs(r.clientWidth-h.clientWidth-p);x<=Ep&&(a-=x)}else u<=Ep&&(a+=u);return{width:a,height:i,x:l,y:c}}const _2=new Set(["absolute","fixed"]);function k2(e,t){const n=os(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,a=to(e)?zs(e):Qr(1),i=e.clientWidth*a.x,l=e.clientHeight*a.y,c=o*a.x,u=r*a.y;return{width:i,height:l,x:c,y:u}}function jp(e,t,n){let r;if(t==="viewport")r=S2(e,n);else if(t==="document")r=C2(oo(e));else if(Fr(t))r=k2(t,n);else{const o=Hx(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return _l(r)}function Gx(e,t){const n=Fo(e);return n===t||!Fr(n)||qs(n)?!1:$r(n).position==="fixed"||Gx(n,t)}function E2(e,t){const n=t.get(e);if(n)return n;let r=Va(e,[],!1).filter(l=>Fr(l)&&ha(l)!=="body"),o=null;const a=$r(e).position==="fixed";let i=a?Fo(e):e;for(;Fr(i)&&!qs(i);){const l=$r(i),c=uf(i);!c&&l.position==="fixed"&&(o=null),(a?!c&&!o:!c&&l.position==="static"&&!!o&&_2.has(o.position)||ai(i)&&!c&&Gx(e,i))?r=r.filter(f=>f!==i):o=l,i=Fo(i)}return t.set(e,r),r}function j2(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const i=[...n==="clippingAncestors"?rc(t)?[]:E2(t,this._c):[].concat(n),r],l=i[0],c=i.reduce((u,f)=>{const h=jp(t,f,o);return u.top=cr(h.top,u.top),u.right=Lo(h.right,u.right),u.bottom=Lo(h.bottom,u.bottom),u.left=cr(h.left,u.left),u},jp(t,l,o));return{width:c.right-c.left,height:c.bottom-c.top,x:c.left,y:c.top}}function N2(e){const{width:t,height:n}=Wx(e);return{width:t,height:n}}function T2(e,t,n){const r=to(t),o=oo(t),a=n==="fixed",i=os(e,!0,a,t);let l={scrollLeft:0,scrollTop:0};const c=Qr(0);function u(){c.x=sc(o)}if(r||!r&&!a)if((ha(t)!=="body"||ai(o))&&(l=oc(t)),r){const p=os(t,!0,a,t);c.x=p.x+t.clientLeft,c.y=p.y+t.clientTop}else o&&u();a&&!r&&o&&u();const f=o&&!r&&!a?Zx(o,l):Qr(0),h=i.left+l.scrollLeft-c.x-f.x,m=i.top+l.scrollTop-c.y-f.y;return{x:h,y:m,width:i.width,height:i.height}}function eu(e){return $r(e).position==="static"}function Np(e,t){if(!to(e)||$r(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return oo(e)===n&&(n=n.ownerDocument.body),n}function Yx(e,t){const n=pr(e);if(rc(e))return n;if(!to(e)){let o=Fo(e);for(;o&&!qs(o);){if(Fr(o)&&!eu(o))return o;o=Fo(o)}return n}let r=Np(e,t);for(;r&&d2(r)&&eu(r);)r=Np(r,t);return r&&qs(r)&&eu(r)&&!uf(r)?n:r||g2(e)||n}const A2=async function(e){const t=this.getOffsetParent||Yx,n=this.getDimensions,r=await n(e.floating);return{reference:T2(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function I2(e){return $r(e).direction==="rtl"}const R2={convertOffsetParentRelativeRectToViewportRelativeRect:b2,getDocumentElement:oo,getClippingRect:j2,getOffsetParent:Yx,getElementRects:A2,getClientRects:y2,getDimensions:N2,getScale:zs,isElement:Fr,isRTL:I2};function Kx(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function P2(e,t){let n=null,r;const o=oo(e);function a(){var l;clearTimeout(r),(l=n)==null||l.disconnect(),n=null}function i(l,c){l===void 0&&(l=!1),c===void 0&&(c=1),a();const u=e.getBoundingClientRect(),{left:f,top:h,width:m,height:p}=u;if(l||t(),!m||!p)return;const x=Mi(h),g=Mi(o.clientWidth-(f+m)),w=Mi(o.clientHeight-(h+p)),v=Mi(f),C={rootMargin:-x+"px "+-g+"px "+-w+"px "+-v+"px",threshold:cr(0,Lo(1,c))||1};let S=!0;function E(_){const j=_[0].intersectionRatio;if(j!==c){if(!S)return i();j?i(!1,j):r=setTimeout(()=>{i(!1,1e-7)},1e3)}j===1&&!Kx(u,e.getBoundingClientRect())&&i(),S=!1}try{n=new IntersectionObserver(E,{...C,root:o.ownerDocument})}catch{n=new IntersectionObserver(E,C)}n.observe(e)}return i(!0),a}function hf(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:o=!0,ancestorResize:a=!0,elementResize:i=typeof ResizeObserver=="function",layoutShift:l=typeof IntersectionObserver=="function",animationFrame:c=!1}=r,u=ff(e),f=o||a?[...u?Va(u):[],...Va(t)]:[];f.forEach(v=>{o&&v.addEventListener("scroll",n,{passive:!0}),a&&v.addEventListener("resize",n)});const h=u&&l?P2(u,n):null;let m=-1,p=null;i&&(p=new ResizeObserver(v=>{let[b]=v;b&&b.target===u&&p&&(p.unobserve(t),cancelAnimationFrame(m),m=requestAnimationFrame(()=>{var C;(C=p)==null||C.observe(t)})),n()}),u&&!c&&p.observe(u),p.observe(t));let x,g=c?os(e):null;c&&w();function w(){const v=os(e);g&&!Kx(g,v)&&n(),g=v,x=requestAnimationFrame(w)}return n(),()=>{var v;f.forEach(b=>{o&&b.removeEventListener("scroll",n),a&&b.removeEventListener("resize",n)}),h==null||h(),(v=p)==null||v.disconnect(),p=null,c&&cancelAnimationFrame(x)}}const M2=s2,D2=a2,O2=n2,L2=l2,F2=r2,Tp=t2,$2=i2,z2=(e,t,n)=>{const r=new Map,o={platform:R2,...n},a={...o.platform,_c:r};return e2(e,t,{...o,platform:a})};var U2=typeof document<"u",B2=function(){},cl=U2?d.useLayoutEffect:B2;function kl(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,r,o;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!kl(e[r],t[r]))return!1;return!0}if(o=Object.keys(e),n=o.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,o[r]))return!1;for(r=n;r--!==0;){const a=o[r];if(!(a==="_owner"&&e.$$typeof)&&!kl(e[a],t[a]))return!1}return!0}return e!==e&&t!==t}function qx(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Ap(e,t){const n=qx(e);return Math.round(t*n)/n}function tu(e){const t=d.useRef(e);return cl(()=>{t.current=e}),t}function pf(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:o,elements:{reference:a,floating:i}={},transform:l=!0,whileElementsMounted:c,open:u}=e,[f,h]=d.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[m,p]=d.useState(r);kl(m,r)||p(r);const[x,g]=d.useState(null),[w,v]=d.useState(null),b=d.useCallback(F=>{F!==_.current&&(_.current=F,g(F))},[]),C=d.useCallback(F=>{F!==j.current&&(j.current=F,v(F))},[]),S=a||x,E=i||w,_=d.useRef(null),j=d.useRef(null),A=d.useRef(f),P=c!=null,O=tu(c),B=tu(o),N=tu(u),M=d.useCallback(()=>{if(!_.current||!j.current)return;const F={placement:t,strategy:n,middleware:m};B.current&&(F.platform=B.current),z2(_.current,j.current,F).then(I=>{const J={...I,isPositioned:N.current!==!1};y.current&&!kl(A.current,J)&&(A.current=J,ia.flushSync(()=>{h(J)}))})},[m,t,n,B,N]);cl(()=>{u===!1&&A.current.isPositioned&&(A.current.isPositioned=!1,h(F=>({...F,isPositioned:!1})))},[u]);const y=d.useRef(!1);cl(()=>(y.current=!0,()=>{y.current=!1}),[]),cl(()=>{if(S&&(_.current=S),E&&(j.current=E),S&&E){if(O.current)return O.current(S,E,M);M()}},[S,E,M,O,P]);const T=d.useMemo(()=>({reference:_,floating:j,setReference:b,setFloating:C}),[b,C]),R=d.useMemo(()=>({reference:S,floating:E}),[S,E]),z=d.useMemo(()=>{const F={position:n,left:0,top:0};if(!R.floating)return F;const I=Ap(R.floating,f.x),J=Ap(R.floating,f.y);return l?{...F,transform:"translate("+I+"px, "+J+"px)",...qx(R.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:I,top:J}},[n,l,R.floating,f.x,f.y]);return d.useMemo(()=>({...f,update:M,refs:T,elements:R,floatingStyles:z}),[f,M,T,R,z])}const V2=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:r,padding:o}=typeof e=="function"?e(n):e;return r&&t(r)?r.current!=null?Tp({element:r.current,padding:o}).fn(n):{}:r?Tp({element:r,padding:o}).fn(n):{}}}},mf=(e,t)=>({...M2(e),options:[e,t]}),gf=(e,t)=>({...D2(e),options:[e,t]}),xf=(e,t)=>({...$2(e),options:[e,t]}),vf=(e,t)=>({...O2(e),options:[e,t]}),wf=(e,t)=>({...L2(e),options:[e,t]}),bf=(e,t)=>({...F2(e),options:[e,t]}),yf=(e,t)=>({...V2(e),options:[e,t]});var W2="Arrow",Xx=d.forwardRef((e,t)=>{const{children:n,width:r=10,height:o=5,...a}=e;return s.jsx(rt.svg,{...a,ref:t,width:r,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:s.jsx("polygon",{points:"0,0 30,0 15,10"})})});Xx.displayName=W2;var Cf=Xx;function Sf(e){const[t,n]=d.useState(void 0);return ln(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const a=o[0];let i,l;if("borderBoxSize"in a){const c=a.borderBoxSize,u=Array.isArray(c)?c[0]:c;i=u.inlineSize,l=u.blockSize}else i=e.offsetWidth,l=e.offsetHeight;n({width:i,height:l})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}var _f="Popper",[Jx,Qx]=mr(_f),[H2,ev]=Jx(_f),tv=e=>{const{__scopePopper:t,children:n}=e,[r,o]=d.useState(null);return s.jsx(H2,{scope:t,anchor:r,onAnchorChange:o,children:n})};tv.displayName=_f;var nv="PopperAnchor",rv=d.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,a=ev(nv,n),i=d.useRef(null),l=mt(t,i);return d.useEffect(()=>{a.onAnchorChange((r==null?void 0:r.current)||i.current)}),r?null:s.jsx(rt.div,{...o,ref:l})});rv.displayName=nv;var kf="PopperContent",[Z2,G2]=Jx(kf),ov=d.forwardRef((e,t)=>{var X,K,q,ne,de,se;const{__scopePopper:n,side:r="bottom",sideOffset:o=0,align:a="center",alignOffset:i=0,arrowPadding:l=0,avoidCollisions:c=!0,collisionBoundary:u=[],collisionPadding:f=0,sticky:h="partial",hideWhenDetached:m=!1,updatePositionStrategy:p="optimized",onPlaced:x,...g}=e,w=ev(kf,n),[v,b]=d.useState(null),C=mt(t,me=>b(me)),[S,E]=d.useState(null),_=Sf(S),j=(_==null?void 0:_.width)??0,A=(_==null?void 0:_.height)??0,P=r+(a!=="center"?"-"+a:""),O=typeof f=="number"?f:{top:0,right:0,bottom:0,left:0,...f},B=Array.isArray(u)?u:[u],N=B.length>0,M={padding:O,boundary:B.filter(K2),altBoundary:N},{refs:y,floatingStyles:T,placement:R,isPositioned:z,middlewareData:F}=pf({strategy:"fixed",placement:P,whileElementsMounted:(...me)=>hf(...me,{animationFrame:p==="always"}),elements:{reference:w.anchor},middleware:[mf({mainAxis:o+A,alignmentAxis:i}),c&&gf({mainAxis:!0,crossAxis:!1,limiter:h==="partial"?xf():void 0,...M}),c&&vf({...M}),wf({...M,apply:({elements:me,rects:k,availableWidth:oe,availableHeight:ie})=>{const{width:Z,height:U}=k.reference,re=me.floating.style;re.setProperty("--radix-popper-available-width",`${oe}px`),re.setProperty("--radix-popper-available-height",`${ie}px`),re.setProperty("--radix-popper-anchor-width",`${Z}px`),re.setProperty("--radix-popper-anchor-height",`${U}px`)}}),S&&yf({element:S,padding:l}),q2({arrowWidth:j,arrowHeight:A}),m&&bf({strategy:"referenceHidden",...M})]}),[I,J]=iv(R),L=Mn(x);ln(()=>{z&&(L==null||L())},[z,L]);const D=(X=F.arrow)==null?void 0:X.x,W=(K=F.arrow)==null?void 0:K.y,G=((q=F.arrow)==null?void 0:q.centerOffset)!==0,[V,Q]=d.useState();return ln(()=>{v&&Q(window.getComputedStyle(v).zIndex)},[v]),s.jsx("div",{ref:y.setFloating,"data-radix-popper-content-wrapper":"",style:{...T,transform:z?T.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:V,"--radix-popper-transform-origin":[(ne=F.transformOrigin)==null?void 0:ne.x,(de=F.transformOrigin)==null?void 0:de.y].join(" "),...((se=F.hide)==null?void 0:se.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:s.jsx(Z2,{scope:n,placedSide:I,onArrowChange:E,arrowX:D,arrowY:W,shouldHideArrow:G,children:s.jsx(rt.div,{"data-side":I,"data-align":J,...g,ref:C,style:{...g.style,animation:z?void 0:"none"}})})})});ov.displayName=kf;var sv="PopperArrow",Y2={top:"bottom",right:"left",bottom:"top",left:"right"},av=d.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,a=G2(sv,r),i=Y2[a.placedSide];return s.jsx("span",{ref:a.onArrowChange,style:{position:"absolute",left:a.arrowX,top:a.arrowY,[i]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[a.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[a.placedSide],visibility:a.shouldHideArrow?"hidden":void 0},children:s.jsx(Cf,{...o,ref:n,style:{...o.style,display:"block"}})})});av.displayName=sv;function K2(e){return e!==null}var q2=e=>({name:"transformOrigin",options:e,fn(t){var w,v,b;const{placement:n,rects:r,middlewareData:o}=t,i=((w=o.arrow)==null?void 0:w.centerOffset)!==0,l=i?0:e.arrowWidth,c=i?0:e.arrowHeight,[u,f]=iv(n),h={start:"0%",center:"50%",end:"100%"}[f],m=(((v=o.arrow)==null?void 0:v.x)??0)+l/2,p=(((b=o.arrow)==null?void 0:b.y)??0)+c/2;let x="",g="";return u==="bottom"?(x=i?h:`${m}px`,g=`${-c}px`):u==="top"?(x=i?h:`${m}px`,g=`${r.floating.height+c}px`):u==="right"?(x=`${-c}px`,g=i?h:`${p}px`):u==="left"&&(x=`${r.floating.width+c}px`,g=i?h:`${p}px`),{data:{x,y:g}}}});function iv(e){const[t,n="center"]=e.split("-");return[t,n]}var X2=tv,J2=rv,Q2=ov,eE=av,tE="Portal",pa=d.forwardRef((e,t)=>{var l;const{container:n,...r}=e,[o,a]=d.useState(!1);ln(()=>a(!0),[]);const i=n||o&&((l=globalThis==null?void 0:globalThis.document)==null?void 0:l.body);return i?W1.createPortal(s.jsx(rt.div,{...r,ref:t}),i):null});pa.displayName=tE;function nE(e,t){return d.useReducer((n,r)=>t[n][r]??n,e)}var _o=e=>{const{present:t,children:n}=e,r=rE(t),o=typeof n=="function"?n({present:r.isPresent}):d.Children.only(n),a=mt(r.ref,oE(o));return typeof n=="function"||r.isPresent?d.cloneElement(o,{ref:a}):null};_o.displayName="Presence";function rE(e){const[t,n]=d.useState(),r=d.useRef(null),o=d.useRef(e),a=d.useRef("none"),i=e?"mounted":"unmounted",[l,c]=nE(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return d.useEffect(()=>{const u=Di(r.current);a.current=l==="mounted"?u:"none"},[l]),ln(()=>{const u=r.current,f=o.current;if(f!==e){const m=a.current,p=Di(u);e?c("MOUNT"):p==="none"||(u==null?void 0:u.display)==="none"?c("UNMOUNT"):c(f&&m!==p?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,c]),ln(()=>{if(t){let u;const f=t.ownerDocument.defaultView??window,h=p=>{const g=Di(r.current).includes(p.animationName);if(p.target===t&&g&&(c("ANIMATION_END"),!o.current)){const w=t.style.animationFillMode;t.style.animationFillMode="forwards",u=f.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=w)})}},m=p=>{p.target===t&&(a.current=Di(r.current))};return t.addEventListener("animationstart",m),t.addEventListener("animationcancel",h),t.addEventListener("animationend",h),()=>{f.clearTimeout(u),t.removeEventListener("animationstart",m),t.removeEventListener("animationcancel",h),t.removeEventListener("animationend",h)}}else c("ANIMATION_END")},[t,c]),{isPresent:["mounted","unmountSuspended"].includes(l),ref:d.useCallback(u=>{r.current=u?getComputedStyle(u):null,n(u)},[])}}function Di(e){return(e==null?void 0:e.animationName)||"none"}function oE(e){var r,o;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(o=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var sE=Bd[" useInsertionEffect ".trim().toString()]||ln;function xo({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[o,a,i]=aE({defaultProp:t,onChange:n}),l=e!==void 0,c=l?e:o;{const f=d.useRef(e!==void 0);d.useEffect(()=>{const h=f.current;h!==l&&console.warn(`${r} is changing from ${h?"controlled":"uncontrolled"} to ${l?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),f.current=l},[l,r])}const u=d.useCallback(f=>{var h;if(l){const m=iE(f)?f(e):f;m!==e&&((h=i.current)==null||h.call(i,m))}else a(f)},[l,e,a,i]);return[c,u]}function aE({defaultProp:e,onChange:t}){const[n,r]=d.useState(e),o=d.useRef(n),a=d.useRef(t);return sE(()=>{a.current=t},[t]),d.useEffect(()=>{var i;o.current!==n&&((i=a.current)==null||i.call(a,n),o.current=n)},[n,o]),[n,r,a]}function iE(e){return typeof e=="function"}var lv=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),lE="VisuallyHidden",ac=d.forwardRef((e,t)=>s.jsx(rt.span,{...e,ref:t,style:{...lv,...e.style}}));ac.displayName=lE;var cE=ac,[ic,S9]=mr("Tooltip",[Qx]),lc=Qx(),cv="TooltipProvider",uE=700,od="tooltip.open",[dE,Ef]=ic(cv),uv=e=>{const{__scopeTooltip:t,delayDuration:n=uE,skipDelayDuration:r=300,disableHoverableContent:o=!1,children:a}=e,i=d.useRef(!0),l=d.useRef(!1),c=d.useRef(0);return d.useEffect(()=>{const u=c.current;return()=>window.clearTimeout(u)},[]),s.jsx(dE,{scope:t,isOpenDelayedRef:i,delayDuration:n,onOpen:d.useCallback(()=>{window.clearTimeout(c.current),i.current=!1},[]),onClose:d.useCallback(()=>{window.clearTimeout(c.current),c.current=window.setTimeout(()=>i.current=!0,r)},[r]),isPointerInTransitRef:l,onPointerInTransitChange:d.useCallback(u=>{l.current=u},[]),disableHoverableContent:o,children:a})};uv.displayName=cv;var Wa="Tooltip",[fE,ii]=ic(Wa),dv=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:o,onOpenChange:a,disableHoverableContent:i,delayDuration:l}=e,c=Ef(Wa,e.__scopeTooltip),u=lc(t),[f,h]=d.useState(null),m=hr(),p=d.useRef(0),x=i??c.disableHoverableContent,g=l??c.delayDuration,w=d.useRef(!1),[v,b]=xo({prop:r,defaultProp:o??!1,onChange:j=>{j?(c.onOpen(),document.dispatchEvent(new CustomEvent(od))):c.onClose(),a==null||a(j)},caller:Wa}),C=d.useMemo(()=>v?w.current?"delayed-open":"instant-open":"closed",[v]),S=d.useCallback(()=>{window.clearTimeout(p.current),p.current=0,w.current=!1,b(!0)},[b]),E=d.useCallback(()=>{window.clearTimeout(p.current),p.current=0,b(!1)},[b]),_=d.useCallback(()=>{window.clearTimeout(p.current),p.current=window.setTimeout(()=>{w.current=!0,b(!0),p.current=0},g)},[g,b]);return d.useEffect(()=>()=>{p.current&&(window.clearTimeout(p.current),p.current=0)},[]),s.jsx(X2,{...u,children:s.jsx(fE,{scope:t,contentId:m,open:v,stateAttribute:C,trigger:f,onTriggerChange:h,onTriggerEnter:d.useCallback(()=>{c.isOpenDelayedRef.current?_():S()},[c.isOpenDelayedRef,_,S]),onTriggerLeave:d.useCallback(()=>{x?E():(window.clearTimeout(p.current),p.current=0)},[E,x]),onOpen:S,onClose:E,disableHoverableContent:x,children:n})})};dv.displayName=Wa;var sd="TooltipTrigger",fv=d.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=ii(sd,n),a=Ef(sd,n),i=lc(n),l=d.useRef(null),c=mt(t,l,o.onTriggerChange),u=d.useRef(!1),f=d.useRef(!1),h=d.useCallback(()=>u.current=!1,[]);return d.useEffect(()=>()=>document.removeEventListener("pointerup",h),[h]),s.jsx(J2,{asChild:!0,...i,children:s.jsx(rt.button,{"aria-describedby":o.open?o.contentId:void 0,"data-state":o.stateAttribute,...r,ref:c,onPointerMove:Ht(e.onPointerMove,m=>{m.pointerType!=="touch"&&!f.current&&!a.isPointerInTransitRef.current&&(o.onTriggerEnter(),f.current=!0)}),onPointerLeave:Ht(e.onPointerLeave,()=>{o.onTriggerLeave(),f.current=!1}),onPointerDown:Ht(e.onPointerDown,()=>{o.open&&o.onClose(),u.current=!0,document.addEventListener("pointerup",h,{once:!0})}),onFocus:Ht(e.onFocus,()=>{u.current||o.onOpen()}),onBlur:Ht(e.onBlur,o.onClose),onClick:Ht(e.onClick,o.onClose)})})});fv.displayName=sd;var jf="TooltipPortal",[hE,pE]=ic(jf,{forceMount:void 0}),hv=e=>{const{__scopeTooltip:t,forceMount:n,children:r,container:o}=e,a=ii(jf,t);return s.jsx(hE,{scope:t,forceMount:n,children:s.jsx(_o,{present:n||a.open,children:s.jsx(pa,{asChild:!0,container:o,children:r})})})};hv.displayName=jf;var Xs="TooltipContent",pv=d.forwardRef((e,t)=>{const n=pE(Xs,e.__scopeTooltip),{forceMount:r=n.forceMount,side:o="top",...a}=e,i=ii(Xs,e.__scopeTooltip);return s.jsx(_o,{present:r||i.open,children:i.disableHoverableContent?s.jsx(mv,{side:o,...a,ref:t}):s.jsx(mE,{side:o,...a,ref:t})})}),mE=d.forwardRef((e,t)=>{const n=ii(Xs,e.__scopeTooltip),r=Ef(Xs,e.__scopeTooltip),o=d.useRef(null),a=mt(t,o),[i,l]=d.useState(null),{trigger:c,onClose:u}=n,f=o.current,{onPointerInTransitChange:h}=r,m=d.useCallback(()=>{l(null),h(!1)},[h]),p=d.useCallback((x,g)=>{const w=x.currentTarget,v={x:x.clientX,y:x.clientY},b=wE(v,w.getBoundingClientRect()),C=bE(v,b),S=yE(g.getBoundingClientRect()),E=SE([...C,...S]);l(E),h(!0)},[h]);return d.useEffect(()=>()=>m(),[m]),d.useEffect(()=>{if(c&&f){const x=w=>p(w,f),g=w=>p(w,c);return c.addEventListener("pointerleave",x),f.addEventListener("pointerleave",g),()=>{c.removeEventListener("pointerleave",x),f.removeEventListener("pointerleave",g)}}},[c,f,p,m]),d.useEffect(()=>{if(i){const x=g=>{const w=g.target,v={x:g.clientX,y:g.clientY},b=(c==null?void 0:c.contains(w))||(f==null?void 0:f.contains(w)),C=!CE(v,i);b?m():C&&(m(),u())};return document.addEventListener("pointermove",x),()=>document.removeEventListener("pointermove",x)}},[c,f,i,u,m]),s.jsx(mv,{...e,ref:a})}),[gE,xE]=ic(Wa,{isInside:!1}),vE=F_("TooltipContent"),mv=d.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":o,onEscapeKeyDown:a,onPointerDownOutside:i,...l}=e,c=ii(Xs,n),u=lc(n),{onClose:f}=c;return d.useEffect(()=>(document.addEventListener(od,f),()=>document.removeEventListener(od,f)),[f]),d.useEffect(()=>{if(c.trigger){const h=m=>{const p=m.target;p!=null&&p.contains(c.trigger)&&f()};return window.addEventListener("scroll",h,{capture:!0}),()=>window.removeEventListener("scroll",h,{capture:!0})}},[c.trigger,f]),s.jsx(tc,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:a,onPointerDownOutside:i,onFocusOutside:h=>h.preventDefault(),onDismiss:f,children:s.jsxs(Q2,{"data-state":c.stateAttribute,...u,...l,ref:t,style:{...l.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[s.jsx(vE,{children:r}),s.jsx(gE,{scope:n,isInside:!0,children:s.jsx(cE,{id:c.contentId,role:"tooltip",children:o||r})})]})})});pv.displayName=Xs;var gv="TooltipArrow",xv=d.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=lc(n);return xE(gv,n).isInside?null:s.jsx(eE,{...o,...r,ref:t})});xv.displayName=gv;function wE(e,t){const n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),o=Math.abs(t.right-e.x),a=Math.abs(t.left-e.x);switch(Math.min(n,r,o,a)){case a:return"left";case o:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}function bE(e,t,n=5){const r=[];switch(t){case"top":r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case"bottom":r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case"left":r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case"right":r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}function yE(e){const{top:t,right:n,bottom:r,left:o}=e;return[{x:o,y:t},{x:n,y:t},{x:n,y:r},{x:o,y:r}]}function CE(e,t){const{x:n,y:r}=e;let o=!1;for(let a=0,i=t.length-1;a<t.length;i=a++){const l=t[a],c=t[i],u=l.x,f=l.y,h=c.x,m=c.y;f>r!=m>r&&n<(h-u)*(r-f)/(m-f)+u&&(o=!o)}return o}function SE(e){const t=e.slice();return t.sort((n,r)=>n.x<r.x?-1:n.x>r.x?1:n.y<r.y?-1:n.y>r.y?1:0),_E(t)}function _E(e){if(e.length<=1)return e.slice();const t=[];for(let r=0;r<e.length;r++){const o=e[r];for(;t.length>=2;){const a=t[t.length-1],i=t[t.length-2];if((a.x-i.x)*(o.y-i.y)>=(a.y-i.y)*(o.x-i.x))t.pop();else break}t.push(o)}t.pop();const n=[];for(let r=e.length-1;r>=0;r--){const o=e[r];for(;n.length>=2;){const a=n[n.length-1],i=n[n.length-2];if((a.x-i.x)*(o.y-i.y)>=(a.y-i.y)*(o.x-i.x))n.pop();else break}n.push(o)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var kE=uv,EE=dv,jE=fv,NE=hv,TE=pv,AE=xv;function IE({delayDuration:e=0,...t}){return s.jsx(kE,{"data-slot":"tooltip-provider",delayDuration:e,...t})}function vo({...e}){return s.jsx(IE,{delayDuration:500,children:s.jsx(EE,{"data-slot":"tooltip",...e})})}function wo({...e}){return s.jsx(jE,{"data-slot":"tooltip-trigger",...e})}function bo({className:e,sideOffset:t=0,children:n,...r}){return s.jsx(NE,{children:s.jsxs(TE,{"data-slot":"tooltip-content",sideOffset:t,className:ze("bg-primary text-primary-foreground animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md px-3 py-1.5 text-xs text-balance",e),...r,children:[n,s.jsx(AE,{className:"bg-primary fill-primary z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]"})]})})}const vv="text-[var(--color-primary-wMain)] enabled:hover:text-[var(--color-primary-w60)] dark:text-[var(--color-primary-w10)] dark:enabled:hover:text-[var(--color-white)]",nu=vv+" enabled:hover:bg-[var(--color-primary-w10)] dark:enabled:hover:bg-[var(--color-primary-w60)]",RE=Uo("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-sm font-semibold transition-all disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 cursor-pointer disabled:cursor-not-allowed",{variants:{variant:{default:"text-[var(--color-primary-w10)] bg-[var(--color-primary-wMain)] enabled:hover:text-[var(--color-white)] enabled:hover:bg-[var(--color-primary-w100)] dark:enabled:hover:bg-[var(--color-primary-w60)]",destructive:"text-[var(--color-white)] bg-[var(--color-error-wMain)] enabled:hover:bg-[var(--color-error-w70)]",outline:nu+" border border-1 border-[var(--color-primary-wMain)]",secondary:nu,ghost:nu,link:vv+" underline-offset-4 enabled:hover:underline"},size:{default:"h-9 px-5 py-2 has-[>svg]:px-3",sm:"h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",lg:"h-10 rounded-md px-6 has-[>svg]:px-4",icon:"size-9"}},defaultVariants:{variant:"default",size:"default"}});function xe({className:e,variant:t,size:n,asChild:r=!1,tooltip:o="",tooltipSide:a,testid:i="",...l}){const c=r?kx:"button",u=o?{...l,"aria-label":o}:l,f=s.jsx(c,{"data-slot":"button","data-testid":i||o||l.title,className:ze(RE({variant:t,size:n,className:e})),...u});return o?s.jsxs(vo,{children:[s.jsx(wo,{asChild:!0,children:f}),s.jsx(bo,{side:a,children:o})]}):f}const wv=({onClick:e,text:t="View Agent Workflow"})=>s.jsx(xe,{"data-testid":"viewAgentWorkflow",variant:"ghost",size:"sm",onClick:e,tooltip:t,children:s.jsx(ol,{className:"h-4 w-4"})}),Wr=d.forwardRef(({className:e,...t},n)=>s.jsx("textarea",{className:ze("flex min-h-[80px] w-full rounded-md border px-3 py-2 placeholder:opacity-75 disabled:cursor-not-allowed disabled:opacity-50",e),ref:n,...t}));Wr.displayName="Textarea";const bv=d.forwardRef(({className:e,value:t,highlightPattern:n=/(\{\{[^}]+\}\})/g,highlightClassName:r="bg-primary/20 text-primary rounded px-0.5",...o},a)=>{const i=d.useRef(null),l=d.useRef(null);d.useImperativeHandle(a,()=>l.current);const c=d.useCallback(()=>{i.current&&l.current&&(i.current.scrollTop=l.current.scrollTop,i.current.scrollLeft=l.current.scrollLeft)},[]),u=d.useCallback(h=>h?h.split(n).map((p,x)=>p.match(n)?s.jsx("mark",{className:r,children:p},x):s.jsx("span",{children:p},x)):null,[n,r]),f=typeof t=="string"?t:"";return s.jsxs("div",{className:"relative",children:[s.jsxs("div",{ref:i,className:ze("pointer-events-none absolute inset-0 overflow-hidden break-words whitespace-pre-wrap","rounded-md border border-transparent px-3 py-2","font-mono text-sm",e),style:{lineHeight:"1.5",wordWrap:"break-word",overflowWrap:"break-word"},"aria-hidden":"true",children:[u(f),s.jsx("br",{})]}),s.jsx("textarea",{ref:l,className:ze("relative z-10 flex min-h-[80px] w-full rounded-md border bg-transparent px-3 py-2","placeholder:opacity-75 disabled:cursor-not-allowed disabled:opacity-50","caret-foreground font-mono text-sm","text-transparent",e),style:{lineHeight:"1.5",caretColor:"var(--foreground)",WebkitTextFillColor:"transparent"},value:t,onScroll:c,...o})]})});bv.displayName="HighlightedTextarea";function br({className:e,type:t,...n}){return s.jsx("input",{type:t,"data-slot":"input",className:ze("file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 border-input flex h-9 w-full min-w-0 rounded-sm border bg-transparent px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm","outline-none focus-visible:border-[var(--color-brand-wMain)] focus-visible:ring-[2px] focus-visible:ring-[var(--color-brand-wMain)]/50","aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",e),...n})}const Nf=({value:e,onChange:t,placeholder:n="Filter by name...",testid:r,className:o=""})=>s.jsxs("div",{className:`relative ${o}`,children:[s.jsx(Vd,{className:"text-muted-foreground absolute top-1/2 left-3 h-4 w-4 -translate-y-1/2"}),s.jsx("input",{type:"text","data-testid":r,placeholder:n,value:e,onChange:a=>t(a.target.value),className:"bg-background w-xs rounded-md border py-2 pr-3 pl-9"})]});var PE="Label",yv=d.forwardRef((e,t)=>s.jsx(rt.label,{...e,ref:t,onMouseDown:n=>{var o;n.target.closest("button, input, select, textarea")||((o=e.onMouseDown)==null||o.call(e,n),!n.defaultPrevented&&n.detail>1&&n.preventDefault())}}));yv.displayName=PE;var ME=yv;function It({className:e,...t}){return s.jsx(ME,{"data-slot":"label",className:ze("flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",e),...t})}function Tf({className:e,noPadding:t,...n}){return s.jsx("div",{"data-slot":"card",className:ze("bg-card text-card-foreground flex flex-col gap-6 rounded-lg border shadow-[0_4px_6px_-1px_rgba(0,0,0,0.15)] dark:shadow-[0_4px_6px_-1px_rgba(255,255,255,0.1)]",!t&&"py-6",e),...n})}function DE({className:e,...t}){return s.jsx("div",{"data-slot":"card-header",className:ze("@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-1.5 px-6 has-data-[slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-6",e),...t})}function Us({className:e,...t}){return s.jsx("div",{"data-slot":"card-title",className:ze("leading-none font-semibold",e),...t})}function OE({className:e,...t}){return s.jsx("div",{"data-slot":"card-description",className:ze("text-muted-foreground text-sm",e),...t})}function cc({className:e,noPadding:t,...n}){return s.jsx("div",{"data-slot":"card-content",className:ze(!t&&"px-6",e),...n})}var li=e=>e.type==="checkbox",Jo=e=>e instanceof Date,Jn=e=>e==null;const Cv=e=>typeof e=="object";var bn=e=>!Jn(e)&&!Array.isArray(e)&&Cv(e)&&!Jo(e),LE=e=>bn(e)&&e.target?li(e.target)?e.target.checked:e.target.value:e,FE=e=>e.substring(0,e.search(/\.\d+(\.|$)/))||e,$E=(e,t)=>e.has(FE(t)),zE=e=>{const t=e.constructor&&e.constructor.prototype;return bn(t)&&t.hasOwnProperty("isPrototypeOf")},Af=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function En(e){let t;const n=Array.isArray(e),r=typeof FileList<"u"?e instanceof FileList:!1;if(e instanceof Date)t=new Date(e);else if(!(Af&&(e instanceof Blob||r))&&(n||bn(e)))if(t=n?[]:Object.create(Object.getPrototypeOf(e)),!n&&!zE(e))t=e;else for(const o in e)e.hasOwnProperty(o)&&(t[o]=En(e[o]));else return e;return t}var uc=e=>/^\w*$/.test(e),dn=e=>e===void 0,If=e=>Array.isArray(e)?e.filter(Boolean):[],Rf=e=>If(e.replace(/["|']|\]/g,"").split(/\.|\[/)),qe=(e,t,n)=>{if(!t||!bn(e))return n;const r=(uc(t)?[t]:Rf(t)).reduce((o,a)=>Jn(o)?o:o[a],e);return dn(r)||r===e?dn(e[t])?n:e[t]:r},Gr=e=>typeof e=="boolean",Gt=(e,t,n)=>{let r=-1;const o=uc(t)?[t]:Rf(t),a=o.length,i=a-1;for(;++r<a;){const l=o[r];let c=n;if(r!==i){const u=e[l];c=bn(u)||Array.isArray(u)?u:isNaN(+o[r+1])?{}:[]}if(l==="__proto__"||l==="constructor"||l==="prototype")return;e[l]=c,e=e[l]}};const Ip={BLUR:"blur",FOCUS_OUT:"focusout"},Tr={onBlur:"onBlur",onChange:"onChange",onSubmit:"onSubmit",onTouched:"onTouched",all:"all"},ao={max:"max",min:"min",maxLength:"maxLength",minLength:"minLength",pattern:"pattern",required:"required",validate:"validate"},UE=Rt.createContext(null);UE.displayName="HookFormContext";var BE=(e,t,n,r=!0)=>{const o={defaultValues:t._defaultValues};for(const a in e)Object.defineProperty(o,a,{get:()=>{const i=a;return t._proxyFormState[i]!==Tr.all&&(t._proxyFormState[i]=!r||Tr.all),e[i]}});return o};const VE=typeof window<"u"?Rt.useLayoutEffect:Rt.useEffect;var ur=e=>typeof e=="string",WE=(e,t,n,r,o)=>ur(e)?(r&&t.watch.add(e),qe(n,e,o)):Array.isArray(e)?e.map(a=>(r&&t.watch.add(a),qe(n,a))):(r&&(t.watchAll=!0),n),ad=e=>Jn(e)||!Cv(e);function Ao(e,t,n=new WeakSet){if(ad(e)||ad(t))return e===t;if(Jo(e)&&Jo(t))return e.getTime()===t.getTime();const r=Object.keys(e),o=Object.keys(t);if(r.length!==o.length)return!1;if(n.has(e)||n.has(t))return!0;n.add(e),n.add(t);for(const a of r){const i=e[a];if(!o.includes(a))return!1;if(a!=="ref"){const l=t[a];if(Jo(i)&&Jo(l)||bn(i)&&bn(l)||Array.isArray(i)&&Array.isArray(l)?!Ao(i,l,n):i!==l)return!1}}return!0}var Pf=(e,t,n,r,o)=>t?{...n[e],types:{...n[e]&&n[e].types?n[e].types:{},[r]:o||!0}}:{},Da=e=>Array.isArray(e)?e:[e],Rp=()=>{let e=[];return{get observers(){return e},next:o=>{for(const a of e)a.next&&a.next(o)},subscribe:o=>(e.push(o),{unsubscribe:()=>{e=e.filter(a=>a!==o)}}),unsubscribe:()=>{e=[]}}};function Sv(e,t){const n={};for(const r in e)if(e.hasOwnProperty(r)){const o=e[r],a=t[r];if(o&&bn(o)&&a){const i=Sv(o,a);bn(i)&&(n[r]=i)}else e[r]&&(n[r]=a)}return n}var Xn=e=>bn(e)&&!Object.keys(e).length,Mf=e=>e.type==="file",Ar=e=>typeof e=="function",El=e=>{if(!Af)return!1;const t=e?e.ownerDocument:0;return e instanceof(t&&t.defaultView?t.defaultView.HTMLElement:HTMLElement)},_v=e=>e.type==="select-multiple",Df=e=>e.type==="radio",HE=e=>Df(e)||li(e),ru=e=>El(e)&&e.isConnected;function ZE(e,t){const n=t.slice(0,-1).length;let r=0;for(;r<n;)e=dn(e)?r++:e[t[r++]];return e}function GE(e){for(const t in e)if(e.hasOwnProperty(t)&&!dn(e[t]))return!1;return!0}function gn(e,t){const n=Array.isArray(t)?t:uc(t)?[t]:Rf(t),r=n.length===1?e:ZE(e,n),o=n.length-1,a=n[o];return r&&delete r[a],o!==0&&(bn(r)&&Xn(r)||Array.isArray(r)&&GE(r))&&gn(e,n.slice(0,-1)),e}var YE=e=>{for(const t in e)if(Ar(e[t]))return!0;return!1};function kv(e){return Array.isArray(e)||bn(e)&&!YE(e)}function id(e,t={}){for(const n in e)kv(e[n])?(t[n]=Array.isArray(e[n])?[]:{},id(e[n],t[n])):dn(e[n])||(t[n]=!0);return t}function Is(e,t,n){n||(n=id(t));for(const r in e)kv(e[r])?dn(t)||ad(n[r])?n[r]=id(e[r],Array.isArray(e[r])?[]:{}):Is(e[r],Jn(t)?{}:t[r],n[r]):n[r]=!Ao(e[r],t[r]);return n}const Pp={value:!1,isValid:!1},Mp={value:!0,isValid:!0};var Ev=e=>{if(Array.isArray(e)){if(e.length>1){const t=e.filter(n=>n&&n.checked&&!n.disabled).map(n=>n.value);return{value:t,isValid:!!t.length}}return e[0].checked&&!e[0].disabled?e[0].attributes&&!dn(e[0].attributes.value)?dn(e[0].value)||e[0].value===""?Mp:{value:e[0].value,isValid:!0}:Mp:Pp}return Pp},jv=(e,{valueAsNumber:t,valueAsDate:n,setValueAs:r})=>dn(e)?e:t?e===""?NaN:e&&+e:n&&ur(e)?new Date(e):r?r(e):e;const Dp={isValid:!1,value:null};var Nv=e=>Array.isArray(e)?e.reduce((t,n)=>n&&n.checked&&!n.disabled?{isValid:!0,value:n.value}:t,Dp):Dp;function Op(e){const t=e.ref;return Mf(t)?t.files:Df(t)?Nv(e.refs).value:_v(t)?[...t.selectedOptions].map(({value:n})=>n):li(t)?Ev(e.refs).value:jv(dn(t.value)?e.ref.value:t.value,e)}var KE=(e,t,n,r)=>{const o={};for(const a of e){const i=qe(t,a);i&&Gt(o,a,i._f)}return{criteriaMode:n,names:[...e],fields:o,shouldUseNativeValidation:r}},jl=e=>e instanceof RegExp,ba=e=>dn(e)?e:jl(e)?e.source:bn(e)?jl(e.value)?e.value.source:e.value:e,Lp=e=>({isOnSubmit:!e||e===Tr.onSubmit,isOnBlur:e===Tr.onBlur,isOnChange:e===Tr.onChange,isOnAll:e===Tr.all,isOnTouch:e===Tr.onTouched});const Fp="AsyncFunction";var qE=e=>!!e&&!!e.validate&&!!(Ar(e.validate)&&e.validate.constructor.name===Fp||bn(e.validate)&&Object.values(e.validate).find(t=>t.constructor.name===Fp)),XE=e=>e.mount&&(e.required||e.min||e.max||e.maxLength||e.minLength||e.pattern||e.validate),$p=(e,t,n)=>!n&&(t.watchAll||t.watch.has(e)||[...t.watch].some(r=>e.startsWith(r)&&/^\.\w+/.test(e.slice(r.length))));const Oa=(e,t,n,r)=>{for(const o of n||Object.keys(e)){const a=qe(e,o);if(a){const{_f:i,...l}=a;if(i){if(i.refs&&i.refs[0]&&t(i.refs[0],o)&&!r)return!0;if(i.ref&&t(i.ref,i.name)&&!r)return!0;if(Oa(l,t))break}else if(bn(l)&&Oa(l,t))break}}};function zp(e,t,n){const r=qe(e,n);if(r||uc(n))return{error:r,name:n};const o=n.split(".");for(;o.length;){const a=o.join("."),i=qe(t,a),l=qe(e,a);if(i&&!Array.isArray(i)&&n!==a)return{name:n};if(l&&l.type)return{name:a,error:l};if(l&&l.root&&l.root.type)return{name:`${a}.root`,error:l.root};o.pop()}return{name:n}}var JE=(e,t,n,r)=>{n(e);const{name:o,...a}=e;return Xn(a)||Object.keys(a).length>=Object.keys(t).length||Object.keys(a).find(i=>t[i]===(!r||Tr.all))},QE=(e,t,n)=>!e||!t||e===t||Da(e).some(r=>r&&(n?r===t:r.startsWith(t)||t.startsWith(r))),ej=(e,t,n,r,o)=>o.isOnAll?!1:!n&&o.isOnTouch?!(t||e):(n?r.isOnBlur:o.isOnBlur)?!e:(n?r.isOnChange:o.isOnChange)?e:!0,tj=(e,t)=>!If(qe(e,t)).length&&gn(e,t),nj=(e,t,n)=>{const r=Da(qe(e,n));return Gt(r,"root",t[n]),Gt(e,n,r),e};function Up(e,t,n="validate"){if(ur(e)||Array.isArray(e)&&e.every(ur)||Gr(e)&&!e)return{type:n,message:ur(e)?e:"",ref:t}}var Ss=e=>bn(e)&&!jl(e)?e:{value:e,message:""},Bp=async(e,t,n,r,o,a)=>{const{ref:i,refs:l,required:c,maxLength:u,minLength:f,min:h,max:m,pattern:p,validate:x,name:g,valueAsNumber:w,mount:v}=e._f,b=qe(n,g);if(!v||t.has(g))return{};const C=l?l[0]:i,S=N=>{o&&C.reportValidity&&(C.setCustomValidity(Gr(N)?"":N||""),C.reportValidity())},E={},_=Df(i),j=li(i),A=_||j,P=(w||Mf(i))&&dn(i.value)&&dn(b)||El(i)&&i.value===""||b===""||Array.isArray(b)&&!b.length,O=Pf.bind(null,g,r,E),B=(N,M,y,T=ao.maxLength,R=ao.minLength)=>{const z=N?M:y;E[g]={type:N?T:R,message:z,ref:i,...O(N?T:R,z)}};if(a?!Array.isArray(b)||!b.length:c&&(!A&&(P||Jn(b))||Gr(b)&&!b||j&&!Ev(l).isValid||_&&!Nv(l).isValid)){const{value:N,message:M}=ur(c)?{value:!!c,message:c}:Ss(c);if(N&&(E[g]={type:ao.required,message:M,ref:C,...O(ao.required,M)},!r))return S(M),E}if(!P&&(!Jn(h)||!Jn(m))){let N,M;const y=Ss(m),T=Ss(h);if(!Jn(b)&&!isNaN(b)){const R=i.valueAsNumber||b&&+b;Jn(y.value)||(N=R>y.value),Jn(T.value)||(M=R<T.value)}else{const R=i.valueAsDate||new Date(b),z=J=>new Date(new Date().toDateString()+" "+J),F=i.type=="time",I=i.type=="week";ur(y.value)&&b&&(N=F?z(b)>z(y.value):I?b>y.value:R>new Date(y.value)),ur(T.value)&&b&&(M=F?z(b)<z(T.value):I?b<T.value:R<new Date(T.value))}if((N||M)&&(B(!!N,y.message,T.message,ao.max,ao.min),!r))return S(E[g].message),E}if((u||f)&&!P&&(ur(b)||a&&Array.isArray(b))){const N=Ss(u),M=Ss(f),y=!Jn(N.value)&&b.length>+N.value,T=!Jn(M.value)&&b.length<+M.value;if((y||T)&&(B(y,N.message,M.message),!r))return S(E[g].message),E}if(p&&!P&&ur(b)){const{value:N,message:M}=Ss(p);if(jl(N)&&!b.match(N)&&(E[g]={type:ao.pattern,message:M,ref:i,...O(ao.pattern,M)},!r))return S(M),E}if(x){if(Ar(x)){const N=await x(b,n),M=Up(N,C);if(M&&(E[g]={...M,...O(ao.validate,M.message)},!r))return S(M.message),E}else if(bn(x)){let N={};for(const M in x){if(!Xn(N)&&!r)break;const y=Up(await x[M](b,n),C,M);y&&(N={...y,...O(M,y.message)},S(y.message),r&&(E[g]=N))}if(!Xn(N)&&(E[g]={ref:C,...N},!r))return E}}return S(!0),E};const rj={mode:Tr.onSubmit,reValidateMode:Tr.onChange,shouldFocusError:!0};function oj(e={}){let t={...rj,...e},n={submitCount:0,isDirty:!1,isReady:!1,isLoading:Ar(t.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{},errors:t.errors||{},disabled:t.disabled||!1},r={},o=bn(t.defaultValues)||bn(t.values)?En(t.defaultValues||t.values)||{}:{},a=t.shouldUnregister?{}:En(o),i={action:!1,mount:!1,watch:!1},l={mount:new Set,disabled:new Set,unMount:new Set,array:new Set,watch:new Set},c,u=0;const f={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1};let h={...f};const m={array:Rp(),state:Rp()},p=t.criteriaMode===Tr.all,x=$=>Y=>{clearTimeout(u),u=setTimeout($,Y)},g=async $=>{if(!t.disabled&&(f.isValid||h.isValid||$)){const Y=t.resolver?Xn((await j()).errors):await P(r,!0);Y!==n.isValid&&m.state.next({isValid:Y})}},w=($,Y)=>{!t.disabled&&(f.isValidating||f.validatingFields||h.isValidating||h.validatingFields)&&(($||Array.from(l.mount)).forEach(H=>{H&&(Y?Gt(n.validatingFields,H,Y):gn(n.validatingFields,H))}),m.state.next({validatingFields:n.validatingFields,isValidating:!Xn(n.validatingFields)}))},v=($,Y=[],H,ce,ue=!0,ae=!0)=>{if(ce&&H&&!t.disabled){if(i.action=!0,ae&&Array.isArray(qe(r,$))){const pe=H(qe(r,$),ce.argA,ce.argB);ue&&Gt(r,$,pe)}if(ae&&Array.isArray(qe(n.errors,$))){const pe=H(qe(n.errors,$),ce.argA,ce.argB);ue&&Gt(n.errors,$,pe),tj(n.errors,$)}if((f.touchedFields||h.touchedFields)&&ae&&Array.isArray(qe(n.touchedFields,$))){const pe=H(qe(n.touchedFields,$),ce.argA,ce.argB);ue&&Gt(n.touchedFields,$,pe)}(f.dirtyFields||h.dirtyFields)&&(n.dirtyFields=Is(o,a)),m.state.next({name:$,isDirty:B($,Y),dirtyFields:n.dirtyFields,errors:n.errors,isValid:n.isValid})}else Gt(a,$,Y)},b=($,Y)=>{Gt(n.errors,$,Y),m.state.next({errors:n.errors})},C=$=>{n.errors=$,m.state.next({errors:n.errors,isValid:!1})},S=($,Y,H,ce)=>{const ue=qe(r,$);if(ue){const ae=qe(a,$,dn(H)?qe(o,$):H);dn(ae)||ce&&ce.defaultChecked||Y?Gt(a,$,Y?ae:Op(ue._f)):y($,ae),i.mount&&g()}},E=($,Y,H,ce,ue)=>{let ae=!1,pe=!1;const Te={name:$};if(!t.disabled){if(!H||ce){(f.isDirty||h.isDirty)&&(pe=n.isDirty,n.isDirty=Te.isDirty=B(),ae=pe!==Te.isDirty);const Ae=Ao(qe(o,$),Y);pe=!!qe(n.dirtyFields,$),Ae?gn(n.dirtyFields,$):Gt(n.dirtyFields,$,!0),Te.dirtyFields=n.dirtyFields,ae=ae||(f.dirtyFields||h.dirtyFields)&&pe!==!Ae}if(H){const Ae=qe(n.touchedFields,$);Ae||(Gt(n.touchedFields,$,H),Te.touchedFields=n.touchedFields,ae=ae||(f.touchedFields||h.touchedFields)&&Ae!==H)}ae&&ue&&m.state.next(Te)}return ae?Te:{}},_=($,Y,H,ce)=>{const ue=qe(n.errors,$),ae=(f.isValid||h.isValid)&&Gr(Y)&&n.isValid!==Y;if(t.delayError&&H?(c=x(()=>b($,H)),c(t.delayError)):(clearTimeout(u),c=null,H?Gt(n.errors,$,H):gn(n.errors,$)),(H?!Ao(ue,H):ue)||!Xn(ce)||ae){const pe={...ce,...ae&&Gr(Y)?{isValid:Y}:{},errors:n.errors,name:$};n={...n,...pe},m.state.next(pe)}},j=async $=>{w($,!0);const Y=await t.resolver(a,t.context,KE($||l.mount,r,t.criteriaMode,t.shouldUseNativeValidation));return w($),Y},A=async $=>{const{errors:Y}=await j($);if($)for(const H of $){const ce=qe(Y,H);ce?Gt(n.errors,H,ce):gn(n.errors,H)}else n.errors=Y;return Y},P=async($,Y,H={valid:!0})=>{for(const ce in $){const ue=$[ce];if(ue){const{_f:ae,...pe}=ue;if(ae){const Te=l.array.has(ae.name),Ae=ue._f&&qE(ue._f);Ae&&f.validatingFields&&w([ae.name],!0);const gt=await Bp(ue,l.disabled,a,p,t.shouldUseNativeValidation&&!Y,Te);if(Ae&&f.validatingFields&&w([ae.name]),gt[ae.name]&&(H.valid=!1,Y))break;!Y&&(qe(gt,ae.name)?Te?nj(n.errors,gt,ae.name):Gt(n.errors,ae.name,gt[ae.name]):gn(n.errors,ae.name))}!Xn(pe)&&await P(pe,Y,H)}}return H.valid},O=()=>{for(const $ of l.unMount){const Y=qe(r,$);Y&&(Y._f.refs?Y._f.refs.every(H=>!ru(H)):!ru(Y._f.ref))&&X($)}l.unMount=new Set},B=($,Y)=>!t.disabled&&($&&Y&&Gt(a,$,Y),!Ao(J(),o)),N=($,Y,H)=>WE($,l,{...i.mount?a:dn(Y)?o:ur($)?{[$]:Y}:Y},H,Y),M=$=>If(qe(i.mount?a:o,$,t.shouldUnregister?qe(o,$,[]):[])),y=($,Y,H={})=>{const ce=qe(r,$);let ue=Y;if(ce){const ae=ce._f;ae&&(!ae.disabled&&Gt(a,$,jv(Y,ae)),ue=El(ae.ref)&&Jn(Y)?"":Y,_v(ae.ref)?[...ae.ref.options].forEach(pe=>pe.selected=ue.includes(pe.value)):ae.refs?li(ae.ref)?ae.refs.forEach(pe=>{(!pe.defaultChecked||!pe.disabled)&&(Array.isArray(ue)?pe.checked=!!ue.find(Te=>Te===pe.value):pe.checked=ue===pe.value||!!ue)}):ae.refs.forEach(pe=>pe.checked=pe.value===ue):Mf(ae.ref)?ae.ref.value="":(ae.ref.value=ue,ae.ref.type||m.state.next({name:$,values:En(a)})))}(H.shouldDirty||H.shouldTouch)&&E($,ue,H.shouldTouch,H.shouldDirty,!0),H.shouldValidate&&I($)},T=($,Y,H)=>{for(const ce in Y){if(!Y.hasOwnProperty(ce))return;const ue=Y[ce],ae=$+"."+ce,pe=qe(r,ae);(l.array.has($)||bn(ue)||pe&&!pe._f)&&!Jo(ue)?T(ae,ue,H):y(ae,ue,H)}},R=($,Y,H={})=>{const ce=qe(r,$),ue=l.array.has($),ae=En(Y);Gt(a,$,ae),ue?(m.array.next({name:$,values:En(a)}),(f.isDirty||f.dirtyFields||h.isDirty||h.dirtyFields)&&H.shouldDirty&&m.state.next({name:$,dirtyFields:Is(o,a),isDirty:B($,ae)})):ce&&!ce._f&&!Jn(ae)?T($,ae,H):y($,ae,H),$p($,l)&&m.state.next({...n,name:$}),m.state.next({name:i.mount?$:void 0,values:En(a)})},z=async $=>{i.mount=!0;const Y=$.target;let H=Y.name,ce=!0;const ue=qe(r,H),ae=Ae=>{ce=Number.isNaN(Ae)||Jo(Ae)&&isNaN(Ae.getTime())||Ao(Ae,qe(a,H,Ae))},pe=Lp(t.mode),Te=Lp(t.reValidateMode);if(ue){let Ae,gt;const Pt=Y.type?Op(ue._f):LE($),Nt=$.type===Ip.BLUR||$.type===Ip.FOCUS_OUT,Mt=!XE(ue._f)&&!t.resolver&&!qe(n.errors,H)&&!ue._f.deps||ej(Nt,qe(n.touchedFields,H),n.isSubmitted,Te,pe),ct=$p(H,l,Nt);Gt(a,H,Pt),Nt?(!Y||!Y.readOnly)&&(ue._f.onBlur&&ue._f.onBlur($),c&&c(0)):ue._f.onChange&&ue._f.onChange($);const $t=E(H,Pt,Nt),Wt=!Xn($t)||ct;if(!Nt&&m.state.next({name:H,type:$.type,values:En(a)}),Mt)return(f.isValid||h.isValid)&&(t.mode==="onBlur"?Nt&&g():Nt||g()),Wt&&m.state.next({name:H,...ct?{}:$t});if(!Nt&&ct&&m.state.next({...n}),t.resolver){const{errors:Dt}=await j([H]);if(ae(Pt),ce){const ve=zp(n.errors,r,H),Pe=zp(Dt,r,ve.name||H);Ae=Pe.error,H=Pe.name,gt=Xn(Dt)}}else w([H],!0),Ae=(await Bp(ue,l.disabled,a,p,t.shouldUseNativeValidation))[H],w([H]),ae(Pt),ce&&(Ae?gt=!1:(f.isValid||h.isValid)&&(gt=await P(r,!0)));ce&&(ue._f.deps&&(!Array.isArray(ue._f.deps)||ue._f.deps.length>0)&&I(ue._f.deps),_(H,gt,Ae,$t))}},F=($,Y)=>{if(qe(n.errors,Y)&&$.focus)return $.focus(),1},I=async($,Y={})=>{let H,ce;const ue=Da($);if(t.resolver){const ae=await A(dn($)?$:ue);H=Xn(ae),ce=$?!ue.some(pe=>qe(ae,pe)):H}else $?(ce=(await Promise.all(ue.map(async ae=>{const pe=qe(r,ae);return await P(pe&&pe._f?{[ae]:pe}:pe)}))).every(Boolean),!(!ce&&!n.isValid)&&g()):ce=H=await P(r);return m.state.next({...!ur($)||(f.isValid||h.isValid)&&H!==n.isValid?{}:{name:$},...t.resolver||!$?{isValid:H}:{},errors:n.errors}),Y.shouldFocus&&!ce&&Oa(r,F,$?ue:l.mount),ce},J=($,Y)=>{let H={...i.mount?a:o};return Y&&(H=Sv(Y.dirtyFields?n.dirtyFields:n.touchedFields,H)),dn($)?H:ur($)?qe(H,$):$.map(ce=>qe(H,ce))},L=($,Y)=>({invalid:!!qe((Y||n).errors,$),isDirty:!!qe((Y||n).dirtyFields,$),error:qe((Y||n).errors,$),isValidating:!!qe(n.validatingFields,$),isTouched:!!qe((Y||n).touchedFields,$)}),D=$=>{$&&Da($).forEach(Y=>gn(n.errors,Y)),m.state.next({errors:$?n.errors:{}})},W=($,Y,H)=>{const ce=(qe(r,$,{_f:{}})._f||{}).ref,ue=qe(n.errors,$)||{},{ref:ae,message:pe,type:Te,...Ae}=ue;Gt(n.errors,$,{...Ae,...Y,ref:ce}),m.state.next({name:$,errors:n.errors,isValid:!1}),H&&H.shouldFocus&&ce&&ce.focus&&ce.focus()},G=($,Y)=>Ar($)?m.state.subscribe({next:H=>"values"in H&&$(N(void 0,Y),H)}):N($,Y,!0),V=$=>m.state.subscribe({next:Y=>{QE($.name,Y.name,$.exact)&&JE(Y,$.formState||f,Z,$.reRenderRoot)&&$.callback({values:{...a},...n,...Y,defaultValues:o})}}).unsubscribe,Q=$=>(i.mount=!0,h={...h,...$.formState},V({...$,formState:h})),X=($,Y={})=>{for(const H of $?Da($):l.mount)l.mount.delete(H),l.array.delete(H),Y.keepValue||(gn(r,H),gn(a,H)),!Y.keepError&&gn(n.errors,H),!Y.keepDirty&&gn(n.dirtyFields,H),!Y.keepTouched&&gn(n.touchedFields,H),!Y.keepIsValidating&&gn(n.validatingFields,H),!t.shouldUnregister&&!Y.keepDefaultValue&&gn(o,H);m.state.next({values:En(a)}),m.state.next({...n,...Y.keepDirty?{isDirty:B()}:{}}),!Y.keepIsValid&&g()},K=({disabled:$,name:Y})=>{(Gr($)&&i.mount||$||l.disabled.has(Y))&&($?l.disabled.add(Y):l.disabled.delete(Y))},q=($,Y={})=>{let H=qe(r,$);const ce=Gr(Y.disabled)||Gr(t.disabled);return Gt(r,$,{...H||{},_f:{...H&&H._f?H._f:{ref:{name:$}},name:$,mount:!0,...Y}}),l.mount.add($),H?K({disabled:Gr(Y.disabled)?Y.disabled:t.disabled,name:$}):S($,!0,Y.value),{...ce?{disabled:Y.disabled||t.disabled}:{},...t.progressive?{required:!!Y.required,min:ba(Y.min),max:ba(Y.max),minLength:ba(Y.minLength),maxLength:ba(Y.maxLength),pattern:ba(Y.pattern)}:{},name:$,onChange:z,onBlur:z,ref:ue=>{if(ue){q($,Y),H=qe(r,$);const ae=dn(ue.value)&&ue.querySelectorAll&&ue.querySelectorAll("input,select,textarea")[0]||ue,pe=HE(ae),Te=H._f.refs||[];if(pe?Te.find(Ae=>Ae===ae):ae===H._f.ref)return;Gt(r,$,{_f:{...H._f,...pe?{refs:[...Te.filter(ru),ae,...Array.isArray(qe(o,$))?[{}]:[]],ref:{type:ae.type,name:$}}:{ref:ae}}}),S($,!1,void 0,ae)}else H=qe(r,$,{}),H._f&&(H._f.mount=!1),(t.shouldUnregister||Y.shouldUnregister)&&!($E(l.array,$)&&i.action)&&l.unMount.add($)}}},ne=()=>t.shouldFocusError&&Oa(r,F,l.mount),de=$=>{Gr($)&&(m.state.next({disabled:$}),Oa(r,(Y,H)=>{const ce=qe(r,H);ce&&(Y.disabled=ce._f.disabled||$,Array.isArray(ce._f.refs)&&ce._f.refs.forEach(ue=>{ue.disabled=ce._f.disabled||$}))},0,!1))},se=($,Y)=>async H=>{let ce;H&&(H.preventDefault&&H.preventDefault(),H.persist&&H.persist());let ue=En(a);if(m.state.next({isSubmitting:!0}),t.resolver){const{errors:ae,values:pe}=await j();n.errors=ae,ue=En(pe)}else await P(r);if(l.disabled.size)for(const ae of l.disabled)gn(ue,ae);if(gn(n.errors,"root"),Xn(n.errors)){m.state.next({errors:{}});try{await $(ue,H)}catch(ae){ce=ae}}else Y&&await Y({...n.errors},H),ne(),setTimeout(ne);if(m.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:Xn(n.errors)&&!ce,submitCount:n.submitCount+1,errors:n.errors}),ce)throw ce},me=($,Y={})=>{qe(r,$)&&(dn(Y.defaultValue)?R($,En(qe(o,$))):(R($,Y.defaultValue),Gt(o,$,En(Y.defaultValue))),Y.keepTouched||gn(n.touchedFields,$),Y.keepDirty||(gn(n.dirtyFields,$),n.isDirty=Y.defaultValue?B($,En(qe(o,$))):B()),Y.keepError||(gn(n.errors,$),f.isValid&&g()),m.state.next({...n}))},k=($,Y={})=>{const H=$?En($):o,ce=En(H),ue=Xn($),ae=ue?o:ce;if(Y.keepDefaultValues||(o=H),!Y.keepValues){if(Y.keepDirtyValues){const pe=new Set([...l.mount,...Object.keys(Is(o,a))]);for(const Te of Array.from(pe))qe(n.dirtyFields,Te)?Gt(ae,Te,qe(a,Te)):R(Te,qe(ae,Te))}else{if(Af&&dn($))for(const pe of l.mount){const Te=qe(r,pe);if(Te&&Te._f){const Ae=Array.isArray(Te._f.refs)?Te._f.refs[0]:Te._f.ref;if(El(Ae)){const gt=Ae.closest("form");if(gt){gt.reset();break}}}}if(Y.keepFieldsRef)for(const pe of l.mount)R(pe,qe(ae,pe));else r={}}a=t.shouldUnregister?Y.keepDefaultValues?En(o):{}:En(ae),m.array.next({values:{...ae}}),m.state.next({values:{...ae}})}l={mount:Y.keepDirtyValues?l.mount:new Set,unMount:new Set,array:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:""},i.mount=!f.isValid||!!Y.keepIsValid||!!Y.keepDirtyValues,i.watch=!!t.shouldUnregister,m.state.next({submitCount:Y.keepSubmitCount?n.submitCount:0,isDirty:ue?!1:Y.keepDirty?n.isDirty:!!(Y.keepDefaultValues&&!Ao($,o)),isSubmitted:Y.keepIsSubmitted?n.isSubmitted:!1,dirtyFields:ue?{}:Y.keepDirtyValues?Y.keepDefaultValues&&a?Is(o,a):n.dirtyFields:Y.keepDefaultValues&&$?Is(o,$):Y.keepDirty?n.dirtyFields:{},touchedFields:Y.keepTouched?n.touchedFields:{},errors:Y.keepErrors?n.errors:{},isSubmitSuccessful:Y.keepIsSubmitSuccessful?n.isSubmitSuccessful:!1,isSubmitting:!1,defaultValues:o})},oe=($,Y)=>k(Ar($)?$(a):$,Y),ie=($,Y={})=>{const H=qe(r,$),ce=H&&H._f;if(ce){const ue=ce.refs?ce.refs[0]:ce.ref;ue.focus&&(ue.focus(),Y.shouldSelect&&Ar(ue.select)&&ue.select())}},Z=$=>{n={...n,...$}},re={control:{register:q,unregister:X,getFieldState:L,handleSubmit:se,setError:W,_subscribe:V,_runSchema:j,_focusError:ne,_getWatch:N,_getDirty:B,_setValid:g,_setFieldArray:v,_setDisabledField:K,_setErrors:C,_getFieldArray:M,_reset:k,_resetDefaultValues:()=>Ar(t.defaultValues)&&t.defaultValues().then($=>{oe($,t.resetOptions),m.state.next({isLoading:!1})}),_removeUnmounted:O,_disableForm:de,_subjects:m,_proxyFormState:f,get _fields(){return r},get _formValues(){return a},get _state(){return i},set _state($){i=$},get _defaultValues(){return o},get _names(){return l},set _names($){l=$},get _formState(){return n},get _options(){return t},set _options($){t={...t,...$}}},subscribe:Q,trigger:I,register:q,handleSubmit:se,watch:G,setValue:R,getValues:J,reset:oe,resetField:me,clearErrors:D,unregister:X,setError:W,setFocus:ie,getFieldState:L};return{...re,formControl:re}}function sj(e={}){const t=Rt.useRef(void 0),n=Rt.useRef(void 0),[r,o]=Rt.useState({isDirty:!1,isValidating:!1,isLoading:Ar(e.defaultValues),isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,submitCount:0,dirtyFields:{},touchedFields:{},validatingFields:{},errors:e.errors||{},disabled:e.disabled||!1,isReady:!1,defaultValues:Ar(e.defaultValues)?void 0:e.defaultValues});if(!t.current)if(e.formControl)t.current={...e.formControl,formState:r},e.defaultValues&&!Ar(e.defaultValues)&&e.formControl.reset(e.defaultValues,e.resetOptions);else{const{formControl:i,...l}=oj(e);t.current={...l,formState:r}}const a=t.current.control;return a._options=e,VE(()=>{const i=a._subscribe({formState:a._proxyFormState,callback:()=>o({...a._formState}),reRenderRoot:!0});return o(l=>({...l,isReady:!0})),a._formState.isReady=!0,i},[a]),Rt.useEffect(()=>a._disableForm(e.disabled),[a,e.disabled]),Rt.useEffect(()=>{e.mode&&(a._options.mode=e.mode),e.reValidateMode&&(a._options.reValidateMode=e.reValidateMode)},[a,e.mode,e.reValidateMode]),Rt.useEffect(()=>{e.errors&&(a._setErrors(e.errors),a._focusError())},[a,e.errors]),Rt.useEffect(()=>{e.shouldUnregister&&a._subjects.state.next({values:a._getWatch()})},[a,e.shouldUnregister]),Rt.useEffect(()=>{if(a._proxyFormState.isDirty){const i=a._getDirty();i!==r.isDirty&&a._subjects.state.next({isDirty:i})}},[a,r.isDirty]),Rt.useEffect(()=>{e.values&&!Ao(e.values,n.current)?(a._reset(e.values,{keepFieldsRef:!0,...a._options.resetOptions}),n.current=e.values,o(i=>({...i}))):a._resetDefaultValues()},[a,e.values]),Rt.useEffect(()=>{a._state.mount||(a._setValid(),a._state.mount=!0),a._state.watch&&(a._state.watch=!1,a._subjects.state.next({...a._formState})),a._removeUnmounted()}),t.current.formState=BE(r,a),t.current}d.createContext({});d.createContext({});const aj=Uo("flex-col items-center justify-center",{variants:{show:{true:"flex",false:"hidden"}},defaultVariants:{show:!0}}),ij=Uo("animate-spin",{variants:{size:{small:"size-4",medium:"size-8",large:"size-12"},variant:{primary:"text-[var(--color-brand-wMain)]",secondary:"text-[var(--color-primary-wMain)]",muted:"text-[var(--color-secondary-text-wMain)] dark:text-[var(--color-secondary-text-w50)]",foreground:"text-foreground"}},defaultVariants:{size:"medium",variant:"primary"}});function no({size:e,show:t,children:n,className:r,variant:o}){return s.jsxs("span",{className:aj({show:t}),children:[s.jsx(fr,{className:ze(ij({size:e,variant:o}),r)}),n]})}var ou="focusScope.autoFocusOnMount",su="focusScope.autoFocusOnUnmount",Vp={bubbles:!1,cancelable:!0},lj="FocusScope",ci=d.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:a,...i}=e,[l,c]=d.useState(null),u=Mn(o),f=Mn(a),h=d.useRef(null),m=mt(t,g=>c(g)),p=d.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;d.useEffect(()=>{if(r){let g=function(C){if(p.paused||!l)return;const S=C.target;l.contains(S)?h.current=S:jo(h.current,{select:!0})},w=function(C){if(p.paused||!l)return;const S=C.relatedTarget;S!==null&&(l.contains(S)||jo(h.current,{select:!0}))},v=function(C){if(document.activeElement===document.body)for(const E of C)E.removedNodes.length>0&&jo(l)};document.addEventListener("focusin",g),document.addEventListener("focusout",w);const b=new MutationObserver(v);return l&&b.observe(l,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",g),document.removeEventListener("focusout",w),b.disconnect()}}},[r,l,p.paused]),d.useEffect(()=>{if(l){Hp.add(p);const g=document.activeElement;if(!l.contains(g)){const v=new CustomEvent(ou,Vp);l.addEventListener(ou,u),l.dispatchEvent(v),v.defaultPrevented||(cj(pj(Tv(l)),{select:!0}),document.activeElement===g&&jo(l))}return()=>{l.removeEventListener(ou,u),setTimeout(()=>{const v=new CustomEvent(su,Vp);l.addEventListener(su,f),l.dispatchEvent(v),v.defaultPrevented||jo(g??document.body,{select:!0}),l.removeEventListener(su,f),Hp.remove(p)},0)}}},[l,u,f,p]);const x=d.useCallback(g=>{if(!n&&!r||p.paused)return;const w=g.key==="Tab"&&!g.altKey&&!g.ctrlKey&&!g.metaKey,v=document.activeElement;if(w&&v){const b=g.currentTarget,[C,S]=uj(b);C&&S?!g.shiftKey&&v===S?(g.preventDefault(),n&&jo(C,{select:!0})):g.shiftKey&&v===C&&(g.preventDefault(),n&&jo(S,{select:!0})):v===b&&g.preventDefault()}},[n,r,p.paused]);return s.jsx(rt.div,{tabIndex:-1,...i,ref:m,onKeyDown:x})});ci.displayName=lj;function cj(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(jo(r,{select:t}),document.activeElement!==n)return}function uj(e){const t=Tv(e),n=Wp(t,e),r=Wp(t.reverse(),e);return[n,r]}function Tv(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const o=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||o?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function Wp(e,t){for(const n of e)if(!dj(n,{upTo:t}))return n}function dj(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function fj(e){return e instanceof HTMLInputElement&&"select"in e}function jo(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&fj(e)&&t&&e.select()}}var Hp=hj();function hj(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=Zp(e,t),e.unshift(t)},remove(t){var n;e=Zp(e,t),(n=e[0])==null||n.resume()}}}function Zp(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function pj(e){return e.filter(t=>t.tagName!=="A")}var au=0;function Av(){d.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??Gp()),document.body.insertAdjacentElement("beforeend",e[1]??Gp()),au++,()=>{au===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),au--}},[])}function Gp(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var Kr=function(){return Kr=Object.assign||function(t){for(var n,r=1,o=arguments.length;r<o;r++){n=arguments[r];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(t[a]=n[a])}return t},Kr.apply(this,arguments)};function Iv(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]]);return n}function mj(e,t,n){if(n||arguments.length===2)for(var r=0,o=t.length,a;r<o;r++)(a||!(r in t))&&(a||(a=Array.prototype.slice.call(t,0,r)),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))}var ul="right-scroll-bar-position",dl="width-before-scroll-bar",gj="with-scroll-bars-hidden",xj="--removed-body-scroll-bar-size";function iu(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function vj(e,t){var n=d.useState(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(r){var o=n.value;o!==r&&(n.value=r,n.callback(r,o))}}}})[0];return n.callback=t,n.facade}var wj=typeof window<"u"?d.useLayoutEffect:d.useEffect,Yp=new WeakMap;function bj(e,t){var n=vj(null,function(r){return e.forEach(function(o){return iu(o,r)})});return wj(function(){var r=Yp.get(n);if(r){var o=new Set(r),a=new Set(e),i=n.current;o.forEach(function(l){a.has(l)||iu(l,null)}),a.forEach(function(l){o.has(l)||iu(l,i)})}Yp.set(n,e)},[e]),n}function yj(e){return e}function Cj(e,t){t===void 0&&(t=yj);var n=[],r=!1,o={read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(a){var i=t(a,r);return n.push(i),function(){n=n.filter(function(l){return l!==i})}},assignSyncMedium:function(a){for(r=!0;n.length;){var i=n;n=[],i.forEach(a)}n={push:function(l){return a(l)},filter:function(){return n}}},assignMedium:function(a){r=!0;var i=[];if(n.length){var l=n;n=[],l.forEach(a),i=n}var c=function(){var f=i;i=[],f.forEach(a)},u=function(){return Promise.resolve().then(c)};u(),n={push:function(f){i.push(f),u()},filter:function(f){return i=i.filter(f),n}}}};return o}function Sj(e){e===void 0&&(e={});var t=Cj(null);return t.options=Kr({async:!0,ssr:!1},e),t}var Rv=function(e){var t=e.sideCar,n=Iv(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw new Error("Sidecar medium not found");return d.createElement(r,Kr({},n))};Rv.isSideCarExport=!0;function _j(e,t){return e.useMedium(t),Rv}var Pv=Sj(),lu=function(){},dc=d.forwardRef(function(e,t){var n=d.useRef(null),r=d.useState({onScrollCapture:lu,onWheelCapture:lu,onTouchMoveCapture:lu}),o=r[0],a=r[1],i=e.forwardProps,l=e.children,c=e.className,u=e.removeScrollBar,f=e.enabled,h=e.shards,m=e.sideCar,p=e.noRelative,x=e.noIsolation,g=e.inert,w=e.allowPinchZoom,v=e.as,b=v===void 0?"div":v,C=e.gapMode,S=Iv(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),E=m,_=bj([n,t]),j=Kr(Kr({},S),o);return d.createElement(d.Fragment,null,f&&d.createElement(E,{sideCar:Pv,removeScrollBar:u,shards:h,noRelative:p,noIsolation:x,inert:g,setCallbacks:a,allowPinchZoom:!!w,lockRef:n,gapMode:C}),i?d.cloneElement(d.Children.only(l),Kr(Kr({},j),{ref:_})):d.createElement(b,Kr({},j,{className:c,ref:_}),l))});dc.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};dc.classNames={fullWidth:dl,zeroRight:ul};var kj=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function Ej(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=kj();return t&&e.setAttribute("nonce",t),e}function jj(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function Nj(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var Tj=function(){var e=0,t=null;return{add:function(n){e==0&&(t=Ej())&&(jj(t,n),Nj(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},Aj=function(){var e=Tj();return function(t,n){d.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},Mv=function(){var e=Aj(),t=function(n){var r=n.styles,o=n.dynamic;return e(r,o),null};return t},Ij={left:0,top:0,right:0,gap:0},cu=function(e){return parseInt(e||"",10)||0},Rj=function(e){var t=window.getComputedStyle(document.body),n=t[e==="padding"?"paddingLeft":"marginLeft"],r=t[e==="padding"?"paddingTop":"marginTop"],o=t[e==="padding"?"paddingRight":"marginRight"];return[cu(n),cu(r),cu(o)]},Pj=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return Ij;var t=Rj(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},Mj=Mv(),Bs="data-scroll-locked",Dj=function(e,t,n,r){var o=e.left,a=e.top,i=e.right,l=e.gap;return n===void 0&&(n="margin"),`
89
+ .`.concat(gj,` {
90
+ overflow: hidden `).concat(r,`;
91
+ padding-right: `).concat(l,"px ").concat(r,`;
92
+ }
93
+ body[`).concat(Bs,`] {
94
+ overflow: hidden `).concat(r,`;
95
+ overscroll-behavior: contain;
96
+ `).concat([t&&"position: relative ".concat(r,";"),n==="margin"&&`
97
+ padding-left: `.concat(o,`px;
98
+ padding-top: `).concat(a,`px;
99
+ padding-right: `).concat(i,`px;
100
+ margin-left:0;
101
+ margin-top:0;
102
+ margin-right: `).concat(l,"px ").concat(r,`;
103
+ `),n==="padding"&&"padding-right: ".concat(l,"px ").concat(r,";")].filter(Boolean).join(""),`
104
+ }
105
+
106
+ .`).concat(ul,` {
107
+ right: `).concat(l,"px ").concat(r,`;
108
+ }
109
+
110
+ .`).concat(dl,` {
111
+ margin-right: `).concat(l,"px ").concat(r,`;
112
+ }
113
+
114
+ .`).concat(ul," .").concat(ul,` {
115
+ right: 0 `).concat(r,`;
116
+ }
117
+
118
+ .`).concat(dl," .").concat(dl,` {
119
+ margin-right: 0 `).concat(r,`;
120
+ }
121
+
122
+ body[`).concat(Bs,`] {
123
+ `).concat(xj,": ").concat(l,`px;
124
+ }
125
+ `)},Kp=function(){var e=parseInt(document.body.getAttribute(Bs)||"0",10);return isFinite(e)?e:0},Oj=function(){d.useEffect(function(){return document.body.setAttribute(Bs,(Kp()+1).toString()),function(){var e=Kp()-1;e<=0?document.body.removeAttribute(Bs):document.body.setAttribute(Bs,e.toString())}},[])},Lj=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,o=r===void 0?"margin":r;Oj();var a=d.useMemo(function(){return Pj(o)},[o]);return d.createElement(Mj,{styles:Dj(a,!t,o,n?"":"!important")})},ld=!1;if(typeof window<"u")try{var Oi=Object.defineProperty({},"passive",{get:function(){return ld=!0,!0}});window.addEventListener("test",Oi,Oi),window.removeEventListener("test",Oi,Oi)}catch{ld=!1}var _s=ld?{passive:!1}:!1,Fj=function(e){return e.tagName==="TEXTAREA"},Dv=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!Fj(e)&&n[t]==="visible")},$j=function(e){return Dv(e,"overflowY")},zj=function(e){return Dv(e,"overflowX")},qp=function(e,t){var n=t.ownerDocument,r=t;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var o=Ov(e,r);if(o){var a=Lv(e,r),i=a[1],l=a[2];if(i>l)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},Uj=function(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;return[t,n,r]},Bj=function(e){var t=e.scrollLeft,n=e.scrollWidth,r=e.clientWidth;return[t,n,r]},Ov=function(e,t){return e==="v"?$j(t):zj(t)},Lv=function(e,t){return e==="v"?Uj(t):Bj(t)},Vj=function(e,t){return e==="h"&&t==="rtl"?-1:1},Wj=function(e,t,n,r,o){var a=Vj(e,window.getComputedStyle(t).direction),i=a*r,l=n.target,c=t.contains(l),u=!1,f=i>0,h=0,m=0;do{if(!l)break;var p=Lv(e,l),x=p[0],g=p[1],w=p[2],v=g-w-a*x;(x||v)&&Ov(e,l)&&(h+=v,m+=x);var b=l.parentNode;l=b&&b.nodeType===Node.DOCUMENT_FRAGMENT_NODE?b.host:b}while(!c&&l!==document.body||c&&(t.contains(l)||t===l));return(f&&Math.abs(h)<1||!f&&Math.abs(m)<1)&&(u=!0),u},Li=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},Xp=function(e){return[e.deltaX,e.deltaY]},Jp=function(e){return e&&"current"in e?e.current:e},Hj=function(e,t){return e[0]===t[0]&&e[1]===t[1]},Zj=function(e){return`
126
+ .block-interactivity-`.concat(e,` {pointer-events: none;}
127
+ .allow-interactivity-`).concat(e,` {pointer-events: all;}
128
+ `)},Gj=0,ks=[];function Yj(e){var t=d.useRef([]),n=d.useRef([0,0]),r=d.useRef(),o=d.useState(Gj++)[0],a=d.useState(Mv)[0],i=d.useRef(e);d.useEffect(function(){i.current=e},[e]),d.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(o));var g=mj([e.lockRef.current],(e.shards||[]).map(Jp),!0).filter(Boolean);return g.forEach(function(w){return w.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),g.forEach(function(w){return w.classList.remove("allow-interactivity-".concat(o))})}}},[e.inert,e.lockRef.current,e.shards]);var l=d.useCallback(function(g,w){if("touches"in g&&g.touches.length===2||g.type==="wheel"&&g.ctrlKey)return!i.current.allowPinchZoom;var v=Li(g),b=n.current,C="deltaX"in g?g.deltaX:b[0]-v[0],S="deltaY"in g?g.deltaY:b[1]-v[1],E,_=g.target,j=Math.abs(C)>Math.abs(S)?"h":"v";if("touches"in g&&j==="h"&&_.type==="range")return!1;var A=qp(j,_);if(!A)return!0;if(A?E=j:(E=j==="v"?"h":"v",A=qp(j,_)),!A)return!1;if(!r.current&&"changedTouches"in g&&(C||S)&&(r.current=E),!E)return!0;var P=r.current||E;return Wj(P,w,g,P==="h"?C:S)},[]),c=d.useCallback(function(g){var w=g;if(!(!ks.length||ks[ks.length-1]!==a)){var v="deltaY"in w?Xp(w):Li(w),b=t.current.filter(function(E){return E.name===w.type&&(E.target===w.target||w.target===E.shadowParent)&&Hj(E.delta,v)})[0];if(b&&b.should){w.cancelable&&w.preventDefault();return}if(!b){var C=(i.current.shards||[]).map(Jp).filter(Boolean).filter(function(E){return E.contains(w.target)}),S=C.length>0?l(w,C[0]):!i.current.noIsolation;S&&w.cancelable&&w.preventDefault()}}},[]),u=d.useCallback(function(g,w,v,b){var C={name:g,delta:w,target:v,should:b,shadowParent:Kj(v)};t.current.push(C),setTimeout(function(){t.current=t.current.filter(function(S){return S!==C})},1)},[]),f=d.useCallback(function(g){n.current=Li(g),r.current=void 0},[]),h=d.useCallback(function(g){u(g.type,Xp(g),g.target,l(g,e.lockRef.current))},[]),m=d.useCallback(function(g){u(g.type,Li(g),g.target,l(g,e.lockRef.current))},[]);d.useEffect(function(){return ks.push(a),e.setCallbacks({onScrollCapture:h,onWheelCapture:h,onTouchMoveCapture:m}),document.addEventListener("wheel",c,_s),document.addEventListener("touchmove",c,_s),document.addEventListener("touchstart",f,_s),function(){ks=ks.filter(function(g){return g!==a}),document.removeEventListener("wheel",c,_s),document.removeEventListener("touchmove",c,_s),document.removeEventListener("touchstart",f,_s)}},[]);var p=e.removeScrollBar,x=e.inert;return d.createElement(d.Fragment,null,x?d.createElement(a,{styles:Zj(o)}):null,p?d.createElement(Lj,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function Kj(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const qj=_j(Pv,Yj);var ui=d.forwardRef(function(e,t){return d.createElement(dc,Kr({},e,{ref:t,sideCar:qj}))});ui.classNames=dc.classNames;var Xj=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},Es=new WeakMap,Fi=new WeakMap,$i={},uu=0,Fv=function(e){return e&&(e.host||Fv(e.parentNode))},Jj=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=Fv(n);return r&&e.contains(r)?r:(console.error("aria-hidden",n,"in not contained inside",e,". Doing nothing"),null)}).filter(function(n){return!!n})},Qj=function(e,t,n,r){var o=Jj(t,Array.isArray(e)?e:[e]);$i[n]||($i[n]=new WeakMap);var a=$i[n],i=[],l=new Set,c=new Set(o),u=function(h){!h||l.has(h)||(l.add(h),u(h.parentNode))};o.forEach(u);var f=function(h){!h||c.has(h)||Array.prototype.forEach.call(h.children,function(m){if(l.has(m))f(m);else try{var p=m.getAttribute(r),x=p!==null&&p!=="false",g=(Es.get(m)||0)+1,w=(a.get(m)||0)+1;Es.set(m,g),a.set(m,w),i.push(m),g===1&&x&&Fi.set(m,!0),w===1&&m.setAttribute(n,"true"),x||m.setAttribute(r,"true")}catch(v){console.error("aria-hidden: cannot operate on ",m,v)}})};return f(t),l.clear(),uu++,function(){i.forEach(function(h){var m=Es.get(h)-1,p=a.get(h)-1;Es.set(h,m),a.set(h,p),m||(Fi.has(h)||h.removeAttribute(r),Fi.delete(h)),p||h.removeAttribute(n)}),uu--,uu||(Es=new WeakMap,Es=new WeakMap,Fi=new WeakMap,$i={})}},fc=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),o=Xj(e);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live], script"))),Qj(r,o,n,"aria-hidden")):function(){return null}},hc="Dialog",[$v,_9]=mr(hc),[eN,Hr]=$v(hc),zv=e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:o,onOpenChange:a,modal:i=!0}=e,l=d.useRef(null),c=d.useRef(null),[u,f]=xo({prop:r,defaultProp:o??!1,onChange:a,caller:hc});return s.jsx(eN,{scope:t,triggerRef:l,contentRef:c,contentId:hr(),titleId:hr(),descriptionId:hr(),open:u,onOpenChange:f,onOpenToggle:d.useCallback(()=>f(h=>!h),[f]),modal:i,children:n})};zv.displayName=hc;var Uv="DialogTrigger",Bv=d.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Hr(Uv,n),a=mt(t,o.triggerRef);return s.jsx(rt.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":Ff(o.open),...r,ref:a,onClick:Ht(e.onClick,o.onOpenToggle)})});Bv.displayName=Uv;var Of="DialogPortal",[tN,Vv]=$v(Of,{forceMount:void 0}),Wv=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:o}=e,a=Hr(Of,t);return s.jsx(tN,{scope:t,forceMount:n,children:d.Children.map(r,i=>s.jsx(_o,{present:n||a.open,children:s.jsx(pa,{asChild:!0,container:o,children:i})}))})};Wv.displayName=Of;var Nl="DialogOverlay",Hv=d.forwardRef((e,t)=>{const n=Vv(Nl,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,a=Hr(Nl,e.__scopeDialog);return a.modal?s.jsx(_o,{present:r||a.open,children:s.jsx(rN,{...o,ref:t})}):null});Hv.displayName=Nl;var nN=Oo("DialogOverlay.RemoveScroll"),rN=d.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Hr(Nl,n);return s.jsx(ui,{as:nN,allowPinchZoom:!0,shards:[o.contentRef],children:s.jsx(rt.div,{"data-state":Ff(o.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),ss="DialogContent",Zv=d.forwardRef((e,t)=>{const n=Vv(ss,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,a=Hr(ss,e.__scopeDialog);return s.jsx(_o,{present:r||a.open,children:a.modal?s.jsx(oN,{...o,ref:t}):s.jsx(sN,{...o,ref:t})})});Zv.displayName=ss;var oN=d.forwardRef((e,t)=>{const n=Hr(ss,e.__scopeDialog),r=d.useRef(null),o=mt(t,n.contentRef,r);return d.useEffect(()=>{const a=r.current;if(a)return fc(a)},[]),s.jsx(Gv,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Ht(e.onCloseAutoFocus,a=>{var i;a.preventDefault(),(i=n.triggerRef.current)==null||i.focus()}),onPointerDownOutside:Ht(e.onPointerDownOutside,a=>{const i=a.detail.originalEvent,l=i.button===0&&i.ctrlKey===!0;(i.button===2||l)&&a.preventDefault()}),onFocusOutside:Ht(e.onFocusOutside,a=>a.preventDefault())})}),sN=d.forwardRef((e,t)=>{const n=Hr(ss,e.__scopeDialog),r=d.useRef(!1),o=d.useRef(!1);return s.jsx(Gv,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:a=>{var i,l;(i=e.onCloseAutoFocus)==null||i.call(e,a),a.defaultPrevented||(r.current||(l=n.triggerRef.current)==null||l.focus(),a.preventDefault()),r.current=!1,o.current=!1},onInteractOutside:a=>{var c,u;(c=e.onInteractOutside)==null||c.call(e,a),a.defaultPrevented||(r.current=!0,a.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const i=a.target;((u=n.triggerRef.current)==null?void 0:u.contains(i))&&a.preventDefault(),a.detail.originalEvent.type==="focusin"&&o.current&&a.preventDefault()}})}),Gv=d.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:a,...i}=e,l=Hr(ss,n),c=d.useRef(null),u=mt(t,c);return Av(),s.jsxs(s.Fragment,{children:[s.jsx(ci,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:a,children:s.jsx(tc,{role:"dialog",id:l.contentId,"aria-describedby":l.descriptionId,"aria-labelledby":l.titleId,"data-state":Ff(l.open),...i,ref:u,onDismiss:()=>l.onOpenChange(!1)})}),s.jsxs(s.Fragment,{children:[s.jsx(aN,{titleId:l.titleId}),s.jsx(lN,{contentRef:c,descriptionId:l.descriptionId})]})]})}),Lf="DialogTitle",Yv=d.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Hr(Lf,n);return s.jsx(rt.h2,{id:o.titleId,...r,ref:t})});Yv.displayName=Lf;var Kv="DialogDescription",qv=d.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Hr(Kv,n);return s.jsx(rt.p,{id:o.descriptionId,...r,ref:t})});qv.displayName=Kv;var Xv="DialogClose",Jv=d.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Hr(Xv,n);return s.jsx(rt.button,{type:"button",...r,ref:t,onClick:Ht(e.onClick,()=>o.onOpenChange(!1))})});Jv.displayName=Xv;function Ff(e){return e?"open":"closed"}var Qv="DialogTitleWarning",[k9,ew]=Ik(Qv,{contentName:ss,titleName:Lf,docsSlug:"dialog"}),aN=({titleId:e})=>{const t=ew(Qv),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
129
+
130
+ If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
131
+
132
+ For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return d.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},iN="DialogDescriptionWarning",lN=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${ew(iN).contentName}}.`;return d.useEffect(()=>{var a;const o=(a=e.current)==null?void 0:a.getAttribute("aria-describedby");t&&o&&(document.getElementById(t)||console.warn(r))},[r,e,t]),null},cN=zv,uN=Bv,dN=Wv,fN=Hv,hN=Zv,pN=Yv,mN=qv,tw=Jv;function On({...e}){return s.jsx(cN,{"data-slot":"dialog",...e})}function cd({...e}){return s.jsx(uN,{"data-slot":"dialog-trigger",...e})}function gN({...e}){return s.jsx(dN,{"data-slot":"dialog-portal",...e})}function nw({...e}){return s.jsx(tw,{"data-slot":"dialog-close",...e})}function xN({className:e,...t}){return s.jsx(fN,{"data-slot":"dialog-overlay",className:ze("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",e),...t})}function Ln({className:e,children:t,showCloseButton:n=!1,...r}){return s.jsxs(gN,{"data-slot":"dialog-portal",children:[s.jsx(xN,{}),s.jsxs(hN,{"data-slot":"dialog-content",className:ze("bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] rounded-sm border p-6 shadow-lg duration-200 sm:max-w-lg",e),...r,children:[t,n&&s.jsxs(tw,{"data-slot":"dialog-close",className:"ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",children:[s.jsx(po,{}),s.jsx("span",{className:"sr-only",children:"Close"})]})]})]})}function Gn({className:e,...t}){return s.jsx("div",{"data-slot":"dialog-header",className:ze("flex flex-col gap-6 text-center sm:text-left",e),...t})}function nr({className:e,...t}){return s.jsx("div",{"data-slot":"dialog-footer",className:ze("mt-6 flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",e),...t})}function Fn({className:e,...t}){return s.jsx(pN,{"data-slot":"dialog-title",className:ze("text-lg leading-none font-semibold",e),...t})}function Yn({className:e,...t}){return s.jsx(mN,{"data-slot":"dialog-description",className:ze(e),...t})}const pc=d.createContext(null);pc.displayName="PanelGroupContext";const sn={group:"data-panel-group",groupDirection:"data-panel-group-direction",groupId:"data-panel-group-id",panel:"data-panel",panelCollapsible:"data-panel-collapsible",panelId:"data-panel-id",panelSize:"data-panel-size",resizeHandle:"data-resize-handle",resizeHandleActive:"data-resize-handle-active",resizeHandleEnabled:"data-panel-resize-handle-enabled",resizeHandleId:"data-panel-resize-handle-id",resizeHandleState:"data-resize-handle-state"},$f=10,Qo=d.useLayoutEffect,Qp=Bd.useId,vN=typeof Qp=="function"?Qp:()=>null;let wN=0;function zf(e=null){const t=vN(),n=d.useRef(e||t||null);return n.current===null&&(n.current=""+wN++),e??n.current}function rw({children:e,className:t="",collapsedSize:n,collapsible:r,defaultSize:o,forwardedRef:a,id:i,maxSize:l,minSize:c,onCollapse:u,onExpand:f,onResize:h,order:m,style:p,tagName:x="div",...g}){const w=d.useContext(pc);if(w===null)throw Error("Panel components must be rendered within a PanelGroup container");const{collapsePanel:v,expandPanel:b,getPanelSize:C,getPanelStyle:S,groupId:E,isPanelCollapsed:_,reevaluatePanelConstraints:j,registerPanel:A,resizePanel:P,unregisterPanel:O}=w,B=zf(i),N=d.useRef({callbacks:{onCollapse:u,onExpand:f,onResize:h},constraints:{collapsedSize:n,collapsible:r,defaultSize:o,maxSize:l,minSize:c},id:B,idIsFromProps:i!==void 0,order:m});d.useRef({didLogMissingDefaultSizeWarning:!1}),Qo(()=>{const{callbacks:y,constraints:T}=N.current,R={...T};N.current.id=B,N.current.idIsFromProps=i!==void 0,N.current.order=m,y.onCollapse=u,y.onExpand=f,y.onResize=h,T.collapsedSize=n,T.collapsible=r,T.defaultSize=o,T.maxSize=l,T.minSize=c,(R.collapsedSize!==T.collapsedSize||R.collapsible!==T.collapsible||R.maxSize!==T.maxSize||R.minSize!==T.minSize)&&j(N.current,R)}),Qo(()=>{const y=N.current;return A(y),()=>{O(y)}},[m,B,A,O]),d.useImperativeHandle(a,()=>({collapse:()=>{v(N.current)},expand:y=>{b(N.current,y)},getId(){return B},getSize(){return C(N.current)},isCollapsed(){return _(N.current)},isExpanded(){return!_(N.current)},resize:y=>{P(N.current,y)}}),[v,b,C,_,B,P]);const M=S(N.current,o);return d.createElement(x,{...g,children:e,className:t,id:B,style:{...M,...p},[sn.groupId]:E,[sn.panel]:"",[sn.panelCollapsible]:r||void 0,[sn.panelId]:B,[sn.panelSize]:parseFloat(""+M.flexGrow).toFixed(1)})}const ow=d.forwardRef((e,t)=>d.createElement(rw,{...e,forwardedRef:t}));rw.displayName="Panel";ow.displayName="forwardRef(Panel)";let ud=null,fl=-1,Io=null;function bN(e,t){if(t){const n=(t&cw)!==0,r=(t&uw)!==0,o=(t&dw)!==0,a=(t&fw)!==0;if(n)return o?"se-resize":a?"ne-resize":"e-resize";if(r)return o?"sw-resize":a?"nw-resize":"w-resize";if(o)return"s-resize";if(a)return"n-resize"}switch(e){case"horizontal":return"ew-resize";case"intersection":return"move";case"vertical":return"ns-resize"}}function yN(){Io!==null&&(document.head.removeChild(Io),ud=null,Io=null,fl=-1)}function du(e,t){var n,r;const o=bN(e,t);if(ud!==o){if(ud=o,Io===null&&(Io=document.createElement("style"),document.head.appendChild(Io)),fl>=0){var a;(a=Io.sheet)===null||a===void 0||a.removeRule(fl)}fl=(n=(r=Io.sheet)===null||r===void 0?void 0:r.insertRule(`*{cursor: ${o} !important;}`))!==null&&n!==void 0?n:-1}}function sw(e){return e.type==="keydown"}function aw(e){return e.type.startsWith("pointer")}function iw(e){return e.type.startsWith("mouse")}function mc(e){if(aw(e)){if(e.isPrimary)return{x:e.clientX,y:e.clientY}}else if(iw(e))return{x:e.clientX,y:e.clientY};return{x:1/0,y:1/0}}function CN(){if(typeof matchMedia=="function")return matchMedia("(pointer:coarse)").matches?"coarse":"fine"}function SN(e,t,n){return e.x<t.x+t.width&&e.x+e.width>t.x&&e.y<t.y+t.height&&e.y+e.height>t.y}function _N(e,t){if(e===t)throw new Error("Cannot compare node with itself");const n={a:nm(e),b:nm(t)};let r;for(;n.a.at(-1)===n.b.at(-1);)e=n.a.pop(),t=n.b.pop(),r=e;vt(r,"Stacking order can only be calculated for elements with a common ancestor");const o={a:tm(em(n.a)),b:tm(em(n.b))};if(o.a===o.b){const a=r.childNodes,i={a:n.a.at(-1),b:n.b.at(-1)};let l=a.length;for(;l--;){const c=a[l];if(c===i.a)return 1;if(c===i.b)return-1}}return Math.sign(o.a-o.b)}const kN=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function EN(e){var t;const n=getComputedStyle((t=lw(e))!==null&&t!==void 0?t:e).display;return n==="flex"||n==="inline-flex"}function jN(e){const t=getComputedStyle(e);return!!(t.position==="fixed"||t.zIndex!=="auto"&&(t.position!=="static"||EN(e))||+t.opacity<1||"transform"in t&&t.transform!=="none"||"webkitTransform"in t&&t.webkitTransform!=="none"||"mixBlendMode"in t&&t.mixBlendMode!=="normal"||"filter"in t&&t.filter!=="none"||"webkitFilter"in t&&t.webkitFilter!=="none"||"isolation"in t&&t.isolation==="isolate"||kN.test(t.willChange)||t.webkitOverflowScrolling==="touch")}function em(e){let t=e.length;for(;t--;){const n=e[t];if(vt(n,"Missing node"),jN(n))return n}return null}function tm(e){return e&&Number(getComputedStyle(e).zIndex)||0}function nm(e){const t=[];for(;e;)t.push(e),e=lw(e);return t}function lw(e){const{parentNode:t}=e;return t&&t instanceof ShadowRoot?t.host:t}const cw=1,uw=2,dw=4,fw=8,NN=CN()==="coarse";let Or=[],Vs=!1,Ro=new Map,gc=new Map;const Ha=new Set;function TN(e,t,n,r,o){var a;const{ownerDocument:i}=t,l={direction:n,element:t,hitAreaMargins:r,setResizeHandlerState:o},c=(a=Ro.get(i))!==null&&a!==void 0?a:0;return Ro.set(i,c+1),Ha.add(l),Tl(),function(){var f;gc.delete(e),Ha.delete(l);const h=(f=Ro.get(i))!==null&&f!==void 0?f:1;if(Ro.set(i,h-1),Tl(),h===1&&Ro.delete(i),Or.includes(l)){const m=Or.indexOf(l);m>=0&&Or.splice(m,1),Bf(),o("up",!0,null)}}}function AN(e){const{target:t}=e,{x:n,y:r}=mc(e);Vs=!0,Uf({target:t,x:n,y:r}),Tl(),Or.length>0&&(Al("down",e),e.preventDefault(),hw(t)||e.stopImmediatePropagation())}function fu(e){const{x:t,y:n}=mc(e);if(Vs&&e.buttons===0&&(Vs=!1,Al("up",e)),!Vs){const{target:r}=e;Uf({target:r,x:t,y:n})}Al("move",e),Bf(),Or.length>0&&e.preventDefault()}function hu(e){const{target:t}=e,{x:n,y:r}=mc(e);gc.clear(),Vs=!1,Or.length>0&&(e.preventDefault(),hw(t)||e.stopImmediatePropagation()),Al("up",e),Uf({target:t,x:n,y:r}),Bf(),Tl()}function hw(e){let t=e;for(;t;){if(t.hasAttribute(sn.resizeHandle))return!0;t=t.parentElement}return!1}function Uf({target:e,x:t,y:n}){Or.splice(0);let r=null;(e instanceof HTMLElement||e instanceof SVGElement)&&(r=e),Ha.forEach(o=>{const{element:a,hitAreaMargins:i}=o,l=a.getBoundingClientRect(),{bottom:c,left:u,right:f,top:h}=l,m=NN?i.coarse:i.fine;if(t>=u-m&&t<=f+m&&n>=h-m&&n<=c+m){if(r!==null&&document.contains(r)&&a!==r&&!a.contains(r)&&!r.contains(a)&&_N(r,a)>0){let x=r,g=!1;for(;x&&!x.contains(a);){if(SN(x.getBoundingClientRect(),l)){g=!0;break}x=x.parentElement}if(g)return}Or.push(o)}})}function pu(e,t){gc.set(e,t)}function Bf(){let e=!1,t=!1;Or.forEach(r=>{const{direction:o}=r;o==="horizontal"?e=!0:t=!0});let n=0;gc.forEach(r=>{n|=r}),e&&t?du("intersection",n):e?du("horizontal",n):t?du("vertical",n):yN()}let mu;function Tl(){var e;(e=mu)===null||e===void 0||e.abort(),mu=new AbortController;const t={capture:!0,signal:mu.signal};Ha.size&&(Vs?(Or.length>0&&Ro.forEach((n,r)=>{const{body:o}=r;n>0&&(o.addEventListener("contextmenu",hu,t),o.addEventListener("pointerleave",fu,t),o.addEventListener("pointermove",fu,t))}),Ro.forEach((n,r)=>{const{body:o}=r;o.addEventListener("pointerup",hu,t),o.addEventListener("pointercancel",hu,t)})):Ro.forEach((n,r)=>{const{body:o}=r;n>0&&(o.addEventListener("pointerdown",AN,t),o.addEventListener("pointermove",fu,t))}))}function Al(e,t){Ha.forEach(n=>{const{setResizeHandlerState:r}=n,o=Or.includes(n);r(e,o,t)})}function IN(){const[e,t]=d.useState(0);return d.useCallback(()=>t(n=>n+1),[])}function vt(e,t){if(!e)throw console.error(t),Error(t)}function as(e,t,n=$f){return e.toFixed(n)===t.toFixed(n)?0:e>t?1:-1}function uo(e,t,n=$f){return as(e,t,n)===0}function ir(e,t,n){return as(e,t,n)===0}function RN(e,t,n){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++){const o=e[r],a=t[r];if(!ir(o,a,n))return!1}return!0}function Ms({panelConstraints:e,panelIndex:t,size:n}){const r=e[t];vt(r!=null,`Panel constraints not found for index ${t}`);let{collapsedSize:o=0,collapsible:a,maxSize:i=100,minSize:l=0}=r;if(as(n,l)<0)if(a){const c=(o+l)/2;as(n,c)<0?n=o:n=l}else n=l;return n=Math.min(i,n),n=parseFloat(n.toFixed($f)),n}function Ta({delta:e,initialLayout:t,panelConstraints:n,pivotIndices:r,prevLayout:o,trigger:a}){if(ir(e,0))return t;const i=[...t],[l,c]=r;vt(l!=null,"Invalid first pivot index"),vt(c!=null,"Invalid second pivot index");let u=0;if(a==="keyboard"){{const h=e<0?c:l,m=n[h];vt(m,`Panel constraints not found for index ${h}`);const{collapsedSize:p=0,collapsible:x,minSize:g=0}=m;if(x){const w=t[h];if(vt(w!=null,`Previous layout not found for panel index ${h}`),ir(w,p)){const v=g-w;as(v,Math.abs(e))>0&&(e=e<0?0-v:v)}}}{const h=e<0?l:c,m=n[h];vt(m,`No panel constraints found for index ${h}`);const{collapsedSize:p=0,collapsible:x,minSize:g=0}=m;if(x){const w=t[h];if(vt(w!=null,`Previous layout not found for panel index ${h}`),ir(w,g)){const v=w-p;as(v,Math.abs(e))>0&&(e=e<0?0-v:v)}}}}{const h=e<0?1:-1;let m=e<0?c:l,p=0;for(;;){const g=t[m];vt(g!=null,`Previous layout not found for panel index ${m}`);const v=Ms({panelConstraints:n,panelIndex:m,size:100})-g;if(p+=v,m+=h,m<0||m>=n.length)break}const x=Math.min(Math.abs(e),Math.abs(p));e=e<0?0-x:x}{let m=e<0?l:c;for(;m>=0&&m<n.length;){const p=Math.abs(e)-Math.abs(u),x=t[m];vt(x!=null,`Previous layout not found for panel index ${m}`);const g=x-p,w=Ms({panelConstraints:n,panelIndex:m,size:g});if(!ir(x,w)&&(u+=x-w,i[m]=w,u.toPrecision(3).localeCompare(Math.abs(e).toPrecision(3),void 0,{numeric:!0})>=0))break;e<0?m--:m++}}if(RN(o,i))return o;{const h=e<0?c:l,m=t[h];vt(m!=null,`Previous layout not found for panel index ${h}`);const p=m+u,x=Ms({panelConstraints:n,panelIndex:h,size:p});if(i[h]=x,!ir(x,p)){let g=p-x,v=e<0?c:l;for(;v>=0&&v<n.length;){const b=i[v];vt(b!=null,`Previous layout not found for panel index ${v}`);const C=b+g,S=Ms({panelConstraints:n,panelIndex:v,size:C});if(ir(b,S)||(g-=S-b,i[v]=S),ir(g,0))break;e>0?v--:v++}}}const f=i.reduce((h,m)=>m+h,0);return ir(f,100)?i:o}function PN({layout:e,panelsArray:t,pivotIndices:n}){let r=0,o=100,a=0,i=0;const l=n[0];vt(l!=null,"No pivot index found"),t.forEach((h,m)=>{const{constraints:p}=h,{maxSize:x=100,minSize:g=0}=p;m===l?(r=g,o=x):(a+=g,i+=x)});const c=Math.min(o,100-a),u=Math.max(r,100-i),f=e[l];return{valueMax:c,valueMin:u,valueNow:f}}function Za(e,t=document){return Array.from(t.querySelectorAll(`[${sn.resizeHandleId}][data-panel-group-id="${e}"]`))}function pw(e,t,n=document){const o=Za(e,n).findIndex(a=>a.getAttribute(sn.resizeHandleId)===t);return o??null}function mw(e,t,n){const r=pw(e,t,n);return r!=null?[r,r+1]:[-1,-1]}function MN(e){return e instanceof HTMLElement?!0:typeof e=="object"&&e!==null&&"tagName"in e&&"getAttribute"in e}function gw(e,t=document){if(MN(t)&&t.dataset.panelGroupId==e)return t;const n=t.querySelector(`[data-panel-group][data-panel-group-id="${e}"]`);return n||null}function xc(e,t=document){const n=t.querySelector(`[${sn.resizeHandleId}="${e}"]`);return n||null}function DN(e,t,n,r=document){var o,a,i,l;const c=xc(t,r),u=Za(e,r),f=c?u.indexOf(c):-1,h=(o=(a=n[f])===null||a===void 0?void 0:a.id)!==null&&o!==void 0?o:null,m=(i=(l=n[f+1])===null||l===void 0?void 0:l.id)!==null&&i!==void 0?i:null;return[h,m]}function ON({committedValuesRef:e,eagerValuesRef:t,groupId:n,layout:r,panelDataArray:o,panelGroupElement:a,setLayout:i}){d.useRef({didWarnAboutMissingResizeHandle:!1}),Qo(()=>{if(!a)return;const l=Za(n,a);for(let c=0;c<o.length-1;c++){const{valueMax:u,valueMin:f,valueNow:h}=PN({layout:r,panelsArray:o,pivotIndices:[c,c+1]}),m=l[c];if(m!=null){const p=o[c];vt(p,`No panel data found for index "${c}"`),m.setAttribute("aria-controls",p.id),m.setAttribute("aria-valuemax",""+Math.round(u)),m.setAttribute("aria-valuemin",""+Math.round(f)),m.setAttribute("aria-valuenow",h!=null?""+Math.round(h):"")}}return()=>{l.forEach((c,u)=>{c.removeAttribute("aria-controls"),c.removeAttribute("aria-valuemax"),c.removeAttribute("aria-valuemin"),c.removeAttribute("aria-valuenow")})}},[n,r,o,a]),d.useEffect(()=>{if(!a)return;const l=t.current;vt(l,"Eager values not found");const{panelDataArray:c}=l,u=gw(n,a);vt(u!=null,`No group found for id "${n}"`);const f=Za(n,a);vt(f,`No resize handles found for group id "${n}"`);const h=f.map(m=>{const p=m.getAttribute(sn.resizeHandleId);vt(p,"Resize handle element has no handle id attribute");const[x,g]=DN(n,p,c,a);if(x==null||g==null)return()=>{};const w=v=>{if(!v.defaultPrevented)switch(v.key){case"Enter":{v.preventDefault();const b=c.findIndex(C=>C.id===x);if(b>=0){const C=c[b];vt(C,`No panel data found for index ${b}`);const S=r[b],{collapsedSize:E=0,collapsible:_,minSize:j=0}=C.constraints;if(S!=null&&_){const A=Ta({delta:ir(S,E)?j-E:E-S,initialLayout:r,panelConstraints:c.map(P=>P.constraints),pivotIndices:mw(n,p,a),prevLayout:r,trigger:"keyboard"});r!==A&&i(A)}}break}}};return m.addEventListener("keydown",w),()=>{m.removeEventListener("keydown",w)}});return()=>{h.forEach(m=>m())}},[a,e,t,n,r,o,i])}function rm(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function xw(e,t){const n=e==="horizontal",{x:r,y:o}=mc(t);return n?r:o}function LN(e,t,n,r,o){const a=n==="horizontal",i=xc(t,o);vt(i,`No resize handle element found for id "${t}"`);const l=i.getAttribute(sn.groupId);vt(l,"Resize handle element has no group id attribute");let{initialCursorPosition:c}=r;const u=xw(n,e),f=gw(l,o);vt(f,`No group element found for id "${l}"`);const h=f.getBoundingClientRect(),m=a?h.width:h.height;return(u-c)/m*100}function FN(e,t,n,r,o,a){if(sw(e)){const i=n==="horizontal";let l=0;e.shiftKey?l=100:o!=null?l=o:l=10;let c=0;switch(e.key){case"ArrowDown":c=i?0:l;break;case"ArrowLeft":c=i?-l:0;break;case"ArrowRight":c=i?l:0;break;case"ArrowUp":c=i?0:-l;break;case"End":c=100;break;case"Home":c=-100;break}return c}else return r==null?0:LN(e,t,n,r,a)}function $N({panelDataArray:e}){const t=Array(e.length),n=e.map(a=>a.constraints);let r=0,o=100;for(let a=0;a<e.length;a++){const i=n[a];vt(i,`Panel constraints not found for index ${a}`);const{defaultSize:l}=i;l!=null&&(r++,t[a]=l,o-=l)}for(let a=0;a<e.length;a++){const i=n[a];vt(i,`Panel constraints not found for index ${a}`);const{defaultSize:l}=i;if(l!=null)continue;const c=e.length-r,u=o/c;r++,t[a]=u,o-=u}return t}function js(e,t,n){t.forEach((r,o)=>{const a=e[o];vt(a,`Panel data not found for index ${o}`);const{callbacks:i,constraints:l,id:c}=a,{collapsedSize:u=0,collapsible:f}=l,h=n[c];if(h==null||r!==h){n[c]=r;const{onCollapse:m,onExpand:p,onResize:x}=i;x&&x(r,h),f&&(m||p)&&(p&&(h==null||uo(h,u))&&!uo(r,u)&&p(),m&&(h==null||!uo(h,u))&&uo(r,u)&&m())}})}function zi(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!=t[n])return!1;return!0}function zN({defaultSize:e,dragState:t,layout:n,panelData:r,panelIndex:o,precision:a=3}){const i=n[o];let l;return i==null?l=e!=null?e.toPrecision(a):"1":r.length===1?l="1":l=i.toPrecision(a),{flexBasis:0,flexGrow:l,flexShrink:1,overflow:"hidden",pointerEvents:t!==null?"none":void 0}}function UN(e,t=10){let n=null;return(...o)=>{n!==null&&clearTimeout(n),n=setTimeout(()=>{e(...o)},t)}}function om(e){try{if(typeof localStorage<"u")e.getItem=t=>localStorage.getItem(t),e.setItem=(t,n)=>{localStorage.setItem(t,n)};else throw new Error("localStorage not supported in this environment")}catch(t){console.error(t),e.getItem=()=>null,e.setItem=()=>{}}}function vw(e){return`react-resizable-panels:${e}`}function ww(e){return e.map(t=>{const{constraints:n,id:r,idIsFromProps:o,order:a}=t;return o?r:a?`${a}:${JSON.stringify(n)}`:JSON.stringify(n)}).sort((t,n)=>t.localeCompare(n)).join(",")}function bw(e,t){try{const n=vw(e),r=t.getItem(n);if(r){const o=JSON.parse(r);if(typeof o=="object"&&o!=null)return o}}catch{}return null}function BN(e,t,n){var r,o;const a=(r=bw(e,n))!==null&&r!==void 0?r:{},i=ww(t);return(o=a[i])!==null&&o!==void 0?o:null}function VN(e,t,n,r,o){var a;const i=vw(e),l=ww(t),c=(a=bw(e,o))!==null&&a!==void 0?a:{};c[l]={expandToSizes:Object.fromEntries(n.entries()),layout:r};try{o.setItem(i,JSON.stringify(c))}catch(u){console.error(u)}}function sm({layout:e,panelConstraints:t}){const n=[...e],r=n.reduce((a,i)=>a+i,0);if(n.length!==t.length)throw Error(`Invalid ${t.length} panel layout: ${n.map(a=>`${a}%`).join(", ")}`);if(!ir(r,100)&&n.length>0)for(let a=0;a<t.length;a++){const i=n[a];vt(i!=null,`No layout data found for index ${a}`);const l=100/r*i;n[a]=l}let o=0;for(let a=0;a<t.length;a++){const i=n[a];vt(i!=null,`No layout data found for index ${a}`);const l=Ms({panelConstraints:t,panelIndex:a,size:i});i!=l&&(o+=i-l,n[a]=l)}if(!ir(o,0))for(let a=0;a<t.length;a++){const i=n[a];vt(i!=null,`No layout data found for index ${a}`);const l=i+o,c=Ms({panelConstraints:t,panelIndex:a,size:l});if(i!==c&&(o-=c-i,n[a]=c,ir(o,0)))break}return n}const WN=100,Aa={getItem:e=>(om(Aa),Aa.getItem(e)),setItem:(e,t)=>{om(Aa),Aa.setItem(e,t)}},am={};function yw({autoSaveId:e=null,children:t,className:n="",direction:r,forwardedRef:o,id:a=null,onLayout:i=null,keyboardResizeBy:l=null,storage:c=Aa,style:u,tagName:f="div",...h}){const m=zf(a),p=d.useRef(null),[x,g]=d.useState(null),[w,v]=d.useState([]),b=IN(),C=d.useRef({}),S=d.useRef(new Map),E=d.useRef(0),_=d.useRef({autoSaveId:e,direction:r,dragState:x,id:m,keyboardResizeBy:l,onLayout:i,storage:c}),j=d.useRef({layout:w,panelDataArray:[],panelDataArrayChanged:!1});d.useRef({didLogIdAndOrderWarning:!1,didLogPanelConstraintsWarning:!1,prevPanelIds:[]}),d.useImperativeHandle(o,()=>({getId:()=>_.current.id,getLayout:()=>{const{layout:W}=j.current;return W},setLayout:W=>{const{onLayout:G}=_.current,{layout:V,panelDataArray:Q}=j.current,X=sm({layout:W,panelConstraints:Q.map(K=>K.constraints)});rm(V,X)||(v(X),j.current.layout=X,G&&G(X),js(Q,X,C.current))}}),[]),Qo(()=>{_.current.autoSaveId=e,_.current.direction=r,_.current.dragState=x,_.current.id=m,_.current.onLayout=i,_.current.storage=c}),ON({committedValuesRef:_,eagerValuesRef:j,groupId:m,layout:w,panelDataArray:j.current.panelDataArray,setLayout:v,panelGroupElement:p.current}),d.useEffect(()=>{const{panelDataArray:W}=j.current;if(e){if(w.length===0||w.length!==W.length)return;let G=am[e];G==null&&(G=UN(VN,WN),am[e]=G);const V=[...W],Q=new Map(S.current);G(e,V,Q,w,c)}},[e,w,c]),d.useEffect(()=>{});const A=d.useCallback(W=>{const{onLayout:G}=_.current,{layout:V,panelDataArray:Q}=j.current;if(W.constraints.collapsible){const X=Q.map(de=>de.constraints),{collapsedSize:K=0,panelSize:q,pivotIndices:ne}=qo(Q,W,V);if(vt(q!=null,`Panel size not found for panel "${W.id}"`),!uo(q,K)){S.current.set(W.id,q);const se=Rs(Q,W)===Q.length-1?q-K:K-q,me=Ta({delta:se,initialLayout:V,panelConstraints:X,pivotIndices:ne,prevLayout:V,trigger:"imperative-api"});zi(V,me)||(v(me),j.current.layout=me,G&&G(me),js(Q,me,C.current))}}},[]),P=d.useCallback((W,G)=>{const{onLayout:V}=_.current,{layout:Q,panelDataArray:X}=j.current;if(W.constraints.collapsible){const K=X.map(k=>k.constraints),{collapsedSize:q=0,panelSize:ne=0,minSize:de=0,pivotIndices:se}=qo(X,W,Q),me=G??de;if(uo(ne,q)){const k=S.current.get(W.id),oe=k!=null&&k>=me?k:me,Z=Rs(X,W)===X.length-1?ne-oe:oe-ne,U=Ta({delta:Z,initialLayout:Q,panelConstraints:K,pivotIndices:se,prevLayout:Q,trigger:"imperative-api"});zi(Q,U)||(v(U),j.current.layout=U,V&&V(U),js(X,U,C.current))}}},[]),O=d.useCallback(W=>{const{layout:G,panelDataArray:V}=j.current,{panelSize:Q}=qo(V,W,G);return vt(Q!=null,`Panel size not found for panel "${W.id}"`),Q},[]),B=d.useCallback((W,G)=>{const{panelDataArray:V}=j.current,Q=Rs(V,W);return zN({defaultSize:G,dragState:x,layout:w,panelData:V,panelIndex:Q})},[x,w]),N=d.useCallback(W=>{const{layout:G,panelDataArray:V}=j.current,{collapsedSize:Q=0,collapsible:X,panelSize:K}=qo(V,W,G);return vt(K!=null,`Panel size not found for panel "${W.id}"`),X===!0&&uo(K,Q)},[]),M=d.useCallback(W=>{const{layout:G,panelDataArray:V}=j.current,{collapsedSize:Q=0,collapsible:X,panelSize:K}=qo(V,W,G);return vt(K!=null,`Panel size not found for panel "${W.id}"`),!X||as(K,Q)>0},[]),y=d.useCallback(W=>{const{panelDataArray:G}=j.current;G.push(W),G.sort((V,Q)=>{const X=V.order,K=Q.order;return X==null&&K==null?0:X==null?-1:K==null?1:X-K}),j.current.panelDataArrayChanged=!0,b()},[b]);Qo(()=>{if(j.current.panelDataArrayChanged){j.current.panelDataArrayChanged=!1;const{autoSaveId:W,onLayout:G,storage:V}=_.current,{layout:Q,panelDataArray:X}=j.current;let K=null;if(W){const ne=BN(W,X,V);ne&&(S.current=new Map(Object.entries(ne.expandToSizes)),K=ne.layout)}K==null&&(K=$N({panelDataArray:X}));const q=sm({layout:K,panelConstraints:X.map(ne=>ne.constraints)});rm(Q,q)||(v(q),j.current.layout=q,G&&G(q),js(X,q,C.current))}}),Qo(()=>{const W=j.current;return()=>{W.layout=[]}},[]);const T=d.useCallback(W=>{let G=!1;const V=p.current;return V&&window.getComputedStyle(V,null).getPropertyValue("direction")==="rtl"&&(G=!0),function(X){X.preventDefault();const K=p.current;if(!K)return()=>null;const{direction:q,dragState:ne,id:de,keyboardResizeBy:se,onLayout:me}=_.current,{layout:k,panelDataArray:oe}=j.current,{initialLayout:ie}=ne??{},Z=mw(de,W,K);let U=FN(X,W,q,ne,se,K);const re=q==="horizontal";re&&G&&(U=-U);const $=oe.map(ce=>ce.constraints),Y=Ta({delta:U,initialLayout:ie??k,panelConstraints:$,pivotIndices:Z,prevLayout:k,trigger:sw(X)?"keyboard":"mouse-or-touch"}),H=!zi(k,Y);(aw(X)||iw(X))&&E.current!=U&&(E.current=U,!H&&U!==0?re?pu(W,U<0?cw:uw):pu(W,U<0?dw:fw):pu(W,0)),H&&(v(Y),j.current.layout=Y,me&&me(Y),js(oe,Y,C.current))}},[]),R=d.useCallback((W,G)=>{const{onLayout:V}=_.current,{layout:Q,panelDataArray:X}=j.current,K=X.map(k=>k.constraints),{panelSize:q,pivotIndices:ne}=qo(X,W,Q);vt(q!=null,`Panel size not found for panel "${W.id}"`);const se=Rs(X,W)===X.length-1?q-G:G-q,me=Ta({delta:se,initialLayout:Q,panelConstraints:K,pivotIndices:ne,prevLayout:Q,trigger:"imperative-api"});zi(Q,me)||(v(me),j.current.layout=me,V&&V(me),js(X,me,C.current))},[]),z=d.useCallback((W,G)=>{const{layout:V,panelDataArray:Q}=j.current,{collapsedSize:X=0,collapsible:K}=G,{collapsedSize:q=0,collapsible:ne,maxSize:de=100,minSize:se=0}=W.constraints,{panelSize:me}=qo(Q,W,V);me!=null&&(K&&ne&&uo(me,X)?uo(X,q)||R(W,q):me<se?R(W,se):me>de&&R(W,de))},[R]),F=d.useCallback((W,G)=>{const{direction:V}=_.current,{layout:Q}=j.current;if(!p.current)return;const X=xc(W,p.current);vt(X,`Drag handle element not found for id "${W}"`);const K=xw(V,G);g({dragHandleId:W,dragHandleRect:X.getBoundingClientRect(),initialCursorPosition:K,initialLayout:Q})},[]),I=d.useCallback(()=>{g(null)},[]),J=d.useCallback(W=>{const{panelDataArray:G}=j.current,V=Rs(G,W);V>=0&&(G.splice(V,1),delete C.current[W.id],j.current.panelDataArrayChanged=!0,b())},[b]),L=d.useMemo(()=>({collapsePanel:A,direction:r,dragState:x,expandPanel:P,getPanelSize:O,getPanelStyle:B,groupId:m,isPanelCollapsed:N,isPanelExpanded:M,reevaluatePanelConstraints:z,registerPanel:y,registerResizeHandle:T,resizePanel:R,startDragging:F,stopDragging:I,unregisterPanel:J,panelGroupElement:p.current}),[A,x,r,P,O,B,m,N,M,z,y,T,R,F,I,J]),D={display:"flex",flexDirection:r==="horizontal"?"row":"column",height:"100%",overflow:"hidden",width:"100%"};return d.createElement(pc.Provider,{value:L},d.createElement(f,{...h,children:t,className:n,id:a,ref:p,style:{...D,...u},[sn.group]:"",[sn.groupDirection]:r,[sn.groupId]:m}))}const Cw=d.forwardRef((e,t)=>d.createElement(yw,{...e,forwardedRef:t}));yw.displayName="PanelGroup";Cw.displayName="forwardRef(PanelGroup)";function Rs(e,t){return e.findIndex(n=>n===t||n.id===t.id)}function qo(e,t,n){const r=Rs(e,t),a=r===e.length-1?[r-1,r]:[r,r+1],i=n[r];return{...t.constraints,panelSize:i,pivotIndices:a}}function HN({disabled:e,handleId:t,resizeHandler:n,panelGroupElement:r}){d.useEffect(()=>{if(e||n==null||r==null)return;const o=xc(t,r);if(o==null)return;const a=i=>{if(!i.defaultPrevented)switch(i.key){case"ArrowDown":case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"End":case"Home":{i.preventDefault(),n(i);break}case"F6":{i.preventDefault();const l=o.getAttribute(sn.groupId);vt(l,`No group element found for id "${l}"`);const c=Za(l,r),u=pw(l,t,r);vt(u!==null,`No resize element found for id "${t}"`);const f=i.shiftKey?u>0?u-1:c.length-1:u+1<c.length?u+1:0;c[f].focus();break}}};return o.addEventListener("keydown",a),()=>{o.removeEventListener("keydown",a)}},[r,e,t,n])}function Sw({children:e=null,className:t="",disabled:n=!1,hitAreaMargins:r,id:o,onBlur:a,onClick:i,onDragging:l,onFocus:c,onPointerDown:u,onPointerUp:f,style:h={},tabIndex:m=0,tagName:p="div",...x}){var g,w;const v=d.useRef(null),b=d.useRef({onClick:i,onDragging:l,onPointerDown:u,onPointerUp:f});d.useEffect(()=>{b.current.onClick=i,b.current.onDragging=l,b.current.onPointerDown=u,b.current.onPointerUp=f});const C=d.useContext(pc);if(C===null)throw Error("PanelResizeHandle components must be rendered within a PanelGroup container");const{direction:S,groupId:E,registerResizeHandle:_,startDragging:j,stopDragging:A,panelGroupElement:P}=C,O=zf(o),[B,N]=d.useState("inactive"),[M,y]=d.useState(!1),[T,R]=d.useState(null),z=d.useRef({state:B});Qo(()=>{z.current.state=B}),d.useEffect(()=>{if(n)R(null);else{const L=_(O);R(()=>L)}},[n,O,_]);const F=(g=r==null?void 0:r.coarse)!==null&&g!==void 0?g:15,I=(w=r==null?void 0:r.fine)!==null&&w!==void 0?w:5;d.useEffect(()=>{if(n||T==null)return;const L=v.current;vt(L,"Element ref not attached");let D=!1;return TN(O,L,S,{coarse:F,fine:I},(G,V,Q)=>{if(!V){N("inactive");return}switch(G){case"down":{N("drag"),D=!1,vt(Q,'Expected event to be defined for "down" action'),j(O,Q);const{onDragging:X,onPointerDown:K}=b.current;X==null||X(!0),K==null||K();break}case"move":{const{state:X}=z.current;D=!0,X!=="drag"&&N("hover"),vt(Q,'Expected event to be defined for "move" action'),T(Q);break}case"up":{N("hover"),A();const{onClick:X,onDragging:K,onPointerUp:q}=b.current;K==null||K(!1),q==null||q(),D||X==null||X();break}}})},[F,S,n,I,_,O,T,j,A]),HN({disabled:n,handleId:O,resizeHandler:T,panelGroupElement:P});const J={touchAction:"none",userSelect:"none"};return d.createElement(p,{...x,children:e,className:t,id:o,onBlur:()=>{y(!1),a==null||a()},onFocus:()=>{y(!0),c==null||c()},ref:v,role:"separator",style:{...J,...h},tabIndex:m,[sn.groupDirection]:S,[sn.groupId]:E,[sn.resizeHandle]:"",[sn.resizeHandleActive]:B==="drag"?"pointer":M?"keyboard":void 0,[sn.resizeHandleEnabled]:!n,[sn.resizeHandleId]:O,[sn.resizeHandleState]:B})}Sw.displayName="PanelResizeHandle";function _w({className:e,...t}){return s.jsx(Cw,{"data-slot":"resizable-panel-group",className:ze("flex h-full w-full data-[panel-group-direction=vertical]:flex-col",e),...t})}function Il({className:e,...t}){return s.jsx(ow,{"data-slot":"resizable-panel",className:ze("bg-transparent",e),...t})}function kw({withHandle:e,className:t,...n}){return s.jsx(Sw,{"data-slot":"resizable-handle",className:ze("bg-border focus-visible:ring-ring relative flex w-px items-center justify-center after:absolute after:inset-y-0 after:left-1/2 after:w-1 after:-translate-x-1/2 focus-visible:ring-1 focus-visible:ring-offset-1 focus-visible:outline-hidden data-[panel-group-direction=vertical]:h-px data-[panel-group-direction=vertical]:w-full data-[panel-group-direction=vertical]:after:left-0 data-[panel-group-direction=vertical]:after:h-1 data-[panel-group-direction=vertical]:after:w-full data-[panel-group-direction=vertical]:after:translate-x-0 data-[panel-group-direction=vertical]:after:-translate-y-1/2 [&[data-panel-group-direction=vertical]>div]:rotate-90",t),...n,children:e&&s.jsx("div",{className:"bg-border z-10 flex h-4 w-3 items-center justify-center rounded-xs border",children:s.jsx(H1,{className:"size-2.5"})})})}function dd({checked:e=!1,onCheckedChange:t,disabled:n=!1,className:r}){const o=()=>{!n&&t&&t(!e)};return s.jsx("button",{type:"button",role:"switch","aria-checked":e,disabled:n,onClick:o,className:ze("peer focus-visible:ring-ring focus-visible:ring-offset-background inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50",e?"bg-primary":"bg-primary/50",r),children:s.jsx("span",{className:ze("bg-background pointer-events-none block h-5 w-5 rounded-full shadow-lg ring-0 transition-transform",e?"translate-x-5":"translate-x-0")})})}const ZN=d.forwardRef(({className:e,...t},n)=>s.jsx("ul",{ref:n,className:ze("flex flex-row items-center gap-1",e),...t}));ZN.displayName="PaginationContent";const GN=d.forwardRef(({className:e,...t},n)=>s.jsx("li",{ref:n,className:ze("",e),...t}));GN.displayName="PaginationItem";function YN({ref:e,anchorRef:t,onClickOutside:n,enabled:r=!0}){d.useEffect(()=>{if(!r)return;const o=a=>{const i=a.target,l=e.current&&!e.current.contains(i),c=t!=null&&t.current?!t.current.contains(i):!0;l&&c&&n()};return document.addEventListener("mousedown",o),()=>{document.removeEventListener("mousedown",o)}},[e,t,n,r])}function KN({onEscape:e,enabled:t=!0}){d.useEffect(()=>{if(!t)return;const n=r=>{r.key==="Escape"&&e()};return document.addEventListener("keydown",n),()=>{document.removeEventListener("keydown",n)}},[e,t])}const qN={x:0,y:0},xr=16,XN=["top-start","bottom-end","top-end"];function JN({anchorRef:e,placement:t="top-start",offset:n=qN,fallbackPlacements:r=XN}){const o=d.useCallback((c,u,f)=>{let h=0,m=0;switch(f){case"top":h=c.top-u.height-n.y,m=c.left+(c.width-u.width)/2+n.x;break;case"top-start":h=c.top-u.height-n.y,m=c.left+n.x;break;case"top-end":h=c.top-u.height-n.y,m=c.right-u.width-n.x;break;case"bottom":h=c.bottom+n.y,m=c.left+(c.width-u.width)/2+n.x;break;case"bottom-start":h=c.bottom+n.y,m=c.left+n.x;break;case"bottom-end":h=c.bottom+n.y,m=c.right-u.width-n.x;break;case"left":h=c.top+(c.height-u.height)/2+n.y,m=c.left-u.width-n.x;break;case"left-start":h=c.top+n.y,m=c.left-u.width-n.x;break;case"left-end":h=c.bottom-u.height-n.y,m=c.left-u.width-n.x;break;case"right":h=c.top+(c.height-u.height)/2+n.y,m=c.right+n.x;break;case"right-start":h=c.top+n.y,m=c.right+n.x;break;case"right-end":h=c.bottom-u.height-n.y,m=c.right+n.x;break}return console.log(`Calculated position for ${f}:`,{top:h,left:m}),{top:h,left:m,placement:f}},[n.x,n.y]),a=d.useCallback((c,u)=>{const f={width:window.innerWidth,height:window.innerHeight};return c.left<xr||c.top<xr||c.left+u.width>f.width-xr||c.top+u.height>f.height-xr},[]),i=d.useCallback(c=>{if(!e.current){const x={width:window.innerWidth,height:window.innerHeight};return{top:x.height/2-100,left:x.width/2-100,placement:t}}const u=e.current.getBoundingClientRect(),f=c.getBoundingClientRect(),h=o(u,f,t);if(!a(h,f))return h;for(const x of r){const g=o(u,f,x);if(!a(g,f))return g}const m={width:window.innerWidth,height:window.innerHeight},p={...h};return p.left<xr?p.left=xr:p.left+f.width>m.width-xr&&(p.left=m.width-f.width-xr),p.top<xr?p.top=xr:p.top+f.height>m.height-xr&&(p.top=m.height-f.height-xr),p},[e,t,r,o,a]);return{getPositionStyle:d.useCallback(c=>{const u=i(c);return{position:"fixed",top:u.top,left:u.left,zIndex:1e3}},[i]),getOptimalPosition:i}}function QN({defaultWidth:e,minWidth:t,maxWidth:n,position:r="left",onWidthChange:o}){const[a,i]=d.useState(e),[l,c]=d.useState(!1),u=d.useRef(0),f=d.useRef(e),h=d.useCallback(v=>{v.preventDefault(),c(!0),u.current=v.clientX,f.current=a},[a]),m=d.useCallback(v=>{if(!l)return;const b=v.clientX-u.current,C=r==="right"?-b:b,S=Math.min(Math.max(f.current+C,t),n);i(S),o==null||o(S)},[l,t,n,r,o]),p=d.useCallback(()=>{c(!1)},[]),x=d.useCallback(v=>{v.preventDefault(),c(!0),u.current=v.touches[0].clientX,f.current=a},[a]),g=d.useCallback(v=>{if(!l)return;const b=v.touches[0].clientX-u.current,C=r==="right"?-b:b,S=Math.min(Math.max(f.current+C,t),n);i(S),o==null||o(S)},[l,t,n,r,o]),w=d.useCallback(()=>{c(!1)},[]);return d.useEffect(()=>{if(l)return document.addEventListener("mousemove",m),document.addEventListener("mouseup",p),document.addEventListener("touchmove",g),document.addEventListener("touchend",w),document.body.style.userSelect="none",document.body.style.cursor="col-resize",()=>{document.removeEventListener("mousemove",m),document.removeEventListener("mouseup",p),document.removeEventListener("touchmove",g),document.removeEventListener("touchend",w),document.body.style.userSelect="",document.body.style.cursor=""}},[l,m,p,g,w]),{width:a,isResizing:l,handleMouseDown:h,handleTouchStart:x,setWidth:i}}const eT=d.forwardRef(({children:e,defaultWidth:t=300,minWidth:n=200,maxWidth:r=800,position:o="left",resizable:a=!0,className:i,onWidthChange:l,...c},u)=>{const{width:f,isResizing:h,handleMouseDown:m,handleTouchStart:p}=QN({defaultWidth:t,minWidth:n,maxWidth:r,position:o,onWidthChange:l}),x={width:`${f}px`},g=o==="left"?"right-0":"left-0";return s.jsxs("div",{ref:u,className:ze("relative h-full flex-shrink-0 cursor-pointer",o==="left"?"border-r":"border-l",i),style:x,...c,children:[s.jsx("div",{className:ze("h-full overflow-x-hidden overflow-y-auto"),children:e}),a&&s.jsx("div",{className:ze("group absolute top-0 bottom-0 w-2",g,"cursor-col-resize","hover:bg-[var(--color-primary-wMain)]","transition-all duration-200",h&&"bg-[var(--color-primary-wMain)]"),onMouseDown:m,onTouchStart:p,role:"separator","aria-orientation":"vertical","aria-label":`Resize ${o} panel`,tabIndex:0,onKeyDown:v=>{if(v.key==="ArrowLeft"||v.key==="ArrowRight"){v.preventDefault();const b=v.key==="ArrowRight"?10:-10,C=o==="right"?-b:b,S=Math.min(Math.max(f+C,n),r);l==null||l(S)}},children:s.jsx("div",{className:ze("absolute inset-y-0 left-1/2 w-0.5 -translate-x-1/2 transform","bg-[var(--color-secondary-w40)] dark:bg-[var(--color-secondary-w70)]","group-hover:bg-[var(--color-primary-wMain)]","transition-colors duration-200",h&&"bg-[var(--color-primary-wMain)]")})})]})});eT.displayName="SidePanel";const Ew=d.createContext(null),jw=d.createContext(void 0),Nw=d.createContext(null),Tw=d.createContext(null),Aw=d.createContext(void 0),Iw=d.createContext(null);function Ut(){const e=d.useContext(Nw);if(e===null)throw new Error("useConfig must be used within a ConfigProvider");return e}const tT="https://solace.com/a2a/extensions/display-name",nT="https://solace.com/a2a/extensions/peer-agent-topology",rT="https://solace.com/a2a/extensions/sam/tools",oT=e=>{var o,a,i,l;let t,n,r;if((o=e.capabilities)!=null&&o.extensions){const c=e.capabilities.extensions.find(h=>h.uri===tT);(a=c==null?void 0:c.params)!=null&&a.display_name&&(t=c.params.display_name);const u=e.capabilities.extensions.find(h=>h.uri===nT);(i=u==null?void 0:u.params)!=null&&i.peer_agent_names&&(n=u.params.peer_agent_names);const f=e.capabilities.extensions.find(h=>h.uri===rT);(l=f==null?void 0:f.params)!=null&&l.tools&&(r=f.params.tools)}return{...e,display_name:t,peer_agents:n||[],tools:r||[],displayName:t,peerAgents:n||[]}},sT=()=>{const{configServerUrl:e}=Ut(),[t,n]=d.useState([]),[r,o]=d.useState(!1),[a,i]=d.useState(null),l=d.useCallback(async()=>{o(!0),i(null);try{const u=`${e}/api/v1`,h=(await _n(`${u}/agentCards`)).map(oT);n(h)}catch(u){console.error("Error fetching agents:",u),i(u instanceof Error?u.message:"Could not load agent information."),n([])}finally{o(!1)}},[e]);d.useEffect(()=>{l()},[l]);const c=d.useMemo(()=>{const u={};return t.forEach(f=>{f.name&&(u[f.name]=f.displayName||f.name)}),u},[t]);return d.useMemo(()=>({agents:t,agentNameMap:c,isLoading:r,error:a,refetch:l}),[t,c,r,a,l])};function aT(e,t){if(t&&t.toLowerCase().startsWith("text/"))return!0;if(!e)return!1;const n=e.toLowerCase();return!!(n.endsWith(".txt")||n.endsWith(".text")||n.endsWith(".sql")||n.endsWith(".xml")||n.endsWith(".toml")||n.endsWith(".ini")||n.endsWith(".conf")||n.endsWith(".config")||n.endsWith(".properties")||n.endsWith(".py")||n.endsWith(".js")||n.endsWith(".ts")||n.endsWith(".jsx")||n.endsWith(".tsx")||n.endsWith(".java")||n.endsWith(".c")||n.endsWith(".cpp")||n.endsWith(".h")||n.endsWith(".hpp")||n.endsWith(".cs")||n.endsWith(".go")||n.endsWith(".rs")||n.endsWith(".rb")||n.endsWith(".php")||n.endsWith(".swift")||n.endsWith(".kt")||n.endsWith(".scala")||n.endsWith(".sh")||n.endsWith(".bash")||n.endsWith(".zsh")||n.endsWith(".bat")||n.endsWith(".cmd")||n.endsWith(".ps1")||n.endsWith(".css")||n.endsWith(".scss")||n.endsWith(".sass")||n.endsWith(".less")||n.endsWith(".log")||n.endsWith(".env")||n.endsWith(".gitignore")||n.endsWith(".dockerignore")||n.endsWith(".editorconfig"))}function iT(e,t){if(t){const n=t.toLowerCase();if(n==="text/html"||n==="application/xhtml+xml")return!0}return e?e.toLowerCase().endsWith(".html")||e.toLowerCase().endsWith(".htm"):!1}function lT(e,t){if(t){const n=t.toLowerCase();if(n==="text/x-mermaid"||n==="application/x-mermaid")return!0}return e?e.toLowerCase().endsWith(".mermaid")||e.toLowerCase().endsWith(".mmd"):!1}function cT(e,t){if(t){const n=t.toLowerCase();if(n==="text/csv"||n==="application/csv")return!0}return e?e.toLowerCase().endsWith(".csv"):!1}function uT(e,t){if(t){const r=t.toLowerCase();if(r.startsWith("image/"))return!0;if(r.startsWith("text/")||r.startsWith("application/"))return!1}if(!e)return!1;const n=e.toLowerCase();return n.endsWith(".png")||n.endsWith(".jpg")||n.endsWith(".jpeg")||n.endsWith(".gif")||n.endsWith(".bmp")||n.endsWith(".webp")||n.endsWith(".svg")}function dT(e,t){if(t){const n=t.toLowerCase();if(n==="application/json"||n==="text/json")return!0}return e?e.toLowerCase().endsWith(".json"):!1}function fT(e,t){if(t){const r=t.toLowerCase();if(r==="application/yaml"||r==="text/yaml"||r==="application/x-yaml"||r==="text/x-yaml")return!0}if(!e)return!1;const n=e.toLowerCase();return n.endsWith(".yaml")||n.endsWith(".yml")}function hT(e,t){if(t){const r=t.toLowerCase();if(r==="text/markdown"||r==="application/markdown"||r==="text/x-markdown")return!0}if(!e)return!1;const n=e.toLowerCase();return n.endsWith(".md")||n.endsWith(".markdown")}function pT(e,t){if(t){const r=t.toLowerCase();if(r.startsWith("audio/"))return!0;if(r.startsWith("text/")||r.startsWith("application/")||r.startsWith("image/"))return!1}if(!e)return!1;const n=e.toLowerCase();return n.endsWith(".mp3")||n.endsWith(".wav")||n.endsWith(".ogg")||n.endsWith(".aac")||n.endsWith(".flac")||n.endsWith(".m4a")}function Ir(e,t){return iT(e,t)?"html":lT(e,t)?"mermaid":uT(e,t)?"image":hT(e,t)?"markdown":pT(e,t)?"audio":dT(e,t)?"json":fT(e,t)?"yaml":cT(e,t)?"csv":aT(e,t)?"text":null}function Rw(e){try{const t=Uint8Array.from(atob(e),n=>n.charCodeAt(0));return new TextDecoder("utf-8",{fatal:!1}).decode(t)}catch(t){console.warn("TextDecoder failed (potentially non-UTF8 data), falling back to simple atob:",t);try{return atob(e)}catch(n){return console.error("Failed to decode base64 content with atob fallback:",n),e}}}const Pw=["csv","html","json","mermaid","image","markdown","audio","text","yaml"],mT=["image","audio"],Mw=e=>{if(!e||!e.content)return"";const t=Ir(e.name,e.mime_type);if(!t||!Pw.includes(t))return"";if(mT.includes(t))return e.content;if(e.isPlainText)return console.log("Content is plain text from streaming, returning as-is"),e.content;try{return Rw(e.content)}catch(n){return console.error("Failed to decode base64 content:",n),""}},Dw=5*1024*1024,gT=si(Dw);function xT(e){if(!e||!e.size)return{canPreview:!1,reason:"No artifact or content available."};const t=Ir(e.filename,e.mime_type);return!t||!Pw.includes(t)?{canPreview:!1,reason:"Preview not yet supported for this file type."}:e.size>Dw?{canPreview:!1,reason:`Preview not supported for files this large. Maximum size is: ${gT}.`}:{canPreview:!0}}const Vf=(e,t="h-4 w-4")=>{if(!e)return s.jsx($u,{className:t});switch(Ir(e.filename,e.mime_type)){case"image":case"mermaid":return s.jsx(Bu,{className:t});case"audio":return s.jsx(Uu,{className:t});case"html":return s.jsx(Rg,{className:t});case"text":return s.jsx(wr,{className:t});case"csv":return s.jsx(zu,{className:t});case"json":return s.jsx(La,{className:t});default:return s.jsx($u,{className:t})}},vT=(e,t)=>{const n=Ir(e,t);return n==="image"||n==="audio"||n==="text"||n==="markdown"},wT=(e,t)=>{const n=Ir(e,t);return n?["text","markdown","json","yaml","csv","html","image","audio"].includes(n):!1},bT=({filename:e,mimeType:t,shouldAutoExpand:n})=>{const r=d.useMemo(()=>vT(e,t),[e,t]),[o,a]=d.useState(()=>n??r),i=d.useMemo(()=>wT(e,t),[e,t]),l=d.useMemo(()=>i?o:!1,[i,o]),c=d.useMemo(()=>i,[i]),u=d.useCallback(()=>{if(!e||!c){console.log(`[useArtifactRendering] Toggle blocked - filename: ${e}, isExpandable: ${c}`);return}a(f=>{const h=!f;return console.log(`[useArtifactRendering] ${h?"Expanding":"Collapsing"} ${e}`),h})},[e,c]);return{shouldRender:l,isExpandable:c,isExpanded:o,toggleExpanded:u}},gu="lastViewedProjectId",Ow=d.createContext(void 0);let fd=null;const yT=e=>{fd=e},CT=({children:e})=>{const{configServerUrl:t,projectsEnabled:n}=Ut(),[r,o]=d.useState([]),[a,i]=d.useState(!0),[l,c]=d.useState(null),[u,f]=d.useState(null),[h,m]=d.useState(null),[p,x]=d.useState(null),[g,w]=d.useState(""),v=`${t}/api/v1`,b=d.useMemo(()=>{if(!g.trim())return r;const N=g.toLowerCase();return r.filter(M=>{var y;return M.name.toLowerCase().includes(N)||(((y=M.description)==null?void 0:y.toLowerCase().includes(N))??!1)})},[r,g]),C=d.useCallback(async()=>{if(!n){i(!1),o([]);return}i(!0),c(null);try{const N=await pt(`${v}/projects?include_artifact_count=true`,{credentials:"include"});if(!N.ok){const T=await N.json().catch(()=>({detail:`Failed to fetch projects: ${N.statusText}`}));throw new Error(T.detail||`Failed to fetch projects: ${N.statusText}`)}const y=[...(await N.json()).projects].sort((T,R)=>T.name.toLowerCase().localeCompare(R.name.toLowerCase()));o(y)}catch(N){console.error("Error fetching projects:",N),c(N instanceof Error?N.message:"Could not load projects."),o([])}finally{i(!1)}},[v,n]),S=d.useCallback(async N=>{if(!n)throw new Error("Projects feature is disabled");try{const M=await pt(`${v}/projects`,{method:"POST",body:N,credentials:"include"});if(!M.ok){const T=await M.text();let R=`Failed to create project: ${M.statusText}`;try{const z=JSON.parse(T);R=z.detail||z.message||R}catch{T&&T.length<200&&(R=T)}throw new Error(R)}const y=await M.json();return o(T=>[y,...T].sort((z,F)=>z.name.toLowerCase().localeCompare(F.name.toLowerCase()))),y}catch(M){const y=M instanceof Error?M.message:"Could not create project.";throw new Error(y)}},[v,n]),E=d.useCallback(async(N,M)=>{if(!n)throw new Error("Projects feature is disabled");try{const y=await pt(`${v}/projects/${N}/artifacts`,{method:"POST",body:M,credentials:"include"});if(!y.ok){const T=await y.text();let R=`Failed to add files: ${y.statusText}`;try{const z=JSON.parse(T);R=z.detail||z.message||R}catch{T&&T.length<500&&(R=T)}throw y.status===413&&!R.includes("exceeds maximum")&&!R.includes("too large")&&(R="One or more files exceed the maximum allowed size. Please try uploading smaller files."),new Error(R)}c(null),await C()}catch(y){console.error("Error adding files to project:",y);const T=y instanceof Error?y.message:"Could not add files to project.";throw new Error(T)}},[v,n,C]),_=d.useCallback(async(N,M)=>{if(!n)throw new Error("Projects feature is disabled");try{const y=await pt(`${v}/projects/${N}/artifacts/${encodeURIComponent(M)}`,{method:"DELETE",credentials:"include"});if(!y.ok&&y.status!==204){const T=await y.json().catch(()=>({detail:`Failed to remove file: ${y.statusText}`}));throw new Error(T.detail||`Failed to remove file: ${y.statusText}`)}c(null),await C()}catch(y){console.error("Error removing file from project:",y);const T=y instanceof Error?y.message:"Could not remove file from project.";throw new Error(T)}},[v,n,C]),j=d.useCallback(async(N,M,y)=>{if(!n)throw new Error("Projects feature is disabled");try{const T=new FormData;T.append("description",y);const R=await pt(`${v}/projects/${N}/artifacts/${encodeURIComponent(M)}`,{method:"PATCH",body:T,credentials:"include"});if(!R.ok){const z=await R.json().catch(()=>({detail:`Failed to update file metadata: ${R.statusText}`}));throw new Error(z.detail||`Failed to update file metadata: ${R.statusText}`)}c(null)}catch(T){console.error("Error updating file metadata:",T);const R=T instanceof Error?T.message:"Could not update file metadata.";throw new Error(R)}},[v,n]),A=d.useCallback(async(N,M)=>{if(!n)throw new Error("Projects feature is disabled");try{const y=await pt(`${v}/projects/${N}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(M),credentials:"include"});if(!y.ok){let R=`Failed to update project: ${y.statusText}`;try{const z=await y.json();y.status===422?z.detail&&(Array.isArray(z.detail)?R=`Validation error: ${z.detail.map(I=>{var L;return`${((L=I.loc)==null?void 0:L.join("."))||"field"}: ${I.msg}`}).join(", ")}`:typeof z.detail=="string"&&(R=z.detail)):R=z.detail||z.message||R}catch{}throw new Error(R)}const T=await y.json();return o(R=>R.map(F=>F.id===T.id?T:F).sort((F,I)=>F.name.toLowerCase().localeCompare(I.name.toLowerCase()))),f(R=>(R==null?void 0:R.id)===T.id?T:R),m(R=>(R==null?void 0:R.id)===T.id?T:R),x(R=>(R==null?void 0:R.id)===T.id?T:R),c(null),T}catch(y){console.error("Error updating project:",y);const T=y instanceof Error?y.message:"Could not update project.";throw new Error(T)}},[v,n]),P=d.useCallback(async N=>{if(!n)throw new Error("Projects feature is disabled");try{const M=await pt(`${v}/projects/${N}`,{method:"DELETE",credentials:"include"});if(!M.ok&&M.status!==204){const y=await M.json().catch(()=>({detail:`Failed to delete project: ${M.statusText}`}));throw new Error(y.detail||`Failed to delete project: ${M.statusText}`)}o(y=>y.filter(T=>T.id!==N)),f(y=>(y==null?void 0:y.id)===N?null:y),m(y=>(y==null?void 0:y.id)===N?null:y),x(y=>(y==null?void 0:y.id)===N?null:y),c(null),fd&&fd(N)}catch(M){console.error("Error deleting project:",M);const y=M instanceof Error?M.message:"Could not delete project.";throw new Error(y)}},[v,n]);d.useEffect(()=>{C()},[C]),d.useEffect(()=>{if(r.length>0&&!h){const N=localStorage.getItem(gu);if(N){const M=r.find(y=>y.id===N);M&&m(M)}}},[r,h]);const O=d.useCallback(N=>{m(N),N?localStorage.setItem(gu,N.id):localStorage.removeItem(gu)},[]),B={projects:r,isLoading:a,error:l,createProject:S,refetch:C,currentProject:u,setCurrentProject:f,selectedProject:h,setSelectedProject:O,activeProject:p,setActiveProject:x,addFilesToProject:E,removeFileFromProject:_,updateFileMetadata:j,updateProject:A,deleteProject:P,searchQuery:g,setSearchQuery:w,filteredProjects:b};return s.jsx(Ow.Provider,{value:B,children:e})},ko=()=>{const e=d.useContext(Ow);if(e===void 0)throw new Error("useProjectContext must be used within a ProjectProvider");return e},ST=e=>{const{configServerUrl:t}=Ut(),{activeProject:n}=ko(),[r,o]=d.useState([]),[a,i]=d.useState(!0),[l,c]=d.useState(null),u=`${t}/api/v1`,f=d.useCallback(async()=>{i(!0),c(null);try{let h;if(e&&e.trim()&&e!=="null"&&e!=="undefined")h=`${u}/artifacts/${e}`;else if(n!=null&&n.id)h=`${u}/artifacts/null?project_id=${n.id}`;else{o([]),i(!1);return}const m=await pt(h,{credentials:"include"});if(!m.ok){const g=await m.json().catch(()=>({message:`Failed to fetch artifacts. ${m.statusText}`}));throw new Error(g.message||`Failed to fetch artifacts. ${m.statusText}`)}const x=(await m.json()).map(g=>({...g,uri:g.uri||`artifact://${e}/${g.filename}`}));o(x)}catch(h){const m=h instanceof Error?h.message:"Failed to fetch artifacts.";c(m),o([])}finally{i(!1)}},[u,e,n==null?void 0:n.id]);return d.useEffect(()=>{f()},[f]),{artifacts:r,isLoading:a,error:l,refetch:f,setArtifacts:o}},Lw=d.createContext(void 0),lo={speechToText:"speechToText",engineSTT:"engineSTT",sttProvider:"sttProvider",languageSTT:"languageSTT",autoSendText:"autoSendText",autoTranscribeAudio:"autoTranscribeAudio",decibelThreshold:"decibelThreshold",textToSpeech:"textToSpeech",engineTTS:"engineTTS",ttsProvider:"ttsProvider",voice:"voice",playbackRate:"playbackRate",automaticPlayback:"automaticPlayback",cacheTTS:"cacheTTS",cloudBrowserVoices:"cloudBrowserVoices",conversationMode:"conversationMode",advancedMode:"advancedMode"},hl={speechToText:!1,engineSTT:"browser",sttProvider:"browser",languageSTT:"en-US",autoSendText:-1,autoTranscribeAudio:!0,decibelThreshold:-45,textToSpeech:!0,engineTTS:"browser",ttsProvider:"browser",voice:"Kore",playbackRate:1,automaticPlayback:!1,cacheTTS:!0,cloudBrowserVoices:!1,conversationMode:!1,advancedMode:!1};function _T(){const e={...hl};try{Object.entries(lo).forEach(([t,n])=>{const r=localStorage.getItem(n);if(r!==null){const o=t;typeof hl[o]=="boolean"?e[o]=r==="true":typeof hl[o]=="number"?e[o]=parseFloat(r):e[o]=r}})}catch(t){console.error("Error loading audio settings from storage:",t)}return e}const kT=({children:e})=>{const[t,n]=d.useState(_T),[r,o]=d.useState(!1),[a,i]=d.useState(!1);d.useEffect(()=>{(async()=>{try{const x=await pt("/api/v1/config");if(x.ok){const w=(await x.json()).tts_settings||{};let v=!1,b=!1;try{const C=await pt("/api/v1/speech/config");if(C.ok){const S=await C.json();v=S.sttExternal||!1,b=S.ttsExternal||!1}}catch(C){console.error("Error fetching speech config:",C)}n(C=>{const S={...C};return Object.entries(w).forEach(([E,_])=>{const j=E,A=lo[j];j in S&&A&&localStorage.getItem(A)===null&&(S[j]=_)}),S.engineSTT==="external"&&!v&&(console.warn("External STT not configured, falling back to browser mode"),S.engineSTT="browser",S.sttProvider="browser",localStorage.setItem(lo.engineSTT,"browser"),localStorage.setItem(lo.sttProvider,"browser")),S.engineTTS==="external"&&!b&&(console.warn("External TTS not configured, falling back to browser mode"),S.engineTTS="browser",S.ttsProvider="browser",localStorage.setItem(lo.engineTTS,"browser"),localStorage.setItem(lo.ttsProvider,"browser")),S})}}catch(x){console.error("Error fetching TTS config from /api/v1/config:",x)}finally{o(!0)}})()},[]);const l=d.useCallback((p,x)=>{n(g=>{const w={...g,[p]:x},v=lo[p];return v&&(localStorage.setItem(v,String(x)),console.log(`Saved ${p} = ${x} to localStorage as ${v}`)),w})},[]),c=d.useCallback(p=>{n(x=>{const g={...x,...p};return Object.entries(p).forEach(([w,v])=>{const b=lo[w];b&&localStorage.setItem(b,String(v))}),g})},[]),u=d.useCallback(()=>{n(hl),Object.values(lo).forEach(p=>{localStorage.removeItem(p)})},[]),f=d.useCallback(()=>{i(!0)},[]),h=d.useCallback(()=>{i(!1)},[]),m={settings:t,isInitialized:r,updateSetting:l,updateSettings:c,resetSettings:u,speechToTextEndpoint:t.engineSTT,textToSpeechEndpoint:t.engineTTS,isTTSPlaying:a,setIsTTSPlaying:i,onTTSStart:f,onTTSEnd:h};return s.jsx(Lw.Provider,{value:m,children:e})};function Bo(){const e=d.useContext(Lw);if(!e)throw new Error("useAudioSettings must be used within AudioSettingsProvider");return e}const Fw=()=>{const e=d.useContext(Ew);if(!e)throw new Error("useAuth must be used within an AuthProvider");return e},Ui="sam_background_tasks";function ET({apiPrefix:e,userId:t,onTaskCompleted:n,onTaskFailed:r}){const[o,a]=d.useState([]),[i,l]=d.useState([]);d.useEffect(()=>{const v=localStorage.getItem(Ui);if(v)try{const b=JSON.parse(v);a(b)}catch(b){console.error("[BackgroundTaskMonitor] Failed to parse stored tasks:",b),localStorage.removeItem(Ui)}},[]),d.useEffect(()=>{o.length>0?localStorage.setItem(Ui,JSON.stringify(o)):localStorage.removeItem(Ui)},[o]);const c=d.useCallback((v,b,C)=>{const S={taskId:v,sessionId:b,lastEventTimestamp:Date.now(),isBackground:!0,startTime:Date.now(),agentName:C};a(E=>E.some(_=>_.taskId===v)?E:[...E,S])},[]),u=d.useCallback(v=>{a(b=>b.filter(S=>S.taskId!==v))},[]),f=d.useCallback((v,b)=>{a(C=>C.map(S=>S.taskId===v?{...S,lastEventTimestamp:b}:S))},[]),h=d.useCallback(async v=>{try{const b=await pt(`${e}/tasks/${v}/status`);if(!b.ok){if(b.status===404)return u(v),null;throw new Error(`HTTP ${b.status}`)}return await b.json()}catch(b){return console.error(`[BackgroundTaskMonitor] Failed to check status for task ${v}:`,b),null}},[e,u]),m=d.useCallback(async()=>{if(o.length!==0)for(const v of o){const b=await h(v.taskId);if(b&&!b.is_running){const C=b.task.status;let S="completed",E="Background task completed";C==="failed"||C==="error"?(S="failed",E="Background task failed"):C==="timeout"&&(S="timeout",E="Background task timed out");const _={taskId:v.taskId,type:S,message:E,timestamp:Date.now()};l(j=>[...j,_]),S==="completed"&&n?n(v.taskId):S!=="completed"&&r&&r(v.taskId,E),u(v.taskId)}}},[o,h,n,r,u]),p=d.useCallback(async()=>{try{const v=await pt(`${e}/tasks/background/active?user_id=${encodeURIComponent(t)}`);if(!v.ok)throw new Error(`HTTP ${v.status}`);return(await v.json()).tasks.map(C=>({taskId:C.id,sessionId:"",lastEventTimestamp:C.last_activity_time||C.start_time,isBackground:!0,startTime:C.start_time}))}catch(v){return console.error("[BackgroundTaskMonitor] Failed to fetch active background tasks:",v),[]}},[e,t]);d.useEffect(()=>{(async()=>{const b=await p();a(C=>{const S=[...C];for(const E of b)S.some(_=>_.taskId===E.taskId)||S.push(E);return S})})()},[t,p]);const x=d.useCallback(v=>{l(b=>b.filter(C=>C.taskId!==v))},[]),g=d.useCallback(v=>o.filter(b=>b.sessionId===v),[o]),w=d.useCallback(v=>o.some(b=>b.taskId===v),[o]);return{backgroundTasks:o,notifications:i,registerBackgroundTask:c,unregisterBackgroundTask:u,updateTaskTimestamp:f,checkTaskStatus:h,checkAllBackgroundTasks:m,dismissNotification:x,getSessionBackgroundTasks:g,isTaskRunningInBackground:w,fetchActiveBackgroundTasks:p}}const Ft=()=>{const e=d.useContext(jw);if(e===void 0)throw new Error("useChatContext must be used within a ChatProvider");return e};function jT(){const{messages:e}=Ft(),t=Ut(),n=d.useCallback(r=>{if((t==null?void 0:t.persistenceEnabled)===!1&&!(e.length<=1))return r.preventDefault(),"Are you sure you want to leave? Your chat history will be lost."},[e.length,t==null?void 0:t.persistenceEnabled]);d.useEffect(()=>(window.addEventListener("beforeunload",n),()=>{window.removeEventListener("beforeunload",n)}),[n])}function $w(){const e=d.useContext(Tw);if(!e)throw new Error("useCsrf must be used within a CsrfProvider");return e}function NT(e,t){const[n,r]=d.useState(e);return d.useEffect(()=>{const o=setTimeout(()=>{r(e)},t);return()=>{clearTimeout(o)}},[e,t]),n}const TT=async(e,t,n,r)=>{const o=t&&t.trim()&&t!=="null"&&t!=="undefined";let a;if(o)a=`${e}/api/v1/artifacts/${t.trim()}/${encodeURIComponent(r.filename)}`;else if(n)a=`${e}/api/v1/artifacts/null/${encodeURIComponent(r.filename)}?project_id=${n}`;else throw new Error("No valid session or project context for downloading artifact.");const l=await(await vn(a)).blob();oi(l,r.filename)},Wf=e=>{const{configServerUrl:t}=Ut(),{addNotification:n,sessionId:r,displayError:o}=Ft(),{activeProject:a}=ko();return{onDownload:async l=>{try{const c=e||(a==null?void 0:a.id)||null;await TT(t,r,c,l),n(`Downloaded artifact: ${l.filename}.`,"success")}catch(c){o({title:"Failed to Download Artifact",error:Yt(c,"An unknown error occurred while downloading the artifact.")})}}}},AT=({onFilesDropped:e,fileFilter:t,disabled:n=!1})=>{const[r,o]=d.useState(!1),a=d.useRef(0),i=d.useCallback(f=>{n||(f.preventDefault(),f.stopPropagation(),a.current=(a.current||0)+1,f.dataTransfer.types.includes("Files")&&o(!0))},[n,a]),l=d.useCallback(f=>{n||(f.preventDefault(),f.stopPropagation(),f.dataTransfer.types.includes("Files")&&(f.dataTransfer.dropEffect="copy"))},[n]),c=d.useCallback(f=>{n||(f.preventDefault(),f.stopPropagation(),a.current=(a.current||0)-1,a.current===0&&o(!1))},[n,a]),u=d.useCallback(f=>{if(n||(f.preventDefault(),f.stopPropagation(),o(!1),a.current=0,!f.dataTransfer.files||f.dataTransfer.files.length===0))return;const h=Array.from(f.dataTransfer.files),m=t?h.filter(t):h;m.length!==0&&e(m)},[n,a,t,e]);return{isDragging:r,handleDragEnter:i,handleDragOver:l,handleDragLeave:c,handleDrop:u}};function IT(){const e=["audio/webm","audio/webm;codecs=opus","audio/mp4","audio/ogg;codecs=opus","audio/ogg","audio/wav"];for(const n of e)if(MediaRecorder.isTypeSupported(n))return n;const t=navigator.userAgent.toLowerCase();return t.indexOf("safari")!==-1&&t.indexOf("chrome")===-1?"audio/mp4":t.indexOf("firefox")!==-1?"audio/ogg":"audio/webm"}function RT(e){const t={"audio/webm":"webm","audio/mp4":"mp4","audio/ogg":"ogg","audio/wav":"wav"};for(const[n,r]of Object.entries(t))if(e.includes(n))return r;return"webm"}function PT(e={}){const{onTranscriptionComplete:t,onTranscriptionUpdate:n,onError:r}=e,{settings:o,updateSetting:a}=Bo(),[i,l]=d.useState(!1),[c,u]=d.useState(!1),[f,h]=d.useState(null),[m,p]=d.useState(""),x=d.useRef(null),g=d.useRef(null),w=d.useRef([]),v=d.useRef(null),b=o.engineSTT==="browser",C=d.useCallback(()=>{if(x.current){try{x.current.stop()}catch{}x.current=null}if(g.current&&g.current.state!=="inactive")try{g.current.stop()}catch{}v.current&&(v.current.getTracks().forEach(B=>B.stop()),v.current=null),w.current=[]},[]),S=d.useCallback(async()=>{const B=window.SpeechRecognition||window.webkitSpeechRecognition;if(!B){const N="Speech recognition is not supported in this browser. Please use Chrome, Edge, or Safari, or switch to External API mode in settings.";h(N),r==null||r(N),console.error("Browser STT not supported. Available:",{SpeechRecognition:!!window.SpeechRecognition,webkitSpeechRecognition:!!window.webkitSpeechRecognition,userAgent:navigator.userAgent});return}try{const N=new B;N.continuous=!0,N.interimResults=!0,N.lang=o.languageSTT||"en-US",N.onstart=()=>{l(!0),h(null)},N.onresult=M=>{let y="",T="";for(let z=M.resultIndex;z<M.results.length;z++){const F=M.results[z],I=F[0].transcript;F.isFinal?T+=I+" ":y+=I}const R=(T+y).trim();p(R),n==null||n(R),T&&(t==null||t(T.trim()))},N.onerror=M=>{const y=`Speech recognition error: ${M.error}`;h(y),r==null||r(y),l(!1)},N.onend=()=>{l(!1)},x.current=N,N.start()}catch(N){const M=`Failed to start speech recognition: ${N}`;h(M),r==null||r(M)}},[o.languageSTT,t,n,r]),E=d.useCallback(async()=>{x.current&&(x.current.stop(),x.current=null),l(!1)},[]),_=d.useCallback(async()=>{try{const B=await pt("/api/v1/speech/config");if(B.ok&&!(await B.json()).sttExternal){a("engineSTT","browser");const M="External STT is not configured. Switched to Browser mode. Please click the microphone button again.";h(M),r==null||r(M);return}}catch{const B="Failed to check STT configuration. Please try again.";h(B),r==null||r(B);return}try{const B=await navigator.mediaDevices.getUserMedia({audio:!0,video:!1});v.current=B,w.current=[];const N=IT(),M=new MediaRecorder(B,{mimeType:N});M.ondataavailable=y=>{y.data.size>0&&w.current.push(y.data)},M.onstop=async()=>{u(!0);try{if(w.current.length===0)throw new Error("No audio data recorded");const y=new Blob(w.current,{type:N}),T=RT(N),R=new FormData;R.append("audio",y,`audio.${T}`),o.sttProvider&&o.sttProvider!=="browser"&&R.append("provider",o.sttProvider),o.languageSTT&&R.append("language",o.languageSTT);const z=await pt("/api/v1/speech/stt",{method:"POST",body:R});if(!z.ok){const J=await z.text();let L="";try{const D=JSON.parse(J);L=D.message||D.detail||""}catch(D){console.error("[useSpeechToText] Failed to parse error response:",D)}if(L)throw new Error(L);if(z.status===500){const D=o.sttProvider==="azure"?"Azure Speech":"OpenAI Whisper";throw new Error(`External STT failed (${D}). Please check your webui.yaml configuration or switch to Browser mode in settings.`)}throw new Error(`Transcription failed: ${z.statusText}`)}const I=(await z.json()).text||"";p(I),t==null||t(I)}catch(y){const T=`Transcription error: ${y}`;h(T),r==null||r(T)}finally{u(!1),C()}},g.current=M,M.start(100),l(!0),h(null)}catch(B){const N=`Failed to access microphone: ${B}`;h(N),r==null||r(N),C()}},[o.sttProvider,t,r,C,a]),j=d.useCallback(async()=>{g.current&&g.current.state!=="inactive"&&g.current.stop(),l(!1)},[]),A=d.useCallback(async()=>{h(null),p(""),b?await S():await _()},[b,S,_]),P=d.useCallback(async()=>{b?await E():await j()},[b,E,j]),O=d.useCallback(()=>{p(""),h(null)},[]);return d.useEffect(()=>()=>{C()},[C]),{isListening:i,isLoading:c,error:f,transcript:m,startRecording:A,stopRecording:P,resetTranscript:O}}function MT(e){const{messageId:t,onStart:n,onEnd:r,onError:o}=e,{settings:a,onTTSStart:i,onTTSEnd:l}=Bo(),[c,u]=d.useState(!1),[f,h]=d.useState(!1),[m,p]=d.useState(null),x=d.useRef(new Set),g=d.useRef([]),w=d.useRef(!1),v=d.useRef(null),b=d.useRef(""),C=d.useRef(0),S=d.useRef(!1),E=d.useRef(!1),_=d.useRef(!1),j=d.useRef(null),A=d.useRef(null),P=d.useRef(n),O=d.useRef(r),B=d.useRef(o),N=d.useRef(i),M=d.useRef(l);d.useEffect(()=>{P.current=n,O.current=r,B.current=o,N.current=i,M.current=l},[n,r,o,i,l]);const y=d.useCallback(J=>{const L=/[^.!?]+[.!?]+(?:\s|$)/g;return(J.match(L)||[]).map(W=>W.trim()).filter(W=>W.length>0)},[]),T=d.useCallback(async J=>{var L;try{console.log(`[StreamingTTS] Requesting streaming TTS for text length: ${J.length}`);const D=await fetch("/api/v1/speech/tts/stream",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({input:J,voice:a.voice,runId:t})});if(!D.ok)throw new Error(`TTS streaming failed: ${D.statusText}`);const W=(L=D.body)==null?void 0:L.getReader();if(!W)throw new Error("No response body reader available");const G=[];let V=0;for(;;){const{done:de,value:se}=await W.read();if(de)break;se&&(G.push(se),V+=se.length)}console.log(`[StreamingTTS] Received ${G.length} chunks, total size: ${V} bytes`);const Q=new Uint8Array(V);let X=0;for(const de of G)Q.set(de,X),X+=de.length;const K=new Blob([Q],{type:"audio/mpeg"});if(console.log(`[StreamingTTS] Created audio blob: size=${K.size}, type=${K.type}`),K.size===0)throw new Error("Received empty audio stream");const q=URL.createObjectURL(K),ne=new Audio;return ne.onerror=de=>{const se=ne.error;console.error(`[StreamingTTS] Audio error: code=${se==null?void 0:se.code}, message=${se==null?void 0:se.message}`,de)},ne.src=q,ne.playbackRate=a.playbackRate||1,ne.load(),ne}catch(D){return console.error("[StreamingTTS] Error generating streamed audio:",D),null}},[a.voice,a.playbackRate,t]),R=d.useCallback(()=>{if(S.current){console.log("[StreamingTTS] Skipping playback - stopped");return}if(w.current||g.current.length===0)return;w.current=!0;const J=g.current.shift();if(!J){w.current=!1;return}const{audio:L,sentence:D}=J;v.current=L,console.log(`[StreamingTTS] Playing sentence: "${D.substring(0,50)}..."`),L.onplay=()=>{var W;console.log("[StreamingTTS] Audio onplay event fired"),u(!0),h(!1),E.current||(console.log("[StreamingTTS] First audio playing, notifying global state"),E.current=!0,(W=P.current)==null||W.call(P),N.current&&N.current())},L.onended=()=>{var W;if(console.log("[StreamingTTS] Audio onended event fired"),URL.revokeObjectURL(L.src),v.current=null,w.current=!1,g.current.length>0)console.log("[StreamingTTS] More audio in queue, playing next"),R();else if(!_.current)console.log("[StreamingTTS] All audio played and generation complete, notifying global state"),u(!1),(W=O.current)==null||W.call(O),M.current&&M.current();else{console.log("[StreamingTTS] Queue empty but still generating, polling...");let G=0;const V=100,Q=setInterval(()=>{var X,K;G++,g.current.length>0?(console.log("[StreamingTTS] New audio arrived during poll, playing"),clearInterval(Q),R()):!_.current&&!w.current?(console.log("[StreamingTTS] Generation finished and not playing, notifying global state"),clearInterval(Q),u(!1),(X=O.current)==null||X.call(O),M.current&&M.current()):G>=V&&(console.log("[StreamingTTS] Poll timeout after 10s, forcing end"),clearInterval(Q),_.current=!1,u(!1),(K=O.current)==null||K.call(O),M.current&&M.current())},100)}},L.onerror=()=>{var V,Q;const W=(V=L.error)==null?void 0:V.code;if(W===1){console.log("[StreamingTTS] Ignoring ABORTED error (expected during stop)");return}const G=`Failed to play audio (code: ${W})`;p(G),(Q=B.current)==null||Q.call(B,G),URL.revokeObjectURL(L.src),v.current=null,w.current=!1,g.current.length>0?R():(u(!1),r==null||r(),l())},L.play().catch(W=>{if(W.name==="AbortError"){console.log("[StreamingTTS] Ignoring AbortError from play() (expected during stop)");return}console.error("[StreamingTTS] Error playing audio:",W),w.current=!1,R()})},[r,l]),z=d.useCallback(async(J,L)=>{if(console.log(`[StreamingTTS] doProcessing called: textLen=${J.length}, isComplete=${L}`),S.current){console.log("[StreamingTTS] Skipping - stopped");return}const D=y(J),W=D.join(" ");if(L){const V=D[D.length-1]||"",Q=J.lastIndexOf(V)+V.length,X=J.substring(Q).trim();X&&console.log(`[StreamingTTS] Adding remaining text: "${X.substring(0,50)}..."`)}const G=L?J:W;if(x.current.has(G)||G.length<10){console.log("[StreamingTTS] Skipping - already processed or too short");return}x.current.add(G),b.current=J,C.current=J.length,console.log(`[StreamingTTS] Processing text (${G.length} chars)`),h(!0),S.current=!1,_.current=!0;try{const V=await T(G);V&&!S.current&&(g.current.push({audio:V,sentence:G.substring(0,50),index:g.current.length}),console.log(`[StreamingTTS] Added audio to queue (size: ${g.current.length})`),w.current||(console.log("[StreamingTTS] Starting playback"),R()))}catch(V){console.error("[StreamingTTS] Error processing:",V)}h(!1),L&&(_.current=!1,console.log("[StreamingTTS] Message complete"))},[y,T,R]),F=d.useCallback(async(J,L)=>{if(j.current){console.log("[StreamingTTS] Already processing, queuing update"),A.current={text:J,isComplete:L};return}j.current=z(J,L);try{await j.current}finally{if(j.current=null,A.current){const D=A.current;A.current=null,console.log("[StreamingTTS] Processing queued update"),await F(D.text,D.isComplete)}}},[z]),I=d.useCallback(()=>{if(!(!w.current&&g.current.length===0)){if(console.log("[StreamingTTS] Stopping playback"),S.current=!0,v.current){try{v.current.pause(),v.current.currentTime=0,URL.revokeObjectURL(v.current.src)}catch{}v.current=null}g.current.forEach(J=>{try{URL.revokeObjectURL(J.audio.src)}catch{}}),g.current=[],w.current=!1,u(!1),h(!1),c&&(r==null||r(),l())}},[c,r,l]);return d.useEffect(()=>(x.current.clear(),b.current="",C.current=0,S.current=!1,E.current=!1,_.current=!1,j.current=null,A.current=null,()=>{const L=x.current;if(w.current||g.current.length>0){if(console.log("[StreamingTTS] Cleanup: stopping playback for message change/unmount"),S.current=!0,v.current){try{v.current.pause(),URL.revokeObjectURL(v.current.src)}catch{}v.current=null}g.current.forEach(D=>{try{URL.revokeObjectURL(D.audio.src)}catch{}}),g.current=[],w.current=!1}L.clear(),b.current="",C.current=0,j.current=null,A.current=null}),[t]),{isPlaying:c,isLoading:f,error:m,processStreamingText:F,stop:I}}const Hf=()=>{const e=d.useContext(Aw);if(e===void 0)throw new Error("useTaskContext must be used within a TaskProvider");return e};function DT(e={}){const{messageId:t,onStart:n,onEnd:r,onError:o}=e,{settings:a}=Bo(),[i,l]=d.useState(!1),[c,u]=d.useState(!1),[f,h]=d.useState(null),[m,p]=d.useState([]),x=d.useRef(null),g=d.useRef(null),w=d.useRef(null),v=d.useRef([]),b=d.useRef(!1),C=d.useRef(0),S=a.engineTTS==="browser";d.useEffect(()=>{if(!S)return;const M=()=>{const y=window.speechSynthesis;if(!y)return;const R=y.getVoices().filter(z=>a.cloudBrowserVoices?!0:z.localService).map(z=>({value:z.name,label:`${z.name} (${z.lang})`}));p(R)};return M(),window.speechSynthesis.onvoiceschanged!==void 0&&(window.speechSynthesis.onvoiceschanged=M),()=>{window.speechSynthesis.onvoiceschanged&&(window.speechSynthesis.onvoiceschanged=null)}},[S,a.cloudBrowserVoices]),d.useEffect(()=>{if(S)return;(async()=>{try{const y=a.ttsProvider||"gemini",R=((await _n(`/api/v1/speech/voices?provider=${y}`)).voices||[]).map(z=>({value:z,label:z}));p(R)}catch(y){console.error("Failed to load external voices:",y)}})()},[S,a.ttsProvider]);const E=d.useCallback(()=>{x.current&&(window.speechSynthesis.cancel(),x.current=null),g.current&&(g.current.pause(),g.current.src="",g.current=null),w.current&&(URL.revokeObjectURL(w.current),w.current=null),v.current.forEach(M=>{M.pause(),M.src&&URL.revokeObjectURL(M.src)}),v.current=[],b.current=!1,C.current=0},[]),_=d.useCallback(async M=>{const y=window.speechSynthesis;if(!y){const T="Speech synthesis is not supported in this browser";h(T),o==null||o(T);return}try{y.cancel();const T=new SpeechSynthesisUtterance(M);if(T.rate=a.playbackRate||1,T.lang=a.languageSTT||"en-US",a.voice){const z=y.getVoices().find(F=>F.name===a.voice);z&&(T.voice=z)}T.onstart=()=>{l(!0),h(null),n==null||n()},T.onend=()=>{l(!1),x.current=null,r==null||r()},T.onerror=R=>{const z=`Speech synthesis error: ${R.error}`;h(z),o==null||o(z),l(!1),x.current=null},x.current=T,y.speak(T)}catch(T){const R=`Failed to speak: ${T}`;h(R),o==null||o(R)}},[a.playbackRate,a.languageSTT,a.voice,n,r,o]),j=d.useCallback(()=>{if(!b.current||C.current>=v.current.length){l(!1),b.current=!1,C.current=0,v.current.forEach(T=>{T.src&&URL.revokeObjectURL(T.src)}),v.current=[],r==null||r();return}const M=C.current,y=v.current[M];C.current++,y.onended=()=>{j()},y.onerror=()=>{j()},y.play().catch(T=>{console.error(`[TTS] Failed to play chunk ${M+1}:`,T),j()})},[r]),A=d.useCallback(async M=>{var y;E(),u(!0);try{if(a.cacheTTS){const I=await caches.open("tts-responses"),J=`${M}-${a.voice}-${a.ttsProvider||"default"}`,L=await I.match(J);if(L){const D=await L.blob(),W=URL.createObjectURL(D),G=new Audio(W);G.playbackRate=a.playbackRate||1,G.onplay=()=>{l(!0),u(!1),h(null),n==null||n()},G.onended=()=>{l(!1),URL.revokeObjectURL(W),g.current=null,r==null||r()},G.onerror=()=>{const V="Failed to play cached audio";h(V),o==null||o(V),l(!1),u(!1),URL.revokeObjectURL(W)},g.current=G,w.current=W,await G.play();return}}const R=(y=(await vn("/api/v1/speech/tts/stream",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({input:M,voice:a.voice,runId:t||`tts-${Date.now()}`,provider:a.ttsProvider})})).body)==null?void 0:y.getReader();if(!R)throw new Error("No response body reader available");let z=!1;const F=[];for(v.current=[],C.current=0,b.current=!0;;){const{done:I,value:J}=await R.read();if(I){if(a.cacheTTS&&F.length>0){const L=F.reduce((K,q)=>K+q.length,0),D=new Uint8Array(L);let W=0;for(const K of F)D.set(K,W),W+=K.length;const G=new Blob([D],{type:"audio/mpeg"}),V=await caches.open("tts-responses"),Q=`${M}-${a.voice}-${a.ttsProvider||"default"}`,X=new Response(G,{headers:{"Content-Type":"audio/mpeg","Content-Length":G.size.toString()}});await V.put(Q,X)}break}if(J&&J.length>0){F.push(J);const L=new Blob([J],{type:"audio/mpeg"}),D=URL.createObjectURL(L),W=new Audio(D);if(W.playbackRate=a.playbackRate||1,v.current.push(W),!z){z=!0,l(!0),u(!1),h(null),n==null||n(),W.onended=()=>{j()},W.onerror=()=>{j()};try{await W.play(),C.current=1}catch(G){throw G instanceof Error&&G.name==="NotAllowedError"?(b.current=!1,u(!1),new Error("Click the speaker button again to play audio (browser autoplay policy)")):G}}}}}catch(T){const R=`TTS error: ${T}`;h(R),o==null||o(R),u(!1),b.current=!1}},[a.cacheTTS,a.voice,a.playbackRate,a.ttsProvider,t,n,r,o,E,j]),P=d.useCallback(async M=>{!M||!M.trim()||(h(null),S?await _(M):await A(M))},[S,_,A]),O=d.useCallback(()=>{S?(window.speechSynthesis.cancel(),l(!1)):(b.current=!1,g.current&&(g.current.pause(),g.current.currentTime=0),v.current.forEach(M=>{M.pause()}),l(!1))},[S]),B=d.useCallback(()=>{if(S)window.speechSynthesis.pause();else{const M=C.current-1;M>=0&&M<v.current.length?v.current[M].pause():g.current&&g.current.pause()}l(!1)},[S]),N=d.useCallback(()=>{if(S)window.speechSynthesis.resume(),l(!0);else{const M=C.current-1;M>=0&&M<v.current.length?(v.current[M].play(),l(!0)):g.current&&(g.current.play(),l(!0))}},[S]);return d.useEffect(()=>()=>{E()},[E]),{isSpeaking:i,isLoading:c,error:f,voices:m,speak:P,stop:O,pause:B,resume:N}}function di(){const e=d.useContext(Iw);if(e===null)throw new Error("useThemeContext must be used within a ThemeProvider");return e}const OT=e=>{const{configServerUrl:t}=Ut(),[n,r]=d.useState([]),[o,a]=d.useState(!0),[i,l]=d.useState(null),c=`${t}/api/v1`,u=d.useCallback(async()=>{if(!e){r([]),a(!1);return}a(!0),l(null);try{const f=`${c}/sessions?project_id=${e}&pageNumber=1&pageSize=100`,h=await pt(f,{credentials:"include"});if(!h.ok){const p=await h.json().catch(()=>({detail:`Failed to fetch sessions. ${h.statusText}`}));throw new Error(p.detail||`Failed to fetch sessions. ${h.statusText}`)}const m=await h.json();r(m.data||[])}catch(f){const h=f instanceof Error?f.message:"Failed to fetch sessions.";l(h),r([])}finally{a(!1)}},[c,e]);return d.useEffect(()=>{u();const f=()=>{u()},h=()=>{u()};return window.addEventListener("session-moved",f),window.addEventListener("new-chat-session",h),()=>{window.removeEventListener("session-moved",f),window.removeEventListener("new-chat-session",h)}},[u]),{sessions:n,isLoading:o,error:i,refetch:u}},LT=()=>{const{agents:e,sessionId:t,setMessages:n,setSelectedAgentName:r,handleNewSession:o}=Ft();return{handleAgentSelection:d.useCallback((i,l=!1)=>{if(i){const c=e.find(u=>u.name===i);if(c){l&&o(),r(i);const u=`Hi! I'm the ${c.displayName}. How can I help?`;n(f=>[...f,{parts:[{kind:"text",text:u}],isUser:!1,isComplete:!0,role:"agent",metadata:{sessionId:t||"",lastProcessedEventSequence:0}}])}else console.warn(`Selected agent not found: ${i}`)}},[e,t,n,r,o])}},Vo=({open:e,title:t,content:n,description:r,actionLabels:o,trigger:a,isLoading:i,onOpenChange:l,onConfirm:c,onCancel:u})=>{const f=(o==null?void 0:o.cancel)??"Cancel",h=(o==null?void 0:o.confirm)??"Confirm";return s.jsxs(On,{open:e,onOpenChange:l,children:[a&&s.jsx(cd,{asChild:!0,children:a}),s.jsxs(Ln,{className:"w-xl max-w-xl sm:max-w-xl",children:[s.jsxs(Gn,{children:[s.jsx(Fn,{className:"flex max-w-[400px] flex-row gap-1",children:t}),s.jsx(Yn,{children:r})]}),s.jsx("div",{className:"min-w-0 break-words",children:n}),s.jsxs(nr,{children:[s.jsx(nw,{asChild:!0,children:s.jsx(xe,{variant:"ghost",title:f,onClick:m=>{m.stopPropagation(),u==null||u()},disabled:i,children:f})}),s.jsx(xe,{"data-testid":"dialogConfirmButton",variant:"outline",title:h,onClick:async m=>{m.stopPropagation(),await c(),l(!1)},disabled:i,children:h})]}),i&&s.jsxs(s.Fragment,{children:[s.jsx("style",{children:`
133
+ @keyframes progressBarSlide {
134
+ 0% { transform: translateX(-100%); }
135
+ 100% { transform: translateX(400%); }
136
+ }
137
+ .progress-bar-animate {
138
+ animation: progressBarSlide 2s ease-in-out infinite;
139
+ width: 25%;
140
+ background: var(--color-brand-wMain);
141
+ }
142
+ `}),s.jsx("div",{className:"bg-muted absolute right-1 bottom-0 left-1 h-1 overflow-hidden rounded-full",children:s.jsx("div",{className:"progress-bar-animate h-full rounded-full"})})]})]})]})};function FT(){const[e,t]=d.useState(!1),[n,r]=d.useState(!1),[o,a]=d.useState(!1),i=HS(({currentLocation:h,nextLocation:m})=>o&&!n&&h.pathname!==m.pathname);d.useEffect(()=>{i.state==="blocked"&&t(!0)},[i]);const l=d.useCallback(()=>{t(!1),i.state==="blocked"&&i.proceed()},[i]),c=d.useCallback(()=>{t(!1),i.state==="blocked"&&i.reset()},[i]),u=d.useCallback(h=>{r(!0),setTimeout(()=>{h()},0)},[]);return{NavigationBlocker:d.useCallback(()=>s.jsx(Vo,{title:"Unsaved Changes Will Be Discarded",description:"Leaving the form will discard any unsaved changes. Are you sure you want to leave?",open:e,onConfirm:l,onCancel:c,onOpenChange:t}),[e,l,c]),allowNavigation:u,setBlockingEnabled:a}}const $T=({title:e,subtitle:t,error:n,errorDetails:r,open:o,onOpenChange:a})=>s.jsx(On,{open:o,onOpenChange:a,children:s.jsxs(Ln,{className:"w-xl max-w-xl sm:max-w-xl",children:[s.jsxs(Gn,{children:[s.jsx(Fn,{className:"flex max-w-[400px] flex-row gap-1",children:e}),s.jsx(Yn,{children:t})]}),s.jsxs("div",{className:"flex flex-col gap-4",children:[s.jsxs("div",{className:"flex flex-row items-center gap-2",children:[s.jsx(Pg,{className:"h-6 w-6 shrink-0 self-start text-(--color-error-wMain)"}),s.jsx("div",{children:n})]}),r&&s.jsx("div",{children:r})]}),s.jsx(nr,{children:s.jsx(nw,{asChild:!0,children:s.jsx(xe,{variant:"outline",testid:"closeButton",title:"Close",children:"Close"})})})]})});function zT(){const[e,t]=d.useState(null),n=d.useCallback(o=>{o||t(null)},[]);return{ErrorDialog:d.useCallback(()=>s.jsx($T,{title:(e==null?void 0:e.title)||"Error",error:(e==null?void 0:e.error)||"An error occurred.",open:e!==null,onOpenChange:n}),[e,n]),setError:t}}d.createContext(null);function vc(e){const t=e+"CollectionProvider",[n,r]=mr(t),[o,a]=n(t,{collectionRef:{current:null},itemMap:new Map}),i=g=>{const{scope:w,children:v}=g,b=Rt.useRef(null),C=Rt.useRef(new Map).current;return s.jsx(o,{scope:w,itemMap:C,collectionRef:b,children:v})};i.displayName=t;const l=e+"CollectionSlot",c=Oo(l),u=Rt.forwardRef((g,w)=>{const{scope:v,children:b}=g,C=a(l,v),S=mt(w,C.collectionRef);return s.jsx(c,{ref:S,children:b})});u.displayName=l;const f=e+"CollectionItemSlot",h="data-radix-collection-item",m=Oo(f),p=Rt.forwardRef((g,w)=>{const{scope:v,children:b,...C}=g,S=Rt.useRef(null),E=mt(w,S),_=a(f,v);return Rt.useEffect(()=>(_.itemMap.set(S,{ref:S,...C}),()=>void _.itemMap.delete(S))),s.jsx(m,{[h]:"",ref:E,children:b})});p.displayName=f;function x(g){const w=a(e+"CollectionConsumer",g);return Rt.useCallback(()=>{const b=w.collectionRef.current;if(!b)return[];const C=Array.from(b.querySelectorAll(`[${h}]`));return Array.from(w.itemMap.values()).sort((_,j)=>C.indexOf(_.ref.current)-C.indexOf(j.ref.current))},[w.collectionRef,w.itemMap])}return[{Provider:i,Slot:u,ItemSlot:p},x,r]}var UT=d.createContext(void 0);function fi(e){const t=d.useContext(UT);return e||t||"ltr"}const hi=d.forwardRef(({actions:e,className:t,...n},r)=>{const o=(i,l)=>{(i.key==="Enter"||i.key===" ")&&(i.preventDefault(),l.onClick())},a=(i,l)=>{var u,f,h,m,p;const c=(u=i.currentTarget.parentElement)==null?void 0:u.querySelectorAll('[role="menuitem"]');if(c)switch(i.key){case"ArrowDown":{i.preventDefault();const x=(l+1)%c.length;(f=c[x])==null||f.focus();break}case"ArrowUp":{i.preventDefault();const x=(l-1+c.length)%c.length;(h=c[x])==null||h.focus();break}case"Home":i.preventDefault(),(m=c[0])==null||m.focus();break;case"End":i.preventDefault(),(p=c[c.length-1])==null||p.focus();break;case"Escape":i.preventDefault(),i.currentTarget.blur();break}};return s.jsx("div",{ref:r,role:"menu",className:ze("min-w-[8rem] overflow-hidden",t),...n,children:e.map((i,l)=>s.jsxs(d.Fragment,{children:[i.divider&&l>0&&s.jsx("div",{className:"my-1 h-px bg-[var(--color-secondary-w40)] dark:bg-[var(--color-secondary-w70)]"}),s.jsxs("div",{role:"menuitem",tabIndex:0,"data-disabled":i.disabled,className:ze("relative my-1.5 flex cursor-pointer items-center gap-2 px-3 py-1.5 text-sm transition-colors select-none","data-[disabled]:pointer-events-none data-[disabled]:opacity-50","hover:bg-[var(--color-primary-w10)] hover:text-[var(--color-primary-text-w60)] dark:hover:bg-[var(--color-primary-w60)] dark:hover:text-[var(--color-primary-text-w10)]"),onClick:i.onClick,onKeyDown:c=>{o(c,i),a(c,l)},children:[i.icon&&i.iconPosition!=="right"&&s.jsx("span",{className:"flex h-4 w-4 items-center justify-center",children:i.icon}),s.jsx("span",{className:"flex-1",children:i.label}),i.icon&&i.iconPosition==="right"&&s.jsx("span",{className:"flex h-4 w-4 items-center justify-center",children:i.icon})]})]},i.id))})});hi.displayName="Menu";var Zf="Popper",[zw,Uw]=mr(Zf),[BT,Bw]=zw(Zf),Vw=e=>{const{__scopePopper:t,children:n}=e,[r,o]=d.useState(null);return s.jsx(BT,{scope:t,anchor:r,onAnchorChange:o,children:n})};Vw.displayName=Zf;var Ww="PopperAnchor",Hw=d.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,a=Bw(Ww,n),i=d.useRef(null),l=mt(t,i);return d.useEffect(()=>{a.onAnchorChange((r==null?void 0:r.current)||i.current)}),r?null:s.jsx(rt.div,{...o,ref:l})});Hw.displayName=Ww;var Gf="PopperContent",[VT,WT]=zw(Gf),Zw=d.forwardRef((e,t)=>{var X,K,q,ne,de,se;const{__scopePopper:n,side:r="bottom",sideOffset:o=0,align:a="center",alignOffset:i=0,arrowPadding:l=0,avoidCollisions:c=!0,collisionBoundary:u=[],collisionPadding:f=0,sticky:h="partial",hideWhenDetached:m=!1,updatePositionStrategy:p="optimized",onPlaced:x,...g}=e,w=Bw(Gf,n),[v,b]=d.useState(null),C=mt(t,me=>b(me)),[S,E]=d.useState(null),_=Sf(S),j=(_==null?void 0:_.width)??0,A=(_==null?void 0:_.height)??0,P=r+(a!=="center"?"-"+a:""),O=typeof f=="number"?f:{top:0,right:0,bottom:0,left:0,...f},B=Array.isArray(u)?u:[u],N=B.length>0,M={padding:O,boundary:B.filter(ZT),altBoundary:N},{refs:y,floatingStyles:T,placement:R,isPositioned:z,middlewareData:F}=pf({strategy:"fixed",placement:P,whileElementsMounted:(...me)=>hf(...me,{animationFrame:p==="always"}),elements:{reference:w.anchor},middleware:[mf({mainAxis:o+A,alignmentAxis:i}),c&&gf({mainAxis:!0,crossAxis:!1,limiter:h==="partial"?xf():void 0,...M}),c&&vf({...M}),wf({...M,apply:({elements:me,rects:k,availableWidth:oe,availableHeight:ie})=>{const{width:Z,height:U}=k.reference,re=me.floating.style;re.setProperty("--radix-popper-available-width",`${oe}px`),re.setProperty("--radix-popper-available-height",`${ie}px`),re.setProperty("--radix-popper-anchor-width",`${Z}px`),re.setProperty("--radix-popper-anchor-height",`${U}px`)}}),S&&yf({element:S,padding:l}),GT({arrowWidth:j,arrowHeight:A}),m&&bf({strategy:"referenceHidden",...M})]}),[I,J]=Kw(R),L=Mn(x);ln(()=>{z&&(L==null||L())},[z,L]);const D=(X=F.arrow)==null?void 0:X.x,W=(K=F.arrow)==null?void 0:K.y,G=((q=F.arrow)==null?void 0:q.centerOffset)!==0,[V,Q]=d.useState();return ln(()=>{v&&Q(window.getComputedStyle(v).zIndex)},[v]),s.jsx("div",{ref:y.setFloating,"data-radix-popper-content-wrapper":"",style:{...T,transform:z?T.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:V,"--radix-popper-transform-origin":[(ne=F.transformOrigin)==null?void 0:ne.x,(de=F.transformOrigin)==null?void 0:de.y].join(" "),...((se=F.hide)==null?void 0:se.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:s.jsx(VT,{scope:n,placedSide:I,onArrowChange:E,arrowX:D,arrowY:W,shouldHideArrow:G,children:s.jsx(rt.div,{"data-side":I,"data-align":J,...g,ref:C,style:{...g.style,animation:z?void 0:"none"}})})})});Zw.displayName=Gf;var Gw="PopperArrow",HT={top:"bottom",right:"left",bottom:"top",left:"right"},Yw=d.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,a=WT(Gw,r),i=HT[a.placedSide];return s.jsx("span",{ref:a.onArrowChange,style:{position:"absolute",left:a.arrowX,top:a.arrowY,[i]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[a.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[a.placedSide],visibility:a.shouldHideArrow?"hidden":void 0},children:s.jsx(Cf,{...o,ref:n,style:{...o.style,display:"block"}})})});Yw.displayName=Gw;function ZT(e){return e!==null}var GT=e=>({name:"transformOrigin",options:e,fn(t){var w,v,b;const{placement:n,rects:r,middlewareData:o}=t,i=((w=o.arrow)==null?void 0:w.centerOffset)!==0,l=i?0:e.arrowWidth,c=i?0:e.arrowHeight,[u,f]=Kw(n),h={start:"0%",center:"50%",end:"100%"}[f],m=(((v=o.arrow)==null?void 0:v.x)??0)+l/2,p=(((b=o.arrow)==null?void 0:b.y)??0)+c/2;let x="",g="";return u==="bottom"?(x=i?h:`${m}px`,g=`${-c}px`):u==="top"?(x=i?h:`${m}px`,g=`${r.floating.height+c}px`):u==="right"?(x=`${-c}px`,g=i?h:`${p}px`):u==="left"&&(x=`${r.floating.width+c}px`,g=i?h:`${p}px`),{data:{x,y:g}}}});function Kw(e){const[t,n="center"]=e.split("-");return[t,n]}var YT=Vw,qw=Hw,KT=Zw,qT=Yw,wc="Popover",[Xw,E9]=mr(wc,[Uw]),pi=Uw(),[XT,Wo]=Xw(wc),Jw=e=>{const{__scopePopover:t,children:n,open:r,defaultOpen:o,onOpenChange:a,modal:i=!1}=e,l=pi(t),c=d.useRef(null),[u,f]=d.useState(!1),[h,m]=xo({prop:r,defaultProp:o??!1,onChange:a,caller:wc});return s.jsx(YT,{...l,children:s.jsx(XT,{scope:t,contentId:hr(),triggerRef:c,open:h,onOpenChange:m,onOpenToggle:d.useCallback(()=>m(p=>!p),[m]),hasCustomAnchor:u,onCustomAnchorAdd:d.useCallback(()=>f(!0),[]),onCustomAnchorRemove:d.useCallback(()=>f(!1),[]),modal:i,children:n})})};Jw.displayName=wc;var Qw="PopoverAnchor",JT=d.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,o=Wo(Qw,n),a=pi(n),{onCustomAnchorAdd:i,onCustomAnchorRemove:l}=o;return d.useEffect(()=>(i(),()=>l()),[i,l]),s.jsx(qw,{...a,...r,ref:t})});JT.displayName=Qw;var e0="PopoverTrigger",t0=d.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,o=Wo(e0,n),a=pi(n),i=mt(t,o.triggerRef),l=s.jsx(rt.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":a0(o.open),...r,ref:i,onClick:Ht(e.onClick,o.onOpenToggle)});return o.hasCustomAnchor?l:s.jsx(qw,{asChild:!0,...a,children:l})});t0.displayName=e0;var Yf="PopoverPortal",[QT,eA]=Xw(Yf,{forceMount:void 0}),n0=e=>{const{__scopePopover:t,forceMount:n,children:r,container:o}=e,a=Wo(Yf,t);return s.jsx(QT,{scope:t,forceMount:n,children:s.jsx(_o,{present:n||a.open,children:s.jsx(pa,{asChild:!0,container:o,children:r})})})};n0.displayName=Yf;var Js="PopoverContent",r0=d.forwardRef((e,t)=>{const n=eA(Js,e.__scopePopover),{forceMount:r=n.forceMount,...o}=e,a=Wo(Js,e.__scopePopover);return s.jsx(_o,{present:r||a.open,children:a.modal?s.jsx(nA,{...o,ref:t}):s.jsx(rA,{...o,ref:t})})});r0.displayName=Js;var tA=Oo("PopoverContent.RemoveScroll"),nA=d.forwardRef((e,t)=>{const n=Wo(Js,e.__scopePopover),r=d.useRef(null),o=mt(t,r),a=d.useRef(!1);return d.useEffect(()=>{const i=r.current;if(i)return fc(i)},[]),s.jsx(ui,{as:tA,allowPinchZoom:!0,children:s.jsx(o0,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Ht(e.onCloseAutoFocus,i=>{var l;i.preventDefault(),a.current||(l=n.triggerRef.current)==null||l.focus()}),onPointerDownOutside:Ht(e.onPointerDownOutside,i=>{const l=i.detail.originalEvent,c=l.button===0&&l.ctrlKey===!0,u=l.button===2||c;a.current=u},{checkForDefaultPrevented:!1}),onFocusOutside:Ht(e.onFocusOutside,i=>i.preventDefault(),{checkForDefaultPrevented:!1})})})}),rA=d.forwardRef((e,t)=>{const n=Wo(Js,e.__scopePopover),r=d.useRef(!1),o=d.useRef(!1);return s.jsx(o0,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:a=>{var i,l;(i=e.onCloseAutoFocus)==null||i.call(e,a),a.defaultPrevented||(r.current||(l=n.triggerRef.current)==null||l.focus(),a.preventDefault()),r.current=!1,o.current=!1},onInteractOutside:a=>{var c,u;(c=e.onInteractOutside)==null||c.call(e,a),a.defaultPrevented||(r.current=!0,a.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const i=a.target;((u=n.triggerRef.current)==null?void 0:u.contains(i))&&a.preventDefault(),a.detail.originalEvent.type==="focusin"&&o.current&&a.preventDefault()}})}),o0=d.forwardRef((e,t)=>{const{__scopePopover:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:a,disableOutsidePointerEvents:i,onEscapeKeyDown:l,onPointerDownOutside:c,onFocusOutside:u,onInteractOutside:f,...h}=e,m=Wo(Js,n),p=pi(n);return Av(),s.jsx(ci,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:a,children:s.jsx(tc,{asChild:!0,disableOutsidePointerEvents:i,onInteractOutside:f,onEscapeKeyDown:l,onPointerDownOutside:c,onFocusOutside:u,onDismiss:()=>m.onOpenChange(!1),children:s.jsx(KT,{"data-state":a0(m.open),role:"dialog",id:m.contentId,...p,...h,ref:t,style:{...h.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}})})})}),s0="PopoverClose",oA=d.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,o=Wo(s0,n);return s.jsx(rt.button,{type:"button",...r,ref:t,onClick:Ht(e.onClick,()=>o.onOpenChange(!1))})});oA.displayName=s0;var sA="PopoverArrow",aA=d.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,o=pi(n);return s.jsx(qT,{...o,...r,ref:t})});aA.displayName=sA;function a0(e){return e?"open":"closed"}var iA=Jw,lA=t0,cA=n0,uA=r0;function bc({...e}){return s.jsx(iA,{"data-slot":"popover",...e})}function yc({...e}){return s.jsx(lA,{"data-slot":"popover-trigger",...e})}function Cc({className:e,align:t="center",sideOffset:n=4,...r}){return s.jsx(cA,{children:s.jsx(uA,{"data-slot":"popover-content",align:t,sideOffset:n,className:ze("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 bg-background z-50 w-auto origin-(--radix-popover-content-transform-origin) rounded-sm border px-0 py-1 shadow-sm outline-hidden",e),...r})})}function dA({isOpen:e,onClose:t,anchorRef:n,children:r,placement:o="bottom-start",offset:a,className:i,closeOnClickOutside:l=!0,closeOnEscape:c=!0,portal:u=!0,animationDuration:f=150,fallbackPlacements:h}){const m=d.useRef(null),[p,x]=d.useState({}),[g,w]=d.useState(!1);YN({ref:m,anchorRef:n,onClickOutside:t,enabled:e&&l}),KN({onEscape:t,enabled:e&&c});const{getPositionStyle:v}=JN({anchorRef:n,placement:o,offset:a,fallbackPlacements:h});if(d.useEffect(()=>{e&&m.current?(w(!1),requestAnimationFrame(()=>{if(m.current){const C=v(m.current);x(C),w(!0)}})):w(!1)},[e,v]),!e)return null;const b=s.jsx("div",{ref:m,role:"dialog","aria-modal":"false",className:ze("bg-background min-w-[8rem] overflow-hidden border shadow-md",i),style:{...p,opacity:e&&g?1:0,transform:`scale(${e&&g?1:.95})`,transition:`opacity ${f}ms ease-in-out, transform ${f}ms ease-in-out`,pointerEvents:e&&g?"auto":"none",visibility:g?"visible":"hidden"},children:r});return u?ia.createPortal(b,document.body):b}function im(e,[t,n]){return Math.min(n,Math.max(t,e))}function xn(e,t,{checkForDefaultPrevented:n=!0}={}){return function(o){if(e==null||e(o),n===!1||!o.defaultPrevented)return t==null?void 0:t(o)}}var fA="DismissableLayer",hd="dismissableLayer.update",hA="dismissableLayer.pointerDownOutside",pA="dismissableLayer.focusOutside",lm,i0=d.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),l0=d.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:a,onInteractOutside:i,onDismiss:l,...c}=e,u=d.useContext(i0),[f,h]=d.useState(null),m=(f==null?void 0:f.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,p]=d.useState({}),x=mt(t,j=>h(j)),g=Array.from(u.layers),[w]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),v=g.indexOf(w),b=f?g.indexOf(f):-1,C=u.layersWithOutsidePointerEventsDisabled.size>0,S=b>=v,E=xA(j=>{const A=j.target,P=[...u.branches].some(O=>O.contains(A));!S||P||(o==null||o(j),i==null||i(j),j.defaultPrevented||l==null||l())},m),_=vA(j=>{const A=j.target;[...u.branches].some(O=>O.contains(A))||(a==null||a(j),i==null||i(j),j.defaultPrevented||l==null||l())},m);return sf(j=>{b===u.layers.size-1&&(r==null||r(j),!j.defaultPrevented&&l&&(j.preventDefault(),l()))},m),d.useEffect(()=>{if(f)return n&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(lm=m.body.style.pointerEvents,m.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(f)),u.layers.add(f),cm(),()=>{n&&u.layersWithOutsidePointerEventsDisabled.size===1&&(m.body.style.pointerEvents=lm)}},[f,m,n,u]),d.useEffect(()=>()=>{f&&(u.layers.delete(f),u.layersWithOutsidePointerEventsDisabled.delete(f),cm())},[f,u]),d.useEffect(()=>{const j=()=>p({});return document.addEventListener(hd,j),()=>document.removeEventListener(hd,j)},[]),s.jsx(rt.div,{...c,ref:x,style:{pointerEvents:C?S?"auto":"none":void 0,...e.style},onFocusCapture:xn(e.onFocusCapture,_.onFocusCapture),onBlurCapture:xn(e.onBlurCapture,_.onBlurCapture),onPointerDownCapture:xn(e.onPointerDownCapture,E.onPointerDownCapture)})});l0.displayName=fA;var mA="DismissableLayerBranch",gA=d.forwardRef((e,t)=>{const n=d.useContext(i0),r=d.useRef(null),o=mt(t,r);return d.useEffect(()=>{const a=r.current;if(a)return n.branches.add(a),()=>{n.branches.delete(a)}},[n.branches]),s.jsx(rt.div,{...e,ref:o})});gA.displayName=mA;function xA(e,t=globalThis==null?void 0:globalThis.document){const n=Mn(e),r=d.useRef(!1),o=d.useRef(()=>{});return d.useEffect(()=>{const a=l=>{if(l.target&&!r.current){let c=function(){c0(hA,n,u,{discrete:!0})};const u={originalEvent:l};l.pointerType==="touch"?(t.removeEventListener("click",o.current),o.current=c,t.addEventListener("click",o.current,{once:!0})):c()}else t.removeEventListener("click",o.current);r.current=!1},i=window.setTimeout(()=>{t.addEventListener("pointerdown",a)},0);return()=>{window.clearTimeout(i),t.removeEventListener("pointerdown",a),t.removeEventListener("click",o.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}function vA(e,t=globalThis==null?void 0:globalThis.document){const n=Mn(e),r=d.useRef(!1);return d.useEffect(()=>{const o=a=>{a.target&&!r.current&&c0(pA,n,{originalEvent:a},{discrete:!1})};return t.addEventListener("focusin",o),()=>t.removeEventListener("focusin",o)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function cm(){const e=new CustomEvent(hd);document.dispatchEvent(e)}function c0(e,t,n,{discrete:r}){const o=n.originalEvent.target,a=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&o.addEventListener(e,t,{once:!0}),r?ec(o,a):o.dispatchEvent(a)}var xu=0;function wA(){d.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??um()),document.body.insertAdjacentElement("beforeend",e[1]??um()),xu++,()=>{xu===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),xu--}},[])}function um(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var Kf="Popper",[u0,Sc]=mr(Kf),[bA,d0]=u0(Kf),f0=e=>{const{__scopePopper:t,children:n}=e,[r,o]=d.useState(null);return s.jsx(bA,{scope:t,anchor:r,onAnchorChange:o,children:n})};f0.displayName=Kf;var h0="PopperAnchor",p0=d.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,a=d0(h0,n),i=d.useRef(null),l=mt(t,i),c=d.useRef(null);return d.useEffect(()=>{const u=c.current;c.current=(r==null?void 0:r.current)||i.current,u!==c.current&&a.onAnchorChange(c.current)}),r?null:s.jsx(rt.div,{...o,ref:l})});p0.displayName=h0;var qf="PopperContent",[yA,CA]=u0(qf),m0=d.forwardRef((e,t)=>{var X,K,q,ne,de,se;const{__scopePopper:n,side:r="bottom",sideOffset:o=0,align:a="center",alignOffset:i=0,arrowPadding:l=0,avoidCollisions:c=!0,collisionBoundary:u=[],collisionPadding:f=0,sticky:h="partial",hideWhenDetached:m=!1,updatePositionStrategy:p="optimized",onPlaced:x,...g}=e,w=d0(qf,n),[v,b]=d.useState(null),C=mt(t,me=>b(me)),[S,E]=d.useState(null),_=Sf(S),j=(_==null?void 0:_.width)??0,A=(_==null?void 0:_.height)??0,P=r+(a!=="center"?"-"+a:""),O=typeof f=="number"?f:{top:0,right:0,bottom:0,left:0,...f},B=Array.isArray(u)?u:[u],N=B.length>0,M={padding:O,boundary:B.filter(_A),altBoundary:N},{refs:y,floatingStyles:T,placement:R,isPositioned:z,middlewareData:F}=pf({strategy:"fixed",placement:P,whileElementsMounted:(...me)=>hf(...me,{animationFrame:p==="always"}),elements:{reference:w.anchor},middleware:[mf({mainAxis:o+A,alignmentAxis:i}),c&&gf({mainAxis:!0,crossAxis:!1,limiter:h==="partial"?xf():void 0,...M}),c&&vf({...M}),wf({...M,apply:({elements:me,rects:k,availableWidth:oe,availableHeight:ie})=>{const{width:Z,height:U}=k.reference,re=me.floating.style;re.setProperty("--radix-popper-available-width",`${oe}px`),re.setProperty("--radix-popper-available-height",`${ie}px`),re.setProperty("--radix-popper-anchor-width",`${Z}px`),re.setProperty("--radix-popper-anchor-height",`${U}px`)}}),S&&yf({element:S,padding:l}),kA({arrowWidth:j,arrowHeight:A}),m&&bf({strategy:"referenceHidden",...M})]}),[I,J]=v0(R),L=Mn(x);ln(()=>{z&&(L==null||L())},[z,L]);const D=(X=F.arrow)==null?void 0:X.x,W=(K=F.arrow)==null?void 0:K.y,G=((q=F.arrow)==null?void 0:q.centerOffset)!==0,[V,Q]=d.useState();return ln(()=>{v&&Q(window.getComputedStyle(v).zIndex)},[v]),s.jsx("div",{ref:y.setFloating,"data-radix-popper-content-wrapper":"",style:{...T,transform:z?T.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:V,"--radix-popper-transform-origin":[(ne=F.transformOrigin)==null?void 0:ne.x,(de=F.transformOrigin)==null?void 0:de.y].join(" "),...((se=F.hide)==null?void 0:se.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:s.jsx(yA,{scope:n,placedSide:I,onArrowChange:E,arrowX:D,arrowY:W,shouldHideArrow:G,children:s.jsx(rt.div,{"data-side":I,"data-align":J,...g,ref:C,style:{...g.style,animation:z?void 0:"none"}})})})});m0.displayName=qf;var g0="PopperArrow",SA={top:"bottom",right:"left",bottom:"top",left:"right"},x0=d.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,a=CA(g0,r),i=SA[a.placedSide];return s.jsx("span",{ref:a.onArrowChange,style:{position:"absolute",left:a.arrowX,top:a.arrowY,[i]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[a.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[a.placedSide],visibility:a.shouldHideArrow?"hidden":void 0},children:s.jsx(Cf,{...o,ref:n,style:{...o.style,display:"block"}})})});x0.displayName=g0;function _A(e){return e!==null}var kA=e=>({name:"transformOrigin",options:e,fn(t){var w,v,b;const{placement:n,rects:r,middlewareData:o}=t,i=((w=o.arrow)==null?void 0:w.centerOffset)!==0,l=i?0:e.arrowWidth,c=i?0:e.arrowHeight,[u,f]=v0(n),h={start:"0%",center:"50%",end:"100%"}[f],m=(((v=o.arrow)==null?void 0:v.x)??0)+l/2,p=(((b=o.arrow)==null?void 0:b.y)??0)+c/2;let x="",g="";return u==="bottom"?(x=i?h:`${m}px`,g=`${-c}px`):u==="top"?(x=i?h:`${m}px`,g=`${r.floating.height+c}px`):u==="right"?(x=`${-c}px`,g=i?h:`${p}px`):u==="left"&&(x=`${r.floating.width+c}px`,g=i?h:`${p}px`),{data:{x,y:g}}}});function v0(e){const[t,n="center"]=e.split("-");return[t,n]}var w0=f0,b0=p0,y0=m0,C0=x0;function EA(e){const t=d.useRef({value:e,previous:e});return d.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var jA=[" ","Enter","ArrowUp","ArrowDown"],NA=[" ","Enter"],is="Select",[_c,kc,TA]=vc(is),[ma,j9]=mr(is,[TA,Sc]),Ec=Sc(),[AA,Ho]=ma(is),[IA,RA]=ma(is),S0=e=>{const{__scopeSelect:t,children:n,open:r,defaultOpen:o,onOpenChange:a,value:i,defaultValue:l,onValueChange:c,dir:u,name:f,autoComplete:h,disabled:m,required:p,form:x}=e,g=Ec(t),[w,v]=d.useState(null),[b,C]=d.useState(null),[S,E]=d.useState(!1),_=fi(u),[j,A]=xo({prop:r,defaultProp:o??!1,onChange:a,caller:is}),[P,O]=xo({prop:i,defaultProp:l,onChange:c,caller:is}),B=d.useRef(null),N=w?x||!!w.closest("form"):!0,[M,y]=d.useState(new Set),T=Array.from(M).map(R=>R.props.value).join(";");return s.jsx(w0,{...g,children:s.jsxs(AA,{required:p,scope:t,trigger:w,onTriggerChange:v,valueNode:b,onValueNodeChange:C,valueNodeHasChildren:S,onValueNodeHasChildrenChange:E,contentId:hr(),value:P,onValueChange:O,open:j,onOpenChange:A,dir:_,triggerPointerDownPosRef:B,disabled:m,children:[s.jsx(_c.Provider,{scope:t,children:s.jsx(IA,{scope:e.__scopeSelect,onNativeOptionAdd:d.useCallback(R=>{y(z=>new Set(z).add(R))},[]),onNativeOptionRemove:d.useCallback(R=>{y(z=>{const F=new Set(z);return F.delete(R),F})},[]),children:n})}),N?s.jsxs(H0,{"aria-hidden":!0,required:p,tabIndex:-1,name:f,autoComplete:h,value:P,onChange:R=>O(R.target.value),disabled:m,form:x,children:[P===void 0?s.jsx("option",{value:""}):null,Array.from(M)]},T):null]})})};S0.displayName=is;var _0="SelectTrigger",k0=d.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...o}=e,a=Ec(n),i=Ho(_0,n),l=i.disabled||r,c=mt(t,i.onTriggerChange),u=kc(n),f=d.useRef("touch"),[h,m,p]=G0(g=>{const w=u().filter(C=>!C.disabled),v=w.find(C=>C.value===i.value),b=Y0(w,g,v);b!==void 0&&i.onValueChange(b.value)}),x=g=>{l||(i.onOpenChange(!0),p()),g&&(i.triggerPointerDownPosRef.current={x:Math.round(g.pageX),y:Math.round(g.pageY)})};return s.jsx(b0,{asChild:!0,...a,children:s.jsx(rt.button,{type:"button",role:"combobox","aria-controls":i.contentId,"aria-expanded":i.open,"aria-required":i.required,"aria-autocomplete":"none",dir:i.dir,"data-state":i.open?"open":"closed",disabled:l,"data-disabled":l?"":void 0,"data-placeholder":Z0(i.value)?"":void 0,...o,ref:c,onClick:xn(o.onClick,g=>{g.currentTarget.focus(),f.current!=="mouse"&&x(g)}),onPointerDown:xn(o.onPointerDown,g=>{f.current=g.pointerType;const w=g.target;w.hasPointerCapture(g.pointerId)&&w.releasePointerCapture(g.pointerId),g.button===0&&g.ctrlKey===!1&&g.pointerType==="mouse"&&(x(g),g.preventDefault())}),onKeyDown:xn(o.onKeyDown,g=>{const w=h.current!=="";!(g.ctrlKey||g.altKey||g.metaKey)&&g.key.length===1&&m(g.key),!(w&&g.key===" ")&&jA.includes(g.key)&&(x(),g.preventDefault())})})})});k0.displayName=_0;var E0="SelectValue",j0=d.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,children:a,placeholder:i="",...l}=e,c=Ho(E0,n),{onValueNodeHasChildrenChange:u}=c,f=a!==void 0,h=mt(t,c.onValueNodeChange);return ln(()=>{u(f)},[u,f]),s.jsx(rt.span,{...l,ref:h,style:{pointerEvents:"none"},children:Z0(c.value)?s.jsx(s.Fragment,{children:i}):a})});j0.displayName=E0;var PA="SelectIcon",N0=d.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...o}=e;return s.jsx(rt.span,{"aria-hidden":!0,...o,ref:t,children:r||"▼"})});N0.displayName=PA;var MA="SelectPortal",T0=e=>s.jsx(pa,{asChild:!0,...e});T0.displayName=MA;var ls="SelectContent",A0=d.forwardRef((e,t)=>{const n=Ho(ls,e.__scopeSelect),[r,o]=d.useState();if(ln(()=>{o(new DocumentFragment)},[]),!n.open){const a=r;return a?ia.createPortal(s.jsx(I0,{scope:e.__scopeSelect,children:s.jsx(_c.Slot,{scope:e.__scopeSelect,children:s.jsx("div",{children:e.children})})}),a):null}return s.jsx(R0,{...e,ref:t})});A0.displayName=ls;var jr=10,[I0,Zo]=ma(ls),DA="SelectContentImpl",OA=Oo("SelectContent.RemoveScroll"),R0=d.forwardRef((e,t)=>{const{__scopeSelect:n,position:r="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:a,onPointerDownOutside:i,side:l,sideOffset:c,align:u,alignOffset:f,arrowPadding:h,collisionBoundary:m,collisionPadding:p,sticky:x,hideWhenDetached:g,avoidCollisions:w,...v}=e,b=Ho(ls,n),[C,S]=d.useState(null),[E,_]=d.useState(null),j=mt(t,X=>S(X)),[A,P]=d.useState(null),[O,B]=d.useState(null),N=kc(n),[M,y]=d.useState(!1),T=d.useRef(!1);d.useEffect(()=>{if(C)return fc(C)},[C]),wA();const R=d.useCallback(X=>{const[K,...q]=N().map(se=>se.ref.current),[ne]=q.slice(-1),de=document.activeElement;for(const se of X)if(se===de||(se==null||se.scrollIntoView({block:"nearest"}),se===K&&E&&(E.scrollTop=0),se===ne&&E&&(E.scrollTop=E.scrollHeight),se==null||se.focus(),document.activeElement!==de))return},[N,E]),z=d.useCallback(()=>R([A,C]),[R,A,C]);d.useEffect(()=>{M&&z()},[M,z]);const{onOpenChange:F,triggerPointerDownPosRef:I}=b;d.useEffect(()=>{if(C){let X={x:0,y:0};const K=ne=>{var de,se;X={x:Math.abs(Math.round(ne.pageX)-(((de=I.current)==null?void 0:de.x)??0)),y:Math.abs(Math.round(ne.pageY)-(((se=I.current)==null?void 0:se.y)??0))}},q=ne=>{X.x<=10&&X.y<=10?ne.preventDefault():C.contains(ne.target)||F(!1),document.removeEventListener("pointermove",K),I.current=null};return I.current!==null&&(document.addEventListener("pointermove",K),document.addEventListener("pointerup",q,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",K),document.removeEventListener("pointerup",q,{capture:!0})}}},[C,F,I]),d.useEffect(()=>{const X=()=>F(!1);return window.addEventListener("blur",X),window.addEventListener("resize",X),()=>{window.removeEventListener("blur",X),window.removeEventListener("resize",X)}},[F]);const[J,L]=G0(X=>{const K=N().filter(de=>!de.disabled),q=K.find(de=>de.ref.current===document.activeElement),ne=Y0(K,X,q);ne&&setTimeout(()=>ne.ref.current.focus())}),D=d.useCallback((X,K,q)=>{const ne=!T.current&&!q;(b.value!==void 0&&b.value===K||ne)&&(P(X),ne&&(T.current=!0))},[b.value]),W=d.useCallback(()=>C==null?void 0:C.focus(),[C]),G=d.useCallback((X,K,q)=>{const ne=!T.current&&!q;(b.value!==void 0&&b.value===K||ne)&&B(X)},[b.value]),V=r==="popper"?pd:P0,Q=V===pd?{side:l,sideOffset:c,align:u,alignOffset:f,arrowPadding:h,collisionBoundary:m,collisionPadding:p,sticky:x,hideWhenDetached:g,avoidCollisions:w}:{};return s.jsx(I0,{scope:n,content:C,viewport:E,onViewportChange:_,itemRefCallback:D,selectedItem:A,onItemLeave:W,itemTextRefCallback:G,focusSelectedItem:z,selectedItemText:O,position:r,isPositioned:M,searchRef:J,children:s.jsx(ui,{as:OA,allowPinchZoom:!0,children:s.jsx(ci,{asChild:!0,trapped:b.open,onMountAutoFocus:X=>{X.preventDefault()},onUnmountAutoFocus:xn(o,X=>{var K;(K=b.trigger)==null||K.focus({preventScroll:!0}),X.preventDefault()}),children:s.jsx(l0,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:a,onPointerDownOutside:i,onFocusOutside:X=>X.preventDefault(),onDismiss:()=>b.onOpenChange(!1),children:s.jsx(V,{role:"listbox",id:b.contentId,"data-state":b.open?"open":"closed",dir:b.dir,onContextMenu:X=>X.preventDefault(),...v,...Q,onPlaced:()=>y(!0),ref:j,style:{display:"flex",flexDirection:"column",outline:"none",...v.style},onKeyDown:xn(v.onKeyDown,X=>{const K=X.ctrlKey||X.altKey||X.metaKey;if(X.key==="Tab"&&X.preventDefault(),!K&&X.key.length===1&&L(X.key),["ArrowUp","ArrowDown","Home","End"].includes(X.key)){let ne=N().filter(de=>!de.disabled).map(de=>de.ref.current);if(["ArrowUp","End"].includes(X.key)&&(ne=ne.slice().reverse()),["ArrowUp","ArrowDown"].includes(X.key)){const de=X.target,se=ne.indexOf(de);ne=ne.slice(se+1)}setTimeout(()=>R(ne)),X.preventDefault()}})})})})})})});R0.displayName=DA;var LA="SelectItemAlignedPosition",P0=d.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...o}=e,a=Ho(ls,n),i=Zo(ls,n),[l,c]=d.useState(null),[u,f]=d.useState(null),h=mt(t,j=>f(j)),m=kc(n),p=d.useRef(!1),x=d.useRef(!0),{viewport:g,selectedItem:w,selectedItemText:v,focusSelectedItem:b}=i,C=d.useCallback(()=>{if(a.trigger&&a.valueNode&&l&&u&&g&&w&&v){const j=a.trigger.getBoundingClientRect(),A=u.getBoundingClientRect(),P=a.valueNode.getBoundingClientRect(),O=v.getBoundingClientRect();if(a.dir!=="rtl"){const de=O.left-A.left,se=P.left-de,me=j.left-se,k=j.width+me,oe=Math.max(k,A.width),ie=window.innerWidth-jr,Z=im(se,[jr,Math.max(jr,ie-oe)]);l.style.minWidth=k+"px",l.style.left=Z+"px"}else{const de=A.right-O.right,se=window.innerWidth-P.right-de,me=window.innerWidth-j.right-se,k=j.width+me,oe=Math.max(k,A.width),ie=window.innerWidth-jr,Z=im(se,[jr,Math.max(jr,ie-oe)]);l.style.minWidth=k+"px",l.style.right=Z+"px"}const B=m(),N=window.innerHeight-jr*2,M=g.scrollHeight,y=window.getComputedStyle(u),T=parseInt(y.borderTopWidth,10),R=parseInt(y.paddingTop,10),z=parseInt(y.borderBottomWidth,10),F=parseInt(y.paddingBottom,10),I=T+R+M+F+z,J=Math.min(w.offsetHeight*5,I),L=window.getComputedStyle(g),D=parseInt(L.paddingTop,10),W=parseInt(L.paddingBottom,10),G=j.top+j.height/2-jr,V=N-G,Q=w.offsetHeight/2,X=w.offsetTop+Q,K=T+R+X,q=I-K;if(K<=G){const de=B.length>0&&w===B[B.length-1].ref.current;l.style.bottom="0px";const se=u.clientHeight-g.offsetTop-g.offsetHeight,me=Math.max(V,Q+(de?W:0)+se+z),k=K+me;l.style.height=k+"px"}else{const de=B.length>0&&w===B[0].ref.current;l.style.top="0px";const me=Math.max(G,T+g.offsetTop+(de?D:0)+Q)+q;l.style.height=me+"px",g.scrollTop=K-G+g.offsetTop}l.style.margin=`${jr}px 0`,l.style.minHeight=J+"px",l.style.maxHeight=N+"px",r==null||r(),requestAnimationFrame(()=>p.current=!0)}},[m,a.trigger,a.valueNode,l,u,g,w,v,a.dir,r]);ln(()=>C(),[C]);const[S,E]=d.useState();ln(()=>{u&&E(window.getComputedStyle(u).zIndex)},[u]);const _=d.useCallback(j=>{j&&x.current===!0&&(C(),b==null||b(),x.current=!1)},[C,b]);return s.jsx($A,{scope:n,contentWrapper:l,shouldExpandOnScrollRef:p,onScrollButtonChange:_,children:s.jsx("div",{ref:c,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:S},children:s.jsx(rt.div,{...o,ref:h,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});P0.displayName=LA;var FA="SelectPopperPosition",pd=d.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:o=jr,...a}=e,i=Ec(n);return s.jsx(y0,{...i,...a,ref:t,align:r,collisionPadding:o,style:{boxSizing:"border-box",...a.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});pd.displayName=FA;var[$A,Xf]=ma(ls,{}),md="SelectViewport",M0=d.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...o}=e,a=Zo(md,n),i=Xf(md,n),l=mt(t,a.onViewportChange),c=d.useRef(0);return s.jsxs(s.Fragment,{children:[s.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:r}),s.jsx(_c.Slot,{scope:n,children:s.jsx(rt.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:l,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:xn(o.onScroll,u=>{const f=u.currentTarget,{contentWrapper:h,shouldExpandOnScrollRef:m}=i;if(m!=null&&m.current&&h){const p=Math.abs(c.current-f.scrollTop);if(p>0){const x=window.innerHeight-jr*2,g=parseFloat(h.style.minHeight),w=parseFloat(h.style.height),v=Math.max(g,w);if(v<x){const b=v+p,C=Math.min(x,b),S=b-C;h.style.height=C+"px",h.style.bottom==="0px"&&(f.scrollTop=S>0?S:0,h.style.justifyContent="flex-end")}}}c.current=f.scrollTop})})})]})});M0.displayName=md;var D0="SelectGroup",[zA,UA]=ma(D0),BA=d.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=hr();return s.jsx(zA,{scope:n,id:o,children:s.jsx(rt.div,{role:"group","aria-labelledby":o,...r,ref:t})})});BA.displayName=D0;var O0="SelectLabel",VA=d.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=UA(O0,n);return s.jsx(rt.div,{id:o.id,...r,ref:t})});VA.displayName=O0;var Rl="SelectItem",[WA,L0]=ma(Rl),F0=d.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:o=!1,textValue:a,...i}=e,l=Ho(Rl,n),c=Zo(Rl,n),u=l.value===r,[f,h]=d.useState(a??""),[m,p]=d.useState(!1),x=mt(t,b=>{var C;return(C=c.itemRefCallback)==null?void 0:C.call(c,b,r,o)}),g=hr(),w=d.useRef("touch"),v=()=>{o||(l.onValueChange(r),l.onOpenChange(!1))};if(r==="")throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return s.jsx(WA,{scope:n,value:r,disabled:o,textId:g,isSelected:u,onItemTextChange:d.useCallback(b=>{h(C=>C||((b==null?void 0:b.textContent)??"").trim())},[]),children:s.jsx(_c.ItemSlot,{scope:n,value:r,disabled:o,textValue:f,children:s.jsx(rt.div,{role:"option","aria-labelledby":g,"data-highlighted":m?"":void 0,"aria-selected":u&&m,"data-state":u?"checked":"unchecked","aria-disabled":o||void 0,"data-disabled":o?"":void 0,tabIndex:o?void 0:-1,...i,ref:x,onFocus:xn(i.onFocus,()=>p(!0)),onBlur:xn(i.onBlur,()=>p(!1)),onClick:xn(i.onClick,()=>{w.current!=="mouse"&&v()}),onPointerUp:xn(i.onPointerUp,()=>{w.current==="mouse"&&v()}),onPointerDown:xn(i.onPointerDown,b=>{w.current=b.pointerType}),onPointerMove:xn(i.onPointerMove,b=>{var C;w.current=b.pointerType,o?(C=c.onItemLeave)==null||C.call(c):w.current==="mouse"&&b.currentTarget.focus({preventScroll:!0})}),onPointerLeave:xn(i.onPointerLeave,b=>{var C;b.currentTarget===document.activeElement&&((C=c.onItemLeave)==null||C.call(c))}),onKeyDown:xn(i.onKeyDown,b=>{var S;((S=c.searchRef)==null?void 0:S.current)!==""&&b.key===" "||(NA.includes(b.key)&&v(),b.key===" "&&b.preventDefault())})})})})});F0.displayName=Rl;var Ia="SelectItemText",$0=d.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,...a}=e,i=Ho(Ia,n),l=Zo(Ia,n),c=L0(Ia,n),u=RA(Ia,n),[f,h]=d.useState(null),m=mt(t,v=>h(v),c.onItemTextChange,v=>{var b;return(b=l.itemTextRefCallback)==null?void 0:b.call(l,v,c.value,c.disabled)}),p=f==null?void 0:f.textContent,x=d.useMemo(()=>s.jsx("option",{value:c.value,disabled:c.disabled,children:p},c.value),[c.disabled,c.value,p]),{onNativeOptionAdd:g,onNativeOptionRemove:w}=u;return ln(()=>(g(x),()=>w(x)),[g,w,x]),s.jsxs(s.Fragment,{children:[s.jsx(rt.span,{id:c.textId,...a,ref:m}),c.isSelected&&i.valueNode&&!i.valueNodeHasChildren?ia.createPortal(a.children,i.valueNode):null]})});$0.displayName=Ia;var z0="SelectItemIndicator",U0=d.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return L0(z0,n).isSelected?s.jsx(rt.span,{"aria-hidden":!0,...r,ref:t}):null});U0.displayName=z0;var gd="SelectScrollUpButton",B0=d.forwardRef((e,t)=>{const n=Zo(gd,e.__scopeSelect),r=Xf(gd,e.__scopeSelect),[o,a]=d.useState(!1),i=mt(t,r.onScrollButtonChange);return ln(()=>{if(n.viewport&&n.isPositioned){let l=function(){const u=c.scrollTop>0;a(u)};const c=n.viewport;return l(),c.addEventListener("scroll",l),()=>c.removeEventListener("scroll",l)}},[n.viewport,n.isPositioned]),o?s.jsx(W0,{...e,ref:i,onAutoScroll:()=>{const{viewport:l,selectedItem:c}=n;l&&c&&(l.scrollTop=l.scrollTop-c.offsetHeight)}}):null});B0.displayName=gd;var xd="SelectScrollDownButton",V0=d.forwardRef((e,t)=>{const n=Zo(xd,e.__scopeSelect),r=Xf(xd,e.__scopeSelect),[o,a]=d.useState(!1),i=mt(t,r.onScrollButtonChange);return ln(()=>{if(n.viewport&&n.isPositioned){let l=function(){const u=c.scrollHeight-c.clientHeight,f=Math.ceil(c.scrollTop)<u;a(f)};const c=n.viewport;return l(),c.addEventListener("scroll",l),()=>c.removeEventListener("scroll",l)}},[n.viewport,n.isPositioned]),o?s.jsx(W0,{...e,ref:i,onAutoScroll:()=>{const{viewport:l,selectedItem:c}=n;l&&c&&(l.scrollTop=l.scrollTop+c.offsetHeight)}}):null});V0.displayName=xd;var W0=d.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...o}=e,a=Zo("SelectScrollButton",n),i=d.useRef(null),l=kc(n),c=d.useCallback(()=>{i.current!==null&&(window.clearInterval(i.current),i.current=null)},[]);return d.useEffect(()=>()=>c(),[c]),ln(()=>{var f;const u=l().find(h=>h.ref.current===document.activeElement);(f=u==null?void 0:u.ref.current)==null||f.scrollIntoView({block:"nearest"})},[l]),s.jsx(rt.div,{"aria-hidden":!0,...o,ref:t,style:{flexShrink:0,...o.style},onPointerDown:xn(o.onPointerDown,()=>{i.current===null&&(i.current=window.setInterval(r,50))}),onPointerMove:xn(o.onPointerMove,()=>{var u;(u=a.onItemLeave)==null||u.call(a),i.current===null&&(i.current=window.setInterval(r,50))}),onPointerLeave:xn(o.onPointerLeave,()=>{c()})})}),HA="SelectSeparator",ZA=d.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return s.jsx(rt.div,{"aria-hidden":!0,...r,ref:t})});ZA.displayName=HA;var vd="SelectArrow",GA=d.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=Ec(n),a=Ho(vd,n),i=Zo(vd,n);return a.open&&i.position==="popper"?s.jsx(C0,{...o,...r,ref:t}):null});GA.displayName=vd;var YA="SelectBubbleInput",H0=d.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{const o=d.useRef(null),a=mt(r,o),i=EA(t);return d.useEffect(()=>{const l=o.current;if(!l)return;const c=window.HTMLSelectElement.prototype,f=Object.getOwnPropertyDescriptor(c,"value").set;if(i!==t&&f){const h=new Event("change",{bubbles:!0});f.call(l,t),l.dispatchEvent(h)}},[i,t]),s.jsx(rt.select,{...n,style:{...lv,...n.style},ref:a,defaultValue:t})});H0.displayName=YA;function Z0(e){return e===""||e===void 0}function G0(e){const t=Mn(e),n=d.useRef(""),r=d.useRef(0),o=d.useCallback(i=>{const l=n.current+i;t(l),function c(u){n.current=u,window.clearTimeout(r.current),u!==""&&(r.current=window.setTimeout(()=>c(""),1e3))}(l)},[t]),a=d.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return d.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,o,a]}function Y0(e,t,n){const o=t.length>1&&Array.from(t).every(u=>u===t[0])?t[0]:t,a=n?e.indexOf(n):-1;let i=KA(e,Math.max(a,0));o.length===1&&(i=i.filter(u=>u!==n));const c=i.find(u=>u.textValue.toLowerCase().startsWith(o.toLowerCase()));return c!==n?c:void 0}function KA(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var qA=S0,XA=k0,JA=j0,QA=N0,eI=T0,tI=A0,nI=M0,rI=F0,oI=$0,sI=U0,aI=B0,iI=V0;function Rr({...e}){return s.jsx(qA,{"data-slot":"select",...e})}function Pr({...e}){return s.jsx(JA,{"data-slot":"select-value",...e})}function Mr({className:e,size:t="default",children:n,...r}){return s.jsxs(XA,{"data-slot":"select-trigger","data-size":t,className:ze("flex w-fit items-center justify-between gap-2 border px-3 py-2 text-sm whitespace-nowrap shadow-xs disabled:cursor-not-allowed disabled:opacity-50 data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e),...r,children:[n,s.jsx(QA,{asChild:!0,children:s.jsx(ml,{className:"size-4 opacity-50"})})]})}function Dr({className:e,children:t,position:n="popper",...r}){return s.jsx(eI,{children:s.jsxs(tI,{"data-slot":"select-content",className:ze("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 bg-background relative z-50 max-h-(--radix-select-content-available-height) min-w-[8rem] origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border",n==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:n,...r,children:[s.jsx(lI,{}),s.jsx(nI,{className:ze("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1"),children:t}),s.jsx(cI,{})]})})}function jt({className:e,children:t,...n}){return s.jsxs(rI,{"data-slot":"select-item",className:ze("[&_svg:not([class*='text-'])]:text-muted-foreground relative flex w-full cursor-default items-center gap-2 py-1.5 pr-8 pl-2 text-sm select-none hover:bg-[var(--color-primary-w10)] hover:text-[var(--color-primary-text-w60)] data-[disabled]:pointer-events-none data-[disabled]:opacity-50 dark:hover:bg-[var(--color-primary-w60)] dark:hover:text-[var(--color-primary-text-w10)] [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",e),...n,children:[s.jsx("span",{className:"absolute right-2 flex size-3.5 items-center justify-center",children:s.jsx(sI,{children:s.jsx(la,{className:"size-4"})})}),s.jsx(oI,{children:t})]})}function lI({className:e,...t}){return s.jsx(aI,{"data-slot":"select-scroll-up-button",className:ze("flex cursor-default items-center justify-center py-1",e),...t,children:s.jsx(Vu,{className:"size-4"})})}function cI({className:e,...t}){return s.jsx(iI,{"data-slot":"select-scroll-down-button",className:ze("flex cursor-default items-center justify-center py-1",e),...t,children:s.jsx(ml,{className:"size-4"})})}var vu="rovingFocusGroup.onEntryFocus",uI={bubbles:!1,cancelable:!0},mi="RovingFocusGroup",[wd,K0,dI]=vc(mi),[fI,q0]=mr(mi,[dI]),[hI,pI]=fI(mi),X0=d.forwardRef((e,t)=>s.jsx(wd.Provider,{scope:e.__scopeRovingFocusGroup,children:s.jsx(wd.Slot,{scope:e.__scopeRovingFocusGroup,children:s.jsx(mI,{...e,ref:t})})}));X0.displayName=mi;var mI=d.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:o=!1,dir:a,currentTabStopId:i,defaultCurrentTabStopId:l,onCurrentTabStopIdChange:c,onEntryFocus:u,preventScrollOnEntryFocus:f=!1,...h}=e,m=d.useRef(null),p=mt(t,m),x=fi(a),[g,w]=xo({prop:i,defaultProp:l??null,onChange:c,caller:mi}),[v,b]=d.useState(!1),C=Mn(u),S=K0(n),E=d.useRef(!1),[_,j]=d.useState(0);return d.useEffect(()=>{const A=m.current;if(A)return A.addEventListener(vu,C),()=>A.removeEventListener(vu,C)},[C]),s.jsx(hI,{scope:n,orientation:r,dir:x,loop:o,currentTabStopId:g,onItemFocus:d.useCallback(A=>w(A),[w]),onItemShiftTab:d.useCallback(()=>b(!0),[]),onFocusableItemAdd:d.useCallback(()=>j(A=>A+1),[]),onFocusableItemRemove:d.useCallback(()=>j(A=>A-1),[]),children:s.jsx(rt.div,{tabIndex:v||_===0?-1:0,"data-orientation":r,...h,ref:p,style:{outline:"none",...e.style},onMouseDown:Ht(e.onMouseDown,()=>{E.current=!0}),onFocus:Ht(e.onFocus,A=>{const P=!E.current;if(A.target===A.currentTarget&&P&&!v){const O=new CustomEvent(vu,uI);if(A.currentTarget.dispatchEvent(O),!O.defaultPrevented){const B=S().filter(R=>R.focusable),N=B.find(R=>R.active),M=B.find(R=>R.id===g),T=[N,M,...B].filter(Boolean).map(R=>R.ref.current);eb(T,f)}}E.current=!1}),onBlur:Ht(e.onBlur,()=>b(!1))})})}),J0="RovingFocusGroupItem",Q0=d.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:a,children:i,...l}=e,c=hr(),u=a||c,f=pI(J0,n),h=f.currentTabStopId===u,m=K0(n),{onFocusableItemAdd:p,onFocusableItemRemove:x,currentTabStopId:g}=f;return d.useEffect(()=>{if(r)return p(),()=>x()},[r,p,x]),s.jsx(wd.ItemSlot,{scope:n,id:u,focusable:r,active:o,children:s.jsx(rt.span,{tabIndex:h?0:-1,"data-orientation":f.orientation,...l,ref:t,onMouseDown:Ht(e.onMouseDown,w=>{r?f.onItemFocus(u):w.preventDefault()}),onFocus:Ht(e.onFocus,()=>f.onItemFocus(u)),onKeyDown:Ht(e.onKeyDown,w=>{if(w.key==="Tab"&&w.shiftKey){f.onItemShiftTab();return}if(w.target!==w.currentTarget)return;const v=vI(w,f.orientation,f.dir);if(v!==void 0){if(w.metaKey||w.ctrlKey||w.altKey||w.shiftKey)return;w.preventDefault();let C=m().filter(S=>S.focusable).map(S=>S.ref.current);if(v==="last")C.reverse();else if(v==="prev"||v==="next"){v==="prev"&&C.reverse();const S=C.indexOf(w.currentTarget);C=f.loop?wI(C,S+1):C.slice(S+1)}setTimeout(()=>eb(C))}}),children:typeof i=="function"?i({isCurrentTabStop:h,hasTabStop:g!=null}):i})})});Q0.displayName=J0;var gI={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function xI(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function vI(e,t,n){const r=xI(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return gI[r]}function eb(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function wI(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var bI=X0,yI=Q0,jc="Tabs",[CI,N9]=mr(jc,[q0]),tb=q0(),[SI,Jf]=CI(jc),nb=d.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,onValueChange:o,defaultValue:a,orientation:i="horizontal",dir:l,activationMode:c="automatic",...u}=e,f=fi(l),[h,m]=xo({prop:r,onChange:o,defaultProp:a??"",caller:jc});return s.jsx(SI,{scope:n,baseId:hr(),value:h,onValueChange:m,orientation:i,dir:f,activationMode:c,children:s.jsx(rt.div,{dir:f,"data-orientation":i,...u,ref:t})})});nb.displayName=jc;var rb="TabsList",ob=d.forwardRef((e,t)=>{const{__scopeTabs:n,loop:r=!0,...o}=e,a=Jf(rb,n),i=tb(n);return s.jsx(bI,{asChild:!0,...i,orientation:a.orientation,dir:a.dir,loop:r,children:s.jsx(rt.div,{role:"tablist","aria-orientation":a.orientation,...o,ref:t})})});ob.displayName=rb;var sb="TabsTrigger",ab=d.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,disabled:o=!1,...a}=e,i=Jf(sb,n),l=tb(n),c=cb(i.baseId,r),u=ub(i.baseId,r),f=r===i.value;return s.jsx(yI,{asChild:!0,...l,focusable:!o,active:f,children:s.jsx(rt.button,{type:"button",role:"tab","aria-selected":f,"aria-controls":u,"data-state":f?"active":"inactive","data-disabled":o?"":void 0,disabled:o,id:c,...a,ref:t,onMouseDown:Ht(e.onMouseDown,h=>{!o&&h.button===0&&h.ctrlKey===!1?i.onValueChange(r):h.preventDefault()}),onKeyDown:Ht(e.onKeyDown,h=>{[" ","Enter"].includes(h.key)&&i.onValueChange(r)}),onFocus:Ht(e.onFocus,()=>{const h=i.activationMode!=="manual";!f&&!o&&h&&i.onValueChange(r)})})})});ab.displayName=sb;var ib="TabsContent",lb=d.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,forceMount:o,children:a,...i}=e,l=Jf(ib,n),c=cb(l.baseId,r),u=ub(l.baseId,r),f=r===l.value,h=d.useRef(f);return d.useEffect(()=>{const m=requestAnimationFrame(()=>h.current=!1);return()=>cancelAnimationFrame(m)},[]),s.jsx(_o,{present:o||f,children:({present:m})=>s.jsx(rt.div,{"data-state":f?"active":"inactive","data-orientation":l.orientation,role:"tabpanel","aria-labelledby":c,hidden:!m,id:u,tabIndex:0,...i,ref:t,style:{...e.style,animationDuration:h.current?"0s":void 0},children:m&&a})})});lb.displayName=ib;function cb(e,t){return`${e}-trigger-${t}`}function ub(e,t){return`${e}-content-${t}`}var _I=nb,kI=ob,EI=ab,jI=lb;function NI({className:e,...t}){return s.jsx(_I,{"data-slot":"tabs",className:ze("flex flex-col gap-2",e),...t})}function TI({className:e,...t}){return s.jsx(kI,{"data-slot":"tabs-list",className:ze("bg-muted text-muted-foreground inline-flex h-9 w-fit items-center justify-center rounded-lg p-[3px]",e),...t})}function dm({className:e,...t}){return s.jsx(EI,{"data-slot":"tabs-trigger","data-testid":t.value,"aria-label":t.value,title:t.title,className:ze("data-[state=active]:bg-background dark:data-[state=active]:border-input dark:data-[state=active]:bg-input/30 focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:outline-ring text-foreground dark:text-muted-foreground inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-2 py-1 text-sm font-medium whitespace-nowrap transition-[color,box-shadow,background-color] hover:bg-[var(--color-brand-w10)] focus-visible:ring-[3px] focus-visible:outline-1 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:text-[var(--color-brand-wMain)] data-[state=active]:shadow-sm dark:hover:bg-[var(--color-brand-wMain30)] dark:data-[state=active]:text-[var(--color-brand-wMain)] [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e),...t})}function fm({className:e,...t}){return s.jsx(jI,{"data-slot":"tabs-content",className:ze("flex-1 outline-none",e),...t})}function Pl(e,t,{checkForDefaultPrevented:n=!0}={}){return function(o){if(e==null||e(o),n===!1||!o.defaultPrevented)return t==null?void 0:t(o)}}function en(e,t,{checkForDefaultPrevented:n=!0}={}){return function(o){if(e==null||e(o),n===!1||!o.defaultPrevented)return t==null?void 0:t(o)}}var AI="DismissableLayer",bd="dismissableLayer.update",II="dismissableLayer.pointerDownOutside",RI="dismissableLayer.focusOutside",hm,db=d.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),fb=d.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:a,onInteractOutside:i,onDismiss:l,...c}=e,u=d.useContext(db),[f,h]=d.useState(null),m=(f==null?void 0:f.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,p]=d.useState({}),x=mt(t,j=>h(j)),g=Array.from(u.layers),[w]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),v=g.indexOf(w),b=f?g.indexOf(f):-1,C=u.layersWithOutsidePointerEventsDisabled.size>0,S=b>=v,E=DI(j=>{const A=j.target,P=[...u.branches].some(O=>O.contains(A));!S||P||(o==null||o(j),i==null||i(j),j.defaultPrevented||l==null||l())},m),_=OI(j=>{const A=j.target;[...u.branches].some(O=>O.contains(A))||(a==null||a(j),i==null||i(j),j.defaultPrevented||l==null||l())},m);return sf(j=>{b===u.layers.size-1&&(r==null||r(j),!j.defaultPrevented&&l&&(j.preventDefault(),l()))},m),d.useEffect(()=>{if(f)return n&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(hm=m.body.style.pointerEvents,m.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(f)),u.layers.add(f),pm(),()=>{n&&u.layersWithOutsidePointerEventsDisabled.size===1&&(m.body.style.pointerEvents=hm)}},[f,m,n,u]),d.useEffect(()=>()=>{f&&(u.layers.delete(f),u.layersWithOutsidePointerEventsDisabled.delete(f),pm())},[f,u]),d.useEffect(()=>{const j=()=>p({});return document.addEventListener(bd,j),()=>document.removeEventListener(bd,j)},[]),s.jsx(rt.div,{...c,ref:x,style:{pointerEvents:C?S?"auto":"none":void 0,...e.style},onFocusCapture:en(e.onFocusCapture,_.onFocusCapture),onBlurCapture:en(e.onBlurCapture,_.onBlurCapture),onPointerDownCapture:en(e.onPointerDownCapture,E.onPointerDownCapture)})});fb.displayName=AI;var PI="DismissableLayerBranch",MI=d.forwardRef((e,t)=>{const n=d.useContext(db),r=d.useRef(null),o=mt(t,r);return d.useEffect(()=>{const a=r.current;if(a)return n.branches.add(a),()=>{n.branches.delete(a)}},[n.branches]),s.jsx(rt.div,{...e,ref:o})});MI.displayName=PI;function DI(e,t=globalThis==null?void 0:globalThis.document){const n=Mn(e),r=d.useRef(!1),o=d.useRef(()=>{});return d.useEffect(()=>{const a=l=>{if(l.target&&!r.current){let c=function(){hb(II,n,u,{discrete:!0})};const u={originalEvent:l};l.pointerType==="touch"?(t.removeEventListener("click",o.current),o.current=c,t.addEventListener("click",o.current,{once:!0})):c()}else t.removeEventListener("click",o.current);r.current=!1},i=window.setTimeout(()=>{t.addEventListener("pointerdown",a)},0);return()=>{window.clearTimeout(i),t.removeEventListener("pointerdown",a),t.removeEventListener("click",o.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}function OI(e,t=globalThis==null?void 0:globalThis.document){const n=Mn(e),r=d.useRef(!1);return d.useEffect(()=>{const o=a=>{a.target&&!r.current&&hb(RI,n,{originalEvent:a},{discrete:!1})};return t.addEventListener("focusin",o),()=>t.removeEventListener("focusin",o)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function pm(){const e=new CustomEvent(bd);document.dispatchEvent(e)}function hb(e,t,n,{discrete:r}){const o=n.originalEvent.target,a=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&o.addEventListener(e,t,{once:!0}),r?ec(o,a):o.dispatchEvent(a)}var wu=0;function LI(){d.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??mm()),document.body.insertAdjacentElement("beforeend",e[1]??mm()),wu++,()=>{wu===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),wu--}},[])}function mm(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}function FI(e,t){return d.useReducer((n,r)=>t[n][r]??n,e)}var gi=e=>{const{present:t,children:n}=e,r=$I(t),o=typeof n=="function"?n({present:r.isPresent}):d.Children.only(n),a=mt(r.ref,zI(o));return typeof n=="function"||r.isPresent?d.cloneElement(o,{ref:a}):null};gi.displayName="Presence";function $I(e){const[t,n]=d.useState(),r=d.useRef(null),o=d.useRef(e),a=d.useRef("none"),i=e?"mounted":"unmounted",[l,c]=FI(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return d.useEffect(()=>{const u=Bi(r.current);a.current=l==="mounted"?u:"none"},[l]),ln(()=>{const u=r.current,f=o.current;if(f!==e){const m=a.current,p=Bi(u);e?c("MOUNT"):p==="none"||(u==null?void 0:u.display)==="none"?c("UNMOUNT"):c(f&&m!==p?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,c]),ln(()=>{if(t){let u;const f=t.ownerDocument.defaultView??window,h=p=>{const g=Bi(r.current).includes(CSS.escape(p.animationName));if(p.target===t&&g&&(c("ANIMATION_END"),!o.current)){const w=t.style.animationFillMode;t.style.animationFillMode="forwards",u=f.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=w)})}},m=p=>{p.target===t&&(a.current=Bi(r.current))};return t.addEventListener("animationstart",m),t.addEventListener("animationcancel",h),t.addEventListener("animationend",h),()=>{f.clearTimeout(u),t.removeEventListener("animationstart",m),t.removeEventListener("animationcancel",h),t.removeEventListener("animationend",h)}}else c("ANIMATION_END")},[t,c]),{isPresent:["mounted","unmountSuspended"].includes(l),ref:d.useCallback(u=>{r.current=u?getComputedStyle(u):null,n(u)},[])}}function Bi(e){return(e==null?void 0:e.animationName)||"none"}function zI(e){var r,o;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(o=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}function Ws(e,t,{checkForDefaultPrevented:n=!0}={}){return function(o){if(e==null||e(o),n===!1||!o.defaultPrevented)return t==null?void 0:t(o)}}var bu="rovingFocusGroup.onEntryFocus",UI={bubbles:!1,cancelable:!0},xi="RovingFocusGroup",[yd,pb,BI]=vc(xi),[VI,mb]=mr(xi,[BI]),[WI,HI]=VI(xi),gb=d.forwardRef((e,t)=>s.jsx(yd.Provider,{scope:e.__scopeRovingFocusGroup,children:s.jsx(yd.Slot,{scope:e.__scopeRovingFocusGroup,children:s.jsx(ZI,{...e,ref:t})})}));gb.displayName=xi;var ZI=d.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:o=!1,dir:a,currentTabStopId:i,defaultCurrentTabStopId:l,onCurrentTabStopIdChange:c,onEntryFocus:u,preventScrollOnEntryFocus:f=!1,...h}=e,m=d.useRef(null),p=mt(t,m),x=fi(a),[g,w]=xo({prop:i,defaultProp:l??null,onChange:c,caller:xi}),[v,b]=d.useState(!1),C=Mn(u),S=pb(n),E=d.useRef(!1),[_,j]=d.useState(0);return d.useEffect(()=>{const A=m.current;if(A)return A.addEventListener(bu,C),()=>A.removeEventListener(bu,C)},[C]),s.jsx(WI,{scope:n,orientation:r,dir:x,loop:o,currentTabStopId:g,onItemFocus:d.useCallback(A=>w(A),[w]),onItemShiftTab:d.useCallback(()=>b(!0),[]),onFocusableItemAdd:d.useCallback(()=>j(A=>A+1),[]),onFocusableItemRemove:d.useCallback(()=>j(A=>A-1),[]),children:s.jsx(rt.div,{tabIndex:v||_===0?-1:0,"data-orientation":r,...h,ref:p,style:{outline:"none",...e.style},onMouseDown:Ws(e.onMouseDown,()=>{E.current=!0}),onFocus:Ws(e.onFocus,A=>{const P=!E.current;if(A.target===A.currentTarget&&P&&!v){const O=new CustomEvent(bu,UI);if(A.currentTarget.dispatchEvent(O),!O.defaultPrevented){const B=S().filter(R=>R.focusable),N=B.find(R=>R.active),M=B.find(R=>R.id===g),T=[N,M,...B].filter(Boolean).map(R=>R.ref.current);wb(T,f)}}E.current=!1}),onBlur:Ws(e.onBlur,()=>b(!1))})})}),xb="RovingFocusGroupItem",vb=d.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:a,children:i,...l}=e,c=hr(),u=a||c,f=HI(xb,n),h=f.currentTabStopId===u,m=pb(n),{onFocusableItemAdd:p,onFocusableItemRemove:x,currentTabStopId:g}=f;return d.useEffect(()=>{if(r)return p(),()=>x()},[r,p,x]),s.jsx(yd.ItemSlot,{scope:n,id:u,focusable:r,active:o,children:s.jsx(rt.span,{tabIndex:h?0:-1,"data-orientation":f.orientation,...l,ref:t,onMouseDown:Ws(e.onMouseDown,w=>{r?f.onItemFocus(u):w.preventDefault()}),onFocus:Ws(e.onFocus,()=>f.onItemFocus(u)),onKeyDown:Ws(e.onKeyDown,w=>{if(w.key==="Tab"&&w.shiftKey){f.onItemShiftTab();return}if(w.target!==w.currentTarget)return;const v=KI(w,f.orientation,f.dir);if(v!==void 0){if(w.metaKey||w.ctrlKey||w.altKey||w.shiftKey)return;w.preventDefault();let C=m().filter(S=>S.focusable).map(S=>S.ref.current);if(v==="last")C.reverse();else if(v==="prev"||v==="next"){v==="prev"&&C.reverse();const S=C.indexOf(w.currentTarget);C=f.loop?qI(C,S+1):C.slice(S+1)}setTimeout(()=>wb(C))}}),children:typeof i=="function"?i({isCurrentTabStop:h,hasTabStop:g!=null}):i})})});vb.displayName=xb;var GI={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function YI(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function KI(e,t,n){const r=YI(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return GI[r]}function wb(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function qI(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var XI=gb,JI=vb,Cd=["Enter"," "],QI=["ArrowDown","PageUp","Home"],bb=["ArrowUp","PageDown","End"],eR=[...QI,...bb],tR={ltr:[...Cd,"ArrowRight"],rtl:[...Cd,"ArrowLeft"]},nR={ltr:["ArrowLeft"],rtl:["ArrowRight"]},vi="Menu",[Ga,rR,oR]=vc(vi),[gs,yb]=mr(vi,[oR,Sc,mb]),Nc=Sc(),Cb=mb(),[sR,xs]=gs(vi),[aR,wi]=gs(vi),Sb=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:o,onOpenChange:a,modal:i=!0}=e,l=Nc(t),[c,u]=d.useState(null),f=d.useRef(!1),h=Mn(a),m=fi(o);return d.useEffect(()=>{const p=()=>{f.current=!0,document.addEventListener("pointerdown",x,{capture:!0,once:!0}),document.addEventListener("pointermove",x,{capture:!0,once:!0})},x=()=>f.current=!1;return document.addEventListener("keydown",p,{capture:!0}),()=>{document.removeEventListener("keydown",p,{capture:!0}),document.removeEventListener("pointerdown",x,{capture:!0}),document.removeEventListener("pointermove",x,{capture:!0})}},[]),s.jsx(w0,{...l,children:s.jsx(sR,{scope:t,open:n,onOpenChange:h,content:c,onContentChange:u,children:s.jsx(aR,{scope:t,onClose:d.useCallback(()=>h(!1),[h]),isUsingKeyboardRef:f,dir:m,modal:i,children:r})})})};Sb.displayName=vi;var iR="MenuAnchor",Qf=d.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=Nc(n);return s.jsx(b0,{...o,...r,ref:t})});Qf.displayName=iR;var eh="MenuPortal",[lR,_b]=gs(eh,{forceMount:void 0}),kb=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:o}=e,a=xs(eh,t);return s.jsx(lR,{scope:t,forceMount:n,children:s.jsx(gi,{present:n||a.open,children:s.jsx(pa,{asChild:!0,container:o,children:r})})})};kb.displayName=eh;var yr="MenuContent",[cR,th]=gs(yr),Eb=d.forwardRef((e,t)=>{const n=_b(yr,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,a=xs(yr,e.__scopeMenu),i=wi(yr,e.__scopeMenu);return s.jsx(Ga.Provider,{scope:e.__scopeMenu,children:s.jsx(gi,{present:r||a.open,children:s.jsx(Ga.Slot,{scope:e.__scopeMenu,children:i.modal?s.jsx(uR,{...o,ref:t}):s.jsx(dR,{...o,ref:t})})})})}),uR=d.forwardRef((e,t)=>{const n=xs(yr,e.__scopeMenu),r=d.useRef(null),o=mt(t,r);return d.useEffect(()=>{const a=r.current;if(a)return fc(a)},[]),s.jsx(nh,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:en(e.onFocusOutside,a=>a.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),dR=d.forwardRef((e,t)=>{const n=xs(yr,e.__scopeMenu);return s.jsx(nh,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),fR=Oo("MenuContent.ScrollLock"),nh=d.forwardRef((e,t)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:o,onOpenAutoFocus:a,onCloseAutoFocus:i,disableOutsidePointerEvents:l,onEntryFocus:c,onEscapeKeyDown:u,onPointerDownOutside:f,onFocusOutside:h,onInteractOutside:m,onDismiss:p,disableOutsideScroll:x,...g}=e,w=xs(yr,n),v=wi(yr,n),b=Nc(n),C=Cb(n),S=rR(n),[E,_]=d.useState(null),j=d.useRef(null),A=mt(t,j,w.onContentChange),P=d.useRef(0),O=d.useRef(""),B=d.useRef(0),N=d.useRef(null),M=d.useRef("right"),y=d.useRef(0),T=x?ui:d.Fragment,R=x?{as:fR,allowPinchZoom:!0}:void 0,z=I=>{var X,K;const J=O.current+I,L=S().filter(q=>!q.disabled),D=document.activeElement,W=(X=L.find(q=>q.ref.current===D))==null?void 0:X.textValue,G=L.map(q=>q.textValue),V=_R(G,J,W),Q=(K=L.find(q=>q.textValue===V))==null?void 0:K.ref.current;(function q(ne){O.current=ne,window.clearTimeout(P.current),ne!==""&&(P.current=window.setTimeout(()=>q(""),1e3))})(J),Q&&setTimeout(()=>Q.focus())};d.useEffect(()=>()=>window.clearTimeout(P.current),[]),LI();const F=d.useCallback(I=>{var L,D;return M.current===((L=N.current)==null?void 0:L.side)&&ER(I,(D=N.current)==null?void 0:D.area)},[]);return s.jsx(cR,{scope:n,searchRef:O,onItemEnter:d.useCallback(I=>{F(I)&&I.preventDefault()},[F]),onItemLeave:d.useCallback(I=>{var J;F(I)||((J=j.current)==null||J.focus(),_(null))},[F]),onTriggerLeave:d.useCallback(I=>{F(I)&&I.preventDefault()},[F]),pointerGraceTimerRef:B,onPointerGraceIntentChange:d.useCallback(I=>{N.current=I},[]),children:s.jsx(T,{...R,children:s.jsx(ci,{asChild:!0,trapped:o,onMountAutoFocus:en(a,I=>{var J;I.preventDefault(),(J=j.current)==null||J.focus({preventScroll:!0})}),onUnmountAutoFocus:i,children:s.jsx(fb,{asChild:!0,disableOutsidePointerEvents:l,onEscapeKeyDown:u,onPointerDownOutside:f,onFocusOutside:h,onInteractOutside:m,onDismiss:p,children:s.jsx(XI,{asChild:!0,...C,dir:v.dir,orientation:"vertical",loop:r,currentTabStopId:E,onCurrentTabStopIdChange:_,onEntryFocus:en(c,I=>{v.isUsingKeyboardRef.current||I.preventDefault()}),preventScrollOnEntryFocus:!0,children:s.jsx(y0,{role:"menu","aria-orientation":"vertical","data-state":Bb(w.open),"data-radix-menu-content":"",dir:v.dir,...b,...g,ref:A,style:{outline:"none",...g.style},onKeyDown:en(g.onKeyDown,I=>{const L=I.target.closest("[data-radix-menu-content]")===I.currentTarget,D=I.ctrlKey||I.altKey||I.metaKey,W=I.key.length===1;L&&(I.key==="Tab"&&I.preventDefault(),!D&&W&&z(I.key));const G=j.current;if(I.target!==G||!eR.includes(I.key))return;I.preventDefault();const Q=S().filter(X=>!X.disabled).map(X=>X.ref.current);bb.includes(I.key)&&Q.reverse(),CR(Q)}),onBlur:en(e.onBlur,I=>{I.currentTarget.contains(I.target)||(window.clearTimeout(P.current),O.current="")}),onPointerMove:en(e.onPointerMove,Ya(I=>{const J=I.target,L=y.current!==I.clientX;if(I.currentTarget.contains(J)&&L){const D=I.clientX>y.current?"right":"left";M.current=D,y.current=I.clientX}}))})})})})})})});Eb.displayName=yr;var hR="MenuGroup",rh=d.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return s.jsx(rt.div,{role:"group",...r,ref:t})});rh.displayName=hR;var pR="MenuLabel",jb=d.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return s.jsx(rt.div,{...r,ref:t})});jb.displayName=pR;var Ml="MenuItem",gm="menu.itemSelect",Tc=d.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...o}=e,a=d.useRef(null),i=wi(Ml,e.__scopeMenu),l=th(Ml,e.__scopeMenu),c=mt(t,a),u=d.useRef(!1),f=()=>{const h=a.current;if(!n&&h){const m=new CustomEvent(gm,{bubbles:!0,cancelable:!0});h.addEventListener(gm,p=>r==null?void 0:r(p),{once:!0}),ec(h,m),m.defaultPrevented?u.current=!1:i.onClose()}};return s.jsx(Nb,{...o,ref:c,disabled:n,onClick:en(e.onClick,f),onPointerDown:h=>{var m;(m=e.onPointerDown)==null||m.call(e,h),u.current=!0},onPointerUp:en(e.onPointerUp,h=>{var m;u.current||(m=h.currentTarget)==null||m.click()}),onKeyDown:en(e.onKeyDown,h=>{const m=l.searchRef.current!=="";n||m&&h.key===" "||Cd.includes(h.key)&&(h.currentTarget.click(),h.preventDefault())})})});Tc.displayName=Ml;var Nb=d.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:o,...a}=e,i=th(Ml,n),l=Cb(n),c=d.useRef(null),u=mt(t,c),[f,h]=d.useState(!1),[m,p]=d.useState("");return d.useEffect(()=>{const x=c.current;x&&p((x.textContent??"").trim())},[a.children]),s.jsx(Ga.ItemSlot,{scope:n,disabled:r,textValue:o??m,children:s.jsx(JI,{asChild:!0,...l,focusable:!r,children:s.jsx(rt.div,{role:"menuitem","data-highlighted":f?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...a,ref:u,onPointerMove:en(e.onPointerMove,Ya(x=>{r?i.onItemLeave(x):(i.onItemEnter(x),x.defaultPrevented||x.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:en(e.onPointerLeave,Ya(x=>i.onItemLeave(x))),onFocus:en(e.onFocus,()=>h(!0)),onBlur:en(e.onBlur,()=>h(!1))})})})}),mR="MenuCheckboxItem",Tb=d.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...o}=e;return s.jsx(Mb,{scope:e.__scopeMenu,checked:n,children:s.jsx(Tc,{role:"menuitemcheckbox","aria-checked":Dl(n)?"mixed":n,...o,ref:t,"data-state":sh(n),onSelect:en(o.onSelect,()=>r==null?void 0:r(Dl(n)?!0:!n),{checkForDefaultPrevented:!1})})})});Tb.displayName=mR;var Ab="MenuRadioGroup",[gR,xR]=gs(Ab,{value:void 0,onValueChange:()=>{}}),Ib=d.forwardRef((e,t)=>{const{value:n,onValueChange:r,...o}=e,a=Mn(r);return s.jsx(gR,{scope:e.__scopeMenu,value:n,onValueChange:a,children:s.jsx(rh,{...o,ref:t})})});Ib.displayName=Ab;var Rb="MenuRadioItem",Pb=d.forwardRef((e,t)=>{const{value:n,...r}=e,o=xR(Rb,e.__scopeMenu),a=n===o.value;return s.jsx(Mb,{scope:e.__scopeMenu,checked:a,children:s.jsx(Tc,{role:"menuitemradio","aria-checked":a,...r,ref:t,"data-state":sh(a),onSelect:en(r.onSelect,()=>{var i;return(i=o.onValueChange)==null?void 0:i.call(o,n)},{checkForDefaultPrevented:!1})})})});Pb.displayName=Rb;var oh="MenuItemIndicator",[Mb,vR]=gs(oh,{checked:!1}),Db=d.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...o}=e,a=vR(oh,n);return s.jsx(gi,{present:r||Dl(a.checked)||a.checked===!0,children:s.jsx(rt.span,{...o,ref:t,"data-state":sh(a.checked)})})});Db.displayName=oh;var wR="MenuSeparator",Ob=d.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return s.jsx(rt.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});Ob.displayName=wR;var bR="MenuArrow",Lb=d.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=Nc(n);return s.jsx(C0,{...o,...r,ref:t})});Lb.displayName=bR;var yR="MenuSub",[T9,Fb]=gs(yR),Ra="MenuSubTrigger",$b=d.forwardRef((e,t)=>{const n=xs(Ra,e.__scopeMenu),r=wi(Ra,e.__scopeMenu),o=Fb(Ra,e.__scopeMenu),a=th(Ra,e.__scopeMenu),i=d.useRef(null),{pointerGraceTimerRef:l,onPointerGraceIntentChange:c}=a,u={__scopeMenu:e.__scopeMenu},f=d.useCallback(()=>{i.current&&window.clearTimeout(i.current),i.current=null},[]);return d.useEffect(()=>f,[f]),d.useEffect(()=>{const h=l.current;return()=>{window.clearTimeout(h),c(null)}},[l,c]),s.jsx(Qf,{asChild:!0,...u,children:s.jsx(Nb,{id:o.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":o.contentId,"data-state":Bb(n.open),...e,ref:Ql(t,o.onTriggerChange),onClick:h=>{var m;(m=e.onClick)==null||m.call(e,h),!(e.disabled||h.defaultPrevented)&&(h.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:en(e.onPointerMove,Ya(h=>{a.onItemEnter(h),!h.defaultPrevented&&!e.disabled&&!n.open&&!i.current&&(a.onPointerGraceIntentChange(null),i.current=window.setTimeout(()=>{n.onOpenChange(!0),f()},100))})),onPointerLeave:en(e.onPointerLeave,Ya(h=>{var p,x;f();const m=(p=n.content)==null?void 0:p.getBoundingClientRect();if(m){const g=(x=n.content)==null?void 0:x.dataset.side,w=g==="right",v=w?-5:5,b=m[w?"left":"right"],C=m[w?"right":"left"];a.onPointerGraceIntentChange({area:[{x:h.clientX+v,y:h.clientY},{x:b,y:m.top},{x:C,y:m.top},{x:C,y:m.bottom},{x:b,y:m.bottom}],side:g}),window.clearTimeout(l.current),l.current=window.setTimeout(()=>a.onPointerGraceIntentChange(null),300)}else{if(a.onTriggerLeave(h),h.defaultPrevented)return;a.onPointerGraceIntentChange(null)}})),onKeyDown:en(e.onKeyDown,h=>{var p;const m=a.searchRef.current!=="";e.disabled||m&&h.key===" "||tR[r.dir].includes(h.key)&&(n.onOpenChange(!0),(p=n.content)==null||p.focus(),h.preventDefault())})})})});$b.displayName=Ra;var zb="MenuSubContent",Ub=d.forwardRef((e,t)=>{const n=_b(yr,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,a=xs(yr,e.__scopeMenu),i=wi(yr,e.__scopeMenu),l=Fb(zb,e.__scopeMenu),c=d.useRef(null),u=mt(t,c);return s.jsx(Ga.Provider,{scope:e.__scopeMenu,children:s.jsx(gi,{present:r||a.open,children:s.jsx(Ga.Slot,{scope:e.__scopeMenu,children:s.jsx(nh,{id:l.contentId,"aria-labelledby":l.triggerId,...o,ref:u,align:"start",side:i.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:f=>{var h;i.isUsingKeyboardRef.current&&((h=c.current)==null||h.focus()),f.preventDefault()},onCloseAutoFocus:f=>f.preventDefault(),onFocusOutside:en(e.onFocusOutside,f=>{f.target!==l.trigger&&a.onOpenChange(!1)}),onEscapeKeyDown:en(e.onEscapeKeyDown,f=>{i.onClose(),f.preventDefault()}),onKeyDown:en(e.onKeyDown,f=>{var p;const h=f.currentTarget.contains(f.target),m=nR[i.dir].includes(f.key);h&&m&&(a.onOpenChange(!1),(p=l.trigger)==null||p.focus(),f.preventDefault())})})})})})});Ub.displayName=zb;function Bb(e){return e?"open":"closed"}function Dl(e){return e==="indeterminate"}function sh(e){return Dl(e)?"indeterminate":e?"checked":"unchecked"}function CR(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function SR(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function _R(e,t,n){const o=t.length>1&&Array.from(t).every(u=>u===t[0])?t[0]:t,a=n?e.indexOf(n):-1;let i=SR(e,Math.max(a,0));o.length===1&&(i=i.filter(u=>u!==n));const c=i.find(u=>u.toLowerCase().startsWith(o.toLowerCase()));return c!==n?c:void 0}function kR(e,t){const{x:n,y:r}=e;let o=!1;for(let a=0,i=t.length-1;a<t.length;i=a++){const l=t[a],c=t[i],u=l.x,f=l.y,h=c.x,m=c.y;f>r!=m>r&&n<(h-u)*(r-f)/(m-f)+u&&(o=!o)}return o}function ER(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return kR(n,t)}function Ya(e){return t=>t.pointerType==="mouse"?e(t):void 0}var jR=Sb,NR=Qf,TR=kb,AR=Eb,IR=rh,RR=jb,PR=Tc,MR=Tb,DR=Ib,OR=Pb,LR=Db,FR=Ob,$R=Lb,zR=$b,UR=Ub,Ac="DropdownMenu",[BR,A9]=mr(Ac,[yb]),Kn=yb(),[VR,Vb]=BR(Ac),Wb=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:o,defaultOpen:a,onOpenChange:i,modal:l=!0}=e,c=Kn(t),u=d.useRef(null),[f,h]=xo({prop:o,defaultProp:a??!1,onChange:i,caller:Ac});return s.jsx(VR,{scope:t,triggerId:hr(),triggerRef:u,contentId:hr(),open:f,onOpenChange:h,onOpenToggle:d.useCallback(()=>h(m=>!m),[h]),modal:l,children:s.jsx(jR,{...c,open:f,onOpenChange:h,dir:r,modal:l,children:n})})};Wb.displayName=Ac;var Hb="DropdownMenuTrigger",Zb=d.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...o}=e,a=Vb(Hb,n),i=Kn(n);return s.jsx(NR,{asChild:!0,...i,children:s.jsx(rt.button,{type:"button",id:a.triggerId,"aria-haspopup":"menu","aria-expanded":a.open,"aria-controls":a.open?a.contentId:void 0,"data-state":a.open?"open":"closed","data-disabled":r?"":void 0,disabled:r,...o,ref:Ql(t,a.triggerRef),onPointerDown:Pl(e.onPointerDown,l=>{!r&&l.button===0&&l.ctrlKey===!1&&(a.onOpenToggle(),a.open||l.preventDefault())}),onKeyDown:Pl(e.onKeyDown,l=>{r||(["Enter"," "].includes(l.key)&&a.onOpenToggle(),l.key==="ArrowDown"&&a.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(l.key)&&l.preventDefault())})})})});Zb.displayName=Hb;var WR="DropdownMenuPortal",Gb=e=>{const{__scopeDropdownMenu:t,...n}=e,r=Kn(t);return s.jsx(TR,{...r,...n})};Gb.displayName=WR;var Yb="DropdownMenuContent",Kb=d.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Vb(Yb,n),a=Kn(n),i=d.useRef(!1);return s.jsx(AR,{id:o.contentId,"aria-labelledby":o.triggerId,...a,...r,ref:t,onCloseAutoFocus:Pl(e.onCloseAutoFocus,l=>{var c;i.current||(c=o.triggerRef.current)==null||c.focus(),i.current=!1,l.preventDefault()}),onInteractOutside:Pl(e.onInteractOutside,l=>{const c=l.detail.originalEvent,u=c.button===0&&c.ctrlKey===!0,f=c.button===2||u;(!o.modal||f)&&(i.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});Kb.displayName=Yb;var HR="DropdownMenuGroup",ZR=d.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Kn(n);return s.jsx(IR,{...o,...r,ref:t})});ZR.displayName=HR;var GR="DropdownMenuLabel",YR=d.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Kn(n);return s.jsx(RR,{...o,...r,ref:t})});YR.displayName=GR;var KR="DropdownMenuItem",qb=d.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Kn(n);return s.jsx(PR,{...o,...r,ref:t})});qb.displayName=KR;var qR="DropdownMenuCheckboxItem",XR=d.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Kn(n);return s.jsx(MR,{...o,...r,ref:t})});XR.displayName=qR;var JR="DropdownMenuRadioGroup",QR=d.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Kn(n);return s.jsx(DR,{...o,...r,ref:t})});QR.displayName=JR;var eP="DropdownMenuRadioItem",tP=d.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Kn(n);return s.jsx(OR,{...o,...r,ref:t})});tP.displayName=eP;var nP="DropdownMenuItemIndicator",rP=d.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Kn(n);return s.jsx(LR,{...o,...r,ref:t})});rP.displayName=nP;var oP="DropdownMenuSeparator",Xb=d.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Kn(n);return s.jsx(FR,{...o,...r,ref:t})});Xb.displayName=oP;var sP="DropdownMenuArrow",aP=d.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Kn(n);return s.jsx($R,{...o,...r,ref:t})});aP.displayName=sP;var iP="DropdownMenuSubTrigger",lP=d.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Kn(n);return s.jsx(zR,{...o,...r,ref:t})});lP.displayName=iP;var cP="DropdownMenuSubContent",uP=d.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Kn(n);return s.jsx(UR,{...o,...r,ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});uP.displayName=cP;var dP=Wb,fP=Zb,hP=Gb,pP=Kb,mP=qb,gP=Xb;function Qs({...e}){return s.jsx(dP,{"data-slot":"dropdown-menu",...e})}function ea({...e}){return s.jsx(fP,{"data-slot":"dropdown-menu-trigger",...e})}function ta({className:e,sideOffset:t=4,...n}){return s.jsx(hP,{children:s.jsx(pP,{"data-slot":"dropdown-menu-content",sideOffset:t,className:ze("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 max-h-(--radix-dropdown-menu-content-available-height) min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border p-1 shadow-md",e),...n})})}function jn({className:e,inset:t,variant:n="default",...r}){return s.jsx(mP,{"data-slot":"dropdown-menu-item","data-inset":t,"data-variant":n,className:ze("focus:bg-accent focus:text-accent-foreground data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 dark:data-[variant=destructive]:focus:bg-destructive/20 data-[variant=destructive]:focus:text-destructive data-[variant=destructive]:*:[svg]:!text-destructive [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[inset]:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e),...r})}function xm({className:e,...t}){return s.jsx(gP,{"data-slot":"dropdown-menu-separator",className:ze("bg-border -mx-1 my-1 h-px",e),...t})}function xP({className:e,...t}){return s.jsx("div",{"data-slot":"table-container",className:"relative w-full overflow-x-auto",children:s.jsx("table",{"data-slot":"table",className:ze("w-full caption-bottom text-sm",e),...t})})}function vP({className:e,...t}){return s.jsx("tbody",{"data-slot":"table-body",className:ze("[&_tr:last-child]:border-0",e),...t})}function wP({className:e,...t}){return s.jsx("tr",{"data-slot":"table-row",className:ze("hover:bg-muted/50 data-[state=selected]:bg-muted border-b transition-colors",e),...t})}function vm({className:e,...t}){return s.jsx("td",{"data-slot":"table-cell",className:ze("p-2 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",e),...t})}const Jb=d.forwardRef(({className:e,...t},n)=>s.jsx(Wr,{autoComplete:"off",ref:n,name:"message","data-testid":"chat-input",className:ze("bg-card flex w-full items-center rounded-md px-4 py-3 placeholder:text-[var(--color-secondary-wMain)] disabled:cursor-not-allowed disabled:opacity-50",e),...t}));Jb.displayName="ChatInput";const bP=Uo("flex gap-2 max-w-full items-end relative group",{variants:{variant:{received:"self-start",sent:"self-end flex-row-reverse"},layout:{default:"",ai:"max-w-full w-full items-center"}},defaultVariants:{variant:"received",layout:"default"}}),Qb=d.forwardRef(({className:e,variant:t,layout:n,children:r,...o},a)=>s.jsx("div",{className:ze(bP({variant:t,layout:n,className:e}),"group relative"),ref:a,...o,children:d.Children.map(r,i=>d.isValidElement(i)&&typeof i.type!="string"?d.cloneElement(i,{variant:t,layout:n}):i)}));Qb.displayName="ChatBubble";const yP=Uo("",{variants:{variant:{received:"rounded-r-lg rounded-tl-lg",sent:"rounded-l-lg rounded-tr-lg justify-end bg-[var(--message-background)] p-4"},layout:{default:"",ai:"border-t w-full rounded-none bg-transparent"}},defaultVariants:{variant:"received",layout:"default"}}),ey=d.forwardRef(({className:e,variant:t,layout:n,children:r,...o},a)=>s.jsx("div",{className:ze(yP({variant:t,layout:n,className:e}),"relative max-w-full leading-[150%] break-words"),ref:a,...o,children:s.jsx(s.Fragment,{children:r})}));ey.displayName="ChatBubbleMessage";const CP=d.forwardRef(({variant:e,className:t,children:n,...r},o)=>s.jsx("div",{ref:o,className:ze("absolute top-1/2 flex -translate-y-1/2 opacity-0 transition-opacity duration-200 group-hover:opacity-100",e==="sent"?"-left-1 -translate-x-full flex-row-reverse":"-right-1 translate-x-full",t),...r,children:n}));CP.displayName="ChatBubbleActionWrapper";const ty={padding:"0 16px",maxWidth:"1280px",minWidth:"400px",margin:"0 auto",width:"100%"},ny=Rt.forwardRef(({className:e="",children:t,...n},r)=>{const o=Rt.useRef(null),{scrollRef:a,isAtBottom:i,disableAutoScroll:l,scrollToBottom:c,userHasScrolled:u}=AP({smooth:!0,content:t,contentRef:o});return d.useImperativeHandle(r,()=>({scrollToBottom:c})),s.jsxs("div",{className:`fade-both-mask relative h-full min-h-0 w-full flex-1 py-3 ${e}`,children:[s.jsx("div",{className:"flex h-full w-full flex-col overflow-y-auto p-4",ref:a,onWheel:l,onTouchMove:l,...n,style:{scrollBehavior:"smooth"},children:s.jsx("div",{className:"flex flex-col gap-6",style:ty,ref:o,children:t})}),!i&&u&&s.jsx(xe,{onClick:()=>{c()},size:"icon",variant:"outline",className:"bg-background absolute bottom-2 left-1/2 z-20 inline-flex -translate-x-1/2 transform rounded-full shadow-md","aria-label":"Scroll to bottom",children:s.jsx(Mg,{className:"h-4 w-4"})})]})});ny.displayName="ChatMessageList";function SP({className:e=""}){return s.jsx(no,{size:"small",variant:"primary",className:e})}const Vi={error:"bg-[var(--color-error-w10)] text-[var(--color-error-wMain)] border-[var(--color-error-wMain)] dark:bg-[var(--color-error-wMain)] dark:text-[var(--color-primary-text-w10)] dark:border-[var(--color-error-w10)]",warning:"bg-[var(--color-warning-w10)] text-[var(--color-warning-wMain)] border-[var(--color-warning-wMain)] dark:bg-[var(--color-warning-wMain)] dark:text-[var(--color-primary-text-w10)] dark:border-[var(--color-warning-w10)]",info:"bg-[var(--color-info-w10)] text-[var(--color-info-wMain)] border-[var(--color-info-w10)] dark:bg-[var(--color-info-wMain)] dark:text-[var(--color-primary-text-w10)] dark:border-[var(--color-info-w10)]",success:"bg-[var(--color-success-w10)] text-[var(--color-success-wMain)] border-[var(--color-success-w10)] dark:bg-[var(--color-success-wMain)] dark:text-[var(--color-primary-text-w10)] dark:border-[var(--color-success-wMain)]"},_P=Uo("inline-flex items-center justify-center rounded-md border px-2 py-0.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-none transition-[color,box-shadow] overflow-hidden",{variants:{variant:{default:"border-transparent [a&]:hover:bg-primary/90",secondary:"border-transparent [a&]:hover:bg-secondary/90",destructive:"border-transparent [a&]:hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground"},type:{error:Vi.error,warning:Vi.warning,info:Vi.info,success:Vi.success}},defaultVariants:{variant:"default"}});function zr({className:e,variant:t,type:n,asChild:r=!1,...o}){const a=r?kx:"span";return s.jsx(a,{"data-slot":"badge",className:ze(_P({variant:t,type:n}),e),...o})}const kP=Uo("relative w-full rounded-lg border px-4 py-3 text-sm grid has-[>svg]:grid-cols-[calc(var(--spacing)*4)_1fr] grid-cols-[0_1fr] has-[>svg]:gap-x-3 gap-y-0.5 items-start [&>svg]:size-4 [&>svg]:translate-y-0.5 [&>svg]:text-current",{variants:{variant:{default:"bg-card text-card-foreground",destructive:"text-destructive bg-card [&>svg]:text-current *:data-[slot=alert-description]:text-destructive/90"}},defaultVariants:{variant:"default"}});function EP({className:e,variant:t,...n}){return s.jsx("div",{"data-slot":"alert",role:"alert",className:ze(kP({variant:t}),e),...n})}function jP({className:e,...t}){return s.jsx("div",{"data-slot":"alert-title",className:ze("col-start-2 line-clamp-1 min-h-4 font-medium tracking-tight",e),...t})}function NP({id:e,message:t,type:n}){return s.jsx("div",{id:e,className:"transform transition-all duration-200 ease-in-out",children:s.jsx(EP,{className:"light:border-none dark:border-border max-w-80 min-w-58 rounded-sm bg-[var(--color-background-wMain)] px-4 py-0 text-white shadow-[0_4px_6px_-1px_rgba(0,0,0,0.15)] dark:shadow-[0_4px_6px_-1px_rgba(255,255,255,0.1)]",children:s.jsxs(jP,{className:"flex h-10 items-center",children:[n==="warning"&&s.jsx(Wd,{className:"mr-2 text-[var(--color-warning-wMain)]"}),n==="success"&&s.jsx(Hd,{className:"mr-2 text-[var(--color-success-wMain)]"}),s.jsx("div",{className:"truncate",children:t})]})})})}function TP(){const{notifications:e}=Ft();return e.length===0?null:s.jsx("div",{className:"pointer-events-none fixed bottom-4 left-1/2 z-50 flex -translate-x-1/2 transform flex-col-reverse gap-2",children:e.map(t=>s.jsx("div",{className:"pointer-events-auto",children:s.jsx(NP,{id:t.id,message:t.message,type:t.type})},t.id))})}function AP(e={}){const{offset:t=20,smooth:n=!1,content:r,autoScrollOnNewContent:o=!1,contentRef:a}=e,i=d.useRef(null),l=d.useRef(0),c=d.useRef(!1),u=d.useRef(0),f=d.useRef(!1),h=d.useRef(!1),[m,p]=d.useState({isAtBottom:!0,autoScrollEnabled:!0}),x=d.useCallback(b=>{const{scrollTop:C,scrollHeight:S,clientHeight:E}=b;return Math.abs(S-C-E)<=t},[t]),g=d.useCallback(b=>{if(!i.current)return;h.current=!0;const C=i.current.scrollHeight-i.current.clientHeight;b?i.current.scrollTop=C:i.current.scrollTo({top:C,behavior:n?"smooth":"auto"}),f.current=!1,p({isAtBottom:!0,autoScrollEnabled:!0}),c.current=!1,setTimeout(()=>{i.current&&(u.current=i.current.scrollTop),h.current=!1},b?50:500)},[n]),w=d.useCallback(()=>{if(!i.current||h.current)return;const b=i.current.scrollTop,C=x(i.current);u.current>0&&b<u.current&&(f.current=!0),u.current=b,C?(f.current=!1,p(()=>({isAtBottom:!0,autoScrollEnabled:!0}))):f.current?p(()=>({isAtBottom:!1,autoScrollEnabled:!1})):p(E=>({...E,isAtBottom:!1}))},[x]);d.useEffect(()=>{const b=i.current;if(b)return b.addEventListener("scroll",w,{passive:!0}),()=>b.removeEventListener("scroll",w)},[w]),d.useEffect(()=>{const b=i.current;if(!b)return;const C=b.scrollHeight;C!==l.current&&((m.autoScrollEnabled||o)&&requestAnimationFrame(()=>{g(l.current===0)}),l.current=C)},[r,m.autoScrollEnabled,g,o]),d.useEffect(()=>{const b=(a==null?void 0:a.current)||i.current;if(!b)return;const C=new ResizeObserver(()=>{m.autoScrollEnabled&&g(!0)});return C.observe(b),()=>C.disconnect()},[m.autoScrollEnabled,g,a]);const v=d.useCallback(()=>{(i.current?x(i.current):!1)||(c.current=!0,p(C=>({...C,autoScrollEnabled:!1})))},[x]);return{scrollRef:i,isAtBottom:m.isAtBottom,autoScrollEnabled:m.autoScrollEnabled,scrollToBottom:()=>g(),disableAutoScroll:v,userHasScrolled:c.current}}const IP=({isOpen:e,position:t,selectedText:n,onClose:r})=>{const o=d.useRef(null);d.useEffect(()=>{if(!e)return;const i=u=>{o.current&&!o.current.contains(u.target)&&r()},l=u=>{u.key==="Escape"&&r()},c=()=>{r()};return setTimeout(()=>{document.addEventListener("mousedown",i),document.addEventListener("keydown",l),window.addEventListener("scroll",c,!0)},100),()=>{document.removeEventListener("mousedown",i),document.removeEventListener("keydown",l),window.removeEventListener("scroll",c,!0)}},[e,r]);const a=()=>{window.dispatchEvent(new CustomEvent("follow-up-question",{detail:{text:n,prompt:"",autoSubmit:!1}})),r()};return!e||!t?null:s.jsx("div",{ref:o,className:"animate-in fade-in-0 zoom-in-95 fixed z-50 duration-200",style:{left:`${t.x}px`,top:`${t.y}px`},children:s.jsx("div",{className:"bg-background w-auto max-w-[160px] rounded-md border p-1 shadow-lg",children:s.jsxs(xe,{variant:"ghost",className:"h-auto w-full justify-start gap-1.5 px-2 py-1.5 text-xs font-normal",onClick:a,children:[s.jsx(Dg,{className:"h-3.5 w-3.5 flex-shrink-0"}),s.jsx("span",{className:"truncate",children:"Ask Followup"})]})})})};function RP(){const e=window.getSelection();return!e||e.rangeCount===0?null:e.toString().trim()||null}function ry(){const e=window.getSelection();return!e||e.rangeCount===0?null:e.getRangeAt(0)}function PP(){const e=ry();return e?e.getBoundingClientRect():null}function MP(e){let o=e.left,a=e.top-40-8;return o+160>window.innerWidth&&(o=window.innerWidth-160-8),o<8&&(o=8),a<8&&(a=e.bottom+8),{x:o,y:a}}function DP(e){if(!e)return!1;const t=e.trim();return t.length>=3&&/\S/.test(t)}const OP=({messageId:e,children:t,isAIMessage:n})=>{const{setSelection:r,clearSelection:o}=_x(),a=d.useRef(null),i=d.useCallback(()=>{n&&setTimeout(()=>{const l=RP(),c=ry(),u=PP();if(!DP(l)||!c||!u||!l)return;const f=a.current;if(!f||!c.intersectsNode(f))return;const h=MP(u);r(l,c,e,h)},10)},[n,e,r]);return d.useEffect(()=>{if(!(!a.current||!n))return document.addEventListener("mouseup",i),()=>{document.removeEventListener("mouseup",i)}},[i,n]),d.useEffect(()=>()=>{o()},[o]),s.jsx("div",{ref:a,className:"selectable-message-content",children:t})},ah=d.forwardRef(({disabled:e=!1,onTranscriptionComplete:t,onError:n,onRecordingStateChange:r,className:o},a)=>{const{settings:i}=Bo(),l=d.useRef(""),c=d.useRef(!0),u=d.useCallback(S=>{console.log("Transcription update:",S)},[]),f=d.useCallback(S=>{if(c.current&&S&&S.trim()){const E=l.current?`${l.current} ${S}`.trim():S.trim();t(E),l.current=""}else c.current||(console.log("AudioRecorder: Transcription canceled, not sending"),l.current="");c.current=!0},[t]),h=d.useCallback(S=>{console.error("Speech-to-text error:",S),n&&n(S)},[n]),{isListening:m,isLoading:p,startRecording:x,stopRecording:g}=PT({onTranscriptionComplete:f,onTranscriptionUpdate:u,onError:h});d.useEffect(()=>{r==null||r(m)},[m,r]),d.useImperativeHandle(a,()=>({startRecording:async()=>{m||(l.current="",c.current=!0,await x())},stopRecording:async()=>{m&&(c.current=!0,await g())},cancelRecording:async()=>{m&&(console.log("AudioRecorder: Canceling recording"),c.current=!1,await g())}}),[m,x,g]);const w=d.useCallback(async()=>{m?(c.current=!0,await g()):(l.current="",c.current=!0,await x())},[m,x,g]),v=()=>p?s.jsx(fr,{className:"size-5 animate-spin"}):m?s.jsx(Wu,{className:"size-5 animate-pulse"}):s.jsx(Wu,{className:"size-5"}),b=()=>m?"Stop recording":p?"Processing...":i.speechToText?"Start voice recording":"Speech-to-text is disabled",C=()=>m?"Stop voice recording":"Start voice recording";return i.speechToText?s.jsx(xe,{variant:"ghost",size:"icon",onClick:w,disabled:e||p,className:ze("transition-colors",m&&"bg-[var(--accent-background)] text-[var(--primary-wMain)] hover:bg-[var(--accent-background)]/80",o),tooltip:b(),"aria-label":C(),"aria-pressed":m,"aria-busy":p,children:v()}):null});ah.displayName="AudioRecorder";function LP({width:e=24,height:t=24}){const{currentTheme:n}=di(),r=n==="dark"?"var(--color-background-wMain)":"var(--color-background-w10)",o=n==="dark"?"var(--color-error-w100)":"var(--color-error-w10)";return s.jsxs("svg",{width:e,height:t,focusable:"false","aria-hidden":"true",viewBox:"0 0 131 131",fill:"none",children:[s.jsx("path",{d:"M119.681 63.9952C119.681 94.0948 95.2807 118.495 65.1812 118.495C35.0816 118.495 10.6812 94.0948 10.6812 63.9952C10.6812 33.8957 35.0816 9.49524 65.1812 9.49524C95.2807 9.49524 119.681 33.8957 119.681 63.9952Z",fill:o}),s.jsx("path",{d:"M2.68115 119.495H128.681V120.495H2.68115V119.495Z",fill:"var(--color-secondary-wMain)"}),s.jsx("rect",{x:14,y:34,width:104.054,height:70.6982,rx:1,fill:r,stroke:"var(--color-secondary-wMain)",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("path",{d:"M59.4929 105.314C59.6018 104.866 60.0032 104.55 60.4646 104.55H72.4448C72.9061 104.55 73.3076 104.866 73.4165 105.314L75.1457 112.433C75.2986 113.062 74.8218 113.669 74.174 113.669H58.7354C58.0876 113.669 57.6107 113.062 57.7637 112.433L59.4929 105.314Z",fill:r,stroke:"var(--color-secondary-wMain)",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("path",{d:"M47.7852 114.103C47.7852 113.55 48.2329 113.103 48.7852 113.103H83.2724C83.8247 113.103 84.2724 113.55 84.2724 114.103V118.656C84.2724 119.208 83.8247 119.656 83.2724 119.656H48.7852C48.2329 119.656 47.7852 119.208 47.7852 118.656V114.103Z",fill:r,stroke:"var(--color-secondary-wMain)",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("path",{d:"M15.1406 95.0068H117.773",stroke:"var(--color-secondary-wMain)",strokeWidth:2}),s.jsxs("g",{clipPath:"url(#clip0_1688:196070)",children:[s.jsx("rect",{opacity:.2,x:54.1126,y:45.1681,width:24.1,height:24.1,stroke:"var(--color-secondary-wMain)",strokeWidth:.1}),s.jsx("path",{d:"M65.6426 60.1142C65.5359 60.1142 65.4453 60.0769 65.3706 60.0022C65.2959 59.9275 65.2586 59.8369 65.2586 59.7302V52.4022C65.2586 52.2955 65.2959 52.2049 65.3706 52.1302C65.4453 52.0555 65.5359 52.0182 65.6426 52.0182H66.9386C67.0559 52.0182 67.1466 52.0555 67.2106 52.1302C67.2853 52.1942 67.3226 52.2849 67.3226 52.4022V59.7302C67.3226 59.8369 67.2853 59.9275 67.2106 60.0022C67.1466 60.0769 67.0559 60.1142 66.9386 60.1142H65.6426ZM65.5466 63.2182C65.4399 63.2182 65.3493 63.1809 65.2746 63.1062C65.1999 63.0315 65.1626 62.9409 65.1626 62.8342V61.3462C65.1626 61.2289 65.1999 61.1329 65.2746 61.0582C65.3493 60.9835 65.4399 60.9462 65.5466 60.9462H67.0346C67.1519 60.9462 67.2479 60.9835 67.3226 61.0582C67.3973 61.1329 67.4346 61.2289 67.4346 61.3462V62.8342C67.4346 62.9409 67.3973 63.0315 67.3226 63.1062C67.2479 63.1809 67.1519 63.2182 67.0346 63.2182H65.5466Z",fill:"var(--color-secondary-wMain)"})]}),s.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M51.3433 73.2659C51.3433 72.9897 51.5671 72.7659 51.8433 72.7659H80.2102C80.4864 72.7659 80.7102 72.9897 80.7102 73.2659C80.7102 73.542 80.4864 73.7659 80.2102 73.7659H51.8433C51.5671 73.7659 51.3433 73.542 51.3433 73.2659Z",fill:"var(--color-secondary-wMain)"}),s.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M55.1851 83.2659C55.1851 82.9897 55.3503 82.7659 55.5542 82.7659H76.4995C76.7034 82.7659 76.8687 82.9897 76.8687 83.2659C76.8687 83.542 76.7034 83.7659 76.4995 83.7659H55.5542C55.3503 83.7659 55.1851 83.542 55.1851 83.2659Z",fill:"var(--color-secondary-wMain)"}),s.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M51.3433 78.2659C51.3433 77.9897 51.5671 77.7659 51.8433 77.7659H80.2102C80.4864 77.7659 80.7102 77.9897 80.7102 78.2659C80.7102 78.542 80.4864 78.7659 80.2102 78.7659H51.8433C51.5671 78.7659 51.3433 78.542 51.3433 78.2659Z",fill:"var(--color-secondary-wMain)"}),s.jsx("defs",{children:s.jsx("clipPath",{id:"clip0_1688:196070",children:s.jsx("rect",{width:24,height:24,fill:r,transform:"translate(54.1626 45.2181)"})})})]})}function FP({width:e=24,height:t=24}){const{currentTheme:n}=di(),r=n==="dark"?"var(--color-background-wMain)":"var(--color-background-w10)";return s.jsxs("svg",{width:e,height:t,viewBox:"0 0 130 130",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[s.jsxs("g",{clipPath:"url(#clip0_483_284)",children:[s.jsx("path",{opacity:.1,d:"M130 61.4874C130 95.4459 102.471 122.975 68.5125 122.975C34.554 122.975 7.02515 95.4459 7.02515 61.4874C7.02515 27.5288 34.554 0 68.5125 0C102.471 0 130 27.5288 130 61.4874Z",fill:"var(--color-info-wMain)"}),s.jsx("path",{d:"M0 25.9979C0 24.1286 1.51535 22.6133 3.38463 22.6133H41.082C49.1822 22.6133 55.7487 29.1798 55.7487 37.28V116.273C55.7487 118.142 54.2333 119.657 52.3641 119.657H3.38463C1.51535 119.657 0 118.142 0 116.273V25.9979Z",fill:r}),s.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M41.082 24.8697H3.38463C2.76154 24.8697 2.25642 25.3748 2.25642 25.9979V116.273C2.25642 116.896 2.76153 117.401 3.38463 117.401H52.3641C52.9871 117.401 53.4923 116.896 53.4923 116.273V37.28C53.4923 30.426 47.936 24.8697 41.082 24.8697ZM3.38463 22.6133C1.51535 22.6133 0 24.1286 0 25.9979V116.273C0 118.142 1.51535 119.657 3.38463 119.657H52.3641C54.2333 119.657 55.7487 118.142 55.7487 116.273V37.28C55.7487 29.1798 49.1822 22.6133 41.082 22.6133H3.38463Z",fill:"var(--color-secondary-wMain)"}),s.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M53.0258 112.821H2.25642V116.206C2.25642 116.829 2.76153 117.334 3.38462 117.334H51.8976C52.5207 117.334 53.0258 116.829 53.0258 116.206V112.821ZM0 110.565V116.206C0 118.075 1.51535 119.59 3.38462 119.59H51.8976C53.7669 119.59 55.2822 118.075 55.2822 116.206V110.565H0Z",fill:"var(--color-secondary-wMain)"}),s.jsx("path",{d:"M51.8977 38.3591C51.8977 29.6358 58.9693 22.5642 67.6926 22.5642H107.18C109.049 22.5642 110.564 24.0796 110.564 25.9488V116.206C110.564 118.075 109.049 119.59 107.18 119.59H55.2823C53.413 119.59 51.8977 118.075 51.8977 116.206V38.3591Z",fill:r}),s.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M107.18 24.8206H67.6926C60.2155 24.8206 54.1541 30.882 54.1541 38.3591V116.206C54.1541 116.829 54.6592 117.334 55.2823 117.334H107.18C107.803 117.334 108.308 116.829 108.308 116.206V25.9488C108.308 25.3257 107.803 24.8206 107.18 24.8206ZM67.6926 22.5642C58.9693 22.5642 51.8977 29.6358 51.8977 38.3591V116.206C51.8977 118.075 53.413 119.59 55.2823 119.59H107.18C109.049 119.59 110.564 118.075 110.564 116.206V25.9488C110.564 24.0796 109.049 22.5642 107.18 22.5642H67.6926Z",fill:"var(--color-secondary-wMain)"}),s.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M108.308 112.821H54.1541V116.206C54.1541 116.829 54.6592 117.334 55.2823 117.334H107.18C107.803 117.334 108.308 116.829 108.308 116.206V112.821ZM51.8977 110.565V116.206C51.8977 118.075 53.413 119.59 55.2823 119.59H107.18C109.049 119.59 110.564 118.075 110.564 116.206V110.565H51.8977Z",fill:"var(--color-secondary-wMain)"}),s.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M29.0351 36.0336C29.0351 35.722 29.2876 35.4695 29.5992 35.4695H43.0726C43.3842 35.4695 43.6367 35.722 43.6367 36.0336C43.6367 36.3451 43.3842 36.5977 43.0726 36.5977H29.5992C29.2876 36.5977 29.0351 36.3451 29.0351 36.0336ZM29.0351 42.7441C29.0351 42.4325 29.2876 42.1799 29.5992 42.1799H43.0726C43.3842 42.1799 43.6367 42.4325 43.6367 42.7441C43.6367 43.0556 43.3842 43.3082 43.0726 43.3082H29.5992C29.2876 43.3082 29.0351 43.0556 29.0351 42.7441ZM29.0351 49.4545C29.0351 49.143 29.2876 48.8904 29.5992 48.8904H43.0726C43.3842 48.8904 43.6367 49.143 43.6367 49.4545C43.6367 49.7661 43.3842 50.0186 43.0726 50.0186H29.5992C29.2876 50.0186 29.0351 49.7661 29.0351 49.4545ZM9.75977 60.2946C9.75977 59.983 10.0123 59.7305 10.3239 59.7305H23.7973C24.1089 59.7305 24.3614 59.983 24.3614 60.2946C24.3614 60.6061 24.1089 60.8587 23.7973 60.8587H10.3239C10.0123 60.8587 9.75977 60.6061 9.75977 60.2946ZM9.75977 67.0051C9.75977 66.6935 10.0123 66.4409 10.3239 66.4409H23.7973C24.1089 66.4409 24.3614 66.6935 24.3614 67.0051C24.3614 67.3166 24.1089 67.5692 23.7973 67.5692H10.3239C10.0123 67.5692 9.75977 67.3166 9.75977 67.0051ZM9.75977 73.7155C9.75977 73.404 10.0123 73.1514 10.3239 73.1514H23.7973C24.1089 73.1514 24.3614 73.404 24.3614 73.7155C24.3614 74.0271 24.1089 74.2796 23.7973 74.2796H10.3239C10.0123 74.2796 9.75977 74.0271 9.75977 73.7155Z",fill:"var(--color-secondary-wMain)"}),s.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M9.75977 83.5231C9.75977 83.2116 10.0123 82.959 10.3239 82.959H42.3277C42.6393 82.959 42.8918 83.2116 42.8918 83.5231C42.8918 83.8347 42.6393 84.0872 42.3277 84.0872H10.3239C10.0123 84.0872 9.75977 83.8347 9.75977 83.5231Z",fill:"var(--color-secondary-wMain)"}),s.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M9.75977 93.8473C9.75977 93.5357 10.0123 93.2832 10.3239 93.2832H42.3277C42.6393 93.2832 42.8918 93.5357 42.8918 93.8473C42.8918 94.1588 42.6393 94.4114 42.3277 94.4114H10.3239C10.0123 94.4114 9.75977 94.1588 9.75977 93.8473Z",fill:"var(--color-secondary-wMain)"}),s.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M9.75977 88.6852C9.75977 88.3737 10.0123 88.1211 10.3239 88.1211H42.3277C42.6393 88.1211 42.8918 88.3737 42.8918 88.6852C42.8918 88.9967 42.6393 89.2493 42.3277 89.2493H10.3239C10.0123 89.2493 9.75977 88.9967 9.75977 88.6852Z",fill:"var(--color-secondary-wMain)"}),s.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M9.75977 99.0089C9.75977 98.6974 10.0123 98.4448 10.3239 98.4448H42.3277C42.6393 98.4448 42.8918 98.6974 42.8918 99.0089C42.8918 99.3205 42.6393 99.573 42.3277 99.573H10.3239C10.0123 99.573 9.75977 99.3205 9.75977 99.0089Z",fill:"var(--color-secondary-wMain)"}),s.jsx("path",{d:"M22.9252 42.8986C22.9252 46.6372 19.8945 49.6679 16.156 49.6679C12.4174 49.6679 9.38672 46.6372 9.38672 42.8986C9.38672 39.1601 12.4174 36.1294 16.156 36.1294C19.8945 36.1294 22.9252 39.1601 22.9252 42.8986Z",fill:r}),s.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M16.156 47.4115C18.6483 47.4115 20.6688 45.391 20.6688 42.8986C20.6688 40.4063 18.6483 38.3858 16.156 38.3858C13.6636 38.3858 11.6431 40.4063 11.6431 42.8986C11.6431 45.391 13.6636 47.4115 16.156 47.4115ZM16.156 49.6679C19.8945 49.6679 22.9252 46.6372 22.9252 42.8986C22.9252 39.1601 19.8945 36.1294 16.156 36.1294C12.4174 36.1294 9.38672 39.1601 9.38672 42.8986C9.38672 46.6372 12.4174 49.6679 16.156 49.6679Z",fill:"var(--color-secondary-wMain)"}),s.jsx("path",{d:"M31.5107 63.1795C31.5107 61.9333 32.521 60.9231 33.7672 60.9231H40.5364C41.7826 60.9231 42.7928 61.9334 42.7928 63.1795V68.9231C42.7928 70.1693 41.7826 71.1796 40.5364 71.1796H33.7672C32.521 71.1796 31.5107 70.1693 31.5107 68.9231V63.1795Z",fill:r}),s.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M40.5364 63.1795H33.7672V68.9231H40.5364V63.1795ZM33.7672 60.9231C32.521 60.9231 31.5107 61.9333 31.5107 63.1795V68.9231C31.5107 70.1693 32.521 71.1796 33.7672 71.1796H40.5364C41.7826 71.1796 42.7928 70.1693 42.7928 68.9231V63.1795C42.7928 61.9334 41.7826 60.9231 40.5364 60.9231H33.7672Z",fill:"var(--color-secondary-wMain)"}),s.jsx("path",{d:"M102.325 102.029C101.702 100.949 102.072 99.5694 103.151 98.9463L107.108 96.6618C108.188 96.0387 109.568 96.4084 110.191 97.4877L123.409 120.382C124.032 121.461 123.662 122.841 122.583 123.464L118.626 125.749C117.547 126.372 116.167 126.002 115.543 124.923L102.325 102.029Z",fill:r}),s.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M108.237 98.6159L104.28 100.9L117.498 123.795L121.455 121.51L108.237 98.6159ZM103.151 98.9463C102.072 99.5694 101.702 100.949 102.325 102.029L115.543 124.923C116.167 126.002 117.547 126.372 118.626 125.749L122.583 123.464C123.662 122.841 124.032 121.461 123.409 120.382L110.191 97.4877C109.568 96.4084 108.188 96.0387 107.108 96.6618L103.151 98.9463Z",fill:"var(--color-secondary-wMain)"}),s.jsx("path",{d:"M115.803 66.4824C115.803 82.3642 102.928 95.239 87.0466 95.239C71.1648 95.239 58.29 82.3642 58.29 66.4824C58.29 50.6006 71.1648 37.7258 87.0466 37.7258C102.928 37.7258 115.803 50.6006 115.803 66.4824Z",fill:r}),s.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M87.0466 92.9825C101.682 92.9825 113.547 81.118 113.547 66.4824C113.547 51.8468 101.682 39.9822 87.0466 39.9822C72.411 39.9822 60.5465 51.8468 60.5465 66.4824C60.5465 81.118 72.411 92.9825 87.0466 92.9825ZM87.0466 95.239C102.928 95.239 115.803 82.3642 115.803 66.4824C115.803 50.6006 102.928 37.7258 87.0466 37.7258C71.1648 37.7258 58.29 50.6006 58.29 66.4824C58.29 82.3642 71.1648 95.239 87.0466 95.239Z",fill:"var(--color-secondary-wMain)"}),s.jsx("path",{d:"M109.771 66.4825C109.771 79.0329 99.5964 89.2071 87.0459 89.2071C74.4954 89.2071 64.3213 79.0329 64.3213 66.4825C64.3213 53.932 74.4954 43.7578 87.0459 43.7578C99.5964 43.7578 109.771 53.932 109.771 66.4825Z",fill:r}),s.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M87.0459 86.9507C98.3502 86.9507 107.514 77.7868 107.514 66.4825C107.514 55.1782 98.3502 46.0142 87.0459 46.0142C75.7416 46.0142 66.5777 55.1782 66.5777 66.4825C66.5777 77.7868 75.7416 86.9507 87.0459 86.9507ZM87.0459 89.2071C99.5964 89.2071 109.771 79.0329 109.771 66.4825C109.771 53.932 99.5964 43.7578 87.0459 43.7578C74.4954 43.7578 64.3213 53.932 64.3213 66.4825C64.3213 79.0329 74.4954 89.2071 87.0459 89.2071Z",fill:"var(--color-secondary-wMain)"}),s.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M86.4824 49.2829C86.4824 48.9713 86.735 48.7188 87.0465 48.7188C96.8572 48.7188 104.81 56.6717 104.81 66.4823C104.81 66.7939 104.558 67.0465 104.246 67.0465C103.935 67.0465 103.682 66.7939 103.682 66.4823C103.682 57.2948 96.2341 49.847 87.0465 49.847C86.735 49.847 86.4824 49.5944 86.4824 49.2829ZM72.0594 74.9461C72.3254 74.7838 72.6725 74.868 72.8348 75.134C73.8285 76.7627 75.0945 78.2075 76.5695 79.4049C77.4599 80.1277 78.4264 80.7603 79.4549 81.2888C81.7303 82.4579 84.3105 83.1178 87.0465 83.1178C87.3581 83.1178 87.6106 83.3704 87.6106 83.6819C87.6106 83.9935 87.3581 84.2461 87.0465 84.2461C84.127 84.2461 81.3705 83.5413 78.9393 82.2922C77.8408 81.7278 76.8089 81.0524 75.8584 80.2808C74.2841 79.0028 72.9327 77.4606 71.8717 75.7216C71.7094 75.4556 71.7935 75.1084 72.0594 74.9461Z",fill:"var(--color-secondary-wMain)"}),s.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M104.511 99.0423L100.011 91.2478L101.965 90.1196L106.465 97.9141L104.511 99.0423Z",fill:"var(--color-secondary-wMain)"}),s.jsx("path",{d:"M86.2924 72.1957C86.1299 72.1957 85.9945 72.1505 85.8862 72.0603C85.7779 71.952 85.7238 71.8076 85.7238 71.6271C85.7238 71.4465 85.7238 71.266 85.7238 71.0855C85.7238 70.905 85.7238 70.7245 85.7238 70.544C85.7599 69.7678 85.9314 69.0818 86.2382 68.4861C86.5451 67.8904 86.9152 67.3489 87.3484 66.8615C87.7997 66.3741 88.251 65.9138 88.7023 65.4806C89.1535 65.0293 89.5326 64.578 89.8395 64.1267C90.1644 63.6754 90.363 63.1971 90.4352 62.6916C90.5074 62.0418 90.381 61.5003 90.0561 61.067C89.7312 60.6157 89.2889 60.2728 88.7293 60.0381C88.1697 59.8034 87.5921 59.6861 86.9964 59.6861C86.0397 59.6861 85.2183 59.9388 84.5324 60.4442C83.8645 60.9316 83.4222 61.762 83.2056 62.9353C83.1515 63.1519 83.0612 63.3054 82.9348 63.3956C82.8085 63.4859 82.6641 63.531 82.5016 63.531H81.2019C81.0395 63.531 80.895 63.4769 80.7687 63.3686C80.6604 63.2603 80.6062 63.1158 80.6062 62.9353C80.6243 62.1952 80.7867 61.4912 81.0936 60.8233C81.4005 60.1554 81.8337 59.5688 82.3933 59.0633C82.9709 58.5579 83.6479 58.1608 84.4241 57.8719C85.2183 57.5651 86.1029 57.4116 87.0776 57.4116C88.1788 57.4116 89.1174 57.5651 89.8936 57.8719C90.6879 58.1608 91.3197 58.5579 91.789 59.0633C92.2764 59.5507 92.6284 60.0922 92.845 60.6879C93.0616 61.2836 93.1519 61.8793 93.1158 62.475C93.0617 63.1971 92.8811 63.8469 92.5743 64.4246C92.2674 64.9842 91.8973 65.5076 91.4641 65.995C91.0309 66.4644 90.5886 66.9337 90.1373 67.403C89.7041 67.8543 89.325 68.3327 89.0001 68.8381C88.6932 69.3255 88.5217 69.858 88.4856 70.4357C88.4676 70.6342 88.4495 70.8328 88.4315 71.0314C88.4315 71.2119 88.4315 71.3924 88.4315 71.5729C88.3954 71.7715 88.3232 71.9249 88.2149 72.0332C88.1066 72.1415 87.9531 72.1957 87.7546 72.1957H86.2924ZM86.0758 76.6363C85.8953 76.6363 85.7418 76.5821 85.6155 76.4738C85.5072 76.3475 85.453 76.194 85.453 76.0135V74.3618C85.453 74.1813 85.5072 74.0369 85.6155 73.9286C85.7418 73.8022 85.8953 73.7391 86.0758 73.7391H87.8358C88.0344 73.7391 88.1878 73.8022 88.2961 73.9286C88.4225 74.0369 88.4856 74.1813 88.4856 74.3618V76.0135C88.4856 76.194 88.4225 76.3475 88.2961 76.4738C88.1878 76.5821 88.0344 76.6363 87.8358 76.6363H86.0758Z",fill:"var(--color-secondary-wMain)"})]}),s.jsx("defs",{children:s.jsx("clipPath",{id:"clip0_483_284",children:s.jsx("rect",{width:130,height:130,fill:r})})})]})}function Lr({title:e,subtitle:t,image:n,variant:r="error",buttons:o,className:a}){const i={error:s.jsx(LP,{width:150,height:150}),notFound:s.jsx(FP,{width:150,height:150}),loading:s.jsx(no,{size:"large"}),noImage:null};return s.jsxs("div",{className:ze("flex h-full w-full flex-col items-center justify-center gap-3",a),children:[n||i[r]||null,s.jsx("p",{className:"mt-4 text-lg",children:e}),t?s.jsx("p",{className:"max-w-xl text-center text-sm",children:t}):null,s.jsx("div",{className:"mt-3 flex min-w-50 flex-col gap-2",children:o&&o.map(({icon:l,text:c,variant:u,onClick:f},h)=>s.jsxs(xe,{testid:c,title:c,variant:u,onClick:f,children:[l||null,c]},`button-${c}-${h}`))})]})}const $P=({children:e,className:t=""})=>s.jsx("div",{className:`flex h-16 items-center justify-end gap-4 border-t px-8 ${t}`,children:e}),Ic=({children:e,className:t,isSelected:n,onClick:r,...o})=>s.jsx(Tf,{className:ze("flex h-[200px] w-[380px] flex-shrink-0 py-4 transition-all",r&&"cursor-pointer hover:bg-[var(--color-primary-w10)] dark:hover:bg-[var(--color-primary-wMain)]",r&&"focus-visible:border-[var(--color-brand-w100)] focus-visible:outline-none",n&&"border-[var(--color-brand-w100)]",t),onClick:r,onKeyDown:a=>{(a.key==="Enter"||a.key===" ")&&(a.preventDefault(),r==null||r())},...r&&{role:"button",tabIndex:0},noPadding:!0,...o,children:e});/*! @license DOMPurify 3.2.6 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.2.6/LICENSE */const{entries:oy,setPrototypeOf:wm,isFrozen:zP,getPrototypeOf:UP,getOwnPropertyDescriptor:BP}=Object;let{freeze:Hn,seal:Sr,create:sy}=Object,{apply:Sd,construct:_d}=typeof Reflect<"u"&&Reflect;Hn||(Hn=function(t){return t});Sr||(Sr=function(t){return t});Sd||(Sd=function(t,n,r){return t.apply(n,r)});_d||(_d=function(t,n){return new t(...n)});const Wi=Zn(Array.prototype.forEach),VP=Zn(Array.prototype.lastIndexOf),bm=Zn(Array.prototype.pop),ya=Zn(Array.prototype.push),WP=Zn(Array.prototype.splice),pl=Zn(String.prototype.toLowerCase),yu=Zn(String.prototype.toString),ym=Zn(String.prototype.match),Ca=Zn(String.prototype.replace),HP=Zn(String.prototype.indexOf),ZP=Zn(String.prototype.trim),Nr=Zn(Object.prototype.hasOwnProperty),Bn=Zn(RegExp.prototype.test),Sa=GP(TypeError);function Zn(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];return Sd(e,t,r)}}function GP(e){return function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return _d(e,n)}}function kt(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:pl;wm&&wm(e,null);let r=t.length;for(;r--;){let o=t[r];if(typeof o=="string"){const a=n(o);a!==o&&(zP(t)||(t[r]=a),o=a)}e[o]=!0}return e}function YP(e){for(let t=0;t<e.length;t++)Nr(e,t)||(e[t]=null);return e}function co(e){const t=sy(null);for(const[n,r]of oy(e))Nr(e,n)&&(Array.isArray(r)?t[n]=YP(r):r&&typeof r=="object"&&r.constructor===Object?t[n]=co(r):t[n]=r);return t}function _a(e,t){for(;e!==null;){const r=BP(e,t);if(r){if(r.get)return Zn(r.get);if(typeof r.value=="function")return Zn(r.value)}e=UP(e)}function n(){return null}return n}const Cm=Hn(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","section","select","shadow","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),Cu=Hn(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","filter","font","g","glyph","glyphref","hkern","image","line","lineargradient","marker","mask","metadata","mpath","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),Su=Hn(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),KP=Hn(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),_u=Hn(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),qP=Hn(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Sm=Hn(["#text"]),_m=Hn(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","face","for","headers","height","hidden","high","href","hreflang","id","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns","slot"]),ku=Hn(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),km=Hn(["accent","accentunder","align","bevelled","close","columnsalign","columnlines","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lspace","lquote","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),Hi=Hn(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),XP=Sr(/\{\{[\w\W]*|[\w\W]*\}\}/gm),JP=Sr(/<%[\w\W]*|[\w\W]*%>/gm),QP=Sr(/\$\{[\w\W]*/gm),e4=Sr(/^data-[\-\w.\u00B7-\uFFFF]+$/),t4=Sr(/^aria-[\-\w]+$/),ay=Sr(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),n4=Sr(/^(?:\w+script|data):/i),r4=Sr(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),iy=Sr(/^html$/i),o4=Sr(/^[a-z][.\w]*(-[.\w]+)+$/i);var Em=Object.freeze({__proto__:null,ARIA_ATTR:t4,ATTR_WHITESPACE:r4,CUSTOM_ELEMENT:o4,DATA_ATTR:e4,DOCTYPE_NAME:iy,ERB_EXPR:JP,IS_ALLOWED_URI:ay,IS_SCRIPT_OR_DATA:n4,MUSTACHE_EXPR:XP,TMPLIT_EXPR:QP});const ka={element:1,text:3,progressingInstruction:7,comment:8,document:9},s4=function(){return typeof window>"u"?null:window},a4=function(t,n){if(typeof t!="object"||typeof t.createPolicy!="function")return null;let r=null;const o="data-tt-policy-suffix";n&&n.hasAttribute(o)&&(r=n.getAttribute(o));const a="dompurify"+(r?"#"+r:"");try{return t.createPolicy(a,{createHTML(i){return i},createScriptURL(i){return i}})}catch{return console.warn("TrustedTypes policy "+a+" could not be created."),null}},jm=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function ly(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:s4();const t=ke=>ly(ke);if(t.version="3.2.6",t.removed=[],!e||!e.document||e.document.nodeType!==ka.document||!e.Element)return t.isSupported=!1,t;let{document:n}=e;const r=n,o=r.currentScript,{DocumentFragment:a,HTMLTemplateElement:i,Node:l,Element:c,NodeFilter:u,NamedNodeMap:f=e.NamedNodeMap||e.MozNamedAttrMap,HTMLFormElement:h,DOMParser:m,trustedTypes:p}=e,x=c.prototype,g=_a(x,"cloneNode"),w=_a(x,"remove"),v=_a(x,"nextSibling"),b=_a(x,"childNodes"),C=_a(x,"parentNode");if(typeof i=="function"){const ke=n.createElement("template");ke.content&&ke.content.ownerDocument&&(n=ke.content.ownerDocument)}let S,E="";const{implementation:_,createNodeIterator:j,createDocumentFragment:A,getElementsByTagName:P}=n,{importNode:O}=r;let B=jm();t.isSupported=typeof oy=="function"&&typeof C=="function"&&_&&_.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:N,ERB_EXPR:M,TMPLIT_EXPR:y,DATA_ATTR:T,ARIA_ATTR:R,IS_SCRIPT_OR_DATA:z,ATTR_WHITESPACE:F,CUSTOM_ELEMENT:I}=Em;let{IS_ALLOWED_URI:J}=Em,L=null;const D=kt({},[...Cm,...Cu,...Su,..._u,...Sm]);let W=null;const G=kt({},[..._m,...ku,...km,...Hi]);let V=Object.seal(sy(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),Q=null,X=null,K=!0,q=!0,ne=!1,de=!0,se=!1,me=!0,k=!1,oe=!1,ie=!1,Z=!1,U=!1,re=!1,$=!0,Y=!1;const H="user-content-";let ce=!0,ue=!1,ae={},pe=null;const Te=kt({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let Ae=null;const gt=kt({},["audio","video","img","source","image","track"]);let Pt=null;const Nt=kt({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Mt="http://www.w3.org/1998/Math/MathML",ct="http://www.w3.org/2000/svg",$t="http://www.w3.org/1999/xhtml";let Wt=$t,Dt=!1,ve=null;const Pe=kt({},[Mt,ct,$t],yu);let Me=kt({},["mi","mo","mn","ms","mtext"]),Oe=kt({},["annotation-xml"]);const at=kt({},["title","style","font","a","script"]);let Ue=null;const it=["application/xhtml+xml","text/html"],We="text/html";let ft=null,Et=null;const hn=n.createElement("form"),Dn=function(te){return te instanceof RegExp||te instanceof Function},ee=function(){let te=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(Et&&Et===te)){if((!te||typeof te!="object")&&(te={}),te=co(te),Ue=it.indexOf(te.PARSER_MEDIA_TYPE)===-1?We:te.PARSER_MEDIA_TYPE,ft=Ue==="application/xhtml+xml"?yu:pl,L=Nr(te,"ALLOWED_TAGS")?kt({},te.ALLOWED_TAGS,ft):D,W=Nr(te,"ALLOWED_ATTR")?kt({},te.ALLOWED_ATTR,ft):G,ve=Nr(te,"ALLOWED_NAMESPACES")?kt({},te.ALLOWED_NAMESPACES,yu):Pe,Pt=Nr(te,"ADD_URI_SAFE_ATTR")?kt(co(Nt),te.ADD_URI_SAFE_ATTR,ft):Nt,Ae=Nr(te,"ADD_DATA_URI_TAGS")?kt(co(gt),te.ADD_DATA_URI_TAGS,ft):gt,pe=Nr(te,"FORBID_CONTENTS")?kt({},te.FORBID_CONTENTS,ft):Te,Q=Nr(te,"FORBID_TAGS")?kt({},te.FORBID_TAGS,ft):co({}),X=Nr(te,"FORBID_ATTR")?kt({},te.FORBID_ATTR,ft):co({}),ae=Nr(te,"USE_PROFILES")?te.USE_PROFILES:!1,K=te.ALLOW_ARIA_ATTR!==!1,q=te.ALLOW_DATA_ATTR!==!1,ne=te.ALLOW_UNKNOWN_PROTOCOLS||!1,de=te.ALLOW_SELF_CLOSE_IN_ATTR!==!1,se=te.SAFE_FOR_TEMPLATES||!1,me=te.SAFE_FOR_XML!==!1,k=te.WHOLE_DOCUMENT||!1,Z=te.RETURN_DOM||!1,U=te.RETURN_DOM_FRAGMENT||!1,re=te.RETURN_TRUSTED_TYPE||!1,ie=te.FORCE_BODY||!1,$=te.SANITIZE_DOM!==!1,Y=te.SANITIZE_NAMED_PROPS||!1,ce=te.KEEP_CONTENT!==!1,ue=te.IN_PLACE||!1,J=te.ALLOWED_URI_REGEXP||ay,Wt=te.NAMESPACE||$t,Me=te.MATHML_TEXT_INTEGRATION_POINTS||Me,Oe=te.HTML_INTEGRATION_POINTS||Oe,V=te.CUSTOM_ELEMENT_HANDLING||{},te.CUSTOM_ELEMENT_HANDLING&&Dn(te.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(V.tagNameCheck=te.CUSTOM_ELEMENT_HANDLING.tagNameCheck),te.CUSTOM_ELEMENT_HANDLING&&Dn(te.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(V.attributeNameCheck=te.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),te.CUSTOM_ELEMENT_HANDLING&&typeof te.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(V.allowCustomizedBuiltInElements=te.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),se&&(q=!1),U&&(Z=!0),ae&&(L=kt({},Sm),W=[],ae.html===!0&&(kt(L,Cm),kt(W,_m)),ae.svg===!0&&(kt(L,Cu),kt(W,ku),kt(W,Hi)),ae.svgFilters===!0&&(kt(L,Su),kt(W,ku),kt(W,Hi)),ae.mathMl===!0&&(kt(L,_u),kt(W,km),kt(W,Hi))),te.ADD_TAGS&&(L===D&&(L=co(L)),kt(L,te.ADD_TAGS,ft)),te.ADD_ATTR&&(W===G&&(W=co(W)),kt(W,te.ADD_ATTR,ft)),te.ADD_URI_SAFE_ATTR&&kt(Pt,te.ADD_URI_SAFE_ATTR,ft),te.FORBID_CONTENTS&&(pe===Te&&(pe=co(pe)),kt(pe,te.FORBID_CONTENTS,ft)),ce&&(L["#text"]=!0),k&&kt(L,["html","head","body"]),L.table&&(kt(L,["tbody"]),delete Q.tbody),te.TRUSTED_TYPES_POLICY){if(typeof te.TRUSTED_TYPES_POLICY.createHTML!="function")throw Sa('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof te.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw Sa('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');S=te.TRUSTED_TYPES_POLICY,E=S.createHTML("")}else S===void 0&&(S=a4(p,o)),S!==null&&typeof E=="string"&&(E=S.createHTML(""));Hn&&Hn(te),Et=te}},le=kt({},[...Cu,...Su,...KP]),fe=kt({},[..._u,...qP]),be=function(te){let ge=C(te);(!ge||!ge.tagName)&&(ge={namespaceURI:Wt,tagName:"template"});const Ie=pl(te.tagName),$e=pl(ge.tagName);return ve[te.namespaceURI]?te.namespaceURI===ct?ge.namespaceURI===$t?Ie==="svg":ge.namespaceURI===Mt?Ie==="svg"&&($e==="annotation-xml"||Me[$e]):!!le[Ie]:te.namespaceURI===Mt?ge.namespaceURI===$t?Ie==="math":ge.namespaceURI===ct?Ie==="math"&&Oe[$e]:!!fe[Ie]:te.namespaceURI===$t?ge.namespaceURI===ct&&!Oe[$e]||ge.namespaceURI===Mt&&!Me[$e]?!1:!fe[Ie]&&(at[Ie]||!le[Ie]):!!(Ue==="application/xhtml+xml"&&ve[te.namespaceURI]):!1},_e=function(te){ya(t.removed,{element:te});try{C(te).removeChild(te)}catch{w(te)}},Fe=function(te,ge){try{ya(t.removed,{attribute:ge.getAttributeNode(te),from:ge})}catch{ya(t.removed,{attribute:null,from:ge})}if(ge.removeAttribute(te),te==="is")if(Z||U)try{_e(ge)}catch{}else try{ge.setAttribute(te,"")}catch{}},He=function(te){let ge=null,Ie=null;if(ie)te="<remove></remove>"+te;else{const wt=ym(te,/^[\r\n\t ]+/);Ie=wt&&wt[0]}Ue==="application/xhtml+xml"&&Wt===$t&&(te='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+te+"</body></html>");const $e=S?S.createHTML(te):te;if(Wt===$t)try{ge=new m().parseFromString($e,Ue)}catch{}if(!ge||!ge.documentElement){ge=_.createDocument(Wt,"template",null);try{ge.documentElement.innerHTML=Dt?E:$e}catch{}}const nt=ge.body||ge.documentElement;return te&&Ie&&nt.insertBefore(n.createTextNode(Ie),nt.childNodes[0]||null),Wt===$t?P.call(ge,k?"html":"body")[0]:k?ge.documentElement:nt},Le=function(te){return j.call(te.ownerDocument||te,te,u.SHOW_ELEMENT|u.SHOW_COMMENT|u.SHOW_TEXT|u.SHOW_PROCESSING_INSTRUCTION|u.SHOW_CDATA_SECTION,null)},Ve=function(te){return te instanceof h&&(typeof te.nodeName!="string"||typeof te.textContent!="string"||typeof te.removeChild!="function"||!(te.attributes instanceof f)||typeof te.removeAttribute!="function"||typeof te.setAttribute!="function"||typeof te.namespaceURI!="string"||typeof te.insertBefore!="function"||typeof te.hasChildNodes!="function")},Xe=function(te){return typeof l=="function"&&te instanceof l};function Se(ke,te,ge){Wi(ke,Ie=>{Ie.call(t,te,ge,Et)})}const je=function(te){let ge=null;if(Se(B.beforeSanitizeElements,te,null),Ve(te))return _e(te),!0;const Ie=ft(te.nodeName);if(Se(B.uponSanitizeElement,te,{tagName:Ie,allowedTags:L}),me&&te.hasChildNodes()&&!Xe(te.firstElementChild)&&Bn(/<[/\w!]/g,te.innerHTML)&&Bn(/<[/\w!]/g,te.textContent)||te.nodeType===ka.progressingInstruction||me&&te.nodeType===ka.comment&&Bn(/<[/\w]/g,te.data))return _e(te),!0;if(!L[Ie]||Q[Ie]){if(!Q[Ie]&&Ze(Ie)&&(V.tagNameCheck instanceof RegExp&&Bn(V.tagNameCheck,Ie)||V.tagNameCheck instanceof Function&&V.tagNameCheck(Ie)))return!1;if(ce&&!pe[Ie]){const $e=C(te)||te.parentNode,nt=b(te)||te.childNodes;if(nt&&$e){const wt=nt.length;for(let Ot=wt-1;Ot>=0;--Ot){const Ct=g(nt[Ot],!0);Ct.__removalCount=(te.__removalCount||0)+1,$e.insertBefore(Ct,v(te))}}}return _e(te),!0}return te instanceof c&&!be(te)||(Ie==="noscript"||Ie==="noembed"||Ie==="noframes")&&Bn(/<\/no(script|embed|frames)/i,te.innerHTML)?(_e(te),!0):(se&&te.nodeType===ka.text&&(ge=te.textContent,Wi([N,M,y],$e=>{ge=Ca(ge,$e," ")}),te.textContent!==ge&&(ya(t.removed,{element:te.cloneNode()}),te.textContent=ge)),Se(B.afterSanitizeElements,te,null),!1)},De=function(te,ge,Ie){if($&&(ge==="id"||ge==="name")&&(Ie in n||Ie in hn))return!1;if(!(q&&!X[ge]&&Bn(T,ge))){if(!(K&&Bn(R,ge))){if(!W[ge]||X[ge]){if(!(Ze(te)&&(V.tagNameCheck instanceof RegExp&&Bn(V.tagNameCheck,te)||V.tagNameCheck instanceof Function&&V.tagNameCheck(te))&&(V.attributeNameCheck instanceof RegExp&&Bn(V.attributeNameCheck,ge)||V.attributeNameCheck instanceof Function&&V.attributeNameCheck(ge))||ge==="is"&&V.allowCustomizedBuiltInElements&&(V.tagNameCheck instanceof RegExp&&Bn(V.tagNameCheck,Ie)||V.tagNameCheck instanceof Function&&V.tagNameCheck(Ie))))return!1}else if(!Pt[ge]){if(!Bn(J,Ca(Ie,F,""))){if(!((ge==="src"||ge==="xlink:href"||ge==="href")&&te!=="script"&&HP(Ie,"data:")===0&&Ae[te])){if(!(ne&&!Bn(z,Ca(Ie,F,"")))){if(Ie)return!1}}}}}}return!0},Ze=function(te){return te!=="annotation-xml"&&ym(te,I)},yt=function(te){Se(B.beforeSanitizeAttributes,te,null);const{attributes:ge}=te;if(!ge||Ve(te))return;const Ie={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:W,forceKeepAttr:void 0};let $e=ge.length;for(;$e--;){const nt=ge[$e],{name:wt,namespaceURI:Ot,value:Ct}=nt,Tt=ft(wt),pn=Ct;let Qe=wt==="value"?pn:ZP(pn);if(Ie.attrName=Tt,Ie.attrValue=Qe,Ie.keepAttr=!0,Ie.forceKeepAttr=void 0,Se(B.uponSanitizeAttribute,te,Ie),Qe=Ie.attrValue,Y&&(Tt==="id"||Tt==="name")&&(Fe(wt,te),Qe=H+Qe),me&&Bn(/((--!?|])>)|<\/(style|title)/i,Qe)){Fe(wt,te);continue}if(Ie.forceKeepAttr)continue;if(!Ie.keepAttr){Fe(wt,te);continue}if(!de&&Bn(/\/>/i,Qe)){Fe(wt,te);continue}se&&Wi([N,M,y],or=>{Qe=Ca(Qe,or," ")});const Lt=ft(te.nodeName);if(!De(Lt,Tt,Qe)){Fe(wt,te);continue}if(S&&typeof p=="object"&&typeof p.getAttributeType=="function"&&!Ot)switch(p.getAttributeType(Lt,Tt)){case"TrustedHTML":{Qe=S.createHTML(Qe);break}case"TrustedScriptURL":{Qe=S.createScriptURL(Qe);break}}if(Qe!==pn)try{Ot?te.setAttributeNS(Ot,wt,Qe):te.setAttribute(wt,Qe),Ve(te)?_e(te):bm(t.removed)}catch{Fe(wt,te)}}Se(B.afterSanitizeAttributes,te,null)},At=function ke(te){let ge=null;const Ie=Le(te);for(Se(B.beforeSanitizeShadowDOM,te,null);ge=Ie.nextNode();)Se(B.uponSanitizeShadowNode,ge,null),je(ge),yt(ge),ge.content instanceof a&&ke(ge.content);Se(B.afterSanitizeShadowDOM,te,null)};return t.sanitize=function(ke){let te=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},ge=null,Ie=null,$e=null,nt=null;if(Dt=!ke,Dt&&(ke="<!-->"),typeof ke!="string"&&!Xe(ke))if(typeof ke.toString=="function"){if(ke=ke.toString(),typeof ke!="string")throw Sa("dirty is not a string, aborting")}else throw Sa("toString is not a function");if(!t.isSupported)return ke;if(oe||ee(te),t.removed=[],typeof ke=="string"&&(ue=!1),ue){if(ke.nodeName){const Ct=ft(ke.nodeName);if(!L[Ct]||Q[Ct])throw Sa("root node is forbidden and cannot be sanitized in-place")}}else if(ke instanceof l)ge=He("<!---->"),Ie=ge.ownerDocument.importNode(ke,!0),Ie.nodeType===ka.element&&Ie.nodeName==="BODY"||Ie.nodeName==="HTML"?ge=Ie:ge.appendChild(Ie);else{if(!Z&&!se&&!k&&ke.indexOf("<")===-1)return S&&re?S.createHTML(ke):ke;if(ge=He(ke),!ge)return Z?null:re?E:""}ge&&ie&&_e(ge.firstChild);const wt=Le(ue?ke:ge);for(;$e=wt.nextNode();)je($e),yt($e),$e.content instanceof a&&At($e.content);if(ue)return ke;if(Z){if(U)for(nt=A.call(ge.ownerDocument);ge.firstChild;)nt.appendChild(ge.firstChild);else nt=ge;return(W.shadowroot||W.shadowrootmode)&&(nt=O.call(r,nt,!0)),nt}let Ot=k?ge.outerHTML:ge.innerHTML;return k&&L["!doctype"]&&ge.ownerDocument&&ge.ownerDocument.doctype&&ge.ownerDocument.doctype.name&&Bn(iy,ge.ownerDocument.doctype.name)&&(Ot="<!DOCTYPE "+ge.ownerDocument.doctype.name+`>
143
+ `+Ot),se&&Wi([N,M,y],Ct=>{Ot=Ca(Ot,Ct," ")}),S&&re?S.createHTML(Ot):Ot},t.setConfig=function(){let ke=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};ee(ke),oe=!0},t.clearConfig=function(){Et=null,oe=!1},t.isValidAttribute=function(ke,te,ge){Et||ee({});const Ie=ft(ke),$e=ft(te);return De(Ie,$e,ge)},t.addHook=function(ke,te){typeof te=="function"&&ya(B[ke],te)},t.removeHook=function(ke,te){if(te!==void 0){const ge=VP(B[ke],te);return ge===-1?void 0:WP(B[ke],ge,1)[0]}return bm(B[ke])},t.removeHooks=function(ke){B[ke]=[]},t.removeAllHooks=function(){B=jm()},t}var cy=ly();const i4=({code:e,language:t})=>{const[n,r]=d.useState(!1),o=d.useCallback(()=>{navigator.clipboard.writeText(e).then(()=>{r(!0),setTimeout(()=>r(!1),2e3)}).catch(a=>{console.error("Failed to copy code:",a)})},[e]);return s.jsxs("div",{className:"group relative",children:[s.jsx("pre",{className:"border-border mb-4 max-w-full overflow-x-auto rounded-lg border bg-transparent p-4 whitespace-pre-wrap",children:s.jsx("code",{className:`bg-transparent p-0 text-sm break-words ${t?`language-${t}`:""}`,children:e})}),s.jsx(xe,{variant:"ghost",size:"icon",className:"bg-background/80 hover:bg-background absolute top-2 right-2 h-8 w-8 opacity-0 transition-opacity group-hover:opacity-100",onClick:o,tooltip:n?"Copied!":"Copy code",children:n?s.jsx(la,{className:"h-4 w-4 text-[var(--color-success-wMain)]"}):s.jsx(Og,{className:"h-4 w-4"})})]})};function Hs({children:e,className:t}){if(!e)return null;const n={replace:r=>{var o;if(r instanceof Rh.Element&&r.attribs&&(r.name==="a"&&(r.attribs.target="_blank",r.attribs.rel="noopener noreferrer"),r.name==="pre")){const a=r.children.find(i=>i instanceof Rh.Element&&i.name==="code");if(a){const i=a.children.map(f=>"data"in f?f.data:"").join(""),c=(((o=a.attribs)==null?void 0:o.class)||"").match(/language-(\w+)/),u=c?c[1]:void 0;return s.jsx(i4,{code:i,language:u})}}}};try{const r=Z1.parse(e,{gfm:!0}),o=cy.sanitize(r,{USE_PROFILES:{html:!0}}),a=G1(o,n);return s.jsx("div",{className:xp(t),children:a})}catch{return s.jsx("div",{className:xp(t),children:e})}}const l4={error:"bg-[var(--color-error-w20)] text-[var(--color-error-wMain)] border-[var(--color-error-wMain)] dark:bg-[var(--color-error-w100)]/60 dark:text-[var(--color-white)] dark:border-[var(--color-error-wMain)]",warning:"bg-[var(--color-warning-w10)] text-[var(--color-warning-wMain)] border-[var(--color-warning-wMain)] dark:bg-[var(--color-warning-w100)]/60 dark:text-[var(--color-white)] dark:border-[var(--color-warning-wMain)]",info:"bg-[var(--color-info-w20)] text-[var(--color-info-wMain)] border-[var(--color-info-wMain)] dark:bg-[var(--color-info-w100)]/60 dark:text-[var(--color-white)] dark:border-[var(--color-info-wMain)]",success:"bg-[var(--color-success-w20)] text-[var(--color-success-wMain)] border-[var(--color-success-w40)] dark:bg-[var(--color-success-w100)]/60 dark:text-[var(--color-white)] dark:border-l-[var(--color-success-w70)]"},c4=Uo("flex items-center gap-3 px-4 py-3 text-sm font-medium transition-all border-l-4 border-solid ",{variants:{variant:l4},defaultVariants:{variant:"error"}}),u4={error:fo,warning:Wd,info:ti,success:Hd};function Kt({className:e,variant:t="error",message:n,icon:r,dismissible:o=!1,onDismiss:a,...i}){const l=u4[t||"error"];return s.jsxs("div",{"data-testid":"messageBanner",className:ze(c4({variant:t,className:e}),"items-start"),role:"alert","aria-live":"polite",...i,children:[r||s.jsx(l,{className:"size-5 shrink-0"}),typeof n=="string"?s.jsx("span",{children:n}):n,s.jsx("div",{className:"ml-auto flex items-center gap-1",children:o&&a&&s.jsx(xe,{variant:"link",className:"h-min self-center p-0",onClick:a,"aria-label":"Dismiss",children:s.jsx(po,{className:"size-3"})})})]})}const d4=({fileName:e,onRemove:t})=>s.jsxs(zr,{className:"bg-muted max-w-50 gap-1.5 rounded-full pr-1",children:[s.jsx("span",{className:"min-w-0 flex-1 truncate text-xs md:text-sm",title:e,children:e}),t&&s.jsx(xe,{variant:"ghost",size:"icon",onClick:t,className:"h-2 min-h-0 w-2 min-w-0 p-2",title:"Remove file",children:s.jsx(po,{})})]}),ih=({group:e,onSubmit:t,onClose:n})=>{var f;const r=((f=e.productionPrompt)==null?void 0:f.promptText)||"",o=Ks(r),[a,i]=d.useState(()=>{const h={};return o.forEach(m=>{h[m]=""}),h}),[l,c]=d.useState(!1),u=h=>{if(h.preventDefault(),!o.every(x=>{var g;return(g=a[x])==null?void 0:g.trim()})){c(!0),setTimeout(()=>c(!1),3e3);return}const p=Nk(r,a);t(p)};return d.useEffect(()=>{const h=m=>{m.key==="Escape"&&n()};return window.addEventListener("keydown",h),()=>window.removeEventListener("keydown",h)},[n]),s.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4",children:s.jsxs("div",{className:"flex max-h-[80vh] w-full max-w-lg flex-col rounded-lg border border-[var(--border)] bg-[var(--background)] shadow-lg",children:[s.jsxs("div",{className:"flex-shrink-0 p-6 pb-4",children:[s.jsxs("h2",{className:"text-lg font-semibold",children:["Insert ",e.name]}),s.jsx("p",{className:"mt-1 text-sm text-[var(--muted-foreground)]",children:"Variables represent placeholder information in the template. Enter a value for each placeholder below."})]}),l&&s.jsx("div",{className:"flex-shrink-0 px-6",children:s.jsx(Kt,{variant:"error",message:"Please fill in all variables before inserting the prompt"})}),s.jsxs("form",{onSubmit:u,className:"flex min-h-0 flex-1 flex-col",children:[s.jsx("div",{className:"flex-1 overflow-y-auto px-6 py-4",children:s.jsx("div",{className:"space-y-4",children:o.map(h=>s.jsxs("div",{children:[s.jsx("label",{htmlFor:`var-${h}`,className:"mb-1 block text-sm font-medium",children:h}),s.jsx("textarea",{id:`var-${h}`,value:a[h],onChange:m=>i(p=>({...p,[h]:m.target.value})),className:"min-h-[80px] w-full rounded-md border border-[var(--border)] bg-[var(--background)] p-2 text-sm focus:ring-2 focus:ring-[var(--primary)] focus:outline-none",required:!0})]},h))})}),s.jsxs("div",{className:"flex flex-shrink-0 justify-end gap-2 border-t border-[var(--border)] p-6 pt-4",children:[s.jsx(xe,{type:"button",variant:"ghost",onClick:n,children:"Cancel"}),s.jsx(xe,{type:"submit",children:"Insert Prompt"})]})]})]})})},Nm=[{command:"create-template",name:"Create Template from Session",description:"Create a reusable prompt template from this conversation",icon:ts}],f4=({isOpen:e,onClose:t,textAreaRef:n,onPromptSelect:r,messages:o=[],onReservedCommand:a})=>{const i=zo(),[l,c]=d.useState(""),[u,f]=d.useState(0),[h,m]=d.useState([]),[p,x]=d.useState(!1),[g,w]=d.useState(null),[v,b]=d.useState(!1),[C,S]=d.useState(!1),E=d.useRef(null),_=d.useRef(null),j=d.useRef(null);d.useEffect(()=>{if(!e)return;(async()=>{x(!0);try{const I=await _n("/api/v1/prompts/groups/all");m(I)}catch(I){console.error("Failed to fetch prompt groups:",I)}finally{x(!1)}})()},[e]);const A=d.useMemo(()=>{const F=o.some(I=>I.isUser&&!I.isStatusBubble);return Nm.filter(I=>I.command==="create-template"?F:!0)},[o]),P=d.useMemo(()=>{if(!l)return h;const F=l.toLowerCase();return h.filter(I=>{var J,L,D;return I.name.toLowerCase().includes(F)||((J=I.description)==null?void 0:J.toLowerCase().includes(F))||((L=I.command)==null?void 0:L.toLowerCase().includes(F))||((D=I.category)==null?void 0:D.toLowerCase().includes(F))})},[h,l]),O=d.useMemo(()=>[...P,...A],[P,A]),B=d.useCallback(F=>F.filter(I=>!I.isStatusBubble&&!I.isError&&!I.authenticationLink).map(I=>{var D;const J=I.isUser?"User":"Assistant",L=((D=I.parts)==null?void 0:D.filter(W=>W.kind==="text").map(W=>W.text).join(`
144
+ `))||"";return`${J}: ${L}`}).join(`
145
+
146
+ `),[]),N=d.useCallback(F=>{if(F.command==="create-template"&&a){const I=B(o);a(F.command,I),t(),c("")}},[o,B,a,t]),M=d.useCallback(()=>{t(),c(""),i("/prompts/new?mode=ai-assisted")},[t,i]),y=d.useCallback(F=>{var D;const I=((D=F.productionPrompt)==null?void 0:D.promptText)||"";Ks(I).length>0?(w(F),b(!0)):(r(I),t(),c(""))},[r,t]),T=d.useCallback(F=>{"command"in F&&Nm.some(I=>I.command===F.command)?N(F):y(F)},[N,y]),R=d.useCallback(F=>{r(F),b(!1),w(null),t(),c("")},[r,t]),z=d.useCallback(F=>{var I,J;F.key==="Escape"?(F.preventDefault(),F.stopPropagation(),t(),c(""),(I=n.current)==null||I.focus()):F.key==="ArrowDown"?(F.preventDefault(),S(!0),f(L=>Math.min(L+1,O.length-1))):F.key==="ArrowUp"?(F.preventDefault(),S(!0),f(L=>Math.max(L-1,0))):F.key==="Enter"||F.key==="Tab"?(F.preventDefault(),O[u]&&T(O[u])):F.key==="Backspace"&&l===""&&(t(),(J=n.current)==null||J.focus())},[O,u,l,T,t,n]);return d.useEffect(()=>{e&&E.current&&E.current.focus()},[e]),d.useEffect(()=>{f(0)},[l]),d.useEffect(()=>{const F=document.getElementById(`prompt-item-${u}`);F&&F.scrollIntoView({behavior:"smooth",block:"nearest"})},[u]),e?s.jsxs(s.Fragment,{children:[s.jsx("div",{ref:j,className:"fixed inset-0 z-40 bg-black/20",onClick:t}),s.jsx("div",{"data-testid":"promptCommand",className:"fixed top-1/3 left-1/2 z-50 w-full max-w-[672px] -translate-x-1/2 px-4",children:s.jsxs("div",{ref:_,className:"flex flex-col rounded-lg border border-[var(--border)] bg-[var(--background)] shadow-lg",style:{maxHeight:"60vh"},children:[s.jsxs("div",{className:"flex items-center gap-2 border-b border-[var(--border)] p-3",children:[s.jsx(Vd,{className:"size-4 text-[var(--muted-foreground)]"}),s.jsx("input",{ref:E,type:"text",value:l,onChange:F=>c(F.target.value),onKeyDown:z,placeholder:"Search by shortcut or name...",className:"flex-1 bg-transparent text-sm outline-none placeholder:text-[var(--muted-foreground)]"})]}),s.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto",children:p?s.jsx("div",{className:"flex items-center justify-center p-8",children:s.jsx("div",{className:"size-6 animate-spin rounded-full border-2 border-[var(--primary)] border-t-transparent"})}):O.length===0?s.jsxs("div",{className:"flex flex-col items-center justify-center gap-4 p-8 text-center",children:[s.jsx("p",{className:"text-sm text-[var(--muted-foreground)]",children:l?"No prompts found":"No prompts available."}),!l&&s.jsxs("button",{onClick:M,className:"inline-flex items-center gap-2 rounded-md bg-[var(--primary)] px-4 py-2 text-sm font-medium text-[var(--primary-foreground)] transition-colors hover:bg-[var(--primary)]/90",children:[s.jsx(ns,{className:"size-4"}),"Create Prompt"]})]}):s.jsxs("div",{className:"flex flex-col p-2",children:[P.map((F,I)=>s.jsx("button",{id:`prompt-item-${I}`,onClick:()=>y(F),onMouseEnter:()=>{S(!1),f(I)},className:`w-full rounded-md p-3 text-left transition-colors ${I===u?"bg-[var(--accent)]":C?"":"hover:bg-[var(--accent)]"}`,children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx(ts,{className:"mt-0.5 size-4 flex-shrink-0 text-[var(--muted-foreground)]"}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[F.command&&s.jsxs("span",{className:"font-mono text-xs text-[var(--primary)]",children:["/",F.command]}),s.jsx("span",{className:"text-sm font-medium",children:F.name}),F.category&&s.jsx("span",{className:"rounded bg-[var(--muted)] px-1.5 py-0.5 text-xs text-[var(--muted-foreground)]",children:F.category})]}),F.description&&s.jsx("p",{className:"mt-1 line-clamp-2 text-xs text-[var(--muted-foreground)]",children:F.description})]})]})},F.id)),A.length>0&&s.jsxs(s.Fragment,{children:[P.length>0&&s.jsx("div",{className:"my-2 border-t border-[var(--border)]"}),A.map((F,I)=>{const J=P.length+I,L=F.icon;return s.jsx("button",{id:`prompt-item-${J}`,onClick:()=>N(F),onMouseEnter:()=>{S(!1),f(J)},className:`w-full rounded-md p-3 text-left transition-colors ${J===u?"bg-[var(--accent)]":C?"":"hover:bg-[var(--accent)]"}`,children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx(L,{className:"mt-0.5 size-4 flex-shrink-0 text-[var(--primary)]"}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsxs("span",{className:"font-mono text-xs text-[var(--primary)]",children:["/",F.command]}),s.jsx("span",{className:"text-sm font-medium",children:F.name}),s.jsx("span",{className:"rounded bg-[var(--primary)]/10 px-1.5 py-0.5 text-xs text-[var(--primary)]",children:"Reserved"})]}),s.jsx("p",{className:"mt-1 line-clamp-2 text-xs text-[var(--muted-foreground)]",children:F.description})]})]})},`reserved-${F.command}`)})]})]})})]})}),v&&g&&s.jsx(ih,{group:g,onSubmit:R,onClose:()=>{b(!1),w(null)}})]}):null},h4=({content:e,onClick:t,onRemove:n,isConfigured:r,filename:o,defaultFilename:a})=>{const l=(u=>u.split(`
147
+ `).slice(0,2).map(h=>{const m=h.trim();return m.length>40?m.substring(0,37)+"...":m}))(e),c=r?`Click to edit: ${o}`:"Click to customize file settings";return s.jsxs(vo,{children:[s.jsx(wo,{asChild:!0,children:s.jsxs("div",{className:`bg-background relative inline-flex max-w-[200px] cursor-pointer flex-col rounded-lg border shadow-sm transition-colors ${r?"border-[var(--color-info-wMain)]/50 hover:border-[var(--color-info-wMain)]":"border-border hover:border-primary/50"}`,onClick:t,children:[s.jsx(xe,{variant:"ghost",size:"icon",onClick:u=>{u.stopPropagation(),n()},className:"bg-background border-border hover:bg-muted absolute -top-2 -left-2 h-5 w-5 rounded-full border p-0 shadow-sm",tooltip:"Remove pasted text",tooltipSide:"left",children:s.jsx(po,{className:"h-3 w-3"})}),s.jsxs("div",{className:"text-muted-foreground overflow-hidden px-3 pt-3 pb-2 font-mono text-xs leading-relaxed",children:[l.map((u,f)=>s.jsx("div",{className:"truncate",children:u||" "},f)),e.split(`
148
+ `).length>2&&s.jsx("div",{className:"text-muted-foreground/60",children:"..."})]}),s.jsx("div",{className:"flex items-center gap-1 px-2 pb-2",children:r?s.jsxs("span",{className:"inline-flex max-w-[170px] items-center gap-1.5 truncate rounded bg-[var(--color-info-w10)] px-2 py-0.5 text-[10px] font-semibold tracking-wider text-[var(--color-info-wMain)] dark:bg-[var(--color-info-wMain)] dark:text-[var(--color-primary-text-w10)]",children:[o||"CONFIGURED",s.jsx("span",{className:"h-1.5 w-1.5 flex-shrink-0 rounded-full bg-[var(--color-info-wMain)] dark:bg-[var(--color-primary-text-w10)]"})]}):s.jsx("span",{className:"bg-muted text-muted-foreground inline-block max-w-[170px] truncate rounded px-2 py-0.5 text-[10px] font-semibold tracking-wider",children:a||"snippet.txt"})})]})}),s.jsx(bo,{side:"top",children:s.jsx("p",{children:c})})]})},p4=e=>{const t=e.length,n=e.split(`
149
+ `).length;return t>=2e3||n>=50},m4=e=>{const t=e.length,n=e.split(`
150
+ `).length,r=e.substring(0,50).replace(/\n/g," ").trim(),o=r.length<e.length?`${r}...`:r;return`Pasted text (${t} chars, ${n} lines): ${o}`},g4=e=>({id:`paste-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,content:e,timestamp:Date.now()}),x4=[{value:"text/plain",label:"Plain Text"},{value:"text/markdown",label:"Markdown"},{value:"text/csv",label:"CSV"},{value:"application/json",label:"JSON"},{value:"text/html",label:"HTML"},{value:"text/css",label:"CSS"},{value:"text/javascript",label:"JavaScript"},{value:"text/typescript",label:"TypeScript"},{value:"text/python",label:"Python"},{value:"text/yaml",label:"YAML"},{value:"text/xml",label:"XML"}],v4=e=>({"text/plain":"txt","text/markdown":"md","text/csv":"csv","application/json":"json","text/html":"html","text/css":"css","text/javascript":"js","text/typescript":"ts","text/python":"py","text/yaml":"yaml","text/xml":"xml"})[e]||"txt",w4=(e,t,n)=>{const r=`${e}.${t}`;if(!n.includes(r))return r;let o=2;for(;n.includes(`${e}-${o}.${t}`);)o++;return`${e}-${o}.${t}`},Zi="text/plain",b4=({isOpen:e,content:t,onSaveMetadata:n,onCancel:r,existingArtifacts:o=[],initialFilename:a,initialMimeType:i,initialDescription:l,defaultFilename:c})=>{const[u,f]=d.useState("snippet.txt"),[h,m]=d.useState(""),[p,x]=d.useState(Zi),[g,w]=d.useState(""),[v,b]=d.useState(null),S=o.includes(u)&&u!==a;d.useEffect(()=>{if(e&&t)if(w(t),a)f(a),x(i||Zi),m(l||"");else{x(Zi);const O=c||w4("snippet","txt",o);f(O);const B=m4(t);m(B)}},[e,t,o,a,i,l,c]),d.useEffect(()=>{const O=v4(p);if(u.match(/^snippet(-\d+)?\.[\w]+$/)){const B=u.match(/^(snippet(-\d+)?)\./),M=`${B?B[1]:"snippet"}.${O}`;M!==u&&f(M)}},[p,u]);const E=()=>{if(!g.trim()){b("Content cannot be empty. Please add some content before saving.");return}b(null),n({filename:u,mimeType:p,description:h.trim()||void 0,content:g}),j()},_=()=>{j(),r()},j=()=>{f("snippet.txt"),m(""),x(Zi),w(""),b(null)},A=g.length,P=g.split(`
151
+ `).length;return s.jsx(On,{open:e,onOpenChange:_,children:s.jsxs(Ln,{className:"flex max-h-[80vh] flex-col sm:max-w-2xl",children:[s.jsxs(Gn,{children:[s.jsx(Fn,{children:"Customize File"}),s.jsx(Yn,{children:"Customize the file settings before sending to the agent"})]}),s.jsxs("div",{className:"flex-1 space-y-4 overflow-y-auto py-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(It,{htmlFor:"title",children:"Filename"}),s.jsx(br,{id:"title",value:u,onChange:O=>f(O.target.value),placeholder:"snippet.txt",autoFocus:!1,onFocus:O=>{setTimeout(()=>{O.target.setSelectionRange(O.target.value.length,O.target.value.length)},0)}}),S&&s.jsx(Kt,{variant:"warning",message:"A file with this name already exists. Saving will create a new version."})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(It,{htmlFor:"description",children:"Description (optional)"}),s.jsx(br,{id:"description",value:h,onChange:O=>m(O.target.value),placeholder:"Brief description of this file"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(It,{htmlFor:"type",children:"Type"}),s.jsxs(Rr,{value:p,onValueChange:x,children:[s.jsx(Mr,{id:"type",children:s.jsx(Pr,{})}),s.jsx(Dr,{children:x4.map(O=>s.jsx(jt,{value:O.value,children:O.label},O.value))})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(It,{htmlFor:"content",children:"Content"}),s.jsx(Wr,{id:"content",value:g,onChange:O=>{w(O.target.value),O.target.value.trim()&&v&&b(null)},className:"min-h-[300px] resize-y font-mono text-sm",placeholder:"Paste content here..."}),s.jsxs("p",{className:"text-muted-foreground text-xs",children:[A," characters, ",P," lines"]}),v&&s.jsx(Kt,{variant:"error",message:v,dismissible:!0,onDismiss:()=>b(null)})]})]}),s.jsxs(nr,{children:[s.jsx(xe,{variant:"ghost",onClick:_,children:"Cancel"}),s.jsx(xe,{onClick:E,disabled:!u.trim(),children:"Customize"})]})]})})},y4=(e,t)=>{switch(e){case"create-template":return t?["I want to create a reusable prompt template based on this conversation I just had:","","<conversation_history>",t,"</conversation_history>","","Please help me create a prompt template by:","","1. **Analyzing the Pattern**: Identify the core task/question pattern in this conversation","2. **Extracting Variables**: Determine which parts should be variables (use {{variable_name}} syntax)","3. **Generalizing**: Make it reusable for similar tasks","4. **Suggesting Metadata**: Recommend a name, description, category, and chat shortcut","","Focus on capturing what made this conversation successful so it can be reused with different inputs."].join(`
152
+ `):"Help me create a new prompt template.";default:return""}},C4=({agents:e=[],scrollToBottom:t})=>{const n=zo(),r=Vr(),{isResponding:o,isCancelling:a,selectedAgentName:i,sessionId:l,setSessionId:c,handleSubmit:u,handleCancel:f,uploadArtifactFile:h,displayError:m,artifacts:p,messages:x,startNewChatWithPrompt:g,pendingPrompt:w,clearPendingPrompt:v}=Ft(),{handleAgentSelection:b}=LT(),{settings:C}=Bo(),{configFeatureEnablement:S}=Ut(),E=(S==null?void 0:S.speechToText)??!0,_=d.useRef(null),[j,A]=d.useState([]),[P,O]=d.useState([]),[B,N]=d.useState(null),[M,y]=d.useState(!1),[T,R]=d.useState(null),[z,F]=d.useState(!1),I=d.useRef(null),J=d.useRef(o),[L,D]=d.useState(""),[W,G]=d.useState(!1),[V,Q]=d.useState(!1),[X,K]=d.useState(null),[q,ne]=d.useState(null),[de,se]=d.useState(!1),me=d.useRef(l),k=d.useRef(null);d.useEffect(()=>{var ve;if((ve=r.state)!=null&&ve.promptText&&k.current!==r.state.groupId){const{promptText:Pe,groupId:Me,groupName:Oe}=r.state;k.current=Me,n(r.pathname,{replace:!0,state:{}}),g({promptText:Pe,groupId:Me,groupName:Oe}),setTimeout(()=>{k.current=null},1e3)}},[r.state,r.pathname,n,g]),d.useEffect(()=>{if(w&&i){const{promptText:ve,groupId:Pe,groupName:Me}=w;Ks(ve).length>0?(K({id:Pe,name:Me,productionPrompt:{promptText:ve}}),Q(!0)):(D(ve),setTimeout(()=>{var at;(at=I.current)==null||at.focus()},100)),v()}},[w,i,v]),d.useEffect(()=>{if(w){me.current=l;return}me.current&&me.current!==l&&(D(""),G(!1),O([])),me.current=l,R(null)},[w,l]),d.useEffect(()=>{J.current&&!o&&setTimeout(()=>{var ve;(ve=I.current)==null||ve.focus()},100),J.current=o},[o]),d.useEffect(()=>{const ve=()=>{setTimeout(()=>{var Pe;(Pe=I.current)==null||Pe.focus()},100)};return window.addEventListener("focus-chat-input",ve),()=>{window.removeEventListener("focus-chat-input",ve)}},[]),d.useEffect(()=>{const ve=async Pe=>{const Me=Pe,{text:Oe,prompt:at,autoSubmit:Ue}=Me.detail;if(at){if(R(Oe),D(at+" "),Ue){setTimeout(async()=>{const it=`${at}
153
+
154
+ Context: "${Oe}"`,We=new Event("submit");await u(We,[],it),R(null),F(!1),D(""),t==null||t()},50);return}}else R(Oe),F(!0);setTimeout(()=>{var it;(it=I.current)==null||it.focus()},100)};return window.addEventListener("follow-up-question",ve),()=>{window.removeEventListener("follow-up-question",ve)}},[u,t]);const oe=()=>{var ve;o||(ve=_.current)==null||ve.click()},ie=ve=>{const Pe=ve.target.files;if(Pe){const Me=Array.from(Pe).filter(Oe=>!j.some(at=>at.name===Oe.name&&at.size===Oe.size&&at.lastModified===Oe.lastModified));Me.length>0&&A(Oe=>[...Oe,...Me])}ve.target&&(ve.target.value=""),setTimeout(()=>{var Me;(Me=I.current)==null||Me.focus()},100)},Z=async ve=>{if(o)return;const Pe=ve.clipboardData;if(!Pe)return;if(Pe.files&&Pe.files.length>0){ve.preventDefault();const Oe=Array.from(Pe.files).filter(at=>!j.some(Ue=>Ue.name===at.name&&Ue.size===at.size&&Ue.lastModified===at.lastModified));Oe.length>0&&A(at=>[...at,...Oe]);return}const Me=Pe.getData("text");if(Me&&p4(Me)){ve.preventDefault();const Oe=g4(Me);O(at=>[...at,Oe])}},U=ve=>{B&&(O(Pe=>Pe.map(Me=>Me.id===B?{...Me,content:ve.content,filename:ve.filename,mimeType:ve.mimeType,description:ve.description,isConfigured:!0}:Me)),N(null),y(!1))},re=()=>{N(null),y(!1)},$=ve=>{N(ve),y(!0)},Y=ve=>{O(Pe=>Pe.filter(Me=>Me.id!==ve))},H=ve=>{A(Pe=>Pe.filter((Me,Oe)=>Oe!==ve))},ce=d.useMemo(()=>!o&&((L==null?void 0:L.trim())||j.length!==0||P.length!==0),[o,L,j,P]),ue=async ve=>{if(ve.preventDefault(),ce){let Pe=L.trim();T&&z&&(Pe=`Context: "${T}"
155
+
156
+ ${Pe}`);const Me=[];let Oe=l;const at=new Set(p.map(We=>We.filename));for(let We=0;We<P.length;We++){const ft=P[We];try{let Et,hn,Dn;if(ft.isConfigured&&ft.filename&&ft.mimeType)Et=ft.filename,hn=ft.mimeType,Dn=ft.description;else{hn="text/plain";const be="txt";if(Et=`snippet.${be}`,at.has(Et)){let _e=2;for(;at.has(`snippet-${_e}.${be}`);)_e++;Et=`snippet-${_e}.${be}`}}at.add(Et);const ee=new Blob([ft.content],{type:hn}),le=new File([ee],Et,{type:hn}),fe=await h(le,Oe,Dn,!0);if(fe&&!("error"in fe))fe.sessionId&&fe.sessionId!==Oe&&(Oe=fe.sessionId,c(fe.sessionId)),Me.push({uri:fe.uri,filename:Et,mimeType:hn});else{const be=fe&&"error"in fe?fe.error:"An unknown upload error occurred.";throw new Error(be)}}catch(Et){m({title:"Failed to Save Pasted Text",error:Yt(Et)})}}const Ue=Me.map(We=>{const ft=JSON.stringify({isArtifactReference:!0,uri:We.uri,filename:We.filename,mimeType:We.mimeType}),Et=new Blob([ft],{type:"application/x-artifact-reference"});return new File([Et],We.filename,{type:"application/x-artifact-reference"})}),it=[...j,...Ue];await u(ve,it,Pe,Oe||null),A([]),O([]),D(""),R(null),F(!1),t==null||t()}},ae=ve=>{if(o)return;const Pe=ve.filter(Me=>!j.some(Oe=>Oe.name===Me.name&&Oe.size===Me.size&&Oe.lastModified===Me.lastModified));Pe.length>0&&A(Me=>[...Me,...Pe])},{isDragging:pe,handleDragEnter:Te,handleDragOver:Ae,handleDragLeave:gt,handleDrop:Pt}=AT({onFilesDropped:ae,disabled:o}),Nt=ve=>{const Pe=ve.target.value;D(Pe);const Me=ve.target.selectionStart,Oe=Pe.substring(0,Me),at=Oe[Oe.length-1],Ue=Oe[Oe.length-2];at==="/"&&(!Ue||Ue===" "||Ue===`
157
+ `)?G(!0):W&&!Oe.includes("/")&&G(!1)},Mt=ve=>{var it;const Pe=((it=I.current)==null?void 0:it.selectionStart)||0,Me=L.substring(0,Pe),Oe=L.substring(Pe),at=Me.lastIndexOf("/"),Ue=Me.substring(0,at)+ve+Oe;D(Ue),G(!1),setTimeout(()=>{var We;(We=I.current)==null||We.focus()},100)},ct=(ve,Pe)=>{const Me=y4(ve,Pe);switch(ve){case"create-template":{n("/prompts/new?mode=ai-assisted",{state:{taskDescription:Me}}),D(""),G(!1);break}}},$t=ve=>{D(ve),Q(!1),K(null),setTimeout(()=>{var Pe;(Pe=I.current)==null||Pe.focus()},100)},Wt=d.useCallback(ve=>{const Pe=L?`${L} ${ve}`:ve;D(Pe),setTimeout(()=>{var Me;(Me=I.current)==null||Me.focus()},100)},[L]),Dt=d.useCallback(ve=>{ne(ve)},[]);return s.jsxs("div",{className:`bg-card rounded-lg border p-4 shadow-sm ${pe?"border-dotted border-[var(--primary-wMain)] bg-[var(--accent-background)]":""}`,onDragEnter:Te,onDragOver:Ae,onDragLeave:gt,onDrop:Pt,children:[q&&s.jsx("div",{className:"mb-3",children:s.jsx(Kt,{variant:"error",message:q,dismissible:!0,onDismiss:()=>ne(null)})}),s.jsx("input",{type:"file",ref:_,className:"hidden",multiple:!0,onChange:ie,accept:"*/*",disabled:o}),j.length>0&&s.jsx("div",{className:"mb-2 flex flex-wrap gap-2",children:j.map((ve,Pe)=>s.jsx(d4,{fileName:ve.name,onRemove:()=>H(Pe)},`${ve.name}-${ve.lastModified}-${Pe}`))}),z&&T&&s.jsx("div",{className:"mb-2",children:s.jsxs("div",{className:"bg-muted/50 inline-flex items-center gap-2 rounded-md border px-3 py-2 text-sm",children:[s.jsxs("div",{className:"flex flex-1 items-center gap-2",children:[s.jsx(Dg,{className:"text-muted-foreground h-4 w-4 flex-shrink-0"}),s.jsxs("span",{className:"text-muted-foreground max-w-[600px] truncate italic",children:['"',T.length>100?T.substring(0,100)+"...":T,'"']})]}),s.jsxs(xe,{variant:"ghost",size:"icon",className:"hover:bg-background h-5 w-5 rounded-sm",onClick:()=>{R(null),F(!1)},children:[s.jsx("span",{className:"sr-only",children:"Remove context"}),s.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",className:"h-3.5 w-3.5",children:s.jsx("path",{d:"M6.28 5.22a.75.75 0 00-1.06 1.06L8.94 10l-3.72 3.72a.75.75 0 101.06 1.06L10 11.06l3.72 3.72a.75.75 0 101.06-1.06L11.06 10l3.72-3.72a.75.75 0 00-1.06-1.06L10 8.94 6.28 5.22z"})})]})]})}),P.length>0&&s.jsx("div",{className:"mb-2 flex max-h-32 flex-wrap gap-2 overflow-y-auto pt-2 pl-2",children:P.map((ve,Pe)=>{let Me="snippet.txt";if(!ve.isConfigured){const Oe=new Set(p.map(Ue=>Ue.filename));P.slice(0,Pe).forEach(Ue=>{Ue.isConfigured&&Ue.filename&&Oe.add(Ue.filename)});let at="snippet.txt";for(let Ue=0;Ue<Pe;Ue++)if(!P[Ue].isConfigured&&(Oe.add(at),Oe.has("snippet.txt"))){let We=2;for(;Oe.has(`snippet-${We}.txt`);)We++;at=`snippet-${We}.txt`}if(Oe.has("snippet.txt")){let Ue=2;for(;Oe.has(`snippet-${Ue}.txt`);)Ue++;Me=`snippet-${Ue}.txt`}}return s.jsx(h4,{id:ve.id,content:ve.content,onClick:()=>$(ve.id),onRemove:()=>Y(ve.id),isConfigured:ve.isConfigured,filename:ve.filename,defaultFilename:Me},ve.id)})}),(()=>{const ve=P.find(Ue=>Ue.id===B),Pe=P.findIndex(Ue=>Ue.id===B),Me=new Set(p.map(Ue=>Ue.filename));let Oe="snippet.txt";P.forEach((Ue,it)=>{if(Ue.id!==B)if(Ue.isConfigured&&Ue.filename)Me.add(Ue.filename);else if(it<Pe||Pe===-1){if(Me.has(Oe)){let We=2;for(;Me.has(`snippet-${We}.txt`);)We++;Oe=`snippet-${We}.txt`}if(Me.add(Oe),Me.has("snippet.txt")){let We=2;for(;Me.has(`snippet-${We}.txt`);)We++;Oe=`snippet-${We}.txt`}else Oe="snippet.txt"}else{if(Me.has(Oe)){let We=2;for(;Me.has(`snippet-${We}.txt`);)We++;Oe=`snippet-${We}.txt`}if(Me.add(Oe),Me.has("snippet.txt")){let We=2;for(;Me.has(`snippet-${We}.txt`);)We++;Oe=`snippet-${We}.txt`}else Oe="snippet.txt"}});let at="snippet.txt";if(ve&&!ve.isConfigured&&Pe>=0){const Ue=new Set(p.map(We=>We.filename));P.slice(0,Pe).forEach(We=>{We.isConfigured&&We.filename&&Ue.add(We.filename)});let it="snippet.txt";for(let We=0;We<Pe;We++)if(!P[We].isConfigured&&(Ue.add(it),Ue.has("snippet.txt"))){let Et=2;for(;Ue.has(`snippet-${Et}.txt`);)Et++;it=`snippet-${Et}.txt`}if(Ue.has("snippet.txt")){let We=2;for(;Ue.has(`snippet-${We}.txt`);)We++;at=`snippet-${We}.txt`}}return s.jsx(b4,{isOpen:M,content:(ve==null?void 0:ve.content)||"",onSaveMetadata:U,onCancel:re,existingArtifacts:Array.from(Me),initialFilename:ve==null?void 0:ve.filename,initialMimeType:ve==null?void 0:ve.mimeType,initialDescription:ve==null?void 0:ve.description,defaultFilename:at})})(),s.jsx(f4,{isOpen:W,onClose:()=>{G(!1)},textAreaRef:I,onPromptSelect:Mt,messages:x,onReservedCommand:ct}),V&&X&&s.jsx(ih,{group:X,onSubmit:$t,onClose:()=>{Q(!1),K(null)}}),s.jsx(Jb,{ref:I,value:L,onChange:Nt,placeholder:de?"Recording...":"How can I help you today? (Type '/' to insert a prompt)",className:"field-sizing-content max-h-50 min-h-0 resize-none rounded-2xl border-none p-3 text-base/normal shadow-none transition-[height] duration-500 ease-in-out focus-visible:outline-none",rows:1,onPaste:Z,disabled:de,onKeyDown:ve=>{ve.key==="Enter"&&!ve.shiftKey&&ce&&ue(ve)}}),s.jsxs("div",{className:"m-2 flex items-center gap-2",children:[s.jsx(xe,{variant:"ghost",onClick:oe,disabled:o,tooltip:"Attach file",children:s.jsx(Lg,{className:"size-4"})}),s.jsx("div",{children:"Agent: "}),s.jsxs(Rr,{value:i,onValueChange:b,disabled:o||e.length===0,children:[s.jsx(Mr,{className:"w-[250px]",children:s.jsx(Pr,{placeholder:"Select an agent..."})}),s.jsx(Dr,{children:e.map(ve=>s.jsx(jt,{value:ve.name,children:ve.displayName||ve.name},ve.name))})]}),s.jsx("div",{className:"flex-1"}),E&&C.speechToText&&s.jsx(ah,{disabled:o,onTranscriptionComplete:Wt,onError:Dt,onRecordingStateChange:se}),o&&!a?s.jsxs(xe,{"data-testid":"cancel",className:"ml-auto gap-1.5",onClick:f,variant:"outline",disabled:a,tooltip:"Cancel",children:[s.jsx(Y1,{className:"size-4"}),"Stop"]}):s.jsx(xe,{"data-testid":"sendMessage",variant:"ghost",className:"ml-auto gap-1.5",onClick:ue,disabled:!ce,tooltip:"Send message",children:s.jsx(Fg,{className:"size-4"})})]})]})},S4=({content:e,mime_type:t,setRenderError:n})=>{const r=`data:${t||"audio/mpeg"};base64,${e}`;return s.jsx("div",{className:"flex h-auto max-w-[100vw] items-center justify-center p-4",children:s.jsxs("audio",{controls:!0,className:"w-full",onLoad:()=>n(null),onError:()=>n("Failed to load audio content."),children:[s.jsx("source",{src:r,type:t||"audio/mpeg"}),"Your browser does not support the audio element."]})})},_4=e=>{if(!e)return[];const t=[];let n=[],r="",o=!1;for(let a=0;a<e.length;a++){const i=e[a],l=a<e.length-1?e[a+1]:"";i==='"'?l==='"'?(r+='"',a++):o=!o:i===","&&!o?(n.push(r.trim()),r=""):(i===`
158
+ `||i==="\r"&&l===`
159
+ `)&&!o?(i==="\r"&&l===`
160
+ `&&a++,n.push(r.trim()),r="",n.some(c=>c.trim())?(t.push(n),n=[]):n=[]):r+=i}return(r||n.length>0)&&(n.push(r.trim()),n.some(a=>a.trim())&&t.push(n)),t},k4=({content:e,setRenderError:t})=>{d.useEffect(()=>{t(null)},[e,t]);const n=d.useMemo(()=>{try{return _4(e)}catch(r){return console.error("Error parsing CSV:",r),t("Failed to parse CSV content."),[]}},[e,t]);return n.length?s.jsx("div",{className:"block w-full overflow-x-scroll p-4",children:s.jsx("div",{style:{minWidth:"min(100%, max-content)"},children:s.jsxs("table",{className:"w-full border text-sm",children:[s.jsx("thead",{className:"sticky top-0 z-10 shadow-sm",children:n.length>0&&s.jsx("tr",{children:n[0].map((r,o)=>s.jsx("th",{className:"border-b p-2 text-left font-medium whitespace-nowrap",title:r,children:(r==null?void 0:r.trim())||""},`header-${o}`))})}),s.jsx("tbody",{children:n.slice(1).map((r,o)=>s.jsx("tr",{className:o%2===0?"bg-muted dark:bg-gray-700":"",children:r.map((a,i)=>s.jsx("td",{className:"min-w-0 border-b p-2 align-top break-words",title:a,children:(a==null?void 0:a.trim())||""},`cell-${o}-${i}`))},`row-${o}`))})]})})}):s.jsx("div",{children:"No valid CSV content found or failed to parse."})},E4=({content:e,setRenderError:t})=>{const n=d.useMemo(()=>e.replace(/<script(?:\s[^>]*)?>([\s\S]*?)<\/script>/gi,(a,i)=>{const l=a.match(/<script(\s[^>]*)?>/i);return`<script${l&&l[1]?l[1]:""}>(function() {
161
+ try {
162
+ ${i}
163
+ } catch (e) { console.error('Error in sandboxed script:', e); }
164
+ })();<\/script>`}),[e]);return s.jsx("div",{className:"h-full w-full overflow-hidden border dark:bg-gray-400",children:s.jsx("iframe",{srcDoc:n,title:"HTML Preview",sandbox:"allow-scripts allow-same-origin allow-downloads allow-forms allow-popups",allow:"autoplay",className:"h-full w-full border-none",onError:()=>t("Failed to load HTML content."),onLoad:()=>t(null)})})},j4=({content:e,mime_type:t,setRenderError:n})=>{const r=`data:${t||"image/png"};base64,${e}`;return s.jsx("div",{className:"flex h-auto w-auto max-w-[100vw] items-center justify-center p-4",children:s.jsx("img",{src:r,onError:()=>n("Failed to load image"),onLoad:()=>n(null),alt:"Preview",className:"h-full w-full object-contain"})})};function uy(){const e=d.useRef(null),t=()=>{if(e.current){const r=document.createRange();r.selectNodeContents(e.current);const o=window.getSelection();o&&(o.removeAllRanges(),o.addRange(r))}};return{ref:e,handleKeyDown:r=>{(r.metaKey||r.ctrlKey)&&r.key==="a"&&(r.preventDefault(),t())},selectAllContent:t}}const N4=({content:e})=>{const{ref:t,handleKeyDown:n}=uy();return s.jsx("div",{className:"w-full p-4",children:s.jsx("div",{ref:t,className:"max-w-full overflow-hidden select-text focus-visible:outline-none",tabIndex:0,onKeyDown:n,children:s.jsx(Hs,{className:"max-w-full break-words",children:e})})})},T4=({content:e,setRenderError:t})=>{const[n,r]=d.useState(""),o=d.useMemo(()=>cy.sanitize(e,{USE_PROFILES:{html:!1},ALLOWED_TAGS:["br","em","strong","b","i"],ALLOWED_ATTR:[]}),[e]);return d.useEffect(()=>{r(`<!DOCTYPE html>
165
+ <html>
166
+ <head>
167
+ <meta charset="utf-8">
168
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
169
+ <title>Mermaid Preview</title>
170
+ <script src="https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.min.js"><\/script>
171
+ <script src="https://cdn.jsdelivr.net/npm/panzoom@9.4.0/dist/panzoom.min.js"><\/script>
172
+ <script>
173
+ document.addEventListener('DOMContentLoaded', function() {
174
+ try {
175
+ mermaid.initialize({
176
+ startOnLoad: true,
177
+ theme: 'default',
178
+ fontFamily: 'arial, sans-serif',
179
+ logLevel: 'error',
180
+ securityLevel: 'strict'
181
+ });
182
+
183
+ // Initialize panzoom after Mermaid rendering
184
+ mermaid.run().then(() => {
185
+ const diagramContainer = document.getElementById('diagram-container');
186
+ if (diagramContainer) {
187
+ const pz = panzoom(diagramContainer, {
188
+ maxZoom: 10,
189
+ minZoom: 0.1,
190
+ smoothScroll: true,
191
+ bounds: true,
192
+ boundsPadding: 0.1
193
+ });
194
+ // Add zoom controls (old version had only reset)
195
+ const resetButton = document.getElementById('reset');
196
+ if (resetButton) {
197
+ resetButton.addEventListener('click', () => {
198
+ pz.moveTo(0, 0);
199
+ pz.zoomAbs(0, 0, 1);
200
+ });
201
+ }
202
+ }
203
+ }).catch(err => {
204
+ console.error("Mermaid rendering failed inside iframe:", err);
205
+ const mermaidDiv = document.querySelector('.mermaid');
206
+ if (mermaidDiv) mermaidDiv.innerText = "Error rendering diagram: " + err.message;
207
+ });
208
+
209
+ window.addEventListener('message', function(event) {
210
+ if (event.data && event.data.action === 'getMermaidSvg') {
211
+ const svgElement = document.querySelector('.mermaid svg');
212
+ if (svgElement) {
213
+ if (!svgElement.getAttribute('xmlns')) { // Ensure xmlns for standalone SVG
214
+ svgElement.setAttribute('xmlns', 'http://www.w3.org/2000/svg');
215
+ }
216
+ const svgData = new XMLSerializer().serializeToString(svgElement);
217
+ window.parent.postMessage({
218
+ action: 'downloadSvg',
219
+ svgData: svgData,
220
+ filename: event.data.filename || 'mermaid-diagram.svg'
221
+ }, '*');
222
+ } else {
223
+ console.error('SVG element not found for download inside iframe.');
224
+ }
225
+ }
226
+ });
227
+ } catch (e) {
228
+ console.error("Error initializing Mermaid or Panzoom inside iframe:", e);
229
+ const mermaidDiv = document.querySelector('.mermaid');
230
+ if (mermaidDiv) mermaidDiv.innerText = "Failed to initialize diagram viewer: " + e.message;
231
+ }
232
+ });
233
+ <\/script>
234
+ <style>
235
+ /* Styles from old code */
236
+ html, body {
237
+ height: 100%;
238
+ margin: 0;
239
+ padding: 0;
240
+ overflow: hidden;
241
+ font-family: Arial, sans-serif; /* Old font */
242
+ }
243
+ .container {
244
+ display: flex;
245
+ flex-direction: column;
246
+ height: 100vh;
247
+ overflow: hidden;
248
+ }
249
+ .diagram-wrapper {
250
+ flex: 1;
251
+ overflow: hidden;
252
+ position: relative;
253
+ display: flex;
254
+ justify-content: center;
255
+ align-items: center;
256
+ background-color: #f9f9f9;
257
+ }
258
+ #diagram-container {
259
+ transform-origin: 0 0;
260
+ cursor: grab;
261
+ box-shadow: 0 0 10px rgba(0,0,0,0.1);
262
+ background-color: white;
263
+ padding: 20px;
264
+ border-radius: 5px;
265
+ /* Ensure diagram container can hold the content */
266
+ width: auto; /* Adjust as needed, or let content define it */
267
+ height: auto;
268
+ max-width: 100%;
269
+ max-height: 100%;
270
+ }
271
+ #diagram-container:active {
272
+ cursor: grabbing;
273
+ }
274
+ .mermaid {
275
+ display: flex; /* Helps in centering if SVG is smaller */
276
+ justify-content: center;
277
+ align-items: center;
278
+ /* width: 100%; Ensures mermaid div takes space, SVG might scale within it */
279
+ /* height: 100%; */
280
+ }
281
+ .mermaid svg {
282
+ max-width: 100%; /* Ensure SVG scales down if too large */
283
+ max-height: 100%;
284
+ }
285
+ .controls{
286
+ position: fixed;
287
+ bottom: 20px;
288
+ right: 20px;
289
+ z-index: 1000;
290
+ display: flex;
291
+ gap: 5px;
292
+ }
293
+ .control-btn {
294
+ width: 40px;
295
+ height: 40px;
296
+ border-radius: 50%;
297
+ border: none;
298
+ background-color: white;
299
+ box-shadow: 0 2px 5px rgba(0,0,0,0.2);
300
+ cursor: pointer;
301
+ font-size: 18px;
302
+ display: flex;
303
+ align-items: center;
304
+ justify-content: center;
305
+ }
306
+ .control-btn:hover {
307
+ background-color: #f0f0f0;
308
+ }
309
+ .instructions {
310
+ position: fixed;
311
+ top: 10px;
312
+ left: 10px;
313
+ background-color: rgba(255,255,255,0.8);
314
+ padding: 5px 10px;
315
+ border-radius: 4px;
316
+ font-size: 12px;
317
+ color: #666;
318
+ }
319
+ </style>
320
+ </head>
321
+ <body>
322
+ <div class="container">
323
+ <div class="diagram-wrapper">
324
+ <div id="diagram-container">
325
+ <div class="mermaid">
326
+ ${o}
327
+ </div>
328
+ </div>
329
+ </div>
330
+ <div class="instructions">
331
+ Drag to pan and scroll to zoom
332
+ </div>
333
+ <div class="controls">
334
+ <button id="reset" class="control-btn" title="Reset View">↺</button>
335
+ </div>
336
+ </div>
337
+ </body>
338
+ </html>`)},[o]),s.jsx("div",{className:"bg-background h-full p-4",children:s.jsx("iframe",{srcDoc:n,title:"Mermaid Diagram Preview",sandbox:"allow-scripts allow-same-origin allow-downloads",className:"h-96 w-full resize border-none",onError:()=>t("Failed to load Mermaid content."),onLoad:()=>t(null)})})};/*! js-yaml 4.1.1 https://github.com/nodeca/js-yaml @license MIT */function dy(e){return typeof e>"u"||e===null}function A4(e){return typeof e=="object"&&e!==null}function I4(e){return Array.isArray(e)?e:dy(e)?[]:[e]}function R4(e,t){var n,r,o,a;if(t)for(a=Object.keys(t),n=0,r=a.length;n<r;n+=1)o=a[n],e[o]=t[o];return e}function P4(e,t){var n="",r;for(r=0;r<t;r+=1)n+=e;return n}function M4(e){return e===0&&Number.NEGATIVE_INFINITY===1/e}var D4=dy,O4=A4,L4=I4,F4=P4,$4=M4,z4=R4,kn={isNothing:D4,isObject:O4,toArray:L4,repeat:F4,isNegativeZero:$4,extend:z4};function fy(e,t){var n="",r=e.reason||"(unknown reason)";return e.mark?(e.mark.name&&(n+='in "'+e.mark.name+'" '),n+="("+(e.mark.line+1)+":"+(e.mark.column+1)+")",!t&&e.mark.snippet&&(n+=`
339
+
340
+ `+e.mark.snippet),r+" "+n):r}function Ka(e,t){Error.call(this),this.name="YAMLException",this.reason=e,this.mark=t,this.message=fy(this,!1),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack||""}Ka.prototype=Object.create(Error.prototype);Ka.prototype.constructor=Ka;Ka.prototype.toString=function(t){return this.name+": "+fy(this,t)};var Wn=Ka;function Eu(e,t,n,r,o){var a="",i="",l=Math.floor(o/2)-1;return r-t>l&&(a=" ... ",t=r-l+a.length),n-r>l&&(i=" ...",n=r+l-i.length),{str:a+e.slice(t,n).replace(/\t/g,"→")+i,pos:r-t+a.length}}function ju(e,t){return kn.repeat(" ",t-e.length)+e}function U4(e,t){if(t=Object.create(t||null),!e.buffer)return null;t.maxLength||(t.maxLength=79),typeof t.indent!="number"&&(t.indent=1),typeof t.linesBefore!="number"&&(t.linesBefore=3),typeof t.linesAfter!="number"&&(t.linesAfter=2);for(var n=/\r?\n|\r|\0/g,r=[0],o=[],a,i=-1;a=n.exec(e.buffer);)o.push(a.index),r.push(a.index+a[0].length),e.position<=a.index&&i<0&&(i=r.length-2);i<0&&(i=r.length-1);var l="",c,u,f=Math.min(e.line+t.linesAfter,o.length).toString().length,h=t.maxLength-(t.indent+f+3);for(c=1;c<=t.linesBefore&&!(i-c<0);c++)u=Eu(e.buffer,r[i-c],o[i-c],e.position-(r[i]-r[i-c]),h),l=kn.repeat(" ",t.indent)+ju((e.line-c+1).toString(),f)+" | "+u.str+`
341
+ `+l;for(u=Eu(e.buffer,r[i],o[i],e.position,h),l+=kn.repeat(" ",t.indent)+ju((e.line+1).toString(),f)+" | "+u.str+`
342
+ `,l+=kn.repeat("-",t.indent+f+3+u.pos)+`^
343
+ `,c=1;c<=t.linesAfter&&!(i+c>=o.length);c++)u=Eu(e.buffer,r[i+c],o[i+c],e.position-(r[i]-r[i+c]),h),l+=kn.repeat(" ",t.indent)+ju((e.line+c+1).toString(),f)+" | "+u.str+`
344
+ `;return l.replace(/\n$/,"")}var B4=U4,V4=["kind","multi","resolve","construct","instanceOf","predicate","represent","representName","defaultStyle","styleAliases"],W4=["scalar","sequence","mapping"];function H4(e){var t={};return e!==null&&Object.keys(e).forEach(function(n){e[n].forEach(function(r){t[String(r)]=n})}),t}function Z4(e,t){if(t=t||{},Object.keys(t).forEach(function(n){if(V4.indexOf(n)===-1)throw new Wn('Unknown option "'+n+'" is met in definition of "'+e+'" YAML type.')}),this.options=t,this.tag=e,this.kind=t.kind||null,this.resolve=t.resolve||function(){return!0},this.construct=t.construct||function(n){return n},this.instanceOf=t.instanceOf||null,this.predicate=t.predicate||null,this.represent=t.represent||null,this.representName=t.representName||null,this.defaultStyle=t.defaultStyle||null,this.multi=t.multi||!1,this.styleAliases=H4(t.styleAliases||null),W4.indexOf(this.kind)===-1)throw new Wn('Unknown kind "'+this.kind+'" is specified for "'+e+'" YAML type.')}var Pn=Z4;function Tm(e,t){var n=[];return e[t].forEach(function(r){var o=n.length;n.forEach(function(a,i){a.tag===r.tag&&a.kind===r.kind&&a.multi===r.multi&&(o=i)}),n[o]=r}),n}function G4(){var e={scalar:{},sequence:{},mapping:{},fallback:{},multi:{scalar:[],sequence:[],mapping:[],fallback:[]}},t,n;function r(o){o.multi?(e.multi[o.kind].push(o),e.multi.fallback.push(o)):e[o.kind][o.tag]=e.fallback[o.tag]=o}for(t=0,n=arguments.length;t<n;t+=1)arguments[t].forEach(r);return e}function kd(e){return this.extend(e)}kd.prototype.extend=function(t){var n=[],r=[];if(t instanceof Pn)r.push(t);else if(Array.isArray(t))r=r.concat(t);else if(t&&(Array.isArray(t.implicit)||Array.isArray(t.explicit)))t.implicit&&(n=n.concat(t.implicit)),t.explicit&&(r=r.concat(t.explicit));else throw new Wn("Schema.extend argument should be a Type, [ Type ], or a schema definition ({ implicit: [...], explicit: [...] })");n.forEach(function(a){if(!(a instanceof Pn))throw new Wn("Specified list of YAML types (or a single Type object) contains a non-Type object.");if(a.loadKind&&a.loadKind!=="scalar")throw new Wn("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.");if(a.multi)throw new Wn("There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.")}),r.forEach(function(a){if(!(a instanceof Pn))throw new Wn("Specified list of YAML types (or a single Type object) contains a non-Type object.")});var o=Object.create(kd.prototype);return o.implicit=(this.implicit||[]).concat(n),o.explicit=(this.explicit||[]).concat(r),o.compiledImplicit=Tm(o,"implicit"),o.compiledExplicit=Tm(o,"explicit"),o.compiledTypeMap=G4(o.compiledImplicit,o.compiledExplicit),o};var hy=kd,py=new Pn("tag:yaml.org,2002:str",{kind:"scalar",construct:function(e){return e!==null?e:""}}),my=new Pn("tag:yaml.org,2002:seq",{kind:"sequence",construct:function(e){return e!==null?e:[]}}),gy=new Pn("tag:yaml.org,2002:map",{kind:"mapping",construct:function(e){return e!==null?e:{}}}),xy=new hy({explicit:[py,my,gy]});function Y4(e){if(e===null)return!0;var t=e.length;return t===1&&e==="~"||t===4&&(e==="null"||e==="Null"||e==="NULL")}function K4(){return null}function q4(e){return e===null}var vy=new Pn("tag:yaml.org,2002:null",{kind:"scalar",resolve:Y4,construct:K4,predicate:q4,represent:{canonical:function(){return"~"},lowercase:function(){return"null"},uppercase:function(){return"NULL"},camelcase:function(){return"Null"},empty:function(){return""}},defaultStyle:"lowercase"});function X4(e){if(e===null)return!1;var t=e.length;return t===4&&(e==="true"||e==="True"||e==="TRUE")||t===5&&(e==="false"||e==="False"||e==="FALSE")}function J4(e){return e==="true"||e==="True"||e==="TRUE"}function Q4(e){return Object.prototype.toString.call(e)==="[object Boolean]"}var wy=new Pn("tag:yaml.org,2002:bool",{kind:"scalar",resolve:X4,construct:J4,predicate:Q4,represent:{lowercase:function(e){return e?"true":"false"},uppercase:function(e){return e?"TRUE":"FALSE"},camelcase:function(e){return e?"True":"False"}},defaultStyle:"lowercase"});function e5(e){return 48<=e&&e<=57||65<=e&&e<=70||97<=e&&e<=102}function t5(e){return 48<=e&&e<=55}function n5(e){return 48<=e&&e<=57}function r5(e){if(e===null)return!1;var t=e.length,n=0,r=!1,o;if(!t)return!1;if(o=e[n],(o==="-"||o==="+")&&(o=e[++n]),o==="0"){if(n+1===t)return!0;if(o=e[++n],o==="b"){for(n++;n<t;n++)if(o=e[n],o!=="_"){if(o!=="0"&&o!=="1")return!1;r=!0}return r&&o!=="_"}if(o==="x"){for(n++;n<t;n++)if(o=e[n],o!=="_"){if(!e5(e.charCodeAt(n)))return!1;r=!0}return r&&o!=="_"}if(o==="o"){for(n++;n<t;n++)if(o=e[n],o!=="_"){if(!t5(e.charCodeAt(n)))return!1;r=!0}return r&&o!=="_"}}if(o==="_")return!1;for(;n<t;n++)if(o=e[n],o!=="_"){if(!n5(e.charCodeAt(n)))return!1;r=!0}return!(!r||o==="_")}function o5(e){var t=e,n=1,r;if(t.indexOf("_")!==-1&&(t=t.replace(/_/g,"")),r=t[0],(r==="-"||r==="+")&&(r==="-"&&(n=-1),t=t.slice(1),r=t[0]),t==="0")return 0;if(r==="0"){if(t[1]==="b")return n*parseInt(t.slice(2),2);if(t[1]==="x")return n*parseInt(t.slice(2),16);if(t[1]==="o")return n*parseInt(t.slice(2),8)}return n*parseInt(t,10)}function s5(e){return Object.prototype.toString.call(e)==="[object Number]"&&e%1===0&&!kn.isNegativeZero(e)}var by=new Pn("tag:yaml.org,2002:int",{kind:"scalar",resolve:r5,construct:o5,predicate:s5,represent:{binary:function(e){return e>=0?"0b"+e.toString(2):"-0b"+e.toString(2).slice(1)},octal:function(e){return e>=0?"0o"+e.toString(8):"-0o"+e.toString(8).slice(1)},decimal:function(e){return e.toString(10)},hexadecimal:function(e){return e>=0?"0x"+e.toString(16).toUpperCase():"-0x"+e.toString(16).toUpperCase().slice(1)}},defaultStyle:"decimal",styleAliases:{binary:[2,"bin"],octal:[8,"oct"],decimal:[10,"dec"],hexadecimal:[16,"hex"]}}),a5=new RegExp("^(?:[-+]?(?:[0-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");function i5(e){return!(e===null||!a5.test(e)||e[e.length-1]==="_")}function l5(e){var t,n;return t=e.replace(/_/g,"").toLowerCase(),n=t[0]==="-"?-1:1,"+-".indexOf(t[0])>=0&&(t=t.slice(1)),t===".inf"?n===1?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY:t===".nan"?NaN:n*parseFloat(t,10)}var c5=/^[-+]?[0-9]+e/;function u5(e,t){var n;if(isNaN(e))switch(t){case"lowercase":return".nan";case"uppercase":return".NAN";case"camelcase":return".NaN"}else if(Number.POSITIVE_INFINITY===e)switch(t){case"lowercase":return".inf";case"uppercase":return".INF";case"camelcase":return".Inf"}else if(Number.NEGATIVE_INFINITY===e)switch(t){case"lowercase":return"-.inf";case"uppercase":return"-.INF";case"camelcase":return"-.Inf"}else if(kn.isNegativeZero(e))return"-0.0";return n=e.toString(10),c5.test(n)?n.replace("e",".e"):n}function d5(e){return Object.prototype.toString.call(e)==="[object Number]"&&(e%1!==0||kn.isNegativeZero(e))}var yy=new Pn("tag:yaml.org,2002:float",{kind:"scalar",resolve:i5,construct:l5,predicate:d5,represent:u5,defaultStyle:"lowercase"}),Cy=xy.extend({implicit:[vy,wy,by,yy]}),Sy=Cy,_y=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),ky=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$");function f5(e){return e===null?!1:_y.exec(e)!==null||ky.exec(e)!==null}function h5(e){var t,n,r,o,a,i,l,c=0,u=null,f,h,m;if(t=_y.exec(e),t===null&&(t=ky.exec(e)),t===null)throw new Error("Date resolve error");if(n=+t[1],r=+t[2]-1,o=+t[3],!t[4])return new Date(Date.UTC(n,r,o));if(a=+t[4],i=+t[5],l=+t[6],t[7]){for(c=t[7].slice(0,3);c.length<3;)c+="0";c=+c}return t[9]&&(f=+t[10],h=+(t[11]||0),u=(f*60+h)*6e4,t[9]==="-"&&(u=-u)),m=new Date(Date.UTC(n,r,o,a,i,l,c)),u&&m.setTime(m.getTime()-u),m}function p5(e){return e.toISOString()}var Ey=new Pn("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:f5,construct:h5,instanceOf:Date,represent:p5});function m5(e){return e==="<<"||e===null}var jy=new Pn("tag:yaml.org,2002:merge",{kind:"scalar",resolve:m5}),lh=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=
345
+ \r`;function g5(e){if(e===null)return!1;var t,n,r=0,o=e.length,a=lh;for(n=0;n<o;n++)if(t=a.indexOf(e.charAt(n)),!(t>64)){if(t<0)return!1;r+=6}return r%8===0}function x5(e){var t,n,r=e.replace(/[\r\n=]/g,""),o=r.length,a=lh,i=0,l=[];for(t=0;t<o;t++)t%4===0&&t&&(l.push(i>>16&255),l.push(i>>8&255),l.push(i&255)),i=i<<6|a.indexOf(r.charAt(t));return n=o%4*6,n===0?(l.push(i>>16&255),l.push(i>>8&255),l.push(i&255)):n===18?(l.push(i>>10&255),l.push(i>>2&255)):n===12&&l.push(i>>4&255),new Uint8Array(l)}function v5(e){var t="",n=0,r,o,a=e.length,i=lh;for(r=0;r<a;r++)r%3===0&&r&&(t+=i[n>>18&63],t+=i[n>>12&63],t+=i[n>>6&63],t+=i[n&63]),n=(n<<8)+e[r];return o=a%3,o===0?(t+=i[n>>18&63],t+=i[n>>12&63],t+=i[n>>6&63],t+=i[n&63]):o===2?(t+=i[n>>10&63],t+=i[n>>4&63],t+=i[n<<2&63],t+=i[64]):o===1&&(t+=i[n>>2&63],t+=i[n<<4&63],t+=i[64],t+=i[64]),t}function w5(e){return Object.prototype.toString.call(e)==="[object Uint8Array]"}var Ny=new Pn("tag:yaml.org,2002:binary",{kind:"scalar",resolve:g5,construct:x5,predicate:w5,represent:v5}),b5=Object.prototype.hasOwnProperty,y5=Object.prototype.toString;function C5(e){if(e===null)return!0;var t=[],n,r,o,a,i,l=e;for(n=0,r=l.length;n<r;n+=1){if(o=l[n],i=!1,y5.call(o)!=="[object Object]")return!1;for(a in o)if(b5.call(o,a))if(!i)i=!0;else return!1;if(!i)return!1;if(t.indexOf(a)===-1)t.push(a);else return!1}return!0}function S5(e){return e!==null?e:[]}var Ty=new Pn("tag:yaml.org,2002:omap",{kind:"sequence",resolve:C5,construct:S5}),_5=Object.prototype.toString;function k5(e){if(e===null)return!0;var t,n,r,o,a,i=e;for(a=new Array(i.length),t=0,n=i.length;t<n;t+=1){if(r=i[t],_5.call(r)!=="[object Object]"||(o=Object.keys(r),o.length!==1))return!1;a[t]=[o[0],r[o[0]]]}return!0}function E5(e){if(e===null)return[];var t,n,r,o,a,i=e;for(a=new Array(i.length),t=0,n=i.length;t<n;t+=1)r=i[t],o=Object.keys(r),a[t]=[o[0],r[o[0]]];return a}var Ay=new Pn("tag:yaml.org,2002:pairs",{kind:"sequence",resolve:k5,construct:E5}),j5=Object.prototype.hasOwnProperty;function N5(e){if(e===null)return!0;var t,n=e;for(t in n)if(j5.call(n,t)&&n[t]!==null)return!1;return!0}function T5(e){return e!==null?e:{}}var Iy=new Pn("tag:yaml.org,2002:set",{kind:"mapping",resolve:N5,construct:T5}),ch=Sy.extend({implicit:[Ey,jy],explicit:[Ny,Ty,Ay,Iy]}),$o=Object.prototype.hasOwnProperty,Ol=1,Ry=2,Py=3,Ll=4,Nu=1,A5=2,Am=3,I5=/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,R5=/[\x85\u2028\u2029]/,P5=/[,\[\]\{\}]/,My=/^(?:!|!!|![a-z\-]+!)$/i,Dy=/^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i;function Im(e){return Object.prototype.toString.call(e)}function eo(e){return e===10||e===13}function es(e){return e===9||e===32}function er(e){return e===9||e===32||e===10||e===13}function Ds(e){return e===44||e===91||e===93||e===123||e===125}function M5(e){var t;return 48<=e&&e<=57?e-48:(t=e|32,97<=t&&t<=102?t-97+10:-1)}function D5(e){return e===120?2:e===117?4:e===85?8:0}function O5(e){return 48<=e&&e<=57?e-48:-1}function Rm(e){return e===48?"\0":e===97?"\x07":e===98?"\b":e===116||e===9?" ":e===110?`
346
+ `:e===118?"\v":e===102?"\f":e===114?"\r":e===101?"\x1B":e===32?" ":e===34?'"':e===47?"/":e===92?"\\":e===78?"…":e===95?" ":e===76?"\u2028":e===80?"\u2029":""}function L5(e){return e<=65535?String.fromCharCode(e):String.fromCharCode((e-65536>>10)+55296,(e-65536&1023)+56320)}function Oy(e,t,n){t==="__proto__"?Object.defineProperty(e,t,{configurable:!0,enumerable:!0,writable:!0,value:n}):e[t]=n}var Ly=new Array(256),Fy=new Array(256);for(var Ns=0;Ns<256;Ns++)Ly[Ns]=Rm(Ns)?1:0,Fy[Ns]=Rm(Ns);function F5(e,t){this.input=e,this.filename=t.filename||null,this.schema=t.schema||ch,this.onWarning=t.onWarning||null,this.legacy=t.legacy||!1,this.json=t.json||!1,this.listener=t.listener||null,this.implicitTypes=this.schema.compiledImplicit,this.typeMap=this.schema.compiledTypeMap,this.length=e.length,this.position=0,this.line=0,this.lineStart=0,this.lineIndent=0,this.firstTabInLine=-1,this.documents=[]}function $y(e,t){var n={name:e.filename,buffer:e.input.slice(0,-1),position:e.position,line:e.line,column:e.position-e.lineStart};return n.snippet=B4(n),new Wn(t,n)}function et(e,t){throw $y(e,t)}function Fl(e,t){e.onWarning&&e.onWarning.call(null,$y(e,t))}var Pm={YAML:function(t,n,r){var o,a,i;t.version!==null&&et(t,"duplication of %YAML directive"),r.length!==1&&et(t,"YAML directive accepts exactly one argument"),o=/^([0-9]+)\.([0-9]+)$/.exec(r[0]),o===null&&et(t,"ill-formed argument of the YAML directive"),a=parseInt(o[1],10),i=parseInt(o[2],10),a!==1&&et(t,"unacceptable YAML version of the document"),t.version=r[0],t.checkLineBreaks=i<2,i!==1&&i!==2&&Fl(t,"unsupported YAML version of the document")},TAG:function(t,n,r){var o,a;r.length!==2&&et(t,"TAG directive accepts exactly two arguments"),o=r[0],a=r[1],My.test(o)||et(t,"ill-formed tag handle (first argument) of the TAG directive"),$o.call(t.tagMap,o)&&et(t,'there is a previously declared suffix for "'+o+'" tag handle'),Dy.test(a)||et(t,"ill-formed tag prefix (second argument) of the TAG directive");try{a=decodeURIComponent(a)}catch{et(t,"tag prefix is malformed: "+a)}t.tagMap[o]=a}};function Po(e,t,n,r){var o,a,i,l;if(t<n){if(l=e.input.slice(t,n),r)for(o=0,a=l.length;o<a;o+=1)i=l.charCodeAt(o),i===9||32<=i&&i<=1114111||et(e,"expected valid JSON character");else I5.test(l)&&et(e,"the stream contains non-printable characters");e.result+=l}}function Mm(e,t,n,r){var o,a,i,l;for(kn.isObject(n)||et(e,"cannot merge mappings; the provided source object is unacceptable"),o=Object.keys(n),i=0,l=o.length;i<l;i+=1)a=o[i],$o.call(t,a)||(Oy(t,a,n[a]),r[a]=!0)}function Os(e,t,n,r,o,a,i,l,c){var u,f;if(Array.isArray(o))for(o=Array.prototype.slice.call(o),u=0,f=o.length;u<f;u+=1)Array.isArray(o[u])&&et(e,"nested arrays are not supported inside keys"),typeof o=="object"&&Im(o[u])==="[object Object]"&&(o[u]="[object Object]");if(typeof o=="object"&&Im(o)==="[object Object]"&&(o="[object Object]"),o=String(o),t===null&&(t={}),r==="tag:yaml.org,2002:merge")if(Array.isArray(a))for(u=0,f=a.length;u<f;u+=1)Mm(e,t,a[u],n);else Mm(e,t,a,n);else!e.json&&!$o.call(n,o)&&$o.call(t,o)&&(e.line=i||e.line,e.lineStart=l||e.lineStart,e.position=c||e.position,et(e,"duplicated mapping key")),Oy(t,o,a),delete n[o];return t}function uh(e){var t;t=e.input.charCodeAt(e.position),t===10?e.position++:t===13?(e.position++,e.input.charCodeAt(e.position)===10&&e.position++):et(e,"a line break is expected"),e.line+=1,e.lineStart=e.position,e.firstTabInLine=-1}function wn(e,t,n){for(var r=0,o=e.input.charCodeAt(e.position);o!==0;){for(;es(o);)o===9&&e.firstTabInLine===-1&&(e.firstTabInLine=e.position),o=e.input.charCodeAt(++e.position);if(t&&o===35)do o=e.input.charCodeAt(++e.position);while(o!==10&&o!==13&&o!==0);if(eo(o))for(uh(e),o=e.input.charCodeAt(e.position),r++,e.lineIndent=0;o===32;)e.lineIndent++,o=e.input.charCodeAt(++e.position);else break}return n!==-1&&r!==0&&e.lineIndent<n&&Fl(e,"deficient indentation"),r}function Rc(e){var t=e.position,n;return n=e.input.charCodeAt(t),!!((n===45||n===46)&&n===e.input.charCodeAt(t+1)&&n===e.input.charCodeAt(t+2)&&(t+=3,n=e.input.charCodeAt(t),n===0||er(n)))}function dh(e,t){t===1?e.result+=" ":t>1&&(e.result+=kn.repeat(`
347
+ `,t-1))}function $5(e,t,n){var r,o,a,i,l,c,u,f,h=e.kind,m=e.result,p;if(p=e.input.charCodeAt(e.position),er(p)||Ds(p)||p===35||p===38||p===42||p===33||p===124||p===62||p===39||p===34||p===37||p===64||p===96||(p===63||p===45)&&(o=e.input.charCodeAt(e.position+1),er(o)||n&&Ds(o)))return!1;for(e.kind="scalar",e.result="",a=i=e.position,l=!1;p!==0;){if(p===58){if(o=e.input.charCodeAt(e.position+1),er(o)||n&&Ds(o))break}else if(p===35){if(r=e.input.charCodeAt(e.position-1),er(r))break}else{if(e.position===e.lineStart&&Rc(e)||n&&Ds(p))break;if(eo(p))if(c=e.line,u=e.lineStart,f=e.lineIndent,wn(e,!1,-1),e.lineIndent>=t){l=!0,p=e.input.charCodeAt(e.position);continue}else{e.position=i,e.line=c,e.lineStart=u,e.lineIndent=f;break}}l&&(Po(e,a,i,!1),dh(e,e.line-c),a=i=e.position,l=!1),es(p)||(i=e.position+1),p=e.input.charCodeAt(++e.position)}return Po(e,a,i,!1),e.result?!0:(e.kind=h,e.result=m,!1)}function z5(e,t){var n,r,o;if(n=e.input.charCodeAt(e.position),n!==39)return!1;for(e.kind="scalar",e.result="",e.position++,r=o=e.position;(n=e.input.charCodeAt(e.position))!==0;)if(n===39)if(Po(e,r,e.position,!0),n=e.input.charCodeAt(++e.position),n===39)r=e.position,e.position++,o=e.position;else return!0;else eo(n)?(Po(e,r,o,!0),dh(e,wn(e,!1,t)),r=o=e.position):e.position===e.lineStart&&Rc(e)?et(e,"unexpected end of the document within a single quoted scalar"):(e.position++,o=e.position);et(e,"unexpected end of the stream within a single quoted scalar")}function U5(e,t){var n,r,o,a,i,l;if(l=e.input.charCodeAt(e.position),l!==34)return!1;for(e.kind="scalar",e.result="",e.position++,n=r=e.position;(l=e.input.charCodeAt(e.position))!==0;){if(l===34)return Po(e,n,e.position,!0),e.position++,!0;if(l===92){if(Po(e,n,e.position,!0),l=e.input.charCodeAt(++e.position),eo(l))wn(e,!1,t);else if(l<256&&Ly[l])e.result+=Fy[l],e.position++;else if((i=D5(l))>0){for(o=i,a=0;o>0;o--)l=e.input.charCodeAt(++e.position),(i=M5(l))>=0?a=(a<<4)+i:et(e,"expected hexadecimal character");e.result+=L5(a),e.position++}else et(e,"unknown escape sequence");n=r=e.position}else eo(l)?(Po(e,n,r,!0),dh(e,wn(e,!1,t)),n=r=e.position):e.position===e.lineStart&&Rc(e)?et(e,"unexpected end of the document within a double quoted scalar"):(e.position++,r=e.position)}et(e,"unexpected end of the stream within a double quoted scalar")}function B5(e,t){var n=!0,r,o,a,i=e.tag,l,c=e.anchor,u,f,h,m,p,x=Object.create(null),g,w,v,b;if(b=e.input.charCodeAt(e.position),b===91)f=93,p=!1,l=[];else if(b===123)f=125,p=!0,l={};else return!1;for(e.anchor!==null&&(e.anchorMap[e.anchor]=l),b=e.input.charCodeAt(++e.position);b!==0;){if(wn(e,!0,t),b=e.input.charCodeAt(e.position),b===f)return e.position++,e.tag=i,e.anchor=c,e.kind=p?"mapping":"sequence",e.result=l,!0;n?b===44&&et(e,"expected the node content, but found ','"):et(e,"missed comma between flow collection entries"),w=g=v=null,h=m=!1,b===63&&(u=e.input.charCodeAt(e.position+1),er(u)&&(h=m=!0,e.position++,wn(e,!0,t))),r=e.line,o=e.lineStart,a=e.position,na(e,t,Ol,!1,!0),w=e.tag,g=e.result,wn(e,!0,t),b=e.input.charCodeAt(e.position),(m||e.line===r)&&b===58&&(h=!0,b=e.input.charCodeAt(++e.position),wn(e,!0,t),na(e,t,Ol,!1,!0),v=e.result),p?Os(e,l,x,w,g,v,r,o,a):h?l.push(Os(e,null,x,w,g,v,r,o,a)):l.push(g),wn(e,!0,t),b=e.input.charCodeAt(e.position),b===44?(n=!0,b=e.input.charCodeAt(++e.position)):n=!1}et(e,"unexpected end of the stream within a flow collection")}function V5(e,t){var n,r,o=Nu,a=!1,i=!1,l=t,c=0,u=!1,f,h;if(h=e.input.charCodeAt(e.position),h===124)r=!1;else if(h===62)r=!0;else return!1;for(e.kind="scalar",e.result="";h!==0;)if(h=e.input.charCodeAt(++e.position),h===43||h===45)Nu===o?o=h===43?Am:A5:et(e,"repeat of a chomping mode identifier");else if((f=O5(h))>=0)f===0?et(e,"bad explicit indentation width of a block scalar; it cannot be less than one"):i?et(e,"repeat of an indentation width identifier"):(l=t+f-1,i=!0);else break;if(es(h)){do h=e.input.charCodeAt(++e.position);while(es(h));if(h===35)do h=e.input.charCodeAt(++e.position);while(!eo(h)&&h!==0)}for(;h!==0;){for(uh(e),e.lineIndent=0,h=e.input.charCodeAt(e.position);(!i||e.lineIndent<l)&&h===32;)e.lineIndent++,h=e.input.charCodeAt(++e.position);if(!i&&e.lineIndent>l&&(l=e.lineIndent),eo(h)){c++;continue}if(e.lineIndent<l){o===Am?e.result+=kn.repeat(`
348
+ `,a?1+c:c):o===Nu&&a&&(e.result+=`
349
+ `);break}for(r?es(h)?(u=!0,e.result+=kn.repeat(`
350
+ `,a?1+c:c)):u?(u=!1,e.result+=kn.repeat(`
351
+ `,c+1)):c===0?a&&(e.result+=" "):e.result+=kn.repeat(`
352
+ `,c):e.result+=kn.repeat(`
353
+ `,a?1+c:c),a=!0,i=!0,c=0,n=e.position;!eo(h)&&h!==0;)h=e.input.charCodeAt(++e.position);Po(e,n,e.position,!1)}return!0}function Dm(e,t){var n,r=e.tag,o=e.anchor,a=[],i,l=!1,c;if(e.firstTabInLine!==-1)return!1;for(e.anchor!==null&&(e.anchorMap[e.anchor]=a),c=e.input.charCodeAt(e.position);c!==0&&(e.firstTabInLine!==-1&&(e.position=e.firstTabInLine,et(e,"tab characters must not be used in indentation")),!(c!==45||(i=e.input.charCodeAt(e.position+1),!er(i))));){if(l=!0,e.position++,wn(e,!0,-1)&&e.lineIndent<=t){a.push(null),c=e.input.charCodeAt(e.position);continue}if(n=e.line,na(e,t,Py,!1,!0),a.push(e.result),wn(e,!0,-1),c=e.input.charCodeAt(e.position),(e.line===n||e.lineIndent>t)&&c!==0)et(e,"bad indentation of a sequence entry");else if(e.lineIndent<t)break}return l?(e.tag=r,e.anchor=o,e.kind="sequence",e.result=a,!0):!1}function W5(e,t,n){var r,o,a,i,l,c,u=e.tag,f=e.anchor,h={},m=Object.create(null),p=null,x=null,g=null,w=!1,v=!1,b;if(e.firstTabInLine!==-1)return!1;for(e.anchor!==null&&(e.anchorMap[e.anchor]=h),b=e.input.charCodeAt(e.position);b!==0;){if(!w&&e.firstTabInLine!==-1&&(e.position=e.firstTabInLine,et(e,"tab characters must not be used in indentation")),r=e.input.charCodeAt(e.position+1),a=e.line,(b===63||b===58)&&er(r))b===63?(w&&(Os(e,h,m,p,x,null,i,l,c),p=x=g=null),v=!0,w=!0,o=!0):w?(w=!1,o=!0):et(e,"incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line"),e.position+=1,b=r;else{if(i=e.line,l=e.lineStart,c=e.position,!na(e,n,Ry,!1,!0))break;if(e.line===a){for(b=e.input.charCodeAt(e.position);es(b);)b=e.input.charCodeAt(++e.position);if(b===58)b=e.input.charCodeAt(++e.position),er(b)||et(e,"a whitespace character is expected after the key-value separator within a block mapping"),w&&(Os(e,h,m,p,x,null,i,l,c),p=x=g=null),v=!0,w=!1,o=!1,p=e.tag,x=e.result;else if(v)et(e,"can not read an implicit mapping pair; a colon is missed");else return e.tag=u,e.anchor=f,!0}else if(v)et(e,"can not read a block mapping entry; a multiline key may not be an implicit key");else return e.tag=u,e.anchor=f,!0}if((e.line===a||e.lineIndent>t)&&(w&&(i=e.line,l=e.lineStart,c=e.position),na(e,t,Ll,!0,o)&&(w?x=e.result:g=e.result),w||(Os(e,h,m,p,x,g,i,l,c),p=x=g=null),wn(e,!0,-1),b=e.input.charCodeAt(e.position)),(e.line===a||e.lineIndent>t)&&b!==0)et(e,"bad indentation of a mapping entry");else if(e.lineIndent<t)break}return w&&Os(e,h,m,p,x,null,i,l,c),v&&(e.tag=u,e.anchor=f,e.kind="mapping",e.result=h),v}function H5(e){var t,n=!1,r=!1,o,a,i;if(i=e.input.charCodeAt(e.position),i!==33)return!1;if(e.tag!==null&&et(e,"duplication of a tag property"),i=e.input.charCodeAt(++e.position),i===60?(n=!0,i=e.input.charCodeAt(++e.position)):i===33?(r=!0,o="!!",i=e.input.charCodeAt(++e.position)):o="!",t=e.position,n){do i=e.input.charCodeAt(++e.position);while(i!==0&&i!==62);e.position<e.length?(a=e.input.slice(t,e.position),i=e.input.charCodeAt(++e.position)):et(e,"unexpected end of the stream within a verbatim tag")}else{for(;i!==0&&!er(i);)i===33&&(r?et(e,"tag suffix cannot contain exclamation marks"):(o=e.input.slice(t-1,e.position+1),My.test(o)||et(e,"named tag handle cannot contain such characters"),r=!0,t=e.position+1)),i=e.input.charCodeAt(++e.position);a=e.input.slice(t,e.position),P5.test(a)&&et(e,"tag suffix cannot contain flow indicator characters")}a&&!Dy.test(a)&&et(e,"tag name cannot contain such characters: "+a);try{a=decodeURIComponent(a)}catch{et(e,"tag name is malformed: "+a)}return n?e.tag=a:$o.call(e.tagMap,o)?e.tag=e.tagMap[o]+a:o==="!"?e.tag="!"+a:o==="!!"?e.tag="tag:yaml.org,2002:"+a:et(e,'undeclared tag handle "'+o+'"'),!0}function Z5(e){var t,n;if(n=e.input.charCodeAt(e.position),n!==38)return!1;for(e.anchor!==null&&et(e,"duplication of an anchor property"),n=e.input.charCodeAt(++e.position),t=e.position;n!==0&&!er(n)&&!Ds(n);)n=e.input.charCodeAt(++e.position);return e.position===t&&et(e,"name of an anchor node must contain at least one character"),e.anchor=e.input.slice(t,e.position),!0}function G5(e){var t,n,r;if(r=e.input.charCodeAt(e.position),r!==42)return!1;for(r=e.input.charCodeAt(++e.position),t=e.position;r!==0&&!er(r)&&!Ds(r);)r=e.input.charCodeAt(++e.position);return e.position===t&&et(e,"name of an alias node must contain at least one character"),n=e.input.slice(t,e.position),$o.call(e.anchorMap,n)||et(e,'unidentified alias "'+n+'"'),e.result=e.anchorMap[n],wn(e,!0,-1),!0}function na(e,t,n,r,o){var a,i,l,c=1,u=!1,f=!1,h,m,p,x,g,w;if(e.listener!==null&&e.listener("open",e),e.tag=null,e.anchor=null,e.kind=null,e.result=null,a=i=l=Ll===n||Py===n,r&&wn(e,!0,-1)&&(u=!0,e.lineIndent>t?c=1:e.lineIndent===t?c=0:e.lineIndent<t&&(c=-1)),c===1)for(;H5(e)||Z5(e);)wn(e,!0,-1)?(u=!0,l=a,e.lineIndent>t?c=1:e.lineIndent===t?c=0:e.lineIndent<t&&(c=-1)):l=!1;if(l&&(l=u||o),(c===1||Ll===n)&&(Ol===n||Ry===n?g=t:g=t+1,w=e.position-e.lineStart,c===1?l&&(Dm(e,w)||W5(e,w,g))||B5(e,g)?f=!0:(i&&V5(e,g)||z5(e,g)||U5(e,g)?f=!0:G5(e)?(f=!0,(e.tag!==null||e.anchor!==null)&&et(e,"alias node should not have any properties")):$5(e,g,Ol===n)&&(f=!0,e.tag===null&&(e.tag="?")),e.anchor!==null&&(e.anchorMap[e.anchor]=e.result)):c===0&&(f=l&&Dm(e,w))),e.tag===null)e.anchor!==null&&(e.anchorMap[e.anchor]=e.result);else if(e.tag==="?"){for(e.result!==null&&e.kind!=="scalar"&&et(e,'unacceptable node kind for !<?> tag; it should be "scalar", not "'+e.kind+'"'),h=0,m=e.implicitTypes.length;h<m;h+=1)if(x=e.implicitTypes[h],x.resolve(e.result)){e.result=x.construct(e.result),e.tag=x.tag,e.anchor!==null&&(e.anchorMap[e.anchor]=e.result);break}}else if(e.tag!=="!"){if($o.call(e.typeMap[e.kind||"fallback"],e.tag))x=e.typeMap[e.kind||"fallback"][e.tag];else for(x=null,p=e.typeMap.multi[e.kind||"fallback"],h=0,m=p.length;h<m;h+=1)if(e.tag.slice(0,p[h].tag.length)===p[h].tag){x=p[h];break}x||et(e,"unknown tag !<"+e.tag+">"),e.result!==null&&x.kind!==e.kind&&et(e,"unacceptable node kind for !<"+e.tag+'> tag; it should be "'+x.kind+'", not "'+e.kind+'"'),x.resolve(e.result,e.tag)?(e.result=x.construct(e.result,e.tag),e.anchor!==null&&(e.anchorMap[e.anchor]=e.result)):et(e,"cannot resolve a node with !<"+e.tag+"> explicit tag")}return e.listener!==null&&e.listener("close",e),e.tag!==null||e.anchor!==null||f}function Y5(e){var t=e.position,n,r,o,a=!1,i;for(e.version=null,e.checkLineBreaks=e.legacy,e.tagMap=Object.create(null),e.anchorMap=Object.create(null);(i=e.input.charCodeAt(e.position))!==0&&(wn(e,!0,-1),i=e.input.charCodeAt(e.position),!(e.lineIndent>0||i!==37));){for(a=!0,i=e.input.charCodeAt(++e.position),n=e.position;i!==0&&!er(i);)i=e.input.charCodeAt(++e.position);for(r=e.input.slice(n,e.position),o=[],r.length<1&&et(e,"directive name must not be less than one character in length");i!==0;){for(;es(i);)i=e.input.charCodeAt(++e.position);if(i===35){do i=e.input.charCodeAt(++e.position);while(i!==0&&!eo(i));break}if(eo(i))break;for(n=e.position;i!==0&&!er(i);)i=e.input.charCodeAt(++e.position);o.push(e.input.slice(n,e.position))}i!==0&&uh(e),$o.call(Pm,r)?Pm[r](e,r,o):Fl(e,'unknown document directive "'+r+'"')}if(wn(e,!0,-1),e.lineIndent===0&&e.input.charCodeAt(e.position)===45&&e.input.charCodeAt(e.position+1)===45&&e.input.charCodeAt(e.position+2)===45?(e.position+=3,wn(e,!0,-1)):a&&et(e,"directives end mark is expected"),na(e,e.lineIndent-1,Ll,!1,!0),wn(e,!0,-1),e.checkLineBreaks&&R5.test(e.input.slice(t,e.position))&&Fl(e,"non-ASCII line breaks are interpreted as content"),e.documents.push(e.result),e.position===e.lineStart&&Rc(e)){e.input.charCodeAt(e.position)===46&&(e.position+=3,wn(e,!0,-1));return}if(e.position<e.length-1)et(e,"end of the stream or a document separator is expected");else return}function zy(e,t){e=String(e),t=t||{},e.length!==0&&(e.charCodeAt(e.length-1)!==10&&e.charCodeAt(e.length-1)!==13&&(e+=`
354
+ `),e.charCodeAt(0)===65279&&(e=e.slice(1)));var n=new F5(e,t),r=e.indexOf("\0");for(r!==-1&&(n.position=r,et(n,"null byte is not allowed in input")),n.input+="\0";n.input.charCodeAt(n.position)===32;)n.lineIndent+=1,n.position+=1;for(;n.position<n.length-1;)Y5(n);return n.documents}function K5(e,t,n){t!==null&&typeof t=="object"&&typeof n>"u"&&(n=t,t=null);var r=zy(e,n);if(typeof t!="function")return r;for(var o=0,a=r.length;o<a;o+=1)t(r[o])}function q5(e,t){var n=zy(e,t);if(n.length!==0){if(n.length===1)return n[0];throw new Wn("expected a single document in the stream, but found more")}}var X5=K5,J5=q5,Uy={loadAll:X5,load:J5},By=Object.prototype.toString,Vy=Object.prototype.hasOwnProperty,fh=65279,Q5=9,qa=10,e3=13,t3=32,n3=33,r3=34,Ed=35,o3=37,s3=38,a3=39,i3=42,Wy=44,l3=45,$l=58,c3=61,u3=62,d3=63,f3=64,Hy=91,Zy=93,h3=96,Gy=123,p3=124,Yy=125,$n={};$n[0]="\\0";$n[7]="\\a";$n[8]="\\b";$n[9]="\\t";$n[10]="\\n";$n[11]="\\v";$n[12]="\\f";$n[13]="\\r";$n[27]="\\e";$n[34]='\\"';$n[92]="\\\\";$n[133]="\\N";$n[160]="\\_";$n[8232]="\\L";$n[8233]="\\P";var m3=["y","Y","yes","Yes","YES","on","On","ON","n","N","no","No","NO","off","Off","OFF"],g3=/^[-+]?[0-9_]+(?::[0-9_]+)+(?:\.[0-9_]*)?$/;function x3(e,t){var n,r,o,a,i,l,c;if(t===null)return{};for(n={},r=Object.keys(t),o=0,a=r.length;o<a;o+=1)i=r[o],l=String(t[i]),i.slice(0,2)==="!!"&&(i="tag:yaml.org,2002:"+i.slice(2)),c=e.compiledTypeMap.fallback[i],c&&Vy.call(c.styleAliases,l)&&(l=c.styleAliases[l]),n[i]=l;return n}function v3(e){var t,n,r;if(t=e.toString(16).toUpperCase(),e<=255)n="x",r=2;else if(e<=65535)n="u",r=4;else if(e<=4294967295)n="U",r=8;else throw new Wn("code point within a string may not be greater than 0xFFFFFFFF");return"\\"+n+kn.repeat("0",r-t.length)+t}var w3=1,Xa=2;function b3(e){this.schema=e.schema||ch,this.indent=Math.max(1,e.indent||2),this.noArrayIndent=e.noArrayIndent||!1,this.skipInvalid=e.skipInvalid||!1,this.flowLevel=kn.isNothing(e.flowLevel)?-1:e.flowLevel,this.styleMap=x3(this.schema,e.styles||null),this.sortKeys=e.sortKeys||!1,this.lineWidth=e.lineWidth||80,this.noRefs=e.noRefs||!1,this.noCompatMode=e.noCompatMode||!1,this.condenseFlow=e.condenseFlow||!1,this.quotingType=e.quotingType==='"'?Xa:w3,this.forceQuotes=e.forceQuotes||!1,this.replacer=typeof e.replacer=="function"?e.replacer:null,this.implicitTypes=this.schema.compiledImplicit,this.explicitTypes=this.schema.compiledExplicit,this.tag=null,this.result="",this.duplicates=[],this.usedDuplicates=null}function Om(e,t){for(var n=kn.repeat(" ",t),r=0,o=-1,a="",i,l=e.length;r<l;)o=e.indexOf(`
355
+ `,r),o===-1?(i=e.slice(r),r=l):(i=e.slice(r,o+1),r=o+1),i.length&&i!==`
356
+ `&&(a+=n),a+=i;return a}function jd(e,t){return`
357
+ `+kn.repeat(" ",e.indent*t)}function y3(e,t){var n,r,o;for(n=0,r=e.implicitTypes.length;n<r;n+=1)if(o=e.implicitTypes[n],o.resolve(t))return!0;return!1}function zl(e){return e===t3||e===Q5}function Ja(e){return 32<=e&&e<=126||161<=e&&e<=55295&&e!==8232&&e!==8233||57344<=e&&e<=65533&&e!==fh||65536<=e&&e<=1114111}function Lm(e){return Ja(e)&&e!==fh&&e!==e3&&e!==qa}function Fm(e,t,n){var r=Lm(e),o=r&&!zl(e);return(n?r:r&&e!==Wy&&e!==Hy&&e!==Zy&&e!==Gy&&e!==Yy)&&e!==Ed&&!(t===$l&&!o)||Lm(t)&&!zl(t)&&e===Ed||t===$l&&o}function C3(e){return Ja(e)&&e!==fh&&!zl(e)&&e!==l3&&e!==d3&&e!==$l&&e!==Wy&&e!==Hy&&e!==Zy&&e!==Gy&&e!==Yy&&e!==Ed&&e!==s3&&e!==i3&&e!==n3&&e!==p3&&e!==c3&&e!==u3&&e!==a3&&e!==r3&&e!==o3&&e!==f3&&e!==h3}function S3(e){return!zl(e)&&e!==$l}function Pa(e,t){var n=e.charCodeAt(t),r;return n>=55296&&n<=56319&&t+1<e.length&&(r=e.charCodeAt(t+1),r>=56320&&r<=57343)?(n-55296)*1024+r-56320+65536:n}function Ky(e){var t=/^\n* /;return t.test(e)}var qy=1,Nd=2,Xy=3,Jy=4,Ps=5;function _3(e,t,n,r,o,a,i,l){var c,u=0,f=null,h=!1,m=!1,p=r!==-1,x=-1,g=C3(Pa(e,0))&&S3(Pa(e,e.length-1));if(t||i)for(c=0;c<e.length;u>=65536?c+=2:c++){if(u=Pa(e,c),!Ja(u))return Ps;g=g&&Fm(u,f,l),f=u}else{for(c=0;c<e.length;u>=65536?c+=2:c++){if(u=Pa(e,c),u===qa)h=!0,p&&(m=m||c-x-1>r&&e[x+1]!==" ",x=c);else if(!Ja(u))return Ps;g=g&&Fm(u,f,l),f=u}m=m||p&&c-x-1>r&&e[x+1]!==" "}return!h&&!m?g&&!i&&!o(e)?qy:a===Xa?Ps:Nd:n>9&&Ky(e)?Ps:i?a===Xa?Ps:Nd:m?Jy:Xy}function k3(e,t,n,r,o){e.dump=function(){if(t.length===0)return e.quotingType===Xa?'""':"''";if(!e.noCompatMode&&(m3.indexOf(t)!==-1||g3.test(t)))return e.quotingType===Xa?'"'+t+'"':"'"+t+"'";var a=e.indent*Math.max(1,n),i=e.lineWidth===-1?-1:Math.max(Math.min(e.lineWidth,40),e.lineWidth-a),l=r||e.flowLevel>-1&&n>=e.flowLevel;function c(u){return y3(e,u)}switch(_3(t,l,e.indent,i,c,e.quotingType,e.forceQuotes&&!r,o)){case qy:return t;case Nd:return"'"+t.replace(/'/g,"''")+"'";case Xy:return"|"+$m(t,e.indent)+zm(Om(t,a));case Jy:return">"+$m(t,e.indent)+zm(Om(E3(t,i),a));case Ps:return'"'+j3(t)+'"';default:throw new Wn("impossible error: invalid scalar style")}}()}function $m(e,t){var n=Ky(e)?String(t):"",r=e[e.length-1]===`
358
+ `,o=r&&(e[e.length-2]===`
359
+ `||e===`
360
+ `),a=o?"+":r?"":"-";return n+a+`
361
+ `}function zm(e){return e[e.length-1]===`
362
+ `?e.slice(0,-1):e}function E3(e,t){for(var n=/(\n+)([^\n]*)/g,r=function(){var u=e.indexOf(`
363
+ `);return u=u!==-1?u:e.length,n.lastIndex=u,Um(e.slice(0,u),t)}(),o=e[0]===`
364
+ `||e[0]===" ",a,i;i=n.exec(e);){var l=i[1],c=i[2];a=c[0]===" ",r+=l+(!o&&!a&&c!==""?`
365
+ `:"")+Um(c,t),o=a}return r}function Um(e,t){if(e===""||e[0]===" ")return e;for(var n=/ [^ ]/g,r,o=0,a,i=0,l=0,c="";r=n.exec(e);)l=r.index,l-o>t&&(a=i>o?i:l,c+=`
366
+ `+e.slice(o,a),o=a+1),i=l;return c+=`
367
+ `,e.length-o>t&&i>o?c+=e.slice(o,i)+`
368
+ `+e.slice(i+1):c+=e.slice(o),c.slice(1)}function j3(e){for(var t="",n=0,r,o=0;o<e.length;n>=65536?o+=2:o++)n=Pa(e,o),r=$n[n],!r&&Ja(n)?(t+=e[o],n>=65536&&(t+=e[o+1])):t+=r||v3(n);return t}function N3(e,t,n){var r="",o=e.tag,a,i,l;for(a=0,i=n.length;a<i;a+=1)l=n[a],e.replacer&&(l=e.replacer.call(n,String(a),l)),(yo(e,t,l,!1,!1)||typeof l>"u"&&yo(e,t,null,!1,!1))&&(r!==""&&(r+=","+(e.condenseFlow?"":" ")),r+=e.dump);e.tag=o,e.dump="["+r+"]"}function Bm(e,t,n,r){var o="",a=e.tag,i,l,c;for(i=0,l=n.length;i<l;i+=1)c=n[i],e.replacer&&(c=e.replacer.call(n,String(i),c)),(yo(e,t+1,c,!0,!0,!1,!0)||typeof c>"u"&&yo(e,t+1,null,!0,!0,!1,!0))&&((!r||o!=="")&&(o+=jd(e,t)),e.dump&&qa===e.dump.charCodeAt(0)?o+="-":o+="- ",o+=e.dump);e.tag=a,e.dump=o||"[]"}function T3(e,t,n){var r="",o=e.tag,a=Object.keys(n),i,l,c,u,f;for(i=0,l=a.length;i<l;i+=1)f="",r!==""&&(f+=", "),e.condenseFlow&&(f+='"'),c=a[i],u=n[c],e.replacer&&(u=e.replacer.call(n,c,u)),yo(e,t,c,!1,!1)&&(e.dump.length>1024&&(f+="? "),f+=e.dump+(e.condenseFlow?'"':"")+":"+(e.condenseFlow?"":" "),yo(e,t,u,!1,!1)&&(f+=e.dump,r+=f));e.tag=o,e.dump="{"+r+"}"}function A3(e,t,n,r){var o="",a=e.tag,i=Object.keys(n),l,c,u,f,h,m;if(e.sortKeys===!0)i.sort();else if(typeof e.sortKeys=="function")i.sort(e.sortKeys);else if(e.sortKeys)throw new Wn("sortKeys must be a boolean or a function");for(l=0,c=i.length;l<c;l+=1)m="",(!r||o!=="")&&(m+=jd(e,t)),u=i[l],f=n[u],e.replacer&&(f=e.replacer.call(n,u,f)),yo(e,t+1,u,!0,!0,!0)&&(h=e.tag!==null&&e.tag!=="?"||e.dump&&e.dump.length>1024,h&&(e.dump&&qa===e.dump.charCodeAt(0)?m+="?":m+="? "),m+=e.dump,h&&(m+=jd(e,t)),yo(e,t+1,f,!0,h)&&(e.dump&&qa===e.dump.charCodeAt(0)?m+=":":m+=": ",m+=e.dump,o+=m));e.tag=a,e.dump=o||"{}"}function Vm(e,t,n){var r,o,a,i,l,c;for(o=n?e.explicitTypes:e.implicitTypes,a=0,i=o.length;a<i;a+=1)if(l=o[a],(l.instanceOf||l.predicate)&&(!l.instanceOf||typeof t=="object"&&t instanceof l.instanceOf)&&(!l.predicate||l.predicate(t))){if(n?l.multi&&l.representName?e.tag=l.representName(t):e.tag=l.tag:e.tag="?",l.represent){if(c=e.styleMap[l.tag]||l.defaultStyle,By.call(l.represent)==="[object Function]")r=l.represent(t,c);else if(Vy.call(l.represent,c))r=l.represent[c](t,c);else throw new Wn("!<"+l.tag+'> tag resolver accepts not "'+c+'" style');e.dump=r}return!0}return!1}function yo(e,t,n,r,o,a,i){e.tag=null,e.dump=n,Vm(e,n,!1)||Vm(e,n,!0);var l=By.call(e.dump),c=r,u;r&&(r=e.flowLevel<0||e.flowLevel>t);var f=l==="[object Object]"||l==="[object Array]",h,m;if(f&&(h=e.duplicates.indexOf(n),m=h!==-1),(e.tag!==null&&e.tag!=="?"||m||e.indent!==2&&t>0)&&(o=!1),m&&e.usedDuplicates[h])e.dump="*ref_"+h;else{if(f&&m&&!e.usedDuplicates[h]&&(e.usedDuplicates[h]=!0),l==="[object Object]")r&&Object.keys(e.dump).length!==0?(A3(e,t,e.dump,o),m&&(e.dump="&ref_"+h+e.dump)):(T3(e,t,e.dump),m&&(e.dump="&ref_"+h+" "+e.dump));else if(l==="[object Array]")r&&e.dump.length!==0?(e.noArrayIndent&&!i&&t>0?Bm(e,t-1,e.dump,o):Bm(e,t,e.dump,o),m&&(e.dump="&ref_"+h+e.dump)):(N3(e,t,e.dump),m&&(e.dump="&ref_"+h+" "+e.dump));else if(l==="[object String]")e.tag!=="?"&&k3(e,e.dump,t,a,c);else{if(l==="[object Undefined]")return!1;if(e.skipInvalid)return!1;throw new Wn("unacceptable kind of an object to dump "+l)}e.tag!==null&&e.tag!=="?"&&(u=encodeURI(e.tag[0]==="!"?e.tag.slice(1):e.tag).replace(/!/g,"%21"),e.tag[0]==="!"?u="!"+u:u.slice(0,18)==="tag:yaml.org,2002:"?u="!!"+u.slice(18):u="!<"+u+">",e.dump=u+" "+e.dump)}return!0}function I3(e,t){var n=[],r=[],o,a;for(Td(e,n,r),o=0,a=r.length;o<a;o+=1)t.duplicates.push(n[r[o]]);t.usedDuplicates=new Array(a)}function Td(e,t,n){var r,o,a;if(e!==null&&typeof e=="object")if(o=t.indexOf(e),o!==-1)n.indexOf(o)===-1&&n.push(o);else if(t.push(e),Array.isArray(e))for(o=0,a=e.length;o<a;o+=1)Td(e[o],t,n);else for(r=Object.keys(e),o=0,a=r.length;o<a;o+=1)Td(e[r[o]],t,n)}function R3(e,t){t=t||{};var n=new b3(t);n.noRefs||I3(e,n);var r=e;return n.replacer&&(r=n.replacer.call({"":r},"",r)),yo(n,0,r,!0,!0)?n.dump+`
369
+ `:""}var P3=R3,M3={dump:P3};function hh(e,t){return function(){throw new Error("Function yaml."+e+" is removed in js-yaml 4. Use yaml."+t+" instead, which is now safe by default.")}}var D3=Pn,O3=hy,L3=xy,F3=Cy,$3=Sy,z3=ch,U3=Uy.load,B3=Uy.loadAll,V3=M3.dump,W3=Wn,H3={binary:Ny,float:yy,map:gy,null:vy,pairs:Ay,set:Iy,timestamp:Ey,bool:wy,int:by,merge:jy,omap:Ty,seq:my,str:py},Z3=hh("safeLoad","load"),G3=hh("safeLoadAll","loadAll"),Y3=hh("safeDump","dump"),K3={Type:D3,Schema:O3,FAILSAFE_SCHEMA:L3,JSON_SCHEMA:F3,CORE_SCHEMA:$3,DEFAULT_SCHEMA:z3,load:U3,loadAll:B3,dump:V3,YAMLException:W3,types:H3,safeLoad:Z3,safeLoadAll:G3,safeDump:Y3};const q3=({content:e,rendererType:t,setRenderError:n})=>{const[r,o]=d.useState(!1);d.useEffect(()=>{n(null)},[e,n]);const[a,i]=d.useMemo(()=>{try{if(t==="yaml"){const l=K3.load(e);return[e,l]}else if(t==="json"){const l=JSON.parse(e);return[JSON.stringify(l,null,2),l]}throw new Error(`Unsupported renderer type: ${t}`)}catch(l){const c=t==="yaml"?"YAML":"JSON";console.error(`Error parsing ${c} for panel:`,l);const u={[`${c}_Parsing_Error`]:`The provided content is not valid ${c}.`,Details:l.message,Content_Snippet:e.substring(0,500)+(e.length>500?"...":"")};return n(`${c} parsing failed: ${l.message}`),[e,u]}},[e,t,n]);return s.jsxs("div",{className:"bg-background relative flex h-full flex-col overflow-hidden",children:[s.jsx("div",{className:"absolute top-4 right-4 z-10",children:s.jsx(xe,{onClick:()=>o(!r),title:r?"Show Structured View":"Show Raw Text",children:r?s.jsxs(s.Fragment,{children:[s.jsx($g,{})," Structured"]}):s.jsxs(s.Fragment,{children:[s.jsx(Zd,{})," Raw Text"]})})}),s.jsx("div",{className:"flex min-h-0 flex-col",children:s.jsx("div",{className:"flex-1 overflow-auto",children:r?s.jsx(Qy,{content:a,setRenderError:n}):s.jsx(Ud,{data:i,maxDepth:4,className:"min-h-16 border-none p-2"})})})]})},Qy=({content:e,className:t=""})=>{const{ref:n,handleKeyDown:r}=uy();return s.jsx("div",{className:`overflow-auto p-4 ${t}`,children:s.jsx("pre",{ref:n,className:"whitespace-pre-wrap select-text focus-visible:outline-none",style:{overflowWrap:"anywhere"},tabIndex:0,onKeyDown:r,children:e})})},ph=({content:e,rendererType:t,mime_type:n,setRenderError:r})=>{switch(t){case"csv":return s.jsx(k4,{content:e,setRenderError:r});case"mermaid":return s.jsx(T4,{content:e,setRenderError:r});case"html":return s.jsx(E4,{content:e,setRenderError:r});case"json":case"yaml":return s.jsx(q3,{content:e,rendererType:t,setRenderError:r});case"image":return s.jsx(j4,{content:e,mime_type:n,setRenderError:r});case"markdown":return s.jsx(N4,{content:e,setRenderError:r});case"audio":return s.jsx(S4,{content:e,mime_type:n,setRenderError:r});default:return s.jsx(Qy,{content:e,setRenderError:r})}},mh=e=>{const t=e.split(".");return t.length>1?t[t.length-1].toUpperCase():"FILE"},Er=e=>{switch(e){case"html":return"bg-[#e34c26]";case"json":return"bg-[#fbc02d] text-[#333]";case"yaml":return"bg-[#cb171e]";case"markdown":return"bg-[#6c757d]";case"text":return"bg-[#5c6bc0]";default:return"bg-gray-500"}},X3=(e,t)=>{const n={className:"text-secondary-foreground/60"};if(e){if(e.startsWith("image/"))return s.jsx(Bu,{...n});if(e.startsWith("video/"))return s.jsx(Ph,{...n});if(e.startsWith("audio/"))return s.jsx(Uu,{...n});if(e==="application/pdf")return s.jsx(wr,{...n});if(e==="application/zip"||e==="application/x-zip-compressed"||e==="application/x-rar-compressed"||e==="application/x-tar"||e==="application/gzip")return s.jsx(Mh,{...n});if(e.includes("word")||e.includes("document"))return s.jsx(wr,{...n});if(e.includes("excel")||e.includes("spreadsheet"))return s.jsx(zu,{...n});if(e.includes("powerpoint")||e.includes("presentation"))return s.jsx(Dh,{...n});if(e==="application/x-executable"||e==="application/x-msdownload")return s.jsx(Fa,{...n})}switch(t?mh(t).toLowerCase():""){case"jpg":case"jpeg":case"png":case"gif":case"bmp":case"webp":case"svg":case"ico":return s.jsx(Bu,{...n});case"mp4":case"avi":case"mov":case"wmv":case"flv":case"webm":case"mkv":return s.jsx(Ph,{...n});case"mp3":case"wav":case"flac":case"aac":case"ogg":case"m4a":return s.jsx(Uu,{...n});case"pdf":case"doc":case"docx":return s.jsx(wr,{...n});case"xls":case"xlsx":case"csv":return s.jsx(zu,{...n});case"ppt":case"pptx":return s.jsx(Dh,{...n});case"zip":case"rar":case"7z":case"tar":case"gz":return s.jsx(Mh,{...n});case"exe":case"msi":case"dmg":case"pkg":case"deb":case"rpm":return s.jsx(Fa,{...n});case"ttf":case"otf":case"woff":case"woff2":return s.jsx(zg,{...n});case"htm":case"html":return s.jsx(Rg,{...n});default:return null}},J3=(e,t)=>{if(e){if(e.startsWith("text/html")||e==="application/xhtml+xml")return Er("html");if(e==="application/json"||e==="text/json")return Er("json");if(e==="application/yaml"||e==="text/yaml"||e==="application/x-yaml"||e==="text/x-yaml")return Er("yaml");if(e.startsWith("text/"))return Er("text");if(e.startsWith("text/markdown")||e==="application/markdown")return Er("markdown")}switch(t?mh(t).toLowerCase():""){case"html":case"htm":return Er("html");case"json":return Er("json");case"yaml":case"yml":return Er("yaml");case"md":case"markdown":return Er("markdown");case"txt":return Er("text");default:return Er("default")}},Q3=({filename:e,mimeType:t,className:n})=>{if(!e||typeof e!="string")return console.warn("FileIcon: filename is required and must be a string"),null;const r=mh(e),o=J3(t,e),a=X3(t,e);return s.jsx("div",{className:ze("relative flex-shrink-0",n),children:s.jsxs("div",{className:"bg-muted/50 relative h-[75px] w-[60px] border",children:[s.jsx("div",{className:"absolute top-[4px] right-[4px] bottom-[24px] left-[4px] overflow-hidden font-mono text-[3.5px] leading-[1.4]",children:a?s.jsx("div",{className:"flex h-full items-center justify-center",children:a}):s.jsx("div",{className:"text-secondary-foreground flex h-full text-[8px] select-none",children:s.jsx("div",{className:"flex h-full w-full items-center justify-center",children:s.jsx($u,{className:"text-secondary-foreground/60"})})})}),s.jsx("div",{className:ze("absolute right-[4px] bottom-[4px] z-[4] px-[4px] py-[2px] text-[10px] font-bold text-[var(--color-primary-text-w10)] select-none",o),children:r.length>4?r.substring(0,4):r})]})})},Wm=({message:e})=>s.jsx("div",{className:"w-full rounded-lg border border-[var(--color-error-w100)] bg-[var(--color-error-wMain-50)] p-3",children:s.jsxs("div",{className:"text-sm text-[var(--color-error-wMain)]",children:["Error: ",e]})}),eM=({filename:e,description:t,mimeType:n,size:r,status:o,expandable:a=!1,expanded:i=!1,onToggleExpand:l,actions:c,bytesTransferred:u,error:f,expandedContent:h,context:m="chat",isDeleted:p=!1,version:x,source:g})=>{const[w,v]=d.useState(h),[b,C]=d.useState(()=>document.documentElement.classList.contains("dark"));if(d.useEffect(()=>{if(h)v(h);else{const T=setTimeout(()=>{v(void 0)},300);return()=>clearTimeout(T)}},[h]),d.useEffect(()=>{const T=new MutationObserver(()=>{C(document.documentElement.classList.contains("dark"))});return T.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>T.disconnect()},[]),!e||typeof e!="string")return console.error("ArtifactBar: filename is required and must be a string"),s.jsx(Wm,{message:"Invalid artifact filename"});if(!o||!["in-progress","completed","failed"].includes(o))return console.error("ArtifactBar: status must be one of: in-progress, completed, failed"),s.jsx(Wm,{message:"Invalid artifact status"});const E=(()=>{if(p)return{text:"Deleted",className:"text-[var(--color-secondary-foreground)]"};switch(o){case"in-progress":return{text:u?`Creating... ${(u/1024).toFixed(1)}KB`:"Creating...",className:"text-[var(--color-info-wMain)]"};case"failed":return{text:f||"Failed to create",className:"text-[var(--color-error-wMain)]"};case"completed":return{text:r?`${(r/1024).toFixed(1)}KB`:""};default:return{text:"Unknown",className:"text-[var(--color-secondary-foreground)]"}}})(),j=((T,R=100)=>{if(!T||typeof T!="string")return"";const z=T.replace(/\s+/g," ").trim();if(z.length<=R)return z;const F=z.substring(0,R),I=F.lastIndexOf(" ");return I>R*.7?F.substring(0,I)+"...":F+"..."})(t),A=t&&t.trim(),P=()=>{if(o==="completed"&&(c!=null&&c.onPreview))try{c.onPreview()}catch(T){console.error("Preview failed:",T)}},O=b?"var(--color-background-wMain)":"var(--color-background-w10)",B=b?"0px 1px 4px 0px var(--color-primary-w90)":"0px 1px 4px 0px var(--color-secondary-w8040)",N=b?"0px 2px 8px 0px var(--color-primary-w90)":"0px 2px 8px 0px var(--color-secondary-w8040)",M=o==="completed"&&(c==null?void 0:c.onPreview)&&!p,y=m==="chat"&&!p;return s.jsxs("div",{className:`w-full ${M?"cursor-pointer":""} ${m==="list"?"border-b":""} ${p?"opacity-60":""} transition-shadow duration-200 ease-in-out`,style:{backgroundColor:O,boxShadow:y?B:void 0,borderRadius:m==="list"?void 0:"4px"},onMouseEnter:T=>{M&&(T.currentTarget.style.boxShadow=N)},onMouseLeave:T=>{M&&(T.currentTarget.style.boxShadow=B)},onClick:p?void 0:P,children:[s.jsxs("div",{className:"flex min-h-[60px] items-center gap-3 p-3",children:[s.jsx(Q3,{filename:e,mimeType:n,size:r,className:"flex-shrink-0"}),s.jsxs("div",{className:"min-w-0 flex-1 py-1",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:"truncate text-sm leading-tight font-semibold",title:A?t:e,children:A?j:e.length>50?`${e.substring(0,47)}...`:e}),g==="project"&&s.jsx(zr,{variant:"outline",className:"bg-primary/10 border-primary/30 text-primary px-2 py-0.5 text-xs font-semibold shadow-sm",children:"Project"})]}),s.jsx("div",{className:"text-secondary-foreground mt-1 flex items-center gap-2 text-xs leading-tight",title:A?e:E.text,children:A?s.jsxs("div",{className:"truncate",children:[e.length>60?`${e.substring(0,57)}...`:e,x!==void 0&&m==="chat"&&s.jsxs("span",{className:"ml-1.5",children:["(v",x,")"]})]}):s.jsxs(s.Fragment,{children:[o==="in-progress"&&s.jsx(no,{size:"small",variant:"primary"}),s.jsx("span",{className:E.className,children:E.text})]})}),A&&s.jsxs("div",{className:ze("mt-0.5 flex items-center gap-2 text-xs leading-tight",E.className),children:[o==="in-progress"&&s.jsx(no,{size:"small",variant:"primary"}),s.jsx("span",{children:E.text})]})]}),s.jsxs("div",{className:"flex flex-shrink-0 items-center gap-1",children:[o==="completed"&&(c==null?void 0:c.onInfo)&&!p&&s.jsx(xe,{variant:"ghost",size:"icon",onClick:T=>{var R;T.stopPropagation();try{(R=c.onInfo)==null||R.call(c)}catch(z){console.error("Info failed:",z)}},tooltip:"Info",children:s.jsx(ti,{className:"h-4 w-4"})}),o==="completed"&&(c==null?void 0:c.onDownload)&&!p&&s.jsx(xe,{variant:"ghost",size:"icon",onClick:T=>{var R;T.stopPropagation();try{(R=c.onDownload)==null||R.call(c)}catch(z){console.error("Download failed:",z)}},tooltip:"Download",children:s.jsx(Co,{className:"h-4 w-4"})}),o==="completed"&&(c==null?void 0:c.onExpand)&&!p&&s.jsx(xe,{variant:"ghost",size:"icon",onClick:T=>{var R;T.stopPropagation();try{(R=c.onExpand)==null||R.call(c)}catch(z){console.error("Expand failed:",z)}},tooltip:i?"Collapse":"Expand",children:i?s.jsx(Vu,{className:"h-4 w-4"}):s.jsx(ml,{className:"h-4 w-4"})}),o==="completed"&&(c==null?void 0:c.onDelete)&&!p&&s.jsx(xe,{variant:"ghost",size:"icon",onClick:T=>{var R;T.stopPropagation();try{(R=c.onDelete)==null||R.call(c)}catch(z){console.error("Delete failed:",z)}},tooltip:"Delete",children:s.jsx(Hl,{className:"h-4 w-4"})}),o==="failed"&&s.jsx("div",{className:"pr-4",title:"Artifact action failed",children:s.jsx(fo,{className:"h-4 w-4 text-[var(--color-error-wMain)]"})})]}),a&&l&&!p&&s.jsx(xe,{variant:"ghost",size:"icon",onClick:T=>{T.stopPropagation();try{l()}catch(R){console.error("Toggle expand failed:",R)}},tooltip:i?"Collapse":"Expand",children:i?s.jsx(Vu,{className:"h-4 w-4 transition-transform duration-200"}):s.jsx(ml,{className:"h-4 w-4 transition-transform duration-200"})})]}),s.jsx("div",{className:ze("grid grid-rows-[0fr] transition-[grid-template-rows] duration-300 ease-in-out",i&&h&&"grid-rows-[1fr]"),children:s.jsx("div",{className:"overflow-hidden",children:w&&s.jsxs(s.Fragment,{children:[s.jsx("hr",{className:"border-t"}),s.jsx("div",{className:"p-3",children:w})]})})})]})},e1=({isVisible:e,message:t="Resolving embeds..."})=>e?s.jsx("div",{className:"absolute inset-0 z-50 flex items-center justify-center bg-background/80 backdrop-blur-sm transition-opacity duration-200",style:{opacity:e?1:0,pointerEvents:e?"auto":"none"},children:s.jsxs("div",{className:"flex flex-col items-center gap-3 rounded-lg bg-card p-6 shadow-lg",children:[s.jsx(fr,{className:"h-6 w-6 animate-spin text-primary"}),s.jsx("p",{className:"text-sm text-muted-foreground",children:t})]})}):null,Ma=e=>{const{artifacts:t,setPreviewArtifact:n,openSidePanelTab:r,sessionId:o,openDeleteModal:a,markArtifactAsDisplayed:i,downloadAndResolveArtifact:l,navigateArtifactVersion:c}=Ft(),{activeProject:u}=ko(),[f,h]=d.useState(!1),[m,p]=d.useState(null),[x,g]=d.useState(null),[w,v]=d.useState(null),[b,C]=d.useState(!1),[S,E]=d.useState(!1),_=d.useMemo(()=>t.find(k=>k.filename===e.name),[t,e.name]),j=e.context||"chat",A=(_==null?void 0:_.source)==="project",P=d.useMemo(()=>{const k=e.status==="completed"?e.fileAttachment:void 0;if(k!=null&&k.uri){const oe=Ju(k.uri);return(oe==null?void 0:oe.version)!==null&&(oe==null?void 0:oe.version)!==void 0?parseInt(oe.version):void 0}},[e]),O=e.status==="completed"?e.fileAttachment:void 0,B=(O==null?void 0:O.name)||e.name,N=O==null?void 0:O.mime_type,M=d.useMemo(()=>e.status==="completed"&&!_,[e.status,_]),y=d.useMemo(()=>{if(M)return!1;const k=Ir(B,N),oe=k==="image"||k==="audio"||k==="markdown",ie=B.toLowerCase().endsWith(".txt")||B.toLowerCase().endsWith(".text");return(oe||k==="text"&&ie)&&j==="chat"},[B,N,j,M]),{shouldRender:T,isExpandable:R,isExpanded:z,toggleExpanded:F}=bT({filename:B,mimeType:N,shouldAutoExpand:y}),I=d.useCallback(async()=>{_&&(r("files"),n(_),P!==void 0&&setTimeout(async()=>{await c(_.filename,P)},100))},[_,r,n,P,c]),J=d.useCallback(()=>{let k=null;_?(k={name:_.filename,mime_type:_.mime_type,uri:_.uri,size:_.size,last_modified:_.last_modified},!k.uri&&(O!=null&&O.content)&&(k.content=O.content)):O&&(k=O),k?Lx(k,o,u==null?void 0:u.id):console.error(`No file to download for artifact: ${e.name}`)},[_,O,o,u==null?void 0:u.id,e.name]),L=d.useCallback(()=>{_&&a(_)},[_,a]),D=d.useCallback(()=>{C(!b)},[b]);d.useEffect(()=>{const k=_==null?void 0:_.filename;return T&&k&&i(k,!0),()=>{k&&i(k,!1)}},[T,_==null?void 0:_.filename,i]);const W=d.useMemo(()=>Ir(B,N)==="image",[B,N]),G=d.useMemo(()=>{const k=Ir(B,N);return k==="text"||k==="markdown"},[B,N]);d.useEffect(()=>{e.status==="in-progress"&&(_!=null&&_.accumulatedContent)&&T&&g(_.accumulatedContent)},[_==null?void 0:_.accumulatedContent,e.status,B,T,z]),d.useEffect(()=>{(async()=>{if(_!=null&&_.needsEmbedResolution&&e.status==="completed"&&T&&!S){E(!0);try{const oe=await l(_.filename);oe!=null&&oe.content&&g(oe.content)}catch(oe){console.error(`Error downloading ${B}:`,oe)}finally{E(!1)}}})()},[_==null?void 0:_.needsEmbedResolution,e.status,T,B,_==null?void 0:_.filename,l,S]),d.useEffect(()=>{(async()=>{if(f||!T)return;if(e.status==="in-progress"){_!=null&&_.accumulatedContent&&g(_.accumulatedContent);return}if(e.status!=="completed")return;if(_!=null&&_.accumulatedContent){g(_.accumulatedContent);return}const oe=O==null?void 0:O.content;if(x||oe){oe&&!x&&g(oe);return}const ie=O==null?void 0:O.uri;if(ie){h(!0),p(null);try{const Z=Ju(ie);if(!Z)throw new Error("Invalid artifact URI.");const{filename:U,version:re}=Z;let $;o&&o.trim()&&o!=="null"&&o!=="undefined"?$=`/api/v1/artifacts/${o}/${encodeURIComponent(U)}/versions/${re||"latest"}`:u!=null&&u.id?$=`/api/v1/artifacts/null/${encodeURIComponent(U)}/versions/${re||"latest"}?project_id=${u.id}`:$=`/api/v1/artifacts/null/${encodeURIComponent(U)}/versions/${re||"latest"}`;const Y=await pt($);if(!Y.ok)throw new Error(`Failed to fetch artifact content: ${Y.statusText}`);const H=await Y.blob(),ce=await new Promise((ue,ae)=>{const pe=new FileReader;pe.onloadend=()=>{typeof pe.result=="string"?ue(pe.result.split(",")[1]):ae(new Error("Failed to read artifact content as a data URL."))},pe.onerror=()=>{ae(pe.error||new Error("An unknown error occurred while reading the file."))},pe.readAsDataURL(H)});g(ce)}catch(Z){console.error("Error fetching inline content:",Z),p(Z instanceof Error?Z.message:"Unknown error fetching content.")}finally{h(!1)}}})()},[e.status,T,O,o,u==null?void 0:u.id,f,x,_==null?void 0:_.accumulatedContent,B,z,_]);const V=d.useMemo(()=>{if(e.status!=="failed")return j==="list"?{onInfo:D,onDownload:e.status==="completed"?J:void 0,onDelete:_&&e.status==="completed"&&!A?L:void 0}:{onPreview:e.status==="completed"?I:void 0,onDownload:e.status==="completed"?J:void 0,onInfo:D}},[e.status,j,J,_,L,D,I,A]),Q=d.useMemo(()=>t.find(k=>k.filename===e.name),[t,e.name]),X=Q==null?void 0:Q.description,K=x||(O==null?void 0:O.content),q=Ir(B,N);let ne=null;if(f)ne=s.jsx("div",{className:"bg-muted flex h-25 items-center justify-center",children:s.jsx(no,{})});else if(m)ne=s.jsx(Kt,{variant:"error",message:m});else if(K&&q)try{const oe=Mw({...O||{name:B,mime_type:N},content:K,isPlainText:(_==null?void 0:_.isAccumulatedContentPlainText)&&x===(_==null?void 0:_.accumulatedContent)||e.status==="in-progress"&&!!x});if(oe){let ie,Z,U;W?(ie="none",U="visible"):G?(ie="6000px",U="auto"):q==="audio"?(ie="300px",U="auto"):q==="html"?(Z="600px",ie="600px",U="auto"):(ie="600px",U="auto"),ne=s.jsxs("div",{className:"group relative max-w-full overflow-hidden",children:[w&&s.jsx(Kt,{variant:"error",message:w}),s.jsx("div",{style:{height:Z,maxHeight:ie,overflowY:U},className:W?"drop-shadow-md":"",children:s.jsx(ph,{content:oe,rendererType:q,mime_type:O==null?void 0:O.mime_type,setRenderError:v})}),s.jsx(e1,{isVisible:S,message:"Resolving embeds..."})]})}}catch(k){console.error("Failed to process file content:",k),ne=s.jsx(Kt,{variant:"error",message:"Failed to process file content for rendering"})}const de=T&&z,se=d.useMemo(()=>!b||!_?null:s.jsxs("div",{className:"space-y-2 text-sm",children:[_.description&&s.jsxs("div",{children:[s.jsx("span",{className:"text-secondary-foreground",children:"Description:"}),s.jsx("div",{className:"mt-1",children:_.description})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[s.jsxs("div",{children:[s.jsx("span",{className:"text-secondary-foreground",children:"Size:"}),s.jsx("div",{children:si(_.size)})]}),s.jsxs("div",{children:[s.jsx("span",{className:"text-secondary-foreground",children:"Modified:"}),s.jsx("div",{children:Ys(_.last_modified)})]})]}),_.mime_type&&s.jsxs("div",{children:[s.jsx("span",{className:"text-secondary-foreground",children:"Type:"}),s.jsx("div",{children:_.mime_type})]})]}),[b,_]),me=d.useMemo(()=>{const k=b&&se,oe=de&&ne;if(k&&oe)return s.jsxs("div",{className:"space-y-4",children:[se,s.jsx("hr",{className:"border-t"}),ne]});if(k)return se;if(oe)return ne},[b,se,de,ne]);return s.jsx(eM,{filename:B,description:X||"",mimeType:N,size:O==null?void 0:O.size,status:e.status,expandable:R&&j==="chat",expanded:z||b,onToggleExpand:R&&j==="chat"?F:void 0,actions:V,bytesTransferred:e.status==="in-progress"?e.bytesTransferred:void 0,error:e.status==="failed"?e.error:void 0,expandedContent:me,context:j,isDeleted:M,version:P,source:_==null?void 0:_.source})},t1=({filename:e,mimeType:t,className:n,onDownload:r,isEmbedded:o=!1})=>{const{artifacts:a,setPreviewArtifact:i,openSidePanelTab:l}=Ft(),c=d.useMemo(()=>a.find(m=>m.filename===e),[a,e]),u=d.useMemo(()=>Vf(c||{filename:e,mime_type:t||""}),[c,e,t]),f=d.useCallback(m=>{m.stopPropagation(),c&&(l("files"),i(c))},[c,l,i]),h=d.useCallback(()=>{r&&r()},[r]);return s.jsxs("div",{className:`flex h-11 max-w-xs flex-shrink items-center gap-2 rounded-lg bg-[var(--accent-background)] px-2 py-1 ${n||""}`,children:[u,s.jsx("span",{className:"min-w-0 flex-1 truncate text-sm leading-9",title:e,children:s.jsx("strong",{children:s.jsx("code",{children:e})})}),c&&!o&&s.jsx(xe,{variant:"ghost",onClick:f,tooltip:"Preview",children:s.jsx($g,{className:"h-4 w-4"})}),r&&s.jsx(xe,{variant:"ghost",onClick:h,tooltip:"Download file",children:s.jsx(Co,{className:"h-4 w-4"})})]})},tM=Rt.memo(({isOpen:e,onClose:t,feedbackType:n,onSubmit:r})=>{const[o,a]=d.useState(""),[i,l]=d.useState(!1),c=d.useRef(null);d.useEffect(()=>{e&&(a(""),l(!1),setTimeout(()=>{var m;(m=c.current)==null||m.focus()},100))},[e]);const u=async()=>{l(!0);try{await r(o),t()}catch{l(!1)}},f=()=>{i||t()},h=n==="up"?"What did you like about the response?":"What did you dislike about the response?";return s.jsx(On,{open:e,onOpenChange:f,children:s.jsxs(Ln,{className:"sm:max-w-[750px]",showCloseButton:!1,children:[s.jsxs(Gn,{children:[s.jsx(Fn,{children:"Provide Feedback"}),s.jsxs(Yn,{className:"flex flex-col gap-2",children:[s.jsx("span",{children:h}),s.jsx("span",{children:"Providing more details will help improve AI responses over time."})]})]}),s.jsxs("div",{className:"flex flex-col gap-2",children:[s.jsx(Wr,{ref:c,value:o,onChange:m=>a(m.target.value),className:"min-h-[120px] text-sm",disabled:i}),s.jsx("p",{className:"text-muted-foreground text-xs",children:"Along with your feedback, details of the task will be recorded."})]}),s.jsxs(nr,{children:[s.jsx(xe,{variant:"ghost",onClick:f,disabled:i,children:"Cancel"}),s.jsx(xe,{variant:"default",onClick:u,disabled:i,children:"Submit"})]})]})})}),nM={"application/pdf":"pdf","application/zip":"zip","application/msword":"doc","application/vnd.openxmlformats-officedocument.wordprocessingml.document":"docx","application/vnd.ms-excel":"xls","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":"xlsx","application/vnd.ms-powerpoint":"ppt","application/vnd.openxmlformats-officedocument.presentationml.presentation":"pptx","text/plain":"txt","text/csv":"csv","text/html":"html","text/markdown":"md","text/x-markdown":"md","application/json":"json","application/yaml":"yaml","text/yaml":"yaml","application/xml":"xml","text/xml":"xml","image/jpeg":"jpg","image/png":"png","image/gif":"gif","image/svg+xml":"svg","image/webp":"webp","image/bmp":"bmp","image/tiff":"tiff","audio/mpeg":"mp3","audio/wav":"wav","audio/ogg":"ogg","audio/aac":"aac","audio/flac":"flac","audio/x-m4a":"m4a","video/mp4":"mp4","video/webm":"webm","video/ogg":"ogv","application/javascript":"js","application/gzip":"gz","application/x-tar":"tar","application/rtf":"rtf"};function rM(e,t){const n=nM[e]||"bin";return`embedded_file_${t+1}.${n}`}function oM(e){if(!e||typeof e!="string")return[];const t=[],n=/data:([a-zA-Z0-9/.-]+);base64,([A-Za-z0-9+/=]+)/g;let r,o=0;for(;(r=n.exec(e))!==null;){const[a,i,l]=r,c=e[r.index-1],u=e[r.index+a.length];if(!(c==='"'&&u==='"'||c==="'"&&u==="'")&&l&&l.length>10){const f=Ir(void 0,i);f?t.push({type:f,content:l,mimeType:i,originalMatch:a}):t.push({type:"file",content:l,mimeType:i,originalMatch:a,filename:rM(i,o++)})}}return t}function sM(e){if(!e||typeof e!="string")return[];const t=[],n=/<html[\s\S]*?<\/html>/gi;let r;for(;(r=n.exec(e))!==null;)t.push({type:"html",content:r[0].trim(),originalMatch:r[0]});return t}function aM(e){if(!e||typeof e!="string")return[];const t=[],n=/```mermaid\s*\n([\s\S]*?)```/gi;let r;for(;(r=n.exec(e))!==null;){const[o,a]=r;t.push({type:"mermaid",content:a.trim(),originalMatch:o})}return t}function iM(e){return!e||typeof e!="string"?[]:[...oM(e),...sM(e),...aM(e)]}const n1={LAYOUT:"layout"},Vn=({label:e,value:t,icon:n,fullWidthValue:r=!1})=>t==null||typeof t=="string"&&!t.trim()?null:s.jsxs("div",{className:`mb-1.5 flex text-sm ${r?"flex-col items-start":"items-center"}`,children:[s.jsxs("div",{className:"flex w-36 flex-shrink-0 items-center text-sm font-semibold text-nowrap",children:[n&&s.jsx("span",{className:"mr-2",children:n}),e,":"]}),s.jsx("div",{className:`text-accent-foreground text-sm ${r?"mt-1 w-full":"truncate"}`,title:typeof t=="string"?t:void 0,children:t})]}),lM=({agent:e,isExpanded:t,onToggleExpand:n})=>{const r=l=>!l||Object.keys(l).length===0?s.jsx("span",{className:"text-sm",children:"N/A"}):s.jsx("ul",{className:"list-inside list-disc pl-1",children:Object.entries(l).map(([c,u])=>s.jsxs("li",{className:"text-sm",children:[s.jsxs("span",{className:"capitalize",children:[c.replace(/_/g," "),":"]})," ",u?"Yes":"No"]},c))}),o=(l,c="None")=>!l||l.length===0?s.jsx("span",{children:c}):l.map(u=>s.jsx("span",{className:"mr-1 mb-1 inline-block rounded-full px-2 py-0.5 text-xs font-medium",children:u},u)),a=l=>!l||l.length===0?s.jsx("span",{children:"No skills listed"}):s.jsx("div",{className:"space-y-1",children:l.map(c=>s.jsxs("div",{className:"rounded p-1.5 text-xs",children:[s.jsx("p",{className:"font-semibold",children:c.name}),s.jsx("p",{children:c.description})]},c.id||c.name))}),i=l=>!l||l.length===0?s.jsx("span",{children:"No tools listed"}):s.jsx("div",{className:"space-y-1",children:l.map(c=>s.jsxs("div",{className:"rounded p-1.5 text-xs",children:[s.jsx("p",{className:"text-foreground font-semibold",children:c.name}),s.jsx("p",{className:"mb-1",children:c.description})]},c.name))});return s.jsx("div",{className:"bg-card h-[400px] w-full flex-shrink-0 cursor-pointer rounded-lg sm:w-[380px]",onClick:n,role:"button",tabIndex:0,"aria-expanded":t,children:s.jsxs("div",{className:`transform-style-preserve-3d relative h-full w-full transition-transform duration-700 ${t?"rotate-y-180":""}`,style:{transformStyle:"preserve-3d"},children:[s.jsxs("div",{className:"absolute flex h-full w-full flex-col overflow-hidden rounded-lg border shadow-xl",style:{backfaceVisibility:"hidden",transform:"rotateY(0deg)"},children:[s.jsx("div",{className:"flex items-center p-4",children:s.jsxs("div",{className:"flex min-w-0 items-center",children:[s.jsx(Zl,{className:"mr-3 h-8 w-8 flex-shrink-0 text-[var(--color-brand-wMain)]"}),s.jsx("div",{className:"min-w-0",children:s.jsx("h2",{className:"truncate text-xl font-semibold",title:e.name,children:e.displayName||e.name})})]})}),s.jsxs("div",{className:"scrollbar-themed flex-grow space-y-3 overflow-y-auto p-4",children:[s.jsx("div",{className:"mb-2 line-clamp-4 text-base",children:e.description||"No description provided."}),s.jsx(Vn,{label:"Version",value:e.version,icon:s.jsx(Oh,{size:14})}),e.capabilities&&Object.keys(e.capabilities).length>0&&s.jsx(Vn,{label:"Key Capabilities",value:r(e.capabilities),icon:s.jsx(Lh,{size:14}),fullWidthValue:!0})]}),s.jsx("div",{"data-testid":"clickForDetails",className:"text-accent-foreground border-t p-2 text-center text-sm",children:"Click for details"})]}),s.jsxs("div",{className:"absolute flex h-full w-full flex-col overflow-hidden rounded-lg border shadow-xl",style:{backfaceVisibility:"hidden",transform:"rotateY(180deg)"},children:[s.jsx("div",{className:"flex items-center p-3",children:s.jsxs("h3",{className:"text-md truncate font-semibold",title:e.name,children:["Details: ",e.displayName||e.name]})}),s.jsxs("div",{className:"scrollbar-themed flex-grow space-y-1.5 overflow-y-auto p-3 text-xs",children:[s.jsx(Vn,{label:"Name",value:e.name,icon:s.jsx(ti,{size:14})}),s.jsx(Vn,{label:"Description",value:e.description,icon:s.jsx(K1,{size:14}),fullWidthValue:!0}),s.jsx(Vn,{label:"Version",value:e.version,icon:s.jsx(Oh,{size:14})}),s.jsx(Vn,{label:"Endpoint",value:e.url||"N/A",icon:s.jsx(Ug,{size:14})}),s.jsx(Vn,{label:"Docs",value:e.documentationUrl?s.jsx("a",{href:e.documentationUrl,target:"_blank",rel:"noopener noreferrer",className:"break-all",children:"View Docs"}):"N/A",icon:s.jsx(Lg,{size:14})}),e.provider&&s.jsxs("div",{className:"mt-1.5 border-t pt-1.5",children:[s.jsx("h4",{className:"mb-0.5 text-xs font-semibold",children:"Provider"}),s.jsx(Vn,{label:"Name",value:e.provider.organization}),s.jsx(Vn,{label:"URL",value:e.provider.url||"N/A"})]}),s.jsx(Vn,{label:"Capabilities",value:r(e.capabilities),icon:s.jsx(Lh,{size:14}),fullWidthValue:!0}),s.jsx(Vn,{label:"Input Modes",value:o(e.defaultInputModes),icon:s.jsx(Fh,{size:14}),fullWidthValue:!0}),s.jsx(Vn,{label:"Output Modes",value:o(e.defaultOutputModes),icon:s.jsx(Fh,{size:14}),fullWidthValue:!0}),s.jsx(Vn,{label:"Skills",value:a(e.skills),icon:s.jsx(q1,{size:14}),fullWidthValue:!0}),s.jsx(Vn,{label:"Tools Info",value:i(e.tools),icon:s.jsx(Zd,{size:14}),fullWidthValue:!0}),s.jsx("div",{className:"text-2xs mt-1.5 pt-1.5",children:s.jsx(Vn,{label:"A2A Protocol",value:e.protocolVersion})})]}),s.jsx("div",{className:"text-accent-foreground border-t p-2 text-center text-sm",children:"Click for summary"})]})]})})},cM=s.jsx(Zl,{className:"text-muted-foreground",size:64}),Ad=({agents:e})=>{const[t,n]=d.useState(null),[r,o]=d.useState(""),a=l=>{n(c=>c===l?null:l)},i=e.filter(l=>{var c;return(c=l.displayName||l.name)==null?void 0:c.toLowerCase().includes(r.toLowerCase())});return s.jsx(s.Fragment,{children:e.length===0?s.jsx(Lr,{image:cM,title:"No agents found",subtitle:"No agents discovered in the current namespace."}):s.jsxs("div",{className:"h-full w-full pt-2 pl-2",children:[s.jsx(Nf,{value:r,onChange:o,placeholder:"Filter by name...",testid:"agentSearchInput",className:"mb-4 w-xs"}),i.length===0&&r?s.jsx(Lr,{variant:"notFound",title:"No Agents Match Your Filter",subtitle:"Try adjusting your filter terms.",buttons:[{text:"Clear Filter",variant:"default",onClick:()=>o("")}]}):s.jsx("div",{className:"max-h-[calc(100vh-250px)] overflow-y-auto",children:s.jsx("div",{className:"flex flex-wrap gap-10",children:i.map(l=>s.jsx(lM,{agent:l,isExpanded:t===l.name,onToggleExpand:()=>a(l.name)},l.name))})})]})})},uM=({currentLayout:e,onLayoutChange:t,className:n=""})=>{const r=r1.getPluginsByType(n1.LAYOUT);return r&&r.length>1?s.jsxs("div",{className:`flex items-center space-x-1 ${n}`,children:[s.jsx("span",{className:"text-sm font-semibold",children:"Layout:"}),s.jsx("div",{className:"flex gap-1 rounded-sm p-1",children:r.map(o=>{const a=o.icon,i=e===o.id;return s.jsxs(xe,{variant:"ghost",size:"sm",onClick:()=>t(o.id),title:o.label,className:i?"bg-[var(--color-secondary-w20)] dark:bg-[var(--color-secondary-w80)]":"",children:[a&&s.jsx(a,{size:14}),s.jsx("span",{children:o.label})]},o.id)})})]}):null};class dM{constructor(){Ih(this,"_plugins",{});this.registerDefaultPlugins()}get plugins(){return Object.values(this._plugins)}registerPlugin(t){this._plugins[t.id]&&console.warn(`Plugin with ID ${t.id} already exists. Overwriting.`),this._plugins[t.id]=t}getPluginById(t){return this._plugins[t]}getPluginsByType(t){return Object.values(this._plugins).filter(n=>n.type===t)}registerDefaultPlugins(){this.registerPlugin({type:n1.LAYOUT,id:"cards",label:"Cards",icon:X1,priority:100,render:t=>s.jsx(Ad,{agents:t.agents||[]})})}renderPlugin(t,n){const r=this.getPluginById(t);if(r)return r.render(n)}}const r1=new dM,Hm={CARDS:"cards"},fM=({message:e})=>{const{handleCancel:t,setMessages:n,isResponding:r,isCancelling:o}=Ft();if(e.authenticationLink){const a=e.authenticationLink.authenticationAttempted||!1,i=e.authenticationLink.rejected||!1,l=()=>{if(a||i)return;n(h=>h.map(m=>{var p,x;return((p=m.metadata)==null?void 0:p.messageId)===((x=e.metadata)==null?void 0:x.messageId)&&m.authenticationLink?{...m,authenticationLink:{...m.authenticationLink,authenticationAttempted:!0}}:m}));const f=window.open(e.authenticationLink.url,"_blank","width=800,height=700,scrollbars=yes,resizable=yes");f&&f.focus()},c=async()=>{a||i||(n(f=>f.map(h=>{var m,p;return((m=h.metadata)==null?void 0:m.messageId)===((p=e.metadata)==null?void 0:p.messageId)&&h.authenticationLink?{...h,authenticationLink:{...h.authenticationLink,rejected:!0}}:h})),t())},u=e.authenticationLink.targetAgent||"Agent";return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"w-max rounded-lg border p-4",children:[s.jsx("div",{className:"font-semibold",children:"Action Needed"}),s.jsxs("div",{className:"py-4",children:['The "',u,'" agent requires authentication.']}),s.jsxs("div",{className:"flex flex-row flex-wrap justify-end gap-2",children:[s.jsx(xe,{variant:"ghost",onClick:c,disabled:a||i||!r||o,children:"Reject"}),s.jsx(xe,{onClick:l,disabled:a||i||!r||o,children:e.authenticationLink.text})]}),s.jsx("div",{className:"text-muted-foreground text-center text-xs",children:a&&s.jsx("div",{className:"mt-4",children:"Authentication window has been opened. Complete the process in the new window."})})]}),i&&s.jsx(Kt,{message:"Authentication request was rejected"})]})}return null},Zm=new Set;let Tn=null;function hM(e){return!e.parts||e.parts.length===0?"":e.parts.filter(n=>n.kind==="text").map(n=>n.text).join(" ").trim()}const pM=({message:e,className:t})=>{var B;const{settings:n,onTTSStart:r,onTTSEnd:o}=Bo(),{configFeatureEnablement:a}=Ut(),i=((B=e.metadata)==null?void 0:B.messageId)||"",l=d.useMemo(()=>hM(e),[e]),c=!e.isComplete,u=(a==null?void 0:a.textToSpeech)??!0,{isSpeaking:f,isLoading:h,speak:m,stop:p}=DT({messageId:i,onStart:()=>{r()},onEnd:()=>{Tn===i&&(Tn=null),o()},onError:N=>{console.error("TTS error:",N),Tn===i&&(Tn=null),o()}}),{isPlaying:x,isLoading:g,processStreamingText:w,stop:v}=MT({messageId:i,onStart:()=>{},onEnd:()=>{Tn===i&&(Tn=null)},onError:N=>{console.error("Streaming TTS error:",N),Tn===i&&(Tn=null)}}),b=c?x:f,C=c?g:h,S=d.useRef(!1),E=d.useRef(!1),[_,j]=d.useState(!1);d.useEffect(()=>{e.isComplete&&i&&(j(!0),Zm.add(i))},[]),d.useEffect(()=>{const N=n.conversationMode;if(N&&!e.isUser&&c&&l&&l.length>20&&!S.current){if(Tn&&Tn!==i)return;Tn=i,S.current=!0,w(l,!1)}else if(N&&!e.isUser&&c&&S.current)w(l,!1);else if(N&&!e.isUser&&e.isComplete&&S.current&&!E.current)E.current=!0,w(l,!0);else if(N&&!e.isUser&&e.isComplete&&!S.current&&!E.current&&l&&!_){if(Tn&&Tn!==i)return;Tn=i,S.current=!0,E.current=!0,w(l,!0)}},[n.conversationMode,n.automaticPlayback,e.isUser,c,e.isComplete,l,i,w,_]),d.useEffect(()=>{if(n.conversationMode&&!e.isUser&&e.isComplete&&l&&!b&&!C&&!E.current&&!S.current&&!_){if(Tn&&Tn!==i)return;Tn=i,E.current=!0;const M=setTimeout(()=>{m(l)},100);return()=>clearTimeout(M)}},[n.conversationMode,n.automaticPlayback,e.isUser,e.isComplete,l,b,C,i,m,_]),d.useEffect(()=>{E.current=!1,S.current=!1,e.isComplete&&i?(j(!0),Zm.add(i)):j(!1)},[i,e.isComplete]);const A=d.useCallback(async()=>{b?c?v():p():l&&(c?(S.current=!0,await w(l,!1)):await m(l))},[b,c,l,m,p,v,w]),P=()=>C?s.jsx(fr,{className:"size-4 animate-spin"}):b?s.jsx(J1,{className:"size-4"}):s.jsx(gl,{className:"size-4"}),O=()=>b?"Stop reading":C?"Generating audio...":n.textToSpeech?"Read aloud":"Text-to-speech is disabled";return!u||!n.textToSpeech||!l?null:s.jsx(xe,{variant:"ghost",size:"icon",onClick:A,disabled:C||!l,className:ze("size-8 transition-colors",b&&"bg-blue-50 hover:bg-blue-100 dark:bg-blue-950 dark:hover:bg-blue-900",t),tooltip:O(),"aria-label":b?"Stop reading aloud":"Read aloud","aria-pressed":b,"aria-busy":C,children:P()})},o1=({message:e,className:t})=>{const{addNotification:n}=Ft(),[r,o]=d.useState(!1),a=d.useRef(null),i=d.useCallback(()=>!e.parts||e.parts.length===0?"":e.parts.filter(u=>u.kind==="text").map(u=>u.text).join(""),[e.parts]),l=d.useCallback(()=>{const c=i();c.trim()?navigator.clipboard.writeText(c.trim()).then(()=>{o(!0),n("Message copied to clipboard!","success")}).catch(u=>{console.error("Failed to copy text:",u)}):n("No text content to copy","info")},[i,n]);return d.useEffect(()=>{if(r){const c=setTimeout(()=>o(!1),2e3);return()=>clearTimeout(c)}},[r]),d.useEffect(()=>{const c=u=>{u.ctrlKey&&u.shiftKey&&u.key.toLowerCase()==="c"&&(u.preventDefault(),l(),a.current&&(a.current.classList.add("bg-[var(--color-secondary-w20)]","dark:bg-[var(--color-secondary-w80)]"),setTimeout(()=>{var f;(f=a.current)==null||f.classList.remove("bg-[var(--color-secondary-w20)]","dark:bg-[var(--color-secondary-w80)]")},200)))};return document.addEventListener("keydown",c),()=>{document.removeEventListener("keydown",c)}},[l]),e.isStatusBubble||e.isStatusMessage?null:s.jsxs("div",{className:ze("flex justify-start gap-1 text-gray-500",t),children:[!e.isUser&&s.jsx(pM,{message:e}),s.jsx(xe,{ref:a,variant:"ghost",size:"icon",className:"h-8 w-8",onClick:l,tooltip:r?"Copied!":"Copy to clipboard",children:r?s.jsx(la,{className:"h-4 w-4 text-[var(--color-success-wMain)]"}):s.jsx(Og,{className:"h-4 w-4"})})]})},mM=["image","audio"],Tu=({message:e,showWorkflowButton:t,showFeedbackActions:n,handleViewWorkflowClick:r})=>{var b;const{configCollectFeedback:o,submittedFeedback:a,handleFeedbackSubmit:i,addNotification:l}=Ft(),[c,u]=d.useState(!1),[f,h]=d.useState(null),m=e.taskId,p=m?(b=a[m])==null?void 0:b.type:void 0,x=C=>{h(C),u(!0)},g=()=>{u(!1),h(null)},w=async C=>{!f||!m||(await i(m,f,C),l("Feedback submitted successfully","success"))},v=n&&o;return!t&&!v?null:s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"mt-3 space-y-2",children:s.jsxs("div",{className:"flex items-center justify-start",children:[t&&s.jsx(wv,{onClick:r}),v&&s.jsxs("div",{className:"flex items-center",children:[s.jsx(xe,{tooltip:"Like",variant:"ghost",size:"sm",className:`${p?"!opacity-100":""}`,onClick:()=>x("up"),disabled:!!p,children:s.jsx(Q1,{className:`h-4 w-4 ${p==="up"?"fill-[var(--color-brand-wMain)] text-[var(--color-brand-wMain)] !opacity-100":""}`})}),s.jsx(xe,{tooltip:"Dislike",variant:"ghost",size:"sm",className:`${p?"!opacity-100":""}`,onClick:()=>x("down"),disabled:!!p,children:s.jsx(eC,{className:`h-4 w-4 ${p==="down"?"fill-[var(--color-brand-wMain)] text-[var(--color-brand-wMain)] opacity-100":""}`})})]}),s.jsx(o1,{message:e})]})}),f&&s.jsx(tM,{isOpen:c,onClose:g,feedbackType:f,onSubmit:w})]})},gM=Rt.memo(({message:e})=>{var l,c;const[t,n]=d.useState(null),{sessionId:r}=Ft(),o=((l=e.parts)==null?void 0:l.filter(u=>u.kind==="text").map(u=>u.text).join(""))||"",a=e.isUser?o.trim():o,i=()=>{if(e.isError)return s.jsxs("div",{className:"flex items-center",children:[s.jsx(fo,{className:"mr-2 self-start text-[var(--color-error-wMain)]"}),s.jsx(Hs,{children:a})]});const u=iM(a);if(u.length===0)return s.jsx(Hs,{children:a});let f=a;const h=[];return u.forEach((m,p)=>{if(f=f.replace(m.originalMatch,""),m.type==="file"){const x={name:m.filename||"downloaded_file",content:m.content,mime_type:m.mimeType};h.push(s.jsx("div",{className:"my-2",children:s.jsx(t1,{filename:x.name,mimeType:x.mime_type,onDownload:()=>Lx(x,r),isEmbedded:!0})},`embedded-file-${p}`))}else if(!mM.includes(m.type)){const x=Rw(m.content);x&&h.push(s.jsx("div",{className:"my-2 h-auto w-md max-w-md",children:s.jsx(ph,{content:x,rendererType:m.type,mime_type:m.mimeType,setRenderError:n})},`embedded-${p}`))}}),s.jsxs("div",{children:[t&&s.jsx(Kt,{variant:"error",message:"Error rendering preview"}),s.jsx(Hs,{children:f}),h]})};return e.isUser?i():s.jsx(OP,{messageId:((c=e.metadata)==null?void 0:c.messageId)||"",isAIMessage:!0,children:i()})}),xM=Rt.memo(({message:e,children:t,className:n})=>s.jsx("div",{className:`mt-1 space-y-1 ${e.isUser?"ml-auto":"mr-auto"} ${n}`,children:t})),vM=e=>e.uploadedFiles&&e.uploadedFiles.length>0?s.jsx(xM,{message:e,className:"flex flex-wrap justify-end gap-2",children:e.uploadedFiles.map((t,n)=>{var r;return s.jsx(t1,{filename:t.name,mimeType:t.type},`uploaded-${(r=e.metadata)==null?void 0:r.messageId}-${n}`)})}):null,wM=(e,t,n)=>{var g,w,v;const{openSidePanelTab:r,setTaskIdInSidePanel:o}=t;if(e.isStatusBubble)return null;if(e.authenticationLink)return s.jsx(fM,{message:e});const a=[];let i="";if((g=e.parts)==null||g.forEach(b=>{b.kind==="text"?i+=b.text:(b.kind==="file"||b.kind==="artifact")&&(i&&(a.push({kind:"text",text:i}),i=""),a.push(b))}),i&&a.push({kind:"text",text:i}),!a.some(b=>b.kind==="text"&&b.text.trim()||b.kind==="file"||b.kind==="artifact"))return null;const c=e.isUser?"sent":"received",u=!e.isUser&&e.isComplete&&!!e.taskId&&!!n,f=!e.isUser&&e.isComplete&&!!e.taskId&&!!n,h=()=>{e.taskId&&(o(e.taskId),r("workflow"))},m=(b,C)=>{var E;const S=e.taskId?`${e.taskId}-${b.kind==="file"?b.file.name:b.name}`:(E=e.metadata)!=null&&E.messageId?`${e.metadata.messageId}-${b.kind==="file"?b.file.name:b.name}`:void 0;if(b.kind==="file"){const j=b.file,A={name:j.name||"untitled_file",mime_type:j.mimeType};return"bytes"in j&&j.bytes?A.content=j.bytes:"uri"in j&&j.uri&&(A.uri=j.uri),s.jsx(Ma,{status:"completed",name:A.name,fileAttachment:A,uniqueKey:S},`part-file-${C}`)}if(b.kind==="artifact"){const _=b;switch(_.status){case"completed":return s.jsx(Ma,{status:"completed",name:_.name,fileAttachment:_.file,uniqueKey:S},`part-artifact-${C}`);case"in-progress":return s.jsx(Ma,{status:"in-progress",name:_.name,bytesTransferred:_.bytesTransferred,uniqueKey:S},`part-artifact-${C}`);case"failed":return s.jsx(Ma,{status:"failed",name:_.name,error:_.error,uniqueKey:S},`part-artifact-${C}`);default:return null}}return null},p=a.length-1,x=(w=a[p])==null?void 0:w.kind;return s.jsxs("div",{className:"space-y-6",children:[a.map((b,C)=>{const S=C===p;if(b.kind==="text"){const E=b.text;return!E||!E.trim()?S&&(u||f)?s.jsx("div",{className:`flex ${e.isUser?"justify-end pr-4":"justify-start pl-4"}`,children:s.jsx(Tu,{message:e,showWorkflowButton:!!u,showFeedbackActions:!!f,handleViewWorkflowClick:h})},`part-${C}`):null:s.jsx(Qb,{variant:c,children:s.jsxs(ey,{variant:c,children:[s.jsx(gM,{message:{...e,parts:[{kind:"text",text:E}]}}),S&&s.jsx(Tu,{message:e,showWorkflowButton:!!u,showFeedbackActions:!!f,handleViewWorkflowClick:h})]})},`part-${C}`)}else if(b.kind==="artifact"||b.kind==="file")return m(b,C);return null}),x==="artifact"||x==="file"?s.jsx("div",{className:`flex ${e.isUser?"justify-end pr-4":"justify-start pl-4"}`,children:s.jsx(Tu,{message:e,showWorkflowButton:!!u,showFeedbackActions:!!f,handleViewWorkflowClick:h})}):null,e.isUser&&s.jsx("div",{className:"flex justify-end",children:s.jsx(o1,{message:e})})]},(v=e.metadata)==null?void 0:v.messageId)},bM=({message:e,isLastWithTaskId:t})=>{const n=Ft();return e?s.jsxs(s.Fragment,{children:[wM(e,n,t),vM(e)]}):null};var Id=new Map,Gi=new WeakMap,Gm=0,yM=void 0;function CM(e){return e?(Gi.has(e)||(Gm+=1,Gi.set(e,Gm.toString())),Gi.get(e)):"0"}function SM(e){return Object.keys(e).sort().filter(t=>e[t]!==void 0).map(t=>`${t}_${t==="root"?CM(e.root):e[t]}`).toString()}function _M(e){const t=SM(e);let n=Id.get(t);if(!n){const r=new Map;let o;const a=new IntersectionObserver(i=>{i.forEach(l=>{var c;const u=l.isIntersecting&&o.some(f=>l.intersectionRatio>=f);e.trackVisibility&&typeof l.isVisible>"u"&&(l.isVisible=u),(c=r.get(l.target))==null||c.forEach(f=>{f(u,l)})})},e);o=a.thresholds||(Array.isArray(e.threshold)?e.threshold:[e.threshold||0]),n={id:t,observer:a,elements:r},Id.set(t,n)}return n}function kM(e,t,n={},r=yM){if(typeof window.IntersectionObserver>"u"&&r!==void 0){const c=e.getBoundingClientRect();return t(r,{isIntersecting:r,target:e,intersectionRatio:typeof n.threshold=="number"?n.threshold:0,time:0,boundingClientRect:c,intersectionRect:c,rootBounds:c}),()=>{}}const{id:o,observer:a,elements:i}=_M(n),l=i.get(e)||[];return i.has(e)||i.set(e,l),l.push(t),a.observe(e),function(){l.splice(l.indexOf(t),1),l.length===0&&(i.delete(e),a.unobserve(e)),i.size===0&&(a.disconnect(),Id.delete(o))}}function EM({threshold:e,delay:t,trackVisibility:n,rootMargin:r,root:o,triggerOnce:a,skip:i,initialInView:l,fallbackInView:c,onChange:u}={}){var f;const[h,m]=d.useState(null),p=d.useRef(u),[x,g]=d.useState({inView:!!l,entry:void 0});p.current=u,d.useEffect(()=>{if(i||!h)return;let C;return C=kM(h,(S,E)=>{g({inView:S,entry:E}),p.current&&p.current(S,E),E.isIntersecting&&a&&C&&(C(),C=void 0)},{root:o,rootMargin:r,threshold:e,trackVisibility:n,delay:t},c),()=>{C&&C()}},[Array.isArray(e)?e.toString():e,h,o,r,a,i,n,c,t]);const w=(f=x.entry)==null?void 0:f.target,v=d.useRef(void 0);!h&&w&&!a&&!i&&v.current!==w&&(v.current=w,g({inView:!!l,entry:void 0}));const b=[m,x.inView,x.entry];return b.ref=b[0],b.inView=b[1],b.entry=b[2],b}const jM=({isOpen:e,onClose:t,onConfirm:n,session:r,projects:o,currentProjectId:a})=>{const[i,l]=d.useState(null),[c,u]=d.useState(!1);if(d.useEffect(()=>{e&&l("")},[e]),!e||!r)return null;const f=async()=>{u(!0);try{await n(i),t()}catch(v){console.error("Failed to move session:",v)}finally{u(!1)}},h=o.filter(v=>v.id!==a),m=()=>a?`Move "${r.name||"Untitled Session"}" to a different project or remove it from the current project.`:`Move "${r.name||"Untitled Session"}" to a project.`,p=()=>a?"No Project (Remove from current)":"No Project",x=()=>a?"Select a project":"Select a project to move to",g=c||i===""||i===null&&!a,w=()=>{c||t()};return s.jsx(On,{open:e,onOpenChange:v=>!v&&w(),children:s.jsxs(Ln,{children:[s.jsxs(Gn,{children:[s.jsx(Fn,{children:"Move Chat Session"}),s.jsx(Yn,{children:m()})]}),s.jsx("div",{className:"py-4",children:s.jsxs(Rr,{value:i===null?"none":i||"",onValueChange:v=>l(v==="none"?null:v),children:[s.jsx(Mr,{className:"w-full rounded-md",children:s.jsx(Pr,{placeholder:x()})}),s.jsxs(Dr,{children:[a&&s.jsx(jt,{value:"none",children:p()}),h.map(v=>s.jsx(jt,{value:v.id,children:s.jsx("p",{className:"max-w-sm truncate",children:v.name})},v.id))]})]})}),s.jsxs(nr,{children:[s.jsx(xe,{variant:"ghost",onClick:w,disabled:c,children:"Cancel"}),s.jsx(xe,{onClick:f,disabled:g,children:c?"Moving...":"Move"})]})]})})},NM=({onSessionSelect:e,projectId:t})=>{const{configServerUrl:n}=Ut(),[r,o]=d.useState(""),[a,i]=d.useState([]),[l,c]=d.useState(!1),[u,f]=d.useState(!1),h=NT(r,300),m=`${n}/api/v1`,p=d.useCallback(async(v,b)=>{if(!v.trim()){i([]),f(!1);return}c(!0);try{const C=new URLSearchParams({query:v.trim(),pageNumber:"1",pageSize:"20"});b&&C.append("projectId",b);const S=await pt(`${m}/sessions/search?${C.toString()}`,{credentials:"include"});if(!S.ok)throw new Error("Search failed");const E=await S.json();i(E.data||[]),f(!0)}catch(C){console.error("Search error:",C),i([])}finally{c(!1)}},[m]);d.useEffect(()=>{p(h,t)},[h,t,p]);const x=()=>{o(""),i([]),f(!1)},g=v=>{e(v),x()};return s.jsxs("div",{className:"relative w-full",children:[s.jsxs("div",{className:"relative",children:[s.jsx(Vd,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),s.jsx(br,{type:"text",placeholder:"Search chats by title",value:r,onChange:v=>o(v.target.value),className:"pl-9 pr-9"}),r&&s.jsx(xe,{variant:"ghost",size:"sm",className:"absolute right-1 top-1/2 h-7 w-7 -translate-y-1/2 p-0",onClick:x,children:s.jsx(po,{className:"h-4 w-4"})})]}),u&&s.jsx("div",{className:"absolute z-50 mt-2 w-full rounded-md border bg-popover p-2 shadow-md",children:l?s.jsx("div",{className:"p-4 text-center text-sm text-muted-foreground",children:"Searching..."}):a.length>0?s.jsx("div",{className:"max-h-[300px] overflow-y-auto",children:a.map(v=>s.jsxs("button",{onClick:()=>g(v.id),className:"w-full rounded-sm px-3 py-2 text-left text-sm hover:bg-accent hover:text-accent-foreground",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2 mb-1",children:[s.jsx("div",{className:"font-medium truncate flex-1",children:v.name||"Untitled Session"}),v.projectName&&s.jsx(zr,{variant:"outline",className:"text-xs bg-primary/10 border-primary/30 text-primary font-semibold px-2 py-0.5 shadow-sm flex-shrink-0",children:v.projectName})]}),s.jsx("div",{className:"text-xs text-muted-foreground",children:new Date(v.updatedTime).toLocaleDateString()})]},v.id))}):s.jsx("div",{className:"p-4 text-center text-sm text-muted-foreground",children:"No results found"})})]})},TM=({projects:e=[]})=>{const t=zo(),{sessionId:n,handleSwitchSession:r,updateSessionName:o,openSessionDeleteModal:a,addNotification:i,displayError:l}=Ft(),{configServerUrl:c,persistenceEnabled:u}=Ut(),f=d.useRef(null),[h,m]=d.useState([]),[p,x]=d.useState(null),[g,w]=d.useState(""),[v,b]=d.useState(1),[C,S]=d.useState(!0),[E,_]=d.useState(!1),[j,A]=d.useState("all"),[P,O]=d.useState(!1),[B,N]=d.useState(null),{ref:M,inView:y}=EM({threshold:0,triggerOnce:!1}),T=d.useCallback(async(K=1,q=!1)=>{_(!0);const ne=`${c}/api/v1/sessions?pageNumber=${K}&pageSize=20`;try{const de=await _n(ne);m(q?se=>[...se,...de.data]:de.data),S(de.meta.pagination.nextPage!==null),b(K)}catch(de){console.error("An error occurred while fetching sessions:",de)}finally{_(!1)}},[c]);d.useEffect(()=>{T(1,!1);const K=()=>{T(1,!1)},q=de=>{const{sessionId:se}=de.detail;m(me=>{const k=me.find(oe=>oe.id===se);if(k){const oe=me.filter(ie=>ie.id!==se);return[k,...oe]}return me})},ne=()=>{T(1,!1)};return window.addEventListener("new-chat-session",K),window.addEventListener("session-updated",q),window.addEventListener("background-task-completed",ne),()=>{window.removeEventListener("new-chat-session",K),window.removeEventListener("session-updated",q),window.removeEventListener("background-task-completed",ne)}},[T]),d.useEffect(()=>{if(!h.some(ne=>ne.hasRunningBackgroundTask))return;const q=setInterval(()=>{T(1,!1)},1e4);return()=>{clearInterval(q)}},[h,T]),d.useEffect(()=>{y&&C&&!E&&T(v+1,!0)},[y,C,E,v,T]),d.useEffect(()=>{p&&f.current&&f.current.focus()},[p]);const R=async K=>{p!==K&&await r(K)},z=K=>{x(K.id),w(K.name||"")},F=async()=>{if(p){const K=p,q=g;x(null),await o(K,q)}},I=K=>{a(K)},J=K=>{N(K),O(!0)},L=K=>{K.projectId&&t(`/projects/${K.projectId}`)},D=async K=>{if(B)try{await vn(`${c}/api/v1/sessions/${B.id}/project`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({projectId:K})}),m(q=>q.map(ne=>{var de;return ne.id===B.id?{...ne,projectId:K,projectName:K&&((de=e.find(se=>se.id===K))==null?void 0:de.name)||null}:ne})),typeof window<"u"&&window.dispatchEvent(new CustomEvent("session-moved",{detail:{sessionId:B.id,projectId:K}})),i==null||i("Session moved successfully","success"),O(!1),N(null)}catch(q){l({title:"Failed to Move Session",error:Yt(q,"An unknown error occurred while moving the session.")})}},W=K=>of(K),G=K=>{if(K.name&&K.name.trim())return K.name;const q=K.id;return q.startsWith("web-session-")?`Chat ${q.replace("web-session-","").substring(0,8)}`:`Session ${q.substring(0,8)}`},V=d.useMemo(()=>{const K=new Set;let q=!1;h.forEach(de=>{de.projectName?K.add(de.projectName):q=!0});const ne=Array.from(K).sort((de,se)=>de.localeCompare(se));return q&&ne.unshift("(No Project)"),ne},[h]),Q=d.useMemo(()=>j==="all"?h:j==="(No Project)"?h.filter(K=>!K.projectName):h.filter(K=>K.projectName===j),[h,j]),X=d.useMemo(()=>{if(j==="all")return null;const K=e.find(q=>q.name===j);return(K==null?void 0:K.id)||null},[j,e]);return s.jsxs("div",{className:"flex h-full flex-col gap-4 py-6 pl-6",children:[s.jsxs("div",{className:"flex flex-col gap-4",children:[s.jsx("div",{className:"pr-4",children:s.jsx(NM,{onSessionSelect:r,projectId:X})}),u&&V.length>0&&s.jsxs("div",{className:"flex items-center gap-2 pr-4",children:[s.jsx("label",{className:"text-sm font-medium",children:"Project:"}),s.jsxs(Rr,{value:j,onValueChange:A,children:[s.jsx(Mr,{className:"flex-1 rounded-md",children:s.jsx(Pr,{})}),s.jsxs(Dr,{children:[s.jsx(jt,{value:"all",children:"All Chats"}),V.map(K=>s.jsx(jt,{value:K,children:K},K))]})]})]})]}),s.jsxs("div",{className:"flex-1 overflow-y-auto",children:[Q.length>0&&s.jsx("ul",{children:Q.map(K=>s.jsx("li",{className:"group my-2 pr-4",children:s.jsxs("div",{className:`flex items-center gap-2 rounded px-2 py-2 ${K.id===n?"bg-muted":""}`,children:[p===K.id?s.jsx("input",{ref:f,type:"text",value:g,onChange:q=>w(q.target.value),onKeyDown:q=>{q.key==="Enter"&&(q.preventDefault(),F())},className:"min-w-0 flex-1 bg-transparent focus:outline-none"}):s.jsx("button",{onClick:()=>R(K.id),className:"min-w-0 flex-1 cursor-pointer text-left",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-1",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"truncate font-semibold",children:G(K)}),K.hasRunningBackgroundTask&&s.jsxs(vo,{children:[s.jsx(wo,{asChild:!0,children:s.jsx(fr,{className:"text-primary h-4 w-4 flex-shrink-0 animate-spin"})}),s.jsx(bo,{children:"Background task running"})]})]}),s.jsx("span",{className:"text-muted-foreground truncate text-xs",children:W(K.updatedTime)})]}),K.projectName&&s.jsxs(vo,{children:[s.jsx(wo,{asChild:!0,children:s.jsx(zr,{variant:"outline",className:"bg-primary/10 border-primary/30 text-primary max-w-[120px] flex-shrink-0 justify-start px-2 py-0.5 text-xs font-semibold shadow-sm",children:s.jsx("span",{className:"block truncate",children:K.projectName})})}),s.jsx(bo,{children:K.projectName})]})]})}),s.jsx("div",{className:"flex flex-shrink-0 items-center",children:p===K.id?s.jsxs(s.Fragment,{children:[s.jsx(xe,{variant:"ghost",size:"sm",onClick:F,className:"h-8 w-8 p-0",children:s.jsx(la,{size:16})}),s.jsx(xe,{variant:"ghost",size:"sm",onClick:()=>x(null),className:"h-8 w-8 p-0",children:s.jsx(po,{size:16})})]}):s.jsxs(Qs,{children:[s.jsx(ea,{asChild:!0,children:s.jsx(xe,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:q=>q.stopPropagation(),children:s.jsx(Mo,{size:16})})}),s.jsxs(ta,{align:"end",className:"w-48",children:[K.projectId&&s.jsxs(s.Fragment,{children:[s.jsxs(jn,{onClick:q=>{q.stopPropagation(),L(K)},children:[s.jsx(tC,{size:16,className:"mr-2"}),"Go to Project"]}),s.jsx(xm,{})]}),s.jsxs(jn,{onClick:q=>{q.stopPropagation(),z(K)},children:[s.jsx(ro,{size:16,className:"mr-2"}),"Rename"]}),s.jsxs(jn,{onClick:q=>{q.stopPropagation(),J(K)},children:[s.jsx(nC,{size:16,className:"mr-2"}),"Move to Project"]}),s.jsx(xm,{}),s.jsxs(jn,{onClick:q=>{q.stopPropagation(),I(K)},children:[s.jsx(rs,{size:16,className:"mr-2"}),"Delete"]})]})]})})]})},K.id))}),Q.length===0&&h.length>0&&!E&&s.jsxs("div",{className:"text-muted-foreground flex h-full flex-col items-center justify-center text-sm",children:[s.jsx(xl,{className:"mx-auto mb-4 h-12 w-12"}),"No sessions found for this project"]}),h.length===0&&!E&&s.jsxs("div",{className:"text-muted-foreground flex h-full flex-col items-center justify-center text-sm",children:[s.jsx(xl,{className:"mx-auto mb-4 h-12 w-12"}),"No chat sessions available"]}),C&&s.jsx("div",{ref:M,className:"flex justify-center py-4",children:E&&s.jsx(no,{size:"small",variant:"muted"})})]}),s.jsx(jM,{isOpen:P,onClose:()=>{O(!1),N(null)},onConfirm:D,session:B,projects:e,currentProjectId:B==null?void 0:B.projectId})]})},AM=()=>{const{persistenceEnabled:e}=Ut(),{sessionName:t}=Ft(),{projects:n}=ko();return e?s.jsx(TM,{projects:n}):s.jsx("div",{className:"flex h-full flex-col",children:s.jsxs("div",{className:"flex-1 overflow-y-auto px-4",children:[s.jsxs("div",{className:"bg-accent/50 hover:bg-accent mb-3 cursor-pointer rounded-md p-3",children:[s.jsx("div",{className:"text-foreground truncate text-sm font-medium text-nowrap",children:t||"New Chat"}),s.jsx("div",{className:"text-muted-foreground mt-1 text-xs",children:"Current session"})]}),s.jsx("div",{className:"text-muted-foreground mt-4 text-center text-xs",children:"Persistence is not enabled."})]})})},IM=({artifact:e,isPreview:t})=>{const{setPreviewArtifact:n}=Ft(),r={name:e.filename,mime_type:e.mime_type,size:e.size,uri:e.uri},o=a=>{t||(a.stopPropagation(),n(e))};return s.jsx("div",{className:`${t?"":"cursor-pointer transition-all duration-150 hover:bg-[var(--accent-background)]"}`,onClick:o,children:s.jsx(Ma,{status:"completed",name:e.filename,fileAttachment:r,context:"list"})})},RM=()=>{const{isDeleteModalOpen:e,artifactToDelete:t,closeDeleteModal:n,confirmDelete:r}=Ft();return t?s.jsx(Vo,{open:e,onOpenChange:o=>!o&&n(),title:"Delete File",content:t.source==="project"?`This action will remove the file, "${t.filename}", from this chat session. This file will remain in the project.`:s.jsxs(s.Fragment,{children:["This action cannot be undone. This file will be permanently deleted: ",s.jsx("strong",{children:t.filename}),"."]}),actionLabels:{confirm:"Delete"},onConfirm:r,onCancel:n}):null},PM=({artifact:e,message:t})=>{const{onDownload:n}=Wf();return s.jsxs("div",{className:"flex h-full w-full flex-col items-center justify-center gap-2 p-4",children:[s.jsx("div",{className:"mb-1 font-semibold",children:"Preview Unavailable"}),s.jsx("div",{children:t}),s.jsxs(xe,{onClick:()=>n(e),children:[s.jsx(Co,{className:"h-4 w-4"}),"Download"]})]})},Au=({children:e})=>s.jsx("div",{className:"text-muted-foreground flex h-[50vh] items-center justify-center",children:e||"No preview available"}),MM=({artifact:e})=>{const{openArtifactForPreview:t,previewFileContent:n,markArtifactAsDisplayed:r,downloadAndResolveArtifact:o}=Ft(),a=d.useMemo(()=>xT(e),[e]),[i,l]=d.useState(!1),[c,u]=d.useState(null),[f,h]=d.useState(null),[m,p]=d.useState(!1),x=d.useRef(!1),g=d.useRef(null),w=d.useRef(!1);if(d.useEffect(()=>(r(e.filename,!0),()=>{r(e.filename,!1)}),[e.filename,r]),d.useEffect(()=>{l(!1),u(null),h(null),x.current=!1,g.current=null},[e.filename]),d.useEffect(()=>{if(e.accumulatedContent){const E={name:e.filename,mime_type:e.mime_type,content:e.accumulatedContent,last_modified:e.last_modified,isPlainText:e.isAccumulatedContentPlainText};h(E)}},[e.accumulatedContent,e.filename,e.mime_type,e.last_modified,e.isAccumulatedContentPlainText]),d.useEffect(()=>{async function E(){if(!(x.current&&g.current===e.filename)){x.current=!0,g.current=e.filename;try{l(!0),u(null),e.accumulatedContent?l(!1):await t(e.filename)}catch(_){console.error("Error fetching artifact content:",_),u(_ instanceof Error?_.message:"Failed to load artifact content")}finally{l(!1)}}}a!=null&&a.canPreview&&E()},[e.filename,t,a,e.accumulatedContent]),d.useEffect(()=>{async function E(){if(e.needsEmbedResolution&&!m&&!w.current){w.current=!0,p(!0);try{const _=await o(e.filename);_&&h({..._,isPlainText:!1})}catch(_){console.error(`[ArtifactPreviewContent] Error downloading ${e.filename}:`,_)}finally{p(!1),w.current=!1}}}E()},[e.needsEmbedResolution,e.filename,o,m]),c)return s.jsxs("div",{className:"flex h-full w-full flex-col",children:[s.jsx(Kt,{variant:"error",message:"Error rendering preview"}),s.jsx(Au,{children:"No preview available"})]});if(i)return s.jsx(Au,{children:s.jsx(fr,{className:"text-muted-foreground h-6 w-6 animate-spin"})});if(!a.canPreview)return s.jsx(PM,{artifact:e,message:a.reason??""});const v=f||n,b=(v==null?void 0:v.mime_type)||e.mime_type,C=Ir(e.filename,b),S=Mw(v);return!C||!S?s.jsx(Au,{children:"No preview available"}):s.jsxs("div",{className:"relative h-full w-full",children:[s.jsx(ph,{content:S,rendererType:C,mime_type:v==null?void 0:v.mime_type,setRenderError:u}),s.jsx(e1,{isVisible:m,message:"Resolving embeds..."})]})},Xr={NameAsc:"name_asc",NameDesc:"name_desc",DateAsc:"date_asc",DateDesc:"date_desc"},DM=e=>{switch(e){case Xr.NameAsc:return"Name (A-Z)";case Xr.NameDesc:return"Name (Z-A)";case Xr.DateAsc:return"Date (oldest first)";case Xr.DateDesc:return"Date (newest first)"}},OM=({currentSortOption:e,onSortChange:t,children:n})=>{const r=Object.values(Xr).map(o=>({id:o,label:DM(o),onClick:()=>t(o),icon:e===o?s.jsx(la,{}):void 0,iconPosition:"right"}));return s.jsxs(bc,{children:[s.jsx(yc,{asChild:!0,children:n}),s.jsx(Cc,{align:"end",side:"bottom",className:"w-auto",sideOffset:0,children:s.jsx(hi,{actions:r})})]})},LM=({children:e,hideDeleteAll:t=!1})=>{const{artifactsRefetch:n,setIsBatchDeleteModalOpen:r}=Ft(),o=[{id:"refreshAll",label:"Refresh",onClick:()=>{n()},icon:s.jsx(Gl,{}),iconPosition:"left"}];return t||o.push({id:"deleteAll",label:"Delete All",onClick:()=>{r(!0)},icon:s.jsx(Hl,{}),iconPosition:"left",divider:!0}),s.jsxs(bc,{children:[s.jsx(yc,{asChild:!0,children:e}),s.jsx(Cc,{align:"end",side:"bottom",className:"w-auto",sideOffset:0,children:s.jsx(hi,{actions:o})})]})},FM=()=>{const{artifacts:e,isBatchDeleteModalOpen:t,setIsBatchDeleteModalOpen:n,confirmBatchDeleteArtifacts:r,setSelectedArtifactFilenames:o}=Ft();if(d.useEffect(()=>{t&&o(new Set(e.map(u=>u.filename)))},[e,t,o]),!t)return null;const a=e.some(u=>u.source==="project"),i=e.filter(u=>u.source==="project").length,l=e.length-i,c=()=>a&&l===0?`${e.length===1?"This file":`All ${e.length} files`} will be removed from this chat session. ${e.length===1?"The file":"These files"} will remain in ${e.length===1?"the":"their"} project${e.length===1?"":"s"}.`:a&&l>0?`${l} ${l===1?"file":"files"} will be permanently deleted. ${i} project ${i===1?"file":"files"} will be removed from this chat but will remain in ${i===1?"the":"their"} project${i===1?"":"s"}.`:`${e.length===1?"One file":`All ${e.length} files`} will be permanently deleted.`;return s.jsx(Vo,{title:"Delete All?",description:c(),actionLabels:{confirm:"Delete"},onCancel:()=>n(!1),onConfirm:r,open:t,onOpenChange:n})},$M=({artifactInfo:e,isPreview:t=!1,isExpanded:n=!1,onDelete:r,onDownload:o,setIsExpanded:a,badge:i})=>{const{previewedArtifactAvailableVersions:l,currentPreviewedVersionNumber:c,navigateArtifactVersion:u}=Ft(),f=d.useMemo(()=>l??[],[l]);return s.jsxs("div",{className:"flex flex-row justify-between gap-1",children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-4",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:"truncate text-sm",title:e.filename,children:e.filename}),i&&i.badgeComponent]}),s.jsx("div",{className:"truncate text-xs",title:Ys(e.last_modified),children:Ys(e.last_modified)})]}),t&&f.length>1&&s.jsx("div",{className:"align-right",children:s.jsxs(Rr,{value:c==null?void 0:c.toString(),onValueChange:h=>{u(e.filename,parseInt(h))},children:[s.jsx(Mr,{className:"h-[16px] py-0 text-xs shadow-none",children:s.jsx(Pr,{placeholder:"Version"})}),s.jsx(Dr,{children:f.map(h=>s.jsxs(jt,{value:h.toString(),children:["Version ",h]},h))})]})})]}),s.jsxs("div",{className:`whitespace-nowrap ${t?"opacity-100":"opacity-0 transition-opacity duration-150 group-focus-within:opacity-100 group-hover:opacity-100"}`,children:[a&&s.jsx(xe,{variant:"ghost",size:"sm",onClick:h=>{h.stopPropagation(),h.preventDefault(),a(!n)},tooltip:n?"Collapse Details":"Expand Details",children:s.jsx(ti,{})}),o&&s.jsx(xe,{variant:"ghost",size:"sm",onClick:async h=>{h.stopPropagation(),h.preventDefault(),await o(e)},tooltip:"Download",children:s.jsx(Co,{})}),r&&s.jsx(xe,{variant:"ghost",size:"sm",onClick:h=>{h.preventDefault(),h.stopPropagation(),r()},tooltip:"Delete",children:s.jsx(Hl,{})})]})]})},zM={[Xr.NameAsc]:(e,t)=>e.filename.localeCompare(t.filename),[Xr.NameDesc]:(e,t)=>t.filename.localeCompare(e.filename),[Xr.DateAsc]:(e,t)=>e.last_modified>t.last_modified?1:-1,[Xr.DateDesc]:(e,t)=>e.last_modified<t.last_modified?1:-1},UM=()=>{const{artifacts:e,artifactsLoading:t,previewArtifact:n,setPreviewArtifact:r,artifactsRefetch:o,openDeleteModal:a}=Ft(),{onDownload:i}=Wf(),[l,c]=d.useState(Xr.DateDesc),[u,f]=d.useState(!1),h=d.useMemo(()=>t?[]:e?[...e].sort(zM[l]):[],[e,t,l]),m=d.useMemo(()=>h.some(x=>x.source!=="project"),[h]),p=d.useMemo(()=>n?s.jsxs("div",{className:"flex items-center gap-2 border-b p-2",children:[s.jsx(xe,{variant:"ghost",onClick:()=>r(null),children:s.jsx(rC,{})}),s.jsx("div",{className:"text-md font-semibold",children:"Preview"})]}):h.length>0&&s.jsxs("div",{className:"flex items-center justify-end border-b p-2",children:[s.jsx(OM,{currentSortOption:l,onSortChange:c,children:s.jsxs(xe,{variant:"ghost",title:"Sort By",children:[s.jsx(Mg,{className:"h-5 w-5"}),s.jsx("div",{children:"Sort By"})]})},"sort-popover"),s.jsx(LM,{hideDeleteAll:!m,children:s.jsx(xe,{variant:"ghost",tooltip:"More",children:s.jsx(Mo,{className:"h-5 w-5"})})},"more-popover")]}),[n,h.length,l,r,m]);return s.jsxs("div",{className:"flex h-full flex-col",children:[p,s.jsxs("div",{className:"flex min-h-0 flex-1",children:[!n&&s.jsxs("div",{className:"flex-1 overflow-y-auto",children:[h.map(x=>s.jsx(IM,{artifact:x},x.filename)),h.length===0&&s.jsx("div",{className:"flex h-full items-center justify-center p-4",children:s.jsxs("div",{className:"text-muted-foreground text-center",children:[t&&s.jsx(fr,{className:"size-6 animate-spin"}),!t&&s.jsxs(s.Fragment,{children:[s.jsx(wr,{className:"mx-auto mb-4 h-12 w-12"}),s.jsx("div",{className:"text-lg font-medium",children:"Files"}),s.jsx("div",{className:"mt-2 text-sm",children:"No files available"}),s.jsx(xe,{className:"mt-4",variant:"default",onClick:o,"data-testid":"refreshFiles",title:"Refresh Files",children:"Refresh"})]})]})})]}),n&&s.jsxs("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col gap-2",children:[s.jsx("div",{className:"border-b px-4 py-3",children:s.jsx($M,{artifactInfo:n,isPreview:!0,isExpanded:u,setIsExpanded:f,onDelete:n.source==="project"?void 0:()=>a(n),onDownload:()=>i(n)})}),u&&s.jsx("div",{className:"border-b px-4 py-3",children:s.jsxs("div",{className:"space-y-2 text-sm",children:[n.description&&s.jsxs("div",{children:[s.jsx("span",{className:"text-secondary-foreground",children:"Description:"}),s.jsx("div",{className:"mt-1",children:n.description})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[s.jsxs("div",{children:[s.jsx("span",{className:"text-secondary-foreground",children:"Size:"}),s.jsx("div",{children:si(n.size)})]}),s.jsxs("div",{children:[s.jsx("span",{className:"text-secondary-foreground",children:"Type:"}),s.jsx("div",{children:n.mime_type||"Unknown"})]})]})]})}),s.jsx("div",{className:"min-h-0 min-w-0 flex-1 overflow-y-auto",children:s.jsx(MM,{artifact:n})})]})]}),s.jsx(RM,{}),s.jsx(FM,{})]})},BM=({onCollapsedToggle:e,isSidePanelCollapsed:t,setIsSidePanelCollapsed:n,isSidePanelTransitioning:r})=>{const{activeSidePanelTab:o,setActiveSidePanelTab:a,setPreviewArtifact:i,taskIdInSidePanel:l}=Ft(),{isReconnecting:c,isTaskMonitorConnecting:u,isTaskMonitorConnected:f,monitoredTasks:h,connectTaskMonitorStream:m,loadTaskFromBackend:p}=Hf(),[x,g]=d.useState(null),[w,v]=d.useState(!1),b=Rt.useRef(new Set);d.useEffect(()=>{if(!l){g(null);return}const j=h[l];if(!b.current.has(l))b.current.add(l),v(!0),p(l).then(A=>{if(!A)if(j&&j.events&&j.events.length>0){const P=Iu(j.events,h,j);g(P)}else g(null)}).catch(()=>{if(j&&j.events&&j.events.length>0){const A=Iu(j.events,h,j);g(A)}else g(null)}).finally(()=>{v(!1)});else if(j&&j.events&&j.events.length>0){const A=Iu(j.events,h,j);g(A),v(!1)}else g(null)},[l,h,p]),d.useEffect(()=>{if(l)return()=>{setTimeout(()=>{b.current.delete(l)},1e3)}},[l]);const C=()=>w?{message:"Loading workflow data...",showButton:!1}:c||u?{message:"Connecting to task monitor ...",showButton:!1}:f?l?x?null:{message:"No workflow data available for the selected task",showButton:!1}:{message:"No task selected to display",showButton:!1}:{message:"No connection to task monitor",showButton:!0,buttonText:"Reconnect",buttonIcon:oC,buttonAction:m},S=()=>{const j=!t;n(j),e(j)},E=j=>{j==="files"&&i(null),a(j)},_=j=>{t&&(n(!1),e==null||e(!1)),E(j)};return t?s.jsxs("div",{className:"bg-background flex h-full w-full flex-col items-center border-l py-4",children:[s.jsx(xe,{"data-testid":"expandPanel",variant:"ghost",size:"sm",onClick:S,className:"h-10 w-10 p-0",tooltip:"Expand Panel",children:s.jsx($h,{className:"size-5"})}),s.jsx("div",{className:"bg-border my-4 h-px w-8"}),s.jsx(xe,{variant:"ghost",size:"sm",onClick:()=>_("files"),className:"mb-2 h-10 w-10 p-0",tooltip:"Files",children:s.jsx(wr,{className:"size-5"})}),s.jsx(xe,{variant:"ghost",size:"sm",onClick:()=>_("workflow"),className:"h-10 w-10 p-0",tooltip:"Workflow",children:s.jsx(ol,{className:"size-5"})})]}):s.jsx("div",{className:"bg-background flex h-full flex-col border-l",children:s.jsx("div",{className:"m-1 min-h-0 flex-1",children:s.jsxs(NI,{value:o,onValueChange:j=>E(j),className:"flex h-full flex-col",children:[s.jsxs("div",{className:"flex gap-2 p-2",children:[s.jsx(xe,{"data-testid":"collapsePanel",variant:"ghost",onClick:S,className:"p-1",tooltip:"Collapse Panel",children:s.jsx($h,{className:"size-5"})}),s.jsxs(TI,{className:"grid w-full grid-cols-2 bg-transparent p-0",children:[s.jsxs(dm,{value:"files",title:"Files",className:"border-border bg-muted data-[state=active]:bg-background relative cursor-pointer rounded-none rounded-l-md border border-r-0 data-[state=active]:z-10 data-[state=active]:border-r-0",onClick:()=>i(null),children:[s.jsx(wr,{className:"mr-2 h-4 w-4"}),"Files"]}),s.jsxs(dm,{value:"workflow",title:"Workflow",className:"border-border bg-muted data-[state=active]:bg-background relative cursor-pointer rounded-none rounded-r-md border border-l-0 data-[state=active]:z-10 data-[state=active]:border-l-0",children:[s.jsx(ol,{className:"mr-2 h-4 w-4"}),"Workflow"]})]})]}),s.jsxs("div",{className:"min-h-0 flex-1",children:[s.jsx(fm,{value:"files",className:"m-0 h-full",children:s.jsx("div",{className:"h-full",children:s.jsx(UM,{})})}),s.jsx(fm,{value:"workflow",className:"m-0 h-full",children:s.jsx("div",{className:"h-full",children:(()=>{const j=C();return!j&&x?s.jsxs("div",{className:"flex h-full flex-col",children:[s.jsx(HM,{task:x}),s.jsx(CD,{processedSteps:x.steps||[],isRightPanelVisible:!1,isSidePanelTransitioning:r})]}):s.jsx("div",{className:"flex h-full items-center justify-center p-4",children:s.jsxs("div",{className:"text-muted-foreground text-center",children:[s.jsx(ol,{className:"mx-auto mb-4 h-12 w-12"}),s.jsx("div",{className:"text-lg font-medium",children:"Workflow"}),s.jsx("div",{className:"mt-2 text-sm",children:j==null?void 0:j.message}),(j==null?void 0:j.showButton)&&s.jsx("div",{className:"mt-4",children:s.jsxs(xe,{onClick:j.buttonAction,children:[j.buttonIcon&&(()=>{const A=j.buttonIcon;return s.jsx(A,{className:"h-4 w-4"})})(),j.buttonText]})})]})})})()})})]})]})})})},Rd=Rt.memo(({statusText:e,onViewWorkflow:t})=>s.jsxs("div",{className:"flex h-8 items-center space-x-3 py-1",children:[t?s.jsx(wv,{onClick:t}):s.jsx(SP,{className:"mr-3 ml-2"}),s.jsx("div",{className:"flex min-w-0 flex-1 items-center gap-1",children:e&&s.jsx("span",{className:"text-muted-foreground animate-pulse truncate text-sm",title:e,children:e})})]})),Ym=({text:e,onClick:t})=>s.jsxs(xe,{"data-testid":"startNewChat",variant:"ghost",onClick:t,tooltip:"Start New Chat Session",children:[s.jsx(Bg,{className:"size-5"}),e]}),s1=({buttonText:e})=>{const{handleNewSession:t}=Ft(),{persistenceEnabled:n}=Ut(),[r,o]=d.useState(!1);return n?s.jsx(Ym,{text:e,onClick:()=>t()}):s.jsx(Vo,{open:r,onOpenChange:o,title:"Start New Chat Session",description:"Starting a new chat session will clear the current chat history and files. Are you sure you want to proceed?",actionLabels:{confirm:"Start New Chat"},onConfirm:t,trigger:s.jsx(Ym,{text:e})})},VM=({onToggle:e})=>s.jsxs("div",{className:"bg-background flex h-full w-100 flex-col border-r",children:[s.jsxs("div",{className:"flex h-20 justify-between border-b px-2 pt-[35px]",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(xe,{variant:"ghost",onClick:e,"data-testid":"hideChatSessions",tooltip:"Hide Chat Sessions",children:s.jsx(Vg,{className:"size-5"})}),s.jsx("div",{className:"text-xl",children:"Chats"})]}),s.jsx("div",{className:"flex items-center",children:s.jsx(s1,{buttonText:"New Chat"})})]}),s.jsx("div",{className:"mt-1 min-h-0 flex-1",children:s.jsx(AM,{})})]}),Ea=(e,t)=>s.jsx(zr,{type:t,className:"rounded-full border-none",children:s.jsx("span",{className:"text-xs font-semibold",title:e,children:e})}),WM=(e,t)=>{var r;if(e.currentStatusText)return s.jsx("div",{title:e.currentStatusText,children:s.jsx(Rd,{statusText:e.currentStatusText})});const n=(r=t==null?void 0:t.parts)==null?void 0:r.filter(o=>o.kind==="text").map(o=>o.text).join("");switch(e.status){case"submitted":case"working":return s.jsx("div",{title:n||e.status,children:s.jsx(Rd,{statusText:n||e.status})});case"input-required":return Ea("Input Required","info");case"completed":return Ea("Completed","success");case"canceled":return Ea("Canceled","info");case"failed":return Ea("Failed","error");default:return Ea("Unknown","info")}},HM=({task:e})=>{const{messages:t,addNotification:n,displayError:r}=Ft(),{configServerUrl:o,configFeatureEnablement:a}=Ut(),i=d.useMemo(()=>`${o}/api/v1`,[o]),l=(a==null?void 0:a.taskLogging)??!1,c=d.useMemo(()=>{const f=t.find(h=>h.isStatusBubble);return e?WM(e,f):null},[t,e]),u=async()=>{try{const h=await(await vn(`${i}/tasks/${e.taskId}`)).blob();oi(h,`${e.taskId}.stim`),n("Task log downloaded","success")}catch(f){r({title:"Failed to Download Task Log",error:Yt(f,"An unknown error occurred while downloading the task log.")})}};return e?s.jsxs("div",{className:"grid grid-cols-[auto_1fr_auto] grid-rows-[32px_32px] items-center gap-x-8 border-b p-4",children:[s.jsx("div",{className:"text-muted-foreground",children:"User"}),s.jsx("div",{className:"truncate",title:e.initialRequestText,children:e.initialRequestText}),s.jsx("div",{}),s.jsx("div",{className:"text-muted-foreground",children:"Status"}),s.jsx("div",{className:"truncate",children:c}),s.jsx("div",{children:l&&s.jsx(xe,{variant:"ghost",size:"icon",onClick:u,tooltip:"Download Task Log (.stim)",disabled:!e.taskId,children:s.jsx(Co,{})})})]}):null};class a1{getEdgeAnimationState(t,n,r){const o=r.find(l=>l.id===t);if(!o)return{isAnimated:!1,animationType:"static"};if(!this.isAgentToToolRequest(o))return{isAnimated:!1,animationType:"static"};const a=r.slice(0,n+1);return this.hasMatchingResponse(o,a)?{isAnimated:!1,animationType:"static"}:{isAnimated:!0,animationType:"request"}}isAgentToToolRequest(t){var n,r;switch(t.type){case"AGENT_LLM_CALL":return!0;case"AGENT_TOOL_INVOCATION_START":return!(((n=t.data.toolDecision)==null?void 0:n.isPeerDelegation)||((r=t.data.toolInvocationStart)==null?void 0:r.isPeerInvocation)||t.target&&t.target.startsWith("peer_"));default:return!1}}hasMatchingResponse(t,n){switch(t.type){case"AGENT_LLM_CALL":return this.hasLLMResponse(t,n);case"AGENT_TOOL_INVOCATION_START":return this.hasToolResponse(t,n);default:return!1}}hasLLMResponse(t,n){const r=new Date(t.timestamp).getTime(),o=t.source;return n.some(a=>{var f;if(new Date(a.timestamp).getTime()<r)return!1;const l=(a.type==="AGENT_LLM_RESPONSE_TOOL_DECISION"||a.type==="AGENT_LLM_RESPONSE_TO_AGENT")&&a.target===o,c=a.source===o&&(a.type==="AGENT_TOOL_INVOCATION_START"||a.type==="TASK_COMPLETED"),u=a.type==="AGENT_TOOL_EXECUTION_RESULT"&&((f=a.data.toolResult)==null?void 0:f.isPeerResponse);return l||c||u})}hasToolResponse(t,n){const r=new Date(t.timestamp).getTime(),o=t.target,a=t.source;return n.some(i=>new Date(i.timestamp).getTime()<r?!1:i.type==="AGENT_TOOL_EXECUTION_RESULT"&&i.source===o&&i.target===a)}isRequestStep(t){return this.isAgentToToolRequest(t)}isResponseStep(t){return["AGENT_TOOL_EXECUTION_RESULT","AGENT_LLM_RESPONSE_TOOL_DECISION","AGENT_LLM_RESPONSE_TO_AGENT"].includes(t.type)}}function i1(e,t){return(t==null?void 0:t[e])||e}const ho={USER:50,MAIN_FLOW:300,TOOLS:600},ZM=50,Nn=50,Cr=330,cs=50,Yr=20,ra=10,Km=Nn+20,GM=90;function us(e,t,n){return e.push(n),t.add(n.id),n}function YM(e,t){return e.push(t),t}function ds(e,t){return e.nodeIdCounter++,`${t.replace(/[^a-zA-Z0-9_]/g,"_")}_${e.nodeIdCounter}`}function qn(e){return e.currentPhaseIndex===-1||e.currentPhaseIndex>=e.phases.length?null:e.phases[e.currentPhaseIndex]}function bi(e){const t=qn(e);return!t||e.currentSubflowIndex===-1||e.currentSubflowIndex>=t.subflows.length?null:t.subflows[e.currentSubflowIndex]}function KM(e,t,n){var r;for(let o=e.length-1;o>=0;o--){const a=e[o],i=n.find(l=>l.id===a.id);if(((r=i==null?void 0:i.data)==null?void 0:r.toolName)===t)return a}return null}function qM(e,t){if(!t)return null;const n=qn(e);return n&&n.subflows.findLast(r=>r.functionCallId===t)||null}function XM(e,t){if(!t)return null;const n=qn(e);return n&&n.subflows.findLast(r=>r.id===t)||null}function Pc(e,t){var o;const n=qn(e);if(!n)return null;if(t.functionCallId){const a=qM(e,t.functionCallId);if(a)return a}if(t.owningTaskId&&t.isSubTaskStep){const a=XM(e,t.owningTaskId);if(a){const i=n.subflows||[];if(!(new Set(i.map(c=>c.id)).size!==i.length))return a}}const r=bi(e);if(r&&t.source){const a=t.source.replace(/[^a-zA-Z0-9_]/g,"_"),i=(o=t.target)==null?void 0:o.replace(/[^a-zA-Z0-9_]/g,"_"),l=r.peerAgent.id;if(l.includes(a)||i&&l.includes(i))return r}return r||null}function l1(e,t){var r,o,a;if(((r=e.data.toolDecision)==null?void 0:r.isParallel)===!0)return!0;const n=(a=(o=e.data)==null?void 0:o.toolInvocationStart)==null?void 0:a.functionCallId;return n?Array.from(t.parallelFlows.values()).some(i=>i.subflowFunctionCallIds.includes(n)):!1}function c1(e,t,n,r){var o;if(r)for(let a=e.length-1;a>=0;a--){const i=e[a];if(i.functionCallId===r){const l=n.find(c=>c.id===i.id);if(((o=l==null?void 0:l.data)==null?void 0:o.toolName)===t||t==="LLM")return i}}return KM(e,t,n)}function JM(e,t,n){const r=qn(e);if(!r)return null;const o=t.replace(/[^a-zA-Z0-9_]/g,"_"),a=n==null?void 0:n.replace(/[^a-zA-Z0-9_]/g,"_");let i=null;for(const l of r.subflows)if(l.peerAgent.id.includes(o)||a&&l.peerAgent.id.includes(a)){i=l;break}if(!i)return null;if(i.isParallel)return i;if(i.parentSubflowId){const l=r.subflows.find(c=>c.id===i.parentSubflowId);if(l&&l.isParallel)return l;if(l)return u1(r,l)}return null}function u1(e,t){if(t.isParallel)return t;if(t.parentSubflowId){const n=e.subflows.find(r=>r.id===t.parentSubflowId);if(n)return u1(e,n)}return null}function oa(e,t,n,r){const o=`phase_${e.phases.length}`,a=ds(e,`${t}_${o}`),i=e.nextAvailableGlobalY,l=i1(t,e.agentNameMap),c={id:a,type:"orchestratorNode",position:{x:ho.MAIN_FLOW,y:i},data:{label:l,visualizerStepId:n.id}};us(r,e.allCreatedNodeIds,c),e.nodePositions.set(a,c.position);const u={id:a,yPosition:i,height:Nn,width:Cr},f={id:a,name:t,type:"orchestrator",phaseId:o,context:"main",nodeInstance:u};e.agentRegistry.registerAgent(f);const h={id:o,orchestratorAgent:u,userNodes:[],subflows:[],toolInstances:[],currentToolYOffset:0,maxY:i+Nn};return e.phases.push(h),e.currentPhaseIndex=e.phases.length-1,e.currentSubflowIndex=-1,e.nextAvailableGlobalY=h.maxY+cs,h}function Pd(e,t,n,r,o){var O,B,N,M,y;const a=qn(e);if(!a)return null;const i=n.type==="AGENT_TOOL_EXECUTION_RESULT"&&((O=n.data.toolResult)==null?void 0:O.isPeerResponse)===!0,l=n.source||"",c=n.target||"",u=sa(l);!i&&!u&&!o&&e.indentationLevel++;const f=((N=(B=n.delegationInfo)==null?void 0:B[0])==null?void 0:N.subTaskId)||n.owningTaskId,h=ds(e,`${t}_${f}`),m=ds(e,`group_${t}_${f}`),p=((y=(M=n.data)==null?void 0:M.toolInvocationStart)==null?void 0:y.functionCallId)||n.functionCallId||"";let x,g,w;const v=Array.from(e.parallelFlows.values()).find(T=>T.subflowFunctionCallIds.includes(p)),b=bi(e),C=JM(e,l,c);o&&v?(x=v.startX+v.currentXOffset,g=v.startY,w=g+Yr,v.currentXOffset+=(Cr+ra)*2.2):C?(w=e.nextAvailableGlobalY,x=(C.groupNode.xPosition||ho.MAIN_FLOW-50)+e.indentationLevel*e.indentationStep,g=w-Yr):(w=e.nextAvailableGlobalY,x=ho.MAIN_FLOW-50+e.indentationLevel*e.indentationStep,g=w-Yr);const S=i1(t,e.agentNameMap),E={id:h,type:"genericAgentNode",position:{x:50,y:Yr},data:{label:S,visualizerStepId:n.id},parentId:m},_={id:m,type:"group",position:{x,y:g},data:{label:`${S} Sub-flow`},style:{backgroundColor:"rgba(220, 220, 255, 0.1)",border:"1px solid #aac",borderRadius:"8px",minHeight:`${Nn+2*Yr}px`}};us(r,e.allCreatedNodeIds,_),us(r,e.allCreatedNodeIds,E),e.nodePositions.set(h,E.position),e.nodePositions.set(m,_.position);const j={id:h,xPosition:ho.MAIN_FLOW,yPosition:w,height:Nn,width:Cr},A={id:h,name:t,type:"peer",phaseId:a.id,subflowId:f,context:"subflow",nodeInstance:j};e.agentRegistry.registerAgent(A);const P={id:f,functionCallId:p,isParallel:o,peerAgent:j,groupNode:{id:m,xPosition:x,yPosition:g,height:Nn+2*Yr,width:0},toolInstances:[],currentToolYOffset:0,maxY:w+Nn,maxContentXRelative:E.position.x+Cr,callingPhaseId:a.id,parentSubflowId:b==null?void 0:b.id,inheritedXOffset:C==null?void 0:C.groupNode.xPosition};return a.subflows.push(P),C&&(C.lastSubflow=P),e.currentSubflowIndex=a.subflows.length-1,o&&v?(v.maxHeight=Math.max(v.maxHeight,P.groupNode.height),e.nextAvailableGlobalY=v.startY+v.maxHeight+cs):e.nextAvailableGlobalY=P.groupNode.yPosition+P.groupNode.height+cs,P}function d1(e,t,n,r,o,a,i=!1){const l=qn(e);if(!l)return null;const c=a?a.toolInstances:l.toolInstances,u=i?"LLM":`Tool: ${t}`,f=i?"LLM":t,h=a?a.groupNode.id:void 0;let m,p,x,g;if(a){if(m=a.peerAgent.yPosition+a.currentToolYOffset,a.currentToolYOffset+=Km,x=50+300,a.groupNode.xPosition===void 0||a.groupNode.yPosition===void 0)return null;p=a.groupNode.xPosition+x,g=m-a.groupNode.yPosition}else p=ho.TOOLS,m=l.orchestratorAgent.yPosition+l.currentToolYOffset,l.currentToolYOffset+=Km,x=p,g=m;const w=ds(e,`${f}_${r.id}`),v={id:w,type:n,position:{x,y:g},data:{label:u,visualizerStepId:r.id,toolName:t},parentId:h};us(o,e.allCreatedNodeIds,v),e.nodePositions.set(w,{x,y:g});const b={id:w,xPosition:p,yPosition:m,height:Nn,width:Cr,functionCallId:r.functionCallId};c.push(b);const C=m+Nn;if(a){a.maxY=Math.max(a.maxY,C),a.maxContentXRelative=Math.max(a.maxContentXRelative,x+Cr);const S=a.maxY-a.groupNode.yPosition+Yr;a.groupNode.height=Math.max(a.groupNode.height,S);const E=a.maxContentXRelative+ra;a.groupNode.width=Math.max(a.groupNode.width||0,E);const _=o.find(j=>j.id===a.groupNode.id);_&&(_.style={..._.style,height:`${a.groupNode.height}px`,width:`${a.groupNode.width}px`}),e.nextAvailableGlobalY=Math.max(e.nextAvailableGlobalY,a.groupNode.yPosition+a.groupNode.height+cs)}else l.maxY=Math.max(l.maxY,C),e.nextAvailableGlobalY=Math.max(e.nextAvailableGlobalY,l.maxY+cs);return b}function gh(e,t,n,r){e.userNodeCounter++;const o=ds(e,`User_response_${e.userNodeCounter}`),a=e.nextAvailableGlobalY+20,i={id:o,type:"userNode",position:{x:ho.USER,y:a},data:{label:"User",visualizerStepId:n.id,isBottomNode:!0}};us(r,e.allCreatedNodeIds,i),e.nodePositions.set(o,i.position);const l={id:o,yPosition:a,height:Nn,width:Cr};t.userNodes.push(l),e.allUserNodes.push(l);const c=a+Nn;return t.maxY=Math.max(t.maxY,c),l}function dr(e,t,n,r,o,a,i,l,c){if(!e||!t||e===t)return;const u=o.allCreatedNodeIds.has(e),f=o.allCreatedNodeIds.has(t);if(!u||!f)return;const h=`edge-${e}${l||""}-to-${t}${c||""}-${n.id}`;if(!r.some(p=>p.id===h)){const p=n.title&&n.title.length>30?n.type.replace(/_/g," ").toLowerCase():n.title||"",x=a.isRequestStep(n),g={id:h,source:e,target:t,label:p,type:"defaultFlowEdge",data:{visualizerStepId:n.id,isAnimated:x,animationType:x?"request":"static",duration:1}};l&&(g.sourceHandle=l),c&&(g.targetHandle=c),YM(r,g)}}function QM(){const e=new Map;return{agents:e,findAgentByName(t){const n=t.startsWith("peer_")?t.substring(5):t,r=[];for(const[,o]of e)(o.name===n||o.name===t)&&r.push(o);return r.length===0?null:r.reduce((o,a)=>{const i=parseInt(o.id.split("_").pop()||"0");return parseInt(a.id.split("_").pop()||"0")>i?a:o})},findAgentById(t){for(const[,n]of e)if(n.id===t)return n;return null},registerAgent(t){e.set(t.id,t)}}}function Md(e,t,n){return e==="orchestrator"?t==="output"?n==="bottom"?"orch-bottom-output":"orch-right-output-tools":n==="top"?"orch-top-input":"orch-right-input-tools":t==="output"?n==="bottom"?"peer-bottom-output":"peer-right-output-tools":n==="top"?"peer-top-input":"peer-right-input-tools"}function sa(e){return e==="OrchestratorAgent"||e.toLowerCase().includes("orchestrator")}const eD=["USER_REQUEST","AGENT_LLM_CALL","AGENT_LLM_RESPONSE_TO_AGENT","AGENT_LLM_RESPONSE_TOOL_DECISION","AGENT_TOOL_INVOCATION_START","AGENT_TOOL_EXECUTION_RESULT","AGENT_RESPONSE_TEXT","TASK_COMPLETED","TASK_FAILED"];function tD(e,t,n,r,o,a){const i=e.target,l=i.replace(/[^a-zA-Z0-9_]/g,"_"),c=qn(t),u=bi(t);let f,h=!1;if(u?(f=u.peerAgent,f.id.startsWith(l+"_")&&(h=!0)):c&&(f=c.orchestratorAgent,f.id.startsWith(l+"_")&&(h=!0)),h&&f&&c){t.userNodeCounter++;const m=ds(t,`User_continue_${t.userNodeCounter}`),p=t.nextAvailableGlobalY,x={id:m,type:"userNode",position:{x:ho.USER,y:p},data:{label:"User",visualizerStepId:e.id}};us(n,t.allCreatedNodeIds,x),t.nodePositions.set(m,x.position);const g={id:m,yPosition:p,height:Nn,width:Cr};c.userNodes.push(g),t.allUserNodes.push(g);const w=p+Nn;f.yPosition=Math.max(f.yPosition,p),c.maxY=Math.max(c.maxY,w,f.yPosition+Nn),t.nextAvailableGlobalY=c.maxY+cs;const v=sa(i)?"orch-left-input":"peer-left-input";dr(g.id,f.id,e,r,t,o,a,"user-right-output",v)}else{const m=oa(t,i,e,n),p=ds(t,`User_${m.id}`),x={id:p,type:"userNode",position:{x:ho.USER,y:m.orchestratorAgent.yPosition-GM},data:{label:"User",visualizerStepId:e.id,isTopNode:!0}};us(n,t.allCreatedNodeIds,x),t.nodePositions.set(p,x.position);const g={id:p,yPosition:x.position.y,height:Nn,width:Cr};m.userNodes.push(g),t.allUserNodes.push(g),t.userNodeCounter++,m.maxY=Math.max(m.maxY,x.position.y+Nn),t.nextAvailableGlobalY=m.maxY+cs,dr(p,m.orchestratorAgent.id,e,r,t,o,a,"user-bottom-output","orch-top-input")}}function nD(e,t,n,r,o,a){const i=qn(t);if(!i)return;const l=Pc(t,e),c=l?l.peerAgent.id:i.orchestratorAgent.id,u=d1(t,"LLM","llmNode",e,n,l,!0);u&&dr(c,u.id,e,r,t,o,a,l?"peer-right-output-tools":"orch-right-output-tools","llm-left-input")}function rD(e,t,n,r,o,a){var x;if(e.type==="AGENT_LLM_RESPONSE_TOOL_DECISION"&&((x=e.data.toolDecision)!=null&&x.isParallel)){const g=`parallel-${e.id}`;e.data.toolDecision.decisions.filter(w=>w.isPeerDelegation).length>1&&t.parallelFlows.set(g,{subflowFunctionCallIds:e.data.toolDecision.decisions.filter(w=>w.isPeerDelegation).map(w=>w.functionCallId),completedSubflows:new Set,startX:ho.MAIN_FLOW-50,startY:t.nextAvailableGlobalY,currentXOffset:0,maxHeight:0})}const i=qn(t);if(!i)return;const l=Pc(t,e);let c;const f=c1((l||i).toolInstances,"LLM",n,e.functionCallId);if(f)c=f.id;else{console.error(`[Timeline] LLM node not found for step type ${e.type}: ${e.id}. Cannot create edge.`);return}const h=e.target||"UnknownAgent";let m,p;l?(m=l.peerAgent.id,p="peer-right-input-tools"):i.orchestratorAgent.id.startsWith(h.replace(/[^a-zA-Z0-9_]/g,"_")+"_")&&(m=i.orchestratorAgent.id,p="orch-right-input-tools"),c&&m&&p?dr(c,m,e,r,t,o,a,"llm-bottom-output",p):console.error(`[Timeline] Could not determine target agent node ID or handle for step type ${e.type}: ${e.id}. Target agent name: ${h}. Edge will be missing.`)}function oD(e,t,n,r,o,a){var f;const i=qn(t);if(!i)return;const l=e.source||"UnknownSource",c=e.target||"UnknownTool";if(((f=e.data.toolInvocationStart)==null?void 0:f.isPeerInvocation)||c.startsWith("peer_")){const h=c.startsWith("peer_")?c.substring(5):c,m=t.agentRegistry.findAgentByName(l);if(!m){console.error(`[Timeline] Could not find source agent in registry: ${l} for step ${e.id}`);return}const p=m.nodeInstance,x=Md(m.type,"output","bottom"),g=l1(e,t),w=Pd(t,h,e,n,g);w&&dr(p.id,w.peerAgent.id,e,r,t,o,a,x,"peer-top-input")}else{const h=Pc(t,e);let m,p;if(h)m=h.peerAgent.id,p="peer-right-output-tools";else{const g=t.agentRegistry.findAgentByName(l);g?(m=g.id,p=Md(g.type,"output","right")):(m=i.orchestratorAgent.id,p="orch-right-output-tools")}const x=d1(t,c,"genericToolNode",e,n,h);x&&dr(m,x.id,e,r,t,o,a,p,`${x.id}-tool-left-input`)}}function sD(e,t,n,r,o,a){var u,f;const i=qn(t);if(!i)return;const l=e.source||"UnknownSource",c=e.target||"OrchestratorAgent";if((u=e.data.toolResult)!=null&&u.isPeerResponse){const h=(f=e.data.toolResult)==null?void 0:f.functionCallId,m=Array.from(t.parallelFlows.entries()).find(([x,g])=>g.subflowFunctionCallIds.includes(h||""));if(m){const[x,g]=m;if(g.completedSubflows.add(h||""),g.completedSubflows.size<g.subflowFunctionCallIds.length)return;const w=i.subflows.filter(S=>g.subflowFunctionCallIds.includes(S.functionCallId)),v=e.target||"OrchestratorAgent";let b,C;if(sa(v))t.indentationLevel=0,b=oa(t,v,e,n).orchestratorAgent,C="orch-top-input",t.currentSubflowIndex=-1;else{t.indentationLevel=Math.max(0,t.indentationLevel-1);const S=Pd(t,v,e,n,!1);if(!S)return;b=S.peerAgent,C="peer-top-input"}w.forEach(S=>{var E;dr(((E=S.lastSubflow)==null?void 0:E.peerAgent.id)??S.peerAgent.id,b.id,e,r,t,o,a,"peer-bottom-output",C)}),t.parallelFlows.delete(x);return}const p=t.agentRegistry.findAgentByName(l.startsWith("peer_")?l.substring(5):l);if(!p){console.error(`[Timeline] Source peer agent not found for peer response: ${l}.`);return}if(sa(c)){t.indentationLevel=0;const x=oa(t,c,e,n);dr(p.id,x.orchestratorAgent.id,e,r,t,o,a,"peer-bottom-output","orch-top-input"),t.currentSubflowIndex=-1}else{t.indentationLevel=Math.max(0,t.indentationLevel-1);const x=l1(e,t)||Array.from(t.parallelFlows.values()).some(w=>w.subflowFunctionCallIds.some(v=>i.subflows.some(b=>b.functionCallId===v))),g=Pd(t,c,e,n,x);g&&dr(p.id,g.peerAgent.id,e,r,t,o,a,"peer-bottom-output","peer-top-input")}}else{let h;const m=Pc(t,e),x=c1((m||i).toolInstances,l,n,e.functionCallId);if(x&&(h=x.id),h){let g,w;if(m)g=m.peerAgent.id,w="peer-right-input-tools";else{const v=t.agentRegistry.findAgentByName(c);v?(g=v.id,w=Md(v.type,"input","right")):(g=i.orchestratorAgent.id,w="orch-right-input-tools")}dr(h,g,e,r,t,o,a,l==="LLM"?"llm-bottom-output":`${h}-tool-bottom-output`,w)}else console.error(`[Timeline] Could not find source tool node for regular tool result: ${e.id}. Step source (tool name): ${l}.`)}}function aD(e,t,n,r,o,a){const i=qn(t);if(!i||e.isSubTaskStep)return;const l=i.orchestratorAgent.id,c=gh(t,i,e,n);dr(l,c.id,e,r,t,o,a,"orch-bottom-output","user-top-input")}function iD(e,t,n,r,o,a){const i=qn(t);if(!i)return;const l=Array.from(t.parallelFlows.values()).find(p=>p.subflowFunctionCallIds.includes(e.functionCallId||""));if(l){if(l.completedSubflows.add(e.functionCallId||""),l.completedSubflows.size===l.subflowFunctionCallIds.length){t.indentationLevel=0;const p=oa(t,"OrchestratorAgent",e,n);i.subflows.forEach(x=>{l.subflowFunctionCallIds.includes(x.functionCallId)&&dr(x.peerAgent.id,p.orchestratorAgent.id,e,r,t,o,a,"peer-bottom-output","orch-top-input")}),t.currentSubflowIndex=-1}return}if(!e.isSubTaskStep)return;const c=bi(t);if(!c){console.warn(`[Timeline] TASK_COMPLETED with isSubTaskStep=true but no active subflow. Step ID: ${e.id}`);return}if(!i){console.error(`[Timeline] No current phase found for TASK_COMPLETED. Step ID: ${e.id}`);return}const u=c.peerAgent,f=n.some(p=>typeof p.data.label=="string"&&sa(p.data.label));let h,m;f?(t.indentationLevel=0,h=oa(t,"OrchestratorAgent",e,n).orchestratorAgent.id,m="orch-top-input"):(h=gh(t,i,e,n).id,m="user-top-input"),dr(u.id,h,e,r,t,o,a,"peer-bottom-output",m),t.currentSubflowIndex=-1}function lD(e,t,n,r){const o=qn(t);if(!o)return;const a=e.source||"UnknownSource",i=e.target||"User";let l,c="orch-bottom-output";const u=bi(t);if(u&&u.peerAgent.id.includes(a.replace(/[^a-zA-Z0-9_]/g,"_")))l=u.peerAgent,c="peer-bottom-output";else if(o.orchestratorAgent.id.includes(a.replace(/[^a-zA-Z0-9_]/g,"_")))l=o.orchestratorAgent,c="orch-bottom-output";else for(const m of o.subflows)if(m.peerAgent.id.includes(a.replace(/[^a-zA-Z0-9_]/g,"_"))){l=m.peerAgent,c="peer-bottom-output";break}if(!l){console.error(`[Timeline] Could not find source agent node for TASK_FAILED: ${a}`);return}let f,h;sa(i)?(t.indentationLevel=0,f=oa(t,i,e,n).orchestratorAgent.id,h="orch-top-input",t.currentSubflowIndex=-1):(f=gh(t,o,e,n).id,h="user-top-input"),cD(l.id,f,e,r,t,c,h)}function cD(e,t,n,r,o,a,i){var h;if(!e||!t||e===t)return;const l=o.allCreatedNodeIds.has(e),c=o.allCreatedNodeIds.has(t);if(!l||!c)return;const u=`error-edge-${e}${a||""}-to-${t}${i||""}-${n.id}`;if(!r.some(m=>m.id===u)){const m=((h=n.data.errorDetails)==null?void 0:h.message)||"Task failed",p=m.length>30?"Error":m,x={id:u,source:e,target:t,label:p,type:"defaultFlowEdge",data:{visualizerStepId:n.id,isAnimated:!1,animationType:"static",isError:!0,errorMessage:m}};a&&(x.sourceHandle=a),i&&(x.targetHandle=i),r.push(x)}}const uD=(e,t={})=>{const n=[],r=[];if(!e||e.length===0)return{nodes:n,edges:r};const o=new a1,a={phases:[],currentPhaseIndex:-1,currentSubflowIndex:-1,parallelFlows:new Map,nextAvailableGlobalY:ZM,nodeIdCounter:0,allCreatedNodeIds:new Set,nodePositions:new Map,allUserNodes:[],userNodeCounter:0,agentRegistry:QM(),indentationLevel:0,indentationStep:50,agentNameMap:t},i=e.filter(u=>eD.includes(u.type)),l=i.findIndex(u=>u.type==="USER_REQUEST");let c=i;l>0&&(c=[i[l],...i.slice(0,l),...i.slice(l+1)]);for(const u of c)switch(u.type){case"USER_REQUEST":tD(u,a,n,r,o,e);break;case"AGENT_LLM_CALL":nD(u,a,n,r,o,e);break;case"AGENT_LLM_RESPONSE_TO_AGENT":case"AGENT_LLM_RESPONSE_TOOL_DECISION":rD(u,a,n,r,o,e);break;case"AGENT_TOOL_INVOCATION_START":oD(u,a,n,r,o,e);break;case"AGENT_TOOL_EXECUTION_RESULT":sD(u,a,n,r,o,e);break;case"AGENT_RESPONSE_TEXT":aD(u,a,n,r,o,e);break;case"TASK_COMPLETED":iD(u,a,n,r,o,e);break;case"TASK_FAILED":lD(u,a,n,r);break}return a.phases.forEach(u=>{u.subflows.forEach(f=>{const h=n.find(m=>m.id===f.groupNode.id);if(h&&h.style){const p=f.maxY-f.groupNode.yPosition+Yr;h.style.height=`${Math.max(Nn+2*Yr,p)}px`;const x=f.maxContentXRelative+ra,g=Cr+2*ra+a.indentationLevel*a.indentationStep;h.style.width=`${Math.max(x,g)}px`}})}),{nodes:n,edges:r}},dD=({id:e,sourceX:t,sourceY:n,targetX:r,targetY:o,sourcePosition:a,targetPosition:i,style:l={},markerEnd:c,data:u})=>{const[f,h]=d.useState(!1),[m]=sC({sourceX:t,sourceY:n,sourcePosition:a,targetX:r,targetY:o,targetPosition:i}),p=()=>{const w={strokeWidth:f?3:2,stroke:"var(--color-muted-foreground)",...l},v=u;return v!=null&&v.isError?{...w,stroke:f?"var(--color-error-wMain)":"var(--color-error-w70)",strokeWidth:f?3:2}:v!=null&&v.isSelected?{...w,stroke:"#3b82f6",strokeWidth:3}:v!=null&&v.isAnimated?{...w,stroke:f?"#1d4ed8":"#3b82f6",strokeWidth:f?4:3}:f?{...w,stroke:"var(--edge-hover-color)"}:w},x=()=>h(!0),g=()=>h(!1);return s.jsxs(s.Fragment,{children:[s.jsx("path",{id:`${e}-interaction`,style:{strokeWidth:16,stroke:"transparent",fill:"none",cursor:"pointer"},className:"react-flow__edge-interaction",d:m,onMouseEnter:x,onMouseLeave:g}),s.jsx("path",{id:e,style:{...p(),cursor:"pointer",transition:"all 0.2s ease-in-out"},className:"react-flow__edge-path",d:m,markerEnd:c,onMouseEnter:x,onMouseLeave:g})]})},fD=({data:e})=>s.jsxs("div",{className:"cursor-pointer rounded-md border-2 border-blue-700 bg-white px-5 py-3 text-gray-800 shadow-md transition-all duration-200 ease-in-out hover:scale-105 hover:shadow-xl dark:border-blue-600 dark:bg-gray-800 dark:text-gray-200",style:{minWidth:"180px",textAlign:"center"},children:[s.jsx(In,{type:"target",position:Rn.Top,id:"peer-top-input",className:"!bg-blue-700",isConnectable:!0}),s.jsx(In,{type:"source",position:Rn.Right,id:"peer-right-output-tools",className:"!bg-blue-700",style:{top:"25%"},isConnectable:!0}),s.jsx(In,{type:"target",position:Rn.Right,id:"peer-right-input-tools",className:"!bg-blue-700",style:{top:"75%"},isConnectable:!0}),s.jsx(In,{type:"source",position:Rn.Bottom,id:"peer-bottom-output",className:"!bg-blue-700",isConnectable:!0}),s.jsx(In,{type:"target",position:Rn.Left,id:"peer-left-input",className:"!bg-blue-700",isConnectable:!0}),s.jsx("div",{className:"flex items-center justify-center",children:s.jsx("div",{className:"text-md truncate font-semibold",style:{maxWidth:"200px"},children:e.label})})]}),hD=({data:e,id:t})=>{const n=()=>{switch(e.status){case"completed":return"bg-green-500";case"in-progress":return"bg-blue-500";case"error":return"bg-red-500";case"started":return"bg-yellow-400";case"idle":default:return"bg-cyan-500"}};return s.jsxs("div",{className:"cursor-pointer rounded-lg border-2 border-cyan-600 bg-white px-3 py-3 text-gray-800 shadow-md transition-all duration-200 ease-in-out hover:scale-105 hover:shadow-xl dark:border-cyan-400 dark:bg-gray-800 dark:text-gray-200",style:{minWidth:"100px",textAlign:"center"},children:[s.jsx(In,{type:"target",position:Rn.Left,id:`${t}-tool-left-input`,className:"!bg-cyan-500",isConnectable:!0,style:{top:"25%"}}),s.jsxs("div",{className:"flex items-center justify-center",children:[s.jsx("div",{className:`mr-2 h-2 w-2 rounded-full ${n()}`}),s.jsx("div",{className:"text-md truncate",style:{maxWidth:"200px"},children:e.label})]}),s.jsx(In,{type:"source",position:Rn.Left,id:`${t}-tool-bottom-output`,className:"!bg-cyan-500",isConnectable:!0,style:{top:"75%"}})]})},pD=({data:e})=>{const t=()=>{switch(e.status){case"completed":return"bg-green-500";case"in-progress":return"bg-blue-500";case"error":return"bg-red-500";case"started":return"bg-yellow-400";case"idle":default:return"bg-teal-500"}};return s.jsxs("div",{className:"cursor-pointer rounded-lg border-2 border-teal-600 bg-white px-3 py-3 text-gray-800 shadow-md transition-all duration-200 ease-in-out hover:scale-105 hover:shadow-xl dark:border-teal-400 dark:bg-gray-800 dark:text-gray-200",style:{minWidth:"100px",textAlign:"center"},children:[s.jsx(In,{type:"target",position:Rn.Left,id:"llm-left-input",className:"!bg-teal-500",isConnectable:!0,style:{top:"25%"}}),s.jsxs("div",{className:"flex items-center justify-center",children:[s.jsx("div",{className:`mr-2 h-2 w-2 rounded-full ${t()}`}),s.jsx("div",{className:"text-md",children:e.label})]}),s.jsx(In,{type:"source",position:Rn.Left,id:"llm-bottom-output",className:"!bg-teal-500",isConnectable:!0,style:{top:"75%"}})]})},mD=({data:e})=>s.jsxs("div",{className:"cursor-pointer rounded-lg border-indigo-600 bg-gradient-to-r from-indigo-50 to-purple-50 px-5 py-3 text-gray-900 shadow-xl transition-all duration-200 ease-in-out hover:scale-105 hover:shadow-2xl dark:border-indigo-400 dark:bg-gradient-to-r dark:from-indigo-900 dark:to-purple-900 dark:text-gray-100",style:{minWidth:"180px",textAlign:"center",borderWidth:"2px",borderStyle:"solid",boxShadow:"0 0 0 1px rgba(79, 70, 229, 0.3), 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05)"},children:[s.jsx(In,{type:"source",position:Rn.Right,id:"orch-right-output-tools",className:"!bg-indigo-500",style:{top:"25%"},isConnectable:!0}),s.jsx(In,{type:"target",position:Rn.Right,id:"orch-right-input-tools",className:"!bg-indigo-500",style:{top:"75%"},isConnectable:!0}),s.jsx(In,{type:"target",position:Rn.Top,id:"orch-top-input",className:"!bg-indigo-500",isConnectable:!0}),s.jsx(In,{type:"source",position:Rn.Bottom,id:"orch-bottom-output",className:"!bg-indigo-500",isConnectable:!0}),s.jsx(In,{type:"target",position:Rn.Left,id:"orch-left-input",className:"!bg-indigo-500",isConnectable:!0}),s.jsx("div",{className:"flex items-center justify-center",children:s.jsx("div",{className:"text-md truncate font-bold",style:{maxWidth:"200px"},children:e.label})})]}),gD=({data:e})=>{const t=()=>{switch(e.status){case"completed":return"bg-green-500";case"in-progress":return"bg-blue-500";case"error":return"bg-red-500";case"started":return"bg-yellow-400";case"idle":default:return"bg-purple-500"}};return s.jsxs("div",{className:"cursor-pointer rounded-md border-2 border-purple-600 bg-white px-4 py-3 text-gray-800 shadow-lg transition-all duration-200 ease-in-out hover:scale-105 hover:shadow-xl dark:border-purple-400 dark:bg-gray-700 dark:text-gray-200",style:{minWidth:"120px",textAlign:"center"},children:[e.isTopNode&&s.jsx(In,{type:"source",position:Rn.Bottom,id:"user-bottom-output",className:"!bg-gray-500",isConnectable:!0}),e.isBottomNode&&s.jsx(In,{type:"target",position:Rn.Top,id:"user-top-input",className:"!bg-gray-500",isConnectable:!0}),!e.isTopNode&&!e.isBottomNode&&s.jsx(In,{type:"source",position:Rn.Right,id:"user-right-output",className:"!bg-gray-500",isConnectable:!0}),s.jsxs("div",{className:"flex items-center justify-center",children:[s.jsx("div",{className:`mr-2 h-3 w-3 rounded-full ${t()}`}),s.jsx("div",{className:"text-sm font-bold",children:e.label})]})]})},xD=({step:e,isHighlighted:t,onClick:n,variant:r="list"})=>{const o=()=>{var v,b,C;switch(e.type){case"USER_REQUEST":return s.jsx(vl,{className:"mr-2 text-blue-500 dark:text-blue-400",size:18});case"AGENT_RESPONSE_TEXT":return s.jsx(Zc,{className:"mr-2 text-teal-500 dark:text-teal-400",size:18});case"TASK_COMPLETED":return s.jsx(Hd,{className:"mr-2 text-green-500 dark:text-green-400",size:18});case"TASK_FAILED":return s.jsx(Pg,{className:"mr-2 text-red-500 dark:text-red-400",size:18});case"AGENT_LLM_CALL":return s.jsx(Zc,{className:"mr-2 text-purple-500 dark:text-purple-400",size:18});case"AGENT_LLM_RESPONSE_TO_AGENT":return s.jsx(Zc,{className:"mr-2 text-teal-500 dark:text-teal-400",size:18});case"AGENT_LLM_RESPONSE_TOOL_DECISION":{const S=(b=(v=e.data.toolDecision)==null?void 0:v.decisions)==null?void 0:b[0];return(S==null?void 0:S.isPeerDelegation)?s.jsx(zh,{className:"mr-2 text-orange-500 dark:text-orange-400",size:18}):s.jsx(Uh,{className:"mr-2 text-orange-500 dark:text-orange-400",size:18})}case"AGENT_TOOL_INVOCATION_START":return(C=e.data.toolInvocationStart)!=null&&C.isPeerInvocation?s.jsx(zh,{className:"mr-2 text-cyan-500 dark:text-cyan-400",size:18}):s.jsx(Uh,{className:"mr-2 text-cyan-500 dark:text-cyan-400",size:18});case"AGENT_TOOL_EXECUTION_RESULT":return s.jsx(aC,{className:"mr-2 text-teal-500 dark:text-teal-400",size:18});case"AGENT_ARTIFACT_NOTIFICATION":return s.jsx(wr,{className:"mr-2 text-indigo-500 dark:text-indigo-400",size:18});default:return s.jsx(Wg,{className:"mr-2 text-gray-500 dark:text-gray-400",size:18})}},a=new Date(e.timestamp).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"}),i=String(new Date(e.timestamp).getMilliseconds()).padStart(3,"0"),l=`${a}.${i}`,c=v=>s.jsxs("div",{className:"mt-1.5 rounded-md bg-gray-50 p-2 text-xs text-gray-700 dark:bg-gray-700 dark:text-gray-300",children:[s.jsxs("p",{children:[s.jsx("strong",{children:"Model:"})," ",v.modelName]}),s.jsx("p",{className:"mt-1",children:s.jsx("strong",{children:"Prompt Preview:"})}),s.jsx("pre",{className:"max-h-28 overflow-y-auto rounded bg-gray-100 p-1.5 font-mono text-xs break-all whitespace-pre-wrap dark:bg-gray-700",children:v.promptPreview})]}),u=({data:v})=>{const[b,C]=Rt.useState(!1),S=E=>{E.stopPropagation(),C(!b)};return b?s.jsxs("div",{className:"mt-1.5 rounded-md bg-gray-50 p-2 text-xs text-gray-700 dark:bg-gray-700 dark:text-gray-300",children:[s.jsxs("div",{className:"mb-1 flex items-center justify-between",children:[s.jsx("strong",{children:"LLM Response Details:"}),s.jsx("button",{onClick:S,className:"text-xs text-blue-500 underline hover:text-blue-700 dark:text-blue-400 dark:hover:text-blue-300",children:"Hide details"})]}),v.modelName&&s.jsxs("p",{children:[s.jsx("strong",{children:"Model:"})," ",v.modelName]}),s.jsxs("div",{className:"mt-1",children:[s.jsx("p",{children:s.jsx("strong",{children:"Response Preview:"})}),s.jsx("pre",{className:"max-h-28 overflow-y-auto rounded bg-gray-100 p-1.5 font-mono text-xs break-all whitespace-pre-wrap dark:bg-gray-700",children:v.responsePreview})]}),v.isFinalResponse!==void 0&&s.jsxs("p",{className:"mt-1",children:[s.jsx("strong",{children:"Final Response:"})," ",v.isFinalResponse?"Yes":"No"]})]}):s.jsxs("div",{className:"mt-1.5 flex items-center justify-between text-xs text-gray-500 dark:text-gray-400",children:[s.jsx("span",{className:"italic",children:"Internal LLM response"}),s.jsx("button",{onClick:S,className:"text-xs text-blue-500 underline hover:text-blue-700 dark:text-blue-400 dark:hover:text-blue-300",children:"Show details"})]})},f=v=>s.jsxs("div",{className:"mt-1.5 rounded-md bg-blue-50 p-2 font-mono text-xs text-blue-700 dark:bg-blue-900 dark:text-blue-300",children:[s.jsx("p",{className:"mb-2",children:s.jsxs("strong",{children:["🔧 ",v.isParallel?"Parallel Tool Calls:":"Tool Call:"]})}),s.jsx("ul",{className:"space-y-1 pl-2",children:v.decisions.map(b=>s.jsxs("li",{className:"flex items-center",children:[s.jsx("span",{className:"mr-2",children:"•"}),s.jsx("code",{children:b.toolName})]},b.functionCallId))})]}),h=v=>s.jsxs("div",{className:"mt-1.5 rounded-md bg-gray-50 p-2 text-xs text-gray-700 dark:bg-gray-700 dark:text-gray-300",children:[s.jsxs("p",{children:[s.jsx("strong",{children:"Tool:"})," ",v.toolName]}),s.jsx("p",{className:"mt-1",children:s.jsx("strong",{children:"Arguments:"})}),s.jsx("div",{className:"max-h-40 overflow-y-auto rounded bg-gray-100 p-1.5 dark:bg-gray-700",children:s.jsx(Ud,{data:v.toolArguments})})]}),m=v=>s.jsxs("div",{className:"mt-1.5 rounded-md bg-gray-50 p-2 text-xs text-gray-700 dark:bg-gray-700 dark:text-gray-300",children:[s.jsxs("p",{children:[s.jsx("strong",{children:"Tool:"})," ",v.toolName]}),s.jsx("p",{className:"mt-1",children:s.jsx("strong",{children:"Result:"})}),s.jsx("div",{className:"max-h-40 overflow-y-auto rounded bg-gray-100 p-1.5 dark:bg-gray-700",children:typeof v.resultData=="object"?s.jsx(Ud,{data:v.resultData}):s.jsx("pre",{className:"font-mono text-xs break-all whitespace-pre-wrap",children:String(v.resultData)})})]}),p=v=>s.jsxs("div",{className:"mt-1.5 rounded-md bg-gray-50 p-2 text-xs text-gray-700 dark:bg-gray-700 dark:text-gray-300",children:[s.jsxs("p",{children:[s.jsx("strong",{children:"Artifact:"})," ",v.artifactName,v.version!==void 0&&s.jsxs("span",{className:"text-gray-500 dark:text-gray-400",children:[" (v",v.version,")"]})]}),v.mimeType&&s.jsxs("p",{children:[s.jsx("strong",{children:"Type:"})," ",v.mimeType]}),v.description&&s.jsxs("p",{className:"mt-1",children:[s.jsx("strong",{children:"Description:"})," ",v.description]})]}),x=r==="list"&&e.nestingLevel&&e.nestingLevel>0?{marginLeft:`${e.nestingLevel*24}px`}:{},g=r==="popover"?`
370
+ p-3 bg-transparent hover:bg-gray-50 dark:hover:bg-gray-700/50 transition-colors duration-150
371
+ ${n?"cursor-pointer":""}
372
+ `:`
373
+ mb-3 p-3 border rounded-lg shadow-sm
374
+ bg-white dark:bg-gray-800 hover:shadow-md transition-shadow duration-150
375
+ ${t?"border-blue-500 dark:border-blue-400 ring-2 ring-blue-500 dark:ring-blue-400":"border-gray-200 dark:border-gray-700"}
376
+ ${n?"cursor-pointer":""}
377
+ `,w=()=>e.type==="AGENT_LLM_RESPONSE_TOOL_DECISION"||e.type==="AGENT_TOOL_INVOCATION_START"?"Delegated to: ":e.type==="AGENT_TOOL_EXECUTION_RESULT"?"Response from: ":"Peer Interaction with: ";return s.jsxs("div",{className:g,style:x,onClick:n,children:[s.jsxs("div",{className:"mb-1.5 flex w-full items-center gap-1",children:[o(),s.jsxs("div",{className:"flex min-w-0 flex-1 flex-wrap items-center justify-between gap-2",children:[s.jsx("h4",{className:"flex-1 truncate text-sm font-semibold",title:e.title,children:e.title}),s.jsx("span",{className:"text-muted-foreground shrink-0 font-mono text-xs",children:l})]})]}),e.delegationInfo&&e.delegationInfo.length>0&&s.jsx("div",{className:"mt-2 mb-1.5 space-y-2 rounded-r-md border-l-4 border-blue-500 bg-blue-50 p-2 text-sm dark:border-blue-400 dark:bg-gray-700/60",children:e.delegationInfo.map(v=>s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center font-semibold text-blue-700 dark:text-blue-300",children:[s.jsx(Ug,{className:"mr-2 h-4 w-4 flex-shrink-0"}),s.jsxs("span",{children:[w(),v.peerAgentName]})]}),v.subTaskId&&s.jsxs("div",{className:"mt-0.5 ml-[24px] text-xs text-blue-600 dark:text-blue-400",children:["Sub-Task:"," ",s.jsxs("span",{className:"font-mono",title:v.subTaskId,children:[v.subTaskId.substring(0,15),"..."]})]})]},v.functionCallId))}),e.data.text&&s.jsx("div",{className:"max-h-20 overflow-y-auto pl-1 text-sm text-gray-800 dark:text-gray-100",children:s.jsx(Hs,{children:e.data.text})}),e.data.finalMessage&&s.jsx("div",{className:"pl-1 text-sm text-gray-800 dark:text-gray-100",children:s.jsx(Hs,{children:e.data.finalMessage})}),e.type==="TASK_COMPLETED"&&!e.data.finalMessage&&s.jsx("div",{className:"pl-1 text-sm text-gray-600 italic dark:text-gray-300",children:"Task completed successfully."}),e.data.errorDetails&&s.jsxs("div",{className:"mt-1 rounded-md bg-red-50 p-2 pl-1 text-sm text-red-700 dark:bg-red-900/30 dark:text-red-400",children:[s.jsxs("p",{children:[s.jsx("strong",{children:"Error:"})," ",e.data.errorDetails.message]}),e.data.errorDetails.code&&s.jsxs("p",{className:"text-xs",children:["Code: ",e.data.errorDetails.code]})]}),e.data.llmCall&&c(e.data.llmCall),e.data.llmResponseToAgent&&s.jsx(u,{data:e.data.llmResponseToAgent}),e.data.toolDecision&&f(e.data.toolDecision),e.data.toolInvocationStart&&h(e.data.toolInvocationStart),e.data.toolResult&&m(e.data.toolResult),e.data.artifactNotification&&p(e.data.artifactNotification)]})},vD={genericAgentNode:fD,userNode:gD,llmNode:pD,orchestratorNode:mD,genericToolNode:hD},wD={defaultFlowEdge:dD},bD={x:16,y:0},yD=({processedSteps:e,isRightPanelVisible:t=!1,isSidePanelTransitioning:n=!1})=>{const[r,o,a]=lC([]),[i,l,c]=cC([]),{fitView:u}=uC(),{highlightedStepId:f,setHighlightedStepId:h}=Hf(),{taskIdInSidePanel:m,agentNameDisplayNameMap:p}=Ft(),x=d.useRef([]),[g,w]=d.useState(!1),[v,b]=d.useState(null),[C,S]=d.useState(!1),E=d.useRef(null),[_,j]=d.useState(null),A=d.useRef(new a1),P=d.useMemo(()=>!e||e.length===0?{nodes:[],edges:[]}:uD(e,p),[e,p]),O=d.useMemo(()=>P.edges.length?P.edges.map(F=>{const I=F.data;let J={isAnimated:!1,animationType:"none"};if(I!=null&&I.visualizerStepId){const D=e.length-1;J=A.current.getEdgeAnimationState(I.visualizerStepId,D,e)}let L=F.id===_;return f&&(I==null?void 0:I.visualizerStepId)===f&&(L=!0),{...F,animated:J.isAnimated,data:{...I,isAnimated:J.isAnimated,animationType:J.animationType,isSelected:L}}}):[],[P.edges,e,_,f]),B=d.useCallback(()=>{o(F=>F.map(I=>{var de,se,me,k;if(I.type!=="group")return I;const J=F.filter(oe=>oe.parentId===I.id);if(J.length===0)return I;let L=0,D=0;J.forEach(oe=>{const ie=oe.position.x+Cr,Z=oe.position.y+Nn;L=Math.max(L,ie),D=Math.max(D,Z)});const W=L+ra,G=D+Yr;let V=0;const Q=I.id.split("_");if(Q.length>2){const oe=Q.find(ie=>ie.startsWith("subflow"));if(oe){const ie=parseInt(oe.replace("subflow",""));isNaN(ie)||(V=ie)}}const X=Cr+2*ra+V*50,K=Math.max(W,X),q=parseInt(((se=(de=I.style)==null?void 0:de.width)==null?void 0:se.toString().replace("px",""))||"0"),ne=parseInt(((k=(me=I.style)==null?void 0:me.height)==null?void 0:k.toString().replace("px",""))||"0");return q!==K||ne!==G?{...I,style:{...I.style,width:`${K}px`,height:`${G}px`}}:I}))},[o]);d.useEffect(()=>{o(P.nodes),l(O),B()},[P.nodes,O,o,l,B]);const N=d.useCallback((F,I)=>i.find(J=>J.source===F&&(I?J.sourceHandle===I:!0))||null,[i]),M=d.useCallback((F,I)=>{var L;w(!0);const J=(L=I.data)==null?void 0:L.visualizerStepId;if(J){const D=e.find(W=>W.id===J);D&&(j(I.id),t?h(J):(h(J),b(D),S(!0)))}},[e,t,h]),y=d.useCallback(F=>{switch(F.type){case"userNode":{const I=F.data;return I!=null&&I.isTopNode?["user-bottom-output"]:I!=null&&I.isBottomNode?["user-top-input"]:["user-right-output"]}case"orchestratorNode":return["orch-right-output-tools","orch-bottom-output"];case"genericAgentNode":return["peer-right-output-tools","peer-bottom-output"];case"llmNode":return["llm-bottom-output"];case"genericToolNode":return[`${F.id}-tool-bottom-output`];default:return[]}},[]),T=d.useCallback(()=>{S(!1),b(null)},[]),R=d.useCallback((F,I)=>{if(w(!0),I.type==="group"){h(null),j(null),T();return}const J=y(I);let L=null;for(const D of J)if(L=N(I.id,D),L)break;if(!L&&I.type==="userNode"){const D=I.data;D!=null&&D.isBottomNode&&(L=i.find(W=>W.target===I.id)||null)}L&&M(F,L)},[y,h,T,N,i,M]),z=d.useCallback(F=>{F!=null&&F.isTrusted&&w(!0)},[]);return d.useEffect(()=>{w(!1)},[m]),d.useEffect(()=>{!n&&u&&r.length>0&&x.current!==e&&g===!1&&(u({duration:200,padding:.1,maxZoom:1.2}),x.current=e)},[r.length,u,e,n,g]),d.useEffect(()=>{if(o(F=>F.map(I=>{var W;const J=((W=I.data)==null?void 0:W.visualizerStepId)&&I.data.visualizerStepId===f,L=P.nodes.find(G=>G.id===I.id),D=(L==null?void 0:L.style)||{};return{...I,style:{...D,boxShadow:J?"0px 4px 12px rgba(0, 0, 0, 0.2)":D.boxShadow||"none",transition:"box-shadow 0.2s ease-in-out"}}})),f){const F=O.find(I=>{const J=I.data;return(J==null?void 0:J.visualizerStepId)===f});F&&j(F.id)}else j(null)},[f,o,P.nodes,O]),!e||e.length===0?s.jsx("div",{className:"flex h-full items-center justify-center text-gray-500 dark:text-gray-400",children:Object.keys(e).length>0?"Processing flow data...":"No steps to display in flow chart."}):P.nodes.length===0&&e.length>0?s.jsx("div",{className:"flex h-full items-center justify-center text-gray-500 dark:text-gray-400",children:"Generating flow chart..."}):s.jsxs("div",{style:{height:"100%",width:"100%"},className:"relative",children:[s.jsxs(dC,{nodes:r,edges:i.map(F=>({...F,markerEnd:{type:mC.ArrowClosed,color:"#888"}})),onNodesChange:a,onEdgesChange:c,onEdgeClick:M,onNodeClick:R,onPaneClick:()=>{h(null),j(null),T()},onMoveStart:z,nodeTypes:vD,edgeTypes:wD,fitViewOptions:{padding:.1},className:"bg-gray-50 dark:bg-gray-900 [&>button]:dark:bg-gray-700",proOptions:{hideAttribution:!0},nodesDraggable:!1,elementsSelectable:!1,nodesConnectable:!1,minZoom:.2,children:[s.jsx(fC,{}),s.jsx(hC,{className:Ak()}),s.jsx(pC,{position:"top-right",className:"flex items-center space-x-4",children:s.jsx("div",{ref:E})})]}),s.jsx(dA,{isOpen:C,onClose:T,anchorRef:E,offset:bD,placement:"right-start",className:"max-w-[500px] min-w-[400px] p-2",children:v&&s.jsx(xD,{step:v,variant:"popover"})})]})},CD=e=>s.jsx(iC,{children:s.jsx(yD,{...e})}),f1=e=>{var t,n,r,o;if(e.events&&e.events.length>0){const a=e.events[0];if((o=(r=(n=(t=a.full_payload)==null?void 0:t.params)==null?void 0:n.message)==null?void 0:r.metadata)!=null&&o.parentTaskId)return a.full_payload.params.message.metadata.parentTaskId}},ja=e=>{var t,n,r;return((r=(n=(t=e.full_payload)==null?void 0:t.result)==null?void 0:n.status)==null?void 0:r.timestamp)||e.timestamp},h1=(e,t,n,r)=>{const o=t[e];if(!o)return console.warn(`[collectAllDescendantEvents] Task not found in allMonitoredTasks: ${e}`),[];n.set(e,r);let a=[...o.events||[]];for(const i in t){const l=t[i];if(l.taskId===e)continue;f1(l)===e&&(a=a.concat(h1(l.taskId,t,n,r+1)))}return a},Iu=(e,t,n)=>{var z,F,I,J,L;if(!n)return null;if(!((z=n.events)==null?void 0:z.some(D=>D.direction==="request"&&D.task_id===n.taskId))&&n.initialRequestText&&n.events&&n.events.length>0){const D=((F=n.events[0])==null?void 0:F.timestamp)||n.firstSeen.toISOString(),W=new Date(new Date(D).getTime()-1).toISOString();let G="Orchestrator";const V=n.events[0];V!=null&&V.source_entity?G=V.source_entity:(L=(J=(I=V==null?void 0:V.full_payload)==null?void 0:I.result)==null?void 0:J.metadata)!=null&&L.agent_name&&(G=V.full_payload.result.metadata.agent_name);const Q={task_id:n.taskId,direction:"request",timestamp:W,source_entity:"User",target_entity:G,event_type:"a2a_message",solace_topic:`synthetic/request/${n.taskId}`,payload_summary:{method:"message/send"},full_payload:{method:"message/send",params:{message:{parts:[{kind:"text",text:n.initialRequestText}]}}}};n.events=[Q,...n.events]}const o={overall:{totalTaskDurationMs:0},agents:{}},a=new Map,i=new Map,l=(D,W)=>(o.agents[D]||(o.agents[D]={agentName:W,instanceId:D,displayName:W,llmCalls:[],toolCalls:[],totalLlmTimeMs:0,totalToolTimeMs:0}),o.agents[D]),c=new Map,u=h1(n.taskId,t,c,0);if(u.length===0)return{taskId:n.taskId,initialRequestText:n.initialRequestText,status:"working",startTime:n.firstSeen.toISOString(),steps:[]};const f=u.sort((D,W)=>new Date(ja(D)).getTime()-new Date(ja(W)).getTime()),h=[];let m,p="",x,g,w=[],v=null,b;const C=new Map,S=new Map,E=new Map,_=D=>{if(p.trim()&&x&&g){const W=p.trim();let G=n.taskId;if(w.length>0){const X=w[0].split("-");X.length>2&&X[1]!=="global"&&(G=X.slice(1,X.length-1).join("-"))}else D&&(G=D);const V=c.get(G)??0,Q=C.get(G)||E.get(G);h.push({id:`vstep-agenttext-${h.length}-${w[0]||"unknown"}`,type:"AGENT_RESPONSE_TEXT",timestamp:g,title:`${x}: Response`,source:x,target:"User",data:{text:W},rawEventIds:[...w],isSubTaskStep:V>0,nestingLevel:V,owningTaskId:G,functionCallId:Q}),v=W}p="",x=void 0,g=void 0,w=[],b=void 0};f.forEach((D,W)=>{var k,oe,ie,Z,U,re,$,Y,H,ce,ue,ae,pe,Te,Ae,gt,Pt,Nt,Mt,ct,$t,Wt,Dt,ve,Pe,Me,Oe,at,Ue,it,We,ft,Et,hn,Dn,ee,le,fe,be,_e,Fe,He,Le,Ve,Xe;const G=ja(D),V=`raw-${D.task_id||"global"}-${W}`,Q=D.full_payload,X=D.task_id||n.taskId,K=c.get(X)??0;let q=D.source_entity||"UnknownAgent";(ie=(oe=(k=Q==null?void 0:Q.params)==null?void 0:k.message)==null?void 0:oe.metadata)!=null&&ie.agent_name?q=Q.params.message.metadata.agent_name:(U=(Z=Q==null?void 0:Q.result)==null?void 0:Z.metadata)!=null&&U.agent_name?q=Q.result.metadata.agent_name:(H=(Y=($=(re=Q==null?void 0:Q.result)==null?void 0:re.status)==null?void 0:$.message)==null?void 0:Y.metadata)!=null&&H.agent_name?q=Q.result.status.message.metadata.agent_name:(ae=(ue=(ce=Q==null?void 0:Q.result)==null?void 0:ce.artifact)==null?void 0:ue.metadata)!=null&&ae.agent_name&&(q=Q.result.artifact.metadata.agent_name);let ne;if(K>0?ne=C.get(X):ne=E.get(X),D.direction==="request"&&K>0){const Se=(pe=Q.params)==null?void 0:pe.metadata,je=Se==null?void 0:Se.function_call_id,De=D.task_id;if(De&&je){C.set(De,je);return}}if(D.payload_summary.method&&D.payload_summary.method==="tasks/cancel")return;if(D.direction==="request"&&K===0&&D.task_id===n.taskId){_(X),v=null;const Se=Q.params;let je="User request";if((Te=Se==null?void 0:Se.message)!=null&&Te.parts){const De=Se.message.parts.filter(Ze=>Ze.kind==="text"&&Ze.text);De.length>0&&(je=De[De.length-1].text)}h.push({id:`vstep-userreq-${h.length}-${V}`,type:"USER_REQUEST",timestamp:G,title:"User Input",source:"User",target:D.target_entity||q,data:{text:je},rawEventIds:[V],isSubTaskStep:!1,nestingLevel:0,owningTaskId:X});return}if(D.direction==="status-update"&&(Q!=null&&Q.result)){const Se=Q.result,je=(Ae=Se.status)==null?void 0:Ae.message,De=je==null?void 0:je.metadata;let Ze;const yt=!!(De!=null&&De.forwarded_from_peer);yt?Ze=De.forwarded_from_peer:(gt=Se.metadata)!=null&&gt.agent_name?Ze=Se.metadata.agent_name:De!=null&&De.agent_name?Ze=De.agent_name:Ze=D.source_entity||"Agent";const At=`${Ze}:${X}`;if(!yt&&(je!=null&&je.parts))for(const ke of je.parts){if(ke.kind==="data"){const te=ke.data;te.type==="agent_progress_update"?m=te.status_text:te.type==="artifact_creation_progress"&&(m=`Saving artifact: ${te.filename} (${te.bytes_saved} bytes)`)}if(ke.kind==="data"){_(X);const ge=ke.data;switch(ge==null?void 0:ge.type){case"agent_progress_update":{h.push({id:`vstep-progress-${h.length}-${V}`,type:"AGENT_RESPONSE_TEXT",timestamp:G,title:`${Ze}: Progress Update`,source:Ze,target:"User",data:{text:ge.status_text},rawEventIds:[V],isSubTaskStep:K>0,nestingLevel:K,owningTaskId:X,functionCallId:ne});break}case"llm_invocation":{const $e=ge.request;let nt="System-initiated LLM call";if($e!=null&&$e.contents&&Array.isArray($e.contents)&&$e.contents.length>0){const Ot=[...$e.contents].reverse().find(Ct=>Ct.role==="user");Ot&&Ot.parts&&(nt=Ot.parts.map(Ct=>Ct.text||"").join(`
378
+ `).trim())}const wt={modelName:($e==null?void 0:$e.model)||"Unknown Model",promptPreview:nt||"No text in user prompt."};l(At,Ze),a.set(At,{timestamp:G,modelName:wt.modelName}),h.push({id:`vstep-llmcall-${h.length}-${V}`,type:"AGENT_LLM_CALL",timestamp:G,title:`${Ze}: LLM Call`,source:Ze,target:"LLM",data:{llmCall:wt},rawEventIds:[V],isSubTaskStep:K>0,nestingLevel:K,owningTaskId:X,functionCallId:ne});break}case"llm_response":{const $e=a.get(At);if($e){const Ct=new Date(G).getTime()-new Date($e.timestamp).getTime();l(At,Ze).llmCalls.push({modelName:$e.modelName,durationMs:Ct,timestamp:$e.timestamp}),a.delete(At)}const nt=ge.data,wt=(Pt=nt.content)==null?void 0:Pt.parts,Ot=wt==null?void 0:wt.filter(Ct=>Ct.function_call);if(Ot&&Ot.length>0){_(X),v=null,E.delete(X);const Ct=Ot.map(xt=>{var zn;return{functionCallId:xt.function_call.id,toolName:xt.function_call.name,toolArguments:xt.function_call.args||{},isPeerDelegation:(zn=xt.function_call.name)==null?void 0:zn.startsWith("peer_")}}),Tt={decisions:Ct,isParallel:Ct.length>1},pn=[],Qe=new Set;Ct.forEach(xt=>{if(xt.isPeerDelegation){const zn=xt.toolName.substring(5);for(const kr in t){const sr=t[kr];if(Qe.has(sr.taskId))continue;if(f1(sr)===X&&sr.events&&sr.events.length>0){const Si=sr.events.find(Yo=>{var _i,ki,Ei,ji;return Yo.direction==="request"&&((ji=(Ei=(ki=(_i=Yo.full_payload)==null?void 0:_i.params)==null?void 0:ki.message)==null?void 0:Ei.metadata)==null?void 0:ji.function_call_id)===xt.functionCallId});if(Si&&new Date(ja(Si)).getTime()>=new Date(G).getTime()){const Yo={functionCallId:xt.functionCallId,peerAgentName:zn,subTaskId:sr.taskId};pn.push(Yo),S.set(xt.functionCallId,Yo),sr.taskId&&(C.set(sr.taskId,xt.functionCallId),Qe.add(sr.taskId));break}}}}});const Lt={id:`vstep-tooldecision-${h.length}-${V}`,type:"AGENT_LLM_RESPONSE_TOOL_DECISION",timestamp:G,title:`LLM: Tool Decision${Tt.isParallel?" (Parallel)":""}`,source:"LLM",target:Ze,data:{toolDecision:Tt},rawEventIds:[V],delegationInfo:pn.length>0?pn:void 0,isSubTaskStep:K>0,nestingLevel:K,owningTaskId:X,functionCallId:ne};h.push(Lt);const or=Tt.isParallel?Lt.id:void 0,gr=At;l(gr,Ze),Ct.forEach(xt=>{var kr;const zn=xt.isPeerDelegation?(kr=S.get(xt.functionCallId))==null?void 0:kr.subTaskId:void 0;i.has(xt.functionCallId)||i.set(xt.functionCallId,{timestamp:G,toolName:xt.toolName,isPeer:xt.isPeerDelegation,invokingAgentInstanceId:gr,subTaskId:zn,parallelBlockId:or})})}else{const Ct=(wt==null?void 0:wt.filter(pn=>pn.text).map(pn=>pn.text).join(`
379
+ `))||"",Tt={responsePreview:Ct.substring(0,200)+(Ct.length>200?"...":""),isFinalResponse:(nt==null?void 0:nt.partial)===!1};h.push({id:`vstep-llmrespagent-${h.length}-${V}`,type:"AGENT_LLM_RESPONSE_TO_AGENT",timestamp:G,title:`${Ze}: LLM Response`,source:"LLM",target:Ze,data:{llmResponseToAgent:Tt},rawEventIds:[V],isSubTaskStep:K>0,nestingLevel:K,owningTaskId:X,functionCallId:ne})}break}case"tool_invocation_start":{const $e={functionCallId:ge.function_call_id,toolName:ge.tool_name,toolArguments:ge.tool_args,isPeerInvocation:(Nt=ge.tool_name)==null?void 0:Nt.startsWith("peer_")};h.push({id:`vstep-toolinvokestart-${h.length}-${V}`,type:"AGENT_TOOL_INVOCATION_START",timestamp:G,title:`${Ze}: Executing tool ${$e.toolName}`,source:Ze,target:$e.toolName,data:{toolInvocationStart:$e},rawEventIds:[V],isSubTaskStep:K>0,nestingLevel:K,owningTaskId:X,functionCallId:ne});break}case"tool_result":{const $e=ge.function_call_id,nt=i.get($e);if(nt){const Ot=new Date(G).getTime()-new Date(nt.timestamp).getTime(),Ct=o.agents[nt.invokingAgentInstanceId];if(Ct){const Tt={toolName:nt.toolName,durationMs:Ot,isPeer:nt.isPeer,timestamp:nt.timestamp,peerAgentName:nt.isPeer?nt.toolName.substring(5):void 0,subTaskId:nt.subTaskId,parallelBlockId:nt.parallelBlockId};Ct.toolCalls.push(Tt)}i.delete($e)}const wt={toolName:ge.tool_name,functionCallId:$e,resultData:ge.result_data,isPeerResponse:(Mt=ge.tool_name)==null?void 0:Mt.startsWith("peer_")};h.push({id:`vstep-toolresult-${h.length}-${V}`,type:"AGENT_TOOL_EXECUTION_RESULT",timestamp:G,title:`${Ze}: Tool Result - ${wt.toolName}`,source:wt.toolName,target:Ze,data:{toolResult:wt},rawEventIds:[V],isSubTaskStep:K>0,nestingLevel:K,owningTaskId:X,functionCallId:ne});break}}}else ke.kind==="text"&&ke.text&&(x&&x!==Ze&&(_(X),v=null),x||(x=Ze,g=G,b=yt),p+=ke.text,w.push(V))}return}if(D.direction==="artifact_update"&&((ct=Q==null?void 0:Q.result)!=null&&ct.artifact)){_(X);const Se=Q.result.artifact,je=(($t=Se.metadata)==null?void 0:$t.agent_name)||D.source_entity||"Agent";let De;if(Se.parts&&Se.parts.length>0){const yt=Se.parts[0];yt.kind==="file"?De=yt.file.mimeType||void 0:(Wt=yt.metadata)!=null&&Wt.mime_type&&(De=yt.metadata.mime_type)}const Ze={artifactName:Se.name||"Unnamed Artifact",version:typeof((Dt=Se.metadata)==null?void 0:Dt.version)=="number"?Se.metadata.version:void 0,description:Se.description||void 0,mimeType:De};h.push({id:`vstep-artifactnotify-${h.length}-${V}`,type:"AGENT_ARTIFACT_NOTIFICATION",timestamp:G,title:`${je}: Artifact Update - ${Ze.artifactName}`,source:je,target:"User/System",data:{artifactNotification:Ze},rawEventIds:[V],isSubTaskStep:K>0,nestingLevel:K,owningTaskId:X,functionCallId:ne});return}if(["response","task"].includes(D.direction)&&((Pe=(ve=Q==null?void 0:Q.result)==null?void 0:ve.status)!=null&&Pe.state)){p.trim()&&_(X);const Se=Q.result,je=Se.status.state,De=((Me=Se.metadata)==null?void 0:Me.agent_name)||((Ue=(at=(Oe=Se.status)==null?void 0:Oe.message)==null?void 0:at.metadata)==null?void 0:Ue.agent_name)||D.source_entity||"Agent";if(["completed","failed","canceled"].includes(je)&&K==0){const Ze=je==="completed"?"TASK_COMPLETED":"TASK_FAILED",yt=`${De}: Task ${je.charAt(0).toUpperCase()+je.slice(1)}`;let At={},ke="";if((it=Se.status.message)!=null&&it.parts){const Ie=Se.status.message.parts.find($e=>$e.kind==="text");Ie!=null&&Ie.text&&(ke=Ie.text.trim())}const te=X===n.taskId,ge=ke&&(!te||ke!==v);if(Ze==="TASK_COMPLETED")At={finalMessage:ge?ke:void 0};else{const $e={message:ge?ke:`Task ${je}.`},nt=Q.error;nt&&($e.message=nt.message||$e.message,$e.code=nt.code,nt.data&&($e.details=nt.data)),Se.error&&($e.message=Se.error.message||$e.message,$e.code=Se.error.code||$e.code,$e.details=Se.error.data||$e.details),At={errorDetails:$e}}h.push({id:`vstep-${je}-${h.length}-${V}`,type:Ze,timestamp:G,title:yt,source:De,target:"User",data:At,rawEventIds:[V],isSubTaskStep:K>0,nestingLevel:K,owningTaskId:X,functionCallId:ne}),te&&(v=null);return}}const se=D.direction==="status-update"&&((hn=(Et=(ft=(We=Q==null?void 0:Q.result)==null?void 0:We.status)==null?void 0:ft.message)==null?void 0:Et.parts)==null?void 0:hn.some(Se=>Se.kind==="text"));let me=D.source_entity;(fe=(le=(ee=(Dn=Q==null?void 0:Q.result)==null?void 0:Dn.status)==null?void 0:ee.message)==null?void 0:le.metadata)!=null&&fe.forwarded_from_peer?me=Q.result.status.message.metadata.forwarded_from_peer:(_e=(be=Q==null?void 0:Q.result)==null?void 0:be.metadata)!=null&&_e.agent_name?me=Q.result.metadata.agent_name:(Ve=(Le=(He=(Fe=Q==null?void 0:Q.result)==null?void 0:Fe.status)==null?void 0:He.message)==null?void 0:Le.metadata)!=null&&Ve.agent_name&&(me=Q.result.status.message.metadata.agent_name),p.trim()&&x&&(!se||se&&me!==x)&&(_(X),c.get(((Xe=w[0])==null?void 0:Xe.split("-")[1])||n.taskId)===0&&!b&&(v=null))});const j=f.length>0&&f[f.length-1].task_id||n.taskId;_(j);const A=f[0]?ja(f[0]):n.firstSeen.toISOString();let P,O="working";const B=h.filter(D=>D.owningTaskId===n.taskId),N=B.length>0?B[B.length-1]:null;if(N&&(N.type==="TASK_COMPLETED"?(O="completed",P=N.timestamp):N.type==="TASK_FAILED"&&(O="failed",P=N.timestamp)),O==="working"&&f.length>0){const D=f[f.length-1];t[D.task_id||n.taskId]}let M;A&&P&&(M=new Date(P).getTime()-new Date(A).getTime()),["completed","failed","canceled","rejected"].includes(O)&&(m=void 0);const y={taskId:n.taskId,initialRequestText:n.initialRequestText,status:O,currentStatusText:m,startTime:A,endTime:P,durationMs:M,steps:h};y.steps.forEach((D,W)=>{if(D.type==="TASK_COMPLETED"){let G="";for(let V=W-1;V>=0;V--){const Q=y.steps[V];if(Q.type!=="AGENT_RESPONSE_TEXT"||Q.source!==D.source)break;G=Q.data.text+G}D.data.finalMessage&&(G+=D.data.finalMessage),D.data.finalMessage=G.trim()||void 0}}),Object.values(o.agents).forEach(D=>{D.totalLlmTimeMs=D.llmCalls.reduce((X,K)=>X+K.durationMs,0);const W=D.toolCalls.filter(X=>!X.parallelBlockId),G=new Map;D.toolCalls.forEach(X=>{X.parallelBlockId&&(G.has(X.parallelBlockId)||G.set(X.parallelBlockId,[]),G.get(X.parallelBlockId).push(X))});const V=W.reduce((X,K)=>X+K.durationMs,0);let Q=0;G.forEach(X=>{if(X.length>0){const K=Math.min(...X.map(ne=>new Date(ne.timestamp).getTime())),q=Math.max(...X.map(ne=>new Date(ne.timestamp).getTime()+ne.durationMs));Q+=q-K}}),D.totalToolTimeMs=V+Q});const T=new Map;Object.values(o.agents).forEach(D=>{T.has(D.agentName)||T.set(D.agentName,[]),T.get(D.agentName).push(D)}),T.forEach(D=>{D.length>1&&(D.sort((W,G)=>{const V=Q=>{const X=[...Q.llmCalls.map(K=>new Date(K.timestamp).getTime()),...Q.toolCalls.map(K=>new Date(K.timestamp).getTime())];return X.length>0?Math.min(...X):1/0};return V(W)-V(G)}),D.forEach((W,G)=>{W.displayName=`${W.agentName} (${G+1})`}))});const R=new Map;return Object.values(o.agents).forEach(D=>{const W=D.instanceId.split(":").slice(1).join(":");W&&R.set(W,D.displayName)}),Object.values(o.agents).forEach(D=>{D.toolCalls.forEach(W=>{if(W.isPeer&&W.subTaskId){const G=R.get(W.subTaskId);G&&(W.peerAgentName=G)}})}),M!==void 0&&(o.overall.totalTaskDurationMs=M),y.performanceReport=o,y},SD=({items:e,bottomItems:t,activeItem:n,onItemChange:r,onHeaderClick:o})=>{const a=l=>{r(l)},i=t==null?void 0:t.filter(l=>l.id!=="theme-toggle");return s.jsxs("aside",{className:"flex h-screen w-[100px] flex-col border-r border-[var(--color-secondary-w70)] bg-[var(--color-primary-w100)]",children:[s.jsx(kD,{onClick:o}),s.jsx(ND,{items:e,bottomItems:i,activeItem:n,onItemClick:a})]})},qm="webui_logo_url",_D=s.jsx("div",{className:"flex h-12 w-12 items-center justify-center overflow-hidden rounded-full",children:s.jsxs("svg",{id:"header-icon",xmlns:"http://www.w3.org/2000/svg",version:"1.1",viewBox:"0 0 500 150",width:"100%",height:"100%",children:[s.jsx("path",{className:"fill-[var(--color-brand-wMain)]",d:"M14.3,82.5c0-4.4,1-8.2,2.9-11.3,1.9-3.1,4.4-5.7,7.5-7.8,3.1-2,6.5-3.6,10.4-4.6,3.8-1,7.7-1.5,11.5-1.5s7.1.3,10.2.9c3.1.6,5.9,1.5,8.2,2.6,2.4,1.1,4.2,2.4,5.6,3.8,1.4,1.4,2,3,2,4.6,0,2.4,0,4.3-.2,5.7-.1,1.4-.3,2.4-.6,3.1-.3.7-.7,1.1-1.1,1.3-.4.2-.9.2-1.6.2-1.8,0-3.2-.7-4.3-2-1.1-1.3-2.3-2.8-3.7-4.4-1.4-1.6-3.1-3.1-5.3-4.4-2.1-1.3-5.3-2-9.3-2s-4.4.3-6,.9c-1.6.6-2.9,1.5-3.8,2.5-.9,1-1.6,2.2-2,3.4-.4,1.2-.6,2.4-.6,3.5,0,2.5,1,4.4,3.1,5.7,2.1,1.3,4.7,2.3,7.8,3.2,3.1.9,6.5,1.7,10.1,2.5,3.6.8,7,1.9,10.1,3.4,3.1,1.5,5.8,3.5,7.9,6.1,2.1,2.6,3.1,6.1,3.1,10.5s-.8,8-2.5,11.3c-1.7,3.4-4,6.2-7,8.5-3,2.3-6.6,4.1-10.8,5.3-4.2,1.3-8.9,1.9-13.9,1.9s-8.8-.6-12.5-1.9c-3.7-1.3-6.9-2.8-9.6-4.6-2.7-1.8-4.7-3.7-6.2-5.6-1.5-1.9-2.2-3.5-2.2-4.7,0-1.8.5-3.6,1.6-5.3,1-1.8,2.6-2.7,4.7-2.7s2.5.4,3.5,1.2c.9.8,1.8,1.7,2.7,2.8.8,1.1,1.7,2.3,2.6,3.7.9,1.4,2,2.6,3.3,3.7,1.3,1.1,2.9,2,4.7,2.8,1.8.8,4.1,1.2,6.8,1.2,4.1,0,7.5-1,10.3-3.1,2.8-2.1,4.2-4.8,4.2-8s-1-4.9-3.1-6.4c-2-1.4-4.6-2.6-7.7-3.5-3.1-.9-6.4-1.7-10-2.4-3.6-.7-7-1.8-10-3.2-3.1-1.4-5.7-3.4-7.7-6-2-2.6-3.1-6.3-3.1-11"}),s.jsx("path",{className:"fill-[var(--color-brand-wMain)]",d:"M124.6,66.8c-4,0-7.3.9-9.9,2.7-2.6,1.8-4.7,4.2-6.4,7.1-1.6,2.9-2.8,6.1-3.5,9.7-.7,3.5-1,6.9-1,10.1,0,4.9.5,9.2,1.6,13,1,3.7,2.5,6.8,4.4,9.3,1.9,2.5,4.1,4.3,6.7,5.6,2.6,1.3,5.3,1.9,8.2,1.9s5.7-.6,8.2-1.9c2.6-1.3,4.8-3.1,6.7-5.6,1.9-2.5,3.3-5.5,4.4-9.3,1-3.7,1.6-8,1.6-13,0-9.5-1.9-16.9-5.8-22-3.9-5.1-8.9-7.7-15.2-7.7M82.2,96.5c0-5.8,1.1-11,3.3-15.9,2.2-4.8,5.2-8.9,9.1-12.4,3.9-3.5,8.4-6.1,13.6-8,5.2-1.9,10.7-2.8,16.6-2.8s11.4.9,16.6,2.8c5.2,1.9,9.7,4.6,13.5,8,3.8,3.5,6.9,7.6,9.1,12.4,2.2,4.8,3.4,10.1,3.4,15.9s-1.1,11.2-3.4,15.9c-2.3,4.8-5.3,8.9-9.1,12.3-3.8,3.5-8.3,6.1-13.5,8-5.2,1.9-10.7,2.8-16.6,2.8s-11.4-.9-16.6-2.8c-5.2-1.9-9.7-4.6-13.6-8-3.9-3.5-6.9-7.6-9.1-12.3-2.2-4.8-3.3-10.1-3.3-15.9"}),s.jsx("path",{className:"fill-[var(--color-brand-wMain)]",d:"M172.3,23.3c0-.8.9-1.8,2.7-2.8,1.8-1,4-2,6.5-2.9,2.5-.9,5.1-1.6,7.7-2.3,2.6-.6,4.7-.9,6.3-.9s1.3,0,1.9.2c.6.2,1.2.5,1.8,1.2.6.6,1,1.6,1.4,2.9.4,1.3.5,3.1.5,5.4v94.7c0,2.4.4,4.1,1.2,4.9.8.9,1.6,1.5,2.5,2,.9.4,1.7.8,2.5,1.3.8.4,1.2,1.4,1.2,2.8s-.5,2.5-1.6,3.2c-1,.7-2.4,1-3.9,1h-24.2c-1.6,0-2.9-.3-3.9-1-1-.7-1.6-1.8-1.6-3.2s.4-2.3,1.2-2.7c.8-.5,1.6-.9,2.5-1.3.9-.4,1.7-1.1,2.5-2,.8-.9,1.2-2.5,1.2-4.9V34.5c0-2-.4-3.4-1.3-4.2-.9-.8-1.9-1.4-2.9-1.9-1-.5-2-1-2.9-1.6-.9-.6-1.3-1.8-1.3-3.5"}),s.jsx("path",{className:"fill-[var(--color-brand-wMain)]",d:"M254.4,93.3c-3.7,1.2-6.8,2.8-9.4,4.7-2.6,1.9-4.6,4.1-6,6.6-1.4,2.5-2.1,5-2.1,7.6s.3,3.6,1,5.3c.7,1.8,1.6,3.4,2.9,4.7,1.3,1.4,2.7,2.5,4.5,3.3,1.7.8,3.6,1.3,5.7,1.3s5.2-.7,7.2-2c2-1.3,3.6-2.9,4.9-4.7,1.3-1.8,2.2-3.7,2.7-5.7.6-1.9.9-3.6.9-4.9v-18.2c-4.5.1-8.6.8-12.2,2M220.5,69.7c0-1.9.9-3.6,2.6-5.1,1.7-1.5,4-2.8,6.8-3.8,2.8-1,6-1.9,9.5-2.4,3.5-.6,7-.9,10.4-.9,7,0,12.9.8,17.6,2.3,4.7,1.5,8.5,3.6,11.5,6.1,2.9,2.6,5,5.5,6.3,8.7,1.3,3.2,1.9,6.6,1.9,10v34.5c0,1.9.4,3.2,1.3,4.1.8.8,1.7,1.5,2.7,2,.9.5,1.8,1,2.7,1.5.8.5,1.3,1.4,1.3,2.7s-.4,2.5-1.2,3.4c-.8.9-2.7,1.3-5.7,1.3h-13.2c-2.4,0-4.1-.5-5.1-1.6-1-1-1.5-2.8-1.5-5.2v-1.7h-.6c-2.4,3.5-5.9,6-10.4,7.6-4.6,1.6-9.3,2.4-14.4,2.4s-8.5-.6-11.9-1.9c-3.4-1.3-6.3-3-8.6-5.1-2.4-2.1-4.1-4.6-5.3-7.5-1.2-2.8-1.8-5.8-1.8-8.8,0-5.2,1.6-9.7,4.8-13.5,3.2-3.8,7.3-6.8,12.2-9.2,5-2.4,10.5-4.1,16.6-5.2,6.1-1.1,12-1.6,17.9-1.6,0-4.7-1.3-8.6-4-11.5-2.7-3-6.6-4.5-11.7-4.5s-5.7.5-7.5,1.4c-1.9.9-3.6,2-5.1,3.1-1.5,1.2-3.1,2.2-4.7,3.1-1.6.9-3.7,1.4-6.2,1.4s-3.8-.5-5-1.6c-1.3-1.1-1.9-2.6-1.9-4.6"}),s.jsx("path",{className:"fill-[var(--color-brand-wMain)]",d:"M301.5,97.6c0-5.9,1-11.3,3.1-16.2,2.1-4.9,4.9-9.2,8.6-12.7,3.6-3.6,7.9-6.3,12.9-8.3,5-2,10.4-3,16.2-3s7.2.4,10.8,1.3c3.5.9,6.6,2.1,9.3,3.5,2.7,1.5,4.9,3.2,6.5,5.2,1.6,2,2.4,4.1,2.4,6.3s-.9,4.1-2.7,5.5c-1.8,1.4-4.2,2-7.2,2s-4.1-.8-5.3-2.4c-1.2-1.6-2.4-3.4-3.5-5.3-1.1-1.9-2.4-3.6-4-5.3-1.6-1.6-3.9-2.4-7.1-2.4s-5.2.8-7.5,2.3c-2.3,1.5-4.2,3.7-5.9,6.5-1.7,2.8-3,6.2-3.8,10-.9,3.9-1.3,8.2-1.3,12.9s.6,7.9,1.8,11.2c1.2,3.3,2.8,6.1,4.8,8.4,2,2.3,4.3,4.1,6.9,5.3,2.6,1.2,5.4,1.8,8.3,1.8s6.9-.6,9.4-1.9c2.5-1.3,4.7-2.6,6.4-4.2,1.8-1.5,3.3-2.9,4.6-4.2,1.3-1.3,2.6-1.9,4-1.9s2,.3,2.7,1c.8.7,1.2,1.6,1.2,2.7,0,1.7-.8,3.6-2.5,5.9-1.7,2.3-4,4.4-6.9,6.4-2.9,2-6.4,3.8-10.4,5.2-4,1.4-8.4,2.1-13.1,2.1s-10.7-.9-15.5-2.7c-4.8-1.8-8.9-4.4-12.3-7.8-3.5-3.3-6.2-7.4-8.2-12-2-4.7-3-9.8-3-15.5"}),s.jsx("path",{className:"fill-[var(--color-brand-wMain)]",d:"M423.2,65.9c-3.4,0-6.3.7-8.9,2.2-2.6,1.5-4.9,3.5-6.8,6.1-1.9,2.6-3.3,5.8-4.3,9.4-1,3.7-1.5,7.7-1.5,12.1v.9c3.5-.3,7.1-.9,11-1.7,3.9-.8,7.4-2,10.7-3.5,3.2-1.5,5.9-3.4,8.1-5.7,2.1-2.4,3.2-5.3,3.2-8.7s-.9-5.9-2.7-8c-1.8-2.1-4.7-3.1-8.7-3.1M380,98.4c0-5.7.9-11,2.7-15.9,1.8-5,4.5-9.3,8.2-13,3.7-3.7,8.3-6.6,13.9-8.8,5.6-2.1,12.2-3.2,19.9-3.2s6.8.4,10.4,1.2c3.6.8,6.8,2,9.8,3.8,3,1.7,5.4,4,7.4,6.8,1.9,2.8,2.9,6.1,2.9,10s-1.6,9-4.9,12.2c-3.3,3.2-7.5,5.8-12.6,7.7-5.1,1.9-10.8,3.4-16.9,4.3-6.1.9-12,1.6-17.7,1.9.5,3.1,1.5,5.9,2.9,8.3,1.4,2.4,3.1,4.4,5.2,6,2,1.6,4.2,2.8,6.6,3.6,2.4.8,4.7,1.2,7.1,1.2s5-.3,7.2-.9c2.2-.6,4.2-1.3,6-2.3,1.8-.9,3.5-2,4.9-3.1,1.5-1.1,2.8-2.2,3.9-3.2,1-1,2-1.9,2.8-2.4.8-.6,1.8-.9,3-.9,2.4,0,3.6,1.2,3.6,3.6s-1,4-3,6.4c-2,2.4-4.7,4.6-8,6.7-3.4,2-7.2,3.8-11.5,5.2-4.3,1.4-8.9,2.1-13.7,2.1s-10.9-.9-15.8-2.8c-4.9-1.9-9.1-4.5-12.7-7.8-3.6-3.3-6.4-7.2-8.5-11.8-2-4.6-3.1-9.5-3.1-14.8"}),s.jsx("path",{className:"fill-[var(--color-brand-wMain)]",d:"M464.7,123.7c0-6.5,5.3-11.8,11.8-11.8s11.8,5.3,11.8,11.8-5.3,11.8-11.8,11.8-11.8-5.3-11.8-11.8"})]})}),kD=({onClick:e})=>{const t=Ut(),[n,r]=d.useState(!1),[o,a]=d.useState("");d.useEffect(()=>{try{const l=localStorage.getItem(qm);l&&a(l)}catch(l){console.warn("Failed to read cached logo URL from localStorage:",l)}},[]),d.useEffect(()=>{if(t.configLogoUrl!==void 0){a(t.configLogoUrl);try{localStorage.setItem(qm,t.configLogoUrl)}catch(l){console.error("Failed to save logo URL to localStorage:",l)}r(!1)}},[t.configLogoUrl]);const i=o&&!n;return s.jsx("div",{className:"flex h-[80px] min-h-[80px] cursor-pointer items-center justify-center border-b",onClick:e,children:i?s.jsx("div",{className:"flex h-16 w-16 items-center justify-center overflow-hidden",children:s.jsx("img",{src:o,alt:"Logo",className:"h-full w-full object-contain",onError:()=>r(!0)})}):_D})},ED=()=>{const{settings:e,updateSetting:t}=Bo(),{configFeatureEnablement:n}=Ut(),[r,o]=d.useState([]),[a,i]=d.useState(!1),[l,c]=d.useState(null),[u,f]=d.useState(null),[h,m]=d.useState(null),[p,x]=d.useState(null),[g,w]=d.useState(!1),[v,b]=d.useState(!1),[C,S]=d.useState(null),E=(n==null?void 0:n.speechToText)??!0,_=(n==null?void 0:n.textToSpeech)??!0;d.useEffect(()=>{(async()=>{try{const P=await pt("/api/v1/speech/config");if(P.ok){const O=await P.json(),B=O.sttExternal||!1,N=O.ttsExternal||!1;c(B),f(N),O.sttProviders&&m(O.sttProviders),O.ttsProviders&&x(O.ttsProviders),!B&&e.sttProvider!=="browser"&&(console.warn("External STT not configured, resetting provider to browser"),t("sttProvider","browser"),t("engineSTT","browser")),!N&&e.ttsProvider!=="browser"&&(console.warn("External TTS not configured, resetting provider to browser"),t("ttsProvider","browser"),t("engineTTS","browser"))}}catch(P){console.error("Error checking speech config:",P)}})()},[e.sttProvider,e.ttsProvider,t]),d.useEffect(()=>{(async()=>{if(e.ttsProvider==="browser"){o([]);return}i(!0);try{const P=e.ttsProvider||"gemini",O=await pt(`/api/v1/speech/voices?provider=${P}`);if(O.ok){const B=await O.json();o(B.voices||[])}else console.error("Failed to load voices:",O.statusText)}catch(P){console.error("Error loading voices:",P)}finally{i(!1)}})()},[e.ttsProvider]),d.useEffect(()=>()=>{C&&(C.pause(),C.src="")},[C]);const j=async A=>{try{C&&(C.pause(),C.src="",C.onended=null,C.onerror=null,S(null)),b(!0),w(!1);const P=new FormData;P.append("voice",A),e.ttsProvider!=="browser"&&P.append("provider",e.ttsProvider);const O=await pt("/api/v1/speech/voice-sample",{method:"POST",body:P});if(!O.ok)throw new Error(`Failed to load voice sample: ${O.statusText}`);const B=await O.blob(),N=URL.createObjectURL(B);b(!1),w(!0);const M=new Audio(N);M.onended=()=>{w(!1),S(null),URL.revokeObjectURL(N)},M.onerror=()=>{w(!1),S(null),URL.revokeObjectURL(N)},M.playbackRate=e.playbackRate||1,S(M),await M.play()}catch(P){console.error("Error playing voice sample:",P),b(!1),w(!1),S(null),alert("Failed to play voice sample. Please try again.")}};return s.jsxs("div",{className:"space-y-6",children:[E&&s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex items-center gap-2 border-b pb-2",children:[s.jsx(Wu,{className:"size-5"}),s.jsx("h3",{className:"text-lg font-semibold",children:"Speech-to-Text"})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx(It,{className:"font-medium",children:"Enable Speech-to-Text"}),s.jsx(dd,{checked:e.speechToText,onCheckedChange:A=>t("speechToText",A)})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx(It,{className:"font-medium",children:"Speech-to-Text Provider"}),s.jsxs(Rr,{value:e.sttProvider,onValueChange:A=>{t("sttProvider",A),t("engineSTT",A==="browser"?"browser":"external")},disabled:!e.speechToText,children:[s.jsx(Mr,{className:"w-44",children:s.jsx(Pr,{})}),s.jsxs(Dr,{children:[s.jsx(jt,{value:"browser",children:"Browser (Free)"}),(h==null?void 0:h.openai)&&s.jsx(jt,{value:"openai",children:"OpenAI Whisper"}),(h==null?void 0:h.azure)&&s.jsx(jt,{value:"azure",children:"Azure Speech"})]})]})]}),e.speechToText&&e.sttProvider!=="browser"&&l===!1&&s.jsx("div",{className:"rounded-md border border-[var(--color-warning-w40)] bg-[var(--color-warning-w20)] p-3 dark:border-[var(--color-warning-w80)] dark:bg-[var(--color-warning-w95)]",children:s.jsxs("div",{className:"flex gap-2",children:[s.jsx(fo,{className:"mt-0.5 size-5 flex-shrink-0 text-[var(--color-warning-wMain)]"}),s.jsxs("div",{className:"flex-1 text-sm",children:[s.jsx("p",{className:"mb-1 font-semibold text-[var(--color-warning-w80)] dark:text-[var(--color-warning-w30)]",children:"External STT Not Configured"}),s.jsxs("p",{className:"mb-2 text-[var(--color-warning-w70)] dark:text-[var(--color-warning-w40)]",children:["To use External API mode, add configuration to your ",s.jsx("code",{className:"rounded bg-[var(--color-warning-w30)] px-1 py-0.5 text-xs dark:bg-[var(--color-warning-w90)]",children:"webui.yaml"}),":"]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{children:[s.jsx("p",{className:"mb-1 text-xs font-semibold text-[var(--color-warning-w80)] dark:text-[var(--color-warning-w30)]",children:"OpenAI Whisper:"}),s.jsx("pre",{className:"overflow-x-auto rounded bg-[var(--color-warning-w30)] p-2 text-xs dark:bg-[var(--color-warning-w90)]",children:`speech:
380
+ stt:
381
+ provider: openai
382
+ openai:
383
+ url: https://api.openai.com/v1/audio/transcriptions
384
+ api_key: \${OPENAI_API_KEY}
385
+ model: whisper-1`})]}),s.jsxs("div",{children:[s.jsx("p",{className:"mb-1 text-xs font-semibold text-[var(--color-warning-w80)] dark:text-[var(--color-warning-w30)]",children:"Azure Speech:"}),s.jsx("pre",{className:"overflow-x-auto rounded bg-[var(--color-warning-w30)] p-2 text-xs dark:bg-[var(--color-warning-w90)]",children:`speech:
386
+ stt:
387
+ provider: azure
388
+ azure:
389
+ api_key: \${AZURE_SPEECH_KEY}
390
+ region: eastus
391
+ language: en-US`})]})]}),s.jsx("p",{className:"mt-2 text-xs text-[var(--color-warning-w70)] dark:text-[var(--color-warning-w40)]",children:"Or use Browser mode (free, no setup required)."})]})]})}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx(It,{className:"font-medium",children:"Language"}),s.jsxs(Rr,{value:e.languageSTT,onValueChange:A=>t("languageSTT",A),disabled:!e.speechToText,children:[s.jsx(Mr,{className:"w-44",children:s.jsx(Pr,{})}),s.jsxs(Dr,{children:[s.jsx(jt,{value:"en-US",children:"English (US)"}),s.jsx(jt,{value:"en-GB",children:"English (UK)"}),s.jsx(jt,{value:"es-ES",children:"Spanish"}),s.jsx(jt,{value:"fr-FR",children:"French"}),s.jsx(jt,{value:"de-DE",children:"German"}),s.jsx(jt,{value:"it-IT",children:"Italian"}),s.jsx(jt,{value:"ja-JP",children:"Japanese"}),s.jsx(jt,{value:"ko-KR",children:"Korean"}),s.jsx(jt,{value:"zh-CN",children:"Chinese (Simplified)"})]})]})]})]}),_&&s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex items-center gap-2 border-b pb-2",children:[s.jsx(gl,{className:"size-5"}),s.jsx("h3",{className:"text-lg font-semibold",children:"Text-to-Speech"})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx(It,{className:"font-medium",children:"Enable Text-to-Speech"}),s.jsx(dd,{checked:e.textToSpeech,onCheckedChange:A=>t("textToSpeech",A)})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx(It,{className:"font-medium",children:"Text-to-Speech Provider"}),s.jsxs(Rr,{value:e.ttsProvider,onValueChange:A=>{t("ttsProvider",A),t("engineTTS",A==="browser"?"browser":"external")},disabled:!e.textToSpeech,children:[s.jsx(Mr,{className:"w-44",children:s.jsx(Pr,{})}),s.jsxs(Dr,{children:[s.jsx(jt,{value:"browser",children:"Browser (Free)"}),(p==null?void 0:p.gemini)&&s.jsx(jt,{value:"gemini",children:"Google Gemini"}),(p==null?void 0:p.azure)&&s.jsx(jt,{value:"azure",children:"Azure Neural"}),(p==null?void 0:p.polly)&&s.jsx(jt,{value:"polly",children:"AWS Polly"})]})]})]}),e.textToSpeech&&e.ttsProvider!=="browser"&&u===!1&&s.jsx("div",{className:"rounded-md border border-[var(--color-warning-w40)] bg-[var(--color-warning-w20)] p-3 dark:border-[var(--color-warning-w80)] dark:bg-[var(--color-warning-w95)]",children:s.jsxs("div",{className:"flex gap-2",children:[s.jsx(fo,{className:"mt-0.5 size-5 flex-shrink-0 text-[var(--color-warning-wMain)]"}),s.jsxs("div",{className:"flex-1 text-sm",children:[s.jsx("p",{className:"mb-1 font-semibold text-[var(--color-warning-w80)] dark:text-[var(--color-warning-w30)]",children:"External TTS Not Configured"}),s.jsxs("p",{className:"mb-2 text-[var(--color-warning-w70)] dark:text-[var(--color-warning-w40)]",children:["To use External API mode, configure TTS in your ",s.jsx("code",{className:"rounded bg-[var(--color-warning-w30)] px-1 py-0.5 text-xs dark:bg-[var(--color-warning-w90)]",children:"webui.yaml"}),". Example for Gemini:"]}),s.jsx("pre",{className:"overflow-x-auto rounded bg-[var(--color-warning-w30)] p-2 text-xs dark:bg-[var(--color-warning-w90)]",children:`speech:
392
+ tts:
393
+ provider: gemini
394
+ api_key: \${GEMINI_API_KEY}
395
+ model: gemini-2.0-flash-exp`}),s.jsx("p",{className:"mt-2 text-xs text-[var(--color-warning-w70)] dark:text-[var(--color-warning-w40)]",children:"Or use Browser mode (free, no setup required)."})]})]})}),e.textToSpeech&&e.ttsProvider==="polly"&&u===!1&&s.jsx("div",{className:"rounded-md border border-[var(--color-warning-w40)] bg-[var(--color-warning-w20)] p-3 dark:border-[var(--color-warning-w80)] dark:bg-[var(--color-warning-w95)]",children:s.jsxs("div",{className:"flex gap-2",children:[s.jsx(fo,{className:"mt-0.5 size-5 flex-shrink-0 text-[var(--color-warning-wMain)]"}),s.jsxs("div",{className:"flex-1 text-sm",children:[s.jsx("p",{className:"mb-1 font-semibold text-[var(--color-warning-w80)] dark:text-[var(--color-warning-w30)]",children:"External TTS Not Configured"}),s.jsxs("p",{className:"mb-2 text-[var(--color-warning-w70)] dark:text-[var(--color-warning-w40)]",children:["To use AWS Polly, configure TTS in your ",s.jsx("code",{className:"rounded bg-[var(--color-warning-w30)] px-1 py-0.5 text-xs dark:bg-[var(--color-warning-w90)]",children:"webui.yaml"}),":"]}),s.jsx("pre",{className:"overflow-x-auto rounded bg-[var(--color-warning-w30)] p-2 text-xs dark:bg-[var(--color-warning-w90)]",children:`speech:
396
+ tts:
397
+ provider: polly
398
+ polly:
399
+ aws_access_key_id: \${AWS_ACCESS_KEY_ID}
400
+ aws_secret_access_key: \${AWS_SECRET_ACCESS_KEY}
401
+ region: us-east-1
402
+ engine: neural # or 'standard'
403
+ default_voice: Joanna`}),s.jsx("p",{className:"mt-2 text-xs text-[var(--color-warning-w70)] dark:text-[var(--color-warning-w40)]",children:"Or use Browser mode (free, no setup required)."})]})]})}),e.ttsProvider!=="browser"&&s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx(It,{className:"font-medium",children:"Voice"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs(Rr,{value:e.voice,onValueChange:A=>t("voice",A),disabled:!e.textToSpeech||a,children:[s.jsx(Mr,{className:"w-[112px]",children:s.jsx(Pr,{placeholder:a?"Loading...":"Select voice"})}),s.jsx(Dr,{children:r.length>0?(()=>{if(r.some(P=>P.includes("DragonHD"))&&e.ttsProvider==="azure"){const P=r.filter(B=>B.includes("DragonHD")),O=r.filter(B=>!B.includes("DragonHD"));return s.jsxs(s.Fragment,{children:[P.length>0&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"text-muted-foreground px-2 py-1.5 text-xs font-semibold",children:"HD Voices (Premium)"}),P.map(B=>{const N=B.split("-"),y=(N[N.length-1]||B).replace("MultilingualNeural:DragonHDLatestNeural","").replace("Neural:DragonHDLatestNeural","").replace(":DragonHDLatestNeural","");return s.jsx(jt,{value:B,children:y},B)})]}),O.length>0&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"text-muted-foreground mt-1 border-t px-2 py-1.5 pt-2 text-xs font-semibold",children:"Standard Voices"}),O.map(B=>{const N=B.split("-"),y=(N[N.length-1]||B).replace("MultilingualNeural","").replace("Neural","");return s.jsx(jt,{value:B,children:y},B)})]})]})}else return r.map(P=>{let O=P;if(P.includes("-")){const B=P.split("-");O=B[B.length-1].replace("Neural","").replace("Multilingual","")||P}return s.jsx(jt,{value:P,children:O},P)})})():s.jsx(jt,{value:"loading",disabled:!0,children:a?"Loading...":"No voices available"})})]}),s.jsx(xe,{variant:g?"default":"outline",size:"sm",onClick:()=>{!g&&!v&&j(e.voice)},disabled:!e.textToSpeech||!e.voice||a||g||v,title:v?"Loading sample...":g?"Playing sample...":"Play voice sample",className:"w-10 px-3",children:v?s.jsx(fr,{className:"size-4 animate-spin"}):g?s.jsx(gl,{className:"size-4"}):s.jsx(gC,{className:"size-4"})})]})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx(It,{className:"font-medium",children:"Playback Speed"}),s.jsx(br,{type:"number",min:.5,max:2,step:.1,value:e.playbackRate,onChange:A=>t("playbackRate",parseFloat(A.target.value)||1),disabled:!e.textToSpeech,className:"w-44"})]})]})]})},Xm=()=>{const{currentTheme:e,toggleTheme:t}=di();return s.jsx("div",{className:"space-y-6",children:s.jsxs("div",{className:"space-y-4",children:[s.jsx("div",{className:"border-b pb-2",children:s.jsx("h3",{className:"text-lg font-semibold",children:"Display"})}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Hg,{className:"size-4"}),s.jsx(It,{className:"font-medium",children:"Dark Mode"})]}),s.jsx(dd,{checked:e==="dark",onCheckedChange:t})]})]})})},jD=()=>{const[e,t]=d.useState(null),[n,r]=d.useState(!0),[o,a]=d.useState(null),i=()=>n?s.jsx(no,{className:"mt-8"}):o?s.jsx(Kt,{variant:"error",message:`Error loading application information. ${o}`}):e?s.jsx(xP,{children:s.jsx(vP,{children:e.products.toSorted((l,c)=>l.name.localeCompare(c.name)).map(l=>s.jsxs(wP,{className:"hover:bg-transparent",children:[s.jsx(vm,{className:"font-medium",children:l.name}),s.jsx(vm,{children:l.version})]},l.id))})}):null;return d.useEffect(()=>{(async()=>{try{const c=await _n("/api/v1/version");t(c)}catch(c){a(Yt(c))}finally{r(!1)}})()},[]),s.jsx("div",{className:"space-y-6",children:s.jsxs("div",{className:"space-y-4",children:[s.jsx("div",{className:"border-b pb-2",children:s.jsx("div",{className:"text-lg font-semibold",children:"Application Versions"})}),i()]})})},Ru=({icon:e,label:t,active:n,onClick:r})=>s.jsxs("button",{onClick:r,className:ze("flex w-full cursor-pointer items-center gap-3 px-4 py-2.5 transition-colors",n?"dark:bg-accent bg-[var(--color-brand-w10)]":"text-muted-foreground hover:bg-accent/50"),children:[e,s.jsx("span",{children:t})]}),Jm=({iconOnly:e=!1,open:t,onOpenChange:n})=>{const{configFeatureEnablement:r}=Ut(),[o,a]=d.useState(!1),[i,l]=d.useState("general"),c=t!==void 0,u=c?t:o,f=n||a,h=(r==null?void 0:r.speechToText)??!0,m=(r==null?void 0:r.textToSpeech)??!0,p=h||m,x=()=>{switch(i){case"about":return s.jsx(jD,{});case"general":return s.jsx(Xm,{});case"speech":return s.jsx(ED,{});default:return s.jsx(Xm,{})}},g=()=>{switch(i){case"about":return"About";case"general":return"General";case"speech":return"Speech";default:return"Settings"}};return s.jsxs(On,{open:u,onOpenChange:f,children:[!c&&(e?s.jsxs(vo,{children:[s.jsx(wo,{asChild:!0,children:s.jsx(cd,{asChild:!0,children:s.jsx("button",{type:"button",className:"relative mx-auto flex w-full cursor-pointer flex-col items-center bg-[var(--color-primary-w100)] px-3 py-5 text-xs text-[var(--color-primary-text-w10)] transition-colors hover:bg-[var(--color-primary-w90)] hover:text-[var(--color-primary-text-w10)]","aria-label":"Open Settings",children:s.jsx(Fa,{className:"h-6 w-6"})})})}),s.jsx(bo,{side:"right",children:"Settings"})]}):s.jsx(cd,{asChild:!0,children:s.jsxs(xe,{variant:"outline",className:"w-full justify-start gap-2",children:[s.jsx(Fa,{className:"size-5"}),s.jsx("span",{children:"Settings"})]})})),s.jsxs(Ln,{className:"max-h-[90vh] w-[90vw] !max-w-[1200px] gap-0 p-0",showCloseButton:!0,children:[s.jsxs(ac,{children:[s.jsx(Fn,{children:"Settings"}),s.jsx(Yn,{children:"Configure application settings"})]}),s.jsxs("div",{className:"flex h-[80vh] overflow-hidden",children:[s.jsxs("div",{className:"bg-muted/30 flex w-64 flex-col border-r",children:[s.jsx("div",{className:"flex h-15 items-center px-4 text-lg font-semibold",children:"Settings"}),s.jsxs("nav",{className:"flex flex-1 flex-col",children:[s.jsxs("div",{className:"flex-1 space-y-1 overflow-y-auto",children:[s.jsx(Ru,{icon:s.jsx(zg,{className:"size-4"}),label:"General",active:i==="general",onClick:()=>l("general")}),p&&s.jsx(Ru,{icon:s.jsx(gl,{className:"size-4"}),label:"Speech",active:i==="speech",onClick:()=>l("speech")})]}),s.jsxs("div",{className:"space-y-1 pb-2",children:[s.jsx("div",{className:"mt-4 border-t pb-2"}),s.jsx(Ru,{icon:s.jsx(ti,{className:"size-4"}),label:"About",active:i==="about",onClick:()=>l("about")})]})]})]}),s.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[s.jsx("div",{className:"flex items-center border-b px-6 py-4",children:s.jsx("h3",{className:"text-xl font-semibold",children:g()})}),s.jsx("div",{className:"flex-1 overflow-y-auto p-6",children:s.jsx("div",{className:"mx-auto max-w-2xl",children:x()})})]})]})]})]})},ND=({items:e,bottomItems:t,activeItem:n,onItemClick:r})=>{const[o,a]=d.useState(!1),[i,l]=d.useState(!1),{frontend_use_authorization:c,configFeatureEnablement:u}=Ut(),f=!!(c&&(u!=null&&u.logout)),{userInfo:h,logout:m}=Fw(),p=()=>{a(!1),l(!0)},x=()=>{a(!1),m()};return s.jsxs("nav",{className:"flex flex-1 flex-col",role:"navigation","aria-label":"Main navigation",children:[s.jsx("ul",{className:"space-y-1",children:e.map(g=>s.jsxs("li",{children:[s.jsx(Qm,{item:g,isActive:n===g.id,onItemClick:r}),g.showDividerAfter&&s.jsx("div",{className:"mx-4 my-3 border-t border-[var(--color-secondary-w70)]"})]},g.id))}),s.jsx("div",{className:"flex-1"}),s.jsxs("ul",{className:"space-y-1",children:[t&&t.length>0&&t.map(g=>s.jsx("li",{className:"my-4",children:s.jsx(Qm,{item:g,isActive:n===g.id,onItemClick:r},g.id)},g.id)),f?s.jsx("li",{className:"my-4 flex justify-center",children:s.jsxs(bc,{open:o,onOpenChange:a,children:[s.jsxs(vo,{children:[s.jsx(wo,{asChild:!0,children:s.jsx(yc,{asChild:!0,children:s.jsx("button",{type:"button",className:"relative mx-auto flex w-full cursor-pointer flex-col items-center bg-[var(--color-primary-w100)] px-3 py-5 text-xs text-[var(--color-primary-text-w10)] transition-colors hover:bg-[var(--color-primary-w90)] hover:text-[var(--color-primary-text-w10)]","aria-label":"Open Menu",children:s.jsx(vl,{className:"h-6 w-6"})})})}),s.jsx(bo,{side:"right",children:"User & Settings"})]}),s.jsxs(Cc,{side:"right",align:"end",className:"w-60 p-0",children:[s.jsxs("div",{className:"flex items-center gap-2 border-b px-3 py-4",children:[s.jsx(vl,{className:"size-4"}),s.jsx("span",{className:"text-sm font-medium",children:typeof(h==null?void 0:h.username)=="string"?h.username:"Guest"})]}),s.jsx(hi,{actions:[{id:"settings",label:"Settings",icon:s.jsx(Fa,{}),onClick:p},{id:"logout",label:"Log Out",icon:s.jsx(xC,{}),onClick:x,divider:!0}]})]})]})}):s.jsx("li",{className:"my-4 flex justify-center",children:s.jsx(Jm,{iconOnly:!0})})]}),i&&s.jsx(Jm,{iconOnly:!1,open:i,onOpenChange:l})]})},Qm=({item:e,isActive:t,onItemClick:n})=>{const{id:r,label:o,icon:a,disabled:i,badge:l}=e,c=()=>{!i&&n&&n(r)},u=f=>{(f.key==="Enter"||f.key===" ")&&c()};return s.jsxs(vo,{children:[s.jsx(wo,{asChild:!0,children:s.jsxs("button",{type:"button",onClick:n?c:void 0,onKeyDown:n?u:void 0,disabled:i,className:ze("relative mx-auto flex w-full cursor-pointer flex-col items-center px-3 py-5 text-xs transition-colors","bg-(--color-primary-w100) hover:bg-(--color-primary-w90)","text-(--color-primary-text-w10) hover:bg-(--color-primary-w90) hover:text-(--color-background-w10)","border-l-4 border-(--color-primary-w100)",t?"border-l-4 border-(--color-brand-wMain) bg-(--color-primary-w90)":""),"aria-label":o,"aria-current":t?"page":void 0,children:[s.jsx(a,{className:ze("mb-1 h-6 w-6",t&&"text-(--color-brand-wMain)")}),s.jsx("span",{className:"text-center text-[13px] leading-tight",children:o}),l&&s.jsx(zr,{variant:"outline",className:"mt-1 border-gray-400 bg-(--color-secondary-w80) px-1 py-0.5 text-[8px] leading-tight text-(--color-secondary-text-w10) uppercase",children:l})]})}),s.jsx(bo,{side:"right",children:o})]})},TD=e=>{const t=[{id:"chat",label:"Chat",icon:xl},{id:"agentMesh",label:"Agents",icon:Zl}];return((e==null?void 0:e.projects)??!1)&&t.push({id:"projects",label:"Projects",icon:Zg}),((e==null?void 0:e.promptLibrary)??!1)&&t.push({id:"prompts",label:"Prompts",icon:ts,badge:"EXPERIMENTAL"}),t},eg=[{id:"theme-toggle",label:"Theme",icon:Hg,onClick:()=>{}}],vs=({title:e,breadcrumbs:t,tabs:n,buttons:r,leadingAction:o})=>s.jsxs("div",{className:"relative flex max-h-[80px] min-h-[80px] w-full items-center border-b px-8",children:[t&&t.length>0&&s.jsx("div",{className:"absolute top-1 left-8 flex h-8 items-center",children:t.map((a,i)=>s.jsxs(Rt.Fragment,{children:[i>0&&s.jsx("span",{className:"mx-1",children:s.jsx(vC,{size:16})}),a.onClick?s.jsx(xe,{variant:"link",className:"m-0 p-0",onClick:a.onClick,children:a.label}):s.jsx("div",{className:"max-w-[150px] truncate",children:a.label})]},i))}),o&&s.jsx("div",{className:"mr-4 flex items-center pt-[35px]",children:o}),s.jsx("div",{className:"max-w-lg truncate pt-[35px] text-xl",children:e}),n&&n.length>0&&s.jsx("div",{className:"ml-8 flex items-center pt-[35px]",role:"tablist",children:n.map((a,i)=>s.jsxs("button",{role:"tab","aria-selected":a.isActive,onClick:a.onClick,className:`relative cursor-pointer px-4 py-3 font-medium transition-colors duration-200 ${a.isActive?"border-b-2 border-[var(--color-brand-wMain)] font-semibold":""} ${i>0?"ml-6":""}`,children:[a.label,a.isActive&&s.jsx("div",{className:"absolute right-0 bottom-0 left-0 h-0.5"})]},a.id))}),s.jsx("div",{className:"flex-1"}),r&&r.length>0&&s.jsx("div",{className:"flex items-center gap-2 pt-[35px]",children:r.map((a,i)=>s.jsx(Rt.Fragment,{children:a},i))})]});function AD(){const{agents:e,agentsLoading:t,agentsError:n,agentsRefetch:r}=Ft(),[o,a]=d.useState("cards"),i=()=>{if(o===Hm.CARDS)return s.jsx(Ad,{agents:e});const l=r1.getPluginById(o);return l?l.render({agents:e}):(console.warn(`Layout ${o} not found, falling back to cards layout`),s.jsx(Ad,{agents:e}))};return s.jsxs("div",{className:"flex h-full w-full flex-col",children:[s.jsx(vs,{title:"Agents",buttons:[s.jsxs(xe,{"data-testid":"refreshAgents",disabled:t,variant:"ghost",title:"Refresh Agents",onClick:()=>r(),children:[s.jsx(Gl,{className:"size-4"}),"Refresh Agents"]})]}),t?s.jsx(Lr,{title:"Loading agents...",variant:"loading"}):n?s.jsx(Lr,{variant:"error",title:"Error loading agents",subtitle:n}):s.jsxs("div",{className:`relative flex-1 p-4 ${o===Hm.CARDS?"":"bg-[var(--muted)] dark:bg-[var(--color-bg-wMain)]"}`,children:[s.jsx("div",{className:"absolute right-8 z-20 flex items-center space-x-4",children:s.jsx(uM,{currentLayout:o,onLayoutChange:a})}),i()]})]})}const ID=Rt.memo(({open:e,onCancel:t,onConfirm:n,sessionName:r})=>s.jsx(Vo,{open:e,onOpenChange:o=>!o&&t(),title:"Delete Chat",content:s.jsxs(s.Fragment,{children:["This action cannot be undone. This chat session and any associated artifacts will be permanently deleted: ",s.jsx("strong",{children:r})]}),actionLabels:{confirm:"Delete"},onConfirm:n})),Yi=4,Dd={chatPanelSizes:{default:50,min:30,max:96},sidePanelSizes:{default:50,min:20,max:70}},RD={chatPanelSizes:{...Dd.chatPanelSizes,min:50},sidePanelSizes:{...Dd.sidePanelSizes,max:50}};function PD(){var G;const{activeProject:e}=ko(),{currentTheme:t}=di(),{agents:n,sessionName:r,messages:o,isSidePanelCollapsed:a,setIsSidePanelCollapsed:i,openSidePanelTab:l,setTaskIdInSidePanel:c,isResponding:u,latestStatusText:f,isLoadingSession:h,sessionToDelete:m,closeSessionDeleteModal:p,confirmSessionDelete:x,currentTaskId:g}=Ft(),{isTaskMonitorConnected:w,isTaskMonitorConnecting:v,taskMonitorSseError:b,connectTaskMonitorStream:C}=Hf(),[S,E]=d.useState(!0),[_,j]=d.useState(!1),A=d.useRef(null),P=d.useRef(null),O=d.useRef(null),{chatPanelSizes:B,sidePanelSizes:N}=d.useMemo(()=>S?Dd:RD,[S]),M=d.useCallback(V=>{if(j(!0),P.current)if(V)P.current.resize(Yi);else{const Q=O.current||N.default;P.current.resize(Q)}setTimeout(()=>j(!1),300)},[N.default]),y=d.useCallback(()=>{i(!0)},[i]),T=d.useCallback(()=>{i(!1)},[i]),R=d.useCallback(V=>{V>Yi+1&&(O.current=V)},[]),z=d.useCallback(()=>{E(!S)},[S]),F=void 0,I=d.useMemo(()=>r||"New Chat",[r]);d.useEffect(()=>{P.current&&a&&P.current.resize(Yi);const V=()=>{if(P.current&&a){j(!0);const Q=O.current||N.default;P.current.resize(Q),i(!1),setTimeout(()=>j(!1),300)}};return window.addEventListener("expand-side-panel",V),()=>{window.removeEventListener("expand-side-panel",V)}},[a,i,N.default]);const J=d.useMemo(()=>{const V=new Map;return o.forEach((Q,X)=>{Q.taskId&&V.set(Q.taskId,X)}),V},[o]),L=d.useMemo(()=>o.find(V=>V.isStatusBubble),[o]),D=d.useMemo(()=>{if(!L||!L.parts)return null;const V=L.parts.find(Q=>Q.kind==="text");return(V==null?void 0:V.text)||null},[L]),W=d.useMemo(()=>{if(g)return()=>{c(g),l("workflow")}},[g,c,l]);return d.useEffect(()=>{const V=()=>{!w&&!v&&b&&(console.log("ChatPage: Window focused while disconnected, attempting reconnection..."),C())};return window.addEventListener("focus",V),()=>{window.removeEventListener("focus",V)}},[w,v,b,C]),s.jsxs("div",{className:"relative flex h-screen w-full flex-col overflow-hidden",children:[s.jsx("div",{className:`absolute top-0 left-0 z-20 h-screen transition-transform duration-300 ${S?"-translate-x-full":"translate-x-0"}`,children:s.jsx(VM,{onToggle:z})}),s.jsx("div",{className:`transition-all duration-300 ${S?"ml-0":"ml-100"}`,children:s.jsx(vs,{title:s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsxs(vo,{delayDuration:300,children:[s.jsx(wo,{className:"font-inherit max-w-[400px] cursor-default truncate border-0 bg-transparent p-0 text-left text-inherit hover:bg-transparent",children:I}),s.jsx(bo,{side:"bottom",children:s.jsx("p",{children:I})})]}),e&&s.jsx(zr,{variant:"outline",className:"bg-primary/10 border-primary/30 text-primary max-w-[200px] px-2 py-0.5 text-xs font-semibold shadow-sm",title:e.name,children:s.jsx("span",{className:"block truncate text-left",children:e.name})})]}),breadcrumbs:F,leadingAction:S?s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(xe,{"data-testid":"showSessionsPanel",variant:"ghost",onClick:z,className:"h-10 w-10 p-0",tooltip:"Show Chat Sessions",children:s.jsx(Vg,{className:"size-5"})}),s.jsx("div",{className:"h-6 border-r"}),s.jsx(s1,{})]}):null})}),s.jsx("div",{className:"flex min-h-0 flex-1",children:s.jsx("div",{className:`min-h-0 flex-1 overflow-x-auto transition-all duration-300 ${S?"ml-0":"ml-100"}`,children:s.jsxs(_w,{direction:"horizontal",autoSaveId:"chat-side-panel",className:"h-full",children:[s.jsx(Il,{defaultSize:B.default,minSize:B.min,maxSize:B.max,id:"chat-panel",style:{backgroundColor:t==="dark"?"var(--color-background-w100)":"var(--color-background-w20)"},children:s.jsx("div",{className:"flex h-full w-full flex-col",children:s.jsx("div",{className:"flex min-h-0 flex-1 flex-col py-6",children:h?s.jsx("div",{className:"flex h-full items-center justify-center",children:s.jsx(no,{size:"medium",variant:"primary",children:s.jsx("p",{className:"text-muted-foreground mt-4 text-sm",children:"Loading session..."})})}):s.jsxs(s.Fragment,{children:[s.jsx(ny,{className:"text-base",ref:A,children:o.map((V,Q)=>{var q;const X=!!(V.taskId&&J.get(V.taskId)===Q),K=((q=V.metadata)==null?void 0:q.messageId)||`temp-${Q}`;return s.jsx(bM,{message:V,isLastWithTaskId:X},K)})}),s.jsxs("div",{style:ty,children:[u&&s.jsx(Rd,{statusText:(D||f.current)??void 0,onViewWorkflow:W}),s.jsx(C4,{agents:n,scrollToBottom:(G=A.current)==null?void 0:G.scrollToBottom})]})]})})})}),s.jsx(kw,{}),s.jsx(Il,{ref:P,defaultSize:N.default,minSize:N.min,maxSize:N.max,collapsedSize:Yi,collapsible:!0,onCollapse:y,onExpand:T,onResize:R,id:"chat-side-panel",className:_?"transition-all duration-300 ease-in-out":"",children:s.jsx("div",{className:"h-full",children:s.jsx(BM,{onCollapsedToggle:M,isSidePanelCollapsed:a,setIsSidePanelCollapsed:i,isSidePanelTransitioning:_})})})]})})}),s.jsx(ID,{open:!!m,onCancel:p,onConfirm:x,sessionName:(m==null?void 0:m.name)||""})]})}const MD=({prompt:e,isSelected:t,onPromptClick:n,onEdit:r,onDelete:o,onViewVersions:a,onUseInChat:i,onTogglePin:l,onExport:c})=>{const{configFeatureEnablement:u}=Ut(),f=(u==null?void 0:u.promptVersionHistory)??!0,[h,m]=d.useState(!1),p=f&&a,x=S=>{S.stopPropagation(),m(!1),r(e)},g=S=>{S.stopPropagation(),m(!1),o(e.id,e.name)},w=S=>{S.stopPropagation(),m(!1),a&&a(e)},v=S=>{S.stopPropagation(),m(!1),i&&i(e)},b=S=>{S.stopPropagation(),l&&l(e.id,e.isPinned)},C=S=>{S.stopPropagation(),m(!1),c&&c(e)};return s.jsx(Ic,{"data-testid":e.id,isSelected:t,onClick:n,children:s.jsxs("div",{className:"flex h-full w-full flex-col",children:[s.jsxs("div",{className:"flex items-center justify-between px-4",children:[s.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[s.jsx(ts,{className:"h-6 w-6 flex-shrink-0 text-[var(--color-brand-wMain)]"}),s.jsx("div",{className:"min-w-0",children:s.jsx("h2",{className:"truncate text-lg font-semibold",title:e.name,children:e.name})})]}),s.jsxs("div",{className:"flex items-center gap-1",children:[l&&s.jsx(xe,{variant:"ghost",size:"icon",onClick:b,className:e.isPinned?"text-primary":"text-muted-foreground",tooltip:e.isPinned?"Remove from favorites":"Add to favorites",children:s.jsx(wC,{size:16,fill:e.isPinned?"currentColor":"none"})}),s.jsxs(Qs,{open:h,onOpenChange:m,children:[s.jsx(ea,{asChild:!0,children:s.jsx(xe,{variant:"ghost",size:"icon",onClick:S=>{S.stopPropagation(),m(!h)},tooltip:"Actions",className:"cursor-pointer",children:s.jsx(Mo,{size:16})})}),s.jsxs(ta,{align:"end",onClick:S=>S.stopPropagation(),children:[i&&s.jsxs(jn,{onClick:v,children:[s.jsx(Wg,{size:14,className:"mr-2"}),"Use in New Chat"]}),c&&s.jsxs(jn,{onClick:C,children:[s.jsx(Co,{size:14,className:"mr-2"}),"Export Prompt"]}),s.jsxs(jn,{onClick:x,children:[s.jsx(ro,{size:14,className:"mr-2"}),"Edit Prompt"]}),p&&s.jsxs(jn,{onClick:w,children:[s.jsx(Gg,{size:14,className:"mr-2"}),"Open Version History"]}),s.jsxs(jn,{onClick:g,children:[s.jsx(rs,{size:14,className:"mr-2"}),"Delete All Versions"]})]})]})]})]}),s.jsxs("div",{className:"flex flex-grow flex-col overflow-hidden px-4",children:[s.jsxs("div",{className:"text-muted-foreground mb-2 text-xs",children:["By ",e.authorName||e.userId]}),s.jsx("div",{className:"mb-3 line-clamp-2 text-sm leading-5",children:e.description||"No description provided."}),s.jsx("div",{className:"mt-auto",children:s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.command&&s.jsxs("span",{className:"text-primary bg-primary/10 inline-block rounded px-2 py-0.5 font-mono text-xs",children:["/",e.command]}),e.category&&s.jsxs("span",{className:"bg-primary/10 text-primary inline-flex items-center gap-1 rounded-full px-2.5 py-0.5 text-xs font-medium",children:[s.jsx(Yg,{size:12}),e.category]})]})})]})]})})},DD=({onManualCreate:e,onAIAssisted:t,isCentered:n=!1})=>{const{configFeatureEnablement:r}=Ut(),o=(r==null?void 0:r.promptAIAssisted)??!0;return n?s.jsx("div",{className:"w-full max-w-[480px] p-8",children:s.jsxs("div",{className:"flex h-full w-full flex-col items-center justify-center gap-6",children:[s.jsxs("div",{className:"flex flex-col items-center gap-2",children:[s.jsx("h2",{className:"text-foreground text-2xl font-semibold",children:"Create New Prompt"}),s.jsx("p",{className:"text-muted-foreground text-sm",children:"Choose how you'd like to create your prompt"})]}),s.jsxs("div",{className:"flex w-full max-w-[320px] flex-col gap-3",children:[s.jsxs(xe,{"data-testid":"buildWithAIButton",onClick:t,disabled:!o,variant:"default",size:"lg",className:"w-full",children:[s.jsx(Gs,{className:"mr-2 h-4 w-4"}),"Build with AI",!o&&s.jsx("span",{className:"ml-1 text-xs",children:"(Disabled)"})]}),s.jsxs(xe,{onClick:e,variant:"outline",size:"lg",className:"w-full",children:[s.jsx(ns,{className:"mr-2 h-4 w-4"}),"Create Manually"]})]})]})}):s.jsx(Ic,{className:"border border-dashed border-[var(--color-primary-wMain)]",children:s.jsxs("div",{className:"flex h-full w-full flex-col items-center justify-center gap-4 p-6",children:[s.jsx("h3",{className:"text-center text-lg font-semibold",children:"Create New Prompt"}),s.jsxs("div",{className:"flex w-full max-w-[240px] flex-col gap-3",children:[s.jsxs(xe,{"data-testid":"buildWithAIButton",onClick:t,disabled:!o,variant:"outline",className:"w-full",children:[s.jsx(Gs,{}),"Build with AI",!o&&s.jsx("span",{className:"ml-1 text-xs",children:"(Disabled)"})]}),s.jsxs(xe,{onClick:e,variant:"ghost",className:"w-full",children:[s.jsx(ns,{}),"Create Manually"]})]})]})})},OD=({prompt:e,onClose:t,onEdit:n,onDelete:r,onViewVersions:o,onUseInChat:a,onExport:i})=>{const{configFeatureEnablement:l}=Ut(),u=((l==null?void 0:l.promptVersionHistory)??!0)&&o;if(!e)return null;const f=()=>{n(e)},h=()=>{r(e.id,e.name)},m=()=>{o&&o(e)},p=()=>{a&&a(e)},x=()=>{i&&i(e)};return s.jsxs("div",{className:"bg-background flex h-full w-full flex-col border-l",children:[s.jsxs("div",{className:"border-b p-4",children:[s.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[s.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[s.jsx(ts,{className:"text-muted-foreground h-5 w-5 flex-shrink-0"}),s.jsxs(vo,{delayDuration:300,children:[s.jsx(wo,{asChild:!0,children:s.jsx("h2",{className:"cursor-default truncate text-lg font-semibold",children:e.name})}),s.jsx(bo,{side:"bottom",children:s.jsx("p",{children:e.name})})]})]}),s.jsxs("div",{className:"ml-2 flex flex-shrink-0 items-center gap-1",children:[s.jsxs(Qs,{children:[s.jsx(ea,{asChild:!0,children:s.jsx(xe,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",tooltip:"Actions",children:s.jsx(Mo,{className:"h-4 w-4"})})}),s.jsxs(ta,{align:"end",children:[i&&s.jsxs(jn,{onClick:x,children:[s.jsx(Co,{size:14,className:"mr-2"}),"Export Prompt"]}),s.jsxs(jn,{onClick:f,children:[s.jsx(ro,{size:14,className:"mr-2"}),"Edit Prompt"]}),u&&s.jsxs(jn,{onClick:m,children:[s.jsx(Gg,{size:14,className:"mr-2"}),"Open Version History"]}),s.jsxs(jn,{onClick:h,children:[s.jsx(rs,{size:14,className:"mr-2"}),"Delete All Versions"]})]})]}),s.jsx(xe,{variant:"ghost",size:"sm",onClick:t,className:"h-8 w-8 p-0",tooltip:"Close",children:s.jsx(po,{className:"h-4 w-4"})})]})]}),e.category&&s.jsxs("span",{className:"bg-primary/10 text-primary inline-flex items-center gap-1 rounded-full px-2.5 py-0.5 text-xs font-medium",children:[s.jsx(Yg,{size:12}),e.category]})]}),s.jsxs("div",{className:"flex-1 space-y-6 overflow-y-auto p-4",children:[s.jsxs("div",{className:"bg-muted/50 space-y-6 rounded p-4",children:[s.jsxs("div",{children:[s.jsx("h3",{className:"text-muted-foreground mb-2 text-xs font-semibold",children:"Description"}),s.jsx("div",{className:"text-sm leading-relaxed",children:e.description||"No description provided."})]}),e.command&&s.jsxs("div",{children:[s.jsx("h3",{className:"text-muted-foreground mb-2 text-xs font-semibold",children:"Chat Shortcut"}),s.jsx("div",{children:s.jsxs("span",{className:"text-primary bg-primary/10 inline-block rounded px-2 py-0.5 font-mono text-xs",children:["/",e.command]})})]})]}),a&&s.jsxs(xe,{"data-testid":"startNewChatButton",onClick:p,className:"w-full",children:[s.jsx(Bg,{className:"h-4 w-4"}),"Use in New Chat"]}),e.productionPrompt&&s.jsxs("div",{children:[s.jsx("h3",{className:"text-muted-foreground mb-2 text-xs font-semibold",children:"Content"}),s.jsx("div",{className:"font-mono text-xs break-words whitespace-pre-wrap",children:e.productionPrompt.promptText.split(/(\{\{[^}]+\}\})/g).map((g,w)=>g.match(/\{\{[^}]+\}\}/)?s.jsx("span",{className:"bg-primary/20 text-primary rounded px-1 font-medium",children:g},w):s.jsx("span",{children:g},w))})]})]}),s.jsxs("div",{className:"bg-background space-y-2 border-t p-4",children:[s.jsxs("div",{className:"text-muted-foreground flex items-center gap-2 text-xs",children:[s.jsx(vl,{size:12}),s.jsxs("span",{children:["Created by: ",e.authorName||e.userId]})]}),e.updatedAt&&s.jsxs("div",{className:"text-muted-foreground flex items-center gap-2 text-xs",children:[s.jsx(Kg,{size:12}),s.jsxs("span",{children:["Last updated: ",Qu(e.updatedAt)]})]})]})]})},LD=({prompts:e,onManualCreate:t,onAIAssisted:n,onEdit:r,onDelete:o,onViewVersions:a,onUseInChat:i,onTogglePin:l,onExport:c,newlyCreatedPromptId:u})=>{const[f,h]=d.useState(null),[m,p]=d.useState(""),[x,g]=d.useState([]),[w,v]=d.useState(!1),b=d.useRef(new Map),{configFeatureEnablement:C}=Ut(),S=(C==null?void 0:C.promptAIAssisted)??!0,E=T=>{h(R=>(R==null?void 0:R.id)===T.id?null:T)},_=()=>{h(null)},j=d.useMemo(()=>{const T=new Set;return e.forEach(R=>{R.category&&T.add(R.category)}),Array.from(T).sort()},[e]),A=d.useMemo(()=>e.filter(R=>{var I,J,L;const z=((I=R.name)==null?void 0:I.toLowerCase().includes(m.toLowerCase()))||((J=R.description)==null?void 0:J.toLowerCase().includes(m.toLowerCase()))||((L=R.command)==null?void 0:L.toLowerCase().includes(m.toLowerCase())),F=x.length===0||R.category&&x.includes(R.category);return z&&F}).sort((R,z)=>{if(R.isPinned!==z.isPinned)return R.isPinned?-1:1;const F=(R.name||"").toLowerCase(),I=(z.name||"").toLowerCase();return F.localeCompare(I)}),[e,m,x]),P=T=>{g(R=>R.includes(T)?R.filter(z=>z!==T):[...R,T])},O=()=>{g([])},B=()=>{p(""),g([])},N=m.length>0||x.length>0,M=e.length===0;d.useEffect(()=>{if(u&&e.length>0){const T=e.find(R=>R.id===u);T&&(h(T),setTimeout(()=>{const R=b.current.get(u);R&&R.scrollIntoView({behavior:"smooth",block:"center"})},100))}},[u,e]);const y=d.useMemo(()=>{const T=[];return S&&T.push({icon:s.jsx(Gs,{}),text:"Build with AI",variant:"default",onClick:n}),T.push({icon:s.jsx(ns,{}),text:"Create Manually",variant:"outline",onClick:t}),T},[S,n,t]);return s.jsx("div",{className:"absolute inset-0 h-full w-full",children:s.jsxs(_w,{id:"promptCardsPanelGroup",direction:"horizontal",className:"h-full",children:[s.jsx(Il,{defaultSize:f?70:100,minSize:50,maxSize:100,id:"promptCardsMainPanel",children:s.jsxs("div",{className:"flex h-full flex-col pt-6 pb-6 pl-6",children:[!M&&s.jsxs("div",{className:"mb-4 flex items-center gap-2",children:[s.jsx(Nf,{value:m,onChange:p,placeholder:"Filter by name...",testid:"promptSearchInput"}),j.length>0&&s.jsxs("div",{className:"relative",children:[s.jsxs(xe,{onClick:()=>v(!w),variant:"outline",testid:"promptTags",children:[s.jsx(bC,{size:16}),"Tags",x.length>0&&s.jsx("span",{className:"bg-primary text-primary-foreground rounded-full px-2 py-0.5 text-xs",children:x.length})]}),w&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>v(!1)}),s.jsxs("div",{className:"bg-background absolute top-full left-0 z-20 mt-1 max-h-[300px] min-w-[200px] overflow-y-auto rounded-md border shadow-lg",children:[x.length>0&&s.jsx("div",{className:"border-b",children:s.jsxs("button",{"data-testid":"clearFiltersButton",onClick:O,className:"text-muted-foreground hover:text-foreground hover:bg-muted flex min-h-[24px] w-full cursor-pointer items-center gap-1 px-3 py-2 text-left text-xs transition-colors",children:[s.jsx(po,{size:14}),x.length===1?"Clear Filter":"Clear Filters"]})}),s.jsx("div",{className:"p-1",children:j.map(T=>s.jsxs("label",{className:"hover:bg-muted flex cursor-pointer items-center gap-2 rounded px-2 py-1.5",children:[s.jsx("input",{"data-testid":`category-checkbox-${T}`,type:"checkbox",checked:x.includes(T),onChange:()=>P(T),className:"rounded"}),s.jsx("span",{className:"text-sm",children:T})]},T))})]})]})]}),N&&s.jsxs(xe,{variant:"ghost",onClick:B,"data-testid":"clearAllFiltersButton",children:[s.jsx(po,{size:16}),"Clear All"]})]}),A.length===0&&m?s.jsx(Lr,{title:"No Prompts Match Your Filter",subtitle:"Try adjusting your filter terms.",variant:"notFound",buttons:[{text:"Clear Filter",variant:"default",onClick:()=>p("")}]}):M?s.jsx(Lr,{title:"No Prompts Found",subtitle:"Create prompts to support reusable text structures for chat interactions.",variant:"noImage",buttons:y}):s.jsx("div",{className:"flex-1 overflow-y-auto",children:s.jsxs("div",{className:"flex flex-wrap gap-6",children:[s.jsx(DD,{onManualCreate:t,onAIAssisted:n}),A.map(T=>s.jsx("div",{ref:R=>{R?b.current.set(T.id,R):b.current.delete(T.id)},children:s.jsx(MD,{prompt:T,isSelected:(f==null?void 0:f.id)===T.id,onPromptClick:()=>E(T),onEdit:r,onDelete:o,onViewVersions:a,onUseInChat:i,onTogglePin:l,onExport:c})},T.id))]})})]})}),f&&s.jsxs(s.Fragment,{children:[s.jsx(kw,{}),s.jsx(Il,{defaultSize:30,minSize:20,maxSize:50,id:"promptDetailSidePanel",children:s.jsx(OD,{prompt:f,onClose:_,onEdit:r,onDelete:o,onViewVersions:a,onUseInChat:i,onTogglePin:l,onExport:c})})]})]})})},FD=["create-template"];function $D(e){return FD.includes(e)}function zD(e){const{addNotification:t}=Ft(),[n,r]=d.useState(()=>{var g,w;return e?{name:e.name,description:e.description,category:e.category,command:e.command,promptText:((g=e.productionPrompt)==null?void 0:g.promptText)||"",detected_variables:Ks(((w=e.productionPrompt)==null?void 0:w.promptText)||"")}:{}}),[o,a]=d.useState({}),[i,l]=d.useState(!1),[c,u]=d.useState("idle"),f=d.useCallback(g=>{r(w=>{const v={...w,...g};if(g.promptText!==void 0){const b=Ks(g.promptText||"");v.detected_variables=b}return v}),a(w=>{const v={...w};return Object.keys(g).forEach(b=>{delete v[b]}),v})},[]),h=d.useCallback(async()=>{const g={};if(!n.name||n.name.trim().length===0?g.name="Template name is required":n.name.length>255&&(g.name="Template name must be less than 255 characters"),!n.command||n.command.trim().length===0?g.command="Chat shortcut is required":/^[a-zA-Z0-9_-]+$/.test(n.command)?n.command.length>50?g.command="Command must be less than 50 characters":$D(n.command)&&(g.command=`'${n.command}' is a reserved command and cannot be used`):g.command="Command can only contain letters, numbers, hyphens, and underscores",!n.promptText||n.promptText.trim().length===0)g.promptText="Prompt text is required";else{const v=Tk(n.promptText);v.valid||(g.promptText=v.error||"Invalid prompt text")}a(g);const w=Object.keys(g).length===0;return w&&t("Template is valid and ready to save!","success"),w},[n,t]),m=d.useCallback(async()=>{l(!0),u("saving");try{if(!await h())return u("error"),l(!1),null;const w={name:n.name,description:n.description||null,category:n.category||null,command:n.command||null,initial_prompt:n.promptText},v=await _n("/api/v1/prompts/groups",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(w)});return u("success"),t("Template saved","success"),l(!1),v.id}catch(g){console.error("Error saving template:",g),u("error"),l(!1);const w=Yt(g,"Failed to save template");return a(v=>({...v,_general:w})),null}},[n,h,t]),p=d.useCallback(async(g,w)=>{var v;l(!0),u("saving");try{if(!await h())return u("error"),l(!1),!1;const C=n.promptText!==((v=e==null?void 0:e.productionPrompt)==null?void 0:v.promptText),S=(e==null?void 0:e._isEditingActiveVersion)??!0,E=(e==null?void 0:e._editingPromptId)||(e==null?void 0:e.productionPromptId);if(w){const _={};return n.name!==(e==null?void 0:e.name)&&(_.name=n.name),n.description!==(e==null?void 0:e.description)&&(_.description=n.description),n.category!==(e==null?void 0:e.category)&&(_.category=n.category),n.command!==(e==null?void 0:e.command)&&(_.command=n.command),_.initial_prompt=n.promptText,await vn(`/api/v1/prompts/groups/${g}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(_)}),u("success"),t(C?"New version created and activated":"Changes saved","success"),l(!1),!0}else{if(n.name!==(e==null?void 0:e.name)||n.description!==(e==null?void 0:e.description)||n.category!==(e==null?void 0:e.category)||n.command!==(e==null?void 0:e.command)){const A={};n.name!==(e==null?void 0:e.name)&&(A.name=n.name),n.description!==(e==null?void 0:e.description)&&(A.description=n.description),n.category!==(e==null?void 0:e.category)&&(A.category=n.category),n.command!==(e==null?void 0:e.command)&&(A.command=n.command),await vn(`/api/v1/prompts/groups/${g}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(A)})}return C&&E&&await vn(`/api/v1/prompts/${E}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({promptText:n.promptText})}),u("success"),t(S?"Active version updated":"Version updated","success"),l(!1),!0}}catch(b){console.error("Error updating template:",b),u("error"),l(!1);const C=Yt(b,"Failed to update template");return a(S=>({...S,_general:C})),!1}},[n,e,h,t]),x=d.useCallback(()=>{r({}),a({}),u("idle")},[]);return{config:n,updateConfig:f,validateConfig:h,saveTemplate:m,updateTemplate:p,resetConfig:x,validationErrors:o,isLoading:i,saveStatus:c}}const UD=({onConfigUpdate:e,currentConfig:t,onReadyToSave:n,initialMessage:r,isEditing:o=!1})=>{const[a,i]=d.useState([]),[l,c]=d.useState(""),[u,f]=d.useState(!1),[h,m]=d.useState(!0),[p,x]=d.useState(!1),g=d.useRef(null),w=d.useRef(null),v=d.useRef(!1),{settings:b}=Bo(),{configFeatureEnablement:C}=Ut(),S=(C==null?void 0:C.speechToText)??!0,[E,_]=d.useState(null),[j,A]=d.useState(!1),P=()=>{var y;(y=g.current)==null||y.scrollIntoView({behavior:"smooth"})};d.useEffect(()=>{P()},[a]),d.useEffect(()=>{if(v.current)return;v.current=!0,(async()=>{try{const R=await(await pt("/api/v1/prompts/chat/init")).json(),z=o?"Hi! I'll help you edit this prompt template. What changes would you like to make?":R.message;if(i([{role:"assistant",content:z,timestamp:new Date}]),r){x(!0);const F={role:"user",content:r,timestamp:new Date};i(I=>[...I,F]),setTimeout(()=>P(),100),f(!0);try{const I=await pt("/api/v1/prompts/chat",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({message:r,conversation_history:[{role:"assistant",content:R.message}],current_template:t})});if(I.ok){const J=await I.json(),L={role:"assistant",content:J.message,timestamp:new Date};i(D=>[...D,L]),Object.keys(J.template_updates).length>0&&e(J.template_updates),n(J.ready_to_save),setTimeout(()=>P(),100)}else{const J=await I.json().catch(()=>({}));console.error("Prompt builder API error:",J);const L={role:"assistant",content:"The conversation history is too long for automatic processing. Please describe your task manually, and I'll help you create a template.",timestamp:new Date};i(D=>[...D,L])}}catch(I){console.error("Error sending initial message:",I);const J={role:"assistant",content:"I encountered an error processing your request. Please try describing your task manually.",timestamp:new Date};i(L=>[...L,J])}finally{f(!1)}}}catch(T){console.error("Failed to initialize chat:",T),i([{role:"assistant",content:o?"Hi! I'll help you edit this prompt template. What changes would you like to make?":"Hi! I'll help you create a prompt template. What kind of recurring task would you like to template?",timestamp:new Date}])}finally{m(!1)}})()},[]),d.useEffect(()=>{!h&&!u&&w.current&&w.current.focus()},[h,u]),d.useEffect(()=>{const y=w.current;if(!y)return;(()=>{y.style.height="auto";const R=Math.min(y.scrollHeight,200);y.style.height=`${R}px`})()},[l]);const O=d.useCallback(y=>{const T=l?`${l} ${y}`:y;c(T),setTimeout(()=>{var R;(R=w.current)==null||R.focus()},100)},[l]),B=d.useCallback(y=>{_(y)},[]),N=async()=>{if(!l.trim()||u)return;const y={role:"user",content:l.trim(),timestamp:new Date};i(T=>[...T,y]),c(""),f(!0),x(!0);try{const T=await pt("/api/v1/prompts/chat",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({message:y.content,conversation_history:a.filter(F=>F.content&&F.content.trim().length>0).map(F=>({role:F.role,content:F.content})),current_template:t})});if(!T.ok)throw new Error("Failed to get response");const R=await T.json(),z={role:"assistant",content:R.message,timestamp:new Date};i(F=>[...F,z]),Object.keys(R.template_updates).length>0&&e(R.template_updates),n(R.ready_to_save)}catch(T){console.error("Error sending message:",T);const R={role:"assistant",content:"I encountered an error. Could you please try again?",timestamp:new Date};i(z=>[...z,R])}finally{f(!1),setTimeout(()=>{var T;return(T=w.current)==null?void 0:T.focus()},100)}},M=y=>{y.preventDefault(),N()};return h?s.jsx("div",{className:"flex h-full items-center justify-center",children:s.jsxs("div",{className:"flex flex-col items-center gap-3",children:[s.jsx(fr,{className:"text-primary h-8 w-8 animate-spin"}),s.jsx("p",{className:"text-muted-foreground text-sm",children:"Initializing AI assistant..."})]})}):s.jsxs("div",{className:"flex h-full flex-col",children:[s.jsx("div",{className:"border-b px-4 py-3",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:"bg-primary/10 flex h-8 w-8 items-center justify-center rounded-full",children:s.jsx(Gs,{className:"text-primary h-4 w-4"})}),s.jsx("h3",{className:"text-sm font-semibold",children:"AI Template Builder"})]})}),s.jsxs("div",{className:"flex-1 space-y-4 overflow-y-auto p-4",children:[a.map((y,T)=>s.jsx("div",{className:`flex ${y.role==="user"?"justify-end":"justify-start"}`,children:s.jsx("div",{className:`max-w-[80%] rounded-2xl px-4 py-3 ${y.role==="user"?"bg-[var(--message-background)]":""}`,children:s.jsx("div",{className:"text-sm leading-relaxed whitespace-pre-wrap",children:y.content})})},T)),u&&s.jsx("div",{className:"flex justify-start",children:s.jsxs("div",{className:"flex items-center gap-2 rounded-2xl px-4 py-3",children:[s.jsx(fr,{className:"h-4 w-4 animate-spin"}),s.jsx("span",{className:"text-muted-foreground text-sm",children:"Thinking..."})]})}),s.jsx("div",{ref:g})]}),s.jsxs("div",{className:"bg-background border-t p-4",children:[E&&s.jsx("div",{className:"mb-3",children:s.jsx(Kt,{variant:"error",message:E,dismissible:!0,onDismiss:()=>_(null)})}),s.jsxs("form",{onSubmit:M,className:"relative",children:[s.jsx(Wr,{ref:w,value:l,onChange:y=>c(y.target.value),onKeyDown:y=>{y.key==="Enter"&&!y.shiftKey&&(y.preventDefault(),N())},placeholder:j?"Recording...":p?"Type your message...":"Describe your recurring task...",disabled:u||j,className:"max-h-[200px] min-h-[40px] resize-none overflow-y-auto pr-24",rows:1,style:{height:"40px"}}),s.jsxs("div",{className:"absolute top-1/2 right-2 flex -translate-y-1/2 items-center gap-1",children:[S&&b.speechToText&&s.jsx(ah,{disabled:u,onTranscriptionComplete:O,onError:B,onRecordingStateChange:A}),s.jsx(xe,{type:"submit",disabled:!l.trim()||u,variant:"ghost",size:"icon",tooltip:"Send message",children:u?s.jsx(fr,{className:"h-4 w-4 animate-spin"}):s.jsx(Fg,{className:"h-4 w-4"})})]})]})]})]})},BD=({config:e,highlightedFields:t})=>{const n=e.promptText&&e.promptText.trim().length>0,r=d.useRef(!1),o=d.useRef([]);d.useEffect(()=>{t.length>0&&n&&(r.current||(r.current=!0)),o.current=t},[t,n]);const a=r.current&&t.length>0,i=(u,f,h,m=!1)=>{const p=t.includes(h),x=!f||f.trim().length===0;return s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(It,{className:"text-muted-foreground text-sm font-medium",children:u}),p&&a&&s.jsx(zr,{variant:"default",className:"bg-primary text-primary-foreground text-xs",children:"Updated"})]}),m?s.jsx("div",{className:"rounded p-3 text-sm",children:x?s.jsxs("span",{className:"text-muted-foreground italic",children:["No ",u.toLowerCase()," yet"]}):s.jsxs("span",{className:"text-primary font-mono",children:["/",f]})}):s.jsx("div",{className:"rounded p-3 text-sm",children:x?s.jsxs("span",{className:"text-muted-foreground italic",children:["No ",u.toLowerCase()," yet"]}):f})]})},l=()=>{const u=t.includes("promptText"),f=!e.promptText||e.promptText.trim().length===0,h=m=>m.split(/(\{\{[^}]+\}\})/g).map((x,g)=>x.match(/\{\{[^}]+\}\}/)?s.jsx("span",{className:"bg-primary/20 text-primary rounded px-1 font-medium",children:x},g):s.jsx("span",{children:x},g));return s.jsxs("div",{className:"space-y-2",children:[s.jsx("div",{className:"flex items-center gap-2",children:u&&a&&s.jsx(zr,{variant:"default",className:"bg-primary text-primary-foreground text-xs",children:"Updated"})}),s.jsx("div",{className:"min-h-[288px] w-full rounded-md px-3 py-2 font-mono text-sm whitespace-pre-wrap",children:f?s.jsx("span",{className:"text-muted-foreground italic",children:"No prompt text yet"}):h(e.promptText)})]})},c=()=>{const u=e.detected_variables||[];return u.length===0?s.jsx("div",{className:"text-muted-foreground py-2 text-sm italic",children:"No variables detected yet"}):s.jsx("div",{className:"py-2",children:s.jsx("div",{className:"flex flex-wrap gap-2",children:u.map((f,h)=>s.jsx("span",{className:"bg-primary/10 text-primary rounded px-2 py-1 font-mono text-xs",children:`{{${f}}}`},h))})})};return s.jsxs("div",{className:"flex h-full flex-col",children:[s.jsx("div",{className:"border-b px-4 py-3",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:"bg-muted flex h-8 w-8 items-center justify-center rounded-full",children:s.jsx(ts,{className:"text-muted-foreground h-4 w-4"})}),s.jsx("div",{children:s.jsx("h3",{className:"text-sm font-semibold",children:"Template Preview"})})]})}),s.jsx("div",{className:"flex-1 space-y-4 overflow-y-auto px-4",style:{paddingTop:"24px"},children:n?s.jsxs(s.Fragment,{children:[s.jsxs("div",{children:[s.jsx(Us,{className:"mb-4 text-base",children:"Basic Information"}),s.jsxs("div",{className:"space-y-6",children:[i("Name",e.name,"name"),i("Description",e.description,"description"),i("Tag",e.category,"category"),i("Chat Shortcut",e.command,"command",!0)]})]}),s.jsxs("div",{children:[s.jsx(Us,{className:"mb-4 text-base",children:"Content"}),l()]}),s.jsxs("div",{children:[s.jsx(Us,{className:"mb-4 text-base",children:"Variables"}),s.jsx("div",{className:"space-y-3",children:e.detected_variables&&e.detected_variables.length>0?s.jsxs(s.Fragment,{children:[s.jsxs("p",{className:"text-muted-foreground text-sm leading-relaxed",children:["Variables are placeholder values that make your prompt flexible and reusable. Variables are enclosed in double brackets like"," ",s.jsx("code",{className:"bg-muted rounded px-1.5 py-0.5 font-mono text-xs",children:"{{Variable Name}}"}),". You will be asked to fill in these variable values whenever you use this prompt. The prompt above has the following variables:"]}),c()]}):s.jsx("div",{className:"text-muted-foreground bg-muted/50 rounded-lg p-3 text-sm italic",children:"No variables detected yet"})})]})]}):s.jsxs("div",{className:"flex h-full flex-col items-center justify-center p-8 text-center",children:[s.jsx("div",{className:"bg-muted mb-4 flex h-16 w-16 items-center justify-center rounded-full",children:s.jsx(ts,{className:"text-muted-foreground h-8 w-8"})}),s.jsx("h3",{className:"mb-2 text-lg font-semibold",children:"No Template Yet"}),s.jsx("p",{className:"text-muted-foreground max-w-sm text-sm",children:"Start chatting with the AI assistant to create your template. The preview will update in real-time as you describe your task."})]})})]})},VD=({onBack:e,onSuccess:t,initialMessage:n,editingGroup:r,isEditing:o=!1,initialMode:a})=>{const{config:i,updateConfig:l,saveTemplate:c,updateTemplate:u,resetConfig:f,validationErrors:h,isLoading:m}=zD(r),[p,x]=d.useState(a||(o?"manual":"ai-assisted")),[g,w]=d.useState(!1),[v,b]=d.useState([]),[C,S]=d.useState(null),{allowNavigation:E,NavigationBlocker:_,setBlockingEnabled:j}=FT();d.useEffect(()=>{var R;if(r&&o){const z={name:r.name,description:r.description,category:r.category,command:r.command,promptText:((R=r.productionPrompt)==null?void 0:R.promptText)||""};l(z),S(z)}else S({name:"",description:"",category:void 0,command:"",promptText:""})},[r,o,l]),d.useEffect(()=>{var F,I,J,L;if(!C){j(!1);return}if(!!!((F=i.name)!=null&&F.trim()||(I=i.description)!=null&&I.trim()||i.category||(J=i.command)!=null&&J.trim()||(L=i.promptText)!=null&&L.trim())){j(!1);return}const z=i.name!==C.name||i.description!==C.description||i.category!==C.category||i.command!==C.command||i.promptText!==C.promptText;j(z)},[i,C,j]);const A=(R=!1)=>{R?E(()=>{f(),x("ai-assisted"),w(!1),b([]),S(null),e()}):e()},P=Object.keys(h).length>0,O=Object.values(h).filter(Boolean),B=async()=>{if(o&&r)await u(r.id,!1)&&E(()=>{A(!0),t&&t(r.id)});else{const R=await c();R&&E(()=>{A(!0),t&&t(R)})}},N=async()=>{if(!o||!r)return;await u(r.id,!0)&&E(()=>{A(!0),t&&t(r.id)})},M=R=>{const z=Object.keys(R).filter(F=>{const I=i[F],J=R[F],L=I==null||I===""?"":I,D=J==null||J===""?"":J;return L!==D});l(R),b(z)},y=()=>{x("manual"),b([])},T=()=>{x("ai-assisted"),b([])};return s.jsx(s.Fragment,{children:s.jsxs("div",{className:"flex h-full flex-col",children:[s.jsx(vs,{title:o?"Edit Prompt":"Create Prompt",breadcrumbs:[{label:"Prompts",onClick:()=>A()},{label:o?"Edit Prompt":"Create Prompt"}],buttons:p==="ai-assisted"?[s.jsxs(xe,{"data-testid":"editManuallyButton",onClick:y,variant:"ghost",size:"sm",children:[s.jsx(ro,{className:"mr-1 h-3 w-3"}),"Edit Manually"]},"edit-manually")]:[s.jsxs(xe,{"data-testid":"buildWithAIButton",onClick:T,variant:"ghost",size:"sm",children:[s.jsx(Gs,{className:"mr-1 h-3 w-3"}),o?"Edit with AI":"Build with AI"]},"build-with-ai")]}),P&&s.jsx("div",{className:"px-8 py-3",children:s.jsx(Kt,{variant:"error",message:`Please fix the following errors: ${O.join(", ")}`})}),s.jsxs("div",{className:"flex min-h-0 flex-1",children:[s.jsx("div",{className:`w-[40%] overflow-hidden border-r ${p==="manual"?"hidden":""}`,children:s.jsx(UD,{onConfigUpdate:M,currentConfig:i,onReadyToSave:w,initialMessage:n,isEditing:o})}),p==="ai-assisted"&&s.jsx("div",{className:"bg-muted/30 w-[60%] overflow-hidden",children:s.jsx(BD,{config:i,highlightedFields:v,isReadyToSave:g})}),p==="manual"&&s.jsx("div",{className:"flex-1 overflow-y-auto px-8 py-6",children:s.jsxs("div",{className:"mx-auto max-w-4xl space-y-6",children:[s.jsxs("div",{children:[s.jsx(Us,{className:"mb-4 text-base",children:"Basic Information"}),s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsxs(It,{htmlFor:"template-name",children:["Name ",s.jsx("span",{className:"text-[var(--color-primary-wMain)]",children:"*"})]}),s.jsx(br,{id:"template-name",placeholder:"e.g., Code Review Template",value:i.name||"",onChange:R=>l({name:R.target.value}),className:`placeholder:text-muted-foreground/50 ${h.name?"border-red-500":""}`}),h.name&&s.jsxs("p",{className:"flex items-center gap-1 text-sm text-red-600",children:[s.jsx(fo,{className:"h-3 w-3"}),h.name]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(It,{htmlFor:"template-description",children:"Description"}),s.jsx(br,{id:"template-description",placeholder:"e.g., Reviews code for best practices and potential issues",value:i.description||"",onChange:R=>l({description:R.target.value}),className:"placeholder:text-muted-foreground/50"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(It,{htmlFor:"template-category",children:"Tag"}),s.jsxs(Rr,{value:i.category||"none",onValueChange:R=>l({category:R==="none"?void 0:R}),children:[s.jsx(Mr,{children:s.jsx(Pr,{placeholder:"Select tag"})}),s.jsxs(Dr,{children:[s.jsx(jt,{value:"none",children:"No Tag"}),s.jsx(jt,{value:"Development",children:"Development"}),s.jsx(jt,{value:"Analysis",children:"Analysis"}),s.jsx(jt,{value:"Documentation",children:"Documentation"}),s.jsx(jt,{value:"Communication",children:"Communication"}),s.jsx(jt,{value:"Testing",children:"Testing"}),s.jsx(jt,{value:"Other",children:"Other"})]})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs(It,{htmlFor:"template-command",children:["Chat Shortcut ",s.jsx("span",{className:"text-[var(--color-primary-wMain)]",children:"*"})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-muted-foreground text-sm",children:"/"}),s.jsx(br,{id:"template-command",placeholder:"e.g., code-review",value:i.command||"",onChange:R=>l({command:R.target.value}),className:`placeholder:text-muted-foreground/50 ${h.command?"border-red-500":""}`})]}),s.jsx("p",{className:"text-muted-foreground text-xs",children:"Quick access shortcut for chat (letters, numbers, hyphens, underscores only)"})]})]})]}),s.jsxs("div",{children:[s.jsxs(Us,{className:"mb-4 text-base",children:["Content",s.jsx("span",{className:"text-[var(--color-primary-wMain)]",children:"*"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(bv,{id:"template-prompt","data-testid":"prompt-text-input",placeholder:"Enter your prompt template here. Use {{Variable Name}} for placeholders.",value:i.promptText||"",onChange:R=>l({promptText:R.target.value}),rows:12,className:`placeholder:text-muted-foreground/50 ${h.promptText?"border-red-500":""}`}),h.promptText&&s.jsxs("p",{className:"flex items-center gap-1 text-sm text-red-600",children:[s.jsx(fo,{className:"h-3 w-3"}),h.promptText]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("p",{className:"text-muted-foreground text-sm",children:["Variables are placeholder values that make your prompt flexible and reusable. You will be asked to fill in these variable values whenever you use this prompt. Use ","{{Variable Name}}"," for placeholders.",i.detected_variables&&i.detected_variables.length>0&&" Your prompt has the following variables:"]}),i.detected_variables&&i.detected_variables.length>0&&s.jsx("div",{className:"flex flex-wrap gap-2",children:i.detected_variables.map((R,z)=>s.jsx("span",{className:"bg-primary/10 text-primary rounded px-2 py-1 font-mono text-xs",children:`{{${R}}}`},z))})]})]})]})]})})]}),s.jsx(_,{}),s.jsxs("div",{className:"flex justify-end gap-2 border-t p-4",children:[s.jsx(xe,{variant:"ghost",onClick:()=>A(),disabled:m,children:o?"Discard Changes":"Cancel"}),o&&s.jsx(xe,{variant:"outline",onClick:N,disabled:m,children:m?s.jsxs(s.Fragment,{children:[s.jsx(fr,{className:"mr-2 h-4 w-4 animate-spin"}),"Saving..."]}):"Save New Version"}),s.jsx(xe,{"data-testid":"createPromptButton",onClick:B,disabled:m,children:m?s.jsxs(s.Fragment,{children:[s.jsx(fr,{className:"mr-2 h-4 w-4 animate-spin"}),o?"Saving...":"Creating..."]}):o?"Save":"Create"})]})]})})},Pu=Rt.memo(({isOpen:e,onClose:t,onConfirm:n,promptName:r})=>s.jsx(Vo,{title:"Delete Prompt",content:s.jsxs(s.Fragment,{children:["This action cannot be undone. This will permanently delete the prompt and all its versions: ",s.jsx("strong",{children:r}),"."]}),actionLabels:{confirm:"Delete"},open:e,onOpenChange:o=>!o&&t(),onConfirm:n,onCancel:t})),WD=({group:e,onBack:t,onEdit:n,onDeleteAll:r,onRestoreVersion:o})=>{const{addNotification:a,displayError:i}=Ft(),[l,c]=d.useState([]),[u,f]=d.useState(null),[h,m]=d.useState(!1),[p,x]=d.useState(e),[g,w]=d.useState(!1),v=d.useRef(!1);d.useEffect(()=>{x(e)},[e]);const b=d.useCallback(async(A=!1)=>{m(!0);try{const P=await _n(`/api/v1/prompts/groups/${e.id}/prompts`);c(P),f(O=>{if(e._selectedVersionId){const B=P.find(N=>N.id===e._selectedVersionId);if(B)return B}if(A&&O){const B=P.find(N=>N.id===O.id);return B||P.find(N=>N.id===e.productionPromptId)||P[0]}else if(P.length>0&&!v.current)return v.current=!0,P.find(B=>B.id===e.productionPromptId)||P[0];return O})}catch(P){console.error("Failed to fetch versions:",P)}finally{m(!1)}},[e.id,e.productionPromptId,e._selectedVersionId]),C=d.useCallback(async()=>{try{const A=await pt(`/api/v1/prompts/groups/${e.id}`,{credentials:"include"});if(A.ok){const P=await A.json();x(P)}}catch(A){console.error("Failed to fetch group data:",A)}},[e.id]);d.useEffect(()=>{b(!0)},[b]);const S=()=>{const A={...p,name:(u==null?void 0:u.name)||p.name,description:(u==null?void 0:u.description)||p.description,category:(u==null?void 0:u.category)||p.category,command:(u==null?void 0:u.command)||p.command,productionPrompt:u?{id:u.id,promptText:u.promptText,groupId:u.groupId,userId:u.userId,version:u.version,name:u.name,description:u.description,category:u.category,command:u.command,createdAt:u.createdAt,updatedAt:u.updatedAt}:p.productionPrompt,_editingPromptId:u==null?void 0:u.id,_isEditingActiveVersion:(u==null?void 0:u.id)===p.productionPromptId,_selectedVersionId:u==null?void 0:u.id};n(A)},E=async()=>{if(u){if(u.id===p.productionPromptId){w(!0),setTimeout(()=>w(!1),5e3);return}try{await vn(`/api/v1/prompts/${u.id}`,{method:"DELETE"}),a("Version deleted successfully","success"),f(null),await b(!1)}catch(A){i({title:"Failed to Delete Version",error:Yt(A,"An unknown error occurred while deleting the version.")})}}},_=async()=>{u&&u.id!==p.productionPromptId&&(await o(u.id),await C(),await b(!0))},j=(u==null?void 0:u.id)===p.productionPromptId;return s.jsxs("div",{className:"flex h-full flex-col",children:[s.jsx(vs,{title:`Version History: ${p.name}`,breadcrumbs:[{label:"Prompts",onClick:t},{label:"Version History"}],buttons:[s.jsxs(Qs,{children:[s.jsx(ea,{asChild:!0,children:s.jsx(xe,{variant:"ghost",size:"sm",children:s.jsx(Mo,{className:"h-4 w-4"})})}),s.jsx(ta,{align:"end",children:s.jsxs(jn,{onClick:()=>r(p.id,p.name),children:[s.jsx(rs,{size:14,className:"mr-2"}),"Delete All Versions"]})})]},"actions-menu")]}),g&&s.jsx(Kt,{variant:"error",message:"Cannot delete the active version. Please make another version active first."}),s.jsxs("div",{className:"flex min-h-0 flex-1",children:[s.jsx("div",{className:"w-[300px] overflow-y-auto border-r",children:s.jsxs("div",{className:"p-4",children:[s.jsx("h3",{className:"text-muted-foreground mb-3 text-sm font-semibold",children:"Versions"}),h?s.jsx("div",{className:"flex items-center justify-center p-8",children:s.jsx("div",{className:"border-primary size-6 animate-spin rounded-full border-2 border-t-transparent"})}):s.jsx("div",{className:"space-y-2",children:l.map(A=>{const P=A.id===p.productionPromptId,O=(u==null?void 0:u.id)===A.id;return s.jsxs("button",{"data-testid":A.id,onClick:()=>f(A),className:`w-full p-3 text-left transition-colors ${O?"bg-primary/5":"hover:bg-muted/50"}`,children:[s.jsxs("div",{className:"mb-1 flex items-center justify-between",children:[s.jsxs("span",{className:"text-sm font-medium",children:["Version ",A.version]}),P&&s.jsx("span",{className:"rounded-full bg-[var(--color-success-w20)] px-2 py-0.5 text-xs text-[var(--color-success-wMain)]",children:"Active"})]}),s.jsx("span",{className:"text-muted-foreground text-xs",children:Qu(A.createdAt)})]},A.id)})})]})}),s.jsx("div",{className:"flex-1 overflow-y-auto",children:u?s.jsx("div",{className:"p-6",children:s.jsxs("div",{className:"mx-auto max-w-4xl space-y-6",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("h2",{className:"text-lg font-semibold",children:["Version ",u.version," Details"]}),s.jsxs(Qs,{children:[s.jsx(ea,{asChild:!0,children:s.jsx(xe,{variant:"ghost",size:"sm",children:s.jsx(Mo,{className:"h-4 w-4"})})}),s.jsxs(ta,{align:"end",children:[s.jsxs(jn,{onClick:S,children:[s.jsx(ro,{size:14,className:"mr-2"}),"Edit Version"]}),!j&&s.jsxs(jn,{onClick:_,children:[s.jsx(la,{size:14,className:"mr-2"}),"Make Active Version"]}),s.jsxs(jn,{onClick:E,children:[s.jsx(rs,{size:14,className:"mr-2"}),"Delete Version"]})]})]})]}),s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(It,{className:"text-[var(--color-secondaryText-wMain)]",children:"Name"}),s.jsx("div",{className:"rounded p-3 text-sm",children:u.name||p.name})]}),(u.description||p.description)&&s.jsxs("div",{className:"space-y-2",children:[s.jsx(It,{className:"text-[var(--color-secondaryText-wMain)]",children:"Description"}),s.jsx("div",{className:"rounded p-3 text-sm",children:u.description||p.description})]}),(u.command||p.command)&&s.jsxs("div",{className:"space-y-2",children:[s.jsx(It,{className:"text-[var(--color-secondaryText-wMain)]",children:"Chat Shortcut"}),s.jsx("div",{className:"rounded p-3 text-sm",children:s.jsxs("span",{className:"text-primary font-mono",children:["/",u.command||p.command]})})]}),(u.category||p.category)&&s.jsxs("div",{className:"space-y-2",children:[s.jsx(It,{className:"text-[var(--color-secondaryText-wMain)]",children:"Tag"}),s.jsx("div",{className:"rounded p-3 text-sm",children:u.category||p.category})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(It,{className:"text-[var(--color-secondaryText-wMain)]",children:"Content"}),s.jsx("div",{className:"rounded p-3 font-mono text-sm break-words whitespace-pre-wrap",children:u.promptText.split(/(\{\{[^}]+\}\})/g).map((A,P)=>A.match(/\{\{[^}]+\}\}/)?s.jsx("span",{className:"bg-primary/20 text-primary rounded px-1 font-medium",children:A},P):s.jsx("span",{children:A},P))})]}),s.jsx("div",{className:"border-t pt-4",children:s.jsxs("div",{className:"text-muted-foreground text-xs",children:["Created: ",Qu(u.createdAt)]})})]})]})}):s.jsx("div",{className:"flex h-full items-center justify-center",children:s.jsx("p",{className:"text-muted-foreground",children:"Select a version to view details"})})})]})]})},HD=[{icon:wr,label:"Summarize a document"},{icon:yC,label:"Write me an email"},{icon:Zd,label:"Translate code"}],tg=({isOpen:e,onClose:t,onGenerate:n})=>{const[r,o]=d.useState(""),[a,i]=d.useState(!1),l=()=>{if(!r.trim()){i(!0);return}i(!1),n(r.trim()),o("")},c=h=>{o(h)},u=()=>{o(""),i(!1),t()},f=h=>{o(h.target.value),a&&h.target.value.trim()&&i(!1)};return s.jsx(On,{open:e,onOpenChange:()=>{},children:s.jsxs(Ln,{className:"sm:max-w-[600px]",children:[s.jsxs(Gn,{children:[s.jsx(Fn,{className:"text-xl",children:"Create Prompt"}),s.jsx(Yn,{className:"text-base",children:"You can generate a prompt by sharing basic details about your task. Alternatively, paste in an existing prompt and the AI will convert it into a re-usable prompt for you."})]}),a&&s.jsx(Kt,{variant:"error",message:"Please describe your task before generating a prompt.",dismissible:!0,onDismiss:()=>i(!1)}),s.jsxs("div",{className:"space-y-4 py-4",children:[s.jsx(Wr,{placeholder:"Describe your task...",value:r,onChange:f,rows:6,className:"resize-none",onKeyDown:h=>{h.key==="Enter"&&(h.metaKey||h.ctrlKey)&&l()}}),s.jsx("div",{className:"flex flex-wrap gap-2",children:HD.map((h,m)=>{const p=h.icon;return s.jsxs(zr,{variant:"outline",className:"hover:bg-primary/10 cursor-pointer px-3 py-1.5 transition-colors",onClick:()=>c(h.label),children:[s.jsx(p,{className:"mr-1.5 h-3 w-3"}),h.label]},m)})})]}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(xe,{variant:"ghost",onClick:u,children:"Cancel"}),s.jsxs(xe,{"data-testid":"generatePromptButton",onClick:l,children:[s.jsx(Gs,{className:"mr-2 h-4 w-4"}),"Generate"]})]})]})})},ng=(e,t,n)=>{if(e&&"reportValidity"in e){const r=qe(n,t);e.setCustomValidity(r&&r.message||""),e.reportValidity()}},Od=(e,t)=>{for(const n in t.fields){const r=t.fields[n];r&&r.ref&&"reportValidity"in r.ref?ng(r.ref,n,e):r&&r.refs&&r.refs.forEach(o=>ng(o,n,e))}},rg=(e,t)=>{t.shouldUseNativeValidation&&Od(e,t);const n={};for(const r in e){const o=qe(t.fields,r),a=Object.assign(e[r]||{},{ref:o&&o.ref});if(ZD(t.names||Object.keys(e),r)){const i=Object.assign({},qe(n,r));Gt(i,"root",a),Gt(n,r,i)}else Gt(n,r,a)}return n},ZD=(e,t)=>{const n=og(t);return e.some(r=>og(r).match(`^${n}\\.\\d+`))};function og(e){return e.replace(/\]|\[/g,"")}function we(e,t,n){function r(l,c){var u;Object.defineProperty(l,"_zod",{value:l._zod??{},enumerable:!1}),(u=l._zod).traits??(u.traits=new Set),l._zod.traits.add(e),t(l,c);for(const f in i.prototype)f in l||Object.defineProperty(l,f,{value:i.prototype[f].bind(l)});l._zod.constr=i,l._zod.def=c}const o=(n==null?void 0:n.Parent)??Object;class a extends o{}Object.defineProperty(a,"name",{value:e});function i(l){var c;const u=n!=null&&n.Parent?new a:this;r(u,l),(c=u._zod).deferred??(c.deferred=[]);for(const f of u._zod.deferred)f();return u}return Object.defineProperty(i,"init",{value:r}),Object.defineProperty(i,Symbol.hasInstance,{value:l=>{var c,u;return n!=null&&n.Parent&&l instanceof n.Parent?!0:(u=(c=l==null?void 0:l._zod)==null?void 0:c.traits)==null?void 0:u.has(e)}}),Object.defineProperty(i,"name",{value:e}),i}class Zs extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class p1 extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}const m1={};function fs(e){return m1}function GD(e){const t=Object.values(e).filter(r=>typeof r=="number");return Object.entries(e).filter(([r,o])=>t.indexOf(+r)===-1).map(([r,o])=>o)}function Ld(e,t){return typeof t=="bigint"?t.toString():t}function xh(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function vh(e){return e==null}function wh(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function YD(e,t){const n=(e.toString().split(".")[1]||"").length,r=t.toString();let o=(r.split(".")[1]||"").length;if(o===0&&/\d?e-\d?/.test(r)){const c=r.match(/\d?e-(\d?)/);c!=null&&c[1]&&(o=Number.parseInt(c[1]))}const a=n>o?n:o,i=Number.parseInt(e.toFixed(a).replace(".","")),l=Number.parseInt(t.toFixed(a).replace(".",""));return i%l/10**a}const sg=Symbol("evaluating");function Jt(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==sg)return r===void 0&&(r=sg,r=n()),r},set(o){Object.defineProperty(e,t,{value:o})},configurable:!0})}function ws(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function bs(...e){const t={};for(const n of e){const r=Object.getOwnPropertyDescriptors(n);Object.assign(t,r)}return Object.defineProperties({},t)}function ag(e){return JSON.stringify(e)}const g1="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Ul(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const KD=xh(()=>{var e;if(typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)!=null&&e.includes("Cloudflare")))return!1;try{const t=Function;return new t(""),!0}catch{return!1}});function Qa(e){if(Ul(e)===!1)return!1;const t=e.constructor;if(t===void 0)return!0;const n=t.prototype;return!(Ul(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function x1(e){return Qa(e)?{...e}:Array.isArray(e)?[...e]:e}const qD=new Set(["string","number","symbol"]);function aa(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Go(e,t,n){const r=new e._zod.constr(t??e._zod.def);return(!t||n!=null&&n.parent)&&(r._zod.parent=e),r}function tt(e){const t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if((t==null?void 0:t.message)!==void 0){if((t==null?void 0:t.error)!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function XD(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}const JD={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function QD(e,t){const n=e._zod.def,r=bs(e._zod.def,{get shape(){const o={};for(const a in t){if(!(a in n.shape))throw new Error(`Unrecognized key: "${a}"`);t[a]&&(o[a]=n.shape[a])}return ws(this,"shape",o),o},checks:[]});return Go(e,r)}function e6(e,t){const n=e._zod.def,r=bs(e._zod.def,{get shape(){const o={...e._zod.def.shape};for(const a in t){if(!(a in n.shape))throw new Error(`Unrecognized key: "${a}"`);t[a]&&delete o[a]}return ws(this,"shape",o),o},checks:[]});return Go(e,r)}function t6(e,t){if(!Qa(t))throw new Error("Invalid input to extend: expected a plain object");const n=e._zod.def.checks;if(n&&n.length>0)throw new Error("Object schemas containing refinements cannot be extended. Use `.safeExtend()` instead.");const o=bs(e._zod.def,{get shape(){const a={...e._zod.def.shape,...t};return ws(this,"shape",a),a},checks:[]});return Go(e,o)}function n6(e,t){if(!Qa(t))throw new Error("Invalid input to safeExtend: expected a plain object");const n={...e._zod.def,get shape(){const r={...e._zod.def.shape,...t};return ws(this,"shape",r),r},checks:e._zod.def.checks};return Go(e,n)}function r6(e,t){const n=bs(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t._zod.def.shape};return ws(this,"shape",r),r},get catchall(){return t._zod.def.catchall},checks:[]});return Go(e,n)}function o6(e,t,n){const r=bs(t._zod.def,{get shape(){const o=t._zod.def.shape,a={...o};if(n)for(const i in n){if(!(i in o))throw new Error(`Unrecognized key: "${i}"`);n[i]&&(a[i]=e?new e({type:"optional",innerType:o[i]}):o[i])}else for(const i in o)a[i]=e?new e({type:"optional",innerType:o[i]}):o[i];return ws(this,"shape",a),a},checks:[]});return Go(t,r)}function s6(e,t,n){const r=bs(t._zod.def,{get shape(){const o=t._zod.def.shape,a={...o};if(n)for(const i in n){if(!(i in a))throw new Error(`Unrecognized key: "${i}"`);n[i]&&(a[i]=new e({type:"nonoptional",innerType:o[i]}))}else for(const i in o)a[i]=new e({type:"nonoptional",innerType:o[i]});return ws(this,"shape",a),a},checks:[]});return Go(t,r)}function Ls(e,t=0){var n;if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(((n=e.issues[r])==null?void 0:n.continue)!==!0)return!0;return!1}function v1(e,t){return t.map(n=>{var r;return(r=n).path??(r.path=[]),n.path.unshift(e),n})}function Ki(e){return typeof e=="string"?e:e==null?void 0:e.message}function hs(e,t,n){var o,a,i,l,c,u;const r={...e,path:e.path??[]};if(!e.message){const f=Ki((i=(a=(o=e.inst)==null?void 0:o._zod.def)==null?void 0:a.error)==null?void 0:i.call(a,e))??Ki((l=t==null?void 0:t.error)==null?void 0:l.call(t,e))??Ki((c=n.customError)==null?void 0:c.call(n,e))??Ki((u=n.localeError)==null?void 0:u.call(n,e))??"Invalid input";r.message=f}return delete r.inst,delete r.continue,t!=null&&t.reportInput||delete r.input,r}function bh(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function ei(...e){const[t,n,r]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:r}:{...t}}const w1=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,Ld,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},yh=we("$ZodError",w1),Mc=we("$ZodError",w1,{Parent:Error});function a6(e,t=n=>n.message){const n={},r=[];for(const o of e.issues)o.path.length>0?(n[o.path[0]]=n[o.path[0]]||[],n[o.path[0]].push(t(o))):r.push(t(o));return{formErrors:r,fieldErrors:n}}function i6(e,t=n=>n.message){const n={_errors:[]},r=o=>{for(const a of o.issues)if(a.code==="invalid_union"&&a.errors.length)a.errors.map(i=>r({issues:i}));else if(a.code==="invalid_key")r({issues:a.issues});else if(a.code==="invalid_element")r({issues:a.issues});else if(a.path.length===0)n._errors.push(t(a));else{let i=n,l=0;for(;l<a.path.length;){const c=a.path[l];l===a.path.length-1?(i[c]=i[c]||{_errors:[]},i[c]._errors.push(t(a))):i[c]=i[c]||{_errors:[]},i=i[c],l++}}};return r(e),n}const Dc=e=>(t,n,r,o)=>{const a=r?Object.assign(r,{async:!1}):{async:!1},i=t._zod.run({value:n,issues:[]},a);if(i instanceof Promise)throw new Zs;if(i.issues.length){const l=new((o==null?void 0:o.Err)??e)(i.issues.map(c=>hs(c,a,fs())));throw g1(l,o==null?void 0:o.callee),l}return i.value},l6=Dc(Mc),Oc=e=>async(t,n,r,o)=>{const a=r?Object.assign(r,{async:!0}):{async:!0};let i=t._zod.run({value:n,issues:[]},a);if(i instanceof Promise&&(i=await i),i.issues.length){const l=new((o==null?void 0:o.Err)??e)(i.issues.map(c=>hs(c,a,fs())));throw g1(l,o==null?void 0:o.callee),l}return i.value},c6=Oc(Mc),Lc=e=>(t,n,r)=>{const o=r?{...r,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},o);if(a instanceof Promise)throw new Zs;return a.issues.length?{success:!1,error:new(e??yh)(a.issues.map(i=>hs(i,o,fs())))}:{success:!0,data:a.value}},u6=Lc(Mc),Fc=e=>async(t,n,r)=>{const o=r?Object.assign(r,{async:!0}):{async:!0};let a=t._zod.run({value:n,issues:[]},o);return a instanceof Promise&&(a=await a),a.issues.length?{success:!1,error:new e(a.issues.map(i=>hs(i,o,fs())))}:{success:!0,data:a.value}},d6=Fc(Mc),f6=e=>(t,n,r)=>{const o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Dc(e)(t,n,o)},h6=e=>(t,n,r)=>Dc(e)(t,n,r),p6=e=>async(t,n,r)=>{const o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Oc(e)(t,n,o)},m6=e=>async(t,n,r)=>Oc(e)(t,n,r),g6=e=>(t,n,r)=>{const o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Lc(e)(t,n,o)},x6=e=>(t,n,r)=>Lc(e)(t,n,r),v6=e=>async(t,n,r)=>{const o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Fc(e)(t,n,o)},w6=e=>async(t,n,r)=>Fc(e)(t,n,r),b6=/^[cC][^\s-]{8,}$/,y6=/^[0-9a-z]+$/,C6=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,S6=/^[0-9a-vA-V]{20}$/,_6=/^[A-Za-z0-9]{27}$/,k6=/^[a-zA-Z0-9_-]{21}$/,E6=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,j6=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,ig=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,N6=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,T6="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function A6(){return new RegExp(T6,"u")}const I6=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,R6=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,P6=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,M6=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,D6=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,b1=/^[A-Za-z0-9_-]*$/,O6=/^(?=.{1,253}\.?$)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[-0-9a-zA-Z]{0,61}[0-9a-zA-Z])?)*\.?$/,L6=/^\+(?:[0-9]){6,14}[0-9]$/,y1="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",F6=new RegExp(`^${y1}$`);function C1(e){const t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof e.precision=="number"?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function $6(e){return new RegExp(`^${C1(e)}$`)}function z6(e){const t=C1({precision:e.precision}),n=["Z"];e.local&&n.push(""),e.offset&&n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const r=`${t}(?:${n.join("|")})`;return new RegExp(`^${y1}T(?:${r})$`)}const U6=e=>{const t=e?`[\\s\\S]{${(e==null?void 0:e.minimum)??0},${(e==null?void 0:e.maximum)??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},B6=/^-?\d+$/,V6=/^-?\d+(?:\.\d+)?/,W6=/^null$/i,H6=/^[^A-Z]*$/,Z6=/^[^a-z]*$/,rr=we("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),S1={number:"number",bigint:"bigint",object:"date"},_1=we("$ZodCheckLessThan",(e,t)=>{rr.init(e,t);const n=S1[typeof t.value];e._zod.onattach.push(r=>{const o=r._zod.bag,a=(t.inclusive?o.maximum:o.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<a&&(t.inclusive?o.maximum=t.value:o.exclusiveMaximum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:n,code:"too_big",maximum:t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),k1=we("$ZodCheckGreaterThan",(e,t)=>{rr.init(e,t);const n=S1[typeof t.value];e._zod.onattach.push(r=>{const o=r._zod.bag,a=(t.inclusive?o.minimum:o.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>a&&(t.inclusive?o.minimum=t.value:o.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:n,code:"too_small",minimum:t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),G6=we("$ZodCheckMultipleOf",(e,t)=>{rr.init(e,t),e._zod.onattach.push(n=>{var r;(r=n._zod.bag).multipleOf??(r.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof n.value=="bigint"?n.value%t.value===BigInt(0):YD(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:"not_multiple_of",divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),Y6=we("$ZodCheckNumberFormat",(e,t)=>{var i;rr.init(e,t),t.format=t.format||"float64";const n=(i=t.format)==null?void 0:i.includes("int"),r=n?"int":"number",[o,a]=JD[t.format];e._zod.onattach.push(l=>{const c=l._zod.bag;c.format=t.format,c.minimum=o,c.maximum=a,n&&(c.pattern=B6)}),e._zod.check=l=>{const c=l.value;if(n){if(!Number.isInteger(c)){l.issues.push({expected:r,format:t.format,code:"invalid_type",continue:!1,input:c,inst:e});return}if(!Number.isSafeInteger(c)){c>0?l.issues.push({input:c,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,continue:!t.abort}):l.issues.push({input:c,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,continue:!t.abort});return}}c<o&&l.issues.push({origin:"number",input:c,code:"too_small",minimum:o,inclusive:!0,inst:e,continue:!t.abort}),c>a&&l.issues.push({origin:"number",input:c,code:"too_big",maximum:a,inst:e})}}),K6=we("$ZodCheckMaxLength",(e,t)=>{var n;rr.init(e,t),(n=e._zod.def).when??(n.when=r=>{const o=r.value;return!vh(o)&&o.length!==void 0}),e._zod.onattach.push(r=>{const o=r._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<o&&(r._zod.bag.maximum=t.maximum)}),e._zod.check=r=>{const o=r.value;if(o.length<=t.maximum)return;const i=bh(o);r.issues.push({origin:i,code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),q6=we("$ZodCheckMinLength",(e,t)=>{var n;rr.init(e,t),(n=e._zod.def).when??(n.when=r=>{const o=r.value;return!vh(o)&&o.length!==void 0}),e._zod.onattach.push(r=>{const o=r._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>o&&(r._zod.bag.minimum=t.minimum)}),e._zod.check=r=>{const o=r.value;if(o.length>=t.minimum)return;const i=bh(o);r.issues.push({origin:i,code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),X6=we("$ZodCheckLengthEquals",(e,t)=>{var n;rr.init(e,t),(n=e._zod.def).when??(n.when=r=>{const o=r.value;return!vh(o)&&o.length!==void 0}),e._zod.onattach.push(r=>{const o=r._zod.bag;o.minimum=t.length,o.maximum=t.length,o.length=t.length}),e._zod.check=r=>{const o=r.value,a=o.length;if(a===t.length)return;const i=bh(o),l=a>t.length;r.issues.push({origin:i,...l?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort})}}),$c=we("$ZodCheckStringFormat",(e,t)=>{var n,r;rr.init(e,t),e._zod.onattach.push(o=>{const a=o._zod.bag;a.format=t.format,t.pattern&&(a.patterns??(a.patterns=new Set),a.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=o=>{t.pattern.lastIndex=0,!t.pattern.test(o.value)&&o.issues.push({origin:"string",code:"invalid_format",format:t.format,input:o.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),J6=we("$ZodCheckRegex",(e,t)=>{$c.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Q6=we("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=H6),$c.init(e,t)}),eO=we("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=Z6),$c.init(e,t)}),tO=we("$ZodCheckIncludes",(e,t)=>{rr.init(e,t);const n=aa(t.includes),r=new RegExp(typeof t.position=="number"?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(o=>{const a=o._zod.bag;a.patterns??(a.patterns=new Set),a.patterns.add(r)}),e._zod.check=o=>{o.value.includes(t.includes,t.position)||o.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:o.value,inst:e,continue:!t.abort})}}),nO=we("$ZodCheckStartsWith",(e,t)=>{rr.init(e,t);const n=new RegExp(`^${aa(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.onattach.push(r=>{const o=r._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(n)}),e._zod.check=r=>{r.value.startsWith(t.prefix)||r.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:r.value,inst:e,continue:!t.abort})}}),rO=we("$ZodCheckEndsWith",(e,t)=>{rr.init(e,t);const n=new RegExp(`.*${aa(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.onattach.push(r=>{const o=r._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(n)}),e._zod.check=r=>{r.value.endsWith(t.suffix)||r.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:r.value,inst:e,continue:!t.abort})}}),oO=we("$ZodCheckOverwrite",(e,t)=>{rr.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class sO{constructor(t=[]){this.content=[],this.indent=0,this&&(this.args=t)}indented(t){this.indent+=1,t(this),this.indent-=1}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}const r=t.split(`
404
+ `).filter(i=>i),o=Math.min(...r.map(i=>i.length-i.trimStart().length)),a=r.map(i=>i.slice(o)).map(i=>" ".repeat(this.indent*2)+i);for(const i of a)this.content.push(i)}compile(){const t=Function,n=this==null?void 0:this.args,o=[...((this==null?void 0:this.content)??[""]).map(a=>` ${a}`)];return new t(...n,o.join(`
405
+ `))}}const aO={major:4,minor:1,patch:12},cn=we("$ZodType",(e,t)=>{var o;var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=aO;const r=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&r.unshift(e);for(const a of r)for(const i of a._zod.onattach)i(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),(o=e._zod.deferred)==null||o.push(()=>{e._zod.run=e._zod.parse});else{const a=(l,c,u)=>{let f=Ls(l),h;for(const m of c){if(m._zod.def.when){if(!m._zod.def.when(l))continue}else if(f)continue;const p=l.issues.length,x=m._zod.check(l);if(x instanceof Promise&&(u==null?void 0:u.async)===!1)throw new Zs;if(h||x instanceof Promise)h=(h??Promise.resolve()).then(async()=>{await x,l.issues.length!==p&&(f||(f=Ls(l,p)))});else{if(l.issues.length===p)continue;f||(f=Ls(l,p))}}return h?h.then(()=>l):l},i=(l,c,u)=>{if(Ls(l))return l.aborted=!0,l;const f=a(c,r,u);if(f instanceof Promise){if(u.async===!1)throw new Zs;return f.then(h=>e._zod.parse(h,u))}return e._zod.parse(f,u)};e._zod.run=(l,c)=>{if(c.skipChecks)return e._zod.parse(l,c);if(c.direction==="backward"){const f=e._zod.parse({value:l.value,issues:[]},{...c,skipChecks:!0});return f instanceof Promise?f.then(h=>i(h,l,c)):i(f,l,c)}const u=e._zod.parse(l,c);if(u instanceof Promise){if(c.async===!1)throw new Zs;return u.then(f=>a(f,r,c))}return a(u,r,c)}}e["~standard"]={validate:a=>{var i;try{const l=u6(e,a);return l.success?{value:l.data}:{issues:(i=l.error)==null?void 0:i.issues}}catch{return d6(e,a).then(c=>{var u;return c.success?{value:c.data}:{issues:(u=c.error)==null?void 0:u.issues}})}},vendor:"zod",version:1}}),Ch=we("$ZodString",(e,t)=>{var n;cn.init(e,t),e._zod.pattern=[...((n=e==null?void 0:e._zod.bag)==null?void 0:n.patterns)??[]].pop()??U6(e._zod.bag),e._zod.parse=(r,o)=>{if(t.coerce)try{r.value=String(r.value)}catch{}return typeof r.value=="string"||r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:e}),r}}),tn=we("$ZodStringFormat",(e,t)=>{$c.init(e,t),Ch.init(e,t)}),iO=we("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=j6),tn.init(e,t)}),lO=we("$ZodUUID",(e,t)=>{if(t.version){const r={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(r===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=ig(r))}else t.pattern??(t.pattern=ig());tn.init(e,t)}),cO=we("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=N6),tn.init(e,t)}),uO=we("$ZodURL",(e,t)=>{tn.init(e,t),e._zod.check=n=>{try{const r=n.value.trim(),o=new URL(r);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(o.hostname)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:O6.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(o.protocol.endsWith(":")?o.protocol.slice(0,-1):o.protocol)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),t.normalize?n.value=o.href:n.value=r;return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),dO=we("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=A6()),tn.init(e,t)}),fO=we("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=k6),tn.init(e,t)}),hO=we("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=b6),tn.init(e,t)}),pO=we("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=y6),tn.init(e,t)}),mO=we("$ZodULID",(e,t)=>{t.pattern??(t.pattern=C6),tn.init(e,t)}),gO=we("$ZodXID",(e,t)=>{t.pattern??(t.pattern=S6),tn.init(e,t)}),xO=we("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=_6),tn.init(e,t)}),vO=we("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=z6(t)),tn.init(e,t)}),wO=we("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=F6),tn.init(e,t)}),bO=we("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=$6(t)),tn.init(e,t)}),yO=we("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=E6),tn.init(e,t)}),CO=we("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=I6),tn.init(e,t),e._zod.onattach.push(n=>{const r=n._zod.bag;r.format="ipv4"})}),SO=we("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=R6),tn.init(e,t),e._zod.onattach.push(n=>{const r=n._zod.bag;r.format="ipv6"}),e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}}}),_O=we("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=P6),tn.init(e,t)}),kO=we("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=M6),tn.init(e,t),e._zod.check=n=>{const r=n.value.split("/");try{if(r.length!==2)throw new Error;const[o,a]=r;if(!a)throw new Error;const i=Number(a);if(`${i}`!==a)throw new Error;if(i<0||i>128)throw new Error;new URL(`http://[${o}]`)}catch{n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}}});function E1(e){if(e==="")return!0;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const EO=we("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=D6),tn.init(e,t),e._zod.onattach.push(n=>{n._zod.bag.contentEncoding="base64"}),e._zod.check=n=>{E1(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});function jO(e){if(!b1.test(e))return!1;const t=e.replace(/[-_]/g,r=>r==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return E1(n)}const NO=we("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=b1),tn.init(e,t),e._zod.onattach.push(n=>{n._zod.bag.contentEncoding="base64url"}),e._zod.check=n=>{jO(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),TO=we("$ZodE164",(e,t)=>{t.pattern??(t.pattern=L6),tn.init(e,t)});function AO(e,t=null){try{const n=e.split(".");if(n.length!==3)return!1;const[r]=n;if(!r)return!1;const o=JSON.parse(atob(r));return!("typ"in o&&(o==null?void 0:o.typ)!=="JWT"||!o.alg||t&&(!("alg"in o)||o.alg!==t))}catch{return!1}}const IO=we("$ZodJWT",(e,t)=>{tn.init(e,t),e._zod.check=n=>{AO(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),j1=we("$ZodNumber",(e,t)=>{cn.init(e,t),e._zod.pattern=e._zod.bag.pattern??V6,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}const o=n.value;if(typeof o=="number"&&!Number.isNaN(o)&&Number.isFinite(o))return n;const a=typeof o=="number"?Number.isNaN(o)?"NaN":Number.isFinite(o)?void 0:"Infinity":void 0;return n.issues.push({expected:"number",code:"invalid_type",input:o,inst:e,...a?{received:a}:{}}),n}}),RO=we("$ZodNumber",(e,t)=>{Y6.init(e,t),j1.init(e,t)}),PO=we("$ZodNull",(e,t)=>{cn.init(e,t),e._zod.pattern=W6,e._zod.values=new Set([null]),e._zod.parse=(n,r)=>{const o=n.value;return o===null||n.issues.push({expected:"null",code:"invalid_type",input:o,inst:e}),n}}),MO=we("$ZodUnknown",(e,t)=>{cn.init(e,t),e._zod.parse=n=>n}),DO=we("$ZodNever",(e,t)=>{cn.init(e,t),e._zod.parse=(n,r)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function lg(e,t,n){e.issues.length&&t.issues.push(...v1(n,e.issues)),t.value[n]=e.value}const OO=we("$ZodArray",(e,t)=>{cn.init(e,t),e._zod.parse=(n,r)=>{const o=n.value;if(!Array.isArray(o))return n.issues.push({expected:"array",code:"invalid_type",input:o,inst:e}),n;n.value=Array(o.length);const a=[];for(let i=0;i<o.length;i++){const l=o[i],c=t.element._zod.run({value:l,issues:[]},r);c instanceof Promise?a.push(c.then(u=>lg(u,n,i))):lg(c,n,i)}return a.length?Promise.all(a).then(()=>n):n}});function Bl(e,t,n,r){e.issues.length&&t.issues.push(...v1(n,e.issues)),e.value===void 0?n in r&&(t.value[n]=void 0):t.value[n]=e.value}function N1(e){var r,o,a,i;const t=Object.keys(e.shape);for(const l of t)if(!((i=(a=(o=(r=e.shape)==null?void 0:r[l])==null?void 0:o._zod)==null?void 0:a.traits)!=null&&i.has("$ZodType")))throw new Error(`Invalid element at key "${l}": expected a Zod schema`);const n=XD(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function T1(e,t,n,r,o,a){const i=[],l=o.keySet,c=o.catchall._zod,u=c.def.type;for(const f of Object.keys(t)){if(l.has(f))continue;if(u==="never"){i.push(f);continue}const h=c.run({value:t[f],issues:[]},r);h instanceof Promise?e.push(h.then(m=>Bl(m,n,f,t))):Bl(h,n,f,t)}return i.length&&n.issues.push({code:"unrecognized_keys",keys:i,input:t,inst:a}),e.length?Promise.all(e).then(()=>n):n}const LO=we("$ZodObject",(e,t)=>{cn.init(e,t);const n=Object.getOwnPropertyDescriptor(t,"shape");if(!(n!=null&&n.get)){const l=t.shape;Object.defineProperty(t,"shape",{get:()=>{const c={...l};return Object.defineProperty(t,"shape",{value:c}),c}})}const r=xh(()=>N1(t));Jt(e._zod,"propValues",()=>{const l=t.shape,c={};for(const u in l){const f=l[u]._zod;if(f.values){c[u]??(c[u]=new Set);for(const h of f.values)c[u].add(h)}}return c});const o=Ul,a=t.catchall;let i;e._zod.parse=(l,c)=>{i??(i=r.value);const u=l.value;if(!o(u))return l.issues.push({expected:"object",code:"invalid_type",input:u,inst:e}),l;l.value={};const f=[],h=i.shape;for(const m of i.keys){const x=h[m]._zod.run({value:u[m],issues:[]},c);x instanceof Promise?f.push(x.then(g=>Bl(g,l,m,u))):Bl(x,l,m,u)}return a?T1(f,u,l,c,r.value,e):f.length?Promise.all(f).then(()=>l):l}}),FO=we("$ZodObjectJIT",(e,t)=>{LO.init(e,t);const n=e._zod.parse,r=xh(()=>N1(t)),o=m=>{const p=new sO(["shape","payload","ctx"]),x=r.value,g=C=>{const S=ag(C);return`shape[${S}]._zod.run({ value: input[${S}], issues: [] }, ctx)`};p.write("const input = payload.value;");const w=Object.create(null);let v=0;for(const C of x.keys)w[C]=`key_${v++}`;p.write("const newResult = {};");for(const C of x.keys){const S=w[C],E=ag(C);p.write(`const ${S} = ${g(C)};`),p.write(`
406
+ if (${S}.issues.length) {
407
+ payload.issues = payload.issues.concat(${S}.issues.map(iss => ({
408
+ ...iss,
409
+ path: iss.path ? [${E}, ...iss.path] : [${E}]
410
+ })));
411
+ }
412
+
413
+
414
+ if (${S}.value === undefined) {
415
+ if (${E} in input) {
416
+ newResult[${E}] = undefined;
417
+ }
418
+ } else {
419
+ newResult[${E}] = ${S}.value;
420
+ }
421
+
422
+ `)}p.write("payload.value = newResult;"),p.write("return payload;");const b=p.compile();return(C,S)=>b(m,C,S)};let a;const i=Ul,l=!m1.jitless,u=l&&KD.value,f=t.catchall;let h;e._zod.parse=(m,p)=>{h??(h=r.value);const x=m.value;return i(x)?l&&u&&(p==null?void 0:p.async)===!1&&p.jitless!==!0?(a||(a=o(t.shape)),m=a(m,p),f?T1([],x,m,p,h,e):m):n(m,p):(m.issues.push({expected:"object",code:"invalid_type",input:x,inst:e}),m)}});function cg(e,t,n,r){for(const a of e)if(a.issues.length===0)return t.value=a.value,t;const o=e.filter(a=>!Ls(a));return o.length===1?(t.value=o[0].value,o[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(a=>a.issues.map(i=>hs(i,r,fs())))}),t)}const $O=we("$ZodUnion",(e,t)=>{cn.init(e,t),Jt(e._zod,"optin",()=>t.options.some(o=>o._zod.optin==="optional")?"optional":void 0),Jt(e._zod,"optout",()=>t.options.some(o=>o._zod.optout==="optional")?"optional":void 0),Jt(e._zod,"values",()=>{if(t.options.every(o=>o._zod.values))return new Set(t.options.flatMap(o=>Array.from(o._zod.values)))}),Jt(e._zod,"pattern",()=>{if(t.options.every(o=>o._zod.pattern)){const o=t.options.map(a=>a._zod.pattern);return new RegExp(`^(${o.map(a=>wh(a.source)).join("|")})$`)}});const n=t.options.length===1,r=t.options[0]._zod.run;e._zod.parse=(o,a)=>{if(n)return r(o,a);let i=!1;const l=[];for(const c of t.options){const u=c._zod.run({value:o.value,issues:[]},a);if(u instanceof Promise)l.push(u),i=!0;else{if(u.issues.length===0)return u;l.push(u)}}return i?Promise.all(l).then(c=>cg(c,o,e,a)):cg(l,o,e,a)}}),zO=we("$ZodIntersection",(e,t)=>{cn.init(e,t),e._zod.parse=(n,r)=>{const o=n.value,a=t.left._zod.run({value:o,issues:[]},r),i=t.right._zod.run({value:o,issues:[]},r);return a instanceof Promise||i instanceof Promise?Promise.all([a,i]).then(([c,u])=>ug(n,c,u)):ug(n,a,i)}});function Fd(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(Qa(e)&&Qa(t)){const n=Object.keys(t),r=Object.keys(e).filter(a=>n.indexOf(a)!==-1),o={...e,...t};for(const a of r){const i=Fd(e[a],t[a]);if(!i.valid)return{valid:!1,mergeErrorPath:[a,...i.mergeErrorPath]};o[a]=i.data}return{valid:!0,data:o}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const n=[];for(let r=0;r<e.length;r++){const o=e[r],a=t[r],i=Fd(o,a);if(!i.valid)return{valid:!1,mergeErrorPath:[r,...i.mergeErrorPath]};n.push(i.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function ug(e,t,n){if(t.issues.length&&e.issues.push(...t.issues),n.issues.length&&e.issues.push(...n.issues),Ls(e))return e;const r=Fd(t.value,n.value);if(!r.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(r.mergeErrorPath)}`);return e.value=r.data,e}const UO=we("$ZodEnum",(e,t)=>{cn.init(e,t);const n=GD(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=new RegExp(`^(${n.filter(o=>qD.has(typeof o)).map(o=>typeof o=="string"?aa(o):o.toString()).join("|")})$`),e._zod.parse=(o,a)=>{const i=o.value;return r.has(i)||o.issues.push({code:"invalid_value",values:n,input:i,inst:e}),o}}),BO=we("$ZodLiteral",(e,t)=>{if(cn.init(e,t),t.values.length===0)throw new Error("Cannot create literal schema with no valid values");e._zod.values=new Set(t.values),e._zod.pattern=new RegExp(`^(${t.values.map(n=>typeof n=="string"?aa(n):n?aa(n.toString()):String(n)).join("|")})$`),e._zod.parse=(n,r)=>{const o=n.value;return e._zod.values.has(o)||n.issues.push({code:"invalid_value",values:t.values,input:o,inst:e}),n}}),VO=we("$ZodTransform",(e,t)=>{cn.init(e,t),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new p1(e.constructor.name);const o=t.transform(n.value,n);if(r.async)return(o instanceof Promise?o:Promise.resolve(o)).then(i=>(n.value=i,n));if(o instanceof Promise)throw new Zs;return n.value=o,n}});function dg(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}const WO=we("$ZodOptional",(e,t)=>{cn.init(e,t),e._zod.optin="optional",e._zod.optout="optional",Jt(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),Jt(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${wh(n.source)})?$`):void 0}),e._zod.parse=(n,r)=>{if(t.innerType._zod.optin==="optional"){const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(a=>dg(a,n.value)):dg(o,n.value)}return n.value===void 0?n:t.innerType._zod.run(n,r)}}),HO=we("$ZodNullable",(e,t)=>{cn.init(e,t),Jt(e._zod,"optin",()=>t.innerType._zod.optin),Jt(e._zod,"optout",()=>t.innerType._zod.optout),Jt(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${wh(n.source)}|null)$`):void 0}),Jt(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(n,r)=>n.value===null?n:t.innerType._zod.run(n,r)}),ZO=we("$ZodDefault",(e,t)=>{cn.init(e,t),e._zod.optin="optional",Jt(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);if(n.value===void 0)return n.value=t.defaultValue,n;const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(a=>fg(a,t)):fg(o,t)}});function fg(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const GO=we("$ZodPrefault",(e,t)=>{cn.init(e,t),e._zod.optin="optional",Jt(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>(r.direction==="backward"||n.value===void 0&&(n.value=t.defaultValue),t.innerType._zod.run(n,r))}),YO=we("$ZodNonOptional",(e,t)=>{cn.init(e,t),Jt(e._zod,"values",()=>{const n=t.innerType._zod.values;return n?new Set([...n].filter(r=>r!==void 0)):void 0}),e._zod.parse=(n,r)=>{const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(a=>hg(a,e)):hg(o,e)}});function hg(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}const KO=we("$ZodCatch",(e,t)=>{cn.init(e,t),Jt(e._zod,"optin",()=>t.innerType._zod.optin),Jt(e._zod,"optout",()=>t.innerType._zod.optout),Jt(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(a=>(n.value=a.value,a.issues.length&&(n.value=t.catchValue({...n,error:{issues:a.issues.map(i=>hs(i,r,fs()))},input:n.value}),n.issues=[]),n)):(n.value=o.value,o.issues.length&&(n.value=t.catchValue({...n,error:{issues:o.issues.map(a=>hs(a,r,fs()))},input:n.value}),n.issues=[]),n)}}),qO=we("$ZodPipe",(e,t)=>{cn.init(e,t),Jt(e._zod,"values",()=>t.in._zod.values),Jt(e._zod,"optin",()=>t.in._zod.optin),Jt(e._zod,"optout",()=>t.out._zod.optout),Jt(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(n,r)=>{if(r.direction==="backward"){const a=t.out._zod.run(n,r);return a instanceof Promise?a.then(i=>qi(i,t.in,r)):qi(a,t.in,r)}const o=t.in._zod.run(n,r);return o instanceof Promise?o.then(a=>qi(a,t.out,r)):qi(o,t.out,r)}});function qi(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}const XO=we("$ZodReadonly",(e,t)=>{cn.init(e,t),Jt(e._zod,"propValues",()=>t.innerType._zod.propValues),Jt(e._zod,"values",()=>t.innerType._zod.values),Jt(e._zod,"optin",()=>t.innerType._zod.optin),Jt(e._zod,"optout",()=>t.innerType._zod.optout),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(pg):pg(o)}});function pg(e){return e.value=Object.freeze(e.value),e}const JO=we("$ZodCustom",(e,t)=>{rr.init(e,t),cn.init(e,t),e._zod.parse=(n,r)=>n,e._zod.check=n=>{const r=n.value,o=t.fn(r);if(o instanceof Promise)return o.then(a=>mg(a,n,r,e));mg(o,n,r,e)}});function mg(e,t,n,r){if(!e){const o={code:"custom",input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(o.params=r._zod.def.params),t.issues.push(ei(o))}}class QO{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...n){const r=n[0];if(this._map.set(t,r),r&&typeof r=="object"&&"id"in r){if(this._idmap.has(r.id))throw new Error(`ID ${r.id} already exists in the registry`);this._idmap.set(r.id,t)}return this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){const n=this._map.get(t);return n&&typeof n=="object"&&"id"in n&&this._idmap.delete(n.id),this._map.delete(t),this}get(t){const n=t._zod.parent;if(n){const r={...this.get(n)??{}};delete r.id;const o={...r,...this._map.get(t)};return Object.keys(o).length?o:void 0}return this._map.get(t)}has(t){return this._map.has(t)}}function e8(){return new QO}const Xi=e8();function t8(e,t){return new e({type:"string",...tt(t)})}function n8(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...tt(t)})}function gg(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...tt(t)})}function r8(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...tt(t)})}function o8(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...tt(t)})}function s8(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...tt(t)})}function a8(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...tt(t)})}function i8(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...tt(t)})}function l8(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...tt(t)})}function c8(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...tt(t)})}function u8(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...tt(t)})}function d8(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...tt(t)})}function f8(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...tt(t)})}function h8(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...tt(t)})}function p8(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...tt(t)})}function m8(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...tt(t)})}function g8(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...tt(t)})}function x8(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...tt(t)})}function v8(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...tt(t)})}function w8(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...tt(t)})}function b8(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...tt(t)})}function y8(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...tt(t)})}function C8(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...tt(t)})}function S8(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...tt(t)})}function _8(e,t){return new e({type:"string",format:"date",check:"string_format",...tt(t)})}function k8(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...tt(t)})}function E8(e,t){return new e({type:"string",format:"duration",check:"string_format",...tt(t)})}function j8(e,t){return new e({type:"number",checks:[],...tt(t)})}function N8(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...tt(t)})}function T8(e,t){return new e({type:"null",...tt(t)})}function A8(e){return new e({type:"unknown"})}function I8(e,t){return new e({type:"never",...tt(t)})}function xg(e,t){return new _1({check:"less_than",...tt(t),value:e,inclusive:!1})}function Mu(e,t){return new _1({check:"less_than",...tt(t),value:e,inclusive:!0})}function vg(e,t){return new k1({check:"greater_than",...tt(t),value:e,inclusive:!1})}function Du(e,t){return new k1({check:"greater_than",...tt(t),value:e,inclusive:!0})}function wg(e,t){return new G6({check:"multiple_of",...tt(t),value:e})}function A1(e,t){return new K6({check:"max_length",...tt(t),maximum:e})}function Vl(e,t){return new q6({check:"min_length",...tt(t),minimum:e})}function I1(e,t){return new X6({check:"length_equals",...tt(t),length:e})}function R8(e,t){return new J6({check:"string_format",format:"regex",...tt(t),pattern:e})}function P8(e){return new Q6({check:"string_format",format:"lowercase",...tt(e)})}function M8(e){return new eO({check:"string_format",format:"uppercase",...tt(e)})}function D8(e,t){return new tO({check:"string_format",format:"includes",...tt(t),includes:e})}function O8(e,t){return new nO({check:"string_format",format:"starts_with",...tt(t),prefix:e})}function L8(e,t){return new rO({check:"string_format",format:"ends_with",...tt(t),suffix:e})}function yi(e){return new oO({check:"overwrite",tx:e})}function F8(e){return yi(t=>t.normalize(e))}function $8(){return yi(e=>e.trim())}function z8(){return yi(e=>e.toLowerCase())}function U8(){return yi(e=>e.toUpperCase())}function B8(e,t,n){return new e({type:"array",element:t,...tt(n)})}function V8(e,t,n){return new e({type:"custom",check:"custom",fn:t,...tt(n)})}function W8(e){const t=H8(n=>(n.addIssue=r=>{if(typeof r=="string")n.issues.push(ei(r,n.value,t._zod.def));else{const o=r;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),o.input??(o.input=n.value),o.inst??(o.inst=t),o.continue??(o.continue=!t._zod.def.abort),n.issues.push(ei(o))}},e(n.value,n)));return t}function H8(e,t){const n=new rr({check:"custom",...tt(t)});return n._zod.check=e,n}function bg(e,t){try{var n=e()}catch(r){return t(r)}return n&&n.then?n.then(void 0,t):n}function Z8(e,t){for(var n={};e.length;){var r=e[0],o=r.code,a=r.message,i=r.path.join(".");if(!n[i])if("unionErrors"in r){var l=r.unionErrors[0].errors[0];n[i]={message:l.message,type:l.code}}else n[i]={message:a,type:o};if("unionErrors"in r&&r.unionErrors.forEach(function(f){return f.errors.forEach(function(h){return e.push(h)})}),t){var c=n[i].types,u=c&&c[r.code];n[i]=Pf(i,t,n,o,u?[].concat(u,r.message):r.message)}e.shift()}return n}function G8(e,t){for(var n={};e.length;){var r=e[0],o=r.code,a=r.message,i=r.path.join(".");if(!n[i])if(r.code==="invalid_union"&&r.errors.length>0){var l=r.errors[0][0];n[i]={message:l.message,type:l.code}}else n[i]={message:a,type:o};if(r.code==="invalid_union"&&r.errors.forEach(function(f){return f.forEach(function(h){return e.push(h)})}),t){var c=n[i].types,u=c&&c[r.code];n[i]=Pf(i,t,n,o,u?[].concat(u,r.message):r.message)}e.shift()}return n}function Y8(e,t,n){if(n===void 0&&(n={}),function(r){return"_def"in r&&typeof r._def=="object"&&"typeName"in r._def}(e))return function(r,o,a){try{return Promise.resolve(bg(function(){return Promise.resolve(e[n.mode==="sync"?"parse":"parseAsync"](r,t)).then(function(i){return a.shouldUseNativeValidation&&Od({},a),{errors:{},values:n.raw?Object.assign({},r):i}})},function(i){if(function(l){return Array.isArray(l==null?void 0:l.issues)}(i))return{values:{},errors:rg(Z8(i.errors,!a.shouldUseNativeValidation&&a.criteriaMode==="all"),a)};throw i}))}catch(i){return Promise.reject(i)}};if(function(r){return"_zod"in r&&typeof r._zod=="object"}(e))return function(r,o,a){try{return Promise.resolve(bg(function(){return Promise.resolve((n.mode==="sync"?l6:c6)(e,r,t)).then(function(i){return a.shouldUseNativeValidation&&Od({},a),{errors:{},values:n.raw?Object.assign({},r):i}})},function(i){if(function(l){return l instanceof yh}(i))return{values:{},errors:rg(G8(i.issues,!a.shouldUseNativeValidation&&a.criteriaMode==="all"),a)};throw i}))}catch(i){return Promise.reject(i)}};throw new Error("Invalid input: not a Zod schema")}const K8=we("ZodISODateTime",(e,t)=>{vO.init(e,t),on.init(e,t)});function q8(e){return S8(K8,e)}const X8=we("ZodISODate",(e,t)=>{wO.init(e,t),on.init(e,t)});function J8(e){return _8(X8,e)}const Q8=we("ZodISOTime",(e,t)=>{bO.init(e,t),on.init(e,t)});function eL(e){return k8(Q8,e)}const tL=we("ZodISODuration",(e,t)=>{yO.init(e,t),on.init(e,t)});function nL(e){return E8(tL,e)}const rL=(e,t)=>{yh.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:n=>i6(e,n)},flatten:{value:n=>a6(e,n)},addIssue:{value:n=>{e.issues.push(n),e.message=JSON.stringify(e.issues,Ld,2)}},addIssues:{value:n=>{e.issues.push(...n),e.message=JSON.stringify(e.issues,Ld,2)}},isEmpty:{get(){return e.issues.length===0}}})},_r=we("ZodError",rL,{Parent:Error}),oL=Dc(_r),sL=Oc(_r),aL=Lc(_r),iL=Fc(_r),lL=f6(_r),cL=h6(_r),uL=p6(_r),dL=m6(_r),fL=g6(_r),hL=x6(_r),pL=v6(_r),mL=w6(_r),fn=we("ZodType",(e,t)=>(cn.init(e,t),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.check=(...n)=>e.clone(bs(t,{checks:[...t.checks??[],...n.map(r=>typeof r=="function"?{_zod:{check:r,def:{check:"custom"},onattach:[]}}:r)]})),e.clone=(n,r)=>Go(e,n,r),e.brand=()=>e,e.register=(n,r)=>(n.add(e,r),e),e.parse=(n,r)=>oL(e,n,r,{callee:e.parse}),e.safeParse=(n,r)=>aL(e,n,r),e.parseAsync=async(n,r)=>sL(e,n,r,{callee:e.parseAsync}),e.safeParseAsync=async(n,r)=>iL(e,n,r),e.spa=e.safeParseAsync,e.encode=(n,r)=>lL(e,n,r),e.decode=(n,r)=>cL(e,n,r),e.encodeAsync=async(n,r)=>uL(e,n,r),e.decodeAsync=async(n,r)=>dL(e,n,r),e.safeEncode=(n,r)=>fL(e,n,r),e.safeDecode=(n,r)=>hL(e,n,r),e.safeEncodeAsync=async(n,r)=>pL(e,n,r),e.safeDecodeAsync=async(n,r)=>mL(e,n,r),e.refine=(n,r)=>e.check(iF(n,r)),e.superRefine=n=>e.check(lF(n)),e.overwrite=n=>e.check(yi(n)),e.optional=()=>_g(e),e.nullable=()=>kg(e),e.nullish=()=>_g(kg(e)),e.nonoptional=n=>eF(e,n),e.array=()=>zL(e),e.or=n=>zc([e,n]),e.and=n=>WL(e,n),e.transform=n=>Eg(e,YL(n)),e.default=n=>XL(e,n),e.prefault=n=>QL(e,n),e.catch=n=>nF(e,n),e.pipe=n=>Eg(e,n),e.readonly=()=>sF(e),e.describe=n=>{const r=e.clone();return Xi.add(r,{description:n}),r},Object.defineProperty(e,"description",{get(){var n;return(n=Xi.get(e))==null?void 0:n.description},configurable:!0}),e.meta=(...n)=>{if(n.length===0)return Xi.get(e);const r=e.clone();return Xi.add(r,n[0]),r},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e)),R1=we("_ZodString",(e,t)=>{Ch.init(e,t),fn.init(e,t);const n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,e.regex=(...r)=>e.check(R8(...r)),e.includes=(...r)=>e.check(D8(...r)),e.startsWith=(...r)=>e.check(O8(...r)),e.endsWith=(...r)=>e.check(L8(...r)),e.min=(...r)=>e.check(Vl(...r)),e.max=(...r)=>e.check(A1(...r)),e.length=(...r)=>e.check(I1(...r)),e.nonempty=(...r)=>e.check(Vl(1,...r)),e.lowercase=r=>e.check(P8(r)),e.uppercase=r=>e.check(M8(r)),e.trim=()=>e.check($8()),e.normalize=(...r)=>e.check(F8(...r)),e.toLowerCase=()=>e.check(z8()),e.toUpperCase=()=>e.check(U8())}),gL=we("ZodString",(e,t)=>{Ch.init(e,t),R1.init(e,t),e.email=n=>e.check(n8(xL,n)),e.url=n=>e.check(i8(vL,n)),e.jwt=n=>e.check(C8(PL,n)),e.emoji=n=>e.check(l8(wL,n)),e.guid=n=>e.check(gg(yg,n)),e.uuid=n=>e.check(r8(Ji,n)),e.uuidv4=n=>e.check(o8(Ji,n)),e.uuidv6=n=>e.check(s8(Ji,n)),e.uuidv7=n=>e.check(a8(Ji,n)),e.nanoid=n=>e.check(c8(bL,n)),e.guid=n=>e.check(gg(yg,n)),e.cuid=n=>e.check(u8(yL,n)),e.cuid2=n=>e.check(d8(CL,n)),e.ulid=n=>e.check(f8(SL,n)),e.base64=n=>e.check(w8(AL,n)),e.base64url=n=>e.check(b8(IL,n)),e.xid=n=>e.check(h8(_L,n)),e.ksuid=n=>e.check(p8(kL,n)),e.ipv4=n=>e.check(m8(EL,n)),e.ipv6=n=>e.check(g8(jL,n)),e.cidrv4=n=>e.check(x8(NL,n)),e.cidrv6=n=>e.check(v8(TL,n)),e.e164=n=>e.check(y8(RL,n)),e.datetime=n=>e.check(q8(n)),e.date=n=>e.check(J8(n)),e.time=n=>e.check(eL(n)),e.duration=n=>e.check(nL(n))});function ps(e){return t8(gL,e)}const on=we("ZodStringFormat",(e,t)=>{tn.init(e,t),R1.init(e,t)}),xL=we("ZodEmail",(e,t)=>{cO.init(e,t),on.init(e,t)}),yg=we("ZodGUID",(e,t)=>{iO.init(e,t),on.init(e,t)}),Ji=we("ZodUUID",(e,t)=>{lO.init(e,t),on.init(e,t)}),vL=we("ZodURL",(e,t)=>{uO.init(e,t),on.init(e,t)}),wL=we("ZodEmoji",(e,t)=>{dO.init(e,t),on.init(e,t)}),bL=we("ZodNanoID",(e,t)=>{fO.init(e,t),on.init(e,t)}),yL=we("ZodCUID",(e,t)=>{hO.init(e,t),on.init(e,t)}),CL=we("ZodCUID2",(e,t)=>{pO.init(e,t),on.init(e,t)}),SL=we("ZodULID",(e,t)=>{mO.init(e,t),on.init(e,t)}),_L=we("ZodXID",(e,t)=>{gO.init(e,t),on.init(e,t)}),kL=we("ZodKSUID",(e,t)=>{xO.init(e,t),on.init(e,t)}),EL=we("ZodIPv4",(e,t)=>{CO.init(e,t),on.init(e,t)}),jL=we("ZodIPv6",(e,t)=>{SO.init(e,t),on.init(e,t)}),NL=we("ZodCIDRv4",(e,t)=>{_O.init(e,t),on.init(e,t)}),TL=we("ZodCIDRv6",(e,t)=>{kO.init(e,t),on.init(e,t)}),AL=we("ZodBase64",(e,t)=>{EO.init(e,t),on.init(e,t)}),IL=we("ZodBase64URL",(e,t)=>{NO.init(e,t),on.init(e,t)}),RL=we("ZodE164",(e,t)=>{TO.init(e,t),on.init(e,t)}),PL=we("ZodJWT",(e,t)=>{IO.init(e,t),on.init(e,t)}),P1=we("ZodNumber",(e,t)=>{j1.init(e,t),fn.init(e,t),e.gt=(r,o)=>e.check(vg(r,o)),e.gte=(r,o)=>e.check(Du(r,o)),e.min=(r,o)=>e.check(Du(r,o)),e.lt=(r,o)=>e.check(xg(r,o)),e.lte=(r,o)=>e.check(Mu(r,o)),e.max=(r,o)=>e.check(Mu(r,o)),e.int=r=>e.check(Cg(r)),e.safe=r=>e.check(Cg(r)),e.positive=r=>e.check(vg(0,r)),e.nonnegative=r=>e.check(Du(0,r)),e.negative=r=>e.check(xg(0,r)),e.nonpositive=r=>e.check(Mu(0,r)),e.multipleOf=(r,o)=>e.check(wg(r,o)),e.step=(r,o)=>e.check(wg(r,o)),e.finite=()=>e;const n=e._zod.bag;e.minValue=Math.max(n.minimum??Number.NEGATIVE_INFINITY,n.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(n.maximum??Number.POSITIVE_INFINITY,n.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(n.format??"").includes("int")||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function $d(e){return j8(P1,e)}const ML=we("ZodNumberFormat",(e,t)=>{RO.init(e,t),P1.init(e,t)});function Cg(e){return N8(ML,e)}const DL=we("ZodNull",(e,t)=>{PO.init(e,t),fn.init(e,t)});function Sh(e){return T8(DL,e)}const OL=we("ZodUnknown",(e,t)=>{MO.init(e,t),fn.init(e,t)});function Sg(){return A8(OL)}const LL=we("ZodNever",(e,t)=>{DO.init(e,t),fn.init(e,t)});function FL(e){return I8(LL,e)}const $L=we("ZodArray",(e,t)=>{OO.init(e,t),fn.init(e,t),e.element=t.element,e.min=(n,r)=>e.check(Vl(n,r)),e.nonempty=n=>e.check(Vl(1,n)),e.max=(n,r)=>e.check(A1(n,r)),e.length=(n,r)=>e.check(I1(n,r)),e.unwrap=()=>e.element});function zL(e,t){return B8($L,e,t)}const UL=we("ZodObject",(e,t)=>{FO.init(e,t),fn.init(e,t),Jt(e,"shape",()=>t.shape),e.keyof=()=>HL(Object.keys(e._zod.def.shape)),e.catchall=n=>e.clone({...e._zod.def,catchall:n}),e.passthrough=()=>e.clone({...e._zod.def,catchall:Sg()}),e.loose=()=>e.clone({...e._zod.def,catchall:Sg()}),e.strict=()=>e.clone({...e._zod.def,catchall:FL()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=n=>t6(e,n),e.safeExtend=n=>n6(e,n),e.merge=n=>r6(e,n),e.pick=n=>QD(e,n),e.omit=n=>e6(e,n),e.partial=(...n)=>o6(M1,e,n[0]),e.required=(...n)=>s6(D1,e,n[0])});function Ci(e,t){const n={type:"object",shape:e??{},...tt(t)};return new UL(n)}const BL=we("ZodUnion",(e,t)=>{$O.init(e,t),fn.init(e,t),e.options=t.options});function zc(e,t){return new BL({type:"union",options:e,...tt(t)})}const VL=we("ZodIntersection",(e,t)=>{zO.init(e,t),fn.init(e,t)});function WL(e,t){return new VL({type:"intersection",left:e,right:t})}const zd=we("ZodEnum",(e,t)=>{UO.init(e,t),fn.init(e,t),e.enum=t.entries,e.options=Object.values(t.entries);const n=new Set(Object.keys(t.entries));e.extract=(r,o)=>{const a={};for(const i of r)if(n.has(i))a[i]=t.entries[i];else throw new Error(`Key ${i} not found in enum`);return new zd({...t,checks:[],...tt(o),entries:a})},e.exclude=(r,o)=>{const a={...t.entries};for(const i of r)if(n.has(i))delete a[i];else throw new Error(`Key ${i} not found in enum`);return new zd({...t,checks:[],...tt(o),entries:a})}});function HL(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(r=>[r,r])):e;return new zd({type:"enum",entries:n,...tt(t)})}const ZL=we("ZodLiteral",(e,t)=>{BO.init(e,t),fn.init(e,t),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function _h(e,t){return new ZL({type:"literal",values:Array.isArray(e)?e:[e],...tt(t)})}const GL=we("ZodTransform",(e,t)=>{VO.init(e,t),fn.init(e,t),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new p1(e.constructor.name);n.addIssue=a=>{if(typeof a=="string")n.issues.push(ei(a,n.value,t));else{const i=a;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),i.input??(i.input=n.value),i.inst??(i.inst=e),n.issues.push(ei(i))}};const o=t.transform(n.value,n);return o instanceof Promise?o.then(a=>(n.value=a,n)):(n.value=o,n)}});function YL(e){return new GL({type:"transform",transform:e})}const M1=we("ZodOptional",(e,t)=>{WO.init(e,t),fn.init(e,t),e.unwrap=()=>e._zod.def.innerType});function _g(e){return new M1({type:"optional",innerType:e})}const KL=we("ZodNullable",(e,t)=>{HO.init(e,t),fn.init(e,t),e.unwrap=()=>e._zod.def.innerType});function kg(e){return new KL({type:"nullable",innerType:e})}const qL=we("ZodDefault",(e,t)=>{ZO.init(e,t),fn.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function XL(e,t){return new qL({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():x1(t)}})}const JL=we("ZodPrefault",(e,t)=>{GO.init(e,t),fn.init(e,t),e.unwrap=()=>e._zod.def.innerType});function QL(e,t){return new JL({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():x1(t)}})}const D1=we("ZodNonOptional",(e,t)=>{YO.init(e,t),fn.init(e,t),e.unwrap=()=>e._zod.def.innerType});function eF(e,t){return new D1({type:"nonoptional",innerType:e,...tt(t)})}const tF=we("ZodCatch",(e,t)=>{KO.init(e,t),fn.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function nF(e,t){return new tF({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}const rF=we("ZodPipe",(e,t)=>{qO.init(e,t),fn.init(e,t),e.in=t.in,e.out=t.out});function Eg(e,t){return new rF({type:"pipe",in:e,out:t})}const oF=we("ZodReadonly",(e,t)=>{XO.init(e,t),fn.init(e,t),e.unwrap=()=>e._zod.def.innerType});function sF(e){return new oF({type:"readonly",innerType:e})}const aF=we("ZodCustom",(e,t)=>{JO.init(e,t),fn.init(e,t)});function iF(e,t={}){return V8(aF,e,t)}function lF(e){return W8(e)}const rn={NAME_MAX:255,DESCRIPTION_MAX:1e3,TAG_MAX:100,COMMAND_MAX:50,PROMPT_TEXT_MAX:1e4},cF=Ci({authorName:zc([ps(),Sh()]).optional(),originalVersion:$d().int().positive(),originalCreatedAt:$d().int().positive()}),Ou=()=>zc([ps(),Sh()]).optional(),uF=Ci({name:ps().min(1,"Name is required"),description:Ou(),category:Ou(),command:Ou(),promptText:ps().min(1,"Prompt text is required"),metadata:zc([cF,Sh()]).optional()}),dF=Ci({version:_h("1.0",{message:"Unsupported export format version. Only version 1.0 is currently supported."}),exportedAt:$d().int().positive("Export timestamp must be a valid positive number"),prompt:uF});Ci({command:ps().max(rn.COMMAND_MAX,`Command must be ${rn.COMMAND_MAX} characters or less`).optional().or(_h(""))});function fF(e){const t=[],n=e.prompt;return n.name&&n.name.length>rn.NAME_MAX&&t.push({field:"Name",currentLength:n.name.length,maxLength:rn.NAME_MAX,message:`Name will be truncated from ${n.name.length} to ${rn.NAME_MAX} characters`}),n.description&&n.description.length>rn.DESCRIPTION_MAX&&t.push({field:"Description",currentLength:n.description.length,maxLength:rn.DESCRIPTION_MAX,message:`Description will be truncated from ${n.description.length} to ${rn.DESCRIPTION_MAX} characters`}),n.category&&n.category.length>rn.TAG_MAX&&t.push({field:"Tag",currentLength:n.category.length,maxLength:rn.TAG_MAX,message:`Tag will be truncated from ${n.category.length} to ${rn.TAG_MAX} characters`}),n.command&&n.command.length>rn.COMMAND_MAX&&t.push({field:"Command",currentLength:n.command.length,maxLength:rn.COMMAND_MAX,message:`Command will be truncated from ${n.command.length} to ${rn.COMMAND_MAX} characters`}),n.promptText&&n.promptText.length>rn.PROMPT_TEXT_MAX&&t.push({field:"Prompt text",currentLength:n.promptText.length,maxLength:rn.PROMPT_TEXT_MAX,message:`Prompt text will be truncated from ${n.promptText.length.toLocaleString()} to ${rn.PROMPT_TEXT_MAX.toLocaleString()} characters`}),t}function hF(e){return e.issues.map(t=>{const n=t.path.join(".");return n?`${n}: ${t.message}`:t.message})}function pF(e,t){return e.issues.some(n=>n.path.includes(t))}function mF(e,t){const n=e.issues.find(r=>r.path.includes(t));return n==null?void 0:n.message}const gF=Ci({name:ps().min(1,"Name is required").max(rn.NAME_MAX,`Name must be ${rn.NAME_MAX} characters or less`),command:ps().max(rn.COMMAND_MAX,`Chat shortcut must be ${rn.COMMAND_MAX} characters or less`).optional().or(_h(""))}),xF=({open:e,onOpenChange:t,onImport:n,existingPrompts:r})=>{var K;const[o,a]=d.useState(null),[i,l]=d.useState(null),[c,u]=d.useState([]),[f,h]=d.useState([]),[m,p]=d.useState(!1),[x,g]=d.useState(!1),[w,v]=d.useState(""),b=d.useRef(null),[C,S]=d.useState(!1),[E,_]=d.useState(!1),{register:j,handleSubmit:A,formState:{errors:P},reset:O,setValue:B,watch:N}=sj({resolver:Y8(gF),defaultValues:{name:"",command:""},mode:"onChange"}),M=N("name"),y=N("command"),T=d.useCallback((q,ne)=>{var oe,ie;const de=q.trim().toLowerCase(),se=ne.trim().toLowerCase();let me=!1,k=!1;for(const Z of r)de&&((oe=Z.name)==null?void 0:oe.toLowerCase())===de&&(me=!0),se&&((ie=Z.command)==null?void 0:ie.toLowerCase())===se&&(k=!0);return{hasNameConflict:me,hasCommandConflict:k}},[r]),R=d.useMemo(()=>o?T(M||"",y||""):{hasNameConflict:!1,hasCommandConflict:!1},[o,M,y,T]),z=R.hasNameConflict||R.hasCommandConflict,F=d.useCallback(async q=>{if(l(null),u([]),h([]),a(null),!q.name.endsWith(".json"))return l("Please select a JSON file"),null;if(q.size>1024*1024)return l("File size must be less than 1MB"),null;try{const ne=await q.text();let de;try{de=JSON.parse(ne)}catch{return l("Failed to parse JSON file. Please ensure it's a valid JSON format."),null}const se=dF.safeParse(de);if(!se.success){const k=hF(se.error);if(pF(se.error,"version")){const oe=mF(se.error,"version");l(oe||"Invalid version format")}else k.length===1?l(k[0]):(l("The imported prompt has validation errors:"),u(k));return null}const me=fF(se.data);return h(me),se.data}catch{return l("Failed to read file. Please try again."),null}},[]),I=d.useCallback(q=>{const ne=q.prompt.name||"",de=q.prompt.command||"",se=T(ne,de);S(se.hasNameConflict),_(se.hasCommandConflict)},[T]),J=async q=>{var se;const ne=(se=q.target.files)==null?void 0:se[0];if(!ne)return;const de=await F(ne);de&&(a(de),v(ne.name),B("name",de.prompt.name||""),B("command",de.prompt.command||""),I(de)),q.target&&(q.target.value="")},L=q=>{q.preventDefault(),q.stopPropagation(),g(!0)},D=q=>{q.preventDefault(),q.stopPropagation(),g(!1)},W=async q=>{q.preventDefault(),q.stopPropagation(),g(!1);const ne=q.dataTransfer.files;if(ne&&ne.length>0){const de=ne[0],se=await F(de);se&&(a(se),v(de.name),B("name",se.prompt.name||""),B("command",se.prompt.command||""),I(se))}},G=()=>{var q;(q=b.current)==null||q.click()},V=async q=>{if(!o){l("Please select a JSON file to import");return}if(!z){p(!0),l(null);try{const ne={...o,prompt:{...o.prompt,name:q.name,command:q.command||void 0}};await n(ne,{preserveCommand:!!q.command,preserveCategory:!0}),Q(),t(!1)}catch(ne){l(ne instanceof Error?ne.message:"Failed to import prompt")}finally{p(!1)}}},Q=()=>{a(null),v(""),l(null),u([]),h([]),S(!1),_(!1),O()},X=()=>{m||(Q(),t(!1))};return s.jsx(On,{open:e,onOpenChange:X,children:s.jsxs(Ln,{className:"max-h-[90vh] overflow-y-auto sm:max-w-[500px]",children:[s.jsx(Gn,{children:s.jsx(Fn,{children:"Import Prompt"})}),s.jsxs("form",{onSubmit:A(V),className:"space-y-4 overflow-x-hidden py-4",children:[w?s.jsxs("div",{className:"bg-muted/30 flex items-center gap-3 rounded-md border p-4",children:[s.jsx(La,{className:"text-primary h-5 w-5 flex-shrink-0"}),s.jsx("div",{className:"min-w-0 flex-1",children:s.jsx("p",{className:"truncate text-sm font-medium",children:w})}),s.jsx(xe,{type:"button",variant:"ghost",size:"sm",onClick:Q,disabled:m,children:"Change"})]}):s.jsxs("div",{className:`flex cursor-pointer flex-col items-center justify-center rounded-md border-2 border-dashed p-8 text-center transition-all ${x?"border-primary bg-primary/10 scale-[1.02]":"border-muted-foreground/30"}`,onDragOver:L,onDragLeave:D,onDrop:W,onClick:G,children:[s.jsx(La,{className:`mb-3 h-10 w-10 transition-colors ${x?"text-primary":"text-muted-foreground"}`}),s.jsx("p",{className:`mb-1 text-sm font-medium transition-colors ${x?"text-primary":"text-foreground"}`,children:x?"Drop JSON file here":"Drag and drop JSON file here"}),s.jsx("p",{className:"text-muted-foreground text-xs",children:"or click to browse"}),s.jsx("input",{type:"file",ref:b,onChange:J,accept:".json",disabled:m,className:"hidden"})]}),i&&s.jsxs("div",{className:"space-y-2",children:[s.jsx(Kt,{variant:"error",message:i}),c.length>0&&s.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 p-3 dark:border-red-800 dark:bg-red-950/30",children:s.jsx("ul",{className:"list-inside list-disc space-y-1 text-sm text-red-800 dark:text-red-200",children:c.map((q,ne)=>s.jsx("li",{children:q},ne))})})]}),o&&!i&&s.jsxs("div",{className:"space-y-4",children:[z&&s.jsx(Kt,{variant:"error",message:s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"font-medium",children:"Conflicts found: "}),R.hasNameConflict&&s.jsx("span",{className:"font-semibold",children:M}),R.hasNameConflict&&R.hasCommandConflict&&" name and ",R.hasCommandConflict&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"font-semibold",children:y})," chat shortcut"]}),R.hasNameConflict&&!R.hasCommandConflict&&" name",R.hasNameConflict&&R.hasCommandConflict?" already exist.":" already exists."]})}),f.length>0&&!z&&s.jsx(Kt,{variant:"warning",message:s.jsxs("div",{className:"space-y-2",children:[s.jsx("p",{className:"font-medium",children:"Some fields exceed the maximum length and will be truncated:"}),s.jsx("ul",{className:"list-inside list-disc space-y-1 text-sm",children:f.map((q,ne)=>s.jsx("li",{children:q.message},ne))})]})}),s.jsxs("div",{className:"flex flex-col gap-4",children:[s.jsx("h3",{className:"text-sm font-semibold",children:"Review Prompt"}),s.jsxs("div",{className:"space-y-1",children:[s.jsxs(It,{htmlFor:"import-name",className:"text-muted-foreground text-xs",children:["Name",R.hasNameConflict&&s.jsx("span",{className:"text-destructive",children:"*"})]}),C?s.jsxs("div",{className:"space-y-2",children:[s.jsx(br,{id:"import-name",...j("name"),className:`${P.name||R.hasNameConflict?"border-red-500 focus-visible:ring-red-500":""}`,maxLength:rn.NAME_MAX}),R.hasNameConflict&&!P.name&&s.jsx(Kt,{variant:"error",message:"Already exists. Change name."}),P.name&&s.jsx("p",{className:"text-xs text-[#647481] dark:text-[#B1B9C0]",children:P.name.message})]}):s.jsx("p",{className:"overflow-wrap-anywhere text-sm break-words",children:M})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(It,{className:"text-muted-foreground text-xs",children:"Description"}),o.prompt.description?s.jsx("p",{className:"overflow-wrap-anywhere text-sm break-words",children:o.prompt.description}):s.jsx("p",{className:"text-muted-foreground text-sm italic",children:"No description"})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(It,{className:"text-muted-foreground text-xs",children:"Tag"}),o.prompt.category?s.jsx("p",{className:"overflow-wrap-anywhere text-sm break-words",children:o.prompt.category}):s.jsx("p",{className:"text-muted-foreground text-sm italic",children:"No tag"})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsxs(It,{htmlFor:"import-command",className:"text-muted-foreground text-xs",children:["Chat Shortcut",R.hasCommandConflict&&s.jsx("span",{className:"text-destructive",children:"*"})]}),E?s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-muted-foreground text-sm",children:"/"}),s.jsx(br,{id:"import-command",...j("command"),placeholder:"e.g., code-review",className:`flex-1 ${P.command||R.hasCommandConflict?"border-red-500 focus-visible:ring-red-500":""}`,maxLength:rn.COMMAND_MAX})]}),R.hasCommandConflict&&!P.command&&s.jsx(Kt,{variant:"error",message:"Already exists. Change chat shortcut."}),P.command&&s.jsx("p",{className:"text-xs text-[#647481] dark:text-[#B1B9C0]",children:P.command.message})]}):y?s.jsx("p",{className:"font-mono text-sm break-all",children:y}):s.jsx("p",{className:"text-muted-foreground text-sm italic",children:"No chat shortcut"})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(It,{className:"text-muted-foreground text-xs",children:"Original Author"}),(K=o.prompt.metadata)!=null&&K.authorName?s.jsx("p",{className:"overflow-wrap-anywhere text-sm break-words",children:o.prompt.metadata.authorName}):s.jsx("p",{className:"text-muted-foreground text-sm italic",children:"No author"})]})]})]}),s.jsxs(nr,{children:[s.jsx(xe,{type:"button",variant:"ghost",onClick:X,disabled:m,children:"Cancel"}),s.jsx(xe,{"data-testid":"importPromptButton",type:"submit",disabled:m||!o||z,children:m?"Importing...":"Import"})]})]})]})})},Qi=()=>{var K;const e=zo(),t=Vr(),n=mx(),{addNotification:r,displayError:o}=Ft(),[a,i]=d.useState([]),[l,c]=d.useState(!1),[u,f]=d.useState(!1),[h,m]=d.useState(!1),[p,x]=d.useState(null),[g,w]=d.useState(null),[v,b]=d.useState("ai-assisted"),[C,S]=d.useState(0),[E,_]=d.useState(null),[j,A]=d.useState(null),[P,O]=d.useState(null),[B,N]=d.useState(!1),[M,y]=d.useState(null),[T,R]=d.useState(!1),z=d.useCallback(async()=>{c(!0);try{const q=await _n("/api/v1/prompts/groups/all");i(q)}catch(q){o({title:"Failed to Load Prompts",error:Yt(q,"An error occurred while fetching prompt groups.")})}finally{c(!1)}},[o]);d.useEffect(()=>{z()},[z]),d.useEffect(()=>{var q;if((n==null?void 0:n.view)==="builder")if(n.mode==="edit"&&n.promptId)(async()=>{try{const de=await _n(`/api/v1/prompts/groups/${n.promptId}`);w(de),b("manual"),f(!0)}catch(de){o({title:"Failed to Edit Prompt",error:Yt(de,"An error occurred while fetching prompt.")})}})();else{w(null);const ne=n.mode==="ai-assisted"?"ai-assisted":"manual";b(ne),ne==="ai-assisted"&&((q=t.state)!=null&&q.taskDescription)?x(t.state.taskDescription):x(null),S(de=>de+1),f(!0)}else(n==null?void 0:n.view)==="versions"&&n.promptId?(async()=>{try{const de=await _n(`/api/v1/prompts/groups/${n.promptId}`);_(de)}catch(de){o({title:"Failed to View Versions",error:Yt(de,"An error occurred while fetching versions.")})}})():(f(!1),_(null),w(null))},[n,(K=t.state)==null?void 0:K.taskDescription,o]);const F=(q,ne)=>{A({id:q,name:ne})},I=async()=>{if(j)try{await vn(`/api/v1/prompts/groups/${j.id}`,{method:"DELETE"}),(E==null?void 0:E.id)===j.id&&_(null),await z(),A(null),r("Prompt deleted","success")}catch(q){A(null),o({title:"Failed to Delete Prompt",error:Yt(q,"An error occurred while deleting the prompt.")})}},J=q=>{e(`/prompts/${q.id}/edit`)},L=async q=>{try{await vn(`/api/v1/prompts/${q}/make-production`,{method:"PATCH"}),z(),r("Version made active","success")}catch(ne){o({title:"Failed to Update Version",error:Yt(ne,"An error occurred while making the version active.")})}},D=q=>{m(!1),e("/prompts/new?mode=ai-assisted",{state:{taskDescription:q}})},W=q=>{var me;const ne=((me=q.productionPrompt)==null?void 0:me.promptText)||"";Ks(ne).length>0?(y(q),N(!0)):e("/chat",{state:{promptText:ne,groupId:q.id,groupName:q.name}})},G=q=>{M&&(e("/chat",{state:{promptText:q,groupId:M.id,groupName:M.name}}),N(!1),y(null))},V=async(q,ne)=>{try{i(de=>de.map(se=>se.id===q?{...se,isPinned:!ne}:se)),await vn(`/api/v1/prompts/groups/${q}/pin`,{method:"PATCH"})}catch(de){i(se=>se.map(me=>me.id===q?{...me,isPinned:ne}:me)),o({title:"Failed to Update Pin Status",error:Yt(de,"An error occurred while updating the pin status.")})}},Q=async q=>{try{const ne=await _n(`/api/v1/prompts/groups/${q.id}/export`),de=new Blob([JSON.stringify(ne,null,2)],{type:"application/json"}),se=`prompt-${q.name.replace(/[^a-z0-9]/gi,"-").toLowerCase()}-${Date.now()}.json`;oi(de,se),r("Prompt exported successfully","success")}catch(ne){o({title:"Failed to Export Prompt",error:Yt(ne,"An error occurred while exporting the prompt.")})}},X=async(q,ne)=>{try{const de={prompt_data:{version:q.version,exported_at:q.exportedAt,prompt:{name:q.prompt.name,description:q.prompt.description,category:q.prompt.category,command:q.prompt.command,prompt_text:q.prompt.promptText,metadata:q.prompt.metadata?{author_name:q.prompt.metadata.authorName,original_version:q.prompt.metadata.originalVersion,original_created_at:q.prompt.metadata.originalCreatedAt}:void 0}},options:{preserve_command:ne.preserveCommand,preserve_category:ne.preserveCategory}},se=await _n("/api/v1/prompts/import",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(de)});f(!1),R(!1),x(null),w(null),await z(),O(se.prompt_group_id);const me=(se.warnings||[]).filter(k=>!k.toLowerCase().includes("truncated"));if(me.length>0){const k=me.length===1?me[0]:me.join("; ");r(`Prompt imported with notes: ${k}`,"info")}else r("Prompt imported","success")}catch(de){throw console.error("Failed to import prompt:",de),de}};return u?s.jsxs(s.Fragment,{children:[s.jsx(VD,{onBack:()=>{e("/prompts")},onSuccess:async q=>{q&&O(q),await z(),e("/prompts")},initialMessage:p,editingGroup:g,isEditing:!!g,initialMode:v},`builder-${C}-${(g==null?void 0:g.id)||"new"}`),j&&s.jsx(Pu,{isOpen:!0,onClose:()=>A(null),onConfirm:I,promptName:j.name},`delete-${j.id}`),s.jsx(tg,{isOpen:h,onClose:()=>m(!1),onGenerate:D})]}):E?s.jsxs(s.Fragment,{children:[s.jsx(WD,{group:E,onBack:()=>e("/prompts"),onBackToPromptDetail:()=>e("/prompts"),onEdit:J,onDeleteAll:F,onRestoreVersion:L}),j&&s.jsx(Pu,{isOpen:!0,onClose:()=>A(null),onConfirm:I,promptName:j.name},`delete-${j.id}`)]}):s.jsxs("div",{className:"flex h-full w-full flex-col",children:[s.jsx(vs,{title:"Prompts",buttons:[s.jsxs(xe,{variant:"ghost",title:"Import Prompt",onClick:()=>R(!0),children:[s.jsx(Fs,{className:"size-4"}),"Import Prompt"]},"importPrompt"),s.jsxs(xe,{"data-testid":"refreshPrompts",disabled:l,variant:"ghost",title:"Refresh Prompts",onClick:()=>z(),children:[s.jsx(Gl,{className:"size-4"}),"Refresh Prompts"]},"refreshPrompts")]}),l?s.jsx(Lr,{title:"Loading prompts...",variant:"loading"}):s.jsx("div",{className:"relative flex-1 p-4",children:s.jsx(LD,{prompts:a,onManualCreate:()=>e("/prompts/new?mode=manual"),onAIAssisted:()=>m(!0),onEdit:J,onDelete:F,onViewVersions:q=>e(`/prompts/${q.id}/versions`),onUseInChat:W,onTogglePin:V,onExport:Q,newlyCreatedPromptId:P})}),j&&s.jsx(Pu,{isOpen:!0,onClose:()=>A(null),onConfirm:I,promptName:j.name},`delete-${j.id}`),s.jsx(tg,{isOpen:h,onClose:()=>m(!1),onGenerate:D}),B&&M&&s.jsx(ih,{group:M,onSubmit:G,onClose:()=>{N(!1),y(null)}}),s.jsx(xF,{open:T,onOpenChange:R,onImport:X,existingPrompts:a})]})},vF=e=>({displayName:e?"Solace Dark JER":"Solace Light JER",styles:{container:{backgroundColor:"transparent",fontFamily:"monospace",fontSize:"14px"},property:e?"var(--color-primary-text-w10)":"var(--color-primary-text-wMain)",bracket:"var(--color-secondary-text-w50)",itemCount:{color:"var(--color-secondary-text-w50)",fontStyle:"italic"},string:e?"var(--color-success-w70)":"var(--color-success-wMain)",number:"var(--color-accent-n0-wMain)",boolean:e?"var(--color-warning-w70)":"var(--color-warning-wMain)",null:{color:"var(--color-secondary-text-w50)",fontStyle:"italic"},iconCollection:"var(--color-secondary-text-w50)",iconCopy:"var(--color-secondary-text-w50)"}}),Ud=({data:e,maxDepth:t=2,className:n=""})=>{const{currentTheme:r}=di(),o=d.useMemo(()=>vF(r==="dark"),[r]),a=d.useMemo(()=>t===void 0||t<0?!1:t,[t]),i=d.useMemo(()=>e===null||typeof e!="object"?{value:e}:e,[e]),l=`rounded-lg border overflow-auto ${n}`.trim();return e===void 0?s.jsx("div",{className:l,children:s.jsx("span",{className:"italic",children:"No JSON data"})}):s.jsx("div",{className:l,children:s.jsx(CC,{data:i,theme:o,viewOnly:!0,collapse:a,showStringQuotes:!0,showCollectionCount:"when-closed"})})},wF=({isOpen:e,onClose:t,onSubmit:n,isSubmitting:r=!1})=>{const[o,a]=d.useState(""),[i,l]=d.useState(""),[c,u]=d.useState(null),f=async m=>{if(m.preventDefault(),!o.trim()){u("Project name is required");return}try{await n({name:o.trim(),description:i.trim()}),a(""),l(""),u(null)}catch(p){u(p instanceof Error?p.message:"Failed to create project")}},h=()=>{r||(a(""),l(""),u(null),t())};return s.jsx(On,{open:e,onOpenChange:m=>!m&&h(),children:s.jsx(Ln,{className:"sm:max-w-[500px]",children:s.jsxs("form",{onSubmit:f,children:[s.jsxs(Gn,{children:[s.jsx(Fn,{children:"Create New Project"}),s.jsx(Yn,{children:"Create a new project to organize your chats and files. You can add more details after creation."})]}),s.jsxs("div",{className:"space-y-4 py-4",children:[c&&s.jsx(Kt,{variant:"error",message:c}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("label",{htmlFor:"project-name",className:"text-sm font-medium",children:["Project Name ",s.jsx("span",{className:"text-[var(--color-brand-wMain)]",children:"*"})]}),s.jsx(br,{id:"project-name",value:o,onChange:m=>a(m.target.value),disabled:r,required:!0,maxLength:255})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{htmlFor:"project-description",className:"text-sm font-medium",children:"Description"}),s.jsx(Wr,{id:"project-description",value:i,onChange:m=>l(m.target.value),disabled:r,rows:3,maxLength:1e3}),s.jsxs("div",{className:"text-muted-foreground text-right text-xs",children:[i.length,"/1000 characters"]})]})]}),s.jsxs(nr,{children:[s.jsx(xe,{type:"button",variant:"ghost",onClick:h,disabled:r,children:"Cancel"}),s.jsx(xe,{type:"submit",disabled:r,children:"Create Project"})]})]})})})},bF=({onClick:e})=>s.jsx(Ic,{className:"border border-dashed border-[var(--color-primary-wMain)]",onClick:e,children:s.jsx(cc,{className:"flex h-full items-center justify-center",children:s.jsxs("div",{className:"text-center",children:[s.jsx("div",{className:"mb-4 flex justify-center",children:s.jsx("div",{className:"bg-primary/10 rounded-full p-4",children:s.jsx(ns,{className:"text-primary h-8 w-8"})})}),s.jsx("h3",{className:"text-foreground text-lg font-semibold",children:"Create New Project"})]})})}),yF=({isOpen:e,files:t,onClose:n,onConfirm:r,isSubmitting:o=!1,error:a=null,onClearError:i})=>{const[l,c]=d.useState({});d.useEffect(()=>{e&&c({})},[e]);const u=d.useCallback(()=>{i==null||i(),n()},[n,i]),f=d.useCallback((p,x)=>{c(g=>({...g,[p]:x}))},[]),h=d.useCallback(()=>{if(!t)return;const p=new FormData,x={};for(const g of Array.from(t))p.append("files",g),l[g.name]&&(x[g.name]=l[g.name]);Object.keys(x).length>0&&p.append("fileMetadata",JSON.stringify(x)),r(p)},[t,l,r]),m=t?Array.from(t):[];return s.jsx(On,{open:e,onOpenChange:p=>!p&&u(),children:s.jsxs(Ln,{className:"sm:max-w-[600px]",children:[s.jsxs(Gn,{children:[s.jsx(Fn,{children:"Upload Files to Project"}),s.jsx(Yn,{children:"Add descriptions for each file. This helps Solace Agent Mesh understand the file's purpose."})]}),s.jsxs("div",{className:"space-y-4 py-4",children:[a&&s.jsx(Kt,{variant:"error",message:a,dismissible:!0,onDismiss:i}),m.length>0?s.jsx("div",{className:"max-h-[50vh] space-y-2 overflow-y-auto pr-2",children:m.map((p,x)=>s.jsx(Tf,{noPadding:!0,className:"bg-muted/50 overflow-hidden py-3 shadow-none",children:s.jsxs(cc,{noPadding:!0,className:"overflow-hidden px-3",children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[s.jsx(wr,{className:"text-muted-foreground h-4 w-4 flex-shrink-0"}),s.jsxs("div",{className:"min-w-0 flex-1 overflow-hidden",children:[s.jsx("p",{className:"text-foreground line-clamp-2 text-sm font-medium break-all",title:p.name,children:p.name}),s.jsxs("p",{className:"text-muted-foreground text-xs",children:[(p.size/1024).toFixed(1)," KB"]})]})]}),s.jsx(Wr,{className:"bg-background text-foreground mt-2",rows:2,disabled:o,value:l[p.name]||"",onChange:g=>f(p.name,g.target.value)})]})},x))}):s.jsx("p",{className:"text-muted-foreground",children:"No files selected."})]}),s.jsxs(nr,{children:[s.jsx(xe,{variant:"ghost",onClick:u,disabled:o,children:"Cancel"}),s.jsx(xe,{onClick:h,disabled:o||m.length===0,children:o?"Uploading...":`Upload ${m.length} File(s)`})]})]})})},CF=({project:e,onClick:t,onDelete:n,onExport:r})=>{const[o,a]=d.useState(!1),i=[...r?[{id:"export",label:"Export Project",icon:s.jsx(Co,{size:14}),onClick:()=>{a(!1),r(e)}}]:[],{id:"delete",label:"Delete",icon:s.jsx(rs,{size:14}),onClick:()=>{a(!1),n&&n(e)}}];return s.jsxs(Ic,{onClick:t,children:[s.jsx(DE,{children:s.jsxs("div",{className:"flex items-start justify-between gap-2",children:[s.jsxs(Us,{className:"flex min-w-0 flex-1 items-center gap-2",title:e.name,children:[s.jsx(Zg,{className:"h-6 w-6 flex-shrink-0 text-[var(--color-brand-wMain)]"}),s.jsx("div",{className:"text-foreground max-w-[250px] min-w-0 truncate text-lg font-semibold",children:e.name})]}),s.jsx("div",{className:"flex shrink-0 items-center gap-1",children:n&&s.jsxs(bc,{open:o,onOpenChange:a,children:[s.jsx(yc,{asChild:!0,children:s.jsx(xe,{variant:"ghost",size:"icon",className:"h-8 w-8",tooltip:"More options",onClick:l=>l.stopPropagation(),children:s.jsx(Mo,{className:"h-4 w-4"})})}),s.jsx(Cc,{align:"start",side:"bottom",className:"w-48 p-1",sideOffset:0,onClick:l=>l.stopPropagation(),children:s.jsx(hi,{actions:i})})]})})]})}),s.jsxs(cc,{className:"flex flex-1 flex-col justify-between",children:[s.jsx("div",{children:e.description?s.jsx(OE,{className:"line-clamp-3",title:e.description,children:e.description}):s.jsx("div",{})}),s.jsxs("div",{className:"text-muted-foreground mt-3 flex items-center justify-between text-xs",children:[s.jsxs("div",{className:"flex items-center gap-1",children:["Created: ",of(e.createdAt),s.jsx("div",{children:"|"}),s.jsx("div",{className:"max-w-[80px] truncate",title:e.userId,children:e.userId})]}),s.jsx("div",{children:e.artifactCount!==void 0&&e.artifactCount!==null&&s.jsxs(zr,{variant:"secondary",className:"flex h-6 items-center gap-1",title:`${e.artifactCount} ${e.artifactCount===1?"file":"files"}`,children:[s.jsx(wr,{className:"h-3.5 w-3.5"}),s.jsx("span",{children:e.artifactCount})]})})]})]})]})},O1=({isOpen:e,onClose:t,onConfirm:n,project:r,isDeleting:o=!1})=>r?s.jsx(Vo,{open:e,onOpenChange:a=>!a&&t(),title:"Delete Project",content:s.jsxs(s.Fragment,{children:["This action cannot be undone. This project and all its associated chat sessions and artifacts will be permanently deleted: ",s.jsx("strong",{children:r.name}),"."]}),actionLabels:{confirm:"Delete"},onConfirm:n,onCancel:t,isLoading:o}):null;function el(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var Lu={exports:{}};/*!
423
+
424
+ JSZip v3.10.1 - A JavaScript class for generating and reading zip files
425
+ <http://stuartk.com/jszip>
426
+
427
+ (c) 2009-2016 Stuart Knightley <stuart [at] stuartk.com>
428
+ Dual licenced under the MIT license or GPLv3. See https://raw.github.com/Stuk/jszip/main/LICENSE.markdown.
429
+
430
+ JSZip uses the library pako released under the MIT license :
431
+ https://github.com/nodeca/pako/blob/main/LICENSE
432
+ */var jg;function SF(){return jg||(jg=1,function(e,t){(function(n){e.exports=n()})(function(){return function n(r,o,a){function i(u,f){if(!o[u]){if(!r[u]){var h=typeof el=="function"&&el;if(!f&&h)return h(u,!0);if(l)return l(u,!0);var m=new Error("Cannot find module '"+u+"'");throw m.code="MODULE_NOT_FOUND",m}var p=o[u]={exports:{}};r[u][0].call(p.exports,function(x){var g=r[u][1][x];return i(g||x)},p,p.exports,n,r,o,a)}return o[u].exports}for(var l=typeof el=="function"&&el,c=0;c<a.length;c++)i(a[c]);return i}({1:[function(n,r,o){var a=n("./utils"),i=n("./support"),l="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";o.encode=function(c){for(var u,f,h,m,p,x,g,w=[],v=0,b=c.length,C=b,S=a.getTypeOf(c)!=="string";v<c.length;)C=b-v,h=S?(u=c[v++],f=v<b?c[v++]:0,v<b?c[v++]:0):(u=c.charCodeAt(v++),f=v<b?c.charCodeAt(v++):0,v<b?c.charCodeAt(v++):0),m=u>>2,p=(3&u)<<4|f>>4,x=1<C?(15&f)<<2|h>>6:64,g=2<C?63&h:64,w.push(l.charAt(m)+l.charAt(p)+l.charAt(x)+l.charAt(g));return w.join("")},o.decode=function(c){var u,f,h,m,p,x,g=0,w=0,v="data:";if(c.substr(0,v.length)===v)throw new Error("Invalid base64 input, it looks like a data url.");var b,C=3*(c=c.replace(/[^A-Za-z0-9+/=]/g,"")).length/4;if(c.charAt(c.length-1)===l.charAt(64)&&C--,c.charAt(c.length-2)===l.charAt(64)&&C--,C%1!=0)throw new Error("Invalid base64 input, bad content length.");for(b=i.uint8array?new Uint8Array(0|C):new Array(0|C);g<c.length;)u=l.indexOf(c.charAt(g++))<<2|(m=l.indexOf(c.charAt(g++)))>>4,f=(15&m)<<4|(p=l.indexOf(c.charAt(g++)))>>2,h=(3&p)<<6|(x=l.indexOf(c.charAt(g++))),b[w++]=u,p!==64&&(b[w++]=f),x!==64&&(b[w++]=h);return b}},{"./support":30,"./utils":32}],2:[function(n,r,o){var a=n("./external"),i=n("./stream/DataWorker"),l=n("./stream/Crc32Probe"),c=n("./stream/DataLengthProbe");function u(f,h,m,p,x){this.compressedSize=f,this.uncompressedSize=h,this.crc32=m,this.compression=p,this.compressedContent=x}u.prototype={getContentWorker:function(){var f=new i(a.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new c("data_length")),h=this;return f.on("end",function(){if(this.streamInfo.data_length!==h.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),f},getCompressedWorker:function(){return new i(a.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},u.createWorkerFrom=function(f,h,m){return f.pipe(new l).pipe(new c("uncompressedSize")).pipe(h.compressWorker(m)).pipe(new c("compressedSize")).withStreamInfo("compression",h)},r.exports=u},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(n,r,o){var a=n("./stream/GenericWorker");o.STORE={magic:"\0\0",compressWorker:function(){return new a("STORE compression")},uncompressWorker:function(){return new a("STORE decompression")}},o.DEFLATE=n("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(n,r,o){var a=n("./utils"),i=function(){for(var l,c=[],u=0;u<256;u++){l=u;for(var f=0;f<8;f++)l=1&l?3988292384^l>>>1:l>>>1;c[u]=l}return c}();r.exports=function(l,c){return l!==void 0&&l.length?a.getTypeOf(l)!=="string"?function(u,f,h,m){var p=i,x=m+h;u^=-1;for(var g=m;g<x;g++)u=u>>>8^p[255&(u^f[g])];return-1^u}(0|c,l,l.length,0):function(u,f,h,m){var p=i,x=m+h;u^=-1;for(var g=m;g<x;g++)u=u>>>8^p[255&(u^f.charCodeAt(g))];return-1^u}(0|c,l,l.length,0):0}},{"./utils":32}],5:[function(n,r,o){o.base64=!1,o.binary=!1,o.dir=!1,o.createFolders=!0,o.date=null,o.compression=null,o.compressionOptions=null,o.comment=null,o.unixPermissions=null,o.dosPermissions=null},{}],6:[function(n,r,o){var a=null;a=typeof Promise<"u"?Promise:n("lie"),r.exports={Promise:a}},{lie:37}],7:[function(n,r,o){var a=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Uint32Array<"u",i=n("pako"),l=n("./utils"),c=n("./stream/GenericWorker"),u=a?"uint8array":"array";function f(h,m){c.call(this,"FlateWorker/"+h),this._pako=null,this._pakoAction=h,this._pakoOptions=m,this.meta={}}o.magic="\b\0",l.inherits(f,c),f.prototype.processChunk=function(h){this.meta=h.meta,this._pako===null&&this._createPako(),this._pako.push(l.transformTo(u,h.data),!1)},f.prototype.flush=function(){c.prototype.flush.call(this),this._pako===null&&this._createPako(),this._pako.push([],!0)},f.prototype.cleanUp=function(){c.prototype.cleanUp.call(this),this._pako=null},f.prototype._createPako=function(){this._pako=new i[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var h=this;this._pako.onData=function(m){h.push({data:m,meta:h.meta})}},o.compressWorker=function(h){return new f("Deflate",h)},o.uncompressWorker=function(){return new f("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(n,r,o){function a(p,x){var g,w="";for(g=0;g<x;g++)w+=String.fromCharCode(255&p),p>>>=8;return w}function i(p,x,g,w,v,b){var C,S,E=p.file,_=p.compression,j=b!==u.utf8encode,A=l.transformTo("string",b(E.name)),P=l.transformTo("string",u.utf8encode(E.name)),O=E.comment,B=l.transformTo("string",b(O)),N=l.transformTo("string",u.utf8encode(O)),M=P.length!==E.name.length,y=N.length!==O.length,T="",R="",z="",F=E.dir,I=E.date,J={crc32:0,compressedSize:0,uncompressedSize:0};x&&!g||(J.crc32=p.crc32,J.compressedSize=p.compressedSize,J.uncompressedSize=p.uncompressedSize);var L=0;x&&(L|=8),j||!M&&!y||(L|=2048);var D=0,W=0;F&&(D|=16),v==="UNIX"?(W=798,D|=function(V,Q){var X=V;return V||(X=Q?16893:33204),(65535&X)<<16}(E.unixPermissions,F)):(W=20,D|=function(V){return 63&(V||0)}(E.dosPermissions)),C=I.getUTCHours(),C<<=6,C|=I.getUTCMinutes(),C<<=5,C|=I.getUTCSeconds()/2,S=I.getUTCFullYear()-1980,S<<=4,S|=I.getUTCMonth()+1,S<<=5,S|=I.getUTCDate(),M&&(R=a(1,1)+a(f(A),4)+P,T+="up"+a(R.length,2)+R),y&&(z=a(1,1)+a(f(B),4)+N,T+="uc"+a(z.length,2)+z);var G="";return G+=`
433
+ \0`,G+=a(L,2),G+=_.magic,G+=a(C,2),G+=a(S,2),G+=a(J.crc32,4),G+=a(J.compressedSize,4),G+=a(J.uncompressedSize,4),G+=a(A.length,2),G+=a(T.length,2),{fileRecord:h.LOCAL_FILE_HEADER+G+A+T,dirRecord:h.CENTRAL_FILE_HEADER+a(W,2)+G+a(B.length,2)+"\0\0\0\0"+a(D,4)+a(w,4)+A+T+B}}var l=n("../utils"),c=n("../stream/GenericWorker"),u=n("../utf8"),f=n("../crc32"),h=n("../signature");function m(p,x,g,w){c.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=x,this.zipPlatform=g,this.encodeFileName=w,this.streamFiles=p,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}l.inherits(m,c),m.prototype.push=function(p){var x=p.meta.percent||0,g=this.entriesCount,w=this._sources.length;this.accumulate?this.contentBuffer.push(p):(this.bytesWritten+=p.data.length,c.prototype.push.call(this,{data:p.data,meta:{currentFile:this.currentFile,percent:g?(x+100*(g-w-1))/g:100}}))},m.prototype.openedSource=function(p){this.currentSourceOffset=this.bytesWritten,this.currentFile=p.file.name;var x=this.streamFiles&&!p.file.dir;if(x){var g=i(p,x,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:g.fileRecord,meta:{percent:0}})}else this.accumulate=!0},m.prototype.closedSource=function(p){this.accumulate=!1;var x=this.streamFiles&&!p.file.dir,g=i(p,x,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(g.dirRecord),x)this.push({data:function(w){return h.DATA_DESCRIPTOR+a(w.crc32,4)+a(w.compressedSize,4)+a(w.uncompressedSize,4)}(p),meta:{percent:100}});else for(this.push({data:g.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},m.prototype.flush=function(){for(var p=this.bytesWritten,x=0;x<this.dirRecords.length;x++)this.push({data:this.dirRecords[x],meta:{percent:100}});var g=this.bytesWritten-p,w=function(v,b,C,S,E){var _=l.transformTo("string",E(S));return h.CENTRAL_DIRECTORY_END+"\0\0\0\0"+a(v,2)+a(v,2)+a(b,4)+a(C,4)+a(_.length,2)+_}(this.dirRecords.length,g,p,this.zipComment,this.encodeFileName);this.push({data:w,meta:{percent:100}})},m.prototype.prepareNextSource=function(){this.previous=this._sources.shift(),this.openedSource(this.previous.streamInfo),this.isPaused?this.previous.pause():this.previous.resume()},m.prototype.registerPrevious=function(p){this._sources.push(p);var x=this;return p.on("data",function(g){x.processChunk(g)}),p.on("end",function(){x.closedSource(x.previous.streamInfo),x._sources.length?x.prepareNextSource():x.end()}),p.on("error",function(g){x.error(g)}),this},m.prototype.resume=function(){return!!c.prototype.resume.call(this)&&(!this.previous&&this._sources.length?(this.prepareNextSource(),!0):this.previous||this._sources.length||this.generatedError?void 0:(this.end(),!0))},m.prototype.error=function(p){var x=this._sources;if(!c.prototype.error.call(this,p))return!1;for(var g=0;g<x.length;g++)try{x[g].error(p)}catch{}return!0},m.prototype.lock=function(){c.prototype.lock.call(this);for(var p=this._sources,x=0;x<p.length;x++)p[x].lock()},r.exports=m},{"../crc32":4,"../signature":23,"../stream/GenericWorker":28,"../utf8":31,"../utils":32}],9:[function(n,r,o){var a=n("../compressions"),i=n("./ZipFileWorker");o.generateWorker=function(l,c,u){var f=new i(c.streamFiles,u,c.platform,c.encodeFileName),h=0;try{l.forEach(function(m,p){h++;var x=function(b,C){var S=b||C,E=a[S];if(!E)throw new Error(S+" is not a valid compression method !");return E}(p.options.compression,c.compression),g=p.options.compressionOptions||c.compressionOptions||{},w=p.dir,v=p.date;p._compressWorker(x,g).withStreamInfo("file",{name:m,dir:w,date:v,comment:p.comment||"",unixPermissions:p.unixPermissions,dosPermissions:p.dosPermissions}).pipe(f)}),f.entriesCount=h}catch(m){f.error(m)}return f}},{"../compressions":3,"./ZipFileWorker":8}],10:[function(n,r,o){function a(){if(!(this instanceof a))return new a;if(arguments.length)throw new Error("The constructor with parameters has been removed in JSZip 3.0, please check the upgrade guide.");this.files=Object.create(null),this.comment=null,this.root="",this.clone=function(){var i=new a;for(var l in this)typeof this[l]!="function"&&(i[l]=this[l]);return i}}(a.prototype=n("./object")).loadAsync=n("./load"),a.support=n("./support"),a.defaults=n("./defaults"),a.version="3.10.1",a.loadAsync=function(i,l){return new a().loadAsync(i,l)},a.external=n("./external"),r.exports=a},{"./defaults":5,"./external":6,"./load":11,"./object":15,"./support":30}],11:[function(n,r,o){var a=n("./utils"),i=n("./external"),l=n("./utf8"),c=n("./zipEntries"),u=n("./stream/Crc32Probe"),f=n("./nodejsUtils");function h(m){return new i.Promise(function(p,x){var g=m.decompressed.getContentWorker().pipe(new u);g.on("error",function(w){x(w)}).on("end",function(){g.streamInfo.crc32!==m.decompressed.crc32?x(new Error("Corrupted zip : CRC32 mismatch")):p()}).resume()})}r.exports=function(m,p){var x=this;return p=a.extend(p||{},{base64:!1,checkCRC32:!1,optimizedBinaryString:!1,createFolders:!1,decodeFileName:l.utf8decode}),f.isNode&&f.isStream(m)?i.Promise.reject(new Error("JSZip can't accept a stream when loading a zip file.")):a.prepareContent("the loaded zip file",m,!0,p.optimizedBinaryString,p.base64).then(function(g){var w=new c(p);return w.load(g),w}).then(function(g){var w=[i.Promise.resolve(g)],v=g.files;if(p.checkCRC32)for(var b=0;b<v.length;b++)w.push(h(v[b]));return i.Promise.all(w)}).then(function(g){for(var w=g.shift(),v=w.files,b=0;b<v.length;b++){var C=v[b],S=C.fileNameStr,E=a.resolve(C.fileNameStr);x.file(E,C.decompressed,{binary:!0,optimizedBinaryString:!0,date:C.date,dir:C.dir,comment:C.fileCommentStr.length?C.fileCommentStr:null,unixPermissions:C.unixPermissions,dosPermissions:C.dosPermissions,createFolders:p.createFolders}),C.dir||(x.file(E).unsafeOriginalName=S)}return w.zipComment.length&&(x.comment=w.zipComment),x})}},{"./external":6,"./nodejsUtils":14,"./stream/Crc32Probe":25,"./utf8":31,"./utils":32,"./zipEntries":33}],12:[function(n,r,o){var a=n("../utils"),i=n("../stream/GenericWorker");function l(c,u){i.call(this,"Nodejs stream input adapter for "+c),this._upstreamEnded=!1,this._bindStream(u)}a.inherits(l,i),l.prototype._bindStream=function(c){var u=this;(this._stream=c).pause(),c.on("data",function(f){u.push({data:f,meta:{percent:0}})}).on("error",function(f){u.isPaused?this.generatedError=f:u.error(f)}).on("end",function(){u.isPaused?u._upstreamEnded=!0:u.end()})},l.prototype.pause=function(){return!!i.prototype.pause.call(this)&&(this._stream.pause(),!0)},l.prototype.resume=function(){return!!i.prototype.resume.call(this)&&(this._upstreamEnded?this.end():this._stream.resume(),!0)},r.exports=l},{"../stream/GenericWorker":28,"../utils":32}],13:[function(n,r,o){var a=n("readable-stream").Readable;function i(l,c,u){a.call(this,c),this._helper=l;var f=this;l.on("data",function(h,m){f.push(h)||f._helper.pause(),u&&u(m)}).on("error",function(h){f.emit("error",h)}).on("end",function(){f.push(null)})}n("../utils").inherits(i,a),i.prototype._read=function(){this._helper.resume()},r.exports=i},{"../utils":32,"readable-stream":16}],14:[function(n,r,o){r.exports={isNode:typeof Buffer<"u",newBufferFrom:function(a,i){if(Buffer.from&&Buffer.from!==Uint8Array.from)return Buffer.from(a,i);if(typeof a=="number")throw new Error('The "data" argument must not be a number');return new Buffer(a,i)},allocBuffer:function(a){if(Buffer.alloc)return Buffer.alloc(a);var i=new Buffer(a);return i.fill(0),i},isBuffer:function(a){return Buffer.isBuffer(a)},isStream:function(a){return a&&typeof a.on=="function"&&typeof a.pause=="function"&&typeof a.resume=="function"}}},{}],15:[function(n,r,o){function a(E,_,j){var A,P=l.getTypeOf(_),O=l.extend(j||{},f);O.date=O.date||new Date,O.compression!==null&&(O.compression=O.compression.toUpperCase()),typeof O.unixPermissions=="string"&&(O.unixPermissions=parseInt(O.unixPermissions,8)),O.unixPermissions&&16384&O.unixPermissions&&(O.dir=!0),O.dosPermissions&&16&O.dosPermissions&&(O.dir=!0),O.dir&&(E=v(E)),O.createFolders&&(A=w(E))&&b.call(this,A,!0);var B=P==="string"&&O.binary===!1&&O.base64===!1;j&&j.binary!==void 0||(O.binary=!B),(_ instanceof h&&_.uncompressedSize===0||O.dir||!_||_.length===0)&&(O.base64=!1,O.binary=!0,_="",O.compression="STORE",P="string");var N=null;N=_ instanceof h||_ instanceof c?_:x.isNode&&x.isStream(_)?new g(E,_):l.prepareContent(E,_,O.binary,O.optimizedBinaryString,O.base64);var M=new m(E,N,O);this.files[E]=M}var i=n("./utf8"),l=n("./utils"),c=n("./stream/GenericWorker"),u=n("./stream/StreamHelper"),f=n("./defaults"),h=n("./compressedObject"),m=n("./zipObject"),p=n("./generate"),x=n("./nodejsUtils"),g=n("./nodejs/NodejsStreamInputAdapter"),w=function(E){E.slice(-1)==="/"&&(E=E.substring(0,E.length-1));var _=E.lastIndexOf("/");return 0<_?E.substring(0,_):""},v=function(E){return E.slice(-1)!=="/"&&(E+="/"),E},b=function(E,_){return _=_!==void 0?_:f.createFolders,E=v(E),this.files[E]||a.call(this,E,null,{dir:!0,createFolders:_}),this.files[E]};function C(E){return Object.prototype.toString.call(E)==="[object RegExp]"}var S={load:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},forEach:function(E){var _,j,A;for(_ in this.files)A=this.files[_],(j=_.slice(this.root.length,_.length))&&_.slice(0,this.root.length)===this.root&&E(j,A)},filter:function(E){var _=[];return this.forEach(function(j,A){E(j,A)&&_.push(A)}),_},file:function(E,_,j){if(arguments.length!==1)return E=this.root+E,a.call(this,E,_,j),this;if(C(E)){var A=E;return this.filter(function(O,B){return!B.dir&&A.test(O)})}var P=this.files[this.root+E];return P&&!P.dir?P:null},folder:function(E){if(!E)return this;if(C(E))return this.filter(function(P,O){return O.dir&&E.test(P)});var _=this.root+E,j=b.call(this,_),A=this.clone();return A.root=j.name,A},remove:function(E){E=this.root+E;var _=this.files[E];if(_||(E.slice(-1)!=="/"&&(E+="/"),_=this.files[E]),_&&!_.dir)delete this.files[E];else for(var j=this.filter(function(P,O){return O.name.slice(0,E.length)===E}),A=0;A<j.length;A++)delete this.files[j[A].name];return this},generate:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},generateInternalStream:function(E){var _,j={};try{if((j=l.extend(E||{},{streamFiles:!1,compression:"STORE",compressionOptions:null,type:"",platform:"DOS",comment:null,mimeType:"application/zip",encodeFileName:i.utf8encode})).type=j.type.toLowerCase(),j.compression=j.compression.toUpperCase(),j.type==="binarystring"&&(j.type="string"),!j.type)throw new Error("No output type specified.");l.checkSupport(j.type),j.platform!=="darwin"&&j.platform!=="freebsd"&&j.platform!=="linux"&&j.platform!=="sunos"||(j.platform="UNIX"),j.platform==="win32"&&(j.platform="DOS");var A=j.comment||this.comment||"";_=p.generateWorker(this,j,A)}catch(P){(_=new c("error")).error(P)}return new u(_,j.type||"string",j.mimeType)},generateAsync:function(E,_){return this.generateInternalStream(E).accumulate(_)},generateNodeStream:function(E,_){return(E=E||{}).type||(E.type="nodebuffer"),this.generateInternalStream(E).toNodejsStream(_)}};r.exports=S},{"./compressedObject":2,"./defaults":5,"./generate":9,"./nodejs/NodejsStreamInputAdapter":12,"./nodejsUtils":14,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31,"./utils":32,"./zipObject":35}],16:[function(n,r,o){r.exports=n("stream")},{stream:void 0}],17:[function(n,r,o){var a=n("./DataReader");function i(l){a.call(this,l);for(var c=0;c<this.data.length;c++)l[c]=255&l[c]}n("../utils").inherits(i,a),i.prototype.byteAt=function(l){return this.data[this.zero+l]},i.prototype.lastIndexOfSignature=function(l){for(var c=l.charCodeAt(0),u=l.charCodeAt(1),f=l.charCodeAt(2),h=l.charCodeAt(3),m=this.length-4;0<=m;--m)if(this.data[m]===c&&this.data[m+1]===u&&this.data[m+2]===f&&this.data[m+3]===h)return m-this.zero;return-1},i.prototype.readAndCheckSignature=function(l){var c=l.charCodeAt(0),u=l.charCodeAt(1),f=l.charCodeAt(2),h=l.charCodeAt(3),m=this.readData(4);return c===m[0]&&u===m[1]&&f===m[2]&&h===m[3]},i.prototype.readData=function(l){if(this.checkOffset(l),l===0)return[];var c=this.data.slice(this.zero+this.index,this.zero+this.index+l);return this.index+=l,c},r.exports=i},{"../utils":32,"./DataReader":18}],18:[function(n,r,o){var a=n("../utils");function i(l){this.data=l,this.length=l.length,this.index=0,this.zero=0}i.prototype={checkOffset:function(l){this.checkIndex(this.index+l)},checkIndex:function(l){if(this.length<this.zero+l||l<0)throw new Error("End of data reached (data length = "+this.length+", asked index = "+l+"). Corrupted zip ?")},setIndex:function(l){this.checkIndex(l),this.index=l},skip:function(l){this.setIndex(this.index+l)},byteAt:function(){},readInt:function(l){var c,u=0;for(this.checkOffset(l),c=this.index+l-1;c>=this.index;c--)u=(u<<8)+this.byteAt(c);return this.index+=l,u},readString:function(l){return a.transformTo("string",this.readData(l))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var l=this.readInt(4);return new Date(Date.UTC(1980+(l>>25&127),(l>>21&15)-1,l>>16&31,l>>11&31,l>>5&63,(31&l)<<1))}},r.exports=i},{"../utils":32}],19:[function(n,r,o){var a=n("./Uint8ArrayReader");function i(l){a.call(this,l)}n("../utils").inherits(i,a),i.prototype.readData=function(l){this.checkOffset(l);var c=this.data.slice(this.zero+this.index,this.zero+this.index+l);return this.index+=l,c},r.exports=i},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(n,r,o){var a=n("./DataReader");function i(l){a.call(this,l)}n("../utils").inherits(i,a),i.prototype.byteAt=function(l){return this.data.charCodeAt(this.zero+l)},i.prototype.lastIndexOfSignature=function(l){return this.data.lastIndexOf(l)-this.zero},i.prototype.readAndCheckSignature=function(l){return l===this.readData(4)},i.prototype.readData=function(l){this.checkOffset(l);var c=this.data.slice(this.zero+this.index,this.zero+this.index+l);return this.index+=l,c},r.exports=i},{"../utils":32,"./DataReader":18}],21:[function(n,r,o){var a=n("./ArrayReader");function i(l){a.call(this,l)}n("../utils").inherits(i,a),i.prototype.readData=function(l){if(this.checkOffset(l),l===0)return new Uint8Array(0);var c=this.data.subarray(this.zero+this.index,this.zero+this.index+l);return this.index+=l,c},r.exports=i},{"../utils":32,"./ArrayReader":17}],22:[function(n,r,o){var a=n("../utils"),i=n("../support"),l=n("./ArrayReader"),c=n("./StringReader"),u=n("./NodeBufferReader"),f=n("./Uint8ArrayReader");r.exports=function(h){var m=a.getTypeOf(h);return a.checkSupport(m),m!=="string"||i.uint8array?m==="nodebuffer"?new u(h):i.uint8array?new f(a.transformTo("uint8array",h)):new l(a.transformTo("array",h)):new c(h)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(n,r,o){o.LOCAL_FILE_HEADER="PK",o.CENTRAL_FILE_HEADER="PK",o.CENTRAL_DIRECTORY_END="PK",o.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK\x07",o.ZIP64_CENTRAL_DIRECTORY_END="PK",o.DATA_DESCRIPTOR="PK\x07\b"},{}],24:[function(n,r,o){var a=n("./GenericWorker"),i=n("../utils");function l(c){a.call(this,"ConvertWorker to "+c),this.destType=c}i.inherits(l,a),l.prototype.processChunk=function(c){this.push({data:i.transformTo(this.destType,c.data),meta:c.meta})},r.exports=l},{"../utils":32,"./GenericWorker":28}],25:[function(n,r,o){var a=n("./GenericWorker"),i=n("../crc32");function l(){a.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}n("../utils").inherits(l,a),l.prototype.processChunk=function(c){this.streamInfo.crc32=i(c.data,this.streamInfo.crc32||0),this.push(c)},r.exports=l},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(n,r,o){var a=n("../utils"),i=n("./GenericWorker");function l(c){i.call(this,"DataLengthProbe for "+c),this.propName=c,this.withStreamInfo(c,0)}a.inherits(l,i),l.prototype.processChunk=function(c){if(c){var u=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=u+c.data.length}i.prototype.processChunk.call(this,c)},r.exports=l},{"../utils":32,"./GenericWorker":28}],27:[function(n,r,o){var a=n("../utils"),i=n("./GenericWorker");function l(c){i.call(this,"DataWorker");var u=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,c.then(function(f){u.dataIsReady=!0,u.data=f,u.max=f&&f.length||0,u.type=a.getTypeOf(f),u.isPaused||u._tickAndRepeat()},function(f){u.error(f)})}a.inherits(l,i),l.prototype.cleanUp=function(){i.prototype.cleanUp.call(this),this.data=null},l.prototype.resume=function(){return!!i.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,a.delay(this._tickAndRepeat,[],this)),!0)},l.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(a.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},l.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var c=null,u=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":c=this.data.substring(this.index,u);break;case"uint8array":c=this.data.subarray(this.index,u);break;case"array":case"nodebuffer":c=this.data.slice(this.index,u)}return this.index=u,this.push({data:c,meta:{percent:this.max?this.index/this.max*100:0}})},r.exports=l},{"../utils":32,"./GenericWorker":28}],28:[function(n,r,o){function a(i){this.name=i||"default",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}a.prototype={push:function(i){this.emit("data",i)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(i){this.emit("error",i)}return!0},error:function(i){return!this.isFinished&&(this.isPaused?this.generatedError=i:(this.isFinished=!0,this.emit("error",i),this.previous&&this.previous.error(i),this.cleanUp()),!0)},on:function(i,l){return this._listeners[i].push(l),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(i,l){if(this._listeners[i])for(var c=0;c<this._listeners[i].length;c++)this._listeners[i][c].call(this,l)},pipe:function(i){return i.registerPrevious(this)},registerPrevious:function(i){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.streamInfo=i.streamInfo,this.mergeStreamInfo(),this.previous=i;var l=this;return i.on("data",function(c){l.processChunk(c)}),i.on("end",function(){l.end()}),i.on("error",function(c){l.error(c)}),this},pause:function(){return!this.isPaused&&!this.isFinished&&(this.isPaused=!0,this.previous&&this.previous.pause(),!0)},resume:function(){if(!this.isPaused||this.isFinished)return!1;var i=this.isPaused=!1;return this.generatedError&&(this.error(this.generatedError),i=!0),this.previous&&this.previous.resume(),!i},flush:function(){},processChunk:function(i){this.push(i)},withStreamInfo:function(i,l){return this.extraStreamInfo[i]=l,this.mergeStreamInfo(),this},mergeStreamInfo:function(){for(var i in this.extraStreamInfo)Object.prototype.hasOwnProperty.call(this.extraStreamInfo,i)&&(this.streamInfo[i]=this.extraStreamInfo[i])},lock:function(){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.isLocked=!0,this.previous&&this.previous.lock()},toString:function(){var i="Worker "+this.name;return this.previous?this.previous+" -> "+i:i}},r.exports=a},{}],29:[function(n,r,o){var a=n("../utils"),i=n("./ConvertWorker"),l=n("./GenericWorker"),c=n("../base64"),u=n("../support"),f=n("../external"),h=null;if(u.nodestream)try{h=n("../nodejs/NodejsStreamOutputAdapter")}catch{}function m(x,g){return new f.Promise(function(w,v){var b=[],C=x._internalType,S=x._outputType,E=x._mimeType;x.on("data",function(_,j){b.push(_),g&&g(j)}).on("error",function(_){b=[],v(_)}).on("end",function(){try{var _=function(j,A,P){switch(j){case"blob":return a.newBlob(a.transformTo("arraybuffer",A),P);case"base64":return c.encode(A);default:return a.transformTo(j,A)}}(S,function(j,A){var P,O=0,B=null,N=0;for(P=0;P<A.length;P++)N+=A[P].length;switch(j){case"string":return A.join("");case"array":return Array.prototype.concat.apply([],A);case"uint8array":for(B=new Uint8Array(N),P=0;P<A.length;P++)B.set(A[P],O),O+=A[P].length;return B;case"nodebuffer":return Buffer.concat(A);default:throw new Error("concat : unsupported type '"+j+"'")}}(C,b),E);w(_)}catch(j){v(j)}b=[]}).resume()})}function p(x,g,w){var v=g;switch(g){case"blob":case"arraybuffer":v="uint8array";break;case"base64":v="string"}try{this._internalType=v,this._outputType=g,this._mimeType=w,a.checkSupport(v),this._worker=x.pipe(new i(v)),x.lock()}catch(b){this._worker=new l("error"),this._worker.error(b)}}p.prototype={accumulate:function(x){return m(this,x)},on:function(x,g){var w=this;return x==="data"?this._worker.on(x,function(v){g.call(w,v.data,v.meta)}):this._worker.on(x,function(){a.delay(g,arguments,w)}),this},resume:function(){return a.delay(this._worker.resume,[],this._worker),this},pause:function(){return this._worker.pause(),this},toNodejsStream:function(x){if(a.checkSupport("nodestream"),this._outputType!=="nodebuffer")throw new Error(this._outputType+" is not supported by this method");return new h(this,{objectMode:this._outputType!=="nodebuffer"},x)}},r.exports=p},{"../base64":1,"../external":6,"../nodejs/NodejsStreamOutputAdapter":13,"../support":30,"../utils":32,"./ConvertWorker":24,"./GenericWorker":28}],30:[function(n,r,o){if(o.base64=!0,o.array=!0,o.string=!0,o.arraybuffer=typeof ArrayBuffer<"u"&&typeof Uint8Array<"u",o.nodebuffer=typeof Buffer<"u",o.uint8array=typeof Uint8Array<"u",typeof ArrayBuffer>"u")o.blob=!1;else{var a=new ArrayBuffer(0);try{o.blob=new Blob([a],{type:"application/zip"}).size===0}catch{try{var i=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);i.append(a),o.blob=i.getBlob("application/zip").size===0}catch{o.blob=!1}}}try{o.nodestream=!!n("readable-stream").Readable}catch{o.nodestream=!1}},{"readable-stream":16}],31:[function(n,r,o){for(var a=n("./utils"),i=n("./support"),l=n("./nodejsUtils"),c=n("./stream/GenericWorker"),u=new Array(256),f=0;f<256;f++)u[f]=252<=f?6:248<=f?5:240<=f?4:224<=f?3:192<=f?2:1;u[254]=u[254]=1;function h(){c.call(this,"utf-8 decode"),this.leftOver=null}function m(){c.call(this,"utf-8 encode")}o.utf8encode=function(p){return i.nodebuffer?l.newBufferFrom(p,"utf-8"):function(x){var g,w,v,b,C,S=x.length,E=0;for(b=0;b<S;b++)(64512&(w=x.charCodeAt(b)))==55296&&b+1<S&&(64512&(v=x.charCodeAt(b+1)))==56320&&(w=65536+(w-55296<<10)+(v-56320),b++),E+=w<128?1:w<2048?2:w<65536?3:4;for(g=i.uint8array?new Uint8Array(E):new Array(E),b=C=0;C<E;b++)(64512&(w=x.charCodeAt(b)))==55296&&b+1<S&&(64512&(v=x.charCodeAt(b+1)))==56320&&(w=65536+(w-55296<<10)+(v-56320),b++),w<128?g[C++]=w:(w<2048?g[C++]=192|w>>>6:(w<65536?g[C++]=224|w>>>12:(g[C++]=240|w>>>18,g[C++]=128|w>>>12&63),g[C++]=128|w>>>6&63),g[C++]=128|63&w);return g}(p)},o.utf8decode=function(p){return i.nodebuffer?a.transformTo("nodebuffer",p).toString("utf-8"):function(x){var g,w,v,b,C=x.length,S=new Array(2*C);for(g=w=0;g<C;)if((v=x[g++])<128)S[w++]=v;else if(4<(b=u[v]))S[w++]=65533,g+=b-1;else{for(v&=b===2?31:b===3?15:7;1<b&&g<C;)v=v<<6|63&x[g++],b--;1<b?S[w++]=65533:v<65536?S[w++]=v:(v-=65536,S[w++]=55296|v>>10&1023,S[w++]=56320|1023&v)}return S.length!==w&&(S.subarray?S=S.subarray(0,w):S.length=w),a.applyFromCharCode(S)}(p=a.transformTo(i.uint8array?"uint8array":"array",p))},a.inherits(h,c),h.prototype.processChunk=function(p){var x=a.transformTo(i.uint8array?"uint8array":"array",p.data);if(this.leftOver&&this.leftOver.length){if(i.uint8array){var g=x;(x=new Uint8Array(g.length+this.leftOver.length)).set(this.leftOver,0),x.set(g,this.leftOver.length)}else x=this.leftOver.concat(x);this.leftOver=null}var w=function(b,C){var S;for((C=C||b.length)>b.length&&(C=b.length),S=C-1;0<=S&&(192&b[S])==128;)S--;return S<0||S===0?C:S+u[b[S]]>C?S:C}(x),v=x;w!==x.length&&(i.uint8array?(v=x.subarray(0,w),this.leftOver=x.subarray(w,x.length)):(v=x.slice(0,w),this.leftOver=x.slice(w,x.length))),this.push({data:o.utf8decode(v),meta:p.meta})},h.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:o.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},o.Utf8DecodeWorker=h,a.inherits(m,c),m.prototype.processChunk=function(p){this.push({data:o.utf8encode(p.data),meta:p.meta})},o.Utf8EncodeWorker=m},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(n,r,o){var a=n("./support"),i=n("./base64"),l=n("./nodejsUtils"),c=n("./external");function u(g){return g}function f(g,w){for(var v=0;v<g.length;++v)w[v]=255&g.charCodeAt(v);return w}n("setimmediate"),o.newBlob=function(g,w){o.checkSupport("blob");try{return new Blob([g],{type:w})}catch{try{var v=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);return v.append(g),v.getBlob(w)}catch{throw new Error("Bug : can't construct the Blob.")}}};var h={stringifyByChunk:function(g,w,v){var b=[],C=0,S=g.length;if(S<=v)return String.fromCharCode.apply(null,g);for(;C<S;)w==="array"||w==="nodebuffer"?b.push(String.fromCharCode.apply(null,g.slice(C,Math.min(C+v,S)))):b.push(String.fromCharCode.apply(null,g.subarray(C,Math.min(C+v,S)))),C+=v;return b.join("")},stringifyByChar:function(g){for(var w="",v=0;v<g.length;v++)w+=String.fromCharCode(g[v]);return w},applyCanBeUsed:{uint8array:function(){try{return a.uint8array&&String.fromCharCode.apply(null,new Uint8Array(1)).length===1}catch{return!1}}(),nodebuffer:function(){try{return a.nodebuffer&&String.fromCharCode.apply(null,l.allocBuffer(1)).length===1}catch{return!1}}()}};function m(g){var w=65536,v=o.getTypeOf(g),b=!0;if(v==="uint8array"?b=h.applyCanBeUsed.uint8array:v==="nodebuffer"&&(b=h.applyCanBeUsed.nodebuffer),b)for(;1<w;)try{return h.stringifyByChunk(g,v,w)}catch{w=Math.floor(w/2)}return h.stringifyByChar(g)}function p(g,w){for(var v=0;v<g.length;v++)w[v]=g[v];return w}o.applyFromCharCode=m;var x={};x.string={string:u,array:function(g){return f(g,new Array(g.length))},arraybuffer:function(g){return x.string.uint8array(g).buffer},uint8array:function(g){return f(g,new Uint8Array(g.length))},nodebuffer:function(g){return f(g,l.allocBuffer(g.length))}},x.array={string:m,array:u,arraybuffer:function(g){return new Uint8Array(g).buffer},uint8array:function(g){return new Uint8Array(g)},nodebuffer:function(g){return l.newBufferFrom(g)}},x.arraybuffer={string:function(g){return m(new Uint8Array(g))},array:function(g){return p(new Uint8Array(g),new Array(g.byteLength))},arraybuffer:u,uint8array:function(g){return new Uint8Array(g)},nodebuffer:function(g){return l.newBufferFrom(new Uint8Array(g))}},x.uint8array={string:m,array:function(g){return p(g,new Array(g.length))},arraybuffer:function(g){return g.buffer},uint8array:u,nodebuffer:function(g){return l.newBufferFrom(g)}},x.nodebuffer={string:m,array:function(g){return p(g,new Array(g.length))},arraybuffer:function(g){return x.nodebuffer.uint8array(g).buffer},uint8array:function(g){return p(g,new Uint8Array(g.length))},nodebuffer:u},o.transformTo=function(g,w){if(w=w||"",!g)return w;o.checkSupport(g);var v=o.getTypeOf(w);return x[v][g](w)},o.resolve=function(g){for(var w=g.split("/"),v=[],b=0;b<w.length;b++){var C=w[b];C==="."||C===""&&b!==0&&b!==w.length-1||(C===".."?v.pop():v.push(C))}return v.join("/")},o.getTypeOf=function(g){return typeof g=="string"?"string":Object.prototype.toString.call(g)==="[object Array]"?"array":a.nodebuffer&&l.isBuffer(g)?"nodebuffer":a.uint8array&&g instanceof Uint8Array?"uint8array":a.arraybuffer&&g instanceof ArrayBuffer?"arraybuffer":void 0},o.checkSupport=function(g){if(!a[g.toLowerCase()])throw new Error(g+" is not supported by this platform")},o.MAX_VALUE_16BITS=65535,o.MAX_VALUE_32BITS=-1,o.pretty=function(g){var w,v,b="";for(v=0;v<(g||"").length;v++)b+="\\x"+((w=g.charCodeAt(v))<16?"0":"")+w.toString(16).toUpperCase();return b},o.delay=function(g,w,v){setImmediate(function(){g.apply(v||null,w||[])})},o.inherits=function(g,w){function v(){}v.prototype=w.prototype,g.prototype=new v},o.extend=function(){var g,w,v={};for(g=0;g<arguments.length;g++)for(w in arguments[g])Object.prototype.hasOwnProperty.call(arguments[g],w)&&v[w]===void 0&&(v[w]=arguments[g][w]);return v},o.prepareContent=function(g,w,v,b,C){return c.Promise.resolve(w).then(function(S){return a.blob&&(S instanceof Blob||["[object File]","[object Blob]"].indexOf(Object.prototype.toString.call(S))!==-1)&&typeof FileReader<"u"?new c.Promise(function(E,_){var j=new FileReader;j.onload=function(A){E(A.target.result)},j.onerror=function(A){_(A.target.error)},j.readAsArrayBuffer(S)}):S}).then(function(S){var E=o.getTypeOf(S);return E?(E==="arraybuffer"?S=o.transformTo("uint8array",S):E==="string"&&(C?S=i.decode(S):v&&b!==!0&&(S=function(_){return f(_,a.uint8array?new Uint8Array(_.length):new Array(_.length))}(S))),S):c.Promise.reject(new Error("Can't read the data of '"+g+"'. Is it in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ?"))})}},{"./base64":1,"./external":6,"./nodejsUtils":14,"./support":30,setimmediate:54}],33:[function(n,r,o){var a=n("./reader/readerFor"),i=n("./utils"),l=n("./signature"),c=n("./zipEntry"),u=n("./support");function f(h){this.files=[],this.loadOptions=h}f.prototype={checkSignature:function(h){if(!this.reader.readAndCheckSignature(h)){this.reader.index-=4;var m=this.reader.readString(4);throw new Error("Corrupted zip or bug: unexpected signature ("+i.pretty(m)+", expected "+i.pretty(h)+")")}},isSignature:function(h,m){var p=this.reader.index;this.reader.setIndex(h);var x=this.reader.readString(4)===m;return this.reader.setIndex(p),x},readBlockEndOfCentral:function(){this.diskNumber=this.reader.readInt(2),this.diskWithCentralDirStart=this.reader.readInt(2),this.centralDirRecordsOnThisDisk=this.reader.readInt(2),this.centralDirRecords=this.reader.readInt(2),this.centralDirSize=this.reader.readInt(4),this.centralDirOffset=this.reader.readInt(4),this.zipCommentLength=this.reader.readInt(2);var h=this.reader.readData(this.zipCommentLength),m=u.uint8array?"uint8array":"array",p=i.transformTo(m,h);this.zipComment=this.loadOptions.decodeFileName(p)},readBlockZip64EndOfCentral:function(){this.zip64EndOfCentralSize=this.reader.readInt(8),this.reader.skip(4),this.diskNumber=this.reader.readInt(4),this.diskWithCentralDirStart=this.reader.readInt(4),this.centralDirRecordsOnThisDisk=this.reader.readInt(8),this.centralDirRecords=this.reader.readInt(8),this.centralDirSize=this.reader.readInt(8),this.centralDirOffset=this.reader.readInt(8),this.zip64ExtensibleData={};for(var h,m,p,x=this.zip64EndOfCentralSize-44;0<x;)h=this.reader.readInt(2),m=this.reader.readInt(4),p=this.reader.readData(m),this.zip64ExtensibleData[h]={id:h,length:m,value:p}},readBlockZip64EndOfCentralLocator:function(){if(this.diskWithZip64CentralDirStart=this.reader.readInt(4),this.relativeOffsetEndOfZip64CentralDir=this.reader.readInt(8),this.disksCount=this.reader.readInt(4),1<this.disksCount)throw new Error("Multi-volumes zip are not supported")},readLocalFiles:function(){var h,m;for(h=0;h<this.files.length;h++)m=this.files[h],this.reader.setIndex(m.localHeaderOffset),this.checkSignature(l.LOCAL_FILE_HEADER),m.readLocalPart(this.reader),m.handleUTF8(),m.processAttributes()},readCentralDir:function(){var h;for(this.reader.setIndex(this.centralDirOffset);this.reader.readAndCheckSignature(l.CENTRAL_FILE_HEADER);)(h=new c({zip64:this.zip64},this.loadOptions)).readCentralPart(this.reader),this.files.push(h);if(this.centralDirRecords!==this.files.length&&this.centralDirRecords!==0&&this.files.length===0)throw new Error("Corrupted zip or bug: expected "+this.centralDirRecords+" records in central dir, got "+this.files.length)},readEndOfCentral:function(){var h=this.reader.lastIndexOfSignature(l.CENTRAL_DIRECTORY_END);if(h<0)throw this.isSignature(0,l.LOCAL_FILE_HEADER)?new Error("Corrupted zip: can't find end of central directory"):new Error("Can't find end of central directory : is this a zip file ? If it is, see https://stuk.github.io/jszip/documentation/howto/read_zip.html");this.reader.setIndex(h);var m=h;if(this.checkSignature(l.CENTRAL_DIRECTORY_END),this.readBlockEndOfCentral(),this.diskNumber===i.MAX_VALUE_16BITS||this.diskWithCentralDirStart===i.MAX_VALUE_16BITS||this.centralDirRecordsOnThisDisk===i.MAX_VALUE_16BITS||this.centralDirRecords===i.MAX_VALUE_16BITS||this.centralDirSize===i.MAX_VALUE_32BITS||this.centralDirOffset===i.MAX_VALUE_32BITS){if(this.zip64=!0,(h=this.reader.lastIndexOfSignature(l.ZIP64_CENTRAL_DIRECTORY_LOCATOR))<0)throw new Error("Corrupted zip: can't find the ZIP64 end of central directory locator");if(this.reader.setIndex(h),this.checkSignature(l.ZIP64_CENTRAL_DIRECTORY_LOCATOR),this.readBlockZip64EndOfCentralLocator(),!this.isSignature(this.relativeOffsetEndOfZip64CentralDir,l.ZIP64_CENTRAL_DIRECTORY_END)&&(this.relativeOffsetEndOfZip64CentralDir=this.reader.lastIndexOfSignature(l.ZIP64_CENTRAL_DIRECTORY_END),this.relativeOffsetEndOfZip64CentralDir<0))throw new Error("Corrupted zip: can't find the ZIP64 end of central directory");this.reader.setIndex(this.relativeOffsetEndOfZip64CentralDir),this.checkSignature(l.ZIP64_CENTRAL_DIRECTORY_END),this.readBlockZip64EndOfCentral()}var p=this.centralDirOffset+this.centralDirSize;this.zip64&&(p+=20,p+=12+this.zip64EndOfCentralSize);var x=m-p;if(0<x)this.isSignature(m,l.CENTRAL_FILE_HEADER)||(this.reader.zero=x);else if(x<0)throw new Error("Corrupted zip: missing "+Math.abs(x)+" bytes.")},prepareReader:function(h){this.reader=a(h)},load:function(h){this.prepareReader(h),this.readEndOfCentral(),this.readCentralDir(),this.readLocalFiles()}},r.exports=f},{"./reader/readerFor":22,"./signature":23,"./support":30,"./utils":32,"./zipEntry":34}],34:[function(n,r,o){var a=n("./reader/readerFor"),i=n("./utils"),l=n("./compressedObject"),c=n("./crc32"),u=n("./utf8"),f=n("./compressions"),h=n("./support");function m(p,x){this.options=p,this.loadOptions=x}m.prototype={isEncrypted:function(){return(1&this.bitFlag)==1},useUTF8:function(){return(2048&this.bitFlag)==2048},readLocalPart:function(p){var x,g;if(p.skip(22),this.fileNameLength=p.readInt(2),g=p.readInt(2),this.fileName=p.readData(this.fileNameLength),p.skip(g),this.compressedSize===-1||this.uncompressedSize===-1)throw new Error("Bug or corrupted zip : didn't get enough information from the central directory (compressedSize === -1 || uncompressedSize === -1)");if((x=function(w){for(var v in f)if(Object.prototype.hasOwnProperty.call(f,v)&&f[v].magic===w)return f[v];return null}(this.compressionMethod))===null)throw new Error("Corrupted zip : compression "+i.pretty(this.compressionMethod)+" unknown (inner file : "+i.transformTo("string",this.fileName)+")");this.decompressed=new l(this.compressedSize,this.uncompressedSize,this.crc32,x,p.readData(this.compressedSize))},readCentralPart:function(p){this.versionMadeBy=p.readInt(2),p.skip(2),this.bitFlag=p.readInt(2),this.compressionMethod=p.readString(2),this.date=p.readDate(),this.crc32=p.readInt(4),this.compressedSize=p.readInt(4),this.uncompressedSize=p.readInt(4);var x=p.readInt(2);if(this.extraFieldsLength=p.readInt(2),this.fileCommentLength=p.readInt(2),this.diskNumberStart=p.readInt(2),this.internalFileAttributes=p.readInt(2),this.externalFileAttributes=p.readInt(4),this.localHeaderOffset=p.readInt(4),this.isEncrypted())throw new Error("Encrypted zip are not supported");p.skip(x),this.readExtraFields(p),this.parseZIP64ExtraField(p),this.fileComment=p.readData(this.fileCommentLength)},processAttributes:function(){this.unixPermissions=null,this.dosPermissions=null;var p=this.versionMadeBy>>8;this.dir=!!(16&this.externalFileAttributes),p==0&&(this.dosPermissions=63&this.externalFileAttributes),p==3&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||this.fileNameStr.slice(-1)!=="/"||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var p=a(this.extraFields[1].value);this.uncompressedSize===i.MAX_VALUE_32BITS&&(this.uncompressedSize=p.readInt(8)),this.compressedSize===i.MAX_VALUE_32BITS&&(this.compressedSize=p.readInt(8)),this.localHeaderOffset===i.MAX_VALUE_32BITS&&(this.localHeaderOffset=p.readInt(8)),this.diskNumberStart===i.MAX_VALUE_32BITS&&(this.diskNumberStart=p.readInt(4))}},readExtraFields:function(p){var x,g,w,v=p.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});p.index+4<v;)x=p.readInt(2),g=p.readInt(2),w=p.readData(g),this.extraFields[x]={id:x,length:g,value:w};p.setIndex(v)},handleUTF8:function(){var p=h.uint8array?"uint8array":"array";if(this.useUTF8())this.fileNameStr=u.utf8decode(this.fileName),this.fileCommentStr=u.utf8decode(this.fileComment);else{var x=this.findExtraFieldUnicodePath();if(x!==null)this.fileNameStr=x;else{var g=i.transformTo(p,this.fileName);this.fileNameStr=this.loadOptions.decodeFileName(g)}var w=this.findExtraFieldUnicodeComment();if(w!==null)this.fileCommentStr=w;else{var v=i.transformTo(p,this.fileComment);this.fileCommentStr=this.loadOptions.decodeFileName(v)}}},findExtraFieldUnicodePath:function(){var p=this.extraFields[28789];if(p){var x=a(p.value);return x.readInt(1)!==1||c(this.fileName)!==x.readInt(4)?null:u.utf8decode(x.readData(p.length-5))}return null},findExtraFieldUnicodeComment:function(){var p=this.extraFields[25461];if(p){var x=a(p.value);return x.readInt(1)!==1||c(this.fileComment)!==x.readInt(4)?null:u.utf8decode(x.readData(p.length-5))}return null}},r.exports=m},{"./compressedObject":2,"./compressions":3,"./crc32":4,"./reader/readerFor":22,"./support":30,"./utf8":31,"./utils":32}],35:[function(n,r,o){function a(x,g,w){this.name=x,this.dir=w.dir,this.date=w.date,this.comment=w.comment,this.unixPermissions=w.unixPermissions,this.dosPermissions=w.dosPermissions,this._data=g,this._dataBinary=w.binary,this.options={compression:w.compression,compressionOptions:w.compressionOptions}}var i=n("./stream/StreamHelper"),l=n("./stream/DataWorker"),c=n("./utf8"),u=n("./compressedObject"),f=n("./stream/GenericWorker");a.prototype={internalStream:function(x){var g=null,w="string";try{if(!x)throw new Error("No output type specified.");var v=(w=x.toLowerCase())==="string"||w==="text";w!=="binarystring"&&w!=="text"||(w="string"),g=this._decompressWorker();var b=!this._dataBinary;b&&!v&&(g=g.pipe(new c.Utf8EncodeWorker)),!b&&v&&(g=g.pipe(new c.Utf8DecodeWorker))}catch(C){(g=new f("error")).error(C)}return new i(g,w,"")},async:function(x,g){return this.internalStream(x).accumulate(g)},nodeStream:function(x,g){return this.internalStream(x||"nodebuffer").toNodejsStream(g)},_compressWorker:function(x,g){if(this._data instanceof u&&this._data.compression.magic===x.magic)return this._data.getCompressedWorker();var w=this._decompressWorker();return this._dataBinary||(w=w.pipe(new c.Utf8EncodeWorker)),u.createWorkerFrom(w,x,g)},_decompressWorker:function(){return this._data instanceof u?this._data.getContentWorker():this._data instanceof f?this._data:new l(this._data)}};for(var h=["asText","asBinary","asNodeBuffer","asUint8Array","asArrayBuffer"],m=function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},p=0;p<h.length;p++)a.prototype[h[p]]=m;r.exports=a},{"./compressedObject":2,"./stream/DataWorker":27,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31}],36:[function(n,r,o){(function(a){var i,l,c=a.MutationObserver||a.WebKitMutationObserver;if(c){var u=0,f=new c(x),h=a.document.createTextNode("");f.observe(h,{characterData:!0}),i=function(){h.data=u=++u%2}}else if(a.setImmediate||a.MessageChannel===void 0)i="document"in a&&"onreadystatechange"in a.document.createElement("script")?function(){var g=a.document.createElement("script");g.onreadystatechange=function(){x(),g.onreadystatechange=null,g.parentNode.removeChild(g),g=null},a.document.documentElement.appendChild(g)}:function(){setTimeout(x,0)};else{var m=new a.MessageChannel;m.port1.onmessage=x,i=function(){m.port2.postMessage(0)}}var p=[];function x(){var g,w;l=!0;for(var v=p.length;v;){for(w=p,p=[],g=-1;++g<v;)w[g]();v=p.length}l=!1}r.exports=function(g){p.push(g)!==1||l||i()}}).call(this,typeof Ni<"u"?Ni:typeof self<"u"?self:typeof window<"u"?window:{})},{}],37:[function(n,r,o){var a=n("immediate");function i(){}var l={},c=["REJECTED"],u=["FULFILLED"],f=["PENDING"];function h(v){if(typeof v!="function")throw new TypeError("resolver must be a function");this.state=f,this.queue=[],this.outcome=void 0,v!==i&&g(this,v)}function m(v,b,C){this.promise=v,typeof b=="function"&&(this.onFulfilled=b,this.callFulfilled=this.otherCallFulfilled),typeof C=="function"&&(this.onRejected=C,this.callRejected=this.otherCallRejected)}function p(v,b,C){a(function(){var S;try{S=b(C)}catch(E){return l.reject(v,E)}S===v?l.reject(v,new TypeError("Cannot resolve promise with itself")):l.resolve(v,S)})}function x(v){var b=v&&v.then;if(v&&(typeof v=="object"||typeof v=="function")&&typeof b=="function")return function(){b.apply(v,arguments)}}function g(v,b){var C=!1;function S(j){C||(C=!0,l.reject(v,j))}function E(j){C||(C=!0,l.resolve(v,j))}var _=w(function(){b(E,S)});_.status==="error"&&S(_.value)}function w(v,b){var C={};try{C.value=v(b),C.status="success"}catch(S){C.status="error",C.value=S}return C}(r.exports=h).prototype.finally=function(v){if(typeof v!="function")return this;var b=this.constructor;return this.then(function(C){return b.resolve(v()).then(function(){return C})},function(C){return b.resolve(v()).then(function(){throw C})})},h.prototype.catch=function(v){return this.then(null,v)},h.prototype.then=function(v,b){if(typeof v!="function"&&this.state===u||typeof b!="function"&&this.state===c)return this;var C=new this.constructor(i);return this.state!==f?p(C,this.state===u?v:b,this.outcome):this.queue.push(new m(C,v,b)),C},m.prototype.callFulfilled=function(v){l.resolve(this.promise,v)},m.prototype.otherCallFulfilled=function(v){p(this.promise,this.onFulfilled,v)},m.prototype.callRejected=function(v){l.reject(this.promise,v)},m.prototype.otherCallRejected=function(v){p(this.promise,this.onRejected,v)},l.resolve=function(v,b){var C=w(x,b);if(C.status==="error")return l.reject(v,C.value);var S=C.value;if(S)g(v,S);else{v.state=u,v.outcome=b;for(var E=-1,_=v.queue.length;++E<_;)v.queue[E].callFulfilled(b)}return v},l.reject=function(v,b){v.state=c,v.outcome=b;for(var C=-1,S=v.queue.length;++C<S;)v.queue[C].callRejected(b);return v},h.resolve=function(v){return v instanceof this?v:l.resolve(new this(i),v)},h.reject=function(v){var b=new this(i);return l.reject(b,v)},h.all=function(v){var b=this;if(Object.prototype.toString.call(v)!=="[object Array]")return this.reject(new TypeError("must be an array"));var C=v.length,S=!1;if(!C)return this.resolve([]);for(var E=new Array(C),_=0,j=-1,A=new this(i);++j<C;)P(v[j],j);return A;function P(O,B){b.resolve(O).then(function(N){E[B]=N,++_!==C||S||(S=!0,l.resolve(A,E))},function(N){S||(S=!0,l.reject(A,N))})}},h.race=function(v){var b=this;if(Object.prototype.toString.call(v)!=="[object Array]")return this.reject(new TypeError("must be an array"));var C=v.length,S=!1;if(!C)return this.resolve([]);for(var E=-1,_=new this(i);++E<C;)j=v[E],b.resolve(j).then(function(A){S||(S=!0,l.resolve(_,A))},function(A){S||(S=!0,l.reject(_,A))});var j;return _}},{immediate:36}],38:[function(n,r,o){var a={};(0,n("./lib/utils/common").assign)(a,n("./lib/deflate"),n("./lib/inflate"),n("./lib/zlib/constants")),r.exports=a},{"./lib/deflate":39,"./lib/inflate":40,"./lib/utils/common":41,"./lib/zlib/constants":44}],39:[function(n,r,o){var a=n("./zlib/deflate"),i=n("./utils/common"),l=n("./utils/strings"),c=n("./zlib/messages"),u=n("./zlib/zstream"),f=Object.prototype.toString,h=0,m=-1,p=0,x=8;function g(v){if(!(this instanceof g))return new g(v);this.options=i.assign({level:m,method:x,chunkSize:16384,windowBits:15,memLevel:8,strategy:p,to:""},v||{});var b=this.options;b.raw&&0<b.windowBits?b.windowBits=-b.windowBits:b.gzip&&0<b.windowBits&&b.windowBits<16&&(b.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new u,this.strm.avail_out=0;var C=a.deflateInit2(this.strm,b.level,b.method,b.windowBits,b.memLevel,b.strategy);if(C!==h)throw new Error(c[C]);if(b.header&&a.deflateSetHeader(this.strm,b.header),b.dictionary){var S;if(S=typeof b.dictionary=="string"?l.string2buf(b.dictionary):f.call(b.dictionary)==="[object ArrayBuffer]"?new Uint8Array(b.dictionary):b.dictionary,(C=a.deflateSetDictionary(this.strm,S))!==h)throw new Error(c[C]);this._dict_set=!0}}function w(v,b){var C=new g(b);if(C.push(v,!0),C.err)throw C.msg||c[C.err];return C.result}g.prototype.push=function(v,b){var C,S,E=this.strm,_=this.options.chunkSize;if(this.ended)return!1;S=b===~~b?b:b===!0?4:0,typeof v=="string"?E.input=l.string2buf(v):f.call(v)==="[object ArrayBuffer]"?E.input=new Uint8Array(v):E.input=v,E.next_in=0,E.avail_in=E.input.length;do{if(E.avail_out===0&&(E.output=new i.Buf8(_),E.next_out=0,E.avail_out=_),(C=a.deflate(E,S))!==1&&C!==h)return this.onEnd(C),!(this.ended=!0);E.avail_out!==0&&(E.avail_in!==0||S!==4&&S!==2)||(this.options.to==="string"?this.onData(l.buf2binstring(i.shrinkBuf(E.output,E.next_out))):this.onData(i.shrinkBuf(E.output,E.next_out)))}while((0<E.avail_in||E.avail_out===0)&&C!==1);return S===4?(C=a.deflateEnd(this.strm),this.onEnd(C),this.ended=!0,C===h):S!==2||(this.onEnd(h),!(E.avail_out=0))},g.prototype.onData=function(v){this.chunks.push(v)},g.prototype.onEnd=function(v){v===h&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=i.flattenChunks(this.chunks)),this.chunks=[],this.err=v,this.msg=this.strm.msg},o.Deflate=g,o.deflate=w,o.deflateRaw=function(v,b){return(b=b||{}).raw=!0,w(v,b)},o.gzip=function(v,b){return(b=b||{}).gzip=!0,w(v,b)}},{"./utils/common":41,"./utils/strings":42,"./zlib/deflate":46,"./zlib/messages":51,"./zlib/zstream":53}],40:[function(n,r,o){var a=n("./zlib/inflate"),i=n("./utils/common"),l=n("./utils/strings"),c=n("./zlib/constants"),u=n("./zlib/messages"),f=n("./zlib/zstream"),h=n("./zlib/gzheader"),m=Object.prototype.toString;function p(g){if(!(this instanceof p))return new p(g);this.options=i.assign({chunkSize:16384,windowBits:0,to:""},g||{});var w=this.options;w.raw&&0<=w.windowBits&&w.windowBits<16&&(w.windowBits=-w.windowBits,w.windowBits===0&&(w.windowBits=-15)),!(0<=w.windowBits&&w.windowBits<16)||g&&g.windowBits||(w.windowBits+=32),15<w.windowBits&&w.windowBits<48&&(15&w.windowBits)==0&&(w.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new f,this.strm.avail_out=0;var v=a.inflateInit2(this.strm,w.windowBits);if(v!==c.Z_OK)throw new Error(u[v]);this.header=new h,a.inflateGetHeader(this.strm,this.header)}function x(g,w){var v=new p(w);if(v.push(g,!0),v.err)throw v.msg||u[v.err];return v.result}p.prototype.push=function(g,w){var v,b,C,S,E,_,j=this.strm,A=this.options.chunkSize,P=this.options.dictionary,O=!1;if(this.ended)return!1;b=w===~~w?w:w===!0?c.Z_FINISH:c.Z_NO_FLUSH,typeof g=="string"?j.input=l.binstring2buf(g):m.call(g)==="[object ArrayBuffer]"?j.input=new Uint8Array(g):j.input=g,j.next_in=0,j.avail_in=j.input.length;do{if(j.avail_out===0&&(j.output=new i.Buf8(A),j.next_out=0,j.avail_out=A),(v=a.inflate(j,c.Z_NO_FLUSH))===c.Z_NEED_DICT&&P&&(_=typeof P=="string"?l.string2buf(P):m.call(P)==="[object ArrayBuffer]"?new Uint8Array(P):P,v=a.inflateSetDictionary(this.strm,_)),v===c.Z_BUF_ERROR&&O===!0&&(v=c.Z_OK,O=!1),v!==c.Z_STREAM_END&&v!==c.Z_OK)return this.onEnd(v),!(this.ended=!0);j.next_out&&(j.avail_out!==0&&v!==c.Z_STREAM_END&&(j.avail_in!==0||b!==c.Z_FINISH&&b!==c.Z_SYNC_FLUSH)||(this.options.to==="string"?(C=l.utf8border(j.output,j.next_out),S=j.next_out-C,E=l.buf2string(j.output,C),j.next_out=S,j.avail_out=A-S,S&&i.arraySet(j.output,j.output,C,S,0),this.onData(E)):this.onData(i.shrinkBuf(j.output,j.next_out)))),j.avail_in===0&&j.avail_out===0&&(O=!0)}while((0<j.avail_in||j.avail_out===0)&&v!==c.Z_STREAM_END);return v===c.Z_STREAM_END&&(b=c.Z_FINISH),b===c.Z_FINISH?(v=a.inflateEnd(this.strm),this.onEnd(v),this.ended=!0,v===c.Z_OK):b!==c.Z_SYNC_FLUSH||(this.onEnd(c.Z_OK),!(j.avail_out=0))},p.prototype.onData=function(g){this.chunks.push(g)},p.prototype.onEnd=function(g){g===c.Z_OK&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=i.flattenChunks(this.chunks)),this.chunks=[],this.err=g,this.msg=this.strm.msg},o.Inflate=p,o.inflate=x,o.inflateRaw=function(g,w){return(w=w||{}).raw=!0,x(g,w)},o.ungzip=x},{"./utils/common":41,"./utils/strings":42,"./zlib/constants":44,"./zlib/gzheader":47,"./zlib/inflate":49,"./zlib/messages":51,"./zlib/zstream":53}],41:[function(n,r,o){var a=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Int32Array<"u";o.assign=function(c){for(var u=Array.prototype.slice.call(arguments,1);u.length;){var f=u.shift();if(f){if(typeof f!="object")throw new TypeError(f+"must be non-object");for(var h in f)f.hasOwnProperty(h)&&(c[h]=f[h])}}return c},o.shrinkBuf=function(c,u){return c.length===u?c:c.subarray?c.subarray(0,u):(c.length=u,c)};var i={arraySet:function(c,u,f,h,m){if(u.subarray&&c.subarray)c.set(u.subarray(f,f+h),m);else for(var p=0;p<h;p++)c[m+p]=u[f+p]},flattenChunks:function(c){var u,f,h,m,p,x;for(u=h=0,f=c.length;u<f;u++)h+=c[u].length;for(x=new Uint8Array(h),u=m=0,f=c.length;u<f;u++)p=c[u],x.set(p,m),m+=p.length;return x}},l={arraySet:function(c,u,f,h,m){for(var p=0;p<h;p++)c[m+p]=u[f+p]},flattenChunks:function(c){return[].concat.apply([],c)}};o.setTyped=function(c){c?(o.Buf8=Uint8Array,o.Buf16=Uint16Array,o.Buf32=Int32Array,o.assign(o,i)):(o.Buf8=Array,o.Buf16=Array,o.Buf32=Array,o.assign(o,l))},o.setTyped(a)},{}],42:[function(n,r,o){var a=n("./common"),i=!0,l=!0;try{String.fromCharCode.apply(null,[0])}catch{i=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{l=!1}for(var c=new a.Buf8(256),u=0;u<256;u++)c[u]=252<=u?6:248<=u?5:240<=u?4:224<=u?3:192<=u?2:1;function f(h,m){if(m<65537&&(h.subarray&&l||!h.subarray&&i))return String.fromCharCode.apply(null,a.shrinkBuf(h,m));for(var p="",x=0;x<m;x++)p+=String.fromCharCode(h[x]);return p}c[254]=c[254]=1,o.string2buf=function(h){var m,p,x,g,w,v=h.length,b=0;for(g=0;g<v;g++)(64512&(p=h.charCodeAt(g)))==55296&&g+1<v&&(64512&(x=h.charCodeAt(g+1)))==56320&&(p=65536+(p-55296<<10)+(x-56320),g++),b+=p<128?1:p<2048?2:p<65536?3:4;for(m=new a.Buf8(b),g=w=0;w<b;g++)(64512&(p=h.charCodeAt(g)))==55296&&g+1<v&&(64512&(x=h.charCodeAt(g+1)))==56320&&(p=65536+(p-55296<<10)+(x-56320),g++),p<128?m[w++]=p:(p<2048?m[w++]=192|p>>>6:(p<65536?m[w++]=224|p>>>12:(m[w++]=240|p>>>18,m[w++]=128|p>>>12&63),m[w++]=128|p>>>6&63),m[w++]=128|63&p);return m},o.buf2binstring=function(h){return f(h,h.length)},o.binstring2buf=function(h){for(var m=new a.Buf8(h.length),p=0,x=m.length;p<x;p++)m[p]=h.charCodeAt(p);return m},o.buf2string=function(h,m){var p,x,g,w,v=m||h.length,b=new Array(2*v);for(p=x=0;p<v;)if((g=h[p++])<128)b[x++]=g;else if(4<(w=c[g]))b[x++]=65533,p+=w-1;else{for(g&=w===2?31:w===3?15:7;1<w&&p<v;)g=g<<6|63&h[p++],w--;1<w?b[x++]=65533:g<65536?b[x++]=g:(g-=65536,b[x++]=55296|g>>10&1023,b[x++]=56320|1023&g)}return f(b,x)},o.utf8border=function(h,m){var p;for((m=m||h.length)>h.length&&(m=h.length),p=m-1;0<=p&&(192&h[p])==128;)p--;return p<0||p===0?m:p+c[h[p]]>m?p:m}},{"./common":41}],43:[function(n,r,o){r.exports=function(a,i,l,c){for(var u=65535&a|0,f=a>>>16&65535|0,h=0;l!==0;){for(l-=h=2e3<l?2e3:l;f=f+(u=u+i[c++]|0)|0,--h;);u%=65521,f%=65521}return u|f<<16|0}},{}],44:[function(n,r,o){r.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},{}],45:[function(n,r,o){var a=function(){for(var i,l=[],c=0;c<256;c++){i=c;for(var u=0;u<8;u++)i=1&i?3988292384^i>>>1:i>>>1;l[c]=i}return l}();r.exports=function(i,l,c,u){var f=a,h=u+c;i^=-1;for(var m=u;m<h;m++)i=i>>>8^f[255&(i^l[m])];return-1^i}},{}],46:[function(n,r,o){var a,i=n("../utils/common"),l=n("./trees"),c=n("./adler32"),u=n("./crc32"),f=n("./messages"),h=0,m=4,p=0,x=-2,g=-1,w=4,v=2,b=8,C=9,S=286,E=30,_=19,j=2*S+1,A=15,P=3,O=258,B=O+P+1,N=42,M=113,y=1,T=2,R=3,z=4;function F(k,oe){return k.msg=f[oe],oe}function I(k){return(k<<1)-(4<k?9:0)}function J(k){for(var oe=k.length;0<=--oe;)k[oe]=0}function L(k){var oe=k.state,ie=oe.pending;ie>k.avail_out&&(ie=k.avail_out),ie!==0&&(i.arraySet(k.output,oe.pending_buf,oe.pending_out,ie,k.next_out),k.next_out+=ie,oe.pending_out+=ie,k.total_out+=ie,k.avail_out-=ie,oe.pending-=ie,oe.pending===0&&(oe.pending_out=0))}function D(k,oe){l._tr_flush_block(k,0<=k.block_start?k.block_start:-1,k.strstart-k.block_start,oe),k.block_start=k.strstart,L(k.strm)}function W(k,oe){k.pending_buf[k.pending++]=oe}function G(k,oe){k.pending_buf[k.pending++]=oe>>>8&255,k.pending_buf[k.pending++]=255&oe}function V(k,oe){var ie,Z,U=k.max_chain_length,re=k.strstart,$=k.prev_length,Y=k.nice_match,H=k.strstart>k.w_size-B?k.strstart-(k.w_size-B):0,ce=k.window,ue=k.w_mask,ae=k.prev,pe=k.strstart+O,Te=ce[re+$-1],Ae=ce[re+$];k.prev_length>=k.good_match&&(U>>=2),Y>k.lookahead&&(Y=k.lookahead);do if(ce[(ie=oe)+$]===Ae&&ce[ie+$-1]===Te&&ce[ie]===ce[re]&&ce[++ie]===ce[re+1]){re+=2,ie++;do;while(ce[++re]===ce[++ie]&&ce[++re]===ce[++ie]&&ce[++re]===ce[++ie]&&ce[++re]===ce[++ie]&&ce[++re]===ce[++ie]&&ce[++re]===ce[++ie]&&ce[++re]===ce[++ie]&&ce[++re]===ce[++ie]&&re<pe);if(Z=O-(pe-re),re=pe-O,$<Z){if(k.match_start=oe,Y<=($=Z))break;Te=ce[re+$-1],Ae=ce[re+$]}}while((oe=ae[oe&ue])>H&&--U!=0);return $<=k.lookahead?$:k.lookahead}function Q(k){var oe,ie,Z,U,re,$,Y,H,ce,ue,ae=k.w_size;do{if(U=k.window_size-k.lookahead-k.strstart,k.strstart>=ae+(ae-B)){for(i.arraySet(k.window,k.window,ae,ae,0),k.match_start-=ae,k.strstart-=ae,k.block_start-=ae,oe=ie=k.hash_size;Z=k.head[--oe],k.head[oe]=ae<=Z?Z-ae:0,--ie;);for(oe=ie=ae;Z=k.prev[--oe],k.prev[oe]=ae<=Z?Z-ae:0,--ie;);U+=ae}if(k.strm.avail_in===0)break;if($=k.strm,Y=k.window,H=k.strstart+k.lookahead,ce=U,ue=void 0,ue=$.avail_in,ce<ue&&(ue=ce),ie=ue===0?0:($.avail_in-=ue,i.arraySet(Y,$.input,$.next_in,ue,H),$.state.wrap===1?$.adler=c($.adler,Y,ue,H):$.state.wrap===2&&($.adler=u($.adler,Y,ue,H)),$.next_in+=ue,$.total_in+=ue,ue),k.lookahead+=ie,k.lookahead+k.insert>=P)for(re=k.strstart-k.insert,k.ins_h=k.window[re],k.ins_h=(k.ins_h<<k.hash_shift^k.window[re+1])&k.hash_mask;k.insert&&(k.ins_h=(k.ins_h<<k.hash_shift^k.window[re+P-1])&k.hash_mask,k.prev[re&k.w_mask]=k.head[k.ins_h],k.head[k.ins_h]=re,re++,k.insert--,!(k.lookahead+k.insert<P)););}while(k.lookahead<B&&k.strm.avail_in!==0)}function X(k,oe){for(var ie,Z;;){if(k.lookahead<B){if(Q(k),k.lookahead<B&&oe===h)return y;if(k.lookahead===0)break}if(ie=0,k.lookahead>=P&&(k.ins_h=(k.ins_h<<k.hash_shift^k.window[k.strstart+P-1])&k.hash_mask,ie=k.prev[k.strstart&k.w_mask]=k.head[k.ins_h],k.head[k.ins_h]=k.strstart),ie!==0&&k.strstart-ie<=k.w_size-B&&(k.match_length=V(k,ie)),k.match_length>=P)if(Z=l._tr_tally(k,k.strstart-k.match_start,k.match_length-P),k.lookahead-=k.match_length,k.match_length<=k.max_lazy_match&&k.lookahead>=P){for(k.match_length--;k.strstart++,k.ins_h=(k.ins_h<<k.hash_shift^k.window[k.strstart+P-1])&k.hash_mask,ie=k.prev[k.strstart&k.w_mask]=k.head[k.ins_h],k.head[k.ins_h]=k.strstart,--k.match_length!=0;);k.strstart++}else k.strstart+=k.match_length,k.match_length=0,k.ins_h=k.window[k.strstart],k.ins_h=(k.ins_h<<k.hash_shift^k.window[k.strstart+1])&k.hash_mask;else Z=l._tr_tally(k,0,k.window[k.strstart]),k.lookahead--,k.strstart++;if(Z&&(D(k,!1),k.strm.avail_out===0))return y}return k.insert=k.strstart<P-1?k.strstart:P-1,oe===m?(D(k,!0),k.strm.avail_out===0?R:z):k.last_lit&&(D(k,!1),k.strm.avail_out===0)?y:T}function K(k,oe){for(var ie,Z,U;;){if(k.lookahead<B){if(Q(k),k.lookahead<B&&oe===h)return y;if(k.lookahead===0)break}if(ie=0,k.lookahead>=P&&(k.ins_h=(k.ins_h<<k.hash_shift^k.window[k.strstart+P-1])&k.hash_mask,ie=k.prev[k.strstart&k.w_mask]=k.head[k.ins_h],k.head[k.ins_h]=k.strstart),k.prev_length=k.match_length,k.prev_match=k.match_start,k.match_length=P-1,ie!==0&&k.prev_length<k.max_lazy_match&&k.strstart-ie<=k.w_size-B&&(k.match_length=V(k,ie),k.match_length<=5&&(k.strategy===1||k.match_length===P&&4096<k.strstart-k.match_start)&&(k.match_length=P-1)),k.prev_length>=P&&k.match_length<=k.prev_length){for(U=k.strstart+k.lookahead-P,Z=l._tr_tally(k,k.strstart-1-k.prev_match,k.prev_length-P),k.lookahead-=k.prev_length-1,k.prev_length-=2;++k.strstart<=U&&(k.ins_h=(k.ins_h<<k.hash_shift^k.window[k.strstart+P-1])&k.hash_mask,ie=k.prev[k.strstart&k.w_mask]=k.head[k.ins_h],k.head[k.ins_h]=k.strstart),--k.prev_length!=0;);if(k.match_available=0,k.match_length=P-1,k.strstart++,Z&&(D(k,!1),k.strm.avail_out===0))return y}else if(k.match_available){if((Z=l._tr_tally(k,0,k.window[k.strstart-1]))&&D(k,!1),k.strstart++,k.lookahead--,k.strm.avail_out===0)return y}else k.match_available=1,k.strstart++,k.lookahead--}return k.match_available&&(Z=l._tr_tally(k,0,k.window[k.strstart-1]),k.match_available=0),k.insert=k.strstart<P-1?k.strstart:P-1,oe===m?(D(k,!0),k.strm.avail_out===0?R:z):k.last_lit&&(D(k,!1),k.strm.avail_out===0)?y:T}function q(k,oe,ie,Z,U){this.good_length=k,this.max_lazy=oe,this.nice_length=ie,this.max_chain=Z,this.func=U}function ne(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=b,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new i.Buf16(2*j),this.dyn_dtree=new i.Buf16(2*(2*E+1)),this.bl_tree=new i.Buf16(2*(2*_+1)),J(this.dyn_ltree),J(this.dyn_dtree),J(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new i.Buf16(A+1),this.heap=new i.Buf16(2*S+1),J(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new i.Buf16(2*S+1),J(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function de(k){var oe;return k&&k.state?(k.total_in=k.total_out=0,k.data_type=v,(oe=k.state).pending=0,oe.pending_out=0,oe.wrap<0&&(oe.wrap=-oe.wrap),oe.status=oe.wrap?N:M,k.adler=oe.wrap===2?0:1,oe.last_flush=h,l._tr_init(oe),p):F(k,x)}function se(k){var oe=de(k);return oe===p&&function(ie){ie.window_size=2*ie.w_size,J(ie.head),ie.max_lazy_match=a[ie.level].max_lazy,ie.good_match=a[ie.level].good_length,ie.nice_match=a[ie.level].nice_length,ie.max_chain_length=a[ie.level].max_chain,ie.strstart=0,ie.block_start=0,ie.lookahead=0,ie.insert=0,ie.match_length=ie.prev_length=P-1,ie.match_available=0,ie.ins_h=0}(k.state),oe}function me(k,oe,ie,Z,U,re){if(!k)return x;var $=1;if(oe===g&&(oe=6),Z<0?($=0,Z=-Z):15<Z&&($=2,Z-=16),U<1||C<U||ie!==b||Z<8||15<Z||oe<0||9<oe||re<0||w<re)return F(k,x);Z===8&&(Z=9);var Y=new ne;return(k.state=Y).strm=k,Y.wrap=$,Y.gzhead=null,Y.w_bits=Z,Y.w_size=1<<Y.w_bits,Y.w_mask=Y.w_size-1,Y.hash_bits=U+7,Y.hash_size=1<<Y.hash_bits,Y.hash_mask=Y.hash_size-1,Y.hash_shift=~~((Y.hash_bits+P-1)/P),Y.window=new i.Buf8(2*Y.w_size),Y.head=new i.Buf16(Y.hash_size),Y.prev=new i.Buf16(Y.w_size),Y.lit_bufsize=1<<U+6,Y.pending_buf_size=4*Y.lit_bufsize,Y.pending_buf=new i.Buf8(Y.pending_buf_size),Y.d_buf=1*Y.lit_bufsize,Y.l_buf=3*Y.lit_bufsize,Y.level=oe,Y.strategy=re,Y.method=ie,se(k)}a=[new q(0,0,0,0,function(k,oe){var ie=65535;for(ie>k.pending_buf_size-5&&(ie=k.pending_buf_size-5);;){if(k.lookahead<=1){if(Q(k),k.lookahead===0&&oe===h)return y;if(k.lookahead===0)break}k.strstart+=k.lookahead,k.lookahead=0;var Z=k.block_start+ie;if((k.strstart===0||k.strstart>=Z)&&(k.lookahead=k.strstart-Z,k.strstart=Z,D(k,!1),k.strm.avail_out===0)||k.strstart-k.block_start>=k.w_size-B&&(D(k,!1),k.strm.avail_out===0))return y}return k.insert=0,oe===m?(D(k,!0),k.strm.avail_out===0?R:z):(k.strstart>k.block_start&&(D(k,!1),k.strm.avail_out),y)}),new q(4,4,8,4,X),new q(4,5,16,8,X),new q(4,6,32,32,X),new q(4,4,16,16,K),new q(8,16,32,32,K),new q(8,16,128,128,K),new q(8,32,128,256,K),new q(32,128,258,1024,K),new q(32,258,258,4096,K)],o.deflateInit=function(k,oe){return me(k,oe,b,15,8,0)},o.deflateInit2=me,o.deflateReset=se,o.deflateResetKeep=de,o.deflateSetHeader=function(k,oe){return k&&k.state?k.state.wrap!==2?x:(k.state.gzhead=oe,p):x},o.deflate=function(k,oe){var ie,Z,U,re;if(!k||!k.state||5<oe||oe<0)return k?F(k,x):x;if(Z=k.state,!k.output||!k.input&&k.avail_in!==0||Z.status===666&&oe!==m)return F(k,k.avail_out===0?-5:x);if(Z.strm=k,ie=Z.last_flush,Z.last_flush=oe,Z.status===N)if(Z.wrap===2)k.adler=0,W(Z,31),W(Z,139),W(Z,8),Z.gzhead?(W(Z,(Z.gzhead.text?1:0)+(Z.gzhead.hcrc?2:0)+(Z.gzhead.extra?4:0)+(Z.gzhead.name?8:0)+(Z.gzhead.comment?16:0)),W(Z,255&Z.gzhead.time),W(Z,Z.gzhead.time>>8&255),W(Z,Z.gzhead.time>>16&255),W(Z,Z.gzhead.time>>24&255),W(Z,Z.level===9?2:2<=Z.strategy||Z.level<2?4:0),W(Z,255&Z.gzhead.os),Z.gzhead.extra&&Z.gzhead.extra.length&&(W(Z,255&Z.gzhead.extra.length),W(Z,Z.gzhead.extra.length>>8&255)),Z.gzhead.hcrc&&(k.adler=u(k.adler,Z.pending_buf,Z.pending,0)),Z.gzindex=0,Z.status=69):(W(Z,0),W(Z,0),W(Z,0),W(Z,0),W(Z,0),W(Z,Z.level===9?2:2<=Z.strategy||Z.level<2?4:0),W(Z,3),Z.status=M);else{var $=b+(Z.w_bits-8<<4)<<8;$|=(2<=Z.strategy||Z.level<2?0:Z.level<6?1:Z.level===6?2:3)<<6,Z.strstart!==0&&($|=32),$+=31-$%31,Z.status=M,G(Z,$),Z.strstart!==0&&(G(Z,k.adler>>>16),G(Z,65535&k.adler)),k.adler=1}if(Z.status===69)if(Z.gzhead.extra){for(U=Z.pending;Z.gzindex<(65535&Z.gzhead.extra.length)&&(Z.pending!==Z.pending_buf_size||(Z.gzhead.hcrc&&Z.pending>U&&(k.adler=u(k.adler,Z.pending_buf,Z.pending-U,U)),L(k),U=Z.pending,Z.pending!==Z.pending_buf_size));)W(Z,255&Z.gzhead.extra[Z.gzindex]),Z.gzindex++;Z.gzhead.hcrc&&Z.pending>U&&(k.adler=u(k.adler,Z.pending_buf,Z.pending-U,U)),Z.gzindex===Z.gzhead.extra.length&&(Z.gzindex=0,Z.status=73)}else Z.status=73;if(Z.status===73)if(Z.gzhead.name){U=Z.pending;do{if(Z.pending===Z.pending_buf_size&&(Z.gzhead.hcrc&&Z.pending>U&&(k.adler=u(k.adler,Z.pending_buf,Z.pending-U,U)),L(k),U=Z.pending,Z.pending===Z.pending_buf_size)){re=1;break}re=Z.gzindex<Z.gzhead.name.length?255&Z.gzhead.name.charCodeAt(Z.gzindex++):0,W(Z,re)}while(re!==0);Z.gzhead.hcrc&&Z.pending>U&&(k.adler=u(k.adler,Z.pending_buf,Z.pending-U,U)),re===0&&(Z.gzindex=0,Z.status=91)}else Z.status=91;if(Z.status===91)if(Z.gzhead.comment){U=Z.pending;do{if(Z.pending===Z.pending_buf_size&&(Z.gzhead.hcrc&&Z.pending>U&&(k.adler=u(k.adler,Z.pending_buf,Z.pending-U,U)),L(k),U=Z.pending,Z.pending===Z.pending_buf_size)){re=1;break}re=Z.gzindex<Z.gzhead.comment.length?255&Z.gzhead.comment.charCodeAt(Z.gzindex++):0,W(Z,re)}while(re!==0);Z.gzhead.hcrc&&Z.pending>U&&(k.adler=u(k.adler,Z.pending_buf,Z.pending-U,U)),re===0&&(Z.status=103)}else Z.status=103;if(Z.status===103&&(Z.gzhead.hcrc?(Z.pending+2>Z.pending_buf_size&&L(k),Z.pending+2<=Z.pending_buf_size&&(W(Z,255&k.adler),W(Z,k.adler>>8&255),k.adler=0,Z.status=M)):Z.status=M),Z.pending!==0){if(L(k),k.avail_out===0)return Z.last_flush=-1,p}else if(k.avail_in===0&&I(oe)<=I(ie)&&oe!==m)return F(k,-5);if(Z.status===666&&k.avail_in!==0)return F(k,-5);if(k.avail_in!==0||Z.lookahead!==0||oe!==h&&Z.status!==666){var Y=Z.strategy===2?function(H,ce){for(var ue;;){if(H.lookahead===0&&(Q(H),H.lookahead===0)){if(ce===h)return y;break}if(H.match_length=0,ue=l._tr_tally(H,0,H.window[H.strstart]),H.lookahead--,H.strstart++,ue&&(D(H,!1),H.strm.avail_out===0))return y}return H.insert=0,ce===m?(D(H,!0),H.strm.avail_out===0?R:z):H.last_lit&&(D(H,!1),H.strm.avail_out===0)?y:T}(Z,oe):Z.strategy===3?function(H,ce){for(var ue,ae,pe,Te,Ae=H.window;;){if(H.lookahead<=O){if(Q(H),H.lookahead<=O&&ce===h)return y;if(H.lookahead===0)break}if(H.match_length=0,H.lookahead>=P&&0<H.strstart&&(ae=Ae[pe=H.strstart-1])===Ae[++pe]&&ae===Ae[++pe]&&ae===Ae[++pe]){Te=H.strstart+O;do;while(ae===Ae[++pe]&&ae===Ae[++pe]&&ae===Ae[++pe]&&ae===Ae[++pe]&&ae===Ae[++pe]&&ae===Ae[++pe]&&ae===Ae[++pe]&&ae===Ae[++pe]&&pe<Te);H.match_length=O-(Te-pe),H.match_length>H.lookahead&&(H.match_length=H.lookahead)}if(H.match_length>=P?(ue=l._tr_tally(H,1,H.match_length-P),H.lookahead-=H.match_length,H.strstart+=H.match_length,H.match_length=0):(ue=l._tr_tally(H,0,H.window[H.strstart]),H.lookahead--,H.strstart++),ue&&(D(H,!1),H.strm.avail_out===0))return y}return H.insert=0,ce===m?(D(H,!0),H.strm.avail_out===0?R:z):H.last_lit&&(D(H,!1),H.strm.avail_out===0)?y:T}(Z,oe):a[Z.level].func(Z,oe);if(Y!==R&&Y!==z||(Z.status=666),Y===y||Y===R)return k.avail_out===0&&(Z.last_flush=-1),p;if(Y===T&&(oe===1?l._tr_align(Z):oe!==5&&(l._tr_stored_block(Z,0,0,!1),oe===3&&(J(Z.head),Z.lookahead===0&&(Z.strstart=0,Z.block_start=0,Z.insert=0))),L(k),k.avail_out===0))return Z.last_flush=-1,p}return oe!==m?p:Z.wrap<=0?1:(Z.wrap===2?(W(Z,255&k.adler),W(Z,k.adler>>8&255),W(Z,k.adler>>16&255),W(Z,k.adler>>24&255),W(Z,255&k.total_in),W(Z,k.total_in>>8&255),W(Z,k.total_in>>16&255),W(Z,k.total_in>>24&255)):(G(Z,k.adler>>>16),G(Z,65535&k.adler)),L(k),0<Z.wrap&&(Z.wrap=-Z.wrap),Z.pending!==0?p:1)},o.deflateEnd=function(k){var oe;return k&&k.state?(oe=k.state.status)!==N&&oe!==69&&oe!==73&&oe!==91&&oe!==103&&oe!==M&&oe!==666?F(k,x):(k.state=null,oe===M?F(k,-3):p):x},o.deflateSetDictionary=function(k,oe){var ie,Z,U,re,$,Y,H,ce,ue=oe.length;if(!k||!k.state||(re=(ie=k.state).wrap)===2||re===1&&ie.status!==N||ie.lookahead)return x;for(re===1&&(k.adler=c(k.adler,oe,ue,0)),ie.wrap=0,ue>=ie.w_size&&(re===0&&(J(ie.head),ie.strstart=0,ie.block_start=0,ie.insert=0),ce=new i.Buf8(ie.w_size),i.arraySet(ce,oe,ue-ie.w_size,ie.w_size,0),oe=ce,ue=ie.w_size),$=k.avail_in,Y=k.next_in,H=k.input,k.avail_in=ue,k.next_in=0,k.input=oe,Q(ie);ie.lookahead>=P;){for(Z=ie.strstart,U=ie.lookahead-(P-1);ie.ins_h=(ie.ins_h<<ie.hash_shift^ie.window[Z+P-1])&ie.hash_mask,ie.prev[Z&ie.w_mask]=ie.head[ie.ins_h],ie.head[ie.ins_h]=Z,Z++,--U;);ie.strstart=Z,ie.lookahead=P-1,Q(ie)}return ie.strstart+=ie.lookahead,ie.block_start=ie.strstart,ie.insert=ie.lookahead,ie.lookahead=0,ie.match_length=ie.prev_length=P-1,ie.match_available=0,k.next_in=Y,k.input=H,k.avail_in=$,ie.wrap=re,p},o.deflateInfo="pako deflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./messages":51,"./trees":52}],47:[function(n,r,o){r.exports=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}},{}],48:[function(n,r,o){r.exports=function(a,i){var l,c,u,f,h,m,p,x,g,w,v,b,C,S,E,_,j,A,P,O,B,N,M,y,T;l=a.state,c=a.next_in,y=a.input,u=c+(a.avail_in-5),f=a.next_out,T=a.output,h=f-(i-a.avail_out),m=f+(a.avail_out-257),p=l.dmax,x=l.wsize,g=l.whave,w=l.wnext,v=l.window,b=l.hold,C=l.bits,S=l.lencode,E=l.distcode,_=(1<<l.lenbits)-1,j=(1<<l.distbits)-1;e:do{C<15&&(b+=y[c++]<<C,C+=8,b+=y[c++]<<C,C+=8),A=S[b&_];t:for(;;){if(b>>>=P=A>>>24,C-=P,(P=A>>>16&255)===0)T[f++]=65535&A;else{if(!(16&P)){if((64&P)==0){A=S[(65535&A)+(b&(1<<P)-1)];continue t}if(32&P){l.mode=12;break e}a.msg="invalid literal/length code",l.mode=30;break e}O=65535&A,(P&=15)&&(C<P&&(b+=y[c++]<<C,C+=8),O+=b&(1<<P)-1,b>>>=P,C-=P),C<15&&(b+=y[c++]<<C,C+=8,b+=y[c++]<<C,C+=8),A=E[b&j];n:for(;;){if(b>>>=P=A>>>24,C-=P,!(16&(P=A>>>16&255))){if((64&P)==0){A=E[(65535&A)+(b&(1<<P)-1)];continue n}a.msg="invalid distance code",l.mode=30;break e}if(B=65535&A,C<(P&=15)&&(b+=y[c++]<<C,(C+=8)<P&&(b+=y[c++]<<C,C+=8)),p<(B+=b&(1<<P)-1)){a.msg="invalid distance too far back",l.mode=30;break e}if(b>>>=P,C-=P,(P=f-h)<B){if(g<(P=B-P)&&l.sane){a.msg="invalid distance too far back",l.mode=30;break e}if(M=v,(N=0)===w){if(N+=x-P,P<O){for(O-=P;T[f++]=v[N++],--P;);N=f-B,M=T}}else if(w<P){if(N+=x+w-P,(P-=w)<O){for(O-=P;T[f++]=v[N++],--P;);if(N=0,w<O){for(O-=P=w;T[f++]=v[N++],--P;);N=f-B,M=T}}}else if(N+=w-P,P<O){for(O-=P;T[f++]=v[N++],--P;);N=f-B,M=T}for(;2<O;)T[f++]=M[N++],T[f++]=M[N++],T[f++]=M[N++],O-=3;O&&(T[f++]=M[N++],1<O&&(T[f++]=M[N++]))}else{for(N=f-B;T[f++]=T[N++],T[f++]=T[N++],T[f++]=T[N++],2<(O-=3););O&&(T[f++]=T[N++],1<O&&(T[f++]=T[N++]))}break}}break}}while(c<u&&f<m);c-=O=C>>3,b&=(1<<(C-=O<<3))-1,a.next_in=c,a.next_out=f,a.avail_in=c<u?u-c+5:5-(c-u),a.avail_out=f<m?m-f+257:257-(f-m),l.hold=b,l.bits=C}},{}],49:[function(n,r,o){var a=n("../utils/common"),i=n("./adler32"),l=n("./crc32"),c=n("./inffast"),u=n("./inftrees"),f=1,h=2,m=0,p=-2,x=1,g=852,w=592;function v(N){return(N>>>24&255)+(N>>>8&65280)+((65280&N)<<8)+((255&N)<<24)}function b(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new a.Buf16(320),this.work=new a.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function C(N){var M;return N&&N.state?(M=N.state,N.total_in=N.total_out=M.total=0,N.msg="",M.wrap&&(N.adler=1&M.wrap),M.mode=x,M.last=0,M.havedict=0,M.dmax=32768,M.head=null,M.hold=0,M.bits=0,M.lencode=M.lendyn=new a.Buf32(g),M.distcode=M.distdyn=new a.Buf32(w),M.sane=1,M.back=-1,m):p}function S(N){var M;return N&&N.state?((M=N.state).wsize=0,M.whave=0,M.wnext=0,C(N)):p}function E(N,M){var y,T;return N&&N.state?(T=N.state,M<0?(y=0,M=-M):(y=1+(M>>4),M<48&&(M&=15)),M&&(M<8||15<M)?p:(T.window!==null&&T.wbits!==M&&(T.window=null),T.wrap=y,T.wbits=M,S(N))):p}function _(N,M){var y,T;return N?(T=new b,(N.state=T).window=null,(y=E(N,M))!==m&&(N.state=null),y):p}var j,A,P=!0;function O(N){if(P){var M;for(j=new a.Buf32(512),A=new a.Buf32(32),M=0;M<144;)N.lens[M++]=8;for(;M<256;)N.lens[M++]=9;for(;M<280;)N.lens[M++]=7;for(;M<288;)N.lens[M++]=8;for(u(f,N.lens,0,288,j,0,N.work,{bits:9}),M=0;M<32;)N.lens[M++]=5;u(h,N.lens,0,32,A,0,N.work,{bits:5}),P=!1}N.lencode=j,N.lenbits=9,N.distcode=A,N.distbits=5}function B(N,M,y,T){var R,z=N.state;return z.window===null&&(z.wsize=1<<z.wbits,z.wnext=0,z.whave=0,z.window=new a.Buf8(z.wsize)),T>=z.wsize?(a.arraySet(z.window,M,y-z.wsize,z.wsize,0),z.wnext=0,z.whave=z.wsize):(T<(R=z.wsize-z.wnext)&&(R=T),a.arraySet(z.window,M,y-T,R,z.wnext),(T-=R)?(a.arraySet(z.window,M,y-T,T,0),z.wnext=T,z.whave=z.wsize):(z.wnext+=R,z.wnext===z.wsize&&(z.wnext=0),z.whave<z.wsize&&(z.whave+=R))),0}o.inflateReset=S,o.inflateReset2=E,o.inflateResetKeep=C,o.inflateInit=function(N){return _(N,15)},o.inflateInit2=_,o.inflate=function(N,M){var y,T,R,z,F,I,J,L,D,W,G,V,Q,X,K,q,ne,de,se,me,k,oe,ie,Z,U=0,re=new a.Buf8(4),$=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!N||!N.state||!N.output||!N.input&&N.avail_in!==0)return p;(y=N.state).mode===12&&(y.mode=13),F=N.next_out,R=N.output,J=N.avail_out,z=N.next_in,T=N.input,I=N.avail_in,L=y.hold,D=y.bits,W=I,G=J,oe=m;e:for(;;)switch(y.mode){case x:if(y.wrap===0){y.mode=13;break}for(;D<16;){if(I===0)break e;I--,L+=T[z++]<<D,D+=8}if(2&y.wrap&&L===35615){re[y.check=0]=255&L,re[1]=L>>>8&255,y.check=l(y.check,re,2,0),D=L=0,y.mode=2;break}if(y.flags=0,y.head&&(y.head.done=!1),!(1&y.wrap)||(((255&L)<<8)+(L>>8))%31){N.msg="incorrect header check",y.mode=30;break}if((15&L)!=8){N.msg="unknown compression method",y.mode=30;break}if(D-=4,k=8+(15&(L>>>=4)),y.wbits===0)y.wbits=k;else if(k>y.wbits){N.msg="invalid window size",y.mode=30;break}y.dmax=1<<k,N.adler=y.check=1,y.mode=512&L?10:12,D=L=0;break;case 2:for(;D<16;){if(I===0)break e;I--,L+=T[z++]<<D,D+=8}if(y.flags=L,(255&y.flags)!=8){N.msg="unknown compression method",y.mode=30;break}if(57344&y.flags){N.msg="unknown header flags set",y.mode=30;break}y.head&&(y.head.text=L>>8&1),512&y.flags&&(re[0]=255&L,re[1]=L>>>8&255,y.check=l(y.check,re,2,0)),D=L=0,y.mode=3;case 3:for(;D<32;){if(I===0)break e;I--,L+=T[z++]<<D,D+=8}y.head&&(y.head.time=L),512&y.flags&&(re[0]=255&L,re[1]=L>>>8&255,re[2]=L>>>16&255,re[3]=L>>>24&255,y.check=l(y.check,re,4,0)),D=L=0,y.mode=4;case 4:for(;D<16;){if(I===0)break e;I--,L+=T[z++]<<D,D+=8}y.head&&(y.head.xflags=255&L,y.head.os=L>>8),512&y.flags&&(re[0]=255&L,re[1]=L>>>8&255,y.check=l(y.check,re,2,0)),D=L=0,y.mode=5;case 5:if(1024&y.flags){for(;D<16;){if(I===0)break e;I--,L+=T[z++]<<D,D+=8}y.length=L,y.head&&(y.head.extra_len=L),512&y.flags&&(re[0]=255&L,re[1]=L>>>8&255,y.check=l(y.check,re,2,0)),D=L=0}else y.head&&(y.head.extra=null);y.mode=6;case 6:if(1024&y.flags&&(I<(V=y.length)&&(V=I),V&&(y.head&&(k=y.head.extra_len-y.length,y.head.extra||(y.head.extra=new Array(y.head.extra_len)),a.arraySet(y.head.extra,T,z,V,k)),512&y.flags&&(y.check=l(y.check,T,V,z)),I-=V,z+=V,y.length-=V),y.length))break e;y.length=0,y.mode=7;case 7:if(2048&y.flags){if(I===0)break e;for(V=0;k=T[z+V++],y.head&&k&&y.length<65536&&(y.head.name+=String.fromCharCode(k)),k&&V<I;);if(512&y.flags&&(y.check=l(y.check,T,V,z)),I-=V,z+=V,k)break e}else y.head&&(y.head.name=null);y.length=0,y.mode=8;case 8:if(4096&y.flags){if(I===0)break e;for(V=0;k=T[z+V++],y.head&&k&&y.length<65536&&(y.head.comment+=String.fromCharCode(k)),k&&V<I;);if(512&y.flags&&(y.check=l(y.check,T,V,z)),I-=V,z+=V,k)break e}else y.head&&(y.head.comment=null);y.mode=9;case 9:if(512&y.flags){for(;D<16;){if(I===0)break e;I--,L+=T[z++]<<D,D+=8}if(L!==(65535&y.check)){N.msg="header crc mismatch",y.mode=30;break}D=L=0}y.head&&(y.head.hcrc=y.flags>>9&1,y.head.done=!0),N.adler=y.check=0,y.mode=12;break;case 10:for(;D<32;){if(I===0)break e;I--,L+=T[z++]<<D,D+=8}N.adler=y.check=v(L),D=L=0,y.mode=11;case 11:if(y.havedict===0)return N.next_out=F,N.avail_out=J,N.next_in=z,N.avail_in=I,y.hold=L,y.bits=D,2;N.adler=y.check=1,y.mode=12;case 12:if(M===5||M===6)break e;case 13:if(y.last){L>>>=7&D,D-=7&D,y.mode=27;break}for(;D<3;){if(I===0)break e;I--,L+=T[z++]<<D,D+=8}switch(y.last=1&L,D-=1,3&(L>>>=1)){case 0:y.mode=14;break;case 1:if(O(y),y.mode=20,M!==6)break;L>>>=2,D-=2;break e;case 2:y.mode=17;break;case 3:N.msg="invalid block type",y.mode=30}L>>>=2,D-=2;break;case 14:for(L>>>=7&D,D-=7&D;D<32;){if(I===0)break e;I--,L+=T[z++]<<D,D+=8}if((65535&L)!=(L>>>16^65535)){N.msg="invalid stored block lengths",y.mode=30;break}if(y.length=65535&L,D=L=0,y.mode=15,M===6)break e;case 15:y.mode=16;case 16:if(V=y.length){if(I<V&&(V=I),J<V&&(V=J),V===0)break e;a.arraySet(R,T,z,V,F),I-=V,z+=V,J-=V,F+=V,y.length-=V;break}y.mode=12;break;case 17:for(;D<14;){if(I===0)break e;I--,L+=T[z++]<<D,D+=8}if(y.nlen=257+(31&L),L>>>=5,D-=5,y.ndist=1+(31&L),L>>>=5,D-=5,y.ncode=4+(15&L),L>>>=4,D-=4,286<y.nlen||30<y.ndist){N.msg="too many length or distance symbols",y.mode=30;break}y.have=0,y.mode=18;case 18:for(;y.have<y.ncode;){for(;D<3;){if(I===0)break e;I--,L+=T[z++]<<D,D+=8}y.lens[$[y.have++]]=7&L,L>>>=3,D-=3}for(;y.have<19;)y.lens[$[y.have++]]=0;if(y.lencode=y.lendyn,y.lenbits=7,ie={bits:y.lenbits},oe=u(0,y.lens,0,19,y.lencode,0,y.work,ie),y.lenbits=ie.bits,oe){N.msg="invalid code lengths set",y.mode=30;break}y.have=0,y.mode=19;case 19:for(;y.have<y.nlen+y.ndist;){for(;q=(U=y.lencode[L&(1<<y.lenbits)-1])>>>16&255,ne=65535&U,!((K=U>>>24)<=D);){if(I===0)break e;I--,L+=T[z++]<<D,D+=8}if(ne<16)L>>>=K,D-=K,y.lens[y.have++]=ne;else{if(ne===16){for(Z=K+2;D<Z;){if(I===0)break e;I--,L+=T[z++]<<D,D+=8}if(L>>>=K,D-=K,y.have===0){N.msg="invalid bit length repeat",y.mode=30;break}k=y.lens[y.have-1],V=3+(3&L),L>>>=2,D-=2}else if(ne===17){for(Z=K+3;D<Z;){if(I===0)break e;I--,L+=T[z++]<<D,D+=8}D-=K,k=0,V=3+(7&(L>>>=K)),L>>>=3,D-=3}else{for(Z=K+7;D<Z;){if(I===0)break e;I--,L+=T[z++]<<D,D+=8}D-=K,k=0,V=11+(127&(L>>>=K)),L>>>=7,D-=7}if(y.have+V>y.nlen+y.ndist){N.msg="invalid bit length repeat",y.mode=30;break}for(;V--;)y.lens[y.have++]=k}}if(y.mode===30)break;if(y.lens[256]===0){N.msg="invalid code -- missing end-of-block",y.mode=30;break}if(y.lenbits=9,ie={bits:y.lenbits},oe=u(f,y.lens,0,y.nlen,y.lencode,0,y.work,ie),y.lenbits=ie.bits,oe){N.msg="invalid literal/lengths set",y.mode=30;break}if(y.distbits=6,y.distcode=y.distdyn,ie={bits:y.distbits},oe=u(h,y.lens,y.nlen,y.ndist,y.distcode,0,y.work,ie),y.distbits=ie.bits,oe){N.msg="invalid distances set",y.mode=30;break}if(y.mode=20,M===6)break e;case 20:y.mode=21;case 21:if(6<=I&&258<=J){N.next_out=F,N.avail_out=J,N.next_in=z,N.avail_in=I,y.hold=L,y.bits=D,c(N,G),F=N.next_out,R=N.output,J=N.avail_out,z=N.next_in,T=N.input,I=N.avail_in,L=y.hold,D=y.bits,y.mode===12&&(y.back=-1);break}for(y.back=0;q=(U=y.lencode[L&(1<<y.lenbits)-1])>>>16&255,ne=65535&U,!((K=U>>>24)<=D);){if(I===0)break e;I--,L+=T[z++]<<D,D+=8}if(q&&(240&q)==0){for(de=K,se=q,me=ne;q=(U=y.lencode[me+((L&(1<<de+se)-1)>>de)])>>>16&255,ne=65535&U,!(de+(K=U>>>24)<=D);){if(I===0)break e;I--,L+=T[z++]<<D,D+=8}L>>>=de,D-=de,y.back+=de}if(L>>>=K,D-=K,y.back+=K,y.length=ne,q===0){y.mode=26;break}if(32&q){y.back=-1,y.mode=12;break}if(64&q){N.msg="invalid literal/length code",y.mode=30;break}y.extra=15&q,y.mode=22;case 22:if(y.extra){for(Z=y.extra;D<Z;){if(I===0)break e;I--,L+=T[z++]<<D,D+=8}y.length+=L&(1<<y.extra)-1,L>>>=y.extra,D-=y.extra,y.back+=y.extra}y.was=y.length,y.mode=23;case 23:for(;q=(U=y.distcode[L&(1<<y.distbits)-1])>>>16&255,ne=65535&U,!((K=U>>>24)<=D);){if(I===0)break e;I--,L+=T[z++]<<D,D+=8}if((240&q)==0){for(de=K,se=q,me=ne;q=(U=y.distcode[me+((L&(1<<de+se)-1)>>de)])>>>16&255,ne=65535&U,!(de+(K=U>>>24)<=D);){if(I===0)break e;I--,L+=T[z++]<<D,D+=8}L>>>=de,D-=de,y.back+=de}if(L>>>=K,D-=K,y.back+=K,64&q){N.msg="invalid distance code",y.mode=30;break}y.offset=ne,y.extra=15&q,y.mode=24;case 24:if(y.extra){for(Z=y.extra;D<Z;){if(I===0)break e;I--,L+=T[z++]<<D,D+=8}y.offset+=L&(1<<y.extra)-1,L>>>=y.extra,D-=y.extra,y.back+=y.extra}if(y.offset>y.dmax){N.msg="invalid distance too far back",y.mode=30;break}y.mode=25;case 25:if(J===0)break e;if(V=G-J,y.offset>V){if((V=y.offset-V)>y.whave&&y.sane){N.msg="invalid distance too far back",y.mode=30;break}Q=V>y.wnext?(V-=y.wnext,y.wsize-V):y.wnext-V,V>y.length&&(V=y.length),X=y.window}else X=R,Q=F-y.offset,V=y.length;for(J<V&&(V=J),J-=V,y.length-=V;R[F++]=X[Q++],--V;);y.length===0&&(y.mode=21);break;case 26:if(J===0)break e;R[F++]=y.length,J--,y.mode=21;break;case 27:if(y.wrap){for(;D<32;){if(I===0)break e;I--,L|=T[z++]<<D,D+=8}if(G-=J,N.total_out+=G,y.total+=G,G&&(N.adler=y.check=y.flags?l(y.check,R,G,F-G):i(y.check,R,G,F-G)),G=J,(y.flags?L:v(L))!==y.check){N.msg="incorrect data check",y.mode=30;break}D=L=0}y.mode=28;case 28:if(y.wrap&&y.flags){for(;D<32;){if(I===0)break e;I--,L+=T[z++]<<D,D+=8}if(L!==(4294967295&y.total)){N.msg="incorrect length check",y.mode=30;break}D=L=0}y.mode=29;case 29:oe=1;break e;case 30:oe=-3;break e;case 31:return-4;case 32:default:return p}return N.next_out=F,N.avail_out=J,N.next_in=z,N.avail_in=I,y.hold=L,y.bits=D,(y.wsize||G!==N.avail_out&&y.mode<30&&(y.mode<27||M!==4))&&B(N,N.output,N.next_out,G-N.avail_out)?(y.mode=31,-4):(W-=N.avail_in,G-=N.avail_out,N.total_in+=W,N.total_out+=G,y.total+=G,y.wrap&&G&&(N.adler=y.check=y.flags?l(y.check,R,G,N.next_out-G):i(y.check,R,G,N.next_out-G)),N.data_type=y.bits+(y.last?64:0)+(y.mode===12?128:0)+(y.mode===20||y.mode===15?256:0),(W==0&&G===0||M===4)&&oe===m&&(oe=-5),oe)},o.inflateEnd=function(N){if(!N||!N.state)return p;var M=N.state;return M.window&&(M.window=null),N.state=null,m},o.inflateGetHeader=function(N,M){var y;return N&&N.state?(2&(y=N.state).wrap)==0?p:((y.head=M).done=!1,m):p},o.inflateSetDictionary=function(N,M){var y,T=M.length;return N&&N.state?(y=N.state).wrap!==0&&y.mode!==11?p:y.mode===11&&i(1,M,T,0)!==y.check?-3:B(N,M,T,T)?(y.mode=31,-4):(y.havedict=1,m):p},o.inflateInfo="pako inflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./inffast":48,"./inftrees":50}],50:[function(n,r,o){var a=n("../utils/common"),i=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],l=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],c=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],u=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];r.exports=function(f,h,m,p,x,g,w,v){var b,C,S,E,_,j,A,P,O,B=v.bits,N=0,M=0,y=0,T=0,R=0,z=0,F=0,I=0,J=0,L=0,D=null,W=0,G=new a.Buf16(16),V=new a.Buf16(16),Q=null,X=0;for(N=0;N<=15;N++)G[N]=0;for(M=0;M<p;M++)G[h[m+M]]++;for(R=B,T=15;1<=T&&G[T]===0;T--);if(T<R&&(R=T),T===0)return x[g++]=20971520,x[g++]=20971520,v.bits=1,0;for(y=1;y<T&&G[y]===0;y++);for(R<y&&(R=y),N=I=1;N<=15;N++)if(I<<=1,(I-=G[N])<0)return-1;if(0<I&&(f===0||T!==1))return-1;for(V[1]=0,N=1;N<15;N++)V[N+1]=V[N]+G[N];for(M=0;M<p;M++)h[m+M]!==0&&(w[V[h[m+M]]++]=M);if(j=f===0?(D=Q=w,19):f===1?(D=i,W-=257,Q=l,X-=257,256):(D=c,Q=u,-1),N=y,_=g,F=M=L=0,S=-1,E=(J=1<<(z=R))-1,f===1&&852<J||f===2&&592<J)return 1;for(;;){for(A=N-F,O=w[M]<j?(P=0,w[M]):w[M]>j?(P=Q[X+w[M]],D[W+w[M]]):(P=96,0),b=1<<N-F,y=C=1<<z;x[_+(L>>F)+(C-=b)]=A<<24|P<<16|O|0,C!==0;);for(b=1<<N-1;L&b;)b>>=1;if(b!==0?(L&=b-1,L+=b):L=0,M++,--G[N]==0){if(N===T)break;N=h[m+w[M]]}if(R<N&&(L&E)!==S){for(F===0&&(F=R),_+=y,I=1<<(z=N-F);z+F<T&&!((I-=G[z+F])<=0);)z++,I<<=1;if(J+=1<<z,f===1&&852<J||f===2&&592<J)return 1;x[S=L&E]=R<<24|z<<16|_-g|0}}return L!==0&&(x[_+L]=N-F<<24|64<<16|0),v.bits=R,0}},{"../utils/common":41}],51:[function(n,r,o){r.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},{}],52:[function(n,r,o){var a=n("../utils/common"),i=0,l=1;function c(U){for(var re=U.length;0<=--re;)U[re]=0}var u=0,f=29,h=256,m=h+1+f,p=30,x=19,g=2*m+1,w=15,v=16,b=7,C=256,S=16,E=17,_=18,j=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],A=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],P=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],O=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],B=new Array(2*(m+2));c(B);var N=new Array(2*p);c(N);var M=new Array(512);c(M);var y=new Array(256);c(y);var T=new Array(f);c(T);var R,z,F,I=new Array(p);function J(U,re,$,Y,H){this.static_tree=U,this.extra_bits=re,this.extra_base=$,this.elems=Y,this.max_length=H,this.has_stree=U&&U.length}function L(U,re){this.dyn_tree=U,this.max_code=0,this.stat_desc=re}function D(U){return U<256?M[U]:M[256+(U>>>7)]}function W(U,re){U.pending_buf[U.pending++]=255&re,U.pending_buf[U.pending++]=re>>>8&255}function G(U,re,$){U.bi_valid>v-$?(U.bi_buf|=re<<U.bi_valid&65535,W(U,U.bi_buf),U.bi_buf=re>>v-U.bi_valid,U.bi_valid+=$-v):(U.bi_buf|=re<<U.bi_valid&65535,U.bi_valid+=$)}function V(U,re,$){G(U,$[2*re],$[2*re+1])}function Q(U,re){for(var $=0;$|=1&U,U>>>=1,$<<=1,0<--re;);return $>>>1}function X(U,re,$){var Y,H,ce=new Array(w+1),ue=0;for(Y=1;Y<=w;Y++)ce[Y]=ue=ue+$[Y-1]<<1;for(H=0;H<=re;H++){var ae=U[2*H+1];ae!==0&&(U[2*H]=Q(ce[ae]++,ae))}}function K(U){var re;for(re=0;re<m;re++)U.dyn_ltree[2*re]=0;for(re=0;re<p;re++)U.dyn_dtree[2*re]=0;for(re=0;re<x;re++)U.bl_tree[2*re]=0;U.dyn_ltree[2*C]=1,U.opt_len=U.static_len=0,U.last_lit=U.matches=0}function q(U){8<U.bi_valid?W(U,U.bi_buf):0<U.bi_valid&&(U.pending_buf[U.pending++]=U.bi_buf),U.bi_buf=0,U.bi_valid=0}function ne(U,re,$,Y){var H=2*re,ce=2*$;return U[H]<U[ce]||U[H]===U[ce]&&Y[re]<=Y[$]}function de(U,re,$){for(var Y=U.heap[$],H=$<<1;H<=U.heap_len&&(H<U.heap_len&&ne(re,U.heap[H+1],U.heap[H],U.depth)&&H++,!ne(re,Y,U.heap[H],U.depth));)U.heap[$]=U.heap[H],$=H,H<<=1;U.heap[$]=Y}function se(U,re,$){var Y,H,ce,ue,ae=0;if(U.last_lit!==0)for(;Y=U.pending_buf[U.d_buf+2*ae]<<8|U.pending_buf[U.d_buf+2*ae+1],H=U.pending_buf[U.l_buf+ae],ae++,Y===0?V(U,H,re):(V(U,(ce=y[H])+h+1,re),(ue=j[ce])!==0&&G(U,H-=T[ce],ue),V(U,ce=D(--Y),$),(ue=A[ce])!==0&&G(U,Y-=I[ce],ue)),ae<U.last_lit;);V(U,C,re)}function me(U,re){var $,Y,H,ce=re.dyn_tree,ue=re.stat_desc.static_tree,ae=re.stat_desc.has_stree,pe=re.stat_desc.elems,Te=-1;for(U.heap_len=0,U.heap_max=g,$=0;$<pe;$++)ce[2*$]!==0?(U.heap[++U.heap_len]=Te=$,U.depth[$]=0):ce[2*$+1]=0;for(;U.heap_len<2;)ce[2*(H=U.heap[++U.heap_len]=Te<2?++Te:0)]=1,U.depth[H]=0,U.opt_len--,ae&&(U.static_len-=ue[2*H+1]);for(re.max_code=Te,$=U.heap_len>>1;1<=$;$--)de(U,ce,$);for(H=pe;$=U.heap[1],U.heap[1]=U.heap[U.heap_len--],de(U,ce,1),Y=U.heap[1],U.heap[--U.heap_max]=$,U.heap[--U.heap_max]=Y,ce[2*H]=ce[2*$]+ce[2*Y],U.depth[H]=(U.depth[$]>=U.depth[Y]?U.depth[$]:U.depth[Y])+1,ce[2*$+1]=ce[2*Y+1]=H,U.heap[1]=H++,de(U,ce,1),2<=U.heap_len;);U.heap[--U.heap_max]=U.heap[1],function(Ae,gt){var Pt,Nt,Mt,ct,$t,Wt,Dt=gt.dyn_tree,ve=gt.max_code,Pe=gt.stat_desc.static_tree,Me=gt.stat_desc.has_stree,Oe=gt.stat_desc.extra_bits,at=gt.stat_desc.extra_base,Ue=gt.stat_desc.max_length,it=0;for(ct=0;ct<=w;ct++)Ae.bl_count[ct]=0;for(Dt[2*Ae.heap[Ae.heap_max]+1]=0,Pt=Ae.heap_max+1;Pt<g;Pt++)Ue<(ct=Dt[2*Dt[2*(Nt=Ae.heap[Pt])+1]+1]+1)&&(ct=Ue,it++),Dt[2*Nt+1]=ct,ve<Nt||(Ae.bl_count[ct]++,$t=0,at<=Nt&&($t=Oe[Nt-at]),Wt=Dt[2*Nt],Ae.opt_len+=Wt*(ct+$t),Me&&(Ae.static_len+=Wt*(Pe[2*Nt+1]+$t)));if(it!==0){do{for(ct=Ue-1;Ae.bl_count[ct]===0;)ct--;Ae.bl_count[ct]--,Ae.bl_count[ct+1]+=2,Ae.bl_count[Ue]--,it-=2}while(0<it);for(ct=Ue;ct!==0;ct--)for(Nt=Ae.bl_count[ct];Nt!==0;)ve<(Mt=Ae.heap[--Pt])||(Dt[2*Mt+1]!==ct&&(Ae.opt_len+=(ct-Dt[2*Mt+1])*Dt[2*Mt],Dt[2*Mt+1]=ct),Nt--)}}(U,re),X(ce,Te,U.bl_count)}function k(U,re,$){var Y,H,ce=-1,ue=re[1],ae=0,pe=7,Te=4;for(ue===0&&(pe=138,Te=3),re[2*($+1)+1]=65535,Y=0;Y<=$;Y++)H=ue,ue=re[2*(Y+1)+1],++ae<pe&&H===ue||(ae<Te?U.bl_tree[2*H]+=ae:H!==0?(H!==ce&&U.bl_tree[2*H]++,U.bl_tree[2*S]++):ae<=10?U.bl_tree[2*E]++:U.bl_tree[2*_]++,ce=H,Te=(ae=0)===ue?(pe=138,3):H===ue?(pe=6,3):(pe=7,4))}function oe(U,re,$){var Y,H,ce=-1,ue=re[1],ae=0,pe=7,Te=4;for(ue===0&&(pe=138,Te=3),Y=0;Y<=$;Y++)if(H=ue,ue=re[2*(Y+1)+1],!(++ae<pe&&H===ue)){if(ae<Te)for(;V(U,H,U.bl_tree),--ae!=0;);else H!==0?(H!==ce&&(V(U,H,U.bl_tree),ae--),V(U,S,U.bl_tree),G(U,ae-3,2)):ae<=10?(V(U,E,U.bl_tree),G(U,ae-3,3)):(V(U,_,U.bl_tree),G(U,ae-11,7));ce=H,Te=(ae=0)===ue?(pe=138,3):H===ue?(pe=6,3):(pe=7,4)}}c(I);var ie=!1;function Z(U,re,$,Y){G(U,(u<<1)+(Y?1:0),3),function(H,ce,ue,ae){q(H),W(H,ue),W(H,~ue),a.arraySet(H.pending_buf,H.window,ce,ue,H.pending),H.pending+=ue}(U,re,$)}o._tr_init=function(U){ie||(function(){var re,$,Y,H,ce,ue=new Array(w+1);for(H=Y=0;H<f-1;H++)for(T[H]=Y,re=0;re<1<<j[H];re++)y[Y++]=H;for(y[Y-1]=H,H=ce=0;H<16;H++)for(I[H]=ce,re=0;re<1<<A[H];re++)M[ce++]=H;for(ce>>=7;H<p;H++)for(I[H]=ce<<7,re=0;re<1<<A[H]-7;re++)M[256+ce++]=H;for($=0;$<=w;$++)ue[$]=0;for(re=0;re<=143;)B[2*re+1]=8,re++,ue[8]++;for(;re<=255;)B[2*re+1]=9,re++,ue[9]++;for(;re<=279;)B[2*re+1]=7,re++,ue[7]++;for(;re<=287;)B[2*re+1]=8,re++,ue[8]++;for(X(B,m+1,ue),re=0;re<p;re++)N[2*re+1]=5,N[2*re]=Q(re,5);R=new J(B,j,h+1,m,w),z=new J(N,A,0,p,w),F=new J(new Array(0),P,0,x,b)}(),ie=!0),U.l_desc=new L(U.dyn_ltree,R),U.d_desc=new L(U.dyn_dtree,z),U.bl_desc=new L(U.bl_tree,F),U.bi_buf=0,U.bi_valid=0,K(U)},o._tr_stored_block=Z,o._tr_flush_block=function(U,re,$,Y){var H,ce,ue=0;0<U.level?(U.strm.data_type===2&&(U.strm.data_type=function(ae){var pe,Te=4093624447;for(pe=0;pe<=31;pe++,Te>>>=1)if(1&Te&&ae.dyn_ltree[2*pe]!==0)return i;if(ae.dyn_ltree[18]!==0||ae.dyn_ltree[20]!==0||ae.dyn_ltree[26]!==0)return l;for(pe=32;pe<h;pe++)if(ae.dyn_ltree[2*pe]!==0)return l;return i}(U)),me(U,U.l_desc),me(U,U.d_desc),ue=function(ae){var pe;for(k(ae,ae.dyn_ltree,ae.l_desc.max_code),k(ae,ae.dyn_dtree,ae.d_desc.max_code),me(ae,ae.bl_desc),pe=x-1;3<=pe&&ae.bl_tree[2*O[pe]+1]===0;pe--);return ae.opt_len+=3*(pe+1)+5+5+4,pe}(U),H=U.opt_len+3+7>>>3,(ce=U.static_len+3+7>>>3)<=H&&(H=ce)):H=ce=$+5,$+4<=H&&re!==-1?Z(U,re,$,Y):U.strategy===4||ce===H?(G(U,2+(Y?1:0),3),se(U,B,N)):(G(U,4+(Y?1:0),3),function(ae,pe,Te,Ae){var gt;for(G(ae,pe-257,5),G(ae,Te-1,5),G(ae,Ae-4,4),gt=0;gt<Ae;gt++)G(ae,ae.bl_tree[2*O[gt]+1],3);oe(ae,ae.dyn_ltree,pe-1),oe(ae,ae.dyn_dtree,Te-1)}(U,U.l_desc.max_code+1,U.d_desc.max_code+1,ue+1),se(U,U.dyn_ltree,U.dyn_dtree)),K(U),Y&&q(U)},o._tr_tally=function(U,re,$){return U.pending_buf[U.d_buf+2*U.last_lit]=re>>>8&255,U.pending_buf[U.d_buf+2*U.last_lit+1]=255&re,U.pending_buf[U.l_buf+U.last_lit]=255&$,U.last_lit++,re===0?U.dyn_ltree[2*$]++:(U.matches++,re--,U.dyn_ltree[2*(y[$]+h+1)]++,U.dyn_dtree[2*D(re)]++),U.last_lit===U.lit_bufsize-1},o._tr_align=function(U){G(U,2,3),V(U,C,B),function(re){re.bi_valid===16?(W(re,re.bi_buf),re.bi_buf=0,re.bi_valid=0):8<=re.bi_valid&&(re.pending_buf[re.pending++]=255&re.bi_buf,re.bi_buf>>=8,re.bi_valid-=8)}(U)}},{"../utils/common":41}],53:[function(n,r,o){r.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],54:[function(n,r,o){(function(a){(function(i,l){if(!i.setImmediate){var c,u,f,h,m=1,p={},x=!1,g=i.document,w=Object.getPrototypeOf&&Object.getPrototypeOf(i);w=w&&w.setTimeout?w:i,c={}.toString.call(i.process)==="[object process]"?function(S){process.nextTick(function(){b(S)})}:function(){if(i.postMessage&&!i.importScripts){var S=!0,E=i.onmessage;return i.onmessage=function(){S=!1},i.postMessage("","*"),i.onmessage=E,S}}()?(h="setImmediate$"+Math.random()+"$",i.addEventListener?i.addEventListener("message",C,!1):i.attachEvent("onmessage",C),function(S){i.postMessage(h+S,"*")}):i.MessageChannel?((f=new MessageChannel).port1.onmessage=function(S){b(S.data)},function(S){f.port2.postMessage(S)}):g&&"onreadystatechange"in g.createElement("script")?(u=g.documentElement,function(S){var E=g.createElement("script");E.onreadystatechange=function(){b(S),E.onreadystatechange=null,u.removeChild(E),E=null},u.appendChild(E)}):function(S){setTimeout(b,0,S)},w.setImmediate=function(S){typeof S!="function"&&(S=new Function(""+S));for(var E=new Array(arguments.length-1),_=0;_<E.length;_++)E[_]=arguments[_+1];var j={callback:S,args:E};return p[m]=j,c(m),m++},w.clearImmediate=v}function v(S){delete p[S]}function b(S){if(x)setTimeout(b,0,S);else{var E=p[S];if(E){x=!0;try{(function(_){var j=_.callback,A=_.args;switch(A.length){case 0:j();break;case 1:j(A[0]);break;case 2:j(A[0],A[1]);break;case 3:j(A[0],A[1],A[2]);break;default:j.apply(l,A)}})(E)}finally{v(S),x=!1}}}}function C(S){S.source===i&&typeof S.data=="string"&&S.data.indexOf(h)===0&&b(+S.data.slice(h.length))}})(typeof self>"u"?a===void 0?this:a:self)}).call(this,typeof Ni<"u"?Ni:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})}(Lu)),Lu.exports}var _F=SF();const kF=SC(_F),EF=100*1024*1024,jF=({open:e,onOpenChange:t,onImport:n})=>{const{validationLimits:r}=Ut(),o=r==null?void 0:r.maxUploadSizeBytes,a=(r==null?void 0:r.maxZipUploadSizeBytes)??EF,[i,l]=d.useState(null),[c,u]=d.useState(""),[f,h]=d.useState(null),[m,p]=d.useState(""),[x,g]=d.useState(null),[w,v]=d.useState(!1),[b,C]=d.useState(!1),S=d.useRef(null),E=()=>{w||(l(null),u(""),h(null),p(""),g(null),t(!1))},_=async y=>{if(g(null),!y.name.endsWith(".zip"))return g("Please select a ZIP file"),!1;if(y.size>a){const T=(a/1048576).toFixed(0);return g(`ZIP file size exceeds ${T}MB limit`),!1}try{const T=await kF.loadAsync(y);if(!T.files["project.json"])return g("Invalid project export: missing project.json"),!1;const R=await T.files["project.json"].async("string"),z=JSON.parse(R);if(z.version!=="1.0")return g(`Unsupported export version: ${z.version}. Only version 1.0 is currently supported.`),!1;const F=Object.keys(T.files).filter(G=>G.startsWith("artifacts/")&&G!=="artifacts/"),I=F.map(G=>G.replace("artifacts/","")),J=z.artifacts||[],L=new Map;for(const G of J)G.filename&&typeof G.size=="number"&&L.set(G.filename,G.size);const D=[],W=[];for(const G of F){const V=T.files[G],Q=G.replace("artifacts/","");let X=L.get(Q);if(X===void 0)try{X=(await V.async("uint8array")).length}catch{X=0}const K=o?X>o:!1,q={name:Q,size:X,isOversized:K};D.push(q),K&&W.push(q)}return h({name:z.project.name,description:z.project.description,systemPrompt:z.project.systemPrompt,defaultAgentId:z.project.defaultAgentId,artifactCount:F.length,artifactNames:I,artifacts:D,oversizedArtifacts:W}),p(z.project.name),!0}catch(T){return console.error("Error validating file:",T),g("Invalid ZIP file or corrupted project export"),!1}},j=async y=>{l(y),u(y.name),await _(y)},A=async y=>{var R;const T=(R=y.target.files)==null?void 0:R[0];T&&await j(T)},P=y=>{y.preventDefault(),C(!0)},O=y=>{y.preventDefault(),C(!1)},B=async y=>{y.preventDefault(),C(!1);const T=y.dataTransfer.files[0];T&&await j(T)},N=async()=>{if(!i){g("Please select a file to import");return}v(!0),g(null);try{await n(i,{preserveName:!1,customName:m.trim()||void 0}),E()}catch(y){const T=y instanceof Error?y.message:"Failed to import project";g(T)}finally{v(!1)}},M=()=>{var y;l(null),u(""),h(null),p(""),g(null),(y=S.current)==null||y.click()};return s.jsx(On,{open:e,onOpenChange:E,children:s.jsxs(Ln,{className:"sm:max-w-[500px]",children:[s.jsxs(Gn,{children:[s.jsx(Fn,{children:"Import Project"}),s.jsx(Yn,{children:"Import a project from a ZIP export file"})]}),s.jsxs("div",{className:"space-y-4 py-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(It,{children:"Project File"}),i?s.jsxs("div",{className:"bg-muted/50 flex items-center gap-3 rounded-lg border p-3",children:[s.jsx(La,{className:"text-primary h-5 w-5 flex-shrink-0"}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("p",{className:"line-clamp-2 text-sm font-medium break-words",title:c,children:c}),s.jsxs("p",{className:"text-muted-foreground text-xs",children:[(i.size/1024/1024).toFixed(2)," MB"]})]}),s.jsx(xe,{variant:"ghost",size:"sm",onClick:M,disabled:w,className:"flex-shrink-0",children:"Change"})]}):s.jsxs("div",{className:`cursor-pointer rounded-lg border-2 border-dashed p-8 text-center transition-colors ${b?"border-primary bg-primary/5 scale-105":"border-muted-foreground/25 hover:border-primary/50 hover:bg-muted/50"}`,onDragOver:P,onDragLeave:O,onDrop:B,onClick:()=>{var y;return(y=S.current)==null?void 0:y.click()},children:[s.jsx(Fs,{className:"text-muted-foreground mx-auto mb-4 h-12 w-12"}),s.jsx("p",{className:"mb-1 text-sm font-medium",children:"Drag and drop ZIP file here"}),s.jsx("p",{className:"text-muted-foreground text-xs",children:"or click to browse"})]}),s.jsx("input",{ref:S,type:"file",accept:".zip",onChange:A,className:"hidden"})]}),f&&s.jsxs("div",{className:"bg-muted/30 space-y-3 rounded-lg border p-4",children:[s.jsxs("div",{children:[s.jsx(It,{className:"text-muted-foreground text-xs",children:"Original Name"}),s.jsx("p",{className:"text-sm font-medium",children:f.name})]}),f.description&&s.jsxs("div",{children:[s.jsx(It,{className:"text-muted-foreground text-xs",children:"Description"}),s.jsx("p",{className:"text-sm",children:f.description})]}),f.systemPrompt&&s.jsxs("div",{children:[s.jsx(It,{className:"text-muted-foreground text-xs",children:"Instructions"}),s.jsx("p",{className:"line-clamp-3 text-sm",children:f.systemPrompt})]}),f.defaultAgentId&&s.jsxs("div",{children:[s.jsx(It,{className:"text-muted-foreground text-xs",children:"Default Agent"}),s.jsx("p",{className:"font-mono text-sm",children:f.defaultAgentId})]}),s.jsxs("div",{children:[s.jsxs(It,{className:"text-muted-foreground text-xs",children:["Artifacts (",f.artifactCount," ",f.artifactCount===1?"file":"files",")"]}),f.artifacts.length>0&&s.jsxs("div",{className:"mt-1 space-y-1",children:[f.artifacts.slice(0,5).map((y,T)=>s.jsxs("div",{className:`flex items-center gap-1.5 text-xs ${y.isOversized?"text-destructive":""}`,children:[y.isOversized?s.jsx(Wd,{className:"text-destructive h-3 w-3 flex-shrink-0"}):s.jsx(La,{className:"text-muted-foreground h-3 w-3 flex-shrink-0"}),s.jsx("span",{className:"truncate",children:y.name}),s.jsxs("span",{className:"text-muted-foreground flex-shrink-0",children:["(",(y.size/(1024*1024)).toFixed(2)," MB)"]})]},T)),f.artifacts.length>5&&s.jsxs("p",{className:"text-muted-foreground text-xs italic",children:["+ ",f.artifacts.length-5," more files"]})]})]}),f.oversizedArtifacts.length>0&&o&&s.jsx("div",{className:"mt-2",children:s.jsx(Kt,{variant:"warning",message:`${f.oversizedArtifacts.length} ${f.oversizedArtifacts.length===1?"file exceeds":"files exceed"} the maximum size of ${(o/(1024*1024)).toFixed(0)} MB and will be skipped during import: ${f.oversizedArtifacts.slice(0,3).map(y=>y.name).join(", ")}${f.oversizedArtifacts.length>3?` and ${f.oversizedArtifacts.length-3} more`:""}`})})]}),f&&s.jsxs("div",{className:"space-y-2",children:[s.jsx(It,{htmlFor:"customName",children:"Project Name"}),s.jsx(br,{id:"customName",value:m,onChange:y=>p(y.target.value),placeholder:"Enter project name",disabled:w}),s.jsx("p",{className:"text-muted-foreground text-xs",children:"Name conflicts will be resolved automatically"})]}),x&&s.jsx(Kt,{variant:"error",message:x})]}),s.jsxs(nr,{children:[s.jsx(xe,{variant:"outline",onClick:E,disabled:w,children:"Cancel"}),s.jsx(xe,{onClick:N,disabled:w,children:w?"Importing...":"Import"})]})]})})},L1="Projects allow you to give the AI a re-usable set of context for conversations. You can upload files, select a default agent and provide custom instructions.",F1="When you ask a question, it will find the most relevant file and pull answers directly from it. It's great for diving into your documents through natural conversation.",NF=`${L1} ${F1}`,TF=()=>s.jsxs("span",{children:[L1,s.jsx("br",{}),s.jsx("br",{}),F1]}),AF=({projects:e,searchQuery:t,onSearchChange:n,onProjectClick:r,onCreateNew:o,onDelete:a,onExport:i,isLoading:l=!1})=>s.jsx("div",{className:"bg-background flex h-full flex-col",children:s.jsxs("div",{className:"flex h-full flex-col pt-6 pb-6 pl-6",children:[e.length>0||t?s.jsx(Nf,{value:t,onChange:n,placeholder:"Filter by name...",className:"mb-4 w-xs"}):null,l?s.jsx(Lr,{variant:"loading",title:"Loading projects..."}):e.length===0&&t?s.jsx(Lr,{variant:"notFound",title:"No Projects Match Your Filter",subtitle:"Try adjusting your filter terms.",buttons:[{text:"Clear Filter",variant:"default",onClick:()=>n("")}]}):e.length===0?s.jsx(Lr,{variant:"noImage",title:"No Projects Found",subtitle:s.jsx(TF,{}),buttons:[{text:"Create New Project",variant:"default",onClick:()=>o()}]}):s.jsxs("div",{className:"flex-1 overflow-y-auto",children:[s.jsx(Kt,{variant:"info",message:NF,className:"mr-6 mb-4 rounded-md"}),s.jsxs("div",{className:"flex flex-wrap gap-6",children:[s.jsx(bF,{onClick:o}),e.map(c=>s.jsx(CF,{project:c,onClick:()=>r(c),onDelete:a,onExport:i},c.id))]})]})]})}),IF=({isOpen:e,onClose:t,onSave:n,project:r,isSaving:o,error:a})=>{const{validationLimits:i}=Ut(),l=(i==null?void 0:i.projectInstructionsMax)??4e3,[c,u]=d.useState(r.systemPrompt||""),[f,h]=d.useState(null);d.useEffect(()=>{e&&(u(r.systemPrompt||""),h(null))},[e,r.systemPrompt]),d.useEffect(()=>{a&&h(a)},[a]);const m=async()=>{if(h(null),c.trim()!==(r.systemPrompt||""))try{await n(c.trim()),t()}catch{}else t()},p=()=>{u(r.systemPrompt||""),h(null),t()},x=c.length,g=x>l,w=x>l*.9;return s.jsx(On,{open:e,onOpenChange:v=>!v&&p(),children:s.jsxs(Ln,{className:"max-w-3xl max-h-[80vh] flex flex-col",children:[s.jsxs(Gn,{children:[s.jsx(Fn,{children:"Edit Project Instructions"}),s.jsx(Yn,{children:"Provide instructions that will guide the AI when working with this project."})]}),s.jsxs("div",{className:"flex-1 min-h-0 space-y-3",children:[s.jsxs("div",{className:"relative",children:[s.jsx(Wr,{value:c,onChange:v=>u(v.target.value),placeholder:"Add instructions for this project...",rows:15,disabled:o,className:`text-sm resize-none ${g?"border-destructive focus-visible:ring-destructive":""}`}),s.jsx("div",{className:`mt-1 text-xs ${g?"text-destructive font-medium":w?"text-orange-500":"text-muted-foreground"}`,children:g?`Instructions must be less than ${l} characters (currently ${x})`:`${x} / ${l} characters`})]}),f&&s.jsxs("div",{className:"flex items-center gap-2 rounded-md border border-destructive/50 bg-destructive/10 p-3 text-sm text-destructive",children:[s.jsx(fo,{className:"h-4 w-4 flex-shrink-0"}),s.jsx("span",{children:f})]})]}),s.jsxs(nr,{children:[s.jsx(xe,{variant:"outline",onClick:p,disabled:o,children:"Discard Changes"}),s.jsx(xe,{onClick:m,disabled:o||g,children:"Save"})]})]})})},RF=({project:e,onSave:t,isSaving:n,error:r})=>{const[o,a]=d.useState(!1);return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"mb-6",children:[s.jsxs("div",{className:"mb-3 flex items-center justify-between px-4 pt-4",children:[s.jsx("h3",{className:"text-foreground text-sm font-semibold",children:"Instructions"}),s.jsx(xe,{variant:"ghost",size:"sm",onClick:()=>a(!0),className:"h-8 w-8 p-0",tooltip:"Edit",children:s.jsx(ro,{className:"h-4 w-4"})})]}),s.jsx("div",{className:"px-4",children:s.jsx("div",{className:`text-muted-foreground bg-muted max-h-[400px] min-h-[120px] overflow-y-auto rounded-md p-3 text-sm whitespace-pre-wrap ${e.systemPrompt?"":"flex items-center justify-center"}`,children:e.systemPrompt||"No instructions. Provide instructions to tailor the chat responses to your needs."})})]}),s.jsx(IF,{isOpen:o,onClose:()=>a(!1),onSave:t,project:e,isSaving:n,error:r})]})},PF=({project:e,onSave:t,isSaving:n})=>{const{agents:r,agentsLoading:o,agentNameDisplayNameMap:a}=Ft(),[i,l]=d.useState(!1),[c,u]=d.useState(e.defaultAgentId||null);d.useEffect(()=>{u(e.defaultAgentId||null)},[e.defaultAgentId]);const f=async()=>{c!==(e.defaultAgentId||null)&&await t(c),l(!1)},h=()=>{u(e.defaultAgentId||null),l(!1)};return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"mb-6",children:[s.jsxs("div",{className:"mb-3 flex items-center justify-between px-4",children:[s.jsx("h3",{className:"text-foreground text-sm font-semibold",children:"Default Agent"}),s.jsx(xe,{variant:"ghost",size:"sm",onClick:()=>l(!0),disabled:o,className:"h-8 w-8 p-0",tooltip:"Edit",children:s.jsx(ro,{className:"h-4 w-4"})})]}),s.jsx("div",{className:"px-4",children:s.jsx("div",{className:"text-muted-foreground bg-muted flex items-center rounded-md p-2.5 text-sm",children:e.defaultAgentId?s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Zl,{className:"h-4 w-4"}),s.jsx("span",{children:a[e.defaultAgentId??""]||"N/A"})]}):s.jsx("span",{className:"w-full text-center",children:"No default agent set."})})})]}),s.jsx(On,{open:i,onOpenChange:l,children:s.jsxs(Ln,{children:[s.jsxs(Gn,{children:[s.jsx(Fn,{children:"Edit Default Agent"}),s.jsx(Yn,{children:"Select the default agent for this project. This agent will be used when starting new chats in this project."})]}),s.jsx("div",{className:"py-4",children:s.jsxs(Rr,{value:c||"none",onValueChange:m=>u(m==="none"?null:m),disabled:n||o,children:[s.jsx(Mr,{className:"w-full",children:s.jsx(Pr,{placeholder:"Select default agent..."})}),s.jsxs(Dr,{children:[s.jsx(jt,{value:"none",children:s.jsx("span",{className:"text-muted-foreground italic",children:"No default agent"})}),r.map(m=>s.jsx(jt,{value:m.name||"",children:m.displayName||m.name},m.name))]})]})}),s.jsxs(nr,{children:[s.jsx(xe,{variant:"ghost",onClick:h,disabled:n,children:"Cancel"}),s.jsx(xe,{onClick:f,disabled:n||o,children:"Save"})]})]})})]})},MF=e=>{const{configServerUrl:t}=Ut(),[n,r]=d.useState([]),[o,a]=d.useState(!0),[i,l]=d.useState(null),c=`${t}/api/v1`,u=d.useCallback(async()=>{if(!e){r([]),a(!1);return}a(!0),l(null);try{const f=`${c}/projects/${e}/artifacts`,h=await _n(f);r(h)}catch(f){const h=f instanceof Error?f.message:"Failed to fetch project artifacts.";l(h),r([])}finally{a(!1)}},[c,e]);return d.useEffect(()=>{u()},[u]),{artifacts:n,isLoading:o,error:i,refetch:u}};function DF(e,t={}){const{maxSizeBytes:n,includeFileSizes:r=!0,maxFilesToList:o=3}=t;if(!n)return{valid:!0};const a=Array.from(e),i=[];for(const u of a)u.size>n&&i.push({name:u.name,size:u.size});if(i.length===0)return{valid:!0};const l=(n/(1024*1024)).toFixed(0);let c;if(i.length===1){const u=i[0];if(r){const f=(u.size/1048576).toFixed(2);c=`File "${u.name}" (${f} MB) exceeds the maximum size of ${l} MB.`}else c=`File "${u.name}" exceeds the maximum size of ${l} MB.`}else{const u=i.slice(0,o),f=r?u.map(p=>`${p.name} (${(p.size/(1024*1024)).toFixed(2)} MB)`):u.map(p=>p.name),h=i.length-o,m=h>0?` and ${h} more`:"";c=`${i.length} files exceed the maximum size of ${l} MB: ${f.join(", ")}${m}`}return{valid:!1,error:c,oversizedFiles:i}}function OF(e,t,n){const r=(t/1048576).toFixed(2),o=(n/(1024*1024)).toFixed(2);return`File "${e}" is too large: ${r} MB exceeds the maximum allowed size of ${o} MB.`}const LF=({artifact:e,onDownload:t,onDelete:n,onClick:r,onEditDescription:o})=>{const[a,i]=d.useState(!1);return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:`hover:bg-accent/50 group flex items-center justify-between rounded-md p-2 ${r?"cursor-pointer":""}`,onClick:r,children:[s.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[Vf(e,"h-4 w-4 flex-shrink-0 text-muted-foreground"),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("p",{className:"text-foreground truncate text-sm font-medium",title:e.filename,children:e.filename}),s.jsxs("div",{className:"text-muted-foreground flex items-center gap-2 text-xs",children:[e.last_modified&&s.jsx("span",{className:"truncate",title:Ys(e.last_modified),children:Ys(e.last_modified)}),e.size!==void 0&&s.jsxs(s.Fragment,{children:[e.last_modified&&s.jsx("span",{children:"•"}),s.jsx("span",{children:si(e.size)})]})]})]})]}),s.jsxs("div",{className:"flex items-center gap-1 opacity-0 transition-opacity group-hover:opacity-100",children:[o&&s.jsx(xe,{variant:"ghost",onClick:l=>{l.stopPropagation(),o()},tooltip:"Edit Description",children:s.jsx(ro,{})}),s.jsx(xe,{variant:"ghost",onClick:l=>{l.stopPropagation(),t()},tooltip:"Download",children:s.jsx(Co,{})}),n&&s.jsx(xe,{variant:"ghost",tooltip:"Delete",onClick:l=>{l.stopPropagation(),i(!0)},children:s.jsx(Hl,{})})]})]}),n&&s.jsx(Vo,{title:"Delete Project File",content:s.jsxs(s.Fragment,{children:["This action cannot be undone. This file will be permanently removed from the project: ",s.jsx("strong",{children:e.filename})]}),actionLabels:{confirm:"Delete"},open:a,onConfirm:n,onOpenChange:i})]})},FF=({isOpen:e,artifact:t,onClose:n,onEdit:r})=>t?s.jsx(On,{open:e,onOpenChange:n,children:s.jsxs(Ln,{className:"sm:max-w-[700px]",children:[s.jsxs(Gn,{children:[s.jsxs("div",{className:"flex justify-between gap-4",children:[s.jsxs("div",{className:"flex min-w-0 flex-1 gap-2",children:[Vf(t,"flex-shrink-0 text-muted-foreground"),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx(Fn,{className:"max-w-[400px] truncate",title:t.filename,children:t.filename}),s.jsxs("div",{className:"text-muted-foreground mt-1 flex flex-row gap-2 text-sm font-medium",children:[s.jsx("div",{children:t.last_modified?Ys(t.last_modified):null}),s.jsx("div",{children:si(t.size)})]})]})]}),s.jsxs(xe,{variant:"ghost",size:"sm",onClick:r,className:"flex-shrink-0 gap-2 text-sm",children:[s.jsx(ro,{className:"h-4 w-4"}),"Edit Description"]})]}),s.jsx(ac,{children:s.jsx(Yn,{children:"Project File Information"})})]}),s.jsxs("div",{className:"my-6",children:[s.jsx("div",{className:"text-secondary-foreground",children:"Description"}),s.jsx("div",{className:"py-2",children:s.jsx("div",{className:"text-sm whitespace-pre-wrap",children:t.description||"No description provided"})})]}),s.jsx(nr,{children:s.jsx(xe,{variant:"outline",onClick:n,children:"Close"})})]})}):null,$F=({isOpen:e,artifact:t,onClose:n,onSave:r,isSaving:o=!1})=>{const[a,i]=d.useState("");d.useEffect(()=>{e&&t&&i(t.description||"")},[e,t]);const l=async()=>{await r(a)},c=()=>{i((t==null?void 0:t.description)||""),n()};return t?s.jsx(On,{open:e,onOpenChange:u=>!u&&n(),children:s.jsxs(Ln,{className:"sm:max-w-[600px]",children:[s.jsxs(Gn,{children:[s.jsx(Fn,{children:"Edit File Description"}),s.jsx(Yn,{children:"Update the description for this file to help Solace Agent Mesh understand its purpose."})]}),s.jsx("div",{className:"space-y-4 py-4",children:s.jsx(Tf,{noPadding:!0,className:"bg-muted/50 overflow-hidden py-3 shadow-none",children:s.jsxs(cc,{noPadding:!0,className:"overflow-hidden px-3",children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[s.jsx(wr,{className:"text-muted-foreground h-4 w-4 flex-shrink-0"}),s.jsxs("div",{className:"min-w-0 flex-1 overflow-hidden",children:[s.jsx("p",{className:"text-foreground line-clamp-2 text-sm font-medium break-all",title:t.filename,children:t.filename}),s.jsxs("p",{className:"text-muted-foreground text-xs",children:[(t.size/1024).toFixed(1)," KB"]})]})]}),s.jsx(Wr,{className:"bg-background text-foreground mt-2",rows:2,disabled:o,value:a,onChange:u=>i(u.target.value),placeholder:"Enter a description for this file..."})]})})}),s.jsxs(nr,{children:[s.jsx(xe,{variant:"ghost",onClick:c,disabled:o,children:"Discard Changes"}),s.jsx(xe,{onClick:l,disabled:o,children:o?"Saving...":"Save"})]})]})}):null},zF=({project:e})=>{const{artifacts:t,isLoading:n,error:r,refetch:o}=MF(e.id),{addFilesToProject:a,removeFileFromProject:i,updateFileMetadata:l}=ko(),{onDownload:c}=Wf(e.id),{validationLimits:u}=Ut(),f=d.useRef(null),h=u==null?void 0:u.maxUploadSizeBytes,[m,p]=d.useState(null),[x,g]=d.useState(!1),[w,v]=d.useState(!1),[b,C]=d.useState(null),[S,E]=d.useState(!1),[_,j]=d.useState(!1),[A,P]=d.useState(!1),[O,B]=d.useState(null),[N,M]=d.useState(null),y=Rt.useMemo(()=>[...t].sort((se,me)=>{const k=se.last_modified?new Date(se.last_modified).getTime():0;return(me.last_modified?new Date(me.last_modified).getTime():0)-k}),[t]),T=d.useCallback(se=>DF(se,{maxSizeBytes:h}),[h]),R=()=>{var se;(se=f.current)==null||se.click()},z=se=>{const me=se.target.files;if(me&&me.length>0){const k=T(me);if(!k.valid){M(k.error||"One or more files exceed the maximum allowed size."),se.target&&(se.target.value="");return}M(null);const oe=new DataTransfer;Array.from(me).forEach(ie=>oe.items.add(ie)),p(oe.files)}se.target&&(se.target.value="")},F=se=>{se.preventDefault(),se.stopPropagation(),v(!0)},I=se=>{se.preventDefault(),se.stopPropagation(),v(!1)},J=se=>{se.preventDefault(),se.stopPropagation(),v(!1);const me=se.dataTransfer.files;if(me&&me.length>0){const k=T(me);if(!k.valid){M(k.error||"One or more files exceed the maximum allowed size.");return}M(null);const oe=new DataTransfer;Array.from(me).forEach(ie=>oe.items.add(ie)),p(oe.files)}},L=async se=>{g(!0),B(null);try{await a(e.id,se),await o(),p(null)}catch(me){console.error("Failed to add files:",me);const k=me instanceof Error?me.message:"Failed to upload files. Please try again.";B(k)}finally{g(!1)}},D=()=>{p(null),B(null)},W=()=>{B(null)},G=()=>{M(null)},V=async se=>{try{await i(e.id,se),await o()}catch(me){console.error(`Failed to delete file ${se}:`,me)}},Q=se=>{C(se),E(!0)},X=se=>{C(se),j(!0)},K=async se=>{if(b){P(!0);try{await l(e.id,b.filename,se),await o(),j(!1),C(null)}catch(me){console.error("Failed to update file description:",me)}finally{P(!1)}}},q=()=>{E(!1),C(null)},ne=()=>{j(!1),S||C(null)},de=()=>{E(!1),j(!0)};return s.jsxs("div",{className:"mb-6",children:[N&&s.jsx("div",{className:"px-4 pb-3",children:s.jsx(Kt,{variant:"error",message:N,dismissible:!0,onDismiss:G})}),s.jsxs("div",{className:"mb-3 flex items-center justify-between px-4",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("h3",{className:"text-foreground text-sm font-semibold",children:"Knowledge"}),!n&&t.length>0&&s.jsxs("span",{className:"text-muted-foreground text-xs",children:["(",t.length,")"]})]}),s.jsxs(xe,{variant:"ghost",size:"sm",onClick:R,children:[s.jsx(Fs,{className:"mr-2 h-4 w-4"}),"Upload"]})]}),s.jsxs("div",{className:"px-4 pb-3",onDragOver:F,onDragLeave:I,onDrop:J,children:[n&&s.jsx("div",{className:"flex items-center justify-center p-4",children:s.jsx(no,{size:"small"})}),r&&s.jsxs("div",{className:"text-destructive border-destructive/50 rounded-md border p-3 text-sm",children:["Error loading files: ",r]}),!n&&!r&&t.length===0&&s.jsxs("div",{className:`flex flex-col items-center justify-center rounded-md border-2 border-dashed p-6 text-center transition-all ${w?"border-primary bg-primary/10 scale-[1.02]":"border-muted-foreground/30"}`,children:[s.jsx(Fs,{className:`mb-3 h-10 w-10 transition-colors ${w?"text-primary":"text-muted-foreground"}`}),s.jsx("p",{className:`text-sm transition-colors ${w?"text-primary font-medium":"text-muted-foreground"}`,children:w?"Drop files here to upload":"No knowledge. Upload documents and files that you want the chat to reference."})]}),!n&&!r&&t.length>0&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:`mb-2 rounded-md border-2 border-dashed p-3 text-center transition-all ${w?"border-primary bg-primary/10 scale-[1.02]":"border-muted-foreground/20 bg-muted/30"}`,children:[s.jsx(Fs,{className:`mx-auto mb-1 h-5 w-5 transition-colors ${w?"text-primary":"text-muted-foreground"}`}),s.jsx("p",{className:`text-xs transition-colors ${w?"text-primary font-medium":"text-muted-foreground"}`,children:w?"Drop files here to upload":"Drag and drop files here to upload"})]}),s.jsx("div",{className:"max-h-[400px] space-y-1 overflow-y-auto rounded-md",children:y.map(se=>s.jsx(LF,{artifact:se,onDownload:()=>c(se),onDelete:()=>V(se.filename),onClick:()=>Q(se),onEditDescription:()=>X(se)},se.filename))})]}),s.jsx("input",{type:"file",ref:f,onChange:z,className:"hidden",multiple:!0})]}),s.jsx(yF,{isOpen:!!m,files:m,onClose:D,onConfirm:L,isSubmitting:x,error:O,onClearError:W}),s.jsx(FF,{isOpen:S,artifact:b,onClose:q,onEdit:de}),s.jsx($F,{isOpen:_,artifact:b,onClose:ne,onSave:K,isSaving:A})]})},UF=({project:e,onChatClick:t,onStartNewChat:n})=>{const{sessions:r,isLoading:o,error:a}=OT(e.id);return s.jsxs("div",{className:"px-6 py-4",children:[s.jsxs("div",{className:"mb-3 flex items-center justify-between",children:[s.jsx("h3",{className:"text-foreground text-sm font-semibold",children:"Chats"}),n&&s.jsxs(xe,{onClick:n,size:"sm",children:[s.jsx(ns,{className:"mr-2 h-4 w-4"}),"New Chat"]})]}),o&&s.jsx("div",{className:"flex items-center justify-center p-8",children:s.jsx(no,{size:"small"})}),a&&s.jsxs("div",{className:"text-destructive border-destructive/50 rounded-md border p-4 text-sm",children:["Error loading chats: ",a]}),!o&&!a&&r.length===0&&s.jsxs("div",{className:"flex flex-col items-center justify-center rounded-md border border-dashed p-8 text-center",children:[s.jsx(xl,{className:"text-muted-foreground mb-2 h-8 w-8"}),s.jsx("p",{className:"text-muted-foreground mb-4 text-sm",children:"No chats. Start a chat with all the knowledge and context from this project."}),n&&s.jsxs(xe,{onClick:n,size:"sm",children:[s.jsx(ns,{className:"mr-2 h-4 w-4"}),"Start New Chat"]})]}),!o&&!a&&r.length>0&&s.jsx("div",{className:"space-y-2",children:r.map(i=>s.jsx("div",{className:"hover:bg-accent/50 cursor-pointer rounded-md border p-3 shadow-sm transition-colors",onClick:()=>t(i.id),role:"button",tabIndex:0,onKeyDown:l=>{(l.key==="Enter"||l.key===" ")&&(l.preventDefault(),t(i.id))},children:s.jsx("div",{className:"flex items-start justify-between gap-2",children:s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("p",{className:"text-foreground truncate text-sm font-medium",children:i.name||`Chat ${i.id.substring(0,8)}`}),s.jsxs("div",{className:"text-muted-foreground mt-1 flex items-center gap-1 text-xs",children:[s.jsx(Kg,{className:"h-3 w-3"}),s.jsx("span",{children:of(i.updatedTime)})]})]})})},i.id))})]})},BF=({project:e,onBack:t,onStartNewChat:n,onChatClick:r})=>{const{updateProject:o,projects:a,deleteProject:i}=ko(),[l,c]=d.useState(!1),[u,f]=d.useState(null),[h,m]=d.useState(!1),[p,x]=d.useState(e.name),[g,w]=d.useState(e.description||""),[v,b]=d.useState(null),[C,S]=d.useState(!1),[E,_]=d.useState(!1),j=async M=>{f(null),c(!0);try{const y={systemPrompt:M};await o(e.id,y)}catch(y){const T=y instanceof Error?y.message:"Failed to update instructions";throw f(T),y}finally{c(!1)}},A=async M=>{c(!0);try{const y={defaultAgentId:M};await o(e.id,y)}catch(y){throw console.error("Failed to update default agent:",y),y}finally{c(!1)}},P=async()=>{const M=p.trim(),y=g.trim();if(a.some(R=>R.id!==e.id&&R.name.toLowerCase()===M.toLowerCase())){b("A project with this name already exists");return}b(null),c(!0);try{const R={};M!==e.name&&(R.name=M),y!==(e.description||"")&&(R.description=y),Object.keys(R).length>0&&await o(e.id,R),m(!1)}catch(R){console.error("Failed to update project:",R),b(R instanceof Error?R.message:"Failed to update project")}finally{c(!1)}},O=()=>{x(e.name),w(e.description||""),m(!1),b(null)},B=()=>{S(!0)},N=async()=>{_(!0);try{await i(e.id),S(!1),t()}catch(M){console.error("Failed to delete project:",M)}finally{_(!1)}};return s.jsxs("div",{className:"flex h-full flex-col",children:[s.jsx(vs,{title:e.name,breadcrumbs:[{label:"Projects",onClick:t},{label:e.name}],buttons:[s.jsxs(xe,{variant:"ghost",size:"sm",onClick:()=>m(!0),className:"gap-2",children:[s.jsx(ro,{className:"h-4 w-4"}),"Edit Details"]},"edit"),s.jsxs(Qs,{children:[s.jsx(ea,{asChild:!0,children:s.jsx(xe,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",children:s.jsx(Mo,{className:"h-4 w-4"})})}),s.jsx(ta,{align:"end",children:s.jsxs(jn,{onClick:B,children:[s.jsx(rs,{className:"mr-2 h-4 w-4"}),"Delete"]})})]},"more")]}),s.jsxs("div",{className:"flex min-h-0 flex-1",children:[s.jsxs("div",{className:"w-[60%] overflow-y-auto border-r",children:[e.description&&s.jsx("div",{className:"px-8 py-4",children:s.jsx("p",{className:"text-muted-foreground text-sm",children:e.description})}),r&&s.jsx(UF,{project:e,onChatClick:r,onStartNewChat:n})]}),s.jsxs("div",{className:"bg-muted/30 w-[40%] overflow-y-auto",children:[s.jsx(RF,{project:e,onSave:j,isSaving:l,error:u}),s.jsx(PF,{project:e,onSave:A,isSaving:l}),s.jsx(zF,{project:e})]})]}),s.jsx($P,{children:s.jsx(xe,{variant:"outline","data-testid":"closeButton",title:"Close",onClick:t,children:"Close"})}),s.jsx(On,{open:h,onOpenChange:m,children:s.jsxs(Ln,{onOpenAutoFocus:M=>M.preventDefault(),children:[s.jsxs(Gn,{children:[s.jsx(Fn,{children:"Edit Project Details"}),s.jsx(Yn,{children:"Update the name and description for this project."})]}),s.jsxs("div",{className:"space-y-4 py-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{className:"text-sm font-medium",children:"Name*"}),s.jsx(br,{value:p,onChange:M=>x(M.target.value),placeholder:"Project name",disabled:l,maxLength:255,autoFocus:!1})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{className:"text-sm font-medium",children:"Description*"}),s.jsx(Wr,{value:g,onChange:M=>w(M.target.value),placeholder:"Project description",rows:4,disabled:l,maxLength:1e3}),s.jsxs("div",{className:"text-muted-foreground text-right text-xs",children:[g.length,"/1000 characters"]})]}),v&&s.jsx(Kt,{variant:"error",message:v})]}),s.jsxs(nr,{children:[s.jsx(xe,{variant:"outline",onClick:O,disabled:l,children:"Discard Changes"}),s.jsx(xe,{onClick:P,disabled:l,children:"Save"})]})]})}),s.jsx(O1,{isOpen:C,onClose:()=>S(!1),onConfirm:N,project:e,isDeleting:E})]})},Ng=()=>{const e=zo(),t=mx(),[n,r]=d.useState(!1),[o,a]=d.useState(!1),[i,l]=d.useState(!1),[c,u]=d.useState(null),[f,h]=d.useState(!1),[m,p]=d.useState(!1),{projects:x,isLoading:g,createProject:w,setActiveProject:v,refetch:b,searchQuery:C,setSearchQuery:S,filteredProjects:E,deleteProject:_}=ko(),{handleNewSession:j,handleSwitchSession:A,addNotification:P,displayError:O}=Ft(),B=d.useMemo(()=>x.find(W=>W.id===(t==null?void 0:t.projectId))||null,[x,t==null?void 0:t.projectId]),N=async W=>{a(!0);try{const G=new FormData;G.append("name",W.name),W.description&&G.append("description",W.description);const V=await w(G);r(!1),await b(),e(`/projects/${V.id}`)}finally{a(!1)}},M=W=>{e(`/projects/${W.id}`)},y=()=>{e("/projects")},T=async W=>{B&&v(B),await A(W),e("chat")},R=()=>{r(!0)},z=W=>{u(W),l(!0)},F=async()=>{if(c){h(!0);try{await _(c.id),l(!1),u(null)}catch(W){console.error("Failed to delete project:",W)}finally{h(!1)}}},I=d.useCallback(async()=>{B&&(v(B),await j(!0),e("chat"))},[B,v,j,e]),J=async W=>{try{const V=await(await vn(`/api/v1/projects/${W.id}/export`)).blob(),Q=`project-${W.name.replace(/[^a-z0-9]/gi,"-").toLowerCase()}-${Date.now()}.zip`;oi(V,Q),P("Project exported","success")}catch(G){console.error("Failed to export project:",G),O({title:"Failed to Export Project",error:Yt(G,"An unknown error occurred while exporting the project.")})}},L=async(W,G)=>{try{const V=new FormData;V.append("file",W),V.append("options",JSON.stringify(G));const Q=await _n("/api/v1/projects/import",{method:"POST",body:V});if(Q.warnings&&Q.warnings.length>0){const X=Q.warnings.length===1?Q.warnings[0]:`Import completed with ${Q.warnings.length} warnings:
434
+ ${Q.warnings.join(`
435
+ `)}`;P(X,"info")}await b(),e(`/projects/${Q.projectId}`),P(`Project imported with ${Q.artifactsImported} artifacts`,"success")}catch(V){throw console.error("Failed to import project:",V),V}},D=B!==null;return s.jsxs("div",{className:"flex h-full w-full flex-col",children:[!D&&s.jsx(vs,{title:"Projects",buttons:[s.jsxs(xe,{variant:"ghost",title:"Import Project",onClick:()=>p(!0),children:[s.jsx(Fs,{className:"size-4"}),"Import Project"]},"importProject"),s.jsxs(xe,{"data-testid":"refreshProjects",disabled:g,variant:"ghost",title:"Refresh Projects",onClick:()=>b(),children:[s.jsx(Gl,{className:"size-4"}),"Refresh Projects"]},"refreshProjects")]}),s.jsx("div",{className:"min-h-0 flex-1",children:D?s.jsx(BF,{project:B,onBack:y,onStartNewChat:I,onChatClick:T}):s.jsx(AF,{projects:E,searchQuery:C,onSearchChange:S,onProjectClick:M,onCreateNew:R,onDelete:z,onExport:J,isLoading:g})}),s.jsx(wF,{isOpen:n,onClose:()=>r(!1),onSubmit:N,isSubmitting:o}),s.jsx(O1,{isOpen:i,onClose:()=>{l(!1),u(null)},onConfirm:F,project:c,isDeleting:f}),s.jsx(jF,{open:m,onOpenChange:p,onImport:L})]})};let tl=null,nl=null;function VF({children:e}){const{fetchCsrfToken:t}=$w(),[n,r]=d.useState(tl),[o,a]=d.useState(!tl&&!nl),[i,l]=d.useState(nl);return d.useEffect(()=>{if(tl||nl)return;let c=!0;return(async()=>{var f,h,m;a(!0),l(null);try{let p=await pt("/api/v1/config",{credentials:"include",headers:{Accept:"application/json"}}),x;if(p.ok)x=await p.json();else{const S=await p.text();if(console.error("Initial config fetch failed:",p.status,S),p.status===403){console.log("Config fetch failed with 403, attempting to get CSRF token first...");const E=await t();if(!E)throw new Error("Failed to obtain CSRF token after config fetch failed.");if(console.log("Retrying config fetch with CSRF token..."),p=await pt("/api/v1/config",{credentials:"include",headers:{"X-CSRF-TOKEN":E,Accept:"application/json"}}),!p.ok){const _=await p.text();throw console.error("Config fetch retry failed:",p.status,_),new Error(`Failed to fetch config on retry: ${p.status} ${_}`)}x=await p.json()}else throw new Error(`Failed to fetch config: ${p.status} ${S}`)}const g=x.frontend_use_authorization??!1;g&&(console.log("Fetching CSRF token for config-related requests..."),await t());const w=((f=x.frontend_feature_enablement)==null?void 0:f.projects)??!1,v=((h=x.frontend_feature_enablement)==null?void 0:h.background_tasks)??!1,b=((m=x.background_tasks_config)==null?void 0:m.default_timeout_ms)??36e5,C={configServerUrl:x.frontend_server_url,configAuthLoginUrl:x.frontend_auth_login_url,configUseAuthorization:g,configWelcomeMessage:x.frontend_welcome_message,configRedirectUrl:x.frontend_redirect_url,configCollectFeedback:x.frontend_collect_feedback,configBotName:x.frontend_bot_name,configLogoUrl:x.frontend_logo_url,configFeatureEnablement:x.frontend_feature_enablement??{},frontend_use_authorization:x.frontend_use_authorization,persistenceEnabled:x.persistence_enabled??!1,projectsEnabled:w,validationLimits:x.validation_limits,backgroundTasksEnabled:v,backgroundTasksDefaultTimeoutMs:b};c&&(tl=C,r(C)),console.log("App config processed and set:",C)}catch(p){if(console.error("Error initializing app:",p),c){const x=p.message||"Failed to load application configuration.";nl=x,l(x)}}finally{c&&a(!1)}})(),()=>{c=!1}},[t]),n?s.jsx(Nw.Provider,{value:n,children:e}):o?s.jsx("div",{className:"flex min-h-screen items-center justify-center bg-white dark:bg-gray-900",children:s.jsxs("div",{className:"text-center",children:[s.jsx("div",{className:"border-solace-green mx-auto mb-4 h-12 w-12 animate-spin rounded-full border-b-2"}),s.jsx("h1",{className:"text-2xl text-black dark:text-white",children:"Loading Configuration..."})]})}):i?s.jsx(Lr,{className:"h-screen w-screen",variant:"error",title:"Configuration Error",subtitle:"Please check the backend server and network connection, then refresh the page."}):s.jsx("div",{className:"flex min-h-screen items-center justify-center bg-white dark:bg-gray-900",children:s.jsxs("div",{className:"text-center",children:[s.jsx("div",{className:"border-solace-green mx-auto mb-4 h-12 w-12 animate-spin rounded-full border-b-2"}),s.jsx("h1",{className:"text-2xl",children:"Initializing Application..."})]})})}const WF=({children:e})=>{const{configServerUrl:t}=Ut(),n=`${t}/api/v1`,[r,o]=d.useState(null),[a,i]=d.useState(!1),[l,c]=d.useState(!1),[u,f]=d.useState(null),[h,m]=d.useState({}),[p,x]=d.useState([]),[g,w]=d.useState(null),[v,b]=d.useState(0),[C,S]=d.useState(!1),E=10,_=d.useRef(null),j=d.useRef(null),A=d.useRef(null);d.useEffect(()=>{j.current=r},[r]);const P=d.useCallback(I=>{m(J=>{var G,V,Q;const L=I.task_id;if(!L)return I.direction==="discovery"||console.warn("TaskMonitorContext: Received event without task_id, skipping:",I),J;const D=J[L],W=new Date(I.timestamp);if(D){const X=[...D.events,I].sort((K,q)=>new Date(K.timestamp).getTime()-new Date(q.timestamp).getTime());return{...J,[L]:{...D,events:X,lastUpdated:W}}}else{let X="Task started...";if(I.direction==="request"&&((V=(G=I.full_payload)==null?void 0:G.method)!=null&&V.startsWith("message/"))){const q=I.full_payload.params;if((Q=q==null?void 0:q.message)!=null&&Q.parts){const ne=q.message.parts.filter(de=>de.kind==="text"&&de.text);ne.length>0&&(X=ne[ne.length-1].text)}}const K={taskId:L,initialRequestText:X,events:[I],firstSeen:W,lastUpdated:W};return x(q=>[L,...q.filter(ne=>ne!==L)]),{...J,[L]:K}}})},[]),O=d.useCallback(()=>{console.log("TaskMonitorContext: SSE connection opened."),i(!1),c(!0),f(null),b(0),S(!1),A.current&&(clearTimeout(A.current),A.current=null)},[]),B=d.useCallback(I=>{try{const J=JSON.parse(I.data);P(J)}catch(J){console.error("TaskMonitorContext: Failed to parse SSE 'a2a_message' event data:",J,"Raw data:",I.data),f("Received unparseable 'a2a_message' event from server.")}},[P]),N=d.useCallback(I=>{console.error("TaskMonitorContext: SSE connection error:",I),i(!1),c(!1),_.current&&_.current.readyState===EventSource.CLOSED?f("Task Monitor SSE connection closed by server or network issue."):f("Task Monitor SSE connection error occurred."),_.current&&(_.current.close(),_.current=null),A.current&&(clearTimeout(A.current),A.current=null)},[]),M=d.useCallback(async()=>{if(l||a){console.warn("TaskMonitorContext: Stream is already active or connecting.");return}console.log("TaskMonitorContext: Attempting to connect stream..."),i(!0);try{const I={subscription_targets:[{type:"my_a2a_messages"}]},J=await pt(`${n}/visualization/subscribe`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(I),credentials:"include"});if(!J.ok){const Q=await J.json().catch(()=>({detail:"Failed to subscribe"}));if(Q.error_type==="authorization_failure"){const X=Q.message||"Access denied: insufficient permissions",K=Q.suggested_action?` ${Q.suggested_action}`:"";throw new Error(`${X}${K}`)}else if(Q.error_type==="subscription_failure"){const X=Q.message||"Subscription failed",K=Q.suggested_action?` ${Q.suggested_action}`:"";throw new Error(`${X}${K}`)}else throw new Error(Q.detail||Q.message||`Subscription failed: ${J.statusText}`)}const L=await J.json();o(L.stream_id);const D=L.sse_endpoint_url.startsWith("/")?`${t||""}${L.sse_endpoint_url}`:L.sse_endpoint_url;_.current&&_.current.close();const W=nf(),G=`${D}${W?`?token=${W}`:""}`,V=new EventSource(G,{withCredentials:!0});_.current=V,V.onopen=O,V.addEventListener("a2a_message",B),V.onerror=N}catch(I){console.error("TaskMonitorContext: Error connecting stream:",I),f(I instanceof Error?I.message:String(I)),i(!1),c(!1),o(null),_.current&&(_.current.close(),_.current=null),A.current&&(clearTimeout(A.current),A.current=null)}},[n,t,l,a,O,B,N]),y=d.useCallback(()=>{if(A.current){console.log("TaskMonitorContext: Reconnection already in progress, skipping...");return}if(v>=E){console.warn("TaskMonitorContext: Max reconnection attempts reached. Stopping auto-reconnection."),S(!1),f(`Connection lost. Max reconnection attempts (${E}) reached.`);return}const I=2e3;console.log(`TaskMonitorContext: Attempting reconnection ${v+1}/${E} in ${I}ms...`),S(!0),b(J=>J+1),A.current=setTimeout(()=>{M()},I)},[v,M]),T=d.useCallback(async()=>{console.log("TaskMonitorContext: Disconnecting stream..."),A.current&&(clearTimeout(A.current),A.current=null),_.current&&(_.current.close(),_.current=null);const I=j.current;if(I)try{await pt(`${n}/visualization/${I}/unsubscribe`,{method:"DELETE",credentials:"include"})}catch(J){console.error(`TaskMonitorContext: Error unsubscribing from stream ID: ${I}`,J)}o(null),i(!1),c(!1),f(null),m({}),x([]),w(null),b(0),S(!1)},[n]);d.useEffect(()=>()=>{console.log("TaskMonitorProvider: Unmounting. Cleaning up Task Monitor SSE connection."),_.current&&(_.current.close(),_.current=null);const I=j.current;if(I)if(navigator.sendBeacon){const J=new FormData;navigator.sendBeacon(`${n}/visualization/${I}/unsubscribe`,J)}else pt(`${n}/visualization/${I}/unsubscribe`,{method:"DELETE",credentials:"include",keepalive:!0}).catch(J=>console.error("TaskMonitorProvider: Error in final unsubscribe on unmount (fetch):",J))},[n]),d.useEffect(()=>{!l&&!a&&(console.log("TaskProvider: Auto-connecting to task monitor stream..."),M())},[]),d.useEffect(()=>{!l&&!a&&u&&(console.log("TaskMonitorContext: Connection lost, initiating auto-reconnection..."),y())},[l,a,u,y]),d.useEffect(()=>()=>{A.current&&(clearTimeout(A.current),A.current=null)},[]);const R=d.useCallback(I=>{w(I)},[]),z=d.useCallback(async I=>{var J,L;try{const D=await pt(`${n}/tasks/${I}/events`,{method:"GET",credentials:"include"});if(!D.ok){const Q=await D.json().catch(()=>({detail:"Failed to load task"}));return console.error(`TaskProvider: Failed to load task ${I}:`,Q),null}const G=(await D.json()).tasks,V={};for(const[Q,X]of Object.entries(G)){const K=X.events,q={taskId:Q,initialRequestText:X.initial_request_text||"Task loaded from history",events:K,firstSeen:new Date(((J=K[0])==null?void 0:J.timestamp)||Date.now()),lastUpdated:new Date(((L=K[K.length-1])==null?void 0:L.timestamp)||Date.now())};V[Q]=q}return m(Q=>({...Q,...V})),x(Q=>Q.includes(I)?Q:[I,...Q]),V[I]||null}catch(D){return console.error(`TaskProvider: Error loading task ${I} from backend:`,D),null}},[n]),F={isTaskMonitorConnecting:a,isTaskMonitorConnected:l,taskMonitorSseError:u,monitoredTasks:h,monitoredTaskOrder:p,highlightedStepId:g,isReconnecting:C,reconnectionAttempts:v,connectTaskMonitorStream:M,disconnectTaskMonitorStream:T,setHighlightedStepId:R,loadTaskFromBackend:z};return s.jsx(Aw.Provider,{value:F,children:e})},An=[];for(let e=0;e<256;++e)An.push((e+256).toString(16).slice(1));function HF(e,t=0){return(An[e[t+0]]+An[e[t+1]]+An[e[t+2]]+An[e[t+3]]+"-"+An[e[t+4]]+An[e[t+5]]+"-"+An[e[t+6]]+An[e[t+7]]+"-"+An[e[t+8]]+An[e[t+9]]+"-"+An[e[t+10]]+An[e[t+11]]+An[e[t+12]]+An[e[t+13]]+An[e[t+14]]+An[e[t+15]]).toLowerCase()}let Fu;const ZF=new Uint8Array(16);function GF(){if(!Fu){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");Fu=crypto.getRandomValues.bind(crypto)}return Fu(ZF)}const YF=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),Tg={randomUUID:YF};function KF(e,t,n){var o;e=e||{};const r=e.random??((o=e.rng)==null?void 0:o.call(e))??GF();if(r.length<16)throw new Error("Random bytes length must be >= 16");return r[6]=r[6]&15|64,r[8]=r[8]&63|128,HF(r)}function Zr(e,t,n){return Tg.randomUUID&&!e?Tg.randomUUID():KF(e)}const rl=1,qF=e=>({...e,taskMetadata:{...e.taskMetadata,schema_version:1}}),XF={0:qF},JF=1*1024*1024,QF=e=>new Promise((t,n)=>{const r=new FileReader;r.readAsDataURL(e),r.onload=()=>t(r.result.split(",")[1]),r.onerror=o=>n(o)}),e9=({children:e})=>{const{configWelcomeMessage:t,configServerUrl:n,persistenceEnabled:r,configCollectFeedback:o,backgroundTasksEnabled:a,backgroundTasksDefaultTimeoutMs:i}=Ut(),l=d.useMemo(()=>`${n}/api/v1`,[n]),{activeProject:c,setActiveProject:u,projects:f}=ko(),{ErrorDialog:h,setError:m}=zT(),[p,x]=d.useState(""),[g,w]=d.useState([]),[v,b]=d.useState(!1),[C,S]=d.useState([]),[E,_]=d.useState(null),j=d.useRef(null),[A,P]=d.useState(""),[O,B]=d.useState(!1),N=d.useRef(new Set),M=d.useRef(new Set),y=d.useRef(new Set),T=d.useRef(O);d.useEffect(()=>{T.current=O},[O]);const R=d.useRef(p);d.useEffect(()=>{R.current=p},[p]);const[z,F]=d.useState(null),I=d.useRef(null),J=d.useRef(!1),L=d.useRef(null),D=d.useRef(0),W=d.useRef([]),G=d.useRef([]),{agents:V,agentNameMap:Q,error:X,isLoading:K,refetch:q}=sT(),{artifacts:ne,isLoading:de,refetch:se,setArtifacts:me}=ST(p),[k,oe]=d.useState(!0),[ie,Z]=d.useState("files"),[U,re]=d.useState(!1),[$,Y]=d.useState(null),[H,ce]=d.useState(!1),[ue,ae]=d.useState(new Set),[pe,Te]=d.useState(!1),[Ae,gt]=d.useState(null),[Pt,Nt]=d.useState(null),[Mt,ct]=d.useState(null),[$t,Wt]=d.useState(null),Dt=d.useMemo(()=>Ae&&ne.find(he=>he.filename===Ae)||null,[ne,Ae]),[ve,Pe]=d.useState({expandedArtifacts:new Set}),[Me,Oe]=d.useState({}),[at,Ue]=d.useState(null),it=d.useCallback((he,Ce)=>{S(ye=>{if(ye.find(Re=>Re.message===he))return ye;const Be=Date.now().toString(),Ee={id:Be,message:he,type:Ce||"info"};return setTimeout(()=>{S(Re=>Re.filter(Je=>Je.id!==Be))},4e3),[...ye,Ee]})},[]),{backgroundTasks:We,notifications:ft,registerBackgroundTask:Et,unregisterBackgroundTask:hn,updateTaskTimestamp:Dn,isTaskRunningInBackground:ee,checkTaskStatus:le}=ET({apiPrefix:l,userId:"sam_dev_user",onTaskCompleted:d.useCallback(he=>{it("Background task completed","success"),typeof window<"u"&&(window.dispatchEvent(new CustomEvent("background-task-completed",{detail:{taskId:he}})),window.dispatchEvent(new CustomEvent("new-chat-session")))},[it]),onTaskFailed:d.useCallback((he,Ce)=>{m({title:"Background Task Failed",error:Ce}),typeof window<"u"&&(window.dispatchEvent(new CustomEvent("background-task-completed",{detail:{taskId:he}})),window.dispatchEvent(new CustomEvent("new-chat-session")))},[m])});d.useEffect(()=>{W.current=We},[We]),d.useEffect(()=>{G.current=g},[g]);const fe=d.useCallback(he=>{var Ne,Be;let Ce="";const ye=he.parts||[];for(const Ee of ye)Ee.kind==="text"?Ce+=Ee.text:Ee.kind==="artifact"&&(Ce+=`«artifact_return:${Ee.name}»`);return{id:((Ne=he.metadata)==null?void 0:Ne.messageId)||`msg-${Zr()}`,type:he.isUser?"user":"agent",text:Ce,parts:he.parts,uploadedFiles:(Be=he.uploadedFiles)==null?void 0:Be.map(Ee=>({name:Ee.name,type:Ee.type})),isError:he.isError}},[]),be=d.useCallback(async(he,Ce)=>{const ye=Ce||p;if(!r||!ye||N.current.has(he.task_id))return!1;N.current.add(he.task_id);try{const Ne=await pt(`${l}/sessions/${ye}/chat-tasks`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({taskId:he.task_id,userMessage:he.user_message,messageBubbles:JSON.stringify(he.message_bubbles),taskMetadata:he.task_metadata?JSON.stringify(he.task_metadata):null})});if(!Ne.ok){const Be=await Ne.json().catch(()=>({detail:"Failed saving task"}));throw new Error(Be.message||`HTTP error ${Ne.status}`)}return!0}catch(Ne){return console.error(`Failed saving task ${he.task_id}:`,Ne),!1}finally{setTimeout(()=>{N.current.delete(he.task_id)},100)}},[l,p,r]),_e=d.useCallback((he,Ce,ye,Ne)=>{const Be=/«artifact_return:([^»]+)»/g,Ee=/«artifact:([^»]+)»/g,Re=Ge=>({kind:"artifact",status:"completed",name:Ge,file:{name:Ge,uri:`artifact://${Ce}/${Ge}`}});let Je;for(;(Je=Be.exec(he))!==null;){const Ge=Je[1];ye.has(Ge)||(ye.add(Ge),Ne.push(Re(Ge)))}for(;(Je=Ee.exec(he))!==null;){const Ge=Je[1];ye.has(Ge)||(ye.add(Ge),Ne.push(Re(Ge)))}},[]),Fe=d.useCallback((he,Ce)=>he.messageBubbles.map(ye=>{const Ne=[],Be=ye.parts||[{kind:"text",text:ye.text||""}],Ee=new Set;ye.text&&_e(ye.text,Ce,Ee,Ne);for(const Re of Be)if(Re.kind==="text"&&Re.text){let Je=Re.text;_e(Je,Ce,Ee,Ne),Je=Je.replace(/«artifact_return:[^»]+»/g,""),Je=Je.replace(/«artifact:[^»]+»/g,""),Je=Je.replace(/«status_update:[^»]+»\n?/g,""),Je.trim()&&Ne.push({kind:"text",text:Je})}else if(Re.kind==="artifact"){const Je=Re.name;Je&&!Ee.has(Je)&&(Ee.add(Je),Ne.push(Re))}else Ne.push(Re);return{taskId:he.taskId,role:ye.type==="user"?"user":"agent",parts:Ne,isUser:ye.type==="user",isComplete:!0,files:ye.files,uploadedFiles:ye.uploadedFiles,artifactNotification:ye.artifactNotification,isError:ye.isError,metadata:{messageId:ye.id,sessionId:Ce,lastProcessedEventSequence:0}}}),[]),He=d.useCallback(he=>{var Ne;const Ce=((Ne=he.taskMetadata)==null?void 0:Ne.schema_version)||0;if(Ce>=rl)return he;let ye=he;for(let Be=Ce;Be<rl;Be++){const Ee=XF[Be];Ee?(ye=Ee(ye),console.log(`Migrated task ${he.taskId} from v${Be} to v${Be+1}`)):console.warn(`No migration function found for version ${Be}`)}return ye},[]),Le=d.useCallback(async he=>{var Ge,St;const Ce=await _n(`${l}/sessions/${he}/chat-tasks`);if(R.current!==he){console.log(`Session ${he} is no longer the active session: ${R.current}`);return}const Be=(Ce.tasks||[]).map(ut=>({...ut,messageBubbles:JSON.parse(ut.messageBubbles),taskMetadata:ut.taskMetadata?JSON.parse(ut.taskMetadata):null})).map(He),Ee=[];for(const ut of Be){const un=Fe(ut,he);Ee.push(...un)}const Re={};for(const ut of Be)(Ge=ut.taskMetadata)!=null&&Ge.feedback&&(Re[ut.taskId]={type:ut.taskMetadata.feedback.type,text:ut.taskMetadata.feedback.text||""});let Je=null;for(let ut=Be.length-1;ut>=0;ut--)if((St=Be[ut].taskMetadata)!=null&&St.agent_name){Je=Be[ut].taskMetadata.agent_name;break}if(w(Ee),Oe(Re),Je&&P(Je),Be.length>0){const ut=Be[Be.length-1];F(ut.taskId)}},[l,Fe,He]),Ve=d.useCallback(async(he,Ce,ye,Ne=!1)=>{const Be=Ce||p,Ee=new FormData;if(Ee.append("upload_file",he),Ee.append("filename",he.name),Ee.append("sessionId",Be||""),ye){const Re={description:ye};Ee.append("metadata_json",JSON.stringify(Re))}try{const Re=await pt(`${l}/artifacts/upload`,{method:"POST",body:Ee});if(Re.status===413){const Ge=await Re.json().catch(()=>({message:`Failed to upload ${he.name}.`})),St=Ge.actual_size_bytes,ut=Ge.max_size_bytes,un=St&&ut?OF(he.name,St,ut):Ge.message||`File "${he.name}" exceeds the maximum allowed size.`;return m({title:"File Upload Failed",error:un}),{error:un}}if(!Re.ok)throw new Error(await Re.json().then(Ge=>Ge.message).catch(()=>`Failed to upload ${he.name}.`));const Je=await Re.json();return Ne||it(`File "${he.name}" uploaded.`,"success"),await se(),Je.uri&&Je.sessionId?{uri:Je.uri,sessionId:Je.sessionId}:null}catch(Re){const Je=Yt(Re,`Failed to upload "${he.name}".`);return m({title:"File Upload Failed",error:Je}),{error:Je}}},[l,p,it,se,m]),[Xe,Se]=d.useState(null),[je,De]=d.useState(null),[Ze,yt]=d.useState(!1),At=d.useCallback(async he=>{try{await vn(`${l}/artifacts/${p}/${encodeURIComponent(he)}`,{method:"DELETE"}),it(`File "${he}" deleted.`,"success"),se()}catch(Ce){m({title:"File Deletion Failed",error:Yt(Ce,`Failed to delete ${he}.`)})}},[l,p,it,se,m]),ke=d.useCallback(he=>{Y(he),re(!0)},[]),te=d.useCallback(()=>{Y(null),re(!1)},[]),ge=d.useCallback(he=>{gt((he==null?void 0:he.filename)||null)},[]),Ie=d.useCallback(async()=>{if($){const he=(Dt==null?void 0:Dt.filename)===$.filename;await At($.filename),he&&ge(null)}te()},[$,At,te,Dt,ge]),$e=d.useCallback(()=>{ue.size!==0&&Te(!0)},[ue]),nt=d.useCallback(async()=>{Te(!1);const he=Array.from(ue);let Ce=0,ye=0;for(const Ne of he)try{await vn(`${l}/artifacts/${p}/${encodeURIComponent(Ne)}`,{method:"DELETE"}),Ce++}catch(Be){console.error(Be),ye++}Ce>0&&it(`${Ce} files(s) deleted.`,"success"),ye>0&&m({title:"File Deletion Failed",error:`${ye} file(s) failed to delete.`}),se(),ae(new Set),ce(!1)},[ue,it,se,l,p,m]),wt=d.useCallback(async he=>{if(M.current.has(he))return null;M.current.add(he),Ae!==he&&(Nt(null),ct(null),Wt(null));try{let Ce;if(p&&p.trim()&&p!=="null"&&p!=="undefined")Ce=`${l}/artifacts/${p}/${encodeURIComponent(he)}/versions`;else if(c!=null&&c.id)Ce=`${l}/artifacts/null/${encodeURIComponent(he)}/versions?project_id=${c.id}`;else throw new Error("No valid context for artifact preview");const ye=await _n(Ce);if(!ye||ye.length===0)throw new Error("No versions available");Nt(ye.sort((yn,Bt)=>yn-Bt));const Ne=Math.max(...ye);ct(Ne);let Be;if(p&&p.trim()&&p!=="null"&&p!=="undefined")Be=`${l}/artifacts/${p}/${encodeURIComponent(he)}/versions/${Ne}`;else if(c!=null&&c.id)Be=`${l}/artifacts/null/${encodeURIComponent(he)}/versions/${Ne}?project_id=${c.id}`;else throw new Error("No valid context for artifact content");const Ee=await vn(Be),Je=(Ee.headers.get("Content-Type")||"application/octet-stream").split(";")[0].trim(),Ge=await Ee.blob(),St=await new Promise((yn,Bt)=>{const lt=new FileReader;lt.onloadend=()=>{var st;return yn(((st=lt.result)==null?void 0:st.toString().split(",")[1])||"")},lt.onerror=Bt,lt.readAsDataURL(Ge)}),ut=ne.find(yn=>yn.filename===he),un={name:he,mime_type:Je,content:St,last_modified:(ut==null?void 0:ut.last_modified)||new Date().toISOString()};return Wt(un),un}catch(Ce){return m({title:"Artifact Preview Failed",error:Yt(Ce,"Failed to load artifact preview.")}),null}finally{M.current.delete(he)}},[l,p,c==null?void 0:c.id,ne,Ae,m]),Ot=d.useCallback(async(he,Ce)=>{if(!Pt||Pt.length===0)return null;if(!Pt.includes(Ce))return console.warn(`Requested version ${Ce} not available for ${he}`),null;Wt(null);try{let ye;if(p&&p.trim()&&p!=="null"&&p!=="undefined")ye=`${l}/artifacts/${p}/${encodeURIComponent(he)}/versions/${Ce}`;else if(c!=null&&c.id)ye=`${l}/artifacts/null/${encodeURIComponent(he)}/versions/${Ce}?project_id=${c.id}`;else throw new Error("No valid context for artifact navigation");const Ne=await vn(ye),Ee=(Ne.headers.get("Content-Type")||"application/octet-stream").split(";")[0].trim(),Re=await Ne.blob(),Je=await new Promise((ut,un)=>{const yn=new FileReader;yn.onloadend=()=>{var Bt;return ut(((Bt=yn.result)==null?void 0:Bt.toString().split(",")[1])||"")},yn.onerror=un,yn.readAsDataURL(Re)}),Ge=ne.find(ut=>ut.filename===he),St={name:he,mime_type:Ee,content:Je,last_modified:(Ge==null?void 0:Ge.last_modified)||new Date().toISOString()};return ct(Ce),Wt(St),St}catch(ye){return m({title:"Artifact Version Preview Failed",error:Yt(ye,"Failed to fetch artifact version.")}),null}},[l,ne,Pt,p,c==null?void 0:c.id,m]),Ct=d.useCallback(he=>{oe(!1),Z(he),typeof window<"u"&&window.dispatchEvent(new CustomEvent("expand-side-panel",{detail:{tab:he}}))},[]),Tt=d.useCallback(()=>{I.current&&(clearTimeout(I.current),I.current=null),j.current&&(j.current.close(),j.current=null),J.current=!1},[]),pn=d.useCallback(async he=>{if(y.current.has(he))return console.log(`[ChatProvider] Skipping duplicate download for ${he} - already in progress`),null;y.current.add(he);try{const Ce=ne.find(Ge=>Ge.filename===he);if(!Ce)return console.error(`Artifact ${he} not found in state`),null;const ye=await _n(`${l}/artifacts/${p}/${encodeURIComponent(he)}/versions`);if(!ye||ye.length===0)throw new Error("No versions available");const Ne=Math.max(...ye),Ee=await(await vn(`${l}/artifacts/${p}/${encodeURIComponent(he)}/versions/${Ne}`)).blob(),Re=await new Promise((Ge,St)=>{const ut=new FileReader;ut.onloadend=()=>{var un;return Ge(((un=ut.result)==null?void 0:un.toString().split(",")[1])||"")},ut.onerror=St,ut.readAsDataURL(Ee)}),Je={name:he,mime_type:Ce.mime_type||"application/octet-stream",content:Re,last_modified:Ce.last_modified||new Date().toISOString()};return me(Ge=>Ge.map(St=>St.filename===he?{...St,accumulatedContent:void 0,needsEmbedResolution:!1}:St)),Je}catch(Ce){return m({title:"File Download Failed",error:Yt(Ce,`Failed to download ${he}.`)}),null}finally{y.current.delete(he)}},[l,p,ne,me,m]),Qe=d.useCallback(he=>{var St,ut,un,yn;D.current+=1;const Ce=D.current;let ye;try{ye=JSON.parse(he.data)}catch(Bt){console.error("Failed to parse SSE message:",Bt);return}if("result"in ye&&ye.result){const Bt=ye.result,lt=Bt.kind==="task"?Bt.id:Bt.kind==="status-update"?Bt.taskId:void 0;lt&&ee(lt)&&Dn(lt,Date.now())}if("error"in ye&&ye.error){const lt=`Error: ${ye.error.message}`;w(st=>{const ot=st.filter(ht=>!ht.isStatusBubble);return ot.push({role:"agent",parts:[{kind:"text",text:lt}],isUser:!1,isError:!0,isComplete:!0,metadata:{messageId:`msg-${Zr()}`,lastProcessedEventSequence:Ce}}),ot}),b(!1),Tt(),_(null);return}if(!("result"in ye)||!ye.result){console.warn("Received SSE message without a result or error field.",ye);return}const Ne=ye.result;let Be=!1,Ee,Re;switch(Ne.kind){case"task":Be=!0,Ee=void 0,Re=Ne.id;break;case"status-update":Be=Ne.final,Ee=(St=Ne.status)==null?void 0:St.message,Re=Ne.taskId;break;case"artifact-update":se();return;default:console.warn("Received unknown result kind in SSE message:",Ne);return}if(Ee!=null&&Ee.parts){const Bt=Ee.parts.filter(lt=>lt.kind==="data");if(Bt.length>0)for(const lt of Bt){const st=lt.data;if(st&&typeof st=="object"&&"type"in st)switch(st.type){case"agent_progress_update":{if(L.current=String((st==null?void 0:st.status_text)??"Processing..."),Ee.parts.filter(ht=>ht.kind!=="data").length===0)return;break}case"artifact_creation_progress":{const{filename:ot,status:ht,bytes_transferred:dt,mime_type:Qt,description:mn,artifact_chunk:Zt,version:qt}=st;let zt=!1;me(Vt=>{const nn=Vt.findIndex(ar=>ar.filename===ot);if(nn>=0){const ar=[...Vt],Xt=ar[nn],Un=Xt.isDisplayed||!1;return ht==="completed"&&Un&&(zt=!0),ar[nn]={...Xt,description:mn!==void 0?mn:Xt.description,size:dt||Xt.size,last_modified:new Date().toISOString(),uri:Xt.uri||`artifact://${p}/${ot}`,accumulatedContent:ht==="in-progress"&&Zt?(Xt.accumulatedContent||"")+Zt:ht==="completed"&&!Un?void 0:Xt.accumulatedContent,isAccumulatedContentPlainText:ht==="in-progress"&&Zt?!0:Xt.isAccumulatedContentPlainText,mime_type:ht==="completed"&&Qt?Qt:Xt.mime_type,needsEmbedResolution:ht==="completed"?!0:Xt.needsEmbedResolution},ar}else if(mn!==void 0||ht==="in-progress")return[...Vt,{filename:ot,description:mn||null,mime_type:Qt||"application/octet-stream",size:dt||0,last_modified:new Date().toISOString(),uri:`artifact://${p}/${ot}`,accumulatedContent:ht==="in-progress"&&Zt?Zt:void 0,isAccumulatedContentPlainText:!!(ht==="in-progress"&&Zt),needsEmbedResolution:ht==="completed"}];return Vt}),zt&&setTimeout(()=>{pn(ot).catch(Vt=>{console.error(`Auto-download failed for ${ot}:`,Vt)})},100),w(Vt=>{const nn=[...Vt];let ar=nn.findLastIndex(Cn=>!Cn.isUser&&Cn.taskId===Re);if(ar===-1){const Cn={role:"agent",parts:[],taskId:Re,isUser:!1,isComplete:!1,isStatusBubble:!1,metadata:{lastProcessedEventSequence:Ce}};nn.push(Cn),ar=nn.length-1}const Xt={...nn[ar],parts:[...nn[ar].parts]};Xt.isStatusBubble=!1;const Un=Xt.parts.findIndex(Cn=>Cn.kind==="artifact"&&Cn.name===ot);if(ht==="in-progress")if(Un>-1){const ys={...Xt.parts[Un],bytesTransferred:dt,status:"in-progress"};Xt.parts[Un]=ys}else{const Cn={kind:"artifact",status:"in-progress",name:ot,bytesTransferred:dt};Xt.parts.push(Cn)}else if(ht==="completed"){const Cn={name:ot,mime_type:Qt,uri:qt!==void 0?`artifact://${p}/${ot}?version=${qt}`:`artifact://${p}/${ot}`};if(Un>-1){const ga={...Xt.parts[Un],status:"completed",file:Cn};delete ga.bytesTransferred,Xt.parts[Un]=ga}else Xt.parts.push({kind:"artifact",status:"completed",name:ot,file:Cn});se()}else{const Cn=`Failed to create artifact: ${ot}`;if(Un>-1){const ga={...Xt.parts[Un],status:"failed",error:Cn};delete ga.bytesTransferred,Xt.parts[Un]=ga}else Xt.parts.push({kind:"artifact",status:"failed",name:ot,error:Cn});Xt.isError=!0}return nn[ar]=Xt,nn.filter(Cn=>!Cn.isStatusBubble||Cn.parts.some(ys=>ys.kind==="artifact"||ys.kind==="file"))});return}case"tool_invocation_start":break;case"authentication_required":{const ot=st==null?void 0:st.auth_uri,ht=typeof(st==null?void 0:st.target_agent)=="string"?st.target_agent:"Agent",dt=typeof(st==null?void 0:st.gateway_task_id)=="string"?st.gateway_task_id:void 0;if(typeof ot=="string"&&ot.startsWith("http")){const Qt={role:"agent",parts:[{kind:"text",text:""}],authenticationLink:{url:ot,text:"Click to Authenticate",targetAgent:ht,gatewayTaskId:dt},isUser:!1,isComplete:!0,metadata:{messageId:`auth-${Zr()}`}};w(mn=>[...mn,Qt])}break}default:console.warn("Received unknown data part type:",st.type)}else if(((ut=lt.metadata)==null?void 0:ut.tool_name)==="_notify_artifact_save"){const ot=st;ot.status==="success"&&w(ht=>ht.map(dt=>dt.isUser||!dt.parts.some(Qt=>Qt.kind==="artifact"&&Qt.name===ot.filename)?dt:{...dt,parts:dt.parts.map(Qt=>{if(Qt.kind==="artifact"&&Qt.name===ot.filename){const mn={name:ot.filename,uri:`artifact://${p}/${ot.filename}`};return{kind:"artifact",status:"completed",name:ot.filename,file:mn}}return Qt})}))}}}const Je=((un=Ee==null?void 0:Ee.parts)==null?void 0:un.filter(Bt=>Bt.kind!=="data"))||[],Ge=Je.some(Bt=>Bt.kind==="file");if(w(Bt=>{var ot;const lt=[...Bt];let st=lt[lt.length-1];if(st!=null&&st.isStatusBubble&&(lt.pop(),st=lt[lt.length-1]),st&&!st.isUser&&st.taskId===Ne.taskId&&Je.length>0){const ht={...st,parts:[...st.parts,...Je],isComplete:Be||Ge,metadata:{...st.metadata,lastProcessedEventSequence:Ce}};lt[lt.length-1]=ht}else if(Je.some(dt=>dt.kind==="text"&&dt.text.trim()||dt.kind==="file")){const dt={role:"agent",parts:Je,taskId:Ne.taskId,isUser:!1,isComplete:Be||Ge,metadata:{messageId:((ot=ye.id)==null?void 0:ot.toString())||`msg-${Zr()}`,sessionId:Ne.contextId,lastProcessedEventSequence:Ce}};lt.push(dt)}if(Be){L.current=null;for(let dt=lt.length-1;dt>=0;dt--){const Qt=lt[dt];if(Qt.taskId===Re&&Qt.parts.some(mn=>mn.kind==="artifact"&&mn.status==="in-progress")){const mn=Qt.parts.map(Zt=>Zt.kind==="artifact"&&Zt.status==="in-progress"?{...Zt,status:"failed",error:`Artifact creation for "${Zt.name}" did not complete.`}:Zt);lt[dt]={...Qt,parts:mn,isError:!0,isComplete:!0}}}const ht=lt.findLastIndex(dt=>!dt.isUser&&dt.taskId===Re);ht!==-1&&(lt[ht]={...lt[ht],isComplete:!0,metadata:{...lt[ht].metadata,lastProcessedEventSequence:Ce}})}return lt}),Be){if(T.current&&(it("Task cancelled.","success"),I.current&&clearTimeout(I.current),B(!1)),Re)if(ee(Re))hn(Re),typeof window<"u"&&window.dispatchEvent(new CustomEvent("new-chat-session"));else{const lt=G.current.filter(st=>st.taskId===Re&&!st.isStatusBubble);if(lt.length>0){const st=lt.map(fe),ot=lt.find(Zt=>Zt.isUser),ht=((yn=ot==null?void 0:ot.parts)==null?void 0:yn.filter(Zt=>Zt.kind==="text").map(Zt=>Zt.text).join(""))||"",Qt=lt.some(Zt=>Zt.isError)?"error":"completed",mn=Ne.contextId||p;be({task_id:Re,user_message:ht,message_bubbles:st,task_metadata:{schema_version:rl,status:Qt,agent_name:A}},mn).then(Zt=>{Zt&&typeof window<"u"&&window.dispatchEvent(new CustomEvent("new-chat-session"))}).catch(Zt=>{console.error(`[ChatProvider] Error saving task ${Re}:`,Zt)})}}w(Bt=>Bt.map(lt=>lt.isUser||!lt.parts.some(ot=>ot.kind==="artifact"&&ot.status==="in-progress")?lt:{...lt,parts:lt.parts.map(ot=>{var ht;if(ot.kind==="artifact"&&ot.status==="in-progress"){const dt=ot,Qt={name:dt.name,mime_type:(ht=dt.file)==null?void 0:ht.mime_type,uri:`artifact://${p}/${dt.name}`};return{kind:"artifact",status:"completed",name:dt.name,file:Qt}}return ot})})),b(!1),Tt(),_(null),J.current=!0,se(),setTimeout(()=>{J.current=!1},100)}},[it,Tt,se,p,A,be,fe,pn,me,ee,Dn,hn]),Lt=d.useCallback(async(he=!1)=>{const Ce="ChatProvider.handleNewSession:";if(Tt(),v&&E&&A&&!O&&!ee(E))try{const Ne={jsonrpc:"2.0",id:`req-${Zr()}`,method:"tasks/cancel",params:{id:E}};pt(`${l}/tasks/${E}:cancel`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Ne),credentials:"include"})}catch(Ne){console.warn(`${Ce} Failed to cancel current task:`,Ne)}I.current&&(clearTimeout(I.current),I.current=null),B(!1),x(""),Se(null),c&&!he?u(null):c&&he&&console.log(`${Ce} Preserving project context: ${c.name}`),P(""),w([]),b(!1),_(null),F(null),ge(null),J.current=!1,L.current=null,D.current=0,typeof window<"u"&&window.dispatchEvent(new CustomEvent("focus-chat-input"))},[l,v,E,A,O,Tt,c,u,ge,ee]),or=d.useCallback(he=>{Ue(he),Lt()},[Lt]),gr=d.useCallback(()=>{Ue(null)},[]),xt=d.useCallback(async he=>{const Ce="ChatProvider.handleSwitchSession:";console.log(`${Ce} Switching to session ${he}...`),yt(!0);const ye=We.filter(Ee=>Ee.sessionId===p),Ne=ye.some(Ee=>Ee.taskId===E),Be=ye.length>0;if(!Ne&&!Be&&w([]),Tt(),v&&E&&A&&!O&&!ee(E))try{const Re={jsonrpc:"2.0",id:`req-${Zr()}`,method:"tasks/cancel",params:{id:E}};await pt(`${l}/tasks/${E}:cancel`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Re),credentials:"include"})}catch(Re){console.warn(`${Ce} Failed to cancel current task:`,Re)}I.current&&(clearTimeout(I.current),I.current=null),B(!1);try{const Ee=await _n(`${l}/sessions/${he}`),Re=Ee==null?void 0:Ee.data;if(Se((Re==null?void 0:Re.name)??"N/A"),Vc.current=!0,Re!=null&&Re.projectId)if(console.log(`${Ce} Session belongs to project ${Re.projectId}`),(c==null?void 0:c.id)!==Re.projectId){const Ge=f.find(St=>St.id===(Re==null?void 0:Re.projectId));Ge?(console.log(`${Ce} Activating project context: ${Ge.name}`),u(Ge)):console.warn(`${Ce} Project ${Re.projectId} not found in projects array`)}else console.log(`${Ce} Already in correct project context`);else c!==null&&(console.log(`${Ce} Session has no project, deactivating project context`),u(null));x(he),b(!1),_(null),F(null),ge(null),J.current=!1,L.current=null,D.current=0,await Le(he);const Je=We.filter(Ge=>Ge.sessionId===he);if(Je.length>0)for(const Ge of Je){const St=await le(Ge.taskId);if(St&&St.is_running){console.log(`[ChatProvider] Reconnecting to running background task ${Ge.taskId}`),_(Ge.taskId),b(!0),Ge.agentName&&P(Ge.agentName);break}else console.log(`[ChatProvider] Background task ${Ge.taskId} is not running, unregistering`),hn(Ge.taskId)}}catch(Ee){m({title:"Switching Chats Failed",error:Yt(Ee,"Failed to switch chat sessions.")})}finally{yt(!1)}},[Tt,v,E,A,O,l,Le,c,f,u,ge,m,ee,We,le,hn]),zn=d.useCallback(async(he,Ce)=>{try{const ye=await pt(`${l}/sessions/${he}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:Ce})});if(ye.status===422)throw new Error("Invalid name");if(!ye.ok)throw new Error(await ye.json().then(Ne=>Ne.message).catch(()=>"Failed to update session name"));Se(Ce),typeof window<"u"&&window.dispatchEvent(new CustomEvent("new-chat-session"))}catch(ye){m({title:"Session Name Update Failed",error:Yt(ye,"Failed to update session name.")})}},[l,m]),kr=d.useCallback(async he=>{try{await vn(`${l}/sessions/${he}`,{method:"DELETE"}),it("Session deleted.","success"),he===p&&Lt(),typeof window<"u"&&window.dispatchEvent(new CustomEvent("new-chat-session"))}catch(Ce){m({title:"Chat Deletion Failed",error:Yt(Ce,"Failed to delete session.")})}},[l,it,Lt,p,m]),sr=d.useCallback(he=>{Pe(Ce=>{const ye=new Set(Ce.expandedArtifacts);return ye.has(he)?ye.delete(he):ye.add(he),{...Ce,expandedArtifacts:ye}})},[]),kh=d.useCallback(he=>ve.expandedArtifacts.has(he),[ve.expandedArtifacts]),Si=d.useCallback((he,Ce)=>{me(ye=>ye.map(Ne=>Ne.filename===he?{...Ne,isDisplayed:Ce}:Ne))},[]),Yo=d.useCallback(he=>{De(he)},[]),_i=d.useCallback(()=>{De(null)},[]),ki=d.useCallback(async()=>{je&&(await kr(je.id),De(null))},[je,kr]),Ei=d.useCallback(async()=>{if(!(!v&&!O||!E)&&!O){B(!0);try{const he={jsonrpc:"2.0",id:`req-${Zr()}`,method:"tasks/cancel",params:{id:E}},Ce=await pt(`${l}/tasks/${E}:cancel`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(he)});if(Ce.status===202)I.current&&clearTimeout(I.current),I.current=setTimeout(()=>{it("Cancellation timed out. Allowing new input."),B(!1),b(!1),Tt(),_(null),I.current=null,w(ye=>ye.filter(Ne=>!Ne.isStatusBubble))},15e3);else{const ye=await Ce.json().catch(()=>({message:"Unknown cancellation error"}));throw new Error(ye.message||`HTTP error ${Ce.status}`)}}catch(he){m({title:"Task Cancellation Failed",error:Yt(he,"An unknown error occurred.")}),B(!1)}}},[v,O,E,l,it,m,Tt]),ji=d.useCallback(async(he,Ce,ye)=>{if(!p){console.error("Cannot submit feedback without a session ID.");return}try{await G_({taskId:he,sessionId:p,feedbackType:Ce,feedbackText:ye}),Oe(Ne=>({...Ne,[he]:{type:Ce,text:ye}}))}catch(Ne){throw console.error("Failed to submit feedback:",Ne),Ne}},[p]),Uc=d.useCallback(()=>{},[]),Bc=d.useCallback(()=>{v&&!J.current&&!T.current&&m({title:"Connection Failed",error:"Connection lost. Please try again."}),J.current||(b(!1),T.current||(Tt(),_(null)),L.current=null),w(he=>he.filter(Ce=>!Ce.isStatusBubble).map((Ce,ye,Ne)=>ye===Ne.length-1&&!Ce.isUser?{...Ce,isComplete:!0}:Ce))},[Tt,v,m]),Eh=d.useCallback(async he=>{if(he.length!==0)for(const{filename:Ce,sessionId:ye}of he)try{const Ne=`${l}/artifacts/${ye}/${encodeURIComponent(Ce)}`;await vn(Ne,{method:"DELETE"})}catch(Ne){console.error(`[cleanupUploadedFiles] Exception while cleaning up file ${Ce}:`,Ne)}},[l]),$1=d.useCallback(async(he,Ce,ye,Ne)=>{he.preventDefault();const Be=(ye==null?void 0:ye.trim())||"",Ee=Ce||[];if(!Be&&Ee.length===0||v||O||!A)return;Tt(),J.current=!1,b(!0),_(null),L.current=null,D.current=0;const Re={role:"user",parts:[{kind:"text",text:Be}],isUser:!0,uploadedFiles:Ee.length>0?Ee:void 0,metadata:{messageId:`msg-${Zr()}`,sessionId:Ne||p,lastProcessedEventSequence:0}};L.current="Thinking",w(Je=>[...Je,Re]);try{const Je=[],Ge=[];let St=Ne||p;console.log(`[handleSubmit] Processing ${Ee.length} file(s)`);for(const qt of Ee){if(qt.type==="application/x-artifact-reference")try{const zt=await qt.text(),Vt=JSON.parse(zt);if(Vt.isArtifactReference&&Vt.uri){console.log(`[handleSubmit] Adding artifact reference: ${Vt.filename} (${Vt.uri})`),Je.push({kind:"file",file:{uri:Vt.uri,name:Vt.filename,mimeType:Vt.mimeType||"application/octet-stream"}});continue}}catch(zt){console.error("[handleSubmit] Error processing artifact reference:",zt)}if(qt.size<JF){const zt=await QF(qt);Je.push({kind:"file",file:{bytes:zt,name:qt.name,mimeType:qt.type}})}else{const zt=await Ve(qt,St);if(zt&&"uri"in zt&&zt.uri&&zt.sessionId)St||(St=zt.sessionId),Ge.push({filename:qt.name,sessionId:zt.sessionId}),Je.push({kind:"file",file:{uri:zt.uri,name:qt.name,mimeType:qt.type}});else{console.error(`[handleSubmit] File upload failed for "${qt.name}". Result:`,zt),await Eh(Ge);const Vt=Ge.length>0?" Previously uploaded files have been cleaned up.":"",nn=zt&&"error"in zt?` (${zt.error})`:"";m({title:"File Upload Failed",error:`Message not sent. File upload failed for "${qt.name}"${nn}.${Vt}.`}),b(!1),w(ar=>ar.filter(Xt=>{var Un,Hc;return((Un=Xt.metadata)==null?void 0:Un.messageId)!==((Hc=Re.metadata)==null?void 0:Hc.messageId)}));return}}}const ut=[];if(Be&&ut.push({kind:"text",text:Be}),ut.push(...Je),ut.length===0)return;console.log(`ChatProvider handleSubmit: Using effectiveSessionId for contextId: ${St}`);const un=a??!1;console.log(`[ChatProvider] Building metadata for ${A}, enableBackground=${un}`);const yn={agent_name:A};c!=null&&c.id&&(yn.project_id=c.id),un&&(yn.background_execution=!0,yn.max_execution_time_ms=i??36e5,console.log(`[ChatProvider] Enabling background execution for ${A}`),console.log("[ChatProvider] Metadata object:",yn));const Bt={role:"user",parts:ut,messageId:`msg-${Zr()}`,kind:"message",contextId:St,metadata:yn};console.log("[ChatProvider] A2A message metadata:",Bt.metadata);const lt={jsonrpc:"2.0",id:`req-${Zr()}`,method:"message/stream",params:{message:Bt}};console.log("ChatProvider handleSubmit: Sending POST to /message:stream");const st=await _n(`${l}/message:stream`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(lt)}),ot=st==null?void 0:st.result,ht=ot==null?void 0:ot.id,dt=ot==null?void 0:ot.contextId;if(console.log(`ChatProvider handleSubmit: Extracted responseSessionId: ${dt}, current sessionId: ${p}`),console.log("ChatProvider handleSubmit: Full result object:",st),!ht)throw console.error("ChatProvider handleSubmit: Backend did not return a valid taskId. Result:",st),new Error("Backend did not return a valid taskId.");console.log(`ChatProvider handleSubmit: Checking session update condition - responseSessionId: ${dt}, sessionId: ${p}, different: ${dt!==p}`);const Qt=!p||p==="",mn=dt||p;if(dt&&dt!==p){if(console.log(`ChatProvider handleSubmit: Updating sessionId from ${p} to ${dt}`),x(dt),w(qt=>qt.map(zt=>{var Vt,nn;return((Vt=zt.metadata)==null?void 0:Vt.messageId)===((nn=Re.metadata)==null?void 0:nn.messageId)?{...zt,metadata:{...zt.metadata,sessionId:dt}}:zt})),Qt){let qt="New Chat";const Vt=Re.parts.filter(nn=>nn.kind==="text").map(nn=>nn.text).join(" ").trim();Vt?qt=Vt.length>100?`${Vt.substring(0,100)}...`:Vt:Ee.length>0&&(Ee.length===1?qt=Ee[0].name:qt=`${Ee[0].name} +${Ee.length-1} more`),qt&&(Se(qt),await zn(dt,qt))}Qt&&typeof window<"u"&&window.dispatchEvent(new CustomEvent("new-chat-session"))}const Zt=a??!1;mn&&await be({task_id:ht,user_message:Be,message_bubbles:[fe(Re)],task_metadata:{schema_version:rl,status:"pending",agent_name:A,is_background_task:Zt}},mn),console.log(`ChatProvider handleSubmit: Received taskId ${ht}. Setting currentTaskId and taskIdInSidePanel.`),_(ht),F(ht),Zt&&(console.log(`[ChatProvider] Registering ${ht} as background task`),Et(ht,mn,A),typeof window<"u"&&window.dispatchEvent(new CustomEvent("new-chat-session"))),w(qt=>qt.map(zt=>{var Vt,nn;return((Vt=zt.metadata)==null?void 0:Vt.messageId)===((nn=Re.metadata)==null?void 0:nn.messageId)?{...zt,taskId:ht}:zt}))}catch(Je){m({title:"Message Failed",error:Yt(Je,"An error occurred. Please try again.")}),b(!1),w(Ge=>Ge.filter(St=>!St.isStatusBubble)),_(null),J.current=!1,L.current=null}},[p,v,O,A,Tt,l,Ve,zn,be,fe,c,Eh,m,Et,a,i]),jh=d.useRef(""),Vc=d.useRef(!1),Wc=d.useRef(!1);d.useEffect(()=>{yT(Ce=>{(c==null?void 0:c.id)===Ce&&(console.log(`Project ${Ce} was deleted, clearing session context`),Lt(!1))})},[c,Lt]),d.useEffect(()=>{const he=async Ce=>{const ye=Ce,{sessionId:Ne,projectId:Be}=ye.detail;if(Ne===p)if(Wc.current=!0,Be){const Ee=f.find(Re=>Re.id===Be);Ee&&u(Ee)}else u(null)};return window.addEventListener("session-moved",he),()=>{window.removeEventListener("session-moved",he)}},[p,f,u]),d.useEffect(()=>{const he=async Ce=>{const ye=Ce,{taskId:Ne}=ye.detail,Be=W.current.find(Ee=>Ee.taskId===Ne);Be&&(console.log(`[ChatProvider] Background task ${Ne} completed, will reload session ${Be.sessionId} after delay`),setTimeout(async()=>{R.current===Be.sessionId&&(console.log(`[ChatProvider] Reloading current session ${Be.sessionId} to get latest data`),await Le(Be.sessionId))},1500))};return window.addEventListener("background-task-completed",he),()=>{window.removeEventListener("background-task-completed",he)}},[Le]),d.useEffect(()=>{const he=jh.current,Ce=c==null?void 0:c.id;Ce!==void 0&&he!==Ce&&!Vc.current&&!Wc.current&&(console.log("Active project changed explicitly, resetting chat view and preserving project context."),Lt(!0)),jh.current=Ce,Vc.current=!1,Wc.current=!1},[c,Lt]),d.useEffect(()=>{if(!A&&V.length>0&&g.length===0&&!Ze){let he=V[0];const ye=new URLSearchParams(window.location.search).get("agent");let Ne;if(ye&&(Ne=V.find(Ee=>Ee.name===ye),Ne?(he=Ne,console.log(`Using URL parameter agent: ${he.name}`)):console.warn(`URL parameter agent "${ye}" not found in available agents, falling back to priority order`)),!Ne)if(c!=null&&c.defaultAgentId){const Ee=V.find(Re=>Re.name===c.defaultAgentId);Ee?(he=Ee,console.log(`Using project default agent: ${he.name}`)):(console.warn(`Project default agent "${c.defaultAgentId}" not found, falling back to OrchestratorAgent`),he=V.find(Re=>Re.name==="OrchestratorAgent")??V[0])}else he=V.find(Ee=>Ee.name==="OrchestratorAgent")??V[0];P(he.name);const Be=t||`Hi! I'm the ${he==null?void 0:he.displayName}. How can I help?`;w([{parts:[{kind:"text",text:Be}],isUser:!1,isComplete:!0,role:"agent",metadata:{sessionId:"",lastProcessedEventSequence:0}}])}},[V,t,g.length,A,p,Ze,c]);const Nh=d.useRef(Qe),Th=d.useRef(Uc),Ah=d.useRef(Bc);d.useEffect(()=>{Nh.current=Qe,Th.current=Uc,Ah.current=Bc},[Qe,Uc,Bc]),d.useEffect(()=>{if(E&&l){const he=nf(),ye=W.current.find(St=>St.taskId===E)!==void 0;let Ne=`${l}/sse/subscribe/${E}`;const Be=new URLSearchParams;he&&Be.append("token",he),ye&&(Be.append("reconnect","true"),Be.append("last_event_timestamp","0"),console.log(`[ChatProvider] Reconnecting to background task ${E} - requesting full event replay`),w(St=>St.filter(un=>!!(un.isUser||un.taskId!==E)))),Be.toString()&&(Ne+=`?${Be.toString()}`);const Ee=new EventSource(Ne,{withCredentials:!0});j.current=Ee;const Re=()=>{Th.current()},Je=()=>{Ah.current()},Ge=St=>{Nh.current(St)};return Ee.onopen=Re,Ee.onerror=Je,Ee.addEventListener("status_update",Ge),Ee.addEventListener("artifact_update",Ge),Ee.addEventListener("final_response",Ge),Ee.addEventListener("error",Ge),()=>{Ee.removeEventListener("status_update",Ge),Ee.removeEventListener("artifact_update",Ge),Ee.removeEventListener("final_response",Ge),Ee.removeEventListener("error",Ge),Ee.close()}}else Tt()},[E,l,Tt]);const z1={configCollectFeedback:o,submittedFeedback:Me,handleFeedbackSubmit:ji,sessionId:p,setSessionId:x,sessionName:Xe,setSessionName:Se,messages:g,setMessages:w,isResponding:v,currentTaskId:E,isCancelling:O,latestStatusText:L,isLoadingSession:Ze,agents:V,agentsLoading:K,agentsError:X,agentsRefetch:q,agentNameDisplayNameMap:Q,handleNewSession:Lt,handleSwitchSession:xt,handleSubmit:$1,handleCancel:Ei,notifications:C,addNotification:it,selectedAgentName:A,setSelectedAgentName:P,artifacts:ne,artifactsLoading:de,artifactsRefetch:se,setArtifacts:me,uploadArtifactFile:Ve,isSidePanelCollapsed:k,activeSidePanelTab:ie,setIsSidePanelCollapsed:oe,setActiveSidePanelTab:Z,openSidePanelTab:Ct,taskIdInSidePanel:z,setTaskIdInSidePanel:F,isDeleteModalOpen:U,artifactToDelete:$,openDeleteModal:ke,closeDeleteModal:te,confirmDelete:Ie,openSessionDeleteModal:Yo,closeSessionDeleteModal:_i,confirmSessionDelete:ki,sessionToDelete:je,isArtifactEditMode:H,setIsArtifactEditMode:ce,selectedArtifactFilenames:ue,setSelectedArtifactFilenames:ae,handleDeleteSelectedArtifacts:$e,confirmBatchDeleteArtifacts:nt,isBatchDeleteModalOpen:pe,setIsBatchDeleteModalOpen:Te,previewedArtifactAvailableVersions:Pt,currentPreviewedVersionNumber:Mt,previewFileContent:$t,openArtifactForPreview:wt,navigateArtifactVersion:Ot,previewArtifact:Dt,setPreviewArtifact:ge,updateSessionName:zn,deleteSession:kr,toggleArtifactExpanded:sr,isArtifactExpanded:kh,setArtifactRenderingState:Pe,artifactRenderingState:ve,markArtifactAsDisplayed:Si,downloadAndResolveArtifact:pn,displayError:m,pendingPrompt:at,startNewChatWithPrompt:or,clearPendingPrompt:gr,backgroundTasks:We,backgroundNotifications:ft,isTaskRunningInBackground:ee};return s.jsxs(jw.Provider,{value:z1,children:[e,s.jsx(h,{})]})},t9=({children:e})=>{const{frontend_use_authorization:t,configAuthLoginUrl:n}=Ut(),{fetchCsrfToken:r,clearCsrfToken:o}=$w(),[a,i]=d.useState(!1),[l,c]=d.useState(!0),[u,f]=d.useState(null);d.useEffect(()=>{let p=!0;const x=async()=>{if(!t){p&&(i(!0),c(!1));return}try{const w=await pt("/api/v1/users/me",{credentials:"include",headers:{Accept:"application/json"}});if(w.ok){const v=await w.json();console.log("User is authenticated:",v),p&&(f(v),i(!0)),console.log("Fetching CSRF token for authenticated requests..."),await r()}else w.status===401?(console.log("User is not authenticated"),p&&i(!1)):(console.error("Unexpected response from /users/me:",w.status),p&&i(!1))}catch(w){console.error("Error checking authentication:",w),p&&i(!1)}finally{p&&c(!1)}};x();const g=w=>{w.key==="access_token"&&x()};return window.addEventListener("storage",g),()=>{p=!1,window.removeEventListener("storage",g)}},[t,n,r]);const h=()=>{window.location.href=n},m=()=>{i(!1),f(null),o()};return l?s.jsx("div",{className:"flex min-h-screen items-center justify-center bg-white dark:bg-gray-900",children:s.jsxs("div",{className:"text-center",children:[s.jsx("div",{className:"border-solace-green mx-auto mb-4 h-12 w-12 animate-spin rounded-full border-b-2"}),s.jsx("h1",{className:"text-2xl text-black dark:text-white",children:"Checking Authentication..."})]})}):s.jsx(Ew.Provider,{value:{isAuthenticated:a,useAuthorization:t,login:h,logout:m,userInfo:u},children:e})};function n9(e){var r;if(typeof document>"u")return null;const n=`; ${document.cookie}`.split(`; ${e}=`);return n.length===2&&((r=n.pop())==null?void 0:r.split(";").shift())||null}const r9=e=>new Promise(t=>setTimeout(t,e)),o9=async(e=5,t=50)=>{try{const n=await pt("/api/v1/csrf-token",{credentials:"include"});if(!n.ok)throw new Error(`CSRF endpoint returned status ${n.status}`);const r=await n.json();if(r.csrf_token)return console.log("CSRF token found in response body:",r.csrf_token),r.csrf_token;for(let o=0;o<e;o++){const a=n9("csrf_token");if(a)return console.log(`CSRF token found in cookie after ${o} retries:`,a),a;console.log(`CSRF token not found in cookie, attempt ${o+1}/${e}. Waiting ${t}ms...`),await r9(t)}throw new Error("CSRF token not available in response or cookie after retries")}catch(n){return console.error("Error fetching/reading CSRF token:",n),null}};function s9({children:e}){const[t,n]=d.useState(null),r=d.useCallback(async()=>{if(t)return t;const i=await o9();if(i)n(i);else throw new Error("Failed to obtain CSRF token after config fetch failed.");return i},[t]),o=d.useCallback(()=>{n(null)},[]),a={fetchCsrfToken:r,clearCsrfToken:o};return s.jsx(Tw.Provider,{value:a,children:e})}const a9={brand:{wMain:"#00C895",w30:"#B3EFDF",wMain30:"#00C8954d",w10:"#E6FAF4",w60:"#66DEBF",w100:"#00AD93"},primary:{w100:"#01374E",w90:"#014968",wMain:"#015B82",w60:"#679DB4",w40:"#99BDCD",w20:"#CCDEE6",w10:"#E6EFF2",text:{wMain:"#273749",w100:"#000000",w10:"#CCCCCC"}},secondary:{w70:"#536574",w80:"#354E62",w8040:"#354E6240",w100:"#000000",wMain:"#8790A0",w40:"#CFD3D9",w20:"#E7E9EC",w10:"#F3F4F6",text:{wMain:"#647481",w50:"#B1B9C0"}},background:{w100:"#021B2F",wMain:"#03223B",w20:"#F7F8F9",w10:"#FFFFFF"},info:{w100:"#2B71B1",wMain:"#0591D3",w70:"#7CD3F6",w30:"#B4DEF2",w20:"#CDE9F6",w10:"#E6F4FB"},error:{w100:"#C33135",wMain:"#E94C4E",w70:"#ED9B9D",w30:"#F8C9CA",w20:"#FBDBDC",w10:"#FDEDED"},warning:{w100:"#E1681F",wMain:"#FF8E2B",w70:"#F8C785",w30:"#FFDDBF",w20:"#FFE8D5",w10:"#FFF4EA"},success:{w100:"#006B53",wMain:"#009A80",w70:"#6FCCBC",w30:"#B3E1D9",w20:"#CCEBE6",w10:"#E6F5F2"},stateLayer:{w10:"#03223B1a",w20:"#03223B33"},accent:{n0:{w100:"#2F51AD",wMain:"#3C69E1",w30:"#C5D2F6",w10:"#ECF0FC"},n1:{w100:"#1F284C",wMain:"#3A4880",w30:"#C4C8D9",w60:"#8991B3",w20:"#D8DAE6",w10:"#EBEDF2"},n2:{w100:"#165E64",wMain:"#009193",w30:"#B3DEDF",w20:"#CCE9E9",w10:"#E6F4F4"},n3:{w100:"#542D75",wMain:"#7841A8",w30:"#D7C6E5",w10:"#F2ECF6"},n4:{w100:"#951379",wMain:"#CB1AA5",w30:"#F2C4E8"},n5:{w100:"#D03C1B",wMain:"#F66651",w30:"#FCCEC7",w60:"#FAA397"},n6:{w100:"#DE7E00",wMain:"#FCA829",w30:"#FEE5BF"},n7:{w100:"#2DADE1",wMain:"#7CD3F6",w30:"#CBEDFB"},n8:{w100:"#4F5A63",wMain:"#86939E",w30:"#DBDFE2"},n9:{wMain:"#DA162D"}},learning:{wMain:"#033A6F",w90:"#022E59",w100:"#022343",w20:"#CDD8E2",w10:"#E6EBF1"}},i9={light:{background:"background.w10",foreground:"primary.text.wMain",card:"background.w10","card-foreground":"primary.text.wMain",popover:"background.w10","popover-foreground":"primary.text.wMain",primary:"primary.wMain","primary-foreground":"primary.text.w10",secondary:"secondary.w10","secondary-foreground":"secondary.text.wMain",muted:"secondary.w10","muted-foreground":"secondary.text.wMain",accent:"secondary.w40","accent-foreground":"secondary.text.wMain",destructive:"error.wMain",border:"secondary.w40",input:"secondary.w40",ring:"brand.wMain","ring-offset":"brand.wMain","accent-background":"background.w20","message-background":"secondary.w20","chart-1":"brand.w60","chart-2":"primary.wMain","chart-3":"accent.n3.wMain","chart-4":"accent.n6.wMain","chart-5":"accent.n5.wMain",sidebar:"background.w20","sidebar-foreground":"primary.text.wMain","sidebar-primary":"primary.wMain","sidebar-primary-foreground":"primary.text.w10","sidebar-accent":"secondary.w10","sidebar-accent-foreground":"secondary.text.wMain","sidebar-border":"secondary.w40","sidebar-ring":"brand.wMain"},dark:{background:"background.w100",foreground:"primary.text.w10",card:"background.wMain","card-foreground":"primary.text.w10",popover:"background.wMain","popover-foreground":"primary.text.w10",primary:"primary.w60","primary-foreground":"primary.text.wMain",secondary:"secondary.w80","secondary-foreground":"secondary.text.w50",muted:"secondary.w80","muted-foreground":"secondary.text.w50",accent:"secondary.w80","accent-foreground":"secondary.text.w50",destructive:"error.w70",border:"secondary.w70",input:"secondary.w70",ring:"brand.w60","ring-offset":"brand.w60","accent-background":"primary.w90","message-background":"secondary.w70","chart-1":"brand.w100","chart-2":"primary.wMain","chart-3":"accent.n3.w100","chart-4":"accent.n6.w30","chart-5":"accent.n5.w60",sidebar:"background.wMain","sidebar-foreground":"primary.text.w10","sidebar-primary":"primary.w60","sidebar-primary-foreground":"primary.text.wMain","sidebar-accent":"secondary.w80","sidebar-accent-foreground":"secondary.text.w50","sidebar-border":"secondary.w70","sidebar-ring":"brand.w60"}},l9={"error-text-wMain":"error.wMain","error-text-w50":"error.w70","warning-text-wMain":"warning.wMain","warning-text-w50":"warning.w70","success-text-wMain":"success.wMain","success-text-w50":"success.w70","info-text-wMain":"info.wMain","info-text-w50":"info.w70"};function Ag(e,t){const n=t.split(".");let r=e;for(const o of n)if(r&&typeof r=="object"&&o in r)r=r[o];else return console.warn(`Color path not found: ${t}`),"#000000";return typeof r=="string"?r:"#000000"}function c9(e,t){const n={},r=i9[t];for(const[o,a]of Object.entries(r)){const i=Ag(e,a);n[`--${o}`]=i}for(const[o,a]of Object.entries(l9)){const i=Ag(e,a);n[`--color-${o}`]=i}return n}const Wl="sam-theme";function u9(e){var n,r,o,a,i,l,c,u,f,h,m,p,x,g,w,v,b,C,S,E,_,j,A,P,O,B,N,M,y,T,R,z,F,I,J,L,D,W,G,V,Q,X,K,q,ne,de,se,me,k,oe,ie,Z,U,re,$,Y,H,ce,ue,ae,pe,Te,Ae,gt,Pt,Nt,Mt,ct,$t,Wt,Dt,ve,Pe,Me,Oe,at,Ue,it,We,ft,Et,hn,Dn,ee,le,fe,be,_e,Fe,He,Le,Ve,Xe,Se,je,De,Ze,yt,At,ke,te,ge,Ie;const t={};return e.brand.wMain&&(t["--color-brand-wMain"]=e.brand.wMain),e.brand.wMain30&&(t["--color-brand-wMain30"]=e.brand.wMain30),e.brand.w100&&(t["--color-brand-w100"]=e.brand.w100),e.brand.w60&&(t["--color-brand-w60"]=e.brand.w60),e.brand.w30&&(t["--color-brand-w30"]=e.brand.w30),e.brand.w10&&(t["--color-brand-w10"]=e.brand.w10),e.primary.wMain&&(t["--color-primary-wMain"]=e.primary.wMain),e.primary.w100&&(t["--color-primary-w100"]=e.primary.w100),e.primary.w90&&(t["--color-primary-w90"]=e.primary.w90),e.primary.w60&&(t["--color-primary-w60"]=e.primary.w60),e.primary.w40&&(t["--color-primary-w40"]=e.primary.w40),e.primary.w20&&(t["--color-primary-w20"]=e.primary.w20),e.primary.w10&&(t["--color-primary-w10"]=e.primary.w10),e.primary.text.wMain&&(t["--color-primary-text-wMain"]=e.primary.text.wMain),e.primary.text.w100&&(t["--color-primary-text-w100"]=e.primary.text.w100),e.primary.text.w10&&(t["--color-primary-text-w10"]=e.primary.text.w10),e.secondary.wMain&&(t["--color-secondary-wMain"]=e.secondary.wMain),e.secondary.w100&&(t["--color-secondary-w100"]=e.secondary.w100),e.secondary.w80&&(t["--color-secondary-w80"]=e.secondary.w80),e.secondary.w8040&&(t["--color-secondary-w8040"]=e.secondary.w8040),e.secondary.w70&&(t["--color-secondary-w70"]=e.secondary.w70),e.secondary.w40&&(t["--color-secondary-w40"]=e.secondary.w40),e.secondary.w20&&(t["--color-secondary-w20"]=e.secondary.w20),e.secondary.w10&&(t["--color-secondary-w10"]=e.secondary.w10),e.secondary.text.wMain&&(t["--color-secondary-text-wMain"]=e.secondary.text.wMain),e.secondary.text.w50&&(t["--color-secondary-text-w50"]=e.secondary.text.w50),e.background.wMain&&(t["--color-background-wMain"]=e.background.wMain),e.background.w100&&(t["--color-background-w100"]=e.background.w100),e.background.w20&&(t["--color-background-w20"]=e.background.w20),e.background.w10&&(t["--color-background-w10"]=e.background.w10),(n=e.info)!=null&&n.wMain&&(t["--color-info-wMain"]=e.info.wMain),(r=e.info)!=null&&r.w100&&(t["--color-info-w100"]=e.info.w100),(o=e.info)!=null&&o.w70&&(t["--color-info-w70"]=e.info.w70),(a=e.info)!=null&&a.w30&&(t["--color-info-w30"]=e.info.w30),(i=e.info)!=null&&i.w20&&(t["--color-info-w20"]=e.info.w20),(l=e.info)!=null&&l.w10&&(t["--color-info-w10"]=e.info.w10),(c=e.error)!=null&&c.wMain&&(t["--color-error-wMain"]=e.error.wMain),(u=e.error)!=null&&u.w100&&(t["--color-error-w100"]=e.error.w100),(f=e.error)!=null&&f.w70&&(t["--color-error-w70"]=e.error.w70),(h=e.error)!=null&&h.w30&&(t["--color-error-w30"]=e.error.w30),(m=e.error)!=null&&m.w20&&(t["--color-error-w20"]=e.error.w20),(p=e.error)!=null&&p.w10&&(t["--color-error-w10"]=e.error.w10),(x=e.warning)!=null&&x.wMain&&(t["--color-warning-wMain"]=e.warning.wMain),(g=e.warning)!=null&&g.w100&&(t["--color-warning-w100"]=e.warning.w100),(w=e.warning)!=null&&w.w70&&(t["--color-warning-w70"]=e.warning.w70),(v=e.warning)!=null&&v.w30&&(t["--color-warning-w30"]=e.warning.w30),(b=e.warning)!=null&&b.w20&&(t["--color-warning-w20"]=e.warning.w20),(C=e.warning)!=null&&C.w10&&(t["--color-warning-w10"]=e.warning.w10),(S=e.success)!=null&&S.wMain&&(t["--color-success-wMain"]=e.success.wMain),(E=e.success)!=null&&E.w100&&(t["--color-success-w100"]=e.success.w100),(_=e.success)!=null&&_.w70&&(t["--color-success-w70"]=e.success.w70),(j=e.success)!=null&&j.w30&&(t["--color-success-w30"]=e.success.w30),(A=e.success)!=null&&A.w20&&(t["--color-success-w20"]=e.success.w20),(P=e.success)!=null&&P.w10&&(t["--color-success-w10"]=e.success.w10),(O=e.stateLayer)!=null&&O.w10&&(t["--color-stateLayer-w10"]=e.stateLayer.w10),(B=e.stateLayer)!=null&&B.w20&&(t["--color-stateLayer-w20"]=e.stateLayer.w20),(M=(N=e.accent)==null?void 0:N.n0)!=null&&M.wMain&&(t["--color-accent-n0-wMain"]=e.accent.n0.wMain),(T=(y=e.accent)==null?void 0:y.n0)!=null&&T.w100&&(t["--color-accent-n0-w100"]=e.accent.n0.w100),(z=(R=e.accent)==null?void 0:R.n0)!=null&&z.w30&&(t["--color-accent-n0-w30"]=e.accent.n0.w30),(I=(F=e.accent)==null?void 0:F.n0)!=null&&I.w10&&(t["--color-accent-n0-w10"]=e.accent.n0.w10),(L=(J=e.accent)==null?void 0:J.n1)!=null&&L.wMain&&(t["--color-accent-n1-wMain"]=e.accent.n1.wMain),(W=(D=e.accent)==null?void 0:D.n1)!=null&&W.w100&&(t["--color-accent-n1-w100"]=e.accent.n1.w100),(V=(G=e.accent)==null?void 0:G.n1)!=null&&V.w60&&(t["--color-accent-n1-w60"]=e.accent.n1.w60),(X=(Q=e.accent)==null?void 0:Q.n1)!=null&&X.w30&&(t["--color-accent-n1-w30"]=e.accent.n1.w30),(q=(K=e.accent)==null?void 0:K.n1)!=null&&q.w20&&(t["--color-accent-n1-w20"]=e.accent.n1.w20),(de=(ne=e.accent)==null?void 0:ne.n1)!=null&&de.w10&&(t["--color-accent-n1-w10"]=e.accent.n1.w10),(me=(se=e.accent)==null?void 0:se.n2)!=null&&me.wMain&&(t["--color-accent-n2-wMain"]=e.accent.n2.wMain),(oe=(k=e.accent)==null?void 0:k.n2)!=null&&oe.w100&&(t["--color-accent-n2-w100"]=e.accent.n2.w100),(Z=(ie=e.accent)==null?void 0:ie.n2)!=null&&Z.w30&&(t["--color-accent-n2-w30"]=e.accent.n2.w30),(re=(U=e.accent)==null?void 0:U.n2)!=null&&re.w20&&(t["--color-accent-n2-w20"]=e.accent.n2.w20),(Y=($=e.accent)==null?void 0:$.n2)!=null&&Y.w10&&(t["--color-accent-n2-w10"]=e.accent.n2.w10),(ce=(H=e.accent)==null?void 0:H.n3)!=null&&ce.wMain&&(t["--color-accent-n3-wMain"]=e.accent.n3.wMain),(ae=(ue=e.accent)==null?void 0:ue.n3)!=null&&ae.w100&&(t["--color-accent-n3-w100"]=e.accent.n3.w100),(Te=(pe=e.accent)==null?void 0:pe.n3)!=null&&Te.w30&&(t["--color-accent-n3-w30"]=e.accent.n3.w30),(gt=(Ae=e.accent)==null?void 0:Ae.n3)!=null&&gt.w10&&(t["--color-accent-n3-w10"]=e.accent.n3.w10),(Nt=(Pt=e.accent)==null?void 0:Pt.n4)!=null&&Nt.wMain&&(t["--color-accent-n4-wMain"]=e.accent.n4.wMain),(ct=(Mt=e.accent)==null?void 0:Mt.n4)!=null&&ct.w100&&(t["--color-accent-n4-w100"]=e.accent.n4.w100),(Wt=($t=e.accent)==null?void 0:$t.n4)!=null&&Wt.w30&&(t["--color-accent-n4-w30"]=e.accent.n4.w30),(ve=(Dt=e.accent)==null?void 0:Dt.n5)!=null&&ve.wMain&&(t["--color-accent-n5-wMain"]=e.accent.n5.wMain),(Me=(Pe=e.accent)==null?void 0:Pe.n5)!=null&&Me.w100&&(t["--color-accent-n5-w100"]=e.accent.n5.w100),(at=(Oe=e.accent)==null?void 0:Oe.n5)!=null&&at.w60&&(t["--color-accent-n5-w60"]=e.accent.n5.w60),(it=(Ue=e.accent)==null?void 0:Ue.n5)!=null&&it.w30&&(t["--color-accent-n5-w30"]=e.accent.n5.w30),(ft=(We=e.accent)==null?void 0:We.n6)!=null&&ft.wMain&&(t["--color-accent-n6-wMain"]=e.accent.n6.wMain),(hn=(Et=e.accent)==null?void 0:Et.n6)!=null&&hn.w100&&(t["--color-accent-n6-w100"]=e.accent.n6.w100),(ee=(Dn=e.accent)==null?void 0:Dn.n6)!=null&&ee.w30&&(t["--color-accent-n6-w30"]=e.accent.n6.w30),(fe=(le=e.accent)==null?void 0:le.n7)!=null&&fe.wMain&&(t["--color-accent-n7-wMain"]=e.accent.n7.wMain),(_e=(be=e.accent)==null?void 0:be.n7)!=null&&_e.w100&&(t["--color-accent-n7-w100"]=e.accent.n7.w100),(He=(Fe=e.accent)==null?void 0:Fe.n7)!=null&&He.w30&&(t["--color-accent-n7-w30"]=e.accent.n7.w30),(Ve=(Le=e.accent)==null?void 0:Le.n8)!=null&&Ve.wMain&&(t["--color-accent-n8-wMain"]=e.accent.n8.wMain),(Se=(Xe=e.accent)==null?void 0:Xe.n8)!=null&&Se.w100&&(t["--color-accent-n8-w100"]=e.accent.n8.w100),(De=(je=e.accent)==null?void 0:je.n8)!=null&&De.w30&&(t["--color-accent-n8-w30"]=e.accent.n8.w30),(yt=(Ze=e.accent)==null?void 0:Ze.n9)!=null&&yt.wMain&&(t["--color-accent-n9-wMain"]=e.accent.n9.wMain),(At=e.learning)!=null&&At.wMain&&(t["--color-learning-wMain"]=e.learning.wMain),(ke=e.learning)!=null&&ke.w100&&(t["--color-learning-w100"]=e.learning.w100),(te=e.learning)!=null&&te.w90&&(t["--color-learning-w90"]=e.learning.w90),(ge=e.learning)!=null&&ge.w20&&(t["--color-learning-w20"]=e.learning.w20),(Ie=e.learning)!=null&&Ie.w10&&(t["--color-learning-w10"]=e.learning.w10),t}function d9(e,t="light"){const n={};if(e){const o=u9(e);Object.assign(n,o)}const r=c9(e,t);return Object.assign(n,r),n}function f9(){const e=localStorage.getItem(Wl);return e==="dark"||e==="light"?e:window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function h9(e,t){const n=d9(e,t),r=document.documentElement;for(const[o,a]of Object.entries(n))r.style.setProperty(o,a);requestAnimationFrame(()=>{r.classList.remove("light","dark"),r.classList.add(t),localStorage.setItem(Wl,t)})}const p9=({children:e})=>{const t=d.useMemo(()=>a9,[]),[n,r]=d.useState(()=>f9()),o=d.useMemo(()=>({currentTheme:n,toggleTheme:()=>{const a=n==="light"?"dark":"light";r(a),localStorage.setItem(Wl,a)}}),[n]);return d.useEffect(()=>{if(!(localStorage.getItem(Wl)!==null)){const i=window.matchMedia("(prefers-color-scheme: dark)"),l=c=>{r(c.matches?"dark":"light")};return i.addEventListener?i.addEventListener("change",l):i.addListener(l),()=>{i.removeEventListener?i.removeEventListener("change",l):i.removeListener(l)}}},[]),d.useEffect(()=>{document.documentElement.classList.remove("light","dark"),h9(t,n)},[n,t]),s.jsx(Iw.Provider,{value:o,children:e})};function m9(){const e=Vr(),t=zo(),{isAuthenticated:n,login:r,useAuthorization:o}=Fw(),{configFeatureEnablement:a}=Ut(),{isMenuOpen:i,menuPosition:l,selectedText:c,clearSelection:u}=_x();d.useEffect(()=>{const x=new MutationObserver(()=>{const g=document.body.style.pointerEvents;!document.querySelector('[data-state="open"]')&&g==="none"&&document.body.style.removeProperty("pointer-events")});return x.observe(document.body,{attributes:!0,attributeFilter:["style"],childList:!0,subtree:!0}),()=>{x.disconnect()}},[]);const f=TD(a);jT();const h=()=>{const x=e.pathname;return x==="/"||x.startsWith("/chat")?"chat":x.startsWith("/projects")?"projects":x.startsWith("/prompts")?"prompts":x.startsWith("/agents")?"agentMesh":"chat"};if(o&&!n)return s.jsx("div",{className:"bg-background flex h-screen items-center justify-center",children:s.jsx(xe,{onClick:r,children:"Login"})});const m=x=>{const g=f.find(w=>w.id===x)||eg.find(w=>w.id===x);g!=null&&g.onClick&&x!=="settings"?g.onClick():x!=="settings"&&t(`/${x==="agentMesh"?"agents":x}`)},p=()=>{t("/chat")};return s.jsxs("div",{className:"relative flex h-screen",children:[s.jsx(SD,{items:f,bottomItems:eg,activeItem:h(),onItemChange:m,onHeaderClick:p}),s.jsx("main",{className:"h-full w-full flex-1 overflow-auto",children:s.jsx(QS,{})}),s.jsx(TP,{}),s.jsx(IP,{isOpen:i,position:l,selectedText:c||"",onClose:u})]})}function g9(){return s.jsx(e9,{children:s.jsx(m9,{})})}const x9=()=>S_([{path:"/",element:s.jsx(g9,{}),children:[{index:!0,element:s.jsx(lp,{to:"/chat",replace:!0})},{path:"chat",element:s.jsx(PD,{})},{path:"projects",children:[{index:!0,element:s.jsx(Ng,{})},{path:":id",element:s.jsx(Ng,{}),loader:({params:e})=>({projectId:e.id})}]},{path:"prompts",children:[{index:!0,element:s.jsx(Qi,{})},{path:"new",element:s.jsx(Qi,{}),loader:({request:e})=>({view:"builder",mode:new URL(e.url).searchParams.get("mode")||"manual"})},{path:":id/edit",element:s.jsx(Qi,{}),loader:({params:e})=>({promptId:e.id,view:"builder",mode:"edit"})},{path:":id/versions",element:s.jsx(Qi,{}),loader:({params:e})=>({promptId:e.id,view:"versions"})}]},{path:"agents",element:s.jsx(AD,{})},{path:"*",element:s.jsx(lp,{to:"/chat",replace:!0})}]}]);function v9(){return s.jsx(D_,{router:x9()})}function w9(){return s.jsx(p9,{children:s.jsx(s9,{children:s.jsx(VF,{children:s.jsx(t9,{children:s.jsx(CT,{children:s.jsx(kT,{children:s.jsx(WF,{children:s.jsx(O_,{children:s.jsx(v9,{})})})})})})})})})}V1.createRoot(document.getElementById("root")).render(s.jsx(d.StrictMode,{children:s.jsx(w9,{})}));