solace-agent-mesh 1.11.2__py3-none-any.whl → 1.12.0__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 (308) hide show
  1. solace_agent_mesh/agent/adk/callbacks.py +177 -10
  2. solace_agent_mesh/agent/adk/embed_resolving_mcp_toolset.py +3 -0
  3. solace_agent_mesh/agent/adk/models/lite_llm.py +34 -16
  4. solace_agent_mesh/agent/adk/runner.py +66 -8
  5. solace_agent_mesh/agent/adk/setup.py +61 -26
  6. solace_agent_mesh/agent/protocol/event_handlers.py +48 -0
  7. solace_agent_mesh/agent/proxies/a2a/component.py +27 -0
  8. solace_agent_mesh/agent/sac/component.py +84 -2
  9. solace_agent_mesh/agent/tools/builtin_artifact_tools.py +41 -22
  10. solace_agent_mesh/agent/tools/peer_agent_tool.py +19 -12
  11. solace_agent_mesh/agent/tools/tool_config_types.py +21 -1
  12. solace_agent_mesh/agent/utils/artifact_helpers.py +54 -0
  13. solace_agent_mesh/assets/docs/404.html +3 -3
  14. solace_agent_mesh/assets/docs/assets/js/15ba94aa.e186750d.js +1 -0
  15. solace_agent_mesh/assets/docs/assets/js/240a0364.83e37aa8.js +1 -0
  16. solace_agent_mesh/assets/docs/assets/js/2e32b5e0.2f0db237.js +1 -0
  17. solace_agent_mesh/assets/docs/assets/js/3a6c6137.7e61915d.js +1 -0
  18. solace_agent_mesh/assets/docs/assets/js/{3ac1795d.28b7c67b.js → 3ac1795d.dc006e20.js} +1 -1
  19. solace_agent_mesh/assets/docs/assets/js/3ff0015d.f08618fb.js +1 -0
  20. solace_agent_mesh/assets/docs/assets/js/4667dc50.bf2ad456.js +1 -0
  21. solace_agent_mesh/assets/docs/assets/js/547e15cc.8e6da617.js +1 -0
  22. solace_agent_mesh/assets/docs/assets/js/5b8d9c11.d4eb37b8.js +1 -0
  23. solace_agent_mesh/assets/docs/assets/js/5c2bd65f.1ee87753.js +1 -0
  24. solace_agent_mesh/assets/docs/assets/js/64195356.09dbd087.js +1 -0
  25. solace_agent_mesh/assets/docs/assets/js/66d4869e.30340bd3.js +1 -0
  26. solace_agent_mesh/assets/docs/assets/js/729898df.7249e9fd.js +1 -0
  27. solace_agent_mesh/assets/docs/assets/js/7e294c01.7c5f6906.js +1 -0
  28. solace_agent_mesh/assets/docs/assets/js/8024126c.e3467286.js +1 -0
  29. solace_agent_mesh/assets/docs/assets/js/81a99df0.95be65d4.js +1 -0
  30. solace_agent_mesh/assets/docs/assets/js/9bb13469.4523ae20.js +1 -0
  31. solace_agent_mesh/assets/docs/assets/js/a7d42657.a956689d.js +1 -0
  32. solace_agent_mesh/assets/docs/assets/js/ab9708a8.3e563275.js +1 -0
  33. solace_agent_mesh/assets/docs/assets/js/e04b235d.06d23db6.js +1 -0
  34. solace_agent_mesh/assets/docs/assets/js/e1b6eeb4.deb2b62e.js +1 -0
  35. solace_agent_mesh/assets/docs/assets/js/e6f9706b.acc800d3.js +1 -0
  36. solace_agent_mesh/assets/docs/assets/js/e92d0134.c147a429.js +1 -0
  37. solace_agent_mesh/assets/docs/assets/js/ee0c2fe7.94d0a351.js +1 -0
  38. solace_agent_mesh/assets/docs/assets/js/f284c35a.08fab659.js +1 -0
  39. solace_agent_mesh/assets/docs/assets/js/main.b241af3e.js +2 -0
  40. solace_agent_mesh/assets/docs/assets/js/runtime~main.4ca7d2e2.js +1 -0
  41. solace_agent_mesh/assets/docs/docs/documentation/components/agents/index.html +4 -4
  42. solace_agent_mesh/assets/docs/docs/documentation/components/builtin-tools/artifact-management/index.html +4 -4
  43. solace_agent_mesh/assets/docs/docs/documentation/components/builtin-tools/audio-tools/index.html +4 -4
  44. solace_agent_mesh/assets/docs/docs/documentation/components/builtin-tools/data-analysis-tools/index.html +4 -4
  45. solace_agent_mesh/assets/docs/docs/documentation/components/builtin-tools/embeds/index.html +4 -4
  46. solace_agent_mesh/assets/docs/docs/documentation/components/builtin-tools/image-tools/index.html +81 -0
  47. solace_agent_mesh/assets/docs/docs/documentation/components/builtin-tools/index.html +14 -12
  48. solace_agent_mesh/assets/docs/docs/documentation/components/cli/index.html +30 -9
  49. solace_agent_mesh/assets/docs/docs/documentation/components/gateways/index.html +4 -4
  50. solace_agent_mesh/assets/docs/docs/documentation/components/index.html +6 -4
  51. solace_agent_mesh/assets/docs/docs/documentation/components/orchestrator/index.html +4 -4
  52. solace_agent_mesh/assets/docs/docs/documentation/components/platform-service/index.html +33 -0
  53. solace_agent_mesh/assets/docs/docs/documentation/components/plugins/index.html +4 -4
  54. solace_agent_mesh/assets/docs/docs/documentation/components/projects/index.html +4 -4
  55. solace_agent_mesh/assets/docs/docs/documentation/components/prompts/index.html +4 -4
  56. solace_agent_mesh/assets/docs/docs/documentation/components/proxies/index.html +4 -4
  57. solace_agent_mesh/assets/docs/docs/documentation/components/speech/index.html +4 -4
  58. solace_agent_mesh/assets/docs/docs/documentation/deploying/debugging/index.html +4 -4
  59. solace_agent_mesh/assets/docs/docs/documentation/deploying/deployment-options/index.html +5 -5
  60. solace_agent_mesh/assets/docs/docs/documentation/deploying/index.html +4 -4
  61. solace_agent_mesh/assets/docs/docs/documentation/deploying/{kubernetes-deployment → kubernetes}/index.html +6 -6
  62. solace_agent_mesh/assets/docs/docs/documentation/deploying/kubernetes/kubernetes-deployment-guide/index.html +197 -0
  63. solace_agent_mesh/assets/docs/docs/documentation/deploying/logging/index.html +11 -6
  64. solace_agent_mesh/assets/docs/docs/documentation/deploying/observability/index.html +4 -4
  65. solace_agent_mesh/assets/docs/docs/documentation/deploying/proxy_configuration/index.html +4 -4
  66. solace_agent_mesh/assets/docs/docs/documentation/developing/create-agents/index.html +4 -4
  67. solace_agent_mesh/assets/docs/docs/documentation/developing/create-gateways/index.html +4 -4
  68. solace_agent_mesh/assets/docs/docs/documentation/developing/creating-python-tools/index.html +23 -5
  69. solace_agent_mesh/assets/docs/docs/documentation/developing/creating-service-providers/index.html +4 -4
  70. solace_agent_mesh/assets/docs/docs/documentation/developing/evaluations/index.html +4 -4
  71. solace_agent_mesh/assets/docs/docs/documentation/developing/index.html +4 -4
  72. solace_agent_mesh/assets/docs/docs/documentation/developing/structure/index.html +4 -4
  73. solace_agent_mesh/assets/docs/docs/documentation/developing/tutorials/bedrock-agents/index.html +4 -4
  74. solace_agent_mesh/assets/docs/docs/documentation/developing/tutorials/custom-agent/index.html +4 -4
  75. solace_agent_mesh/assets/docs/docs/documentation/developing/tutorials/event-mesh-gateway/index.html +4 -4
  76. solace_agent_mesh/assets/docs/docs/documentation/developing/tutorials/mcp-integration/index.html +17 -8
  77. solace_agent_mesh/assets/docs/docs/documentation/developing/tutorials/mongodb-integration/index.html +4 -4
  78. solace_agent_mesh/assets/docs/docs/documentation/developing/tutorials/rag-integration/index.html +4 -4
  79. solace_agent_mesh/assets/docs/docs/documentation/developing/tutorials/rest-gateway/index.html +4 -4
  80. solace_agent_mesh/assets/docs/docs/documentation/developing/tutorials/slack-integration/index.html +4 -4
  81. solace_agent_mesh/assets/docs/docs/documentation/developing/tutorials/sql-database/index.html +4 -4
  82. solace_agent_mesh/assets/docs/docs/documentation/developing/tutorials/teams-integration/index.html +4 -4
  83. solace_agent_mesh/assets/docs/docs/documentation/enterprise/agent-builder/index.html +5 -5
  84. solace_agent_mesh/assets/docs/docs/documentation/enterprise/connectors/index.html +4 -4
  85. solace_agent_mesh/assets/docs/docs/documentation/enterprise/index.html +4 -4
  86. solace_agent_mesh/assets/docs/docs/documentation/enterprise/installation/index.html +4 -4
  87. solace_agent_mesh/assets/docs/docs/documentation/enterprise/openapi-tools/index.html +4 -4
  88. solace_agent_mesh/assets/docs/docs/documentation/enterprise/rbac-setup-guide/index.html +4 -4
  89. solace_agent_mesh/assets/docs/docs/documentation/enterprise/secure-user-delegated-access/index.html +4 -4
  90. solace_agent_mesh/assets/docs/docs/documentation/enterprise/single-sign-on/index.html +4 -4
  91. solace_agent_mesh/assets/docs/docs/documentation/enterprise/wheel-installation/index.html +4 -4
  92. solace_agent_mesh/assets/docs/docs/documentation/getting-started/architecture/index.html +4 -4
  93. solace_agent_mesh/assets/docs/docs/documentation/getting-started/index.html +6 -5
  94. solace_agent_mesh/assets/docs/docs/documentation/getting-started/introduction/index.html +4 -4
  95. solace_agent_mesh/assets/docs/docs/documentation/getting-started/try-agent-mesh/index.html +4 -4
  96. solace_agent_mesh/assets/docs/docs/documentation/getting-started/vibe_coding/index.html +62 -0
  97. solace_agent_mesh/assets/docs/docs/documentation/installing-and-configuring/artifact-storage/index.html +25 -4
  98. solace_agent_mesh/assets/docs/docs/documentation/installing-and-configuring/configurations/index.html +4 -4
  99. solace_agent_mesh/assets/docs/docs/documentation/installing-and-configuring/index.html +4 -4
  100. solace_agent_mesh/assets/docs/docs/documentation/installing-and-configuring/installation/index.html +4 -4
  101. solace_agent_mesh/assets/docs/docs/documentation/installing-and-configuring/large_language_models/index.html +4 -4
  102. solace_agent_mesh/assets/docs/docs/documentation/installing-and-configuring/run-project/index.html +4 -4
  103. solace_agent_mesh/assets/docs/docs/documentation/installing-and-configuring/session-storage/index.html +4 -4
  104. solace_agent_mesh/assets/docs/docs/documentation/installing-and-configuring/user-feedback/index.html +4 -4
  105. solace_agent_mesh/assets/docs/docs/documentation/migrations/a2a-upgrade/a2a-gateway-upgrade-to-0.3.0/index.html +4 -4
  106. solace_agent_mesh/assets/docs/docs/documentation/migrations/a2a-upgrade/a2a-technical-migration-map/index.html +4 -4
  107. solace_agent_mesh/assets/docs/docs/documentation/migrations/platform-service-split/index.html +85 -0
  108. solace_agent_mesh/assets/docs/lunr-index-1767712284328.json +1 -0
  109. solace_agent_mesh/assets/docs/lunr-index.json +1 -1
  110. solace_agent_mesh/assets/docs/search-doc-1767712284328.json +1 -0
  111. solace_agent_mesh/assets/docs/search-doc.json +1 -1
  112. solace_agent_mesh/assets/docs/sitemap.xml +1 -1
  113. solace_agent_mesh/cli/__init__.py +1 -1
  114. solace_agent_mesh/cli/commands/init_cmd/__init__.py +15 -0
  115. solace_agent_mesh/cli/commands/init_cmd/directory_step.py +1 -1
  116. solace_agent_mesh/cli/commands/init_cmd/env_step.py +29 -2
  117. solace_agent_mesh/cli/commands/init_cmd/platform_service_step.py +85 -0
  118. solace_agent_mesh/cli/commands/tools_cmd.py +315 -0
  119. solace_agent_mesh/cli/main.py +2 -0
  120. solace_agent_mesh/client/webui/frontend/static/assets/{authCallback-Dj3JtK42.js → authCallback-8Nihi8rv.js} +1 -1
  121. solace_agent_mesh/client/webui/frontend/static/assets/{client-ZKk9kEJ5.js → client-DYtZN8p-.js} +1 -1
  122. solace_agent_mesh/client/webui/frontend/static/assets/main-BYGUHQMk.js +435 -0
  123. solace_agent_mesh/client/webui/frontend/static/assets/main-D2CSH1bp.css +1 -0
  124. solace_agent_mesh/client/webui/frontend/static/assets/{vendor-BNV4kZN0.js → vendor-XBWAmrun.js} +106 -101
  125. solace_agent_mesh/client/webui/frontend/static/auth-callback.html +3 -3
  126. solace_agent_mesh/client/webui/frontend/static/index.html +4 -4
  127. solace_agent_mesh/client/webui/frontend/static/ui-version.json +1 -1
  128. solace_agent_mesh/common/a2a/types.py +1 -1
  129. solace_agent_mesh/common/agent_registry.py +38 -11
  130. solace_agent_mesh/common/data_parts.py +28 -0
  131. solace_agent_mesh/common/error_handlers.py +83 -0
  132. solace_agent_mesh/common/sam_events/event_service.py +2 -2
  133. solace_agent_mesh/config_portal/backend/common.py +2 -0
  134. solace_agent_mesh/config_portal/frontend/static/client/assets/_index-ZV-jX48T.js +103 -0
  135. solace_agent_mesh/config_portal/frontend/static/client/assets/{manifest-ba77705e.js → manifest-ce5bc5da.js} +1 -1
  136. solace_agent_mesh/config_portal/frontend/static/client/index.html +1 -1
  137. solace_agent_mesh/core_a2a/service.py +3 -2
  138. solace_agent_mesh/gateway/adapter/base.py +28 -1
  139. solace_agent_mesh/gateway/adapter/types.py +9 -0
  140. solace_agent_mesh/gateway/base/auth_interface.py +103 -0
  141. solace_agent_mesh/gateway/base/component.py +68 -1
  142. solace_agent_mesh/gateway/generic/component.py +195 -30
  143. solace_agent_mesh/gateway/http_sse/app.py +23 -6
  144. solace_agent_mesh/gateway/http_sse/component.py +9 -61
  145. solace_agent_mesh/gateway/http_sse/dependencies.py +9 -51
  146. solace_agent_mesh/gateway/http_sse/main.py +28 -418
  147. solace_agent_mesh/gateway/http_sse/repository/chat_task_repository.py +2 -2
  148. solace_agent_mesh/gateway/http_sse/repository/entities/project.py +1 -1
  149. solace_agent_mesh/gateway/http_sse/repository/entities/project_user.py +1 -1
  150. solace_agent_mesh/gateway/http_sse/repository/entities/session.py +2 -2
  151. solace_agent_mesh/gateway/http_sse/repository/feedback_repository.py +2 -2
  152. solace_agent_mesh/gateway/http_sse/repository/interfaces.py +2 -2
  153. solace_agent_mesh/gateway/http_sse/repository/models/prompt_model.py +1 -1
  154. solace_agent_mesh/gateway/http_sse/repository/models/session_model.py +1 -1
  155. solace_agent_mesh/gateway/http_sse/repository/project_repository.py +1 -1
  156. solace_agent_mesh/gateway/http_sse/repository/project_user_repository.py +1 -1
  157. solace_agent_mesh/gateway/http_sse/repository/session_repository.py +4 -4
  158. solace_agent_mesh/gateway/http_sse/repository/task_repository.py +2 -2
  159. solace_agent_mesh/gateway/http_sse/routers/artifacts.py +16 -15
  160. solace_agent_mesh/gateway/http_sse/routers/auth.py +61 -132
  161. solace_agent_mesh/gateway/http_sse/routers/config.py +12 -8
  162. solace_agent_mesh/gateway/http_sse/routers/dto/requests/session_requests.py +1 -1
  163. solace_agent_mesh/gateway/http_sse/routers/dto/responses/base_responses.py +1 -1
  164. solace_agent_mesh/gateway/http_sse/routers/dto/responses/session_responses.py +2 -2
  165. solace_agent_mesh/gateway/http_sse/routers/feedback.py +2 -2
  166. solace_agent_mesh/gateway/http_sse/routers/people.py +2 -2
  167. solace_agent_mesh/gateway/http_sse/routers/projects.py +2 -1
  168. solace_agent_mesh/gateway/http_sse/routers/prompts.py +2 -1
  169. solace_agent_mesh/gateway/http_sse/routers/sessions.py +3 -3
  170. solace_agent_mesh/gateway/http_sse/routers/speech.py +1 -1
  171. solace_agent_mesh/gateway/http_sse/routers/tasks.py +3 -2
  172. solace_agent_mesh/gateway/http_sse/routers/users.py +1 -1
  173. solace_agent_mesh/gateway/http_sse/routers/visualization.py +2 -1
  174. solace_agent_mesh/gateway/http_sse/services/background_task_monitor.py +1 -1
  175. solace_agent_mesh/gateway/http_sse/services/data_retention_service.py +1 -1
  176. solace_agent_mesh/gateway/http_sse/services/feedback_service.py +1 -1
  177. solace_agent_mesh/gateway/http_sse/services/session_service.py +4 -4
  178. solace_agent_mesh/gateway/http_sse/services/task_logger_service.py +1 -1
  179. solace_agent_mesh/services/platform/__init__.py +23 -12
  180. solace_agent_mesh/services/platform/api/dependencies.py +23 -16
  181. solace_agent_mesh/services/platform/api/main.py +118 -43
  182. solace_agent_mesh/services/platform/api/routers/__init__.py +12 -3
  183. solace_agent_mesh/services/platform/api/routers/health_router.py +31 -0
  184. solace_agent_mesh/services/platform/app.py +101 -7
  185. solace_agent_mesh/services/platform/component.py +552 -33
  186. solace_agent_mesh/shared/__init__.py +14 -0
  187. solace_agent_mesh/shared/api/__init__.py +42 -0
  188. solace_agent_mesh/shared/auth/__init__.py +26 -0
  189. solace_agent_mesh/shared/auth/dependencies.py +204 -0
  190. solace_agent_mesh/shared/auth/middleware.py +291 -0
  191. solace_agent_mesh/shared/database/__init__.py +20 -0
  192. solace_agent_mesh/{gateway/http_sse/shared → shared/database}/base_repository.py +1 -1
  193. solace_agent_mesh/{gateway/http_sse/shared → shared/database}/database_exceptions.py +1 -1
  194. solace_agent_mesh/{gateway/http_sse/shared → shared/database}/database_helpers.py +1 -1
  195. solace_agent_mesh/shared/exceptions/__init__.py +36 -0
  196. solace_agent_mesh/{gateway/http_sse/shared → shared/exceptions}/exception_handlers.py +1 -1
  197. solace_agent_mesh/shared/utils/__init__.py +21 -0
  198. solace_agent_mesh/templates/platform.yaml +49 -0
  199. solace_agent_mesh/templates/webui.yaml +12 -3
  200. {solace_agent_mesh-1.11.2.dist-info → solace_agent_mesh-1.12.0.dist-info}/METADATA +2 -1
  201. {solace_agent_mesh-1.11.2.dist-info → solace_agent_mesh-1.12.0.dist-info}/RECORD +214 -258
  202. solace_agent_mesh/agent/adk/adk_llm.txt +0 -226
  203. solace_agent_mesh/agent/adk/adk_llm_detail.txt +0 -566
  204. solace_agent_mesh/agent/adk/artifacts/artifacts_llm.txt +0 -171
  205. solace_agent_mesh/agent/adk/models/models_llm.txt +0 -189
  206. solace_agent_mesh/agent/agent_llm.txt +0 -369
  207. solace_agent_mesh/agent/agent_llm_detail.txt +0 -1702
  208. solace_agent_mesh/agent/protocol/protocol_llm.txt +0 -81
  209. solace_agent_mesh/agent/protocol/protocol_llm_detail.txt +0 -92
  210. solace_agent_mesh/agent/proxies/a2a/a2a_llm.txt +0 -190
  211. solace_agent_mesh/agent/proxies/base/base_llm.txt +0 -148
  212. solace_agent_mesh/agent/proxies/proxies_llm.txt +0 -283
  213. solace_agent_mesh/agent/sac/sac_llm.txt +0 -189
  214. solace_agent_mesh/agent/sac/sac_llm_detail.txt +0 -200
  215. solace_agent_mesh/agent/testing/testing_llm.txt +0 -58
  216. solace_agent_mesh/agent/testing/testing_llm_detail.txt +0 -68
  217. solace_agent_mesh/agent/tools/tools_llm.txt +0 -276
  218. solace_agent_mesh/agent/tools/tools_llm_detail.txt +0 -275
  219. solace_agent_mesh/agent/utils/utils_llm.txt +0 -152
  220. solace_agent_mesh/agent/utils/utils_llm_detail.txt +0 -149
  221. solace_agent_mesh/assets/docs/assets/js/15ba94aa.92fea363.js +0 -1
  222. solace_agent_mesh/assets/docs/assets/js/240a0364.9ad94d1b.js +0 -1
  223. solace_agent_mesh/assets/docs/assets/js/2e32b5e0.33f5d75b.js +0 -1
  224. solace_agent_mesh/assets/docs/assets/js/3a6c6137.f5940cfa.js +0 -1
  225. solace_agent_mesh/assets/docs/assets/js/3ff0015d.2ddc75c0.js +0 -1
  226. solace_agent_mesh/assets/docs/assets/js/547e15cc.2f7790c1.js +0 -1
  227. solace_agent_mesh/assets/docs/assets/js/5c2bd65f.90a87880.js +0 -1
  228. solace_agent_mesh/assets/docs/assets/js/64195356.c498c4d0.js +0 -1
  229. solace_agent_mesh/assets/docs/assets/js/66d4869e.b77431fc.js +0 -1
  230. solace_agent_mesh/assets/docs/assets/js/8024126c.fa0e7186.js +0 -1
  231. solace_agent_mesh/assets/docs/assets/js/81a99df0.2484b8d9.js +0 -1
  232. solace_agent_mesh/assets/docs/assets/js/9bb13469.b2333011.js +0 -1
  233. solace_agent_mesh/assets/docs/assets/js/ab9708a8.245ae0ef.js +0 -1
  234. solace_agent_mesh/assets/docs/assets/js/db5d6442.3daf1696.js +0 -1
  235. solace_agent_mesh/assets/docs/assets/js/e04b235d.52cb25ed.js +0 -1
  236. solace_agent_mesh/assets/docs/assets/js/e1b6eeb4.b1068f9b.js +0 -1
  237. solace_agent_mesh/assets/docs/assets/js/e6f9706b.4488e34c.js +0 -1
  238. solace_agent_mesh/assets/docs/assets/js/e92d0134.3bda61dd.js +0 -1
  239. solace_agent_mesh/assets/docs/assets/js/f284c35a.250993bf.js +0 -1
  240. solace_agent_mesh/assets/docs/assets/js/main.7acf7ace.js +0 -2
  241. solace_agent_mesh/assets/docs/assets/js/runtime~main.9e0813a2.js +0 -1
  242. solace_agent_mesh/assets/docs/lunr-index-1765810064709.json +0 -1
  243. solace_agent_mesh/assets/docs/search-doc-1765810064709.json +0 -1
  244. solace_agent_mesh/cli/commands/add_cmd/add_cmd_llm.txt +0 -250
  245. solace_agent_mesh/cli/commands/init_cmd/init_cmd_llm.txt +0 -365
  246. solace_agent_mesh/cli/commands/plugin_cmd/plugin_cmd_llm.txt +0 -305
  247. solace_agent_mesh/client/webui/frontend/static/assets/main-BcUaNZ-Q.css +0 -1
  248. solace_agent_mesh/client/webui/frontend/static/assets/main-vjch4RYc.js +0 -435
  249. solace_agent_mesh/common/a2a/a2a_llm.txt +0 -175
  250. solace_agent_mesh/common/a2a/a2a_llm_detail.txt +0 -193
  251. solace_agent_mesh/common/a2a_spec/a2a_spec_llm.txt +0 -445
  252. solace_agent_mesh/common/a2a_spec/a2a_spec_llm_detail.txt +0 -736
  253. solace_agent_mesh/common/a2a_spec/schemas/schemas_llm.txt +0 -330
  254. solace_agent_mesh/common/common_llm.txt +0 -230
  255. solace_agent_mesh/common/common_llm_detail.txt +0 -2562
  256. solace_agent_mesh/common/middleware/middleware_llm.txt +0 -174
  257. solace_agent_mesh/common/middleware/middleware_llm_detail.txt +0 -185
  258. solace_agent_mesh/common/sac/sac_llm.txt +0 -71
  259. solace_agent_mesh/common/sac/sac_llm_detail.txt +0 -82
  260. solace_agent_mesh/common/sam_events/sam_events_llm.txt +0 -104
  261. solace_agent_mesh/common/sam_events/sam_events_llm_detail.txt +0 -115
  262. solace_agent_mesh/common/services/providers/providers_llm.txt +0 -81
  263. solace_agent_mesh/common/services/services_llm.txt +0 -368
  264. solace_agent_mesh/common/services/services_llm_detail.txt +0 -459
  265. solace_agent_mesh/common/utils/embeds/embeds_llm.txt +0 -220
  266. solace_agent_mesh/common/utils/utils_llm.txt +0 -335
  267. solace_agent_mesh/common/utils/utils_llm_detail.txt +0 -572
  268. solace_agent_mesh/config_portal/frontend/static/client/assets/_index-DiOiAjzL.js +0 -103
  269. solace_agent_mesh/core_a2a/core_a2a_llm.txt +0 -90
  270. solace_agent_mesh/core_a2a/core_a2a_llm_detail.txt +0 -101
  271. solace_agent_mesh/gateway/base/base_llm.txt +0 -226
  272. solace_agent_mesh/gateway/base/base_llm_detail.txt +0 -235
  273. solace_agent_mesh/gateway/gateway_llm.txt +0 -369
  274. solace_agent_mesh/gateway/gateway_llm_detail.txt +0 -3885
  275. solace_agent_mesh/gateway/http_sse/alembic/alembic_llm.txt +0 -345
  276. solace_agent_mesh/gateway/http_sse/alembic/versions/versions_llm.txt +0 -161
  277. solace_agent_mesh/gateway/http_sse/components/components_llm.txt +0 -105
  278. solace_agent_mesh/gateway/http_sse/http_sse_llm.txt +0 -299
  279. solace_agent_mesh/gateway/http_sse/http_sse_llm_detail.txt +0 -3278
  280. solace_agent_mesh/gateway/http_sse/repository/entities/entities_llm.txt +0 -221
  281. solace_agent_mesh/gateway/http_sse/repository/models/models_llm.txt +0 -257
  282. solace_agent_mesh/gateway/http_sse/repository/repository_llm.txt +0 -308
  283. solace_agent_mesh/gateway/http_sse/routers/dto/dto_llm.txt +0 -450
  284. solace_agent_mesh/gateway/http_sse/routers/dto/requests/requests_llm.txt +0 -133
  285. solace_agent_mesh/gateway/http_sse/routers/dto/responses/responses_llm.txt +0 -123
  286. solace_agent_mesh/gateway/http_sse/routers/routers_llm.txt +0 -312
  287. solace_agent_mesh/gateway/http_sse/services/services_llm.txt +0 -303
  288. solace_agent_mesh/gateway/http_sse/shared/__init__.py +0 -146
  289. solace_agent_mesh/gateway/http_sse/shared/shared_llm.txt +0 -319
  290. solace_agent_mesh/gateway/http_sse/utils/utils_llm.txt +0 -47
  291. solace_agent_mesh/llm.txt +0 -228
  292. solace_agent_mesh/llm_detail.txt +0 -2835
  293. solace_agent_mesh/solace_agent_mesh_llm.txt +0 -362
  294. solace_agent_mesh/solace_agent_mesh_llm_detail.txt +0 -8599
  295. solace_agent_mesh/templates/templates_llm.txt +0 -147
  296. /solace_agent_mesh/assets/docs/assets/js/{main.7acf7ace.js.LICENSE.txt → main.b241af3e.js.LICENSE.txt} +0 -0
  297. /solace_agent_mesh/{gateway/http_sse/shared → shared/api}/auth_utils.py +0 -0
  298. /solace_agent_mesh/{gateway/http_sse/shared → shared/api}/pagination.py +0 -0
  299. /solace_agent_mesh/{gateway/http_sse/shared → shared/api}/response_utils.py +0 -0
  300. /solace_agent_mesh/{gateway/http_sse/shared → shared/exceptions}/error_dto.py +0 -0
  301. /solace_agent_mesh/{gateway/http_sse/shared → shared/exceptions}/exceptions.py +0 -0
  302. /solace_agent_mesh/{gateway/http_sse/shared → shared/utils}/enums.py +0 -0
  303. /solace_agent_mesh/{gateway/http_sse/shared → shared/utils}/timestamp_utils.py +0 -0
  304. /solace_agent_mesh/{gateway/http_sse/shared → shared/utils}/types.py +0 -0
  305. /solace_agent_mesh/{gateway/http_sse/shared → shared/utils}/utils.py +0 -0
  306. {solace_agent_mesh-1.11.2.dist-info → solace_agent_mesh-1.12.0.dist-info}/WHEEL +0 -0
  307. {solace_agent_mesh-1.11.2.dist-info → solace_agent_mesh-1.12.0.dist-info}/entry_points.txt +0 -0
  308. {solace_agent_mesh-1.11.2.dist-info → solace_agent_mesh-1.12.0.dist-info}/licenses/LICENSE +0 -0
@@ -0,0 +1,435 @@
1
+ var _1=Object.defineProperty;var k1=(e,t,n)=>t in e?_1(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var ws=(e,t,n)=>k1(e,typeof t!="symbol"?t+"":t,n);import{c as j1}from"./client-DYtZN8p-.js";import{r as d,a as oa,j as s,R as Ad,b as E1,N as Xi,S as Id,c as At,L as ar,X as Xr,E as N1,F as Nu,d as Da,e as Tu,f as gr,g as pg,h as Au,i as Iu,C as mg,k as ll,l as sa,m as Ru,A as gg,T as Rd,n as Pd,M as xg,o as Pu,p as T1,q as A1,s as mh,t as vg,I as Qa,u as To,v as Qo,P as es,w as wg,B as I1,x as bg,y as yg,z as Md,D as gh,G as xh,H as vh,J as Oa,K as Cg,O as xo,Q as zl,U as $l,V as wh,W as bh,Y as R1,Z as Sg,_ as yh,$ as P1,a0 as M1,a1 as D1,a2 as cl,a3 as O1,a4 as L1,a5 as Io,a6 as F1,a7 as eo,a8 as z1,a9 as ts,aa as ul,ab as Ul,ac as $1,ad as Ch,ae as U1,af as _g,ag as kg,ah as B1,ai as yn,aj as Cn,ak as V1,al as jg,am as W1,an as Sh,ao as _h,ap as Dc,aq as dl,ar as H1,as as Z1,at as G1,au as Y1,av as K1,aw as q1,ax as X1,ay as J1,az as Q1,aA as eC,aB as Eg,aC as tC,aD as Ng,aE as nC,aF as rC,aG as Tg,aH as Ag,aI as Hs,aJ as Ig,aK as oC,aL as sC,aM as Os,aN as aC,aO as Ci,aP as iC}from"./vendor-XBWAmrun.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 Rg=e=>{throw TypeError(e)},lC=(e,t,n)=>t.has(e)||Rg("Cannot "+n),Oc=(e,t,n)=>(lC(e,t,"read from private field"),n?n.call(e):t.get(e)),cC=(e,t,n)=>t.has(e)?Rg("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),kh="popstate";function uC(e={}){function t(o,a){let{pathname:i="/",search:l="",hash:c=""}=vo(o.location.hash.substring(1));return!i.startsWith("/")&&!i.startsWith(".")&&(i="/"+i),La("",{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:Ro(a))}function r(o,a){un(o.pathname.charAt(0)==="/",`relative pathnames are not supported in hash history.push(${JSON.stringify(a)})`)}return fC(t,n,r,e)}function wt(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function un(e,t){if(!e){typeof console<"u"&&console.warn(t);try{throw new Error(t)}catch{}}}function dC(){return Math.random().toString(36).substring(2,10)}function jh(e,t){return{usr:e.state,key:e.key,idx:t}}function La(e,t,n=null,r){return{pathname:typeof e=="string"?e:e.pathname,search:"",hash:"",...typeof t=="string"?vo(t):t,state:n,key:t&&t.key||r||dC()}}function Ro({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 vo(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 fC(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 v=f(),w=v==null?null:v-u;u=v,c&&c({action:l,location:g.location,delta:w})}function p(v,w){l="PUSH";let b=La(g.location,v,w);n&&n(b,v),u=f()+1;let C=jh(b,u),_=g.createHref(b);try{i.pushState(C,"",_)}catch(E){if(E instanceof DOMException&&E.name==="DataCloneError")throw E;o.location.assign(_)}a&&c&&c({action:l,location:g.location,delta:1})}function m(v,w){l="REPLACE";let b=La(g.location,v,w);n&&n(b,v),u=f();let C=jh(b,u),_=g.createHref(b);i.replaceState(C,"",_),a&&c&&c({action:l,location:g.location,delta:0})}function x(v){return Pg(v)}let g={get action(){return l},get location(){return e(o,i)},listen(v){if(c)throw new Error("A history only accepts one active listener");return o.addEventListener(kh,h),c=v,()=>{o.removeEventListener(kh,h),c=null}},createHref(v){return t(o,v)},createURL:x,encodeLocation(v){let w=x(v);return{pathname:w.pathname,search:w.search,hash:w.hash}},push:p,replace:m,go(v){return i.go(v)}};return g}function Pg(e,t=!1){let n="http://localhost";typeof window<"u"&&(n=window.location.origin!=="null"?window.location.origin:window.location.href),wt(n,"No window.location.(origin|href) available to create URL");let r=typeof e=="string"?e:Ro(e);return r=r.replace(/ $/,"%20"),!t&&r.startsWith("//")&&(r=n+r),new URL(r,n)}var ja,Eh=class{constructor(e){if(cC(this,ja,new Map),e)for(let[t,n]of e)this.set(t,n)}get(e){if(Oc(this,ja).has(e))return Oc(this,ja).get(e);if(e.defaultValue!==void 0)return e.defaultValue;throw new Error("No value found for context")}set(e,t){Oc(this,ja).set(e,t)}};ja=new WeakMap;var hC=new Set(["lazy","caseSensitive","path","id","index","children"]);function pC(e){return hC.has(e)}var mC=new Set(["lazy","caseSensitive","path","id","index","middleware","children"]);function gC(e){return mC.has(e)}function xC(e){return e.index===!0}function Fa(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(wt(a.index!==!0||!a.children,"Cannot specify children on an index route"),wt(o||!r[c],`Found a route id collision on id "${c}". Route id's must be globally unique within Data Router usages`),xC(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=Fa(a.children,t,l,r,o)),u}})}function _o(e,t,n="/"){return Ji(e,t,n,!1)}function Ji(e,t,n,r){let o=typeof t=="string"?vo(t):t,a=Qn(o.pathname||"/",n);if(a==null)return null;let i=Mg(e);wC(i);let l=null;for(let c=0;l==null&&c<i.length;++c){let u=AC(a);l=NC(i[c],u,r)}return l}function vC(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 Mg(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;wt(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=Yr([r,f.relativePath]),p=n.concat(f);i.children&&i.children.length>0&&(wt(i.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${h}".`),Mg(i.children,t,p,h,c)),!(i.path==null&&!i.index)&&t.push({path:h,score:jC(h,i.index),routesMeta:p})};return e.forEach((i,l)=>{var c;if(i.path===""||!((c=i.path)!=null&&c.includes("?")))a(i,l);else for(let u of Dg(i.path))a(i,l,!0,u)}),t}function Dg(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=Dg(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 wC(e){e.sort((t,n)=>t.score!==n.score?n.score-t.score:EC(t.routesMeta.map(r=>r.childrenIndex),n.routesMeta.map(r=>r.childrenIndex)))}var bC=/^:[\w-]+$/,yC=3,CC=2,SC=1,_C=10,kC=-2,Nh=e=>e==="*";function jC(e,t){let n=e.split("/"),r=n.length;return n.some(Nh)&&(r+=kC),t&&(r+=CC),n.filter(o=>!Nh(o)).reduce((o,a)=>o+(bC.test(a)?yC:a===""?SC:_C),r)}function EC(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 NC(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=fl({path:c.relativePath,caseSensitive:c.caseSensitive,end:u},f),p=c.route;if(!h&&u&&n&&!r[r.length-1].route.index&&(h=fl({path:c.relativePath,caseSensitive:c.caseSensitive,end:!1},f)),!h)return null;Object.assign(o,h.params),i.push({params:o,pathname:Yr([a,h.pathname]),pathnameBase:MC(Yr([a,h.pathnameBase])),route:p}),h.pathnameBase!=="/"&&(a=Yr([a,h.pathnameBase]))}return i}function fl(e,t){typeof e=="string"&&(e={path:e,caseSensitive:!1,end:!0});let[n,r]=TC(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},p)=>{if(f==="*"){let x=l[p]||"";i=a.slice(0,a.length-x.length).replace(/(.)\/+$/,"$1")}const m=l[p];return h&&!m?u[f]=void 0:u[f]=(m||"").replace(/%2F/g,"/"),u},{}),pathname:a,pathnameBase:i,pattern:e}}function TC(e,t=!1,n=!0){un(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 AC(e){try{return e.split("/").map(t=>decodeURIComponent(t).replace(/\//g,"%2F")).join("/")}catch(t){return un(!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 Qn(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 IC({basename:e,pathname:t}){return t==="/"?e:Yr([e,t])}function RC(e,t="/"){let{pathname:n,search:r="",hash:o=""}=typeof e=="string"?vo(e):e;return{pathname:n?n.startsWith("/")?n:PC(n,t):t,search:DC(r),hash:OC(o)}}function PC(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 Lc(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 Og(e){return e.filter((t,n)=>n===0||t.route.path&&t.route.path.length>0)}function Bl(e){let t=Og(e);return t.map((n,r)=>r===t.length-1?n.pathname:n.pathnameBase)}function Vl(e,t,n,r=!1){let o;typeof e=="string"?o=vo(e):(o={...e},wt(!o.pathname||!o.pathname.includes("?"),Lc("?","pathname","search",o)),wt(!o.pathname||!o.pathname.includes("#"),Lc("#","pathname","hash",o)),wt(!o.search||!o.search.includes("#"),Lc("#","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 p=i.split("/");for(;p[0]==="..";)p.shift(),h-=1;o.pathname=p.join("/")}l=h>=0?t[h]:"/"}let c=RC(o,l),u=i&&i!=="/"&&i.endsWith("/"),f=(a||i===".")&&n.endsWith("/");return!c.pathname.endsWith("/")&&(u||f)&&(c.pathname+="/"),c}var Yr=e=>e.join("/").replace(/\/\/+/g,"/"),MC=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/"),DC=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,OC=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e,hl=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 za(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}var Lg=["POST","PUT","PATCH","DELETE"],LC=new Set(Lg),FC=["GET",...Lg],zC=new Set(FC),$C=new Set([301,302,303,307,308]),UC=new Set([307,308]),Fc={state:"idle",location:void 0,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0},BC={state:"idle",data:void 0,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0},Es={state:"unblocked",proceed:void 0,reset:void 0,location:void 0},VC=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Dd=e=>VC.test(e),WC=e=>({hasErrorBoundary:!!e.hasErrorBoundary}),Fg="remix-router-transitions",zg=Symbol("ResetLoaderData");function HC(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";wt(e.routes.length>0,"You must provide a non-empty routes array to createRouter");let r=e.hydrationRouteProperties||[],o=e.mapRouteProperties||WC,a={},i=Fa(e.routes,o,void 0,a),l,c=e.basename||"/";c.startsWith("/")||(c=`/${c}`);let u=e.dataStrategy||qC,f={...e.future},h=null,p=new Set,m=null,x=null,g=null,v=e.hydrationData!=null,w=_o(i,e.history.location,c),b=!1,C=null,_;if(w==null&&!e.patchRoutesOnNavigation){let ee=mr(404,{pathname:e.history.location.pathname}),{matches:ie,route:fe}=Si(i);_=!0,w=ie,C={[fe.id]:ee}}else if(w&&!e.hydrationData&&st(w,i,e.history.location.pathname).active&&(w=null),w)if(w.some(ee=>ee.route.lazy))_=!1;else if(!w.some(ee=>Od(ee.route)))_=!0;else{let ee=e.hydrationData?e.hydrationData.loaderData:null,ie=e.hydrationData?e.hydrationData.errors:null;if(ie){let fe=w.findIndex(we=>ie[we.route.id]!==void 0);_=w.slice(0,fe+1).every(we=>!Du(we.route,ee,ie))}else _=w.every(fe=>!Du(fe.route,ee,ie))}else{_=!1,w=[];let ee=st(null,i,e.history.location.pathname);ee.active&&ee.matches&&(b=!0,w=ee.matches)}let E,S={historyAction:e.history.action,location:e.history.location,matches:w,initialized:_,navigation:Fc,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,I,P=!1,F=new Map,N=null,R=!1,y=!1,T=new Set,D=new Map,L=0,O=-1,M=new Map,J=new Set,z=new Map,H=new Map,U=new Set,X=new Map,W,te=null;function $(){if(h=e.history.listen(({action:ee,location:ie,delta:fe})=>{if(W){W(),W=void 0;return}un(X.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 we=Ie({currentLocation:S.location,nextLocation:ie,historyAction:ee});if(we&&fe!=null){let ye=new Promise(Le=>{W=Le});e.history.go(fe*-1),Re(we,{state:"blocked",location:ie,proceed(){Re(we,{state:"proceeding",proceed:void 0,reset:void 0,location:ie}),ye.then(()=>e.history.go(fe))},reset(){let Le=new Map(S.blockers);Le.set(we,Es),re({blockers:Le})}});return}return k(ee,ie)}),n){dS(t,F);let ee=()=>fS(t,F);t.addEventListener("pagehide",ee),N=()=>t.removeEventListener("pagehide",ee)}return S.initialized||k("POP",S.location,{initialHydration:!0}),E}function q(){h&&h(),N&&N(),p.clear(),I&&I.abort(),S.fetchers.forEach((ee,ie)=>Lt(ie)),S.blockers.forEach((ee,ie)=>xe(ie))}function Y(ee){return p.add(ee),()=>p.delete(ee)}function re(ee,ie={}){ee.matches&&(ee.matches=ee.matches.map(ye=>{let Le=a[ye.route.id],$e=ye.route;return $e.element!==Le.element||$e.errorElement!==Le.errorElement||$e.hydrateFallbackElement!==Le.hydrateFallbackElement?{...ye,route:Le}:ye})),S={...S,...ee};let fe=[],we=[];S.fetchers.forEach((ye,Le)=>{ye.state==="idle"&&(U.has(Le)?fe.push(Le):we.push(Le))}),U.forEach(ye=>{!S.fetchers.has(ye)&&!D.has(ye)&&fe.push(ye)}),[...p].forEach(ye=>ye(S,{deletedFetchers:fe,viewTransitionOpts:ie.viewTransitionOpts,flushSync:ie.flushSync===!0})),fe.forEach(ye=>Lt(ye)),we.forEach(ye=>S.fetchers.delete(ye))}function ue(ee,ie,{flushSync:fe}={}){var We,Ce;let we=S.actionData!=null&&S.navigation.formMethod!=null&&qn(S.navigation.formMethod)&&S.navigation.state==="loading"&&((We=ee.state)==null?void 0:We._isRedirect)!==!0,ye;ie.actionData?Object.keys(ie.actionData).length>0?ye=ie.actionData:ye=null:we?ye=S.actionData:ye=null;let Le=ie.loaderData?Fh(S.loaderData,ie.loaderData,ie.matches||[],ie.errors):S.loaderData,$e=S.blockers;$e.size>0&&($e=new Map($e),$e.forEach((ke,Je)=>$e.set(Je,Es)));let De=R?!1:Ke(ee,ie.matches||S.matches),Ve=A===!0||S.navigation.formMethod!=null&&qn(S.navigation.formMethod)&&((Ce=ee.state)==null?void 0:Ce._isRedirect)!==!0;l&&(i=l,l=void 0),R||j==="POP"||(j==="PUSH"?e.history.push(ee,ee.state):j==="REPLACE"&&e.history.replace(ee,ee.state));let Xe;if(j==="POP"){let ke=F.get(S.location.pathname);ke&&ke.has(ee.pathname)?Xe={currentLocation:S.location,nextLocation:ee}:F.has(ee.pathname)&&(Xe={currentLocation:ee,nextLocation:S.location})}else if(P){let ke=F.get(S.location.pathname);ke?ke.add(ee.pathname):(ke=new Set([ee.pathname]),F.set(S.location.pathname,ke)),Xe={currentLocation:S.location,nextLocation:ee}}re({...ie,actionData:ye,loaderData:Le,historyAction:j,location:ee,initialized:!0,navigation:Fc,revalidation:"idle",restoreScrollPosition:De,preventScrollReset:Ve,blockers:$e},{viewTransitionOpts:Xe,flushSync:fe===!0}),j="POP",A=!1,P=!1,R=!1,y=!1,te==null||te.resolve(),te=null}async function ce(ee,ie){if(typeof ee=="number"){e.history.go(ee);return}let fe=Mu(S.location,S.matches,c,ee,ie==null?void 0:ie.fromRouteId,ie==null?void 0:ie.relative),{path:we,submission:ye,error:Le}=Th(!1,fe,ie),$e=S.location,De=La(S.location,we,ie&&ie.state);De={...De,...e.history.encodeLocation(De)};let Ve=ie&&ie.replace!=null?ie.replace:void 0,Xe="PUSH";Ve===!0?Xe="REPLACE":Ve===!1||ye!=null&&qn(ye.formMethod)&&ye.formAction===S.location.pathname+S.location.search&&(Xe="REPLACE");let We=ie&&"preventScrollReset"in ie?ie.preventScrollReset===!0:void 0,Ce=(ie&&ie.flushSync)===!0,ke=Ie({currentLocation:$e,nextLocation:De,historyAction:Xe});if(ke){Re(ke,{state:"blocked",location:De,proceed(){Re(ke,{state:"proceeding",proceed:void 0,reset:void 0,location:De}),ce(ee,ie)},reset(){let Je=new Map(S.blockers);Je.set(ke,Es),re({blockers:Je})}});return}await k(Xe,De,{submission:ye,pendingError:Le,preventScrollReset:We,replace:ie&&ie.replace,enableViewTransition:ie&&ie.viewTransition,flushSync:Ce})}function pe(){te||(te=hS()),se(),re({revalidation:"loading"});let ee=te.promise;return S.navigation.state==="submitting"?ee:S.navigation.state==="idle"?(k(S.historyAction,S.location,{startUninterruptedRevalidation:!0}),ee):(k(j||S.historyAction,S.navigation.location,{overrideNavigation:S.navigation,enableViewTransition:P===!0}),ee)}async function k(ee,ie,fe){I&&I.abort(),I=null,j=ee,R=(fe&&fe.startUninterruptedRevalidation)===!0,Pt(S.location,S.matches),A=(fe&&fe.preventScrollReset)===!0,P=(fe&&fe.enableViewTransition)===!0;let we=l||i,ye=fe&&fe.overrideNavigation,Le=fe!=null&&fe.initialHydration&&S.matches&&S.matches.length>0&&!b?S.matches:_o(we,ie,c),$e=(fe&&fe.flushSync)===!0;if(Le&&S.initialized&&!y&&oS(S.location,ie)&&!(fe&&fe.submission&&qn(fe.submission.formMethod))){ue(ie,{matches:Le},{flushSync:$e});return}let De=st(Le,we,ie.pathname);if(De.active&&De.matches&&(Le=De.matches),!Le){let{error:Tt,notFoundMatches:_e,route:Q}=Pe(ie.pathname);ue(ie,{matches:_e,loaderData:{},errors:{[Q.id]:Tt}},{flushSync:$e});return}I=new AbortController;let Ve=Ns(e.history,ie,I.signal,fe&&fe.submission),Xe=e.getContext?await e.getContext():new Eh,We;if(fe&&fe.pendingError)We=[ko(Le).route.id,{type:"error",error:fe.pendingError}];else if(fe&&fe.submission&&qn(fe.submission.formMethod)){let Tt=await oe(Ve,ie,fe.submission,Le,Xe,De.active,fe&&fe.initialHydration===!0,{replace:fe.replace,flushSync:$e});if(Tt.shortCircuited)return;if(Tt.pendingActionResult){let[_e,Q]=Tt.pendingActionResult;if(rr(Q)&&za(Q.error)&&Q.error.status===404){I=null,ue(ie,{matches:Tt.matches,loaderData:{},errors:{[_e]:Q.error}});return}}Le=Tt.matches||Le,We=Tt.pendingActionResult,ye=zc(ie,fe.submission),$e=!1,De.active=!1,Ve=Ns(e.history,Ve.url,Ve.signal)}let{shortCircuited:Ce,matches:ke,loaderData:Je,errors:He}=await ae(Ve,ie,Le,Xe,De.active,ye,fe&&fe.submission,fe&&fe.fetcherSubmission,fe&&fe.replace,fe&&fe.initialHydration===!0,$e,We);Ce||(I=null,ue(ie,{matches:ke||Le,...zh(We),loaderData:Je,errors:He}))}async function oe(ee,ie,fe,we,ye,Le,$e,De={}){se();let Ve=cS(ie,fe);if(re({navigation:Ve},{flushSync:De.flushSync===!0}),Le){let Ce=await yt(we,ie.pathname,ee.signal);if(Ce.type==="aborted")return{shortCircuited:!0};if(Ce.type==="error"){if(Ce.partialMatches.length===0){let{matches:Je,route:He}=Si(i);return{matches:Je,pendingActionResult:[He.id,{type:"error",error:Ce.error}]}}let ke=ko(Ce.partialMatches).route.id;return{matches:Ce.partialMatches,pendingActionResult:[ke,{type:"error",error:Ce.error}]}}else if(Ce.matches)we=Ce.matches;else{let{notFoundMatches:ke,error:Je,route:He}=Pe(ie.pathname);return{matches:ke,pendingActionResult:[He.id,{type:"error",error:Je}]}}}let Xe,We=Qi(we,ie);if(!We.route.action&&!We.route.lazy)Xe={type:"error",error:mr(405,{method:ee.method,pathname:ie.pathname,routeId:We.route.id})};else{let Ce=Ls(o,a,ee,we,We,$e?[]:r,ye),ke=await le(ee,Ce,ye,null);if(Xe=ke[We.route.id],!Xe){for(let Je of we)if(ke[Je.route.id]){Xe=ke[Je.route.id];break}}if(ee.signal.aborted)return{shortCircuited:!0}}if(Ko(Xe)){let Ce;return De&&De.replace!=null?Ce=De.replace:Ce=Dh(Xe.response.headers.get("Location"),new URL(ee.url),c)===S.location.pathname+S.location.search,await Z(ee,Xe,!0,{submission:fe,replace:Ce}),{shortCircuited:!0}}if(rr(Xe)){let Ce=ko(we,We.route.id);return(De&&De.replace)!==!0&&(j="PUSH"),{matches:we,pendingActionResult:[Ce.route.id,Xe,We.route.id]}}return{matches:we,pendingActionResult:[We.route.id,Xe]}}async function ae(ee,ie,fe,we,ye,Le,$e,De,Ve,Xe,We,Ce){let ke=Le||zc(ie,$e),Je=$e||De||Uh(ke),He=!R&&!Xe;if(ye){if(He){let Qt=G(Ce);re({navigation:ke,...Qt!==void 0?{actionData:Qt}:{}},{flushSync:We})}let qe=await yt(fe,ie.pathname,ee.signal);if(qe.type==="aborted")return{shortCircuited:!0};if(qe.type==="error"){if(qe.partialMatches.length===0){let{matches:Zn,route:dr}=Si(i);return{matches:Zn,loaderData:{},errors:{[dr.id]:qe.error}}}let Qt=ko(qe.partialMatches).route.id;return{matches:qe.partialMatches,loaderData:{},errors:{[Qt]:qe.error}}}else if(qe.matches)fe=qe.matches;else{let{error:Qt,notFoundMatches:Zn,route:dr}=Pe(ie.pathname);return{matches:Zn,loaderData:{},errors:{[dr.id]:Qt}}}}let Tt=l||i,{dsMatches:_e,revalidatingFetchers:Q}=Ah(ee,we,o,a,e.history,S,fe,Je,ie,Xe?[]:r,Xe===!0,y,T,U,z,J,Tt,c,e.patchRoutesOnNavigation!=null,Ce);if(O=++L,!e.dataStrategy&&!_e.some(qe=>qe.shouldLoad)&&!_e.some(qe=>qe.route.middleware&&qe.route.middleware.length>0)&&Q.length===0){let qe=Ot();return ue(ie,{matches:fe,loaderData:{},errors:Ce&&rr(Ce[1])?{[Ce[0]]:Ce[1].error}:null,...zh(Ce),...qe?{fetchers:new Map(S.fetchers)}:{}},{flushSync:We}),{shortCircuited:!0}}if(He){let qe={};if(!ye){qe.navigation=ke;let Qt=G(Ce);Qt!==void 0&&(qe.actionData=Qt)}Q.length>0&&(qe.fetchers=V(Q)),re(qe,{flushSync:We})}Q.forEach(qe=>{Rt(qe.key),qe.controller&&D.set(qe.key,qe.controller)});let ve=()=>Q.forEach(qe=>Rt(qe.key));I&&I.signal.addEventListener("abort",ve);let{loaderResults:be,fetcherResults:ut}=await de(_e,Q,ee,we);if(ee.signal.aborted)return{shortCircuited:!0};I&&I.signal.removeEventListener("abort",ve),Q.forEach(qe=>D.delete(qe.key));let Fe=_i(be);if(Fe)return await Z(ee,Fe.result,!0,{replace:Ve}),{shortCircuited:!0};if(Fe=_i(ut),Fe)return J.add(Fe.key),await Z(ee,Fe.result,!0,{replace:Ve}),{shortCircuited:!0};let{loaderData:tt,errors:Ct}=Lh(S,fe,be,Ce,Q,ut);Xe&&S.errors&&(Ct={...S.errors,...Ct});let lt=Ot(),Et=Jt(O),hn=lt||Et||Q.length>0;return{matches:fe,loaderData:tt,errors:Ct,...hn?{fetchers:new Map(S.fetchers)}:{}}}function G(ee){if(ee&&!rr(ee[1]))return{[ee[0]]:ee[1].data};if(S.actionData)return Object.keys(S.actionData).length===0?null:S.actionData}function V(ee){return ee.forEach(ie=>{let fe=S.fetchers.get(ie.key),we=ma(void 0,fe?fe.data:void 0);S.fetchers.set(ie.key,we)}),new Map(S.fetchers)}async function ne(ee,ie,fe,we){Rt(ee);let ye=(we&&we.flushSync)===!0,Le=l||i,$e=Mu(S.location,S.matches,c,fe,ie,we==null?void 0:we.relative),De=_o(Le,$e,c),Ve=st(De,Le,$e);if(Ve.active&&Ve.matches&&(De=Ve.matches),!De){Ee(ee,ie,mr(404,{pathname:$e}),{flushSync:ye});return}let{path:Xe,submission:We,error:Ce}=Th(!0,$e,we);if(Ce){Ee(ee,ie,Ce,{flushSync:ye});return}let ke=e.getContext?await e.getContext():new Eh,Je=(we&&we.preventScrollReset)===!0;if(We&&qn(We.formMethod)){await B(ee,ie,Xe,De,ke,Ve.active,ye,Je,We);return}z.set(ee,{routeId:ie,path:Xe}),await K(ee,ie,Xe,De,ke,Ve.active,ye,Je,We)}async function B(ee,ie,fe,we,ye,Le,$e,De,Ve){se(),z.delete(ee);let Xe=S.fetchers.get(ee);he(ee,uS(Ve,Xe),{flushSync:$e});let We=new AbortController,Ce=Ns(e.history,fe,We.signal,Ve);if(Le){let Gt=await yt(we,new URL(Ce.url).pathname,Ce.signal,ee);if(Gt.type==="aborted")return;if(Gt.type==="error"){Ee(ee,ie,Gt.error,{flushSync:$e});return}else if(Gt.matches)we=Gt.matches;else{Ee(ee,ie,mr(404,{pathname:fe}),{flushSync:$e});return}}let ke=Qi(we,fe);if(!ke.route.action&&!ke.route.lazy){let Gt=mr(405,{method:Ve.formMethod,pathname:fe,routeId:ie});Ee(ee,ie,Gt,{flushSync:$e});return}D.set(ee,We);let Je=L,He=Ls(o,a,Ce,we,ke,r,ye),_e=(await le(Ce,He,ye,ee))[ke.route.id];if(Ce.signal.aborted){D.get(ee)===We&&D.delete(ee);return}if(U.has(ee)){if(Ko(_e)||rr(_e)){he(ee,so(void 0));return}}else{if(Ko(_e))if(D.delete(ee),O>Je){he(ee,so(void 0));return}else return J.add(ee),he(ee,ma(Ve)),Z(Ce,_e,!1,{fetcherSubmission:Ve,preventScrollReset:De});if(rr(_e)){Ee(ee,ie,_e.error);return}}let Q=S.navigation.location||S.location,ve=Ns(e.history,Q,We.signal),be=l||i,ut=S.navigation.state!=="idle"?_o(be,S.navigation.location,c):S.matches;wt(ut,"Didn't find any matches after fetcher action");let Fe=++L;M.set(ee,Fe);let tt=ma(Ve,_e.data);S.fetchers.set(ee,tt);let{dsMatches:Ct,revalidatingFetchers:lt}=Ah(ve,ye,o,a,e.history,S,ut,Ve,Q,r,!1,y,T,U,z,J,be,c,e.patchRoutesOnNavigation!=null,[ke.route.id,_e]);lt.filter(Gt=>Gt.key!==ee).forEach(Gt=>{let Wt=Gt.key,fr=S.fetchers.get(Wt),no=ma(void 0,fr?fr.data:void 0);S.fetchers.set(Wt,no),Rt(Wt),Gt.controller&&D.set(Wt,Gt.controller)}),re({fetchers:new Map(S.fetchers)});let Et=()=>lt.forEach(Gt=>Rt(Gt.key));We.signal.addEventListener("abort",Et);let{loaderResults:hn,fetcherResults:qe}=await de(Ct,lt,ve,ye);if(We.signal.aborted)return;if(We.signal.removeEventListener("abort",Et),M.delete(ee),D.delete(ee),lt.forEach(Gt=>D.delete(Gt.key)),S.fetchers.has(ee)){let Gt=so(_e.data);S.fetchers.set(ee,Gt)}let Qt=_i(hn);if(Qt)return Z(ve,Qt.result,!1,{preventScrollReset:De});if(Qt=_i(qe),Qt)return J.add(Qt.key),Z(ve,Qt.result,!1,{preventScrollReset:De});let{loaderData:Zn,errors:dr}=Lh(S,ut,hn,void 0,lt,qe);Jt(Fe),S.navigation.state==="loading"&&Fe>O?(wt(j,"Expected pending action"),I&&I.abort(),ue(S.navigation.location,{matches:ut,loaderData:Zn,errors:dr,fetchers:new Map(S.fetchers)})):(re({errors:dr,loaderData:Fh(S.loaderData,Zn,ut,dr),fetchers:new Map(S.fetchers)}),y=!1)}async function K(ee,ie,fe,we,ye,Le,$e,De,Ve){let Xe=S.fetchers.get(ee);he(ee,ma(Ve,Xe?Xe.data:void 0),{flushSync:$e});let We=new AbortController,Ce=Ns(e.history,fe,We.signal);if(Le){let Q=await yt(we,new URL(Ce.url).pathname,Ce.signal,ee);if(Q.type==="aborted")return;if(Q.type==="error"){Ee(ee,ie,Q.error,{flushSync:$e});return}else if(Q.matches)we=Q.matches;else{Ee(ee,ie,mr(404,{pathname:fe}),{flushSync:$e});return}}let ke=Qi(we,fe);D.set(ee,We);let Je=L,He=Ls(o,a,Ce,we,ke,r,ye),_e=(await le(Ce,He,ye,ee))[ke.route.id];if(D.get(ee)===We&&D.delete(ee),!Ce.signal.aborted){if(U.has(ee)){he(ee,so(void 0));return}if(Ko(_e))if(O>Je){he(ee,so(void 0));return}else{J.add(ee),await Z(Ce,_e,!1,{preventScrollReset:De});return}if(rr(_e)){Ee(ee,ie,_e.error);return}he(ee,so(_e.data))}}async function Z(ee,ie,fe,{submission:we,fetcherSubmission:ye,preventScrollReset:Le,replace:$e}={}){ie.response.headers.has("X-Remix-Revalidate")&&(y=!0);let De=ie.response.headers.get("Location");wt(De,"Expected a Location header on the redirect Response"),De=Dh(De,new URL(ee.url),c);let Ve=La(S.location,De,{_isRedirect:!0});if(n){let He=!1;if(ie.response.headers.has("X-Remix-Reload-Document"))He=!0;else if(Dd(De)){const Tt=Pg(De,!0);He=Tt.origin!==t.location.origin||Qn(Tt.pathname,c)==null}if(He){$e?t.location.replace(De):t.location.assign(De);return}}I=null;let Xe=$e===!0||ie.response.headers.has("X-Remix-Replace")?"REPLACE":"PUSH",{formMethod:We,formAction:Ce,formEncType:ke}=S.navigation;!we&&!ye&&We&&Ce&&ke&&(we=Uh(S.navigation));let Je=we||ye;if(UC.has(ie.response.status)&&Je&&qn(Je.formMethod))await k(Xe,Ve,{submission:{...Je,formAction:De},preventScrollReset:Le||A,enableViewTransition:fe?P:void 0});else{let He=zc(Ve,we);await k(Xe,Ve,{overrideNavigation:He,fetcherSubmission:ye,preventScrollReset:Le||A,enableViewTransition:fe?P:void 0})}}async function le(ee,ie,fe,we){let ye,Le={};try{ye=await JC(u,ee,ie,we,fe,!1)}catch($e){return ie.filter(De=>De.shouldLoad).forEach(De=>{Le[De.route.id]={type:"error",error:$e}}),Le}if(ee.signal.aborted)return Le;for(let[$e,De]of Object.entries(ye))if(iS(De)){let Ve=De.result;Le[$e]={type:"redirect",response:nS(Ve,ee,$e,ie,c)}}else Le[$e]=await tS(De);return Le}async function de(ee,ie,fe,we){let ye=le(fe,ee,we,null),Le=Promise.all(ie.map(async Ve=>{if(Ve.matches&&Ve.match&&Ve.request&&Ve.controller){let We=(await le(Ve.request,Ve.matches,we,Ve.key))[Ve.match.route.id];return{[Ve.key]:We}}else return Promise.resolve({[Ve.key]:{type:"error",error:mr(404,{pathname:Ve.path})}})})),$e=await ye,De=(await Le).reduce((Ve,Xe)=>Object.assign(Ve,Xe),{});return{loaderResults:$e,fetcherResults:De}}function se(){y=!0,z.forEach((ee,ie)=>{D.has(ie)&&T.add(ie),Rt(ie)})}function he(ee,ie,fe={}){S.fetchers.set(ee,ie),re({fetchers:new Map(S.fetchers)},{flushSync:(fe&&fe.flushSync)===!0})}function Ee(ee,ie,fe,we={}){let ye=ko(S.matches,ie);Lt(ee),re({errors:{[ye.route.id]:fe},fetchers:new Map(S.fetchers)},{flushSync:(we&&we.flushSync)===!0})}function Ae(ee){return H.set(ee,(H.get(ee)||0)+1),U.has(ee)&&U.delete(ee),S.fetchers.get(ee)||BC}function pt(ee,ie){Rt(ee,ie==null?void 0:ie.reason),he(ee,so(null))}function Lt(ee){let ie=S.fetchers.get(ee);D.has(ee)&&!(ie&&ie.state==="loading"&&M.has(ee))&&Rt(ee),z.delete(ee),M.delete(ee),J.delete(ee),U.delete(ee),T.delete(ee),S.fetchers.delete(ee)}function jt(ee){let ie=(H.get(ee)||0)-1;ie<=0?(H.delete(ee),U.add(ee)):H.set(ee,ie),re({fetchers:new Map(S.fetchers)})}function Rt(ee,ie){let fe=D.get(ee);fe&&(fe.abort(ie),D.delete(ee))}function it(ee){for(let ie of ee){let fe=Ae(ie),we=so(fe.data);S.fetchers.set(ie,we)}}function Ot(){let ee=[],ie=!1;for(let fe of J){let we=S.fetchers.get(fe);wt(we,`Expected fetcher: ${fe}`),we.state==="loading"&&(J.delete(fe),ee.push(fe),ie=!0)}return it(ee),ie}function Jt(ee){let ie=[];for(let[fe,we]of M)if(we<ee){let ye=S.fetchers.get(fe);wt(ye,`Expected fetcher: ${fe}`),ye.state==="loading"&&(Rt(fe),M.delete(fe),ie.push(fe))}return it(ie),ie.length>0}function Ft(ee,ie){let fe=S.blockers.get(ee)||Es;return X.get(ee)!==ie&&X.set(ee,ie),fe}function xe(ee){S.blockers.delete(ee),X.delete(ee)}function Re(ee,ie){let fe=S.blockers.get(ee)||Es;wt(fe.state==="unblocked"&&ie.state==="blocked"||fe.state==="blocked"&&ie.state==="blocked"||fe.state==="blocked"&&ie.state==="proceeding"||fe.state==="blocked"&&ie.state==="unblocked"||fe.state==="proceeding"&&ie.state==="unblocked",`Invalid blocker state transition: ${fe.state} -> ${ie.state}`);let we=new Map(S.blockers);we.set(ee,ie),re({blockers:we})}function Ie({currentLocation:ee,nextLocation:ie,historyAction:fe}){if(X.size===0)return;X.size>1&&un(!1,"A router only supports one blocker at a time");let we=Array.from(X.entries()),[ye,Le]=we[we.length-1],$e=S.blockers.get(ye);if(!($e&&$e.state==="proceeding")&&Le({currentLocation:ee,nextLocation:ie,historyAction:fe}))return ye}function Pe(ee){let ie=mr(404,{pathname:ee}),fe=l||i,{matches:we,route:ye}=Si(fe);return{notFoundMatches:we,route:ye,error:ie}}function ot(ee,ie,fe){if(m=ee,g=ie,x=fe||null,!v&&S.navigation===Fc){v=!0;let we=Ke(S.location,S.matches);we!=null&&re({restoreScrollPosition:we})}return()=>{m=null,g=null,x=null}}function Me(ee,ie){return x&&x(ee,ie.map(we=>vC(we,S.loaderData)))||ee.key}function Pt(ee,ie){if(m&&g){let fe=Me(ee,ie);m[fe]=g()}}function Ke(ee,ie){if(m){let fe=Me(ee,ie),we=m[fe];if(typeof we=="number")return we}return null}function st(ee,ie,fe){if(e.patchRoutesOnNavigation)if(ee){if(Object.keys(ee[0].params).length>0)return{active:!0,matches:Ji(ie,fe,c,!0)}}else return{active:!0,matches:Ji(ie,fe,c,!0)||[]};return{active:!1,matches:null}}async function yt(ee,ie,fe,we){if(!e.patchRoutesOnNavigation)return{type:"success",matches:ee};let ye=ee;for(;;){let Le=l==null,$e=l||i,De=a;try{await e.patchRoutesOnNavigation({signal:fe,path:ie,matches:ye,fetcherKey:we,patch:(We,Ce)=>{fe.aborted||Ih(We,Ce,$e,De,o,!1)}})}catch(We){return{type:"error",error:We,partialMatches:ye}}finally{Le&&!fe.aborted&&(i=[...i])}if(fe.aborted)return{type:"aborted"};let Ve=_o($e,ie,c);if(Ve)return{type:"success",matches:Ve};let Xe=Ji($e,ie,c,!0);if(!Xe||ye.length===Xe.length&&ye.every((We,Ce)=>We.route.id===Xe[Ce].route.id))return{type:"success",matches:null};ye=Xe}}function en(ee){a={},l=Fa(ee,o,void 0,a)}function Rn(ee,ie,fe=!1){let we=l==null;Ih(ee,ie,l||i,a,o,fe),we&&(i=[...i],re({}))}return E={get basename(){return c},get future(){return f},get state(){return S},get routes(){return i},get window(){return t},initialize:$,subscribe:Y,enableScrollRestoration:ot,navigate:ce,fetch:ne,revalidate:pe,createHref:ee=>e.history.createHref(ee),encodeLocation:ee=>e.history.encodeLocation(ee),getFetcher:Ae,resetFetcher:pt,deleteFetcher:jt,dispose:q,getBlocker:Ft,deleteBlocker:xe,patchRoutes:Rn,_internalFetchControllers:D,_internalSetRoutes:en,_internalSetStateDoNotUseOrYouWillBreakYourApp(ee){re(ee)}},E}function ZC(e){return e!=null&&("formData"in e&&e.formData!=null||"body"in e&&e.body!==void 0)}function Mu(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=Vl(r||".",Bl(i),Qn(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=Ld(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(m=>m).forEach(m=>f.append("index",m));let p=f.toString();c.search=p?`?${p}`:""}}return n!=="/"&&(c.pathname=IC({basename:n,pathname:c.pathname})),Ro(c)}function Th(e,t,n){if(!n||!ZC(n))return{path:t};if(n.formMethod&&!lS(n.formMethod))return{path:t,error:mr(405,{method:n.formMethod})};let r=()=>({path:t,error:mr(400,{type:"invalid-body"})}),a=(n.formMethod||"get").toUpperCase(),i=Hg(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((p,[m,x])=>`${p}${m}=${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()}}}wt(typeof FormData=="function","FormData is not available in this environment");let l,c;if(n.formData)l=Lu(n.formData),c=n.formData;else if(n.body instanceof FormData)l=Lu(n.body),c=n.body;else if(n.body instanceof URLSearchParams)l=n.body,c=Oh(l);else if(n.body==null)l=new URLSearchParams,c=new FormData;else try{l=new URLSearchParams(n.body),c=Oh(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=vo(t);return e&&f.search&&Ld(f.search)&&l.append("index",""),f.search=`?${l}`,{path:Ro(f),submission:u}}function Ah(e,t,n,r,o,a,i,l,c,u,f,h,p,m,x,g,v,w,b,C){var R;let _=C?rr(C[1])?C[1].error:C[1].data:void 0,E=o.createURL(a.location),S=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&&rr(C[1])){let y=C[0];j=i.findIndex(T=>T.route.id===y)-1}let A=C?C[1].statusCode:void 0,I=A&&A>=400,P={currentUrl:E,currentParams:((R=a.matches[0])==null?void 0:R.params)||{},nextUrl:S,nextParams:i[0].params,...l,actionResult:_,actionStatus:A},F=i.map((y,T)=>{let{route:D}=y,L=null;if(j!=null&&T>j?L=!1:D.lazy?L=!0:Od(D)?f?L=Du(D,a.loaderData,a.errors):GC(a.loaderData,a.matches[T],y)&&(L=!0):L=!1,L!==null)return Ou(n,r,e,y,u,t,L);let O=I?!1:h||E.pathname+E.search===S.pathname+S.search||E.search!==S.search||YC(a.matches[T],y),M={...P,defaultShouldRevalidate:O},J=pl(y,M);return Ou(n,r,e,y,u,t,J,M)}),N=[];return x.forEach((y,T)=>{if(f||!i.some(U=>U.route.id===y.routeId)||m.has(T))return;let D=a.fetchers.get(T),L=D&&D.state!=="idle"&&D.data===void 0,O=_o(v,y.path,w);if(!O){if(b&&L)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 M=Qi(O,y.path),J=new AbortController,z=Ns(o,y.path,J.signal),H=null;if(p.has(T))p.delete(T),H=Ls(n,r,z,O,M,u,t);else if(L)h&&(H=Ls(n,r,z,O,M,u,t));else{let U={...P,defaultShouldRevalidate:I?!1:h};pl(M,U)&&(H=Ls(n,r,z,O,M,u,t,U))}H&&N.push({key:T,routeId:y.routeId,path:y.path,matches:H,match:M,request:z,controller:J})}),{dsMatches:F,revalidatingFetchers:N}}function Od(e){return e.loader!=null||e.middleware!=null&&e.middleware.length>0}function Du(e,t,n){if(e.lazy)return!0;if(!Od(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 GC(e,t,n){let r=!t||n.route.id!==t.route.id,o=!e.hasOwnProperty(n.route.id);return r||o}function YC(e,t){let n=e.route.path;return e.pathname!==t.pathname||n!=null&&n.endsWith("*")&&e.params["*"]!==t.params["*"]}function pl(e,t){if(e.route.shouldRevalidate){let n=e.route.shouldRevalidate(t);if(typeof n=="boolean")return n}return t.defaultShouldRevalidate}function Ih(e,t,n,r,o,a){let i;if(e){let u=r[e];wt(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=>$g(u,h));f?c.push({existingRoute:f,newRoute:u}):l.push(u)}),l.length>0){let u=Fa(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],p=f,[m]=Fa([h],o,[],{},!0);Object.assign(p,{element:m.element?m.element:p.element,errorElement:m.errorElement?m.errorElement:p.errorElement,hydrateFallbackElement:m.hydrateFallbackElement?m.hydrateFallbackElement:p.hydrateFallbackElement})}}function $g(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=>$g(n,a))}):!1}var Rh=new WeakMap,Ug=({key:e,route:t,manifest:n,mapRouteProperties:r})=>{let o=n[t.id];if(wt(o,"No route found in manifest"),!o.lazy||typeof o.lazy!="object")return;let a=o.lazy[e];if(!a)return;let i=Rh.get(o);i||(i={},Rh.set(o,i));let l=i[e];if(l)return l;let c=(async()=>{let u=pC(e),h=o[e]!==void 0&&e!=="hasErrorBoundary";if(u)un(!u,"Route property "+e+" is not a supported lazy route property. This property will be ignored."),i[e]=Promise.resolve();else if(h)un(!1,`Route "${o.id}" has a static property "${e}" defined. The lazy property will be ignored.`);else{let p=await a();p!=null&&(Object.assign(o,{[e]:p}),Object.assign(o,r(o)))}typeof o.lazy=="object"&&(o.lazy[e]=void 0,Object.values(o.lazy).every(p=>p===void 0)&&(o.lazy=void 0))})();return i[e]=c,c},Ph=new WeakMap;function KC(e,t,n,r,o){let a=n[e.id];if(wt(a,"No route found in manifest"),!e.lazy)return{lazyRoutePromise:void 0,lazyHandlerPromise:void 0};if(typeof e.lazy=="function"){let f=Ph.get(a);if(f)return{lazyRoutePromise:f,lazyHandlerPromise:f};let h=(async()=>{wt(typeof e.lazy=="function","No lazy route function found");let p=await e.lazy(),m={};for(let x in p){let g=p[x];if(g===void 0)continue;let v=gC(x),b=a[x]!==void 0&&x!=="hasErrorBoundary";v?un(!v,"Route property "+x+" is not a supported property to be returned from a lazy route function. This property will be ignored."):b?un(!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.`):m[x]=g}Object.assign(a,m),Object.assign(a,{...r(a),lazy:void 0})})();return Ph.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=Ug({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 Mh(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 qC(e){return e.matches.some(t=>t.route.middleware)?Bg(e,()=>Mh(e)):Mh(e)}function Bg(e,t){return XC(e,t,r=>r,sS,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=ko(i,i[l].route.id).route.id;return Promise.resolve({[c]:{type:"error",result:r}})}}}async function XC(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(p=>[h.route.id,p]):[]);return await Vg({request:i,params:l,context:c},u,t,n,r,o)}async function Vg(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,p=async()=>{if(h)throw new Error("You may only call `next()` once per middleware");try{return h={value:await Vg(e,t,n,r,o,a,i+1)},h.value}catch(m){return h={value:await a(m,u,h)},h.value}};try{let m=await f(e,p),x=m!=null?r(m):void 0;return o(x)?x:h?x??h.value:(h={value:await p()},h.value)}catch(m){return await a(m,u,h)}}function Wg(e,t,n,r,o){let a=Ug({key:"middleware",route:r.route,manifest:t,mapRouteProperties:e}),i=KC(r.route,qn(n.method)?"action":"loader",t,e,o);return{middleware:a,route:i.lazyRoutePromise,handler:i.lazyHandlerPromise}}function Ou(e,t,n,r,o,a,i,l=null){let c=!1,u=Wg(e,t,n,r,o);return{...r,_lazyPromises:u,shouldLoad:i,unstable_shouldRevalidateArgs:l,unstable_shouldCallHandler(f){return c=!0,l?typeof f=="boolean"?pl(r,{...l,defaultShouldRevalidate:f}):pl(r,l):i},resolve(f){let{lazy:h,loader:p,middleware:m}=r.route,x=c||i||f&&!qn(n.method)&&(h||p),g=m&&m.length>0&&!p&&!h;return x&&!g?QC({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 Ls(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:Wg(e,t,n,c,a),resolve:()=>Promise.resolve({type:"data",result:void 0})}:Ou(e,t,n,c,a,i,!0,l))}async function JC(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 Bg(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 QC({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 p,m=new Promise((v,w)=>p=w);l=()=>p(),e.signal.addEventListener("abort",l);let x=v=>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},...v!==void 0?[v]:[]),g=(async()=>{try{return{type:"data",result:await(o?o(w=>x(w)):x())}}catch(v){return{type:"error",result:v}}})();return Promise.race([g,m])};try{let h=c?t.route.action:t.route.loader;if(n||r)if(h){let p,[m]=await Promise.all([f(h).catch(x=>{p=x}),n,r]);if(p!==void 0)throw p;i=m}else{await n;let p=c?t.route.action:t.route.loader;if(p)[i]=await Promise.all([f(p),r]);else if(u==="action"){let m=new URL(e.url),x=m.pathname+m.search;throw mr(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 p=new URL(e.url),m=p.pathname+p.search;throw mr(404,{pathname:m})}}catch(h){return{type:"error",result:h}}finally{l&&e.signal.removeEventListener("abort",l)}return i}async function eS(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 tS(e){var r,o,a,i,l,c;let{result:t,type:n}=e;if(Zg(t)){let u;try{u=await eS(t)}catch(f){return{type:"error",error:f}}return n==="error"?{type:"error",error:new hl(t.status,t.statusText,u),statusCode:t.status,headers:t.headers}:{type:"data",data:u,statusCode:t.status,headers:t.headers}}return n==="error"?$h(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 hl(((a=t.init)==null?void 0:a.status)||500,void 0,t.data),statusCode:za(t)?t.status:void 0,headers:(i=t.init)!=null&&i.headers?new Headers(t.init.headers):void 0}:{type:"error",error:t,statusCode:za(t)?t.status:void 0}:$h(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 nS(e,t,n,r,o){let a=e.headers.get("Location");if(wt(a,"Redirects returned/thrown from loaders/actions must have a Location header"),!Dd(a)){let i=r.slice(0,r.findIndex(l=>l.route.id===n)+1);a=Mu(new URL(t.url),i,o,a),e.headers.set("Location",a)}return e}function Dh(e,t,n){if(Dd(e)){let r=e,o=r.startsWith("//")?new URL(t.protocol+r):new URL(r),a=Qn(o.pathname,n)!=null;if(o.origin===t.origin&&a)return o.pathname+o.search+o.hash}return e}function Ns(e,t,n,r){let o=e.createURL(Hg(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=Lu(r.formData):a.body=r.formData}return new Request(o,a)}function Lu(e){let t=new URLSearchParams;for(let[n,r]of e.entries())t.append(n,typeof r=="string"?r:r.name);return t}function Oh(e){let t=new FormData;for(let[n,r]of e.entries())t.append(n,r);return t}function rS(e,t,n,r=!1,o=!1){let a={},i=null,l,c=!1,u={},f=n&&rr(n[1])?n[1].error:void 0;return e.forEach(h=>{if(!(h.route.id in t))return;let p=h.route.id,m=t[p];if(wt(!Ko(m),"Cannot handle redirect results in processLoaderData"),rr(m)){let x=m.error;if(f!==void 0&&(x=f,f=void 0),i=i||{},o)i[p]=x;else{let g=ko(e,p);i[g.route.id]==null&&(i[g.route.id]=x)}r||(a[p]=zg),c||(c=!0,l=za(m.error)?m.error.status:500),m.headers&&(u[p]=m.headers)}else a[p]=m.data,m.statusCode&&m.statusCode!==200&&!c&&(l=m.statusCode),m.headers&&(u[p]=m.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 Lh(e,t,n,r,o,a){let{loaderData:i,errors:l}=rS(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 p=a[u];if(wt(p,"Did not find corresponding fetcher result"),rr(p)){let m=ko(e.matches,f==null?void 0:f.route.id);l&&l[m.route.id]||(l={...l,[m.route.id]:p.error}),e.fetchers.delete(u)}else if(Ko(p))wt(!1,"Unhandled fetcher revalidation redirect");else{let m=so(p.data);e.fetchers.set(u,m)}}),{loaderData:i,errors:l}}function Fh(e,t,n,r){let o=Object.entries(t).filter(([,a])=>a!==zg).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 zh(e){return e?rr(e[1])?{actionData:{}}:{actionData:{[e[0]]:e[1].data}}:{}}function ko(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 Si(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 mr(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 hl(e||500,i,new Error(l),!0)}function _i(e){let t=Object.entries(e);for(let n=t.length-1;n>=0;n--){let[r,o]=t[n];if(Ko(o))return{key:r,result:o}}}function Hg(e){let t=typeof e=="string"?vo(e):e;return Ro({...t,hash:""})}function oS(e,t){return e.pathname!==t.pathname||e.search!==t.search?!1:e.hash===""?t.hash!=="":e.hash===t.hash?!0:t.hash!==""}function sS(e){return e!=null&&typeof e=="object"&&Object.entries(e).every(([t,n])=>typeof t=="string"&&aS(n))}function aS(e){return e!=null&&typeof e=="object"&&"type"in e&&"result"in e&&(e.type==="data"||e.type==="error")}function iS(e){return Zg(e.result)&&$C.has(e.result.status)}function rr(e){return e.type==="error"}function Ko(e){return(e&&e.type)==="redirect"}function $h(e){return typeof e=="object"&&e!=null&&"type"in e&&"data"in e&&"init"in e&&e.type==="DataWithResponseInit"}function Zg(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.headers=="object"&&typeof e.body<"u"}function lS(e){return zC.has(e.toUpperCase())}function qn(e){return LC.has(e.toUpperCase())}function Ld(e){return new URLSearchParams(e).getAll("index").some(t=>t==="")}function Qi(e,t){let n=typeof t=="string"?vo(t).search:t.search;if(e[e.length-1].route.index&&Ld(n||""))return e[e.length-1];let r=Og(e);return r[r.length-1]}function Uh(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 zc(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 cS(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 ma(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 uS(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 so(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 dS(e,t){try{let n=e.sessionStorage.getItem(Fg);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 fS(e,t){if(t.size>0){let n={};for(let[r,o]of t)n[r]=[...o];try{e.sessionStorage.setItem(Fg,JSON.stringify(n))}catch(r){un(!1,`Failed to save applied view transitions in sessionStorage (${r}).`)}}}function hS(){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 fs=d.createContext(null);fs.displayName="DataRouter";var ei=d.createContext(null);ei.displayName="DataRouterState";d.createContext(!1);var Fd=d.createContext({isTransitioning:!1});Fd.displayName="ViewTransition";var Gg=d.createContext(new Map);Gg.displayName="Fetchers";var pS=d.createContext(null);pS.displayName="Await";var Lr=d.createContext(null);Lr.displayName="Navigation";var Wl=d.createContext(null);Wl.displayName="Location";var Fr=d.createContext({outlet:null,matches:[],isDataRoute:!1});Fr.displayName="Route";var zd=d.createContext(null);zd.displayName="RouteError";function mS(e,{relative:t}={}){wt(aa(),"useHref() may be used only in the context of a <Router> component.");let{basename:n,navigator:r}=d.useContext(Lr),{hash:o,pathname:a,search:i}=ti(e,{relative:t}),l=a;return n!=="/"&&(l=a==="/"?n:Yr([n,a])),r.createHref({pathname:l,search:i,hash:o})}function aa(){return d.useContext(Wl)!=null}function zr(){return wt(aa(),"useLocation() may be used only in the context of a <Router> component."),d.useContext(Wl).location}var Yg="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function Kg(e){d.useContext(Lr).static||d.useLayoutEffect(e)}function zo(){let{isDataRoute:e}=d.useContext(Fr);return e?AS():gS()}function gS(){wt(aa(),"useNavigate() may be used only in the context of a <Router> component.");let e=d.useContext(fs),{basename:t,navigator:n}=d.useContext(Lr),{matches:r}=d.useContext(Fr),{pathname:o}=zr(),a=JSON.stringify(Bl(r)),i=d.useRef(!1);return Kg(()=>{i.current=!0}),d.useCallback((c,u={})=>{if(un(i.current,Yg),!i.current)return;if(typeof c=="number"){n.go(c);return}let f=Vl(c,JSON.parse(a),o,u.relative==="path");e==null&&t!=="/"&&(f.pathname=f.pathname==="/"?t:Yr([t,f.pathname])),(u.replace?n.replace:n.push)(f,u.state,u)},[t,n,a,o,e])}var xS=d.createContext(null);function vS(e){let t=d.useContext(Fr).outlet;return d.useMemo(()=>t&&d.createElement(xS.Provider,{value:e},t),[t,e])}function ti(e,{relative:t}={}){let{matches:n}=d.useContext(Fr),{pathname:r}=zr(),o=JSON.stringify(Bl(n));return d.useMemo(()=>Vl(e,JSON.parse(o),r,t==="path"),[e,o,r,t])}function wS(e,t,n,r,o){wt(aa(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:a}=d.useContext(Lr),{matches:i}=d.useContext(Fr),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||"";Jg(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 p=zr(),m;m=p;let x=m.pathname||"/",g=x;if(f!=="/"){let b=f.replace(/^\//,"").split("/");g="/"+x.replace(/^\//,"").split("/").slice(b.length).join("/")}let v=_o(e,{pathname:g});return un(h||v!=null,`No routes matched location "${m.pathname}${m.search}${m.hash}" `),un(v==null||v[v.length-1].route.element!==void 0||v[v.length-1].route.Component!==void 0||v[v.length-1].route.lazy!==void 0,`Matched leaf route at location "${m.pathname}${m.search}${m.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.`),_S(v&&v.map(b=>Object.assign({},b,{params:Object.assign({},c,b.params),pathname:Yr([f,a.encodeLocation?a.encodeLocation(b.pathname.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:b.pathname]),pathnameBase:b.pathnameBase==="/"?f:Yr([f,a.encodeLocation?a.encodeLocation(b.pathnameBase.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:b.pathnameBase])})),i,n,r,o)}function bS(){let e=ES(),t=za(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 yS=d.createElement(bS,null),CS=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(Fr.Provider,{value:this.props.routeContext},d.createElement(zd.Provider,{value:this.state.error,children:this.props.component})):this.props.children}};function SS({routeContext:e,match:t,children:n}){let r=d.useContext(fs);return r&&r.static&&r.staticContext&&(t.route.errorElement||t.route.ErrorBoundary)&&(r.staticContext._deepestRenderedBoundaryId=t.route.id),d.createElement(Fr.Provider,{value:e},n)}function _S(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);wt(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:p}=n,m=f.route.loader&&!h.hasOwnProperty(f.route.id)&&(!p||p[f.route.id]===void 0);if(f.route.lazy||m){l=!0,c>=0?a=a.slice(0,c+1):a=[a[0]];break}}}return a.reduceRight((u,f,h)=>{let p,m=!1,x=null,g=null;n&&(p=i&&f.route.id?i[f.route.id]:void 0,x=f.route.errorElement||yS,l&&(c<0&&h===0?(Jg("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),m=!0,g=null):c===h&&(m=!0,g=f.route.hydrateFallbackElement||null)));let v=t.concat(a.slice(0,h+1)),w=()=>{let b;return p?b=x:m?b=g:f.route.Component?b=d.createElement(f.route.Component,null):f.route.element?b=f.route.element:b=u,d.createElement(SS,{match:f,routeContext:{outlet:u,matches:v,isDataRoute:n!=null},children:b})};return n&&(f.route.ErrorBoundary||f.route.errorElement||h===0)?d.createElement(CS,{location:n.location,revalidation:n.revalidation,component:x,error:p,children:w(),routeContext:{outlet:null,matches:v,isDataRoute:!0},unstable_onError:r}):w()},null)}function $d(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function qg(e){let t=d.useContext(fs);return wt(t,$d(e)),t}function Ud(e){let t=d.useContext(ei);return wt(t,$d(e)),t}function kS(e){let t=d.useContext(Fr);return wt(t,$d(e)),t}function Hl(e){let t=kS(e),n=t.matches[t.matches.length-1];return wt(n.route.id,`${e} can only be used on routes that contain a unique "id"`),n.route.id}function jS(){return Hl("useRouteId")}function Xg(){let e=Ud("useLoaderData"),t=Hl("useLoaderData");return e.loaderData[t]}function ES(){var r;let e=d.useContext(zd),t=Ud("useRouteError"),n=Hl("useRouteError");return e!==void 0?e:(r=t.errors)==null?void 0:r[n]}var NS=0;function TS(e){let{router:t,basename:n}=qg("useBlocker"),r=Ud("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:Qn(c.pathname,n)||c.pathname},nextLocation:{...u,pathname:Qn(u.pathname,n)||u.pathname},historyAction:f})},[n,e]);return d.useEffect(()=>{let l=String(++NS);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):Es}function AS(){let{router:e}=qg("useNavigate"),t=Hl("useNavigate"),n=d.useRef(!1);return Kg(()=>{n.current=!0}),d.useCallback(async(o,a={})=>{un(n.current,Yg),n.current&&(typeof o=="number"?e.navigate(o):await e.navigate(o,{fromRouteId:t,...a}))},[e,t])}var Bh={};function Jg(e,t,n){!t&&!Bh[e]&&(Bh[e]=!0,un(!1,n))}var Vh={};function Wh(e,t){!e&&!Vh[t]&&(Vh[t]=!0,console.warn(t))}function IS(e){let t={hasErrorBoundary:e.hasErrorBoundary||e.ErrorBoundary!=null||e.errorElement!=null};return e.Component&&(e.element&&un(!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&&un(!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&&un(!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 RS=["HydrateFallback","hydrateFallbackElement"],PS=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 MS({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,p]=d.useState(),[m,x]=d.useState(),g=d.useRef(new Map),v=d.useCallback(E=>{o(S=>(E.errors&&n&&Object.entries(E.errors).forEach(([j,A])=>{var I;((I=S.errors)==null?void 0:I[j])!==A&&n(A)}),E))},[n]),w=d.useCallback((E,{deletedFetchers:S,flushSync:j,viewTransitionOpts:A})=>{E.fetchers.forEach((P,F)=>{P.data!==void 0&&g.current.set(F,P.data)}),S.forEach(P=>g.current.delete(P)),Wh(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 I=e.window!=null&&e.window.document!=null&&typeof e.window.document.startViewTransition=="function";if(Wh(A==null||I,"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||!I){t&&j?t(()=>v(E)):d.startTransition(()=>v(E));return}if(t&&j){t(()=>{h&&(u&&u.resolve(),h.skipTransition()),c({isTransitioning:!0,flushSync:!0,currentLocation:A.currentLocation,nextLocation:A.nextLocation})});let P=e.window.document.startViewTransition(()=>{t(()=>v(E))});P.finished.finally(()=>{t(()=>{f(void 0),p(void 0),i(void 0),c({isTransitioning:!1})})}),t(()=>p(P));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,v]);d.useLayoutEffect(()=>e.subscribe(w),[e,w]),d.useEffect(()=>{l.isTransitioning&&!l.flushSync&&f(new PS)},[l]),d.useEffect(()=>{if(u&&a&&e.window){let E=a,S=u.promise,j=e.window.document.startViewTransition(async()=>{d.startTransition(()=>v(E)),await S});j.finished.finally(()=>{f(void 0),p(void 0),i(void 0),c({isTransitioning:!1})}),p(j)}},[a,u,e.window,v]),d.useEffect(()=>{u&&a&&r.location.key===a.location.key&&u.resolve()},[u,h,r.location,a]),d.useEffect(()=>{!l.isTransitioning&&m&&(i(m.state),c({isTransitioning:!0,flushSync:!1,currentLocation:m.currentLocation,nextLocation:m.nextLocation}),x(void 0))},[l.isTransitioning,m]);let b=d.useMemo(()=>({createHref:e.createHref,encodeLocation:e.encodeLocation,go:E=>e.navigate(E),push:(E,S,j)=>e.navigate(E,{state:S,preventScrollReset:j==null?void 0:j.preventScrollReset}),replace:(E,S,j)=>e.navigate(E,{replace:!0,state:S,preventScrollReset:j==null?void 0:j.preventScrollReset})}),[e]),C=e.basename||"/",_=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(fs.Provider,{value:_},d.createElement(ei.Provider,{value:r},d.createElement(Gg.Provider,{value:g.current},d.createElement(Fd.Provider,{value:l},d.createElement(FS,{basename:C,location:r.location,navigationType:r.historyAction,navigator:b},d.createElement(DS,{routes:e.routes,future:e.future,state:r,unstable_onError:n})))))),null)}var DS=d.memo(OS);function OS({routes:e,future:t,state:n,unstable_onError:r}){return wS(e,void 0,n,r,t)}function Hh({to:e,replace:t,state:n,relative:r}){wt(aa(),"<Navigate> may be used only in the context of a <Router> component.");let{static:o}=d.useContext(Lr);un(!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(Fr),{pathname:i}=zr(),l=zo(),c=Vl(e,Bl(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 LS(e){return vS(e.context)}function FS({basename:e="/",children:t=null,location:n,navigationType:r="POP",navigator:o,static:a=!1}){wt(!aa(),"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=vo(n));let{pathname:c="/",search:u="",hash:f="",state:h=null,key:p="default"}=n,m=d.useMemo(()=>{let x=Qn(c,i);return x==null?null:{location:{pathname:x,search:u,hash:f,state:h,key:p},navigationType:r}},[i,c,u,f,h,p,r]);return un(m!=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.`),m==null?null:d.createElement(Lr.Provider,{value:l},d.createElement(Wl.Provider,{children:t,value:m}))}var el="get",tl="application/x-www-form-urlencoded";function Zl(e){return e!=null&&typeof e.tagName=="string"}function zS(e){return Zl(e)&&e.tagName.toLowerCase()==="button"}function $S(e){return Zl(e)&&e.tagName.toLowerCase()==="form"}function US(e){return Zl(e)&&e.tagName.toLowerCase()==="input"}function BS(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function VS(e,t){return e.button===0&&(!t||t==="_self")&&!BS(e)}var ki=null;function WS(){if(ki===null)try{new FormData(document.createElement("form"),0),ki=!1}catch{ki=!0}return ki}var HS=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function $c(e){return e!=null&&!HS.has(e)?(un(!1,`"${e}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${tl}"`),null):e}function ZS(e,t){let n,r,o,a,i;if($S(e)){let l=e.getAttribute("action");r=l?Qn(l,t):null,n=e.getAttribute("method")||el,o=$c(e.getAttribute("enctype"))||tl,a=new FormData(e)}else if(zS(e)||US(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?Qn(c,t):null,n=e.getAttribute("formmethod")||l.getAttribute("method")||el,o=$c(e.getAttribute("formenctype"))||$c(l.getAttribute("enctype"))||tl,a=new FormData(l,e),!WS()){let{name:u,type:f,value:h}=e;if(f==="image"){let p=u?`${u}.`:"";a.append(`${p}x`,"0"),a.append(`${p}y`,"0")}else u&&a.append(u,h)}}else{if(Zl(e))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');n=el,r=null,o=tl,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 Bd(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function GS(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&&Qn(r.pathname,t)==="/"?r.pathname=`${t.replace(/\/$/,"")}/_root.${n}`:r.pathname=`${r.pathname.replace(/\/$/,"")}.${n}`,r}async function YS(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 KS(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 qS(e,t,n){let r=await Promise.all(e.map(async o=>{let a=t.routes[o.route.id];if(a){let i=await YS(a,n);return i.links?i.links():[]}return[]}));return e_(r.flat(1).filter(KS).filter(o=>o.rel==="stylesheet"||o.rel==="preload").map(o=>o.rel==="stylesheet"?{...o,rel:"prefetch",as:"style"}:{...o,rel:"prefetch"}))}function Zh(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 p=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 p=="boolean")return p}return!0}):[]}function XS(e,t,{includeHydrateFallback:n}={}){return JS(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 JS(e){return[...new Set(e)]}function QS(e){let t={},n=Object.keys(e).sort();for(let r of n)t[r]=e[r];return t}function e_(e,t){let n=new Set;return new Set(t),e.reduce((r,o)=>{let a=JSON.stringify(QS(o));return n.has(a)||(n.add(a),r.push({key:a,link:o})),r},[])}function Qg(){let e=d.useContext(fs);return Bd(e,"You must render this element inside a <DataRouterContext.Provider> element"),e}function t_(){let e=d.useContext(ei);return Bd(e,"You must render this element inside a <DataRouterStateContext.Provider> element"),e}var Vd=d.createContext(void 0);Vd.displayName="FrameworkContext";function ex(){let e=d.useContext(Vd);return Bd(e,"You must render this element inside a <HydratedRouter> element"),e}function n_(e,t){let n=d.useContext(Vd),[r,o]=d.useState(!1),[a,i]=d.useState(!1),{onFocus:l,onBlur:c,onMouseEnter:u,onMouseLeave:f,onTouchStart:h}=t,p=d.useRef(null);d.useEffect(()=>{if(e==="render"&&i(!0),e==="viewport"){let g=w=>{w.forEach(b=>{i(b.isIntersecting)})},v=new IntersectionObserver(g,{threshold:.5});return p.current&&v.observe(p.current),()=>{v.disconnect()}}},[e]),d.useEffect(()=>{if(r){let g=setTimeout(()=>{i(!0)},100);return()=>{clearTimeout(g)}}},[r]);let m=()=>{o(!0)},x=()=>{o(!1),i(!1)};return n?e!=="intent"?[a,p,{}]:[a,p,{onFocus:ga(l,m),onBlur:ga(c,x),onMouseEnter:ga(u,m),onMouseLeave:ga(f,x),onTouchStart:ga(h,m)}]:[!1,p,{}]}function ga(e,t){return n=>{e&&e(n),n.defaultPrevented||t(n)}}function r_({page:e,...t}){let{router:n}=Qg(),r=d.useMemo(()=>_o(n.routes,e,n.basename),[n.routes,e,n.basename]);return r?d.createElement(s_,{page:e,matches:r,...t}):null}function o_(e){let{manifest:t,routeModules:n}=ex(),[r,o]=d.useState([]);return d.useEffect(()=>{let a=!1;return qS(e,t,n).then(i=>{a||o(i)}),()=>{a=!0}},[e,t,n]),r}function s_({page:e,matches:t,...n}){let r=zr(),{manifest:o,routeModules:a}=ex(),{basename:i}=Qg(),{loaderData:l,matches:c}=t_(),u=d.useMemo(()=>Zh(e,t,c,o,r,"data"),[e,t,c,o,r]),f=d.useMemo(()=>Zh(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(w=>{var C;let b=o.routes[w.route.id];!b||!b.hasLoader||(!u.some(_=>_.route.id===w.route.id)&&w.route.id in l&&((C=a[w.route.id])!=null&&C.shouldRevalidate)||b.hasClientLoader?g=!0:x.add(w.route.id))}),x.size===0)return[];let v=GS(e,i,"data");return g&&x.size>0&&v.searchParams.set("_routes",t.filter(w=>x.has(w.route.id)).map(w=>w.route.id).join(",")),[v.pathname+v.search]},[i,l,r,o,u,t,e,a]),p=d.useMemo(()=>XS(f,o),[f,o]),m=o_(f);return d.createElement(d.Fragment,null,h.map(x=>d.createElement("link",{key:x,rel:"prefetch",as:"fetch",href:x,...n})),p.map(x=>d.createElement("link",{key:x,rel:"modulepreload",href:x,...n})),m.map(({key:x,link:g})=>d.createElement("link",{key:x,nonce:n.nonce,...g})))}function a_(...e){return t=>{e.forEach(n=>{typeof n=="function"?n(t):n!=null&&(n.current=t)})}}var tx=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{tx&&(window.__reactRouterVersion="7.9.3")}catch{}function i_(e,t){return HC({basename:t==null?void 0:t.basename,getContext:t==null?void 0:t.getContext,future:t==null?void 0:t.future,history:uC({window:t==null?void 0:t.window}),hydrationData:l_(),routes:e,mapRouteProperties:IS,hydrationRouteProperties:RS,dataStrategy:t==null?void 0:t.dataStrategy,patchRoutesOnNavigation:t==null?void 0:t.patchRoutesOnNavigation,window:t==null?void 0:t.window}).initialize()}function l_(){let e=window==null?void 0:window.__staticRouterHydrationData;return e&&e.errors&&(e={...e,errors:c_(e.errors)}),e}function c_(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 hl(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 nx=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,rx=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,...p},m){let{basename:x}=d.useContext(Lr),g=typeof u=="string"&&nx.test(u),v,w=!1;if(typeof u=="string"&&g&&(v=u,tx))try{let I=new URL(window.location.href),P=u.startsWith("//")?new URL(I.protocol+u):new URL(u),F=Qn(P.pathname,x);P.origin===I.origin&&F!=null?u=F+P.search+P.hash:w=!0}catch{un(!1,`<Link to="${u}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}let b=mS(u,{relative:o}),[C,_,E]=n_(r,p),S=h_(u,{replace:i,state:l,target:c,preventScrollReset:f,relative:o,viewTransition:h});function j(I){t&&t(I),I.defaultPrevented||S(I)}let A=d.createElement("a",{...p,...E,href:v||b,onClick:w||a?t:j,ref:a_(m,_),target:c,"data-discover":!g&&n==="render"?"true":void 0});return C&&!g?d.createElement(d.Fragment,null,A,d.createElement(r_,{page:b})):A});rx.displayName="Link";var u_=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=ti(i,{relative:u.relative}),p=zr(),m=d.useContext(ei),{navigator:x,basename:g}=d.useContext(Lr),v=m!=null&&v_(h)&&l===!0,w=x.encodeLocation?x.encodeLocation(h).pathname:h.pathname,b=p.pathname,C=m&&m.navigation&&m.navigation.location?m.navigation.location.pathname:null;n||(b=b.toLowerCase(),C=C?C.toLowerCase():null,w=w.toLowerCase()),C&&g&&(C=Qn(C,g)||C);const _=w!=="/"&&w.endsWith("/")?w.length-1:w.length;let E=b===w||!o&&b.startsWith(w)&&b.charAt(_)==="/",S=C!=null&&(C===w||!o&&C.startsWith(w)&&C.charAt(w.length)==="/"),j={isActive:E,isPending:S,isTransitioning:v},A=E?t:void 0,I;typeof r=="function"?I=r(j):I=[r,E?"active":null,S?"pending":null,v?"transitioning":null].filter(Boolean).join(" ");let P=typeof a=="function"?a(j):a;return d.createElement(rx,{...u,"aria-current":A,className:I,ref:f,style:P,to:i,viewTransition:l},typeof c=="function"?c(j):c)});u_.displayName="NavLink";var d_=d.forwardRef(({discover:e="render",fetcherKey:t,navigate:n,reloadDocument:r,replace:o,state:a,method:i=el,action:l,onSubmit:c,relative:u,preventScrollReset:f,viewTransition:h,...p},m)=>{let x=g_(),g=x_(l,{relative:u}),v=i.toLowerCase()==="get"?"get":"post",w=typeof l=="string"&&nx.test(l),b=C=>{if(c&&c(C),C.defaultPrevented)return;C.preventDefault();let _=C.nativeEvent.submitter,E=(_==null?void 0:_.getAttribute("formmethod"))||i;x(_||C.currentTarget,{fetcherKey:t,method:E,navigate:n,replace:o,state:a,relative:u,preventScrollReset:f,viewTransition:h})};return d.createElement("form",{ref:m,method:v,action:g,onSubmit:r?c:b,...p,"data-discover":!w&&e==="render"?"true":void 0})});d_.displayName="Form";function f_(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function ox(e){let t=d.useContext(fs);return wt(t,f_(e)),t}function h_(e,{target:t,replace:n,state:r,preventScrollReset:o,relative:a,viewTransition:i}={}){let l=zo(),c=zr(),u=ti(e,{relative:a});return d.useCallback(f=>{if(VS(f,t)){f.preventDefault();let h=n!==void 0?n:Ro(c)===Ro(u);l(e,{replace:h,state:r,preventScrollReset:o,relative:a,viewTransition:i})}},[c,l,u,n,r,t,e,o,a,i])}var p_=0,m_=()=>`__${String(++p_)}__`;function g_(){let{router:e}=ox("useSubmit"),{basename:t}=d.useContext(Lr),n=jS();return d.useCallback(async(r,o={})=>{let{action:a,method:i,encType:l,formData:c,body:u}=ZS(r,t);if(o.navigate===!1){let f=o.fetcherKey||m_();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 x_(e,{relative:t}={}){let{basename:n}=d.useContext(Lr),r=d.useContext(Fr);wt(r,"useFormAction must be used inside a RouteContext");let[o]=r.matches.slice(-1),a={...ti(e||".",{relative:t})},i=zr();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:Yr([n,a.pathname])),Ro(a)}function v_(e,{relative:t}={}){let n=d.useContext(Fd);wt(n!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:r}=ox("useViewTransitionState"),o=ti(e,{relative:t});if(!n.isTransitioning)return!1;let a=Qn(n.currentLocation.pathname,r)||n.currentLocation.pathname,i=Qn(n.nextLocation.pathname,r)||n.nextLocation.pathname;return fl(o.pathname,i)!=null||fl(o.pathname,a)!=null}function w_(e){return d.createElement(MS,{flushSync:oa.flushSync,...e})}const sx=d.createContext(void 0),ax=()=>{const e=d.useContext(sx);if(!e)throw new Error("useTextSelection must be used within TextSelectionProvider");return e},b_=({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 Gh(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function Gl(...e){return t=>{let n=!1;const r=e.map(o=>{const a=Gh(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():Gh(e[o],null)}}}}function ht(...e){return d.useCallback(Gl(...e),e)}function Po(e){const t=y_(e),n=d.forwardRef((r,o)=>{const{children:a,...i}=r,l=d.Children.toArray(a),c=l.find(S_);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 ix=Po("Slot");function y_(e){const t=d.forwardRef((n,r)=>{const{children:o,...a}=n;if(d.isValidElement(o)){const i=k_(o),l=__(a,o.props);return o.type!==d.Fragment&&(l.ref=r?Gl(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 lx=Symbol("radix.slottable");function C_(e){const t=({children:n})=>s.jsx(s.Fragment,{children:n});return t.displayName=`${e}.Slottable`,t.__radixId=lx,t}function S_(e){return d.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===lx}function __(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 k_(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 cx(e){var t,n,r="";if(typeof e=="string"||typeof e=="number")r+=e;else if(typeof e=="object")if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(n=cx(e[t]))&&(r&&(r+=" "),r+=n)}else for(n in e)e[n]&&(r&&(r+=" "),r+=n);return r}function ux(){for(var e,t,n=0,r="",o=arguments.length;n<o;n++)(e=arguments[n])&&(t=cx(e))&&(r&&(r+=" "),r+=t);return r}const Yh=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,Kh=ux,$o=(e,t)=>n=>{var r;if((t==null?void 0:t.variants)==null)return Kh(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 p=Yh(f)||Yh(h);return o[u][p]}),l=n&&Object.entries(n).reduce((u,f)=>{let[h,p]=f;return p===void 0||(u[h]=p),u},{}),c=t==null||(r=t.compoundVariants)===null||r===void 0?void 0:r.reduce((u,f)=>{let{class:h,className:p,...m}=f;return Object.entries(m).every(x=>{let[g,v]=x;return Array.isArray(v)?v.includes({...a,...l}[g]):{...a,...l}[g]===v})?[...u,h,p]:u},[]);return Kh(e,i,c,n==null?void 0:n.class,n==null?void 0:n.className)},Wd=()=>localStorage.getItem("access_token"),Ut=(e,t="An unknown error occurred")=>e instanceof Error?e.message??t:t,Hd="-",j_=e=>{const t=N_(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:i=>{const l=i.split(Hd);return l[0]===""&&l.length!==1&&l.shift(),dx(l,t)||E_(i)},getConflictingClassGroupIds:(i,l)=>{const c=n[i]||[];return l&&r[i]?[...c,...r[i]]:c}}},dx=(e,t)=>{var i;if(e.length===0)return t.classGroupId;const n=e[0],r=t.nextPart.get(n),o=r?dx(e.slice(1),r):void 0;if(o)return o;if(t.validators.length===0)return;const a=e.join(Hd);return(i=t.validators.find(({validator:l})=>l(a)))==null?void 0:i.classGroupId},qh=/^\[(.+)\]$/,E_=e=>{if(qh.test(e)){const t=qh.exec(e)[1],n=t==null?void 0:t.substring(0,t.indexOf(":"));if(n)return"arbitrary.."+n}},N_=e=>{const{theme:t,classGroups:n}=e,r={nextPart:new Map,validators:[]};for(const o in n)Fu(n[o],r,o,t);return r},Fu=(e,t,n,r)=>{e.forEach(o=>{if(typeof o=="string"){const a=o===""?t:Xh(t,o);a.classGroupId=n;return}if(typeof o=="function"){if(T_(o)){Fu(o(r),t,n,r);return}t.validators.push({validator:o,classGroupId:n});return}Object.entries(o).forEach(([a,i])=>{Fu(i,Xh(t,a),n,r)})})},Xh=(e,t)=>{let n=e;return t.split(Hd).forEach(r=>{n.nextPart.has(r)||n.nextPart.set(r,{nextPart:new Map,validators:[]}),n=n.nextPart.get(r)}),n},T_=e=>e.isThemeGetter,A_=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)}}},zu="!",$u=":",I_=$u.length,R_=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===$u){a.push(o.slice(c,x)),c=x+I_;continue}if(g==="/"){u=x;continue}}g==="["?i++:g==="]"?i--:g==="("?l++:g===")"&&l--}const f=a.length===0?o:o.substring(c),h=P_(f),p=h!==f,m=u&&u>c?u-c:void 0;return{modifiers:a,hasImportantModifier:p,baseClassName:h,maybePostfixModifierPosition:m}};if(t){const o=t+$u,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},P_=e=>e.endsWith(zu)?e.substring(0,e.length-1):e.startsWith(zu)?e.substring(1):e,M_=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}},D_=e=>({cache:A_(e.cacheSize),parseClassName:R_(e),sortModifiers:M_(e),...j_(e)}),O_=/\s+/,L_=(e,t)=>{const{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:o,sortModifiers:a}=t,i=[],l=e.trim().split(O_);let c="";for(let u=l.length-1;u>=0;u-=1){const f=l[u],{isExternal:h,modifiers:p,hasImportantModifier:m,baseClassName:x,maybePostfixModifierPosition:g}=n(f);if(h){c=f+(c.length>0?" "+c:c);continue}let v=!!g,w=r(v?x.substring(0,g):x);if(!w){if(!v){c=f+(c.length>0?" "+c:c);continue}if(w=r(x),!w){c=f+(c.length>0?" "+c:c);continue}v=!1}const b=a(p).join(":"),C=m?b+zu:b,_=C+w;if(i.includes(_))continue;i.push(_);const E=o(w,v);for(let S=0;S<E.length;++S){const j=E[S];i.push(C+j)}c=f+(c.length>0?" "+c:c)}return c};function F_(){let e=0,t,n,r="";for(;e<arguments.length;)(t=arguments[e++])&&(n=fx(t))&&(r&&(r+=" "),r+=n);return r}const fx=e=>{if(typeof e=="string")return e;let t,n="";for(let r=0;r<e.length;r++)e[r]&&(t=fx(e[r]))&&(n&&(n+=" "),n+=t);return n};function z_(e,...t){let n,r,o,a=i;function i(c){const u=t.reduce((f,h)=>h(f),e());return n=D_(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=L_(c,n);return o(c,f),f}return function(){return a(F_.apply(null,arguments))}}const bn=e=>{const t=n=>n[e]||[];return t.isThemeGetter=!0,t},hx=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,px=/^\((?:(\w[\w-]*):)?(.+)\)$/i,$_=/^\d+\/\d+$/,U_=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,B_=/\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$/,V_=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,W_=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,H_=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,bs=e=>$_.test(e),xt=e=>!!e&&!Number.isNaN(Number(e)),Co=e=>!!e&&Number.isInteger(Number(e)),Uc=e=>e.endsWith("%")&&xt(e.slice(0,-1)),ro=e=>U_.test(e),Z_=()=>!0,G_=e=>B_.test(e)&&!V_.test(e),mx=()=>!1,Y_=e=>W_.test(e),K_=e=>H_.test(e),q_=e=>!Ze(e)&&!Ge(e),X_=e=>ia(e,vx,mx),Ze=e=>hx.test(e),Go=e=>ia(e,wx,G_),Bc=e=>ia(e,nk,xt),Jh=e=>ia(e,gx,mx),J_=e=>ia(e,xx,K_),ji=e=>ia(e,bx,Y_),Ge=e=>px.test(e),xa=e=>la(e,wx),Q_=e=>la(e,rk),Qh=e=>la(e,gx),ek=e=>la(e,vx),tk=e=>la(e,xx),Ei=e=>la(e,bx,!0),ia=(e,t,n)=>{const r=hx.exec(e);return r?r[1]?t(r[1]):n(r[2]):!1},la=(e,t,n=!1)=>{const r=px.exec(e);return r?r[1]?t(r[1]):n:!1},gx=e=>e==="position"||e==="percentage",xx=e=>e==="image"||e==="url",vx=e=>e==="length"||e==="size"||e==="bg-size",wx=e=>e==="length",nk=e=>e==="number",rk=e=>e==="family-name",bx=e=>e==="shadow",ok=()=>{const e=bn("color"),t=bn("font"),n=bn("text"),r=bn("font-weight"),o=bn("tracking"),a=bn("leading"),i=bn("breakpoint"),l=bn("container"),c=bn("spacing"),u=bn("radius"),f=bn("shadow"),h=bn("inset-shadow"),p=bn("text-shadow"),m=bn("drop-shadow"),x=bn("blur"),g=bn("perspective"),v=bn("aspect"),w=bn("ease"),b=bn("animate"),C=()=>["auto","avoid","all","avoid-page","page","left","right","column"],_=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],E=()=>[..._(),Ge,Ze],S=()=>["auto","hidden","clip","visible","scroll"],j=()=>["auto","contain","none"],A=()=>[Ge,Ze,c],I=()=>[bs,"full","auto",...A()],P=()=>[Co,"none","subgrid",Ge,Ze],F=()=>["auto",{span:["full",Co,Ge,Ze]},Co,Ge,Ze],N=()=>[Co,"auto",Ge,Ze],R=()=>["auto","min","max","fr",Ge,Ze],y=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],T=()=>["start","end","center","stretch","center-safe","end-safe"],D=()=>["auto",...A()],L=()=>[bs,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...A()],O=()=>[e,Ge,Ze],M=()=>[..._(),Qh,Jh,{position:[Ge,Ze]}],J=()=>["no-repeat",{repeat:["","x","y","space","round"]}],z=()=>["auto","cover","contain",ek,X_,{size:[Ge,Ze]}],H=()=>[Uc,xa,Go],U=()=>["","none","full",u,Ge,Ze],X=()=>["",xt,xa,Go],W=()=>["solid","dashed","dotted","double"],te=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],$=()=>[xt,Uc,Qh,Jh],q=()=>["","none",x,Ge,Ze],Y=()=>["none",xt,Ge,Ze],re=()=>["none",xt,Ge,Ze],ue=()=>[xt,Ge,Ze],ce=()=>[bs,"full",...A()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[ro],breakpoint:[ro],color:[Z_],container:[ro],"drop-shadow":[ro],ease:["in","out","in-out"],font:[q_],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[ro],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[ro],shadow:[ro],spacing:["px",xt],text:[ro],"text-shadow":[ro],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",bs,Ze,Ge,v]}],container:["container"],columns:[{columns:[xt,Ze,Ge,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:S()}],"overflow-x":[{"overflow-x":S()}],"overflow-y":[{"overflow-y":S()}],overscroll:[{overscroll:j()}],"overscroll-x":[{"overscroll-x":j()}],"overscroll-y":[{"overscroll-y":j()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:I()}],"inset-x":[{"inset-x":I()}],"inset-y":[{"inset-y":I()}],start:[{start:I()}],end:[{end:I()}],top:[{top:I()}],right:[{right:I()}],bottom:[{bottom:I()}],left:[{left:I()}],visibility:["visible","invisible","collapse"],z:[{z:[Co,"auto",Ge,Ze]}],basis:[{basis:[bs,"full","auto",l,...A()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[xt,bs,"auto","initial","none",Ze]}],grow:[{grow:["",xt,Ge,Ze]}],shrink:[{shrink:["",xt,Ge,Ze]}],order:[{order:[Co,"first","last","none",Ge,Ze]}],"grid-cols":[{"grid-cols":P()}],"col-start-end":[{col:F()}],"col-start":[{"col-start":N()}],"col-end":[{"col-end":N()}],"grid-rows":[{"grid-rows":P()}],"row-start-end":[{row:F()}],"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":R()}],"auto-rows":[{"auto-rows":R()}],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:D()}],mx:[{mx:D()}],my:[{my:D()}],ms:[{ms:D()}],me:[{me:D()}],mt:[{mt:D()}],mr:[{mr:D()}],mb:[{mb:D()}],ml:[{ml:D()}],"space-x":[{"space-x":A()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":A()}],"space-y-reverse":["space-y-reverse"],size:[{size:L()}],w:[{w:[l,"screen",...L()]}],"min-w":[{"min-w":[l,"screen","none",...L()]}],"max-w":[{"max-w":[l,"screen","none","prose",{screen:[i]},...L()]}],h:[{h:["screen","lh",...L()]}],"min-h":[{"min-h":["screen","lh","none",...L()]}],"max-h":[{"max-h":["screen","lh",...L()]}],"font-size":[{text:["base",n,xa,Go]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[r,Ge,Bc]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",Uc,Ze]}],"font-family":[{font:[Q_,Ze,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,Ge,Ze]}],"line-clamp":[{"line-clamp":[xt,"none",Ge,Bc]}],leading:[{leading:[a,...A()]}],"list-image":[{"list-image":["none",Ge,Ze]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",Ge,Ze]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:O()}],"text-color":[{text:O()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...W(),"wavy"]}],"text-decoration-thickness":[{decoration:[xt,"from-font","auto",Ge,Go]}],"text-decoration-color":[{decoration:O()}],"underline-offset":[{"underline-offset":[xt,"auto",Ge,Ze]}],"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",Ge,Ze]}],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",Ge,Ze]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:M()}],"bg-repeat":[{bg:J()}],"bg-size":[{bg:z()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},Co,Ge,Ze],radial:["",Ge,Ze],conic:[Co,Ge,Ze]},tk,J_]}],"bg-color":[{bg:O()}],"gradient-from-pos":[{from:H()}],"gradient-via-pos":[{via:H()}],"gradient-to-pos":[{to:H()}],"gradient-from":[{from:O()}],"gradient-via":[{via:O()}],"gradient-to":[{to:O()}],rounded:[{rounded:U()}],"rounded-s":[{"rounded-s":U()}],"rounded-e":[{"rounded-e":U()}],"rounded-t":[{"rounded-t":U()}],"rounded-r":[{"rounded-r":U()}],"rounded-b":[{"rounded-b":U()}],"rounded-l":[{"rounded-l":U()}],"rounded-ss":[{"rounded-ss":U()}],"rounded-se":[{"rounded-se":U()}],"rounded-ee":[{"rounded-ee":U()}],"rounded-es":[{"rounded-es":U()}],"rounded-tl":[{"rounded-tl":U()}],"rounded-tr":[{"rounded-tr":U()}],"rounded-br":[{"rounded-br":U()}],"rounded-bl":[{"rounded-bl":U()}],"border-w":[{border:X()}],"border-w-x":[{"border-x":X()}],"border-w-y":[{"border-y":X()}],"border-w-s":[{"border-s":X()}],"border-w-e":[{"border-e":X()}],"border-w-t":[{"border-t":X()}],"border-w-r":[{"border-r":X()}],"border-w-b":[{"border-b":X()}],"border-w-l":[{"border-l":X()}],"divide-x":[{"divide-x":X()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":X()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...W(),"hidden","none"]}],"divide-style":[{divide:[...W(),"hidden","none"]}],"border-color":[{border:O()}],"border-color-x":[{"border-x":O()}],"border-color-y":[{"border-y":O()}],"border-color-s":[{"border-s":O()}],"border-color-e":[{"border-e":O()}],"border-color-t":[{"border-t":O()}],"border-color-r":[{"border-r":O()}],"border-color-b":[{"border-b":O()}],"border-color-l":[{"border-l":O()}],"divide-color":[{divide:O()}],"outline-style":[{outline:[...W(),"none","hidden"]}],"outline-offset":[{"outline-offset":[xt,Ge,Ze]}],"outline-w":[{outline:["",xt,xa,Go]}],"outline-color":[{outline:O()}],shadow:[{shadow:["","none",f,Ei,ji]}],"shadow-color":[{shadow:O()}],"inset-shadow":[{"inset-shadow":["none",h,Ei,ji]}],"inset-shadow-color":[{"inset-shadow":O()}],"ring-w":[{ring:X()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:O()}],"ring-offset-w":[{"ring-offset":[xt,Go]}],"ring-offset-color":[{"ring-offset":O()}],"inset-ring-w":[{"inset-ring":X()}],"inset-ring-color":[{"inset-ring":O()}],"text-shadow":[{"text-shadow":["none",p,Ei,ji]}],"text-shadow-color":[{"text-shadow":O()}],opacity:[{opacity:[xt,Ge,Ze]}],"mix-blend":[{"mix-blend":[...te(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":te()}],"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":[xt]}],"mask-image-linear-from-pos":[{"mask-linear-from":$()}],"mask-image-linear-to-pos":[{"mask-linear-to":$()}],"mask-image-linear-from-color":[{"mask-linear-from":O()}],"mask-image-linear-to-color":[{"mask-linear-to":O()}],"mask-image-t-from-pos":[{"mask-t-from":$()}],"mask-image-t-to-pos":[{"mask-t-to":$()}],"mask-image-t-from-color":[{"mask-t-from":O()}],"mask-image-t-to-color":[{"mask-t-to":O()}],"mask-image-r-from-pos":[{"mask-r-from":$()}],"mask-image-r-to-pos":[{"mask-r-to":$()}],"mask-image-r-from-color":[{"mask-r-from":O()}],"mask-image-r-to-color":[{"mask-r-to":O()}],"mask-image-b-from-pos":[{"mask-b-from":$()}],"mask-image-b-to-pos":[{"mask-b-to":$()}],"mask-image-b-from-color":[{"mask-b-from":O()}],"mask-image-b-to-color":[{"mask-b-to":O()}],"mask-image-l-from-pos":[{"mask-l-from":$()}],"mask-image-l-to-pos":[{"mask-l-to":$()}],"mask-image-l-from-color":[{"mask-l-from":O()}],"mask-image-l-to-color":[{"mask-l-to":O()}],"mask-image-x-from-pos":[{"mask-x-from":$()}],"mask-image-x-to-pos":[{"mask-x-to":$()}],"mask-image-x-from-color":[{"mask-x-from":O()}],"mask-image-x-to-color":[{"mask-x-to":O()}],"mask-image-y-from-pos":[{"mask-y-from":$()}],"mask-image-y-to-pos":[{"mask-y-to":$()}],"mask-image-y-from-color":[{"mask-y-from":O()}],"mask-image-y-to-color":[{"mask-y-to":O()}],"mask-image-radial":[{"mask-radial":[Ge,Ze]}],"mask-image-radial-from-pos":[{"mask-radial-from":$()}],"mask-image-radial-to-pos":[{"mask-radial-to":$()}],"mask-image-radial-from-color":[{"mask-radial-from":O()}],"mask-image-radial-to-color":[{"mask-radial-to":O()}],"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":_()}],"mask-image-conic-pos":[{"mask-conic":[xt]}],"mask-image-conic-from-pos":[{"mask-conic-from":$()}],"mask-image-conic-to-pos":[{"mask-conic-to":$()}],"mask-image-conic-from-color":[{"mask-conic-from":O()}],"mask-image-conic-to-color":[{"mask-conic-to":O()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:M()}],"mask-repeat":[{mask:J()}],"mask-size":[{mask:z()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",Ge,Ze]}],filter:[{filter:["","none",Ge,Ze]}],blur:[{blur:q()}],brightness:[{brightness:[xt,Ge,Ze]}],contrast:[{contrast:[xt,Ge,Ze]}],"drop-shadow":[{"drop-shadow":["","none",m,Ei,ji]}],"drop-shadow-color":[{"drop-shadow":O()}],grayscale:[{grayscale:["",xt,Ge,Ze]}],"hue-rotate":[{"hue-rotate":[xt,Ge,Ze]}],invert:[{invert:["",xt,Ge,Ze]}],saturate:[{saturate:[xt,Ge,Ze]}],sepia:[{sepia:["",xt,Ge,Ze]}],"backdrop-filter":[{"backdrop-filter":["","none",Ge,Ze]}],"backdrop-blur":[{"backdrop-blur":q()}],"backdrop-brightness":[{"backdrop-brightness":[xt,Ge,Ze]}],"backdrop-contrast":[{"backdrop-contrast":[xt,Ge,Ze]}],"backdrop-grayscale":[{"backdrop-grayscale":["",xt,Ge,Ze]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[xt,Ge,Ze]}],"backdrop-invert":[{"backdrop-invert":["",xt,Ge,Ze]}],"backdrop-opacity":[{"backdrop-opacity":[xt,Ge,Ze]}],"backdrop-saturate":[{"backdrop-saturate":[xt,Ge,Ze]}],"backdrop-sepia":[{"backdrop-sepia":["",xt,Ge,Ze]}],"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",Ge,Ze]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[xt,"initial",Ge,Ze]}],ease:[{ease:["linear","initial",w,Ge,Ze]}],delay:[{delay:[xt,Ge,Ze]}],animate:[{animate:["none",b,Ge,Ze]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[g,Ge,Ze]}],"perspective-origin":[{"perspective-origin":E()}],rotate:[{rotate:Y()}],"rotate-x":[{"rotate-x":Y()}],"rotate-y":[{"rotate-y":Y()}],"rotate-z":[{"rotate-z":Y()}],scale:[{scale:re()}],"scale-x":[{"scale-x":re()}],"scale-y":[{"scale-y":re()}],"scale-z":[{"scale-z":re()}],"scale-3d":["scale-3d"],skew:[{skew:ue()}],"skew-x":[{"skew-x":ue()}],"skew-y":[{"skew-y":ue()}],transform:[{transform:[Ge,Ze,"","none","gpu","cpu"]}],"transform-origin":[{origin:E()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:ce()}],"translate-x":[{"translate-x":ce()}],"translate-y":[{"translate-y":ce()}],"translate-z":[{"translate-z":ce()}],"translate-none":["translate-none"],accent:[{accent:O()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:O()}],"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",Ge,Ze]}],"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",Ge,Ze]}],fill:[{fill:["none",...O()]}],"stroke-w":[{stroke:[xt,xa,Go,Bc]}],stroke:[{stroke:["none",...O()]}],"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"]}},sk=z_(ok);function ze(...e){return sk(ux(e))}const ak=()=>localStorage.getItem("refresh_token"),ik=(e,t)=>{localStorage.setItem("access_token",e),localStorage.setItem("refresh_token",t)},lk=()=>{localStorage.removeItem("access_token"),localStorage.removeItem("refresh_token")},ck=async()=>{const e=ak();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 ik(n.access_token,n.refresh_token),n.access_token}return lk(),window.location.href="/api/v1/auth/login",null},uk=async e=>{const t=`Request failed: ${e.statusText||`HTTP ${e.status}`}`;try{const n=await e.text();if(!n)return t;try{const r=JSON.parse(n);return r.message||r.detail||t}catch{return n.length<500?n:t}}catch{return t}},yx=async(e,t={})=>{const n=Wd();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 ck();if(o)return fetch(e,{...t,headers:{...t.headers,Authorization:`Bearer ${o}`}})}return r},dk=async(e,t={})=>{const n=await yx(e,t);if(!n.ok)throw new Error(await uk(n));return n},fk=async(e,t={})=>{const n=await dk(e,t);if(n.status===204)return;const r=await n.text();return r?JSON.parse(r):void 0};class hk{constructor(){ws(this,"webuiBaseUrl","");ws(this,"platformBaseUrl","");ws(this,"webui");ws(this,"platform");this.webui=this.createHttpMethods(()=>this.webuiBaseUrl),this.platform=this.createHttpMethods(()=>this.platformBaseUrl)}configure(t,n){this.webuiBaseUrl=t,this.platformBaseUrl=n}async request(t,n,r){const o=`${t}${n}`,{fullResponse:a,...i}=r||{};return a?yx(o,i):fk(o,i)}buildRequestWithBody(t,n,r){return n instanceof FormData?{...r,method:t,body:n}:n==null?{...r,method:t}:{...r,method:t,headers:{"Content-Type":"application/json",...r==null?void 0:r.headers},body:JSON.stringify(n)}}createHttpMethods(t){return{get:(n,r)=>this.request(t(),n,r),post:(n,r,o)=>this.request(t(),n,this.buildRequestWithBody("POST",r,o)),put:(n,r,o)=>this.request(t(),n,this.buildRequestWithBody("PUT",r,o)),delete:(n,r)=>this.request(t(),n,{...r,method:"DELETE"}),patch:(n,r,o)=>this.request(t(),n,this.buildRequestWithBody("PATCH",r,o)),getFullUrl:n=>`${t()}${n}`}}}const je=new hk,Uu=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}},ni=(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)}},Cx=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=Uu(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 je.webui.get(l,{fullResponse:!0});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.");ni(r,o)}catch(r){console.error("Error creating download link:",r)}},pk=e=>new Promise((t,n)=>{const r=new FileReader;r.onload=()=>t(r.result.split(",")[1]),r.onerror=o=>n(o),r.readAsDataURL(e)}),Sx=e=>new Promise((t,n)=>{const r=new FileReader;r.onloadend=()=>{var o;return t(((o=r.result)==null?void 0:o.toString().split(",")[1])||"")},r.onerror=n,r.readAsDataURL(e)}),_x=({filename:e,sessionId:t,projectId:n,version:r})=>{const o=t&&t.trim()&&t!=="null"&&t!=="undefined",a=encodeURIComponent(e),i=o?`/api/v1/artifacts/${t}/${a}/versions`:`/api/v1/artifacts/null/${a}/versions`,l=r!==void 0?`/${r}`:"",c=`${i}${l}`;if(!o&&n)return`${c}?project_id=${n}`;if(!o&&!n)throw new Error("No valid context for artifact: either sessionId or projectId must be provided");return c},ep=async({filename:e,sessionId:t,projectId:n,version:r})=>{const o=_x({filename:e,sessionId:t,projectId:n,version:r}),a=await je.webui.get(o,{fullResponse:!0});if(!a.ok)throw new Error(`Failed to fetch artifact content: ${a.statusText}`);const l=(a.headers.get("Content-Type")||"application/octet-stream").split(";")[0].trim(),c=await a.blob();return{content:await Sx(c),mimeType:l}};function mk(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(m=>`${m.name} (${(m.size/(1024*1024)).toFixed(2)} MB)`):u.map(m=>m.name),h=i.length-o,p=h>0?` and ${h} more`:"";c=`${i.length} files exceed the maximum size of ${l} MB: ${f.join(", ")}${p}`}return{valid:!1,error:c,oversizedFiles:i}}function gk(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 ri=(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]},Zs=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"}},Zd=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 Gs(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 xk(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 vk(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 Bu(e){return new Date(e).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}const ml=1,wk=e=>({...e,taskMetadata:{...e.taskMetadata,schema_version:1}}),bk={0:wk},yk=e=>{var r;const t=((r=e.taskMetadata)==null?void 0:r.schema_version)??0;if(t>=ml)return e;let n=e;for(let o=t;o<ml;o++){const a=bk[o];a?(n=a(n),console.log(`[Migration] Migrated task ${e.taskId} from v${o} to v${o+1}`)):console.warn(`[Migration] No migration function found for version ${o}`)}return n},tp=(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," "),Ck=(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 Bt(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 Sk(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 ur(e,t=[]){let n=[];function r(a,i){const l=d.createContext(i),c=n.length;n=[...n,i];const u=h=>{var w;const{scope:p,children:m,...x}=h,g=((w=p==null?void 0:p[e])==null?void 0:w[c])||l,v=d.useMemo(()=>x,Object.values(x));return s.jsx(g.Provider,{value:v,children:m})};u.displayName=a+"Provider";function f(h,p){var g;const m=((g=p==null?void 0:p[e])==null?void 0:g[c])||l,x=d.useContext(m);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,_k(o,...t)]}function _k(...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 kk=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],nt=kk.reduce((e,t)=>{const n=Po(`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 Yl(e,t){e&&oa.flushSync(()=>e.dispatchEvent(t))}function In(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 Gd(e,t=globalThis==null?void 0:globalThis.document){const n=In(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 jk="DismissableLayer",Vu="dismissableLayer.update",Ek="dismissableLayer.pointerDownOutside",Nk="dismissableLayer.focusOutside",np,kx=d.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Kl=d.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:a,onInteractOutside:i,onDismiss:l,...c}=e,u=d.useContext(kx),[f,h]=d.useState(null),p=(f==null?void 0:f.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,m]=d.useState({}),x=ht(t,j=>h(j)),g=Array.from(u.layers),[v]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),w=g.indexOf(v),b=f?g.indexOf(f):-1,C=u.layersWithOutsidePointerEventsDisabled.size>0,_=b>=w,E=Ik(j=>{const A=j.target,I=[...u.branches].some(P=>P.contains(A));!_||I||(o==null||o(j),i==null||i(j),j.defaultPrevented||l==null||l())},p),S=Rk(j=>{const A=j.target;[...u.branches].some(P=>P.contains(A))||(a==null||a(j),i==null||i(j),j.defaultPrevented||l==null||l())},p);return Gd(j=>{b===u.layers.size-1&&(r==null||r(j),!j.defaultPrevented&&l&&(j.preventDefault(),l()))},p),d.useEffect(()=>{if(f)return n&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(np=p.body.style.pointerEvents,p.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(f)),u.layers.add(f),rp(),()=>{n&&u.layersWithOutsidePointerEventsDisabled.size===1&&(p.body.style.pointerEvents=np)}},[f,p,n,u]),d.useEffect(()=>()=>{f&&(u.layers.delete(f),u.layersWithOutsidePointerEventsDisabled.delete(f),rp())},[f,u]),d.useEffect(()=>{const j=()=>m({});return document.addEventListener(Vu,j),()=>document.removeEventListener(Vu,j)},[]),s.jsx(nt.div,{...c,ref:x,style:{pointerEvents:C?_?"auto":"none":void 0,...e.style},onFocusCapture:Bt(e.onFocusCapture,S.onFocusCapture),onBlurCapture:Bt(e.onBlurCapture,S.onBlurCapture),onPointerDownCapture:Bt(e.onPointerDownCapture,E.onPointerDownCapture)})});Kl.displayName=jk;var Tk="DismissableLayerBranch",Ak=d.forwardRef((e,t)=>{const n=d.useContext(kx),r=d.useRef(null),o=ht(t,r);return d.useEffect(()=>{const a=r.current;if(a)return n.branches.add(a),()=>{n.branches.delete(a)}},[n.branches]),s.jsx(nt.div,{...e,ref:o})});Ak.displayName=Tk;function Ik(e,t=globalThis==null?void 0:globalThis.document){const n=In(e),r=d.useRef(!1),o=d.useRef(()=>{});return d.useEffect(()=>{const a=l=>{if(l.target&&!r.current){let c=function(){jx(Ek,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 Rk(e,t=globalThis==null?void 0:globalThis.document){const n=In(e),r=d.useRef(!1);return d.useEffect(()=>{const o=a=>{a.target&&!r.current&&jx(Nk,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 rp(){const e=new CustomEvent(Vu);document.dispatchEvent(e)}function jx(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?Yl(o,a):o.dispatchEvent(a)}var dn=globalThis!=null&&globalThis.document?d.useLayoutEffect:()=>{},Pk=Ad[" useId ".trim().toString()]||(()=>{}),Mk=0;function ir(e){const[t,n]=d.useState(Pk());return dn(()=>{n(r=>r??String(Mk++))},[e]),t?`radix-${t}`:""}const Dk=["top","right","bottom","left"],Mo=Math.min,or=Math.max,gl=Math.round,Ni=Math.floor,Kr=e=>({x:e,y:e}),Ok={left:"right",right:"left",bottom:"top",top:"bottom"},Lk={start:"end",end:"start"};function Wu(e,t,n){return or(e,Mo(t,n))}function co(e,t){return typeof e=="function"?e(t):e}function uo(e){return e.split("-")[0]}function ca(e){return e.split("-")[1]}function Yd(e){return e==="x"?"y":"x"}function Kd(e){return e==="y"?"height":"width"}const Fk=new Set(["top","bottom"]);function Zr(e){return Fk.has(uo(e))?"y":"x"}function qd(e){return Yd(Zr(e))}function zk(e,t,n){n===void 0&&(n=!1);const r=ca(e),o=qd(e),a=Kd(o);let i=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[a]>t.floating[a]&&(i=xl(i)),[i,xl(i)]}function $k(e){const t=xl(e);return[Hu(e),t,Hu(t)]}function Hu(e){return e.replace(/start|end/g,t=>Lk[t])}const op=["left","right"],sp=["right","left"],Uk=["top","bottom"],Bk=["bottom","top"];function Vk(e,t,n){switch(e){case"top":case"bottom":return n?t?sp:op:t?op:sp;case"left":case"right":return t?Uk:Bk;default:return[]}}function Wk(e,t,n,r){const o=ca(e);let a=Vk(uo(e),n==="start",r);return o&&(a=a.map(i=>i+"-"+o),t&&(a=a.concat(a.map(Hu)))),a}function xl(e){return e.replace(/left|right|bottom|top/g,t=>Ok[t])}function Hk(e){return{top:0,right:0,bottom:0,left:0,...e}}function Ex(e){return typeof e!="number"?Hk(e):{top:e,right:e,bottom:e,left:e}}function vl(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 ap(e,t,n){let{reference:r,floating:o}=e;const a=Zr(t),i=qd(t),l=Kd(i),c=uo(t),u=a==="y",f=r.x+r.width/2-o.width/2,h=r.y+r.height/2-o.height/2,p=r[l]/2-o[l]/2;let m;switch(c){case"top":m={x:f,y:r.y-o.height};break;case"bottom":m={x:f,y:r.y+r.height};break;case"right":m={x:r.x+r.width,y:h};break;case"left":m={x:r.x-o.width,y:h};break;default:m={x:r.x,y:r.y}}switch(ca(t)){case"start":m[i]-=p*(n&&u?-1:1);break;case"end":m[i]+=p*(n&&u?-1:1);break}return m}const Zk=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}=ap(u,r,c),p=r,m={},x=0;for(let g=0;g<l.length;g++){const{name:v,fn:w}=l[g],{x:b,y:C,data:_,reset:E}=await w({x:f,y:h,initialPlacement:r,placement:p,strategy:o,middlewareData:m,rects:u,platform:i,elements:{reference:e,floating:t}});f=b??f,h=C??h,m={...m,[v]:{...m[v],..._}},E&&x<=50&&(x++,typeof E=="object"&&(E.placement&&(p=E.placement),E.rects&&(u=E.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:o}):E.rects),{x:f,y:h}=ap(u,p,c)),g=-1)}return{x:f,y:h,placement:p,strategy:o,middlewareData:m}};async function $a(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:p=!1,padding:m=0}=co(t,e),x=Ex(m),v=l[p?h==="floating"?"reference":"floating":h],w=vl(await a.getClippingRect({element:(n=await(a.isElement==null?void 0:a.isElement(v)))==null||n?v:v.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)),_=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=vl(a.convertOffsetParentRelativeRectToViewportRelativeRect?await a.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:b,offsetParent:C,strategy:c}):b);return{top:(w.top-E.top+x.top)/_.y,bottom:(E.bottom-w.bottom+x.bottom)/_.y,left:(w.left-E.left+x.left)/_.x,right:(E.right-w.right+x.right)/_.x}}const Gk=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}=co(e,t)||{};if(u==null)return{};const h=Ex(f),p={x:n,y:r},m=qd(o),x=Kd(m),g=await i.getDimensions(u),v=m==="y",w=v?"top":"left",b=v?"bottom":"right",C=v?"clientHeight":"clientWidth",_=a.reference[x]+a.reference[m]-p[m]-a.floating[x],E=p[m]-a.reference[m],S=await(i.getOffsetParent==null?void 0:i.getOffsetParent(u));let j=S?S[C]:0;(!j||!await(i.isElement==null?void 0:i.isElement(S)))&&(j=l.floating[C]||a.floating[x]);const A=_/2-E/2,I=j/2-g[x]/2-1,P=Mo(h[w],I),F=Mo(h[b],I),N=P,R=j-g[x]-F,y=j/2-g[x]/2+A,T=Wu(N,y,R),D=!c.arrow&&ca(o)!=null&&y!==T&&a.reference[x]/2-(y<N?P:F)-g[x]/2<0,L=D?y<N?y-N:y-R:0;return{[m]:p[m]+L,data:{[m]:T,centerOffset:y-T-L,...D&&{alignmentOffset:L}},reset:D}}}),Yk=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:p,fallbackStrategy:m="bestFit",fallbackAxisSideDirection:x="none",flipAlignment:g=!0,...v}=co(e,t);if((n=a.arrow)!=null&&n.alignmentOffset)return{};const w=uo(o),b=Zr(l),C=uo(l)===l,_=await(c.isRTL==null?void 0:c.isRTL(u.floating)),E=p||(C||!g?[xl(l)]:$k(l)),S=x!=="none";!p&&S&&E.push(...Wk(l,g,x,_));const j=[l,...E],A=await $a(t,v),I=[];let P=((r=a.flip)==null?void 0:r.overflows)||[];if(f&&I.push(A[w]),h){const y=zk(o,i,_);I.push(A[y[0]],A[y[1]])}if(P=[...P,{placement:o,overflows:I}],!I.every(y=>y<=0)){var F,N;const y=(((F=a.flip)==null?void 0:F.index)||0)+1,T=j[y];if(T&&(!(h==="alignment"?b!==Zr(T):!1)||P.every(O=>Zr(O.placement)===b?O.overflows[0]>0:!0)))return{data:{index:y,overflows:P},reset:{placement:T}};let D=(N=P.filter(L=>L.overflows[0]<=0).sort((L,O)=>L.overflows[1]-O.overflows[1])[0])==null?void 0:N.placement;if(!D)switch(m){case"bestFit":{var R;const L=(R=P.filter(O=>{if(S){const M=Zr(O.placement);return M===b||M==="y"}return!0}).map(O=>[O.placement,O.overflows.filter(M=>M>0).reduce((M,J)=>M+J,0)]).sort((O,M)=>O[1]-M[1])[0])==null?void 0:R[0];L&&(D=L);break}case"initialPlacement":D=l;break}if(o!==D)return{reset:{placement:D}}}return{}}}};function ip(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function lp(e){return Dk.some(t=>e[t]>=0)}const Kk=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n}=t,{strategy:r="referenceHidden",...o}=co(e,t);switch(r){case"referenceHidden":{const a=await $a(t,{...o,elementContext:"reference"}),i=ip(a,n.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:lp(i)}}}case"escaped":{const a=await $a(t,{...o,altBoundary:!0}),i=ip(a,n.floating);return{data:{escapedOffsets:i,escaped:lp(i)}}}default:return{}}}}},Nx=new Set(["left","top"]);async function qk(e,t){const{placement:n,platform:r,elements:o}=e,a=await(r.isRTL==null?void 0:r.isRTL(o.floating)),i=uo(n),l=ca(n),c=Zr(n)==="y",u=Nx.has(i)?-1:1,f=a&&c?-1:1,h=co(t,e);let{mainAxis:p,crossAxis:m,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"&&(m=l==="end"?x*-1:x),c?{x:m*f,y:p*u}:{x:p*u,y:m*f}}const Xk=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 qk(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}}}}},Jk=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:v=>{let{x:w,y:b}=v;return{x:w,y:b}}},...c}=co(e,t),u={x:n,y:r},f=await $a(t,c),h=Zr(uo(o)),p=Yd(h);let m=u[p],x=u[h];if(a){const v=p==="y"?"top":"left",w=p==="y"?"bottom":"right",b=m+f[v],C=m-f[w];m=Wu(b,m,C)}if(i){const v=h==="y"?"top":"left",w=h==="y"?"bottom":"right",b=x+f[v],C=x-f[w];x=Wu(b,x,C)}const g=l.fn({...t,[p]:m,[h]:x});return{...g,data:{x:g.x-n,y:g.y-r,enabled:{[p]:a,[h]:i}}}}}},Qk=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}=co(e,t),f={x:n,y:r},h=Zr(o),p=Yd(h);let m=f[p],x=f[h];const g=co(l,t),v=typeof g=="number"?{mainAxis:g,crossAxis:0}:{mainAxis:0,crossAxis:0,...g};if(c){const C=p==="y"?"height":"width",_=a.reference[p]-a.floating[C]+v.mainAxis,E=a.reference[p]+a.reference[C]-v.mainAxis;m<_?m=_:m>E&&(m=E)}if(u){var w,b;const C=p==="y"?"width":"height",_=Nx.has(uo(o)),E=a.reference[h]-a.floating[C]+(_&&((w=i.offset)==null?void 0:w[h])||0)+(_?0:v.crossAxis),S=a.reference[h]+a.reference[C]+(_?0:((b=i.offset)==null?void 0:b[h])||0)-(_?v.crossAxis:0);x<E?x=E:x>S&&(x=S)}return{[p]:m,[h]:x}}}},e2=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}=co(e,t),f=await $a(t,u),h=uo(o),p=ca(o),m=Zr(o)==="y",{width:x,height:g}=a.floating;let v,w;h==="top"||h==="bottom"?(v=h,w=p===(await(i.isRTL==null?void 0:i.isRTL(l.floating))?"start":"end")?"left":"right"):(w=h,v=p==="end"?"top":"bottom");const b=g-f.top-f.bottom,C=x-f.left-f.right,_=Mo(g-f[v],b),E=Mo(x-f[w],C),S=!t.middlewareData.shift;let j=_,A=E;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(A=C),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(j=b),S&&!p){const P=or(f.left,0),F=or(f.right,0),N=or(f.top,0),R=or(f.bottom,0);m?A=x-2*(P!==0||F!==0?P+F:or(f.left,f.right)):j=g-2*(N!==0||R!==0?N+R:or(f.top,f.bottom))}await c({...t,availableWidth:A,availableHeight:j});const I=await i.getDimensions(l.floating);return x!==I.width||g!==I.height?{reset:{rects:!0}}:{}}}};function ql(){return typeof window<"u"}function ua(e){return Tx(e)?(e.nodeName||"").toLowerCase():"#document"}function lr(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function to(e){var t;return(t=(Tx(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function Tx(e){return ql()?e instanceof Node||e instanceof lr(e).Node:!1}function Mr(e){return ql()?e instanceof Element||e instanceof lr(e).Element:!1}function Jr(e){return ql()?e instanceof HTMLElement||e instanceof lr(e).HTMLElement:!1}function cp(e){return!ql()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof lr(e).ShadowRoot}const t2=new Set(["inline","contents"]);function oi(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=Dr(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!t2.has(o)}const n2=new Set(["table","td","th"]);function r2(e){return n2.has(ua(e))}const o2=[":popover-open",":modal"];function Xl(e){return o2.some(t=>{try{return e.matches(t)}catch{return!1}})}const s2=["transform","translate","scale","rotate","perspective"],a2=["transform","translate","scale","rotate","perspective","filter"],i2=["paint","layout","strict","content"];function Xd(e){const t=Jd(),n=Mr(e)?Dr(e):e;return s2.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)||a2.some(r=>(n.willChange||"").includes(r))||i2.some(r=>(n.contain||"").includes(r))}function l2(e){let t=Do(e);for(;Jr(t)&&!Ys(t);){if(Xd(t))return t;if(Xl(t))return null;t=Do(t)}return null}function Jd(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const c2=new Set(["html","body","#document"]);function Ys(e){return c2.has(ua(e))}function Dr(e){return lr(e).getComputedStyle(e)}function Jl(e){return Mr(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Do(e){if(ua(e)==="html")return e;const t=e.assignedSlot||e.parentNode||cp(e)&&e.host||to(e);return cp(t)?t.host:t}function Ax(e){const t=Do(e);return Ys(t)?e.ownerDocument?e.ownerDocument.body:e.body:Jr(t)&&oi(t)?t:Ax(t)}function Ua(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=Ax(e),a=o===((r=e.ownerDocument)==null?void 0:r.body),i=lr(o);if(a){const l=Zu(i);return t.concat(i,i.visualViewport||[],oi(o)?o:[],l&&n?Ua(l):[])}return t.concat(o,Ua(o,[],n))}function Zu(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Ix(e){const t=Dr(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=Jr(e),a=o?e.offsetWidth:n,i=o?e.offsetHeight:r,l=gl(n)!==a||gl(r)!==i;return l&&(n=a,r=i),{width:n,height:r,$:l}}function Qd(e){return Mr(e)?e:e.contextElement}function Fs(e){const t=Qd(e);if(!Jr(t))return Kr(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:a}=Ix(t);let i=(a?gl(n.width):n.width)/r,l=(a?gl(n.height):n.height)/o;return(!i||!Number.isFinite(i))&&(i=1),(!l||!Number.isFinite(l))&&(l=1),{x:i,y:l}}const u2=Kr(0);function Rx(e){const t=lr(e);return!Jd()||!t.visualViewport?u2:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function d2(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==lr(e)?!1:t}function ns(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),a=Qd(e);let i=Kr(1);t&&(r?Mr(r)&&(i=Fs(r)):i=Fs(e));const l=d2(a,n,r)?Rx(a):Kr(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 p=lr(a),m=r&&Mr(r)?lr(r):r;let x=p,g=Zu(x);for(;g&&r&&m!==x;){const v=Fs(g),w=g.getBoundingClientRect(),b=Dr(g),C=w.left+(g.clientLeft+parseFloat(b.paddingLeft))*v.x,_=w.top+(g.clientTop+parseFloat(b.paddingTop))*v.y;c*=v.x,u*=v.y,f*=v.x,h*=v.y,c+=C,u+=_,x=lr(g),g=Zu(x)}}return vl({width:f,height:h,x:c,y:u})}function Ql(e,t){const n=Jl(e).scrollLeft;return t?t.left+n:ns(to(e)).left+n}function Px(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-Ql(e,n),o=n.top+t.scrollTop;return{x:r,y:o}}function f2(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const a=o==="fixed",i=to(r),l=t?Xl(t.floating):!1;if(r===i||l&&a)return n;let c={scrollLeft:0,scrollTop:0},u=Kr(1);const f=Kr(0),h=Jr(r);if((h||!h&&!a)&&((ua(r)!=="body"||oi(i))&&(c=Jl(r)),Jr(r))){const m=ns(r);u=Fs(r),f.x=m.x+r.clientLeft,f.y=m.y+r.clientTop}const p=i&&!h&&!a?Px(i,c):Kr(0);return{width:n.width*u.x,height:n.height*u.y,x:n.x*u.x-c.scrollLeft*u.x+f.x+p.x,y:n.y*u.y-c.scrollTop*u.y+f.y+p.y}}function h2(e){return Array.from(e.getClientRects())}function p2(e){const t=to(e),n=Jl(e),r=e.ownerDocument.body,o=or(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),a=or(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let i=-n.scrollLeft+Ql(e);const l=-n.scrollTop;return Dr(r).direction==="rtl"&&(i+=or(t.clientWidth,r.clientWidth)-o),{width:o,height:a,x:i,y:l}}const up=25;function m2(e,t){const n=lr(e),r=to(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=Jd();(!f||f&&t==="fixed")&&(l=o.offsetLeft,c=o.offsetTop)}const u=Ql(r);if(u<=0){const f=r.ownerDocument,h=f.body,p=getComputedStyle(h),m=f.compatMode==="CSS1Compat"&&parseFloat(p.marginLeft)+parseFloat(p.marginRight)||0,x=Math.abs(r.clientWidth-h.clientWidth-m);x<=up&&(a-=x)}else u<=up&&(a+=u);return{width:a,height:i,x:l,y:c}}const g2=new Set(["absolute","fixed"]);function x2(e,t){const n=ns(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,a=Jr(e)?Fs(e):Kr(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 dp(e,t,n){let r;if(t==="viewport")r=m2(e,n);else if(t==="document")r=p2(to(e));else if(Mr(t))r=x2(t,n);else{const o=Rx(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return vl(r)}function Mx(e,t){const n=Do(e);return n===t||!Mr(n)||Ys(n)?!1:Dr(n).position==="fixed"||Mx(n,t)}function v2(e,t){const n=t.get(e);if(n)return n;let r=Ua(e,[],!1).filter(l=>Mr(l)&&ua(l)!=="body"),o=null;const a=Dr(e).position==="fixed";let i=a?Do(e):e;for(;Mr(i)&&!Ys(i);){const l=Dr(i),c=Xd(i);!c&&l.position==="fixed"&&(o=null),(a?!c&&!o:!c&&l.position==="static"&&!!o&&g2.has(o.position)||oi(i)&&!c&&Mx(e,i))?r=r.filter(f=>f!==i):o=l,i=Do(i)}return t.set(e,r),r}function w2(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const i=[...n==="clippingAncestors"?Xl(t)?[]:v2(t,this._c):[].concat(n),r],l=i[0],c=i.reduce((u,f)=>{const h=dp(t,f,o);return u.top=or(h.top,u.top),u.right=Mo(h.right,u.right),u.bottom=Mo(h.bottom,u.bottom),u.left=or(h.left,u.left),u},dp(t,l,o));return{width:c.right-c.left,height:c.bottom-c.top,x:c.left,y:c.top}}function b2(e){const{width:t,height:n}=Ix(e);return{width:t,height:n}}function y2(e,t,n){const r=Jr(t),o=to(t),a=n==="fixed",i=ns(e,!0,a,t);let l={scrollLeft:0,scrollTop:0};const c=Kr(0);function u(){c.x=Ql(o)}if(r||!r&&!a)if((ua(t)!=="body"||oi(o))&&(l=Jl(t)),r){const m=ns(t,!0,a,t);c.x=m.x+t.clientLeft,c.y=m.y+t.clientTop}else o&&u();a&&!r&&o&&u();const f=o&&!r&&!a?Px(o,l):Kr(0),h=i.left+l.scrollLeft-c.x-f.x,p=i.top+l.scrollTop-c.y-f.y;return{x:h,y:p,width:i.width,height:i.height}}function Vc(e){return Dr(e).position==="static"}function fp(e,t){if(!Jr(e)||Dr(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return to(e)===n&&(n=n.ownerDocument.body),n}function Dx(e,t){const n=lr(e);if(Xl(e))return n;if(!Jr(e)){let o=Do(e);for(;o&&!Ys(o);){if(Mr(o)&&!Vc(o))return o;o=Do(o)}return n}let r=fp(e,t);for(;r&&r2(r)&&Vc(r);)r=fp(r,t);return r&&Ys(r)&&Vc(r)&&!Xd(r)?n:r||l2(e)||n}const C2=async function(e){const t=this.getOffsetParent||Dx,n=this.getDimensions,r=await n(e.floating);return{reference:y2(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function S2(e){return Dr(e).direction==="rtl"}const _2={convertOffsetParentRelativeRectToViewportRelativeRect:f2,getDocumentElement:to,getClippingRect:w2,getOffsetParent:Dx,getElementRects:C2,getClientRects:h2,getDimensions:b2,getScale:Fs,isElement:Mr,isRTL:S2};function Ox(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function k2(e,t){let n=null,r;const o=to(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:p,height:m}=u;if(l||t(),!p||!m)return;const x=Ni(h),g=Ni(o.clientWidth-(f+p)),v=Ni(o.clientHeight-(h+m)),w=Ni(f),C={rootMargin:-x+"px "+-g+"px "+-v+"px "+-w+"px",threshold:or(0,Mo(1,c))||1};let _=!0;function E(S){const j=S[0].intersectionRatio;if(j!==c){if(!_)return i();j?i(!1,j):r=setTimeout(()=>{i(!1,1e-7)},1e3)}j===1&&!Ox(u,e.getBoundingClientRect())&&i(),_=!1}try{n=new IntersectionObserver(E,{...C,root:o.ownerDocument})}catch{n=new IntersectionObserver(E,C)}n.observe(e)}return i(!0),a}function ef(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=Qd(e),f=o||a?[...u?Ua(u):[],...Ua(t)]:[];f.forEach(w=>{o&&w.addEventListener("scroll",n,{passive:!0}),a&&w.addEventListener("resize",n)});const h=u&&l?k2(u,n):null;let p=-1,m=null;i&&(m=new ResizeObserver(w=>{let[b]=w;b&&b.target===u&&m&&(m.unobserve(t),cancelAnimationFrame(p),p=requestAnimationFrame(()=>{var C;(C=m)==null||C.observe(t)})),n()}),u&&!c&&m.observe(u),m.observe(t));let x,g=c?ns(e):null;c&&v();function v(){const w=ns(e);g&&!Ox(g,w)&&n(),g=w,x=requestAnimationFrame(v)}return n(),()=>{var w;f.forEach(b=>{o&&b.removeEventListener("scroll",n),a&&b.removeEventListener("resize",n)}),h==null||h(),(w=m)==null||w.disconnect(),m=null,c&&cancelAnimationFrame(x)}}const j2=Xk,E2=Jk,N2=Yk,T2=e2,A2=Kk,hp=Gk,I2=Qk,R2=(e,t,n)=>{const r=new Map,o={platform:_2,...n},a={...o.platform,_c:r};return Zk(e,t,{...o,platform:a})};var P2=typeof document<"u",M2=function(){},nl=P2?d.useLayoutEffect:M2;function wl(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(!wl(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)&&!wl(e[a],t[a]))return!1}return!0}return e!==e&&t!==t}function Lx(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function pp(e,t){const n=Lx(e);return Math.round(t*n)/n}function Wc(e){const t=d.useRef(e);return nl(()=>{t.current=e}),t}function tf(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}),[p,m]=d.useState(r);wl(p,r)||m(r);const[x,g]=d.useState(null),[v,w]=d.useState(null),b=d.useCallback(O=>{O!==S.current&&(S.current=O,g(O))},[]),C=d.useCallback(O=>{O!==j.current&&(j.current=O,w(O))},[]),_=a||x,E=i||v,S=d.useRef(null),j=d.useRef(null),A=d.useRef(f),I=c!=null,P=Wc(c),F=Wc(o),N=Wc(u),R=d.useCallback(()=>{if(!S.current||!j.current)return;const O={placement:t,strategy:n,middleware:p};F.current&&(O.platform=F.current),R2(S.current,j.current,O).then(M=>{const J={...M,isPositioned:N.current!==!1};y.current&&!wl(A.current,J)&&(A.current=J,oa.flushSync(()=>{h(J)}))})},[p,t,n,F,N]);nl(()=>{u===!1&&A.current.isPositioned&&(A.current.isPositioned=!1,h(O=>({...O,isPositioned:!1})))},[u]);const y=d.useRef(!1);nl(()=>(y.current=!0,()=>{y.current=!1}),[]),nl(()=>{if(_&&(S.current=_),E&&(j.current=E),_&&E){if(P.current)return P.current(_,E,R);R()}},[_,E,R,P,I]);const T=d.useMemo(()=>({reference:S,floating:j,setReference:b,setFloating:C}),[b,C]),D=d.useMemo(()=>({reference:_,floating:E}),[_,E]),L=d.useMemo(()=>{const O={position:n,left:0,top:0};if(!D.floating)return O;const M=pp(D.floating,f.x),J=pp(D.floating,f.y);return l?{...O,transform:"translate("+M+"px, "+J+"px)",...Lx(D.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:M,top:J}},[n,l,D.floating,f.x,f.y]);return d.useMemo(()=>({...f,update:R,refs:T,elements:D,floatingStyles:L}),[f,R,T,D,L])}const D2=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?hp({element:r.current,padding:o}).fn(n):{}:r?hp({element:r,padding:o}).fn(n):{}}}},nf=(e,t)=>({...j2(e),options:[e,t]}),rf=(e,t)=>({...E2(e),options:[e,t]}),of=(e,t)=>({...I2(e),options:[e,t]}),sf=(e,t)=>({...N2(e),options:[e,t]}),af=(e,t)=>({...T2(e),options:[e,t]}),lf=(e,t)=>({...A2(e),options:[e,t]}),cf=(e,t)=>({...D2(e),options:[e,t]});var O2="Arrow",Fx=d.forwardRef((e,t)=>{const{children:n,width:r=10,height:o=5,...a}=e;return s.jsx(nt.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"})})});Fx.displayName=O2;var uf=Fx;function df(e){const[t,n]=d.useState(void 0);return dn(()=>{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 ff="Popper",[zx,$x]=ur(ff),[L2,Ux]=zx(ff),Bx=e=>{const{__scopePopper:t,children:n}=e,[r,o]=d.useState(null);return s.jsx(L2,{scope:t,anchor:r,onAnchorChange:o,children:n})};Bx.displayName=ff;var Vx="PopperAnchor",Wx=d.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,a=Ux(Vx,n),i=d.useRef(null),l=ht(t,i);return d.useEffect(()=>{a.onAnchorChange((r==null?void 0:r.current)||i.current)}),r?null:s.jsx(nt.div,{...o,ref:l})});Wx.displayName=Vx;var hf="PopperContent",[F2,z2]=zx(hf),Hx=d.forwardRef((e,t)=>{var $,q,Y,re,ue,ce;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:p=!1,updatePositionStrategy:m="optimized",onPlaced:x,...g}=e,v=Ux(hf,n),[w,b]=d.useState(null),C=ht(t,pe=>b(pe)),[_,E]=d.useState(null),S=df(_),j=(S==null?void 0:S.width)??0,A=(S==null?void 0:S.height)??0,I=r+(a!=="center"?"-"+a:""),P=typeof f=="number"?f:{top:0,right:0,bottom:0,left:0,...f},F=Array.isArray(u)?u:[u],N=F.length>0,R={padding:P,boundary:F.filter(U2),altBoundary:N},{refs:y,floatingStyles:T,placement:D,isPositioned:L,middlewareData:O}=tf({strategy:"fixed",placement:I,whileElementsMounted:(...pe)=>ef(...pe,{animationFrame:m==="always"}),elements:{reference:v.anchor},middleware:[nf({mainAxis:o+A,alignmentAxis:i}),c&&rf({mainAxis:!0,crossAxis:!1,limiter:h==="partial"?of():void 0,...R}),c&&sf({...R}),af({...R,apply:({elements:pe,rects:k,availableWidth:oe,availableHeight:ae})=>{const{width:G,height:V}=k.reference,ne=pe.floating.style;ne.setProperty("--radix-popper-available-width",`${oe}px`),ne.setProperty("--radix-popper-available-height",`${ae}px`),ne.setProperty("--radix-popper-anchor-width",`${G}px`),ne.setProperty("--radix-popper-anchor-height",`${V}px`)}}),_&&cf({element:_,padding:l}),B2({arrowWidth:j,arrowHeight:A}),p&&lf({strategy:"referenceHidden",...R})]}),[M,J]=Yx(D),z=In(x);dn(()=>{L&&(z==null||z())},[L,z]);const H=($=O.arrow)==null?void 0:$.x,U=(q=O.arrow)==null?void 0:q.y,X=((Y=O.arrow)==null?void 0:Y.centerOffset)!==0,[W,te]=d.useState();return dn(()=>{w&&te(window.getComputedStyle(w).zIndex)},[w]),s.jsx("div",{ref:y.setFloating,"data-radix-popper-content-wrapper":"",style:{...T,transform:L?T.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:W,"--radix-popper-transform-origin":[(re=O.transformOrigin)==null?void 0:re.x,(ue=O.transformOrigin)==null?void 0:ue.y].join(" "),...((ce=O.hide)==null?void 0:ce.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:s.jsx(F2,{scope:n,placedSide:M,onArrowChange:E,arrowX:H,arrowY:U,shouldHideArrow:X,children:s.jsx(nt.div,{"data-side":M,"data-align":J,...g,ref:C,style:{...g.style,animation:L?void 0:"none"}})})})});Hx.displayName=hf;var Zx="PopperArrow",$2={top:"bottom",right:"left",bottom:"top",left:"right"},Gx=d.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,a=z2(Zx,r),i=$2[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(uf,{...o,ref:n,style:{...o.style,display:"block"}})})});Gx.displayName=Zx;function U2(e){return e!==null}var B2=e=>({name:"transformOrigin",options:e,fn(t){var v,w,b;const{placement:n,rects:r,middlewareData:o}=t,i=((v=o.arrow)==null?void 0:v.centerOffset)!==0,l=i?0:e.arrowWidth,c=i?0:e.arrowHeight,[u,f]=Yx(n),h={start:"0%",center:"50%",end:"100%"}[f],p=(((w=o.arrow)==null?void 0:w.x)??0)+l/2,m=(((b=o.arrow)==null?void 0:b.y)??0)+c/2;let x="",g="";return u==="bottom"?(x=i?h:`${p}px`,g=`${-c}px`):u==="top"?(x=i?h:`${p}px`,g=`${r.floating.height+c}px`):u==="right"?(x=`${-c}px`,g=i?h:`${m}px`):u==="left"&&(x=`${r.floating.width+c}px`,g=i?h:`${m}px`),{data:{x,y:g}}}});function Yx(e){const[t,n="center"]=e.split("-");return[t,n]}var V2=Bx,W2=Wx,H2=Hx,Z2=Gx,G2="Portal",da=d.forwardRef((e,t)=>{var l;const{container:n,...r}=e,[o,a]=d.useState(!1);dn(()=>a(!0),[]);const i=n||o&&((l=globalThis==null?void 0:globalThis.document)==null?void 0:l.body);return i?E1.createPortal(s.jsx(nt.div,{...r,ref:t}),i):null});da.displayName=G2;function Y2(e,t){return d.useReducer((n,r)=>t[n][r]??n,e)}var wo=e=>{const{present:t,children:n}=e,r=K2(t),o=typeof n=="function"?n({present:r.isPresent}):d.Children.only(n),a=ht(r.ref,q2(o));return typeof n=="function"||r.isPresent?d.cloneElement(o,{ref:a}):null};wo.displayName="Presence";function K2(e){const[t,n]=d.useState(),r=d.useRef(null),o=d.useRef(e),a=d.useRef("none"),i=e?"mounted":"unmounted",[l,c]=Y2(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return d.useEffect(()=>{const u=Ti(r.current);a.current=l==="mounted"?u:"none"},[l]),dn(()=>{const u=r.current,f=o.current;if(f!==e){const p=a.current,m=Ti(u);e?c("MOUNT"):m==="none"||(u==null?void 0:u.display)==="none"?c("UNMOUNT"):c(f&&p!==m?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,c]),dn(()=>{if(t){let u;const f=t.ownerDocument.defaultView??window,h=m=>{const g=Ti(r.current).includes(m.animationName);if(m.target===t&&g&&(c("ANIMATION_END"),!o.current)){const v=t.style.animationFillMode;t.style.animationFillMode="forwards",u=f.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=v)})}},p=m=>{m.target===t&&(a.current=Ti(r.current))};return t.addEventListener("animationstart",p),t.addEventListener("animationcancel",h),t.addEventListener("animationend",h),()=>{f.clearTimeout(u),t.removeEventListener("animationstart",p),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 Ti(e){return(e==null?void 0:e.animationName)||"none"}function q2(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 X2=Ad[" useInsertionEffect ".trim().toString()]||dn;function fo({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[o,a,i]=J2({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 p=Q2(f)?f(e):f;p!==e&&((h=i.current)==null||h.call(i,p))}else a(f)},[l,e,a,i]);return[c,u]}function J2({defaultProp:e,onChange:t}){const[n,r]=d.useState(e),o=d.useRef(n),a=d.useRef(t);return X2(()=>{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 Q2(e){return typeof e=="function"}var Kx=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"}),ej="VisuallyHidden",ec=d.forwardRef((e,t)=>s.jsx(nt.span,{...e,ref:t,style:{...Kx,...e.style}}));ec.displayName=ej;var tj=ec,[tc,m9]=ur("Tooltip",[$x]),nc=$x(),qx="TooltipProvider",nj=700,Gu="tooltip.open",[rj,pf]=tc(qx),Xx=e=>{const{__scopeTooltip:t,delayDuration:n=nj,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(rj,{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})};Xx.displayName=qx;var Ba="Tooltip",[oj,si]=tc(Ba),Jx=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:o,onOpenChange:a,disableHoverableContent:i,delayDuration:l}=e,c=pf(Ba,e.__scopeTooltip),u=nc(t),[f,h]=d.useState(null),p=ir(),m=d.useRef(0),x=i??c.disableHoverableContent,g=l??c.delayDuration,v=d.useRef(!1),[w,b]=fo({prop:r,defaultProp:o??!1,onChange:j=>{j?(c.onOpen(),document.dispatchEvent(new CustomEvent(Gu))):c.onClose(),a==null||a(j)},caller:Ba}),C=d.useMemo(()=>w?v.current?"delayed-open":"instant-open":"closed",[w]),_=d.useCallback(()=>{window.clearTimeout(m.current),m.current=0,v.current=!1,b(!0)},[b]),E=d.useCallback(()=>{window.clearTimeout(m.current),m.current=0,b(!1)},[b]),S=d.useCallback(()=>{window.clearTimeout(m.current),m.current=window.setTimeout(()=>{v.current=!0,b(!0),m.current=0},g)},[g,b]);return d.useEffect(()=>()=>{m.current&&(window.clearTimeout(m.current),m.current=0)},[]),s.jsx(V2,{...u,children:s.jsx(oj,{scope:t,contentId:p,open:w,stateAttribute:C,trigger:f,onTriggerChange:h,onTriggerEnter:d.useCallback(()=>{c.isOpenDelayedRef.current?S():_()},[c.isOpenDelayedRef,S,_]),onTriggerLeave:d.useCallback(()=>{x?E():(window.clearTimeout(m.current),m.current=0)},[E,x]),onOpen:_,onClose:E,disableHoverableContent:x,children:n})})};Jx.displayName=Ba;var Yu="TooltipTrigger",Qx=d.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=si(Yu,n),a=pf(Yu,n),i=nc(n),l=d.useRef(null),c=ht(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(W2,{asChild:!0,...i,children:s.jsx(nt.button,{"aria-describedby":o.open?o.contentId:void 0,"data-state":o.stateAttribute,...r,ref:c,onPointerMove:Bt(e.onPointerMove,p=>{p.pointerType!=="touch"&&!f.current&&!a.isPointerInTransitRef.current&&(o.onTriggerEnter(),f.current=!0)}),onPointerLeave:Bt(e.onPointerLeave,()=>{o.onTriggerLeave(),f.current=!1}),onPointerDown:Bt(e.onPointerDown,()=>{o.open&&o.onClose(),u.current=!0,document.addEventListener("pointerup",h,{once:!0})}),onFocus:Bt(e.onFocus,()=>{u.current||o.onOpen()}),onBlur:Bt(e.onBlur,o.onClose),onClick:Bt(e.onClick,o.onClose)})})});Qx.displayName=Yu;var mf="TooltipPortal",[sj,aj]=tc(mf,{forceMount:void 0}),ev=e=>{const{__scopeTooltip:t,forceMount:n,children:r,container:o}=e,a=si(mf,t);return s.jsx(sj,{scope:t,forceMount:n,children:s.jsx(wo,{present:n||a.open,children:s.jsx(da,{asChild:!0,container:o,children:r})})})};ev.displayName=mf;var Ks="TooltipContent",tv=d.forwardRef((e,t)=>{const n=aj(Ks,e.__scopeTooltip),{forceMount:r=n.forceMount,side:o="top",...a}=e,i=si(Ks,e.__scopeTooltip);return s.jsx(wo,{present:r||i.open,children:i.disableHoverableContent?s.jsx(nv,{side:o,...a,ref:t}):s.jsx(ij,{side:o,...a,ref:t})})}),ij=d.forwardRef((e,t)=>{const n=si(Ks,e.__scopeTooltip),r=pf(Ks,e.__scopeTooltip),o=d.useRef(null),a=ht(t,o),[i,l]=d.useState(null),{trigger:c,onClose:u}=n,f=o.current,{onPointerInTransitChange:h}=r,p=d.useCallback(()=>{l(null),h(!1)},[h]),m=d.useCallback((x,g)=>{const v=x.currentTarget,w={x:x.clientX,y:x.clientY},b=dj(w,v.getBoundingClientRect()),C=fj(w,b),_=hj(g.getBoundingClientRect()),E=mj([...C,..._]);l(E),h(!0)},[h]);return d.useEffect(()=>()=>p(),[p]),d.useEffect(()=>{if(c&&f){const x=v=>m(v,f),g=v=>m(v,c);return c.addEventListener("pointerleave",x),f.addEventListener("pointerleave",g),()=>{c.removeEventListener("pointerleave",x),f.removeEventListener("pointerleave",g)}}},[c,f,m,p]),d.useEffect(()=>{if(i){const x=g=>{const v=g.target,w={x:g.clientX,y:g.clientY},b=(c==null?void 0:c.contains(v))||(f==null?void 0:f.contains(v)),C=!pj(w,i);b?p():C&&(p(),u())};return document.addEventListener("pointermove",x),()=>document.removeEventListener("pointermove",x)}},[c,f,i,u,p]),s.jsx(nv,{...e,ref:a})}),[lj,cj]=tc(Ba,{isInside:!1}),uj=C_("TooltipContent"),nv=d.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":o,onEscapeKeyDown:a,onPointerDownOutside:i,...l}=e,c=si(Ks,n),u=nc(n),{onClose:f}=c;return d.useEffect(()=>(document.addEventListener(Gu,f),()=>document.removeEventListener(Gu,f)),[f]),d.useEffect(()=>{if(c.trigger){const h=p=>{const m=p.target;m!=null&&m.contains(c.trigger)&&f()};return window.addEventListener("scroll",h,{capture:!0}),()=>window.removeEventListener("scroll",h,{capture:!0})}},[c.trigger,f]),s.jsx(Kl,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:a,onPointerDownOutside:i,onFocusOutside:h=>h.preventDefault(),onDismiss:f,children:s.jsxs(H2,{"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(uj,{children:r}),s.jsx(lj,{scope:n,isInside:!0,children:s.jsx(tj,{id:c.contentId,role:"tooltip",children:o||r})})]})})});tv.displayName=Ks;var rv="TooltipArrow",ov=d.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=nc(n);return cj(rv,n).isInside?null:s.jsx(Z2,{...o,...r,ref:t})});ov.displayName=rv;function dj(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 fj(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 hj(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 pj(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,p=c.y;f>r!=p>r&&n<(h-u)*(r-f)/(p-f)+u&&(o=!o)}return o}function mj(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),gj(t)}function gj(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 xj=Xx,vj=Jx,wj=Qx,bj=ev,yj=tv,Cj=ov;function Sj({delayDuration:e=0,...t}){return s.jsx(xj,{"data-slot":"tooltip-provider",delayDuration:e,...t})}function ho({...e}){return s.jsx(Sj,{delayDuration:500,children:s.jsx(vj,{"data-slot":"tooltip",...e})})}function po({...e}){return s.jsx(wj,{"data-slot":"tooltip-trigger",...e})}function mo({className:e,sideOffset:t=0,children:n,...r}){return s.jsx(bj,{children:s.jsxs(yj,{"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(Cj,{className:"bg-primary fill-primary z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]"})]})})}const sv="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)]",Hc=sv+" enabled:hover:bg-[var(--color-primary-w10)] dark:enabled:hover:bg-[var(--color-primary-w60)]",_j=$o("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:Hc+" border border-1 border-[var(--color-primary-wMain)]",secondary:Hc,ghost:Hc,link:sv+" 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 me({className:e,variant:t,size:n,asChild:r=!1,tooltip:o="",tooltipSide:a,testid:i="",...l}){const c=r?ix:"button",u=o?{...l,"aria-label":o}:l,f=s.jsx(c,{"data-slot":"button","data-testid":i||o||l.title,className:ze(_j({variant:t,size:n,className:e})),...u});return o?s.jsxs(ho,{children:[s.jsx(po,{asChild:!0,children:f}),s.jsx(mo,{side:a,children:o})]}):f}const av=({onClick:e,text:t="View Agent Workflow"})=>s.jsx(me,{"data-testid":"viewAgentWorkflow",variant:"ghost",size:"sm",onClick:e,tooltip:t,children:s.jsx(Xi,{className:"h-4 w-4"})}),$r=d.forwardRef(({className:e,...t},n)=>s.jsx("textarea",{className:ze("flex min-h-[80px] w-full rounded-xs border px-3 py-2 placeholder:opacity-75 disabled:cursor-not-allowed disabled:opacity-50",e),ref:n,...t}));$r.displayName="Textarea";const iv=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((m,x)=>m.match(n)?s.jsx("mark",{className:r,children:m},x):s.jsx("span",{children:m},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})]})});iv.displayName="HighlightedTextarea";function xr({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-xs 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)]","aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",e),...n})}const gf=({value:e,onChange:t,placeholder:n="Filter by name...",testid:r,className:o=""})=>s.jsxs("div",{className:`relative ${o}`,children:[s.jsx(Id,{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 kj="Label",lv=d.forwardRef((e,t)=>s.jsx(nt.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())}}));lv.displayName=kj;var jj=lv;function Nt({className:e,...t}){return s.jsx(jj,{"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 xf({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 Ej({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 zs({className:e,...t}){return s.jsx("div",{"data-slot":"card-title",className:ze("leading-none font-semibold",e),...t})}function Nj({className:e,...t}){return s.jsx("div",{"data-slot":"card-description",className:ze("text-muted-foreground text-sm",e),...t})}function rc({className:e,noPadding:t,...n}){return s.jsx("div",{"data-slot":"card-content",className:ze(!t&&"px-6",e),...n})}var ai=e=>e.type==="checkbox",qo=e=>e instanceof Date,Kn=e=>e==null;const cv=e=>typeof e=="object";var wn=e=>!Kn(e)&&!Array.isArray(e)&&cv(e)&&!qo(e),Tj=e=>wn(e)&&e.target?ai(e.target)?e.target.checked:e.target.value:e,Aj=e=>e.substring(0,e.search(/\.\d+(\.|$)/))||e,Ij=(e,t)=>e.has(Aj(t)),Rj=e=>{const t=e.constructor&&e.constructor.prototype;return wn(t)&&t.hasOwnProperty("isPrototypeOf")},vf=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function kn(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(!(vf&&(e instanceof Blob||r))&&(n||wn(e)))if(t=n?[]:Object.create(Object.getPrototypeOf(e)),!n&&!Rj(e))t=e;else for(const o in e)e.hasOwnProperty(o)&&(t[o]=kn(e[o]));else return e;return t}var oc=e=>/^\w*$/.test(e),pn=e=>e===void 0,wf=e=>Array.isArray(e)?e.filter(Boolean):[],bf=e=>wf(e.replace(/["|']|\]/g,"").split(/\.|\[/)),Ye=(e,t,n)=>{if(!t||!wn(e))return n;const r=(oc(t)?[t]:bf(t)).reduce((o,a)=>Kn(o)?o:o[a],e);return pn(r)||r===e?pn(e[t])?n:e[t]:r},Vr=e=>typeof e=="boolean",Zt=(e,t,n)=>{let r=-1;const o=oc(t)?[t]:bf(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=wn(u)||Array.isArray(u)?u:isNaN(+o[r+1])?{}:[]}if(l==="__proto__"||l==="constructor"||l==="prototype")return;e[l]=c,e=e[l]}};const mp={BLUR:"blur",FOCUS_OUT:"focusout"},kr={onBlur:"onBlur",onChange:"onChange",onSubmit:"onSubmit",onTouched:"onTouched",all:"all"},oo={max:"max",min:"min",maxLength:"maxLength",minLength:"minLength",pattern:"pattern",required:"required",validate:"validate"},Pj=At.createContext(null);Pj.displayName="HookFormContext";var Mj=(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]!==kr.all&&(t._proxyFormState[i]=!r||kr.all),e[i]}});return o};const Dj=typeof window<"u"?At.useLayoutEffect:At.useEffect;var sr=e=>typeof e=="string",Oj=(e,t,n,r,o)=>sr(e)?(r&&t.watch.add(e),Ye(n,e,o)):Array.isArray(e)?e.map(a=>(r&&t.watch.add(a),Ye(n,a))):(r&&(t.watchAll=!0),n),Ku=e=>Kn(e)||!cv(e);function jo(e,t,n=new WeakSet){if(Ku(e)||Ku(t))return e===t;if(qo(e)&&qo(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(qo(i)&&qo(l)||wn(i)&&wn(l)||Array.isArray(i)&&Array.isArray(l)?!jo(i,l,n):i!==l)return!1}}return!0}var yf=(e,t,n,r,o)=>t?{...n[e],types:{...n[e]&&n[e].types?n[e].types:{},[r]:o||!0}}:{},Pa=e=>Array.isArray(e)?e:[e],gp=()=>{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 uv(e,t){const n={};for(const r in e)if(e.hasOwnProperty(r)){const o=e[r],a=t[r];if(o&&wn(o)&&a){const i=uv(o,a);wn(i)&&(n[r]=i)}else e[r]&&(n[r]=a)}return n}var Yn=e=>wn(e)&&!Object.keys(e).length,Cf=e=>e.type==="file",jr=e=>typeof e=="function",bl=e=>{if(!vf)return!1;const t=e?e.ownerDocument:0;return e instanceof(t&&t.defaultView?t.defaultView.HTMLElement:HTMLElement)},dv=e=>e.type==="select-multiple",Sf=e=>e.type==="radio",Lj=e=>Sf(e)||ai(e),Zc=e=>bl(e)&&e.isConnected;function Fj(e,t){const n=t.slice(0,-1).length;let r=0;for(;r<n;)e=pn(e)?r++:e[t[r++]];return e}function zj(e){for(const t in e)if(e.hasOwnProperty(t)&&!pn(e[t]))return!1;return!0}function gn(e,t){const n=Array.isArray(t)?t:oc(t)?[t]:bf(t),r=n.length===1?e:Fj(e,n),o=n.length-1,a=n[o];return r&&delete r[a],o!==0&&(wn(r)&&Yn(r)||Array.isArray(r)&&zj(r))&&gn(e,n.slice(0,-1)),e}var $j=e=>{for(const t in e)if(jr(e[t]))return!0;return!1};function fv(e){return Array.isArray(e)||wn(e)&&!$j(e)}function qu(e,t={}){for(const n in e)fv(e[n])?(t[n]=Array.isArray(e[n])?[]:{},qu(e[n],t[n])):pn(e[n])||(t[n]=!0);return t}function Ts(e,t,n){n||(n=qu(t));for(const r in e)fv(e[r])?pn(t)||Ku(n[r])?n[r]=qu(e[r],Array.isArray(e[r])?[]:{}):Ts(e[r],Kn(t)?{}:t[r],n[r]):n[r]=!jo(e[r],t[r]);return n}const xp={value:!1,isValid:!1},vp={value:!0,isValid:!0};var hv=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&&!pn(e[0].attributes.value)?pn(e[0].value)||e[0].value===""?vp:{value:e[0].value,isValid:!0}:vp:xp}return xp},pv=(e,{valueAsNumber:t,valueAsDate:n,setValueAs:r})=>pn(e)?e:t?e===""?NaN:e&&+e:n&&sr(e)?new Date(e):r?r(e):e;const wp={isValid:!1,value:null};var mv=e=>Array.isArray(e)?e.reduce((t,n)=>n&&n.checked&&!n.disabled?{isValid:!0,value:n.value}:t,wp):wp;function bp(e){const t=e.ref;return Cf(t)?t.files:Sf(t)?mv(e.refs).value:dv(t)?[...t.selectedOptions].map(({value:n})=>n):ai(t)?hv(e.refs).value:pv(pn(t.value)?e.ref.value:t.value,e)}var Uj=(e,t,n,r)=>{const o={};for(const a of e){const i=Ye(t,a);i&&Zt(o,a,i._f)}return{criteriaMode:n,names:[...e],fields:o,shouldUseNativeValidation:r}},yl=e=>e instanceof RegExp,va=e=>pn(e)?e:yl(e)?e.source:wn(e)?yl(e.value)?e.value.source:e.value:e,yp=e=>({isOnSubmit:!e||e===kr.onSubmit,isOnBlur:e===kr.onBlur,isOnChange:e===kr.onChange,isOnAll:e===kr.all,isOnTouch:e===kr.onTouched});const Cp="AsyncFunction";var Bj=e=>!!e&&!!e.validate&&!!(jr(e.validate)&&e.validate.constructor.name===Cp||wn(e.validate)&&Object.values(e.validate).find(t=>t.constructor.name===Cp)),Vj=e=>e.mount&&(e.required||e.min||e.max||e.maxLength||e.minLength||e.pattern||e.validate),Sp=(e,t,n)=>!n&&(t.watchAll||t.watch.has(e)||[...t.watch].some(r=>e.startsWith(r)&&/^\.\w+/.test(e.slice(r.length))));const Ma=(e,t,n,r)=>{for(const o of n||Object.keys(e)){const a=Ye(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(Ma(l,t))break}else if(wn(l)&&Ma(l,t))break}}};function _p(e,t,n){const r=Ye(e,n);if(r||oc(n))return{error:r,name:n};const o=n.split(".");for(;o.length;){const a=o.join("."),i=Ye(t,a),l=Ye(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 Wj=(e,t,n,r)=>{n(e);const{name:o,...a}=e;return Yn(a)||Object.keys(a).length>=Object.keys(t).length||Object.keys(a).find(i=>t[i]===(!r||kr.all))},Hj=(e,t,n)=>!e||!t||e===t||Pa(e).some(r=>r&&(n?r===t:r.startsWith(t)||t.startsWith(r))),Zj=(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,Gj=(e,t)=>!wf(Ye(e,t)).length&&gn(e,t),Yj=(e,t,n)=>{const r=Pa(Ye(e,n));return Zt(r,"root",t[n]),Zt(e,n,r),e};function kp(e,t,n="validate"){if(sr(e)||Array.isArray(e)&&e.every(sr)||Vr(e)&&!e)return{type:n,message:sr(e)?e:"",ref:t}}var ys=e=>wn(e)&&!yl(e)?e:{value:e,message:""},jp=async(e,t,n,r,o,a)=>{const{ref:i,refs:l,required:c,maxLength:u,minLength:f,min:h,max:p,pattern:m,validate:x,name:g,valueAsNumber:v,mount:w}=e._f,b=Ye(n,g);if(!w||t.has(g))return{};const C=l?l[0]:i,_=N=>{o&&C.reportValidity&&(C.setCustomValidity(Vr(N)?"":N||""),C.reportValidity())},E={},S=Sf(i),j=ai(i),A=S||j,I=(v||Cf(i))&&pn(i.value)&&pn(b)||bl(i)&&i.value===""||b===""||Array.isArray(b)&&!b.length,P=yf.bind(null,g,r,E),F=(N,R,y,T=oo.maxLength,D=oo.minLength)=>{const L=N?R:y;E[g]={type:N?T:D,message:L,ref:i,...P(N?T:D,L)}};if(a?!Array.isArray(b)||!b.length:c&&(!A&&(I||Kn(b))||Vr(b)&&!b||j&&!hv(l).isValid||S&&!mv(l).isValid)){const{value:N,message:R}=sr(c)?{value:!!c,message:c}:ys(c);if(N&&(E[g]={type:oo.required,message:R,ref:C,...P(oo.required,R)},!r))return _(R),E}if(!I&&(!Kn(h)||!Kn(p))){let N,R;const y=ys(p),T=ys(h);if(!Kn(b)&&!isNaN(b)){const D=i.valueAsNumber||b&&+b;Kn(y.value)||(N=D>y.value),Kn(T.value)||(R=D<T.value)}else{const D=i.valueAsDate||new Date(b),L=J=>new Date(new Date().toDateString()+" "+J),O=i.type=="time",M=i.type=="week";sr(y.value)&&b&&(N=O?L(b)>L(y.value):M?b>y.value:D>new Date(y.value)),sr(T.value)&&b&&(R=O?L(b)<L(T.value):M?b<T.value:D<new Date(T.value))}if((N||R)&&(F(!!N,y.message,T.message,oo.max,oo.min),!r))return _(E[g].message),E}if((u||f)&&!I&&(sr(b)||a&&Array.isArray(b))){const N=ys(u),R=ys(f),y=!Kn(N.value)&&b.length>+N.value,T=!Kn(R.value)&&b.length<+R.value;if((y||T)&&(F(y,N.message,R.message),!r))return _(E[g].message),E}if(m&&!I&&sr(b)){const{value:N,message:R}=ys(m);if(yl(N)&&!b.match(N)&&(E[g]={type:oo.pattern,message:R,ref:i,...P(oo.pattern,R)},!r))return _(R),E}if(x){if(jr(x)){const N=await x(b,n),R=kp(N,C);if(R&&(E[g]={...R,...P(oo.validate,R.message)},!r))return _(R.message),E}else if(wn(x)){let N={};for(const R in x){if(!Yn(N)&&!r)break;const y=kp(await x[R](b,n),C,R);y&&(N={...y,...P(R,y.message)},_(y.message),r&&(E[g]=N))}if(!Yn(N)&&(E[g]={ref:C,...N},!r))return E}}return _(!0),E};const Kj={mode:kr.onSubmit,reValidateMode:kr.onChange,shouldFocusError:!0};function qj(e={}){let t={...Kj,...e},n={submitCount:0,isDirty:!1,isReady:!1,isLoading:jr(t.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{},errors:t.errors||{},disabled:t.disabled||!1},r={},o=wn(t.defaultValues)||wn(t.values)?kn(t.defaultValues||t.values)||{}:{},a=t.shouldUnregister?{}:kn(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 p={array:gp(),state:gp()},m=t.criteriaMode===kr.all,x=B=>K=>{clearTimeout(u),u=setTimeout(B,K)},g=async B=>{if(!t.disabled&&(f.isValid||h.isValid||B)){const K=t.resolver?Yn((await j()).errors):await I(r,!0);K!==n.isValid&&p.state.next({isValid:K})}},v=(B,K)=>{!t.disabled&&(f.isValidating||f.validatingFields||h.isValidating||h.validatingFields)&&((B||Array.from(l.mount)).forEach(Z=>{Z&&(K?Zt(n.validatingFields,Z,K):gn(n.validatingFields,Z))}),p.state.next({validatingFields:n.validatingFields,isValidating:!Yn(n.validatingFields)}))},w=(B,K=[],Z,le,de=!0,se=!0)=>{if(le&&Z&&!t.disabled){if(i.action=!0,se&&Array.isArray(Ye(r,B))){const he=Z(Ye(r,B),le.argA,le.argB);de&&Zt(r,B,he)}if(se&&Array.isArray(Ye(n.errors,B))){const he=Z(Ye(n.errors,B),le.argA,le.argB);de&&Zt(n.errors,B,he),Gj(n.errors,B)}if((f.touchedFields||h.touchedFields)&&se&&Array.isArray(Ye(n.touchedFields,B))){const he=Z(Ye(n.touchedFields,B),le.argA,le.argB);de&&Zt(n.touchedFields,B,he)}(f.dirtyFields||h.dirtyFields)&&(n.dirtyFields=Ts(o,a)),p.state.next({name:B,isDirty:F(B,K),dirtyFields:n.dirtyFields,errors:n.errors,isValid:n.isValid})}else Zt(a,B,K)},b=(B,K)=>{Zt(n.errors,B,K),p.state.next({errors:n.errors})},C=B=>{n.errors=B,p.state.next({errors:n.errors,isValid:!1})},_=(B,K,Z,le)=>{const de=Ye(r,B);if(de){const se=Ye(a,B,pn(Z)?Ye(o,B):Z);pn(se)||le&&le.defaultChecked||K?Zt(a,B,K?se:bp(de._f)):y(B,se),i.mount&&g()}},E=(B,K,Z,le,de)=>{let se=!1,he=!1;const Ee={name:B};if(!t.disabled){if(!Z||le){(f.isDirty||h.isDirty)&&(he=n.isDirty,n.isDirty=Ee.isDirty=F(),se=he!==Ee.isDirty);const Ae=jo(Ye(o,B),K);he=!!Ye(n.dirtyFields,B),Ae?gn(n.dirtyFields,B):Zt(n.dirtyFields,B,!0),Ee.dirtyFields=n.dirtyFields,se=se||(f.dirtyFields||h.dirtyFields)&&he!==!Ae}if(Z){const Ae=Ye(n.touchedFields,B);Ae||(Zt(n.touchedFields,B,Z),Ee.touchedFields=n.touchedFields,se=se||(f.touchedFields||h.touchedFields)&&Ae!==Z)}se&&de&&p.state.next(Ee)}return se?Ee:{}},S=(B,K,Z,le)=>{const de=Ye(n.errors,B),se=(f.isValid||h.isValid)&&Vr(K)&&n.isValid!==K;if(t.delayError&&Z?(c=x(()=>b(B,Z)),c(t.delayError)):(clearTimeout(u),c=null,Z?Zt(n.errors,B,Z):gn(n.errors,B)),(Z?!jo(de,Z):de)||!Yn(le)||se){const he={...le,...se&&Vr(K)?{isValid:K}:{},errors:n.errors,name:B};n={...n,...he},p.state.next(he)}},j=async B=>{v(B,!0);const K=await t.resolver(a,t.context,Uj(B||l.mount,r,t.criteriaMode,t.shouldUseNativeValidation));return v(B),K},A=async B=>{const{errors:K}=await j(B);if(B)for(const Z of B){const le=Ye(K,Z);le?Zt(n.errors,Z,le):gn(n.errors,Z)}else n.errors=K;return K},I=async(B,K,Z={valid:!0})=>{for(const le in B){const de=B[le];if(de){const{_f:se,...he}=de;if(se){const Ee=l.array.has(se.name),Ae=de._f&&Bj(de._f);Ae&&f.validatingFields&&v([se.name],!0);const pt=await jp(de,l.disabled,a,m,t.shouldUseNativeValidation&&!K,Ee);if(Ae&&f.validatingFields&&v([se.name]),pt[se.name]&&(Z.valid=!1,K))break;!K&&(Ye(pt,se.name)?Ee?Yj(n.errors,pt,se.name):Zt(n.errors,se.name,pt[se.name]):gn(n.errors,se.name))}!Yn(he)&&await I(he,K,Z)}}return Z.valid},P=()=>{for(const B of l.unMount){const K=Ye(r,B);K&&(K._f.refs?K._f.refs.every(Z=>!Zc(Z)):!Zc(K._f.ref))&&$(B)}l.unMount=new Set},F=(B,K)=>!t.disabled&&(B&&K&&Zt(a,B,K),!jo(J(),o)),N=(B,K,Z)=>Oj(B,l,{...i.mount?a:pn(K)?o:sr(B)?{[B]:K}:K},Z,K),R=B=>wf(Ye(i.mount?a:o,B,t.shouldUnregister?Ye(o,B,[]):[])),y=(B,K,Z={})=>{const le=Ye(r,B);let de=K;if(le){const se=le._f;se&&(!se.disabled&&Zt(a,B,pv(K,se)),de=bl(se.ref)&&Kn(K)?"":K,dv(se.ref)?[...se.ref.options].forEach(he=>he.selected=de.includes(he.value)):se.refs?ai(se.ref)?se.refs.forEach(he=>{(!he.defaultChecked||!he.disabled)&&(Array.isArray(de)?he.checked=!!de.find(Ee=>Ee===he.value):he.checked=de===he.value||!!de)}):se.refs.forEach(he=>he.checked=he.value===de):Cf(se.ref)?se.ref.value="":(se.ref.value=de,se.ref.type||p.state.next({name:B,values:kn(a)})))}(Z.shouldDirty||Z.shouldTouch)&&E(B,de,Z.shouldTouch,Z.shouldDirty,!0),Z.shouldValidate&&M(B)},T=(B,K,Z)=>{for(const le in K){if(!K.hasOwnProperty(le))return;const de=K[le],se=B+"."+le,he=Ye(r,se);(l.array.has(B)||wn(de)||he&&!he._f)&&!qo(de)?T(se,de,Z):y(se,de,Z)}},D=(B,K,Z={})=>{const le=Ye(r,B),de=l.array.has(B),se=kn(K);Zt(a,B,se),de?(p.array.next({name:B,values:kn(a)}),(f.isDirty||f.dirtyFields||h.isDirty||h.dirtyFields)&&Z.shouldDirty&&p.state.next({name:B,dirtyFields:Ts(o,a),isDirty:F(B,se)})):le&&!le._f&&!Kn(se)?T(B,se,Z):y(B,se,Z),Sp(B,l)&&p.state.next({...n,name:B}),p.state.next({name:i.mount?B:void 0,values:kn(a)})},L=async B=>{i.mount=!0;const K=B.target;let Z=K.name,le=!0;const de=Ye(r,Z),se=Ae=>{le=Number.isNaN(Ae)||qo(Ae)&&isNaN(Ae.getTime())||jo(Ae,Ye(a,Z,Ae))},he=yp(t.mode),Ee=yp(t.reValidateMode);if(de){let Ae,pt;const Lt=K.type?bp(de._f):Tj(B),jt=B.type===mp.BLUR||B.type===mp.FOCUS_OUT,Rt=!Vj(de._f)&&!t.resolver&&!Ye(n.errors,Z)&&!de._f.deps||Zj(jt,Ye(n.touchedFields,Z),n.isSubmitted,Ee,he),it=Sp(Z,l,jt);Zt(a,Z,Lt),jt?(!K||!K.readOnly)&&(de._f.onBlur&&de._f.onBlur(B),c&&c(0)):de._f.onChange&&de._f.onChange(B);const Ot=E(Z,Lt,jt),Jt=!Yn(Ot)||it;if(!jt&&p.state.next({name:Z,type:B.type,values:kn(a)}),Rt)return(f.isValid||h.isValid)&&(t.mode==="onBlur"?jt&&g():jt||g()),Jt&&p.state.next({name:Z,...it?{}:Ot});if(!jt&&it&&p.state.next({...n}),t.resolver){const{errors:Ft}=await j([Z]);if(se(Lt),le){const xe=_p(n.errors,r,Z),Re=_p(Ft,r,xe.name||Z);Ae=Re.error,Z=Re.name,pt=Yn(Ft)}}else v([Z],!0),Ae=(await jp(de,l.disabled,a,m,t.shouldUseNativeValidation))[Z],v([Z]),se(Lt),le&&(Ae?pt=!1:(f.isValid||h.isValid)&&(pt=await I(r,!0)));le&&(de._f.deps&&(!Array.isArray(de._f.deps)||de._f.deps.length>0)&&M(de._f.deps),S(Z,pt,Ae,Ot))}},O=(B,K)=>{if(Ye(n.errors,K)&&B.focus)return B.focus(),1},M=async(B,K={})=>{let Z,le;const de=Pa(B);if(t.resolver){const se=await A(pn(B)?B:de);Z=Yn(se),le=B?!de.some(he=>Ye(se,he)):Z}else B?(le=(await Promise.all(de.map(async se=>{const he=Ye(r,se);return await I(he&&he._f?{[se]:he}:he)}))).every(Boolean),!(!le&&!n.isValid)&&g()):le=Z=await I(r);return p.state.next({...!sr(B)||(f.isValid||h.isValid)&&Z!==n.isValid?{}:{name:B},...t.resolver||!B?{isValid:Z}:{},errors:n.errors}),K.shouldFocus&&!le&&Ma(r,O,B?de:l.mount),le},J=(B,K)=>{let Z={...i.mount?a:o};return K&&(Z=uv(K.dirtyFields?n.dirtyFields:n.touchedFields,Z)),pn(B)?Z:sr(B)?Ye(Z,B):B.map(le=>Ye(Z,le))},z=(B,K)=>({invalid:!!Ye((K||n).errors,B),isDirty:!!Ye((K||n).dirtyFields,B),error:Ye((K||n).errors,B),isValidating:!!Ye(n.validatingFields,B),isTouched:!!Ye((K||n).touchedFields,B)}),H=B=>{B&&Pa(B).forEach(K=>gn(n.errors,K)),p.state.next({errors:B?n.errors:{}})},U=(B,K,Z)=>{const le=(Ye(r,B,{_f:{}})._f||{}).ref,de=Ye(n.errors,B)||{},{ref:se,message:he,type:Ee,...Ae}=de;Zt(n.errors,B,{...Ae,...K,ref:le}),p.state.next({name:B,errors:n.errors,isValid:!1}),Z&&Z.shouldFocus&&le&&le.focus&&le.focus()},X=(B,K)=>jr(B)?p.state.subscribe({next:Z=>"values"in Z&&B(N(void 0,K),Z)}):N(B,K,!0),W=B=>p.state.subscribe({next:K=>{Hj(B.name,K.name,B.exact)&&Wj(K,B.formState||f,G,B.reRenderRoot)&&B.callback({values:{...a},...n,...K,defaultValues:o})}}).unsubscribe,te=B=>(i.mount=!0,h={...h,...B.formState},W({...B,formState:h})),$=(B,K={})=>{for(const Z of B?Pa(B):l.mount)l.mount.delete(Z),l.array.delete(Z),K.keepValue||(gn(r,Z),gn(a,Z)),!K.keepError&&gn(n.errors,Z),!K.keepDirty&&gn(n.dirtyFields,Z),!K.keepTouched&&gn(n.touchedFields,Z),!K.keepIsValidating&&gn(n.validatingFields,Z),!t.shouldUnregister&&!K.keepDefaultValue&&gn(o,Z);p.state.next({values:kn(a)}),p.state.next({...n,...K.keepDirty?{isDirty:F()}:{}}),!K.keepIsValid&&g()},q=({disabled:B,name:K})=>{(Vr(B)&&i.mount||B||l.disabled.has(K))&&(B?l.disabled.add(K):l.disabled.delete(K))},Y=(B,K={})=>{let Z=Ye(r,B);const le=Vr(K.disabled)||Vr(t.disabled);return Zt(r,B,{...Z||{},_f:{...Z&&Z._f?Z._f:{ref:{name:B}},name:B,mount:!0,...K}}),l.mount.add(B),Z?q({disabled:Vr(K.disabled)?K.disabled:t.disabled,name:B}):_(B,!0,K.value),{...le?{disabled:K.disabled||t.disabled}:{},...t.progressive?{required:!!K.required,min:va(K.min),max:va(K.max),minLength:va(K.minLength),maxLength:va(K.maxLength),pattern:va(K.pattern)}:{},name:B,onChange:L,onBlur:L,ref:de=>{if(de){Y(B,K),Z=Ye(r,B);const se=pn(de.value)&&de.querySelectorAll&&de.querySelectorAll("input,select,textarea")[0]||de,he=Lj(se),Ee=Z._f.refs||[];if(he?Ee.find(Ae=>Ae===se):se===Z._f.ref)return;Zt(r,B,{_f:{...Z._f,...he?{refs:[...Ee.filter(Zc),se,...Array.isArray(Ye(o,B))?[{}]:[]],ref:{type:se.type,name:B}}:{ref:se}}}),_(B,!1,void 0,se)}else Z=Ye(r,B,{}),Z._f&&(Z._f.mount=!1),(t.shouldUnregister||K.shouldUnregister)&&!(Ij(l.array,B)&&i.action)&&l.unMount.add(B)}}},re=()=>t.shouldFocusError&&Ma(r,O,l.mount),ue=B=>{Vr(B)&&(p.state.next({disabled:B}),Ma(r,(K,Z)=>{const le=Ye(r,Z);le&&(K.disabled=le._f.disabled||B,Array.isArray(le._f.refs)&&le._f.refs.forEach(de=>{de.disabled=le._f.disabled||B}))},0,!1))},ce=(B,K)=>async Z=>{let le;Z&&(Z.preventDefault&&Z.preventDefault(),Z.persist&&Z.persist());let de=kn(a);if(p.state.next({isSubmitting:!0}),t.resolver){const{errors:se,values:he}=await j();n.errors=se,de=kn(he)}else await I(r);if(l.disabled.size)for(const se of l.disabled)gn(de,se);if(gn(n.errors,"root"),Yn(n.errors)){p.state.next({errors:{}});try{await B(de,Z)}catch(se){le=se}}else K&&await K({...n.errors},Z),re(),setTimeout(re);if(p.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:Yn(n.errors)&&!le,submitCount:n.submitCount+1,errors:n.errors}),le)throw le},pe=(B,K={})=>{Ye(r,B)&&(pn(K.defaultValue)?D(B,kn(Ye(o,B))):(D(B,K.defaultValue),Zt(o,B,kn(K.defaultValue))),K.keepTouched||gn(n.touchedFields,B),K.keepDirty||(gn(n.dirtyFields,B),n.isDirty=K.defaultValue?F(B,kn(Ye(o,B))):F()),K.keepError||(gn(n.errors,B),f.isValid&&g()),p.state.next({...n}))},k=(B,K={})=>{const Z=B?kn(B):o,le=kn(Z),de=Yn(B),se=de?o:le;if(K.keepDefaultValues||(o=Z),!K.keepValues){if(K.keepDirtyValues){const he=new Set([...l.mount,...Object.keys(Ts(o,a))]);for(const Ee of Array.from(he))Ye(n.dirtyFields,Ee)?Zt(se,Ee,Ye(a,Ee)):D(Ee,Ye(se,Ee))}else{if(vf&&pn(B))for(const he of l.mount){const Ee=Ye(r,he);if(Ee&&Ee._f){const Ae=Array.isArray(Ee._f.refs)?Ee._f.refs[0]:Ee._f.ref;if(bl(Ae)){const pt=Ae.closest("form");if(pt){pt.reset();break}}}}if(K.keepFieldsRef)for(const he of l.mount)D(he,Ye(se,he));else r={}}a=t.shouldUnregister?K.keepDefaultValues?kn(o):{}:kn(se),p.array.next({values:{...se}}),p.state.next({values:{...se}})}l={mount:K.keepDirtyValues?l.mount:new Set,unMount:new Set,array:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:""},i.mount=!f.isValid||!!K.keepIsValid||!!K.keepDirtyValues,i.watch=!!t.shouldUnregister,p.state.next({submitCount:K.keepSubmitCount?n.submitCount:0,isDirty:de?!1:K.keepDirty?n.isDirty:!!(K.keepDefaultValues&&!jo(B,o)),isSubmitted:K.keepIsSubmitted?n.isSubmitted:!1,dirtyFields:de?{}:K.keepDirtyValues?K.keepDefaultValues&&a?Ts(o,a):n.dirtyFields:K.keepDefaultValues&&B?Ts(o,B):K.keepDirty?n.dirtyFields:{},touchedFields:K.keepTouched?n.touchedFields:{},errors:K.keepErrors?n.errors:{},isSubmitSuccessful:K.keepIsSubmitSuccessful?n.isSubmitSuccessful:!1,isSubmitting:!1,defaultValues:o})},oe=(B,K)=>k(jr(B)?B(a):B,K),ae=(B,K={})=>{const Z=Ye(r,B),le=Z&&Z._f;if(le){const de=le.refs?le.refs[0]:le.ref;de.focus&&(de.focus(),K.shouldSelect&&jr(de.select)&&de.select())}},G=B=>{n={...n,...B}},ne={control:{register:Y,unregister:$,getFieldState:z,handleSubmit:ce,setError:U,_subscribe:W,_runSchema:j,_focusError:re,_getWatch:N,_getDirty:F,_setValid:g,_setFieldArray:w,_setDisabledField:q,_setErrors:C,_getFieldArray:R,_reset:k,_resetDefaultValues:()=>jr(t.defaultValues)&&t.defaultValues().then(B=>{oe(B,t.resetOptions),p.state.next({isLoading:!1})}),_removeUnmounted:P,_disableForm:ue,_subjects:p,_proxyFormState:f,get _fields(){return r},get _formValues(){return a},get _state(){return i},set _state(B){i=B},get _defaultValues(){return o},get _names(){return l},set _names(B){l=B},get _formState(){return n},get _options(){return t},set _options(B){t={...t,...B}}},subscribe:te,trigger:M,register:Y,handleSubmit:ce,watch:X,setValue:D,getValues:J,reset:oe,resetField:pe,clearErrors:H,unregister:$,setError:U,setFocus:ae,getFieldState:z};return{...ne,formControl:ne}}function Xj(e={}){const t=At.useRef(void 0),n=At.useRef(void 0),[r,o]=At.useState({isDirty:!1,isValidating:!1,isLoading:jr(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:jr(e.defaultValues)?void 0:e.defaultValues});if(!t.current)if(e.formControl)t.current={...e.formControl,formState:r},e.defaultValues&&!jr(e.defaultValues)&&e.formControl.reset(e.defaultValues,e.resetOptions);else{const{formControl:i,...l}=qj(e);t.current={...l,formState:r}}const a=t.current.control;return a._options=e,Dj(()=>{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]),At.useEffect(()=>a._disableForm(e.disabled),[a,e.disabled]),At.useEffect(()=>{e.mode&&(a._options.mode=e.mode),e.reValidateMode&&(a._options.reValidateMode=e.reValidateMode)},[a,e.mode,e.reValidateMode]),At.useEffect(()=>{e.errors&&(a._setErrors(e.errors),a._focusError())},[a,e.errors]),At.useEffect(()=>{e.shouldUnregister&&a._subjects.state.next({values:a._getWatch()})},[a,e.shouldUnregister]),At.useEffect(()=>{if(a._proxyFormState.isDirty){const i=a._getDirty();i!==r.isDirty&&a._subjects.state.next({isDirty:i})}},[a,r.isDirty]),At.useEffect(()=>{e.values&&!jo(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]),At.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=Mj(r,a),t.current}d.createContext({});d.createContext({});const Jj=$o("flex-col items-center justify-center",{variants:{show:{true:"flex",false:"hidden"}},defaultVariants:{show:!0}}),Qj=$o("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 Qr({size:e,show:t,children:n,className:r,variant:o}){return s.jsxs("span",{className:Jj({show:t}),children:[s.jsx(ar,{className:ze(Qj({size:e,variant:o}),r)}),n]})}var Gc="focusScope.autoFocusOnMount",Yc="focusScope.autoFocusOnUnmount",Ep={bubbles:!1,cancelable:!0},eE="FocusScope",ii=d.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:a,...i}=e,[l,c]=d.useState(null),u=In(o),f=In(a),h=d.useRef(null),p=ht(t,g=>c(g)),m=d.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;d.useEffect(()=>{if(r){let g=function(C){if(m.paused||!l)return;const _=C.target;l.contains(_)?h.current=_:So(h.current,{select:!0})},v=function(C){if(m.paused||!l)return;const _=C.relatedTarget;_!==null&&(l.contains(_)||So(h.current,{select:!0}))},w=function(C){if(document.activeElement===document.body)for(const E of C)E.removedNodes.length>0&&So(l)};document.addEventListener("focusin",g),document.addEventListener("focusout",v);const b=new MutationObserver(w);return l&&b.observe(l,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",g),document.removeEventListener("focusout",v),b.disconnect()}}},[r,l,m.paused]),d.useEffect(()=>{if(l){Tp.add(m);const g=document.activeElement;if(!l.contains(g)){const w=new CustomEvent(Gc,Ep);l.addEventListener(Gc,u),l.dispatchEvent(w),w.defaultPrevented||(tE(aE(gv(l)),{select:!0}),document.activeElement===g&&So(l))}return()=>{l.removeEventListener(Gc,u),setTimeout(()=>{const w=new CustomEvent(Yc,Ep);l.addEventListener(Yc,f),l.dispatchEvent(w),w.defaultPrevented||So(g??document.body,{select:!0}),l.removeEventListener(Yc,f),Tp.remove(m)},0)}}},[l,u,f,m]);const x=d.useCallback(g=>{if(!n&&!r||m.paused)return;const v=g.key==="Tab"&&!g.altKey&&!g.ctrlKey&&!g.metaKey,w=document.activeElement;if(v&&w){const b=g.currentTarget,[C,_]=nE(b);C&&_?!g.shiftKey&&w===_?(g.preventDefault(),n&&So(C,{select:!0})):g.shiftKey&&w===C&&(g.preventDefault(),n&&So(_,{select:!0})):w===b&&g.preventDefault()}},[n,r,m.paused]);return s.jsx(nt.div,{tabIndex:-1,...i,ref:p,onKeyDown:x})});ii.displayName=eE;function tE(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(So(r,{select:t}),document.activeElement!==n)return}function nE(e){const t=gv(e),n=Np(t,e),r=Np(t.reverse(),e);return[n,r]}function gv(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 Np(e,t){for(const n of e)if(!rE(n,{upTo:t}))return n}function rE(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 oE(e){return e instanceof HTMLInputElement&&"select"in e}function So(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&oE(e)&&t&&e.select()}}var Tp=sE();function sE(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=Ap(e,t),e.unshift(t)},remove(t){var n;e=Ap(e,t),(n=e[0])==null||n.resume()}}}function Ap(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function aE(e){return e.filter(t=>t.tagName!=="A")}var Kc=0;function xv(){d.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??Ip()),document.body.insertAdjacentElement("beforeend",e[1]??Ip()),Kc++,()=>{Kc===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),Kc--}},[])}function Ip(){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 Hr=function(){return Hr=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},Hr.apply(this,arguments)};function vv(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 iE(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 rl="right-scroll-bar-position",ol="width-before-scroll-bar",lE="with-scroll-bars-hidden",cE="--removed-body-scroll-bar-size";function qc(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function uE(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 dE=typeof window<"u"?d.useLayoutEffect:d.useEffect,Rp=new WeakMap;function fE(e,t){var n=uE(null,function(r){return e.forEach(function(o){return qc(o,r)})});return dE(function(){var r=Rp.get(n);if(r){var o=new Set(r),a=new Set(e),i=n.current;o.forEach(function(l){a.has(l)||qc(l,null)}),a.forEach(function(l){o.has(l)||qc(l,i)})}Rp.set(n,e)},[e]),n}function hE(e){return e}function pE(e,t){t===void 0&&(t=hE);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 mE(e){e===void 0&&(e={});var t=pE(null);return t.options=Hr({async:!0,ssr:!1},e),t}var wv=function(e){var t=e.sideCar,n=vv(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,Hr({},n))};wv.isSideCarExport=!0;function gE(e,t){return e.useMedium(t),wv}var bv=mE(),Xc=function(){},sc=d.forwardRef(function(e,t){var n=d.useRef(null),r=d.useState({onScrollCapture:Xc,onWheelCapture:Xc,onTouchMoveCapture:Xc}),o=r[0],a=r[1],i=e.forwardProps,l=e.children,c=e.className,u=e.removeScrollBar,f=e.enabled,h=e.shards,p=e.sideCar,m=e.noRelative,x=e.noIsolation,g=e.inert,v=e.allowPinchZoom,w=e.as,b=w===void 0?"div":w,C=e.gapMode,_=vv(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),E=p,S=fE([n,t]),j=Hr(Hr({},_),o);return d.createElement(d.Fragment,null,f&&d.createElement(E,{sideCar:bv,removeScrollBar:u,shards:h,noRelative:m,noIsolation:x,inert:g,setCallbacks:a,allowPinchZoom:!!v,lockRef:n,gapMode:C}),i?d.cloneElement(d.Children.only(l),Hr(Hr({},j),{ref:S})):d.createElement(b,Hr({},j,{className:c,ref:S}),l))});sc.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};sc.classNames={fullWidth:ol,zeroRight:rl};var xE=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function vE(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=xE();return t&&e.setAttribute("nonce",t),e}function wE(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function bE(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var yE=function(){var e=0,t=null;return{add:function(n){e==0&&(t=vE())&&(wE(t,n),bE(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},CE=function(){var e=yE();return function(t,n){d.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},yv=function(){var e=CE(),t=function(n){var r=n.styles,o=n.dynamic;return e(r,o),null};return t},SE={left:0,top:0,right:0,gap:0},Jc=function(e){return parseInt(e||"",10)||0},_E=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[Jc(n),Jc(r),Jc(o)]},kE=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return SE;var t=_E(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])}},jE=yv(),$s="data-scroll-locked",EE=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(lE,` {
90
+ overflow: hidden `).concat(r,`;
91
+ padding-right: `).concat(l,"px ").concat(r,`;
92
+ }
93
+ body[`).concat($s,`] {
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(rl,` {
107
+ right: `).concat(l,"px ").concat(r,`;
108
+ }
109
+
110
+ .`).concat(ol,` {
111
+ margin-right: `).concat(l,"px ").concat(r,`;
112
+ }
113
+
114
+ .`).concat(rl," .").concat(rl,` {
115
+ right: 0 `).concat(r,`;
116
+ }
117
+
118
+ .`).concat(ol," .").concat(ol,` {
119
+ margin-right: 0 `).concat(r,`;
120
+ }
121
+
122
+ body[`).concat($s,`] {
123
+ `).concat(cE,": ").concat(l,`px;
124
+ }
125
+ `)},Pp=function(){var e=parseInt(document.body.getAttribute($s)||"0",10);return isFinite(e)?e:0},NE=function(){d.useEffect(function(){return document.body.setAttribute($s,(Pp()+1).toString()),function(){var e=Pp()-1;e<=0?document.body.removeAttribute($s):document.body.setAttribute($s,e.toString())}},[])},TE=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,o=r===void 0?"margin":r;NE();var a=d.useMemo(function(){return kE(o)},[o]);return d.createElement(jE,{styles:EE(a,!t,o,n?"":"!important")})},Xu=!1;if(typeof window<"u")try{var Ai=Object.defineProperty({},"passive",{get:function(){return Xu=!0,!0}});window.addEventListener("test",Ai,Ai),window.removeEventListener("test",Ai,Ai)}catch{Xu=!1}var Cs=Xu?{passive:!1}:!1,AE=function(e){return e.tagName==="TEXTAREA"},Cv=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!AE(e)&&n[t]==="visible")},IE=function(e){return Cv(e,"overflowY")},RE=function(e){return Cv(e,"overflowX")},Mp=function(e,t){var n=t.ownerDocument,r=t;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var o=Sv(e,r);if(o){var a=_v(e,r),i=a[1],l=a[2];if(i>l)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},PE=function(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;return[t,n,r]},ME=function(e){var t=e.scrollLeft,n=e.scrollWidth,r=e.clientWidth;return[t,n,r]},Sv=function(e,t){return e==="v"?IE(t):RE(t)},_v=function(e,t){return e==="v"?PE(t):ME(t)},DE=function(e,t){return e==="h"&&t==="rtl"?-1:1},OE=function(e,t,n,r,o){var a=DE(e,window.getComputedStyle(t).direction),i=a*r,l=n.target,c=t.contains(l),u=!1,f=i>0,h=0,p=0;do{if(!l)break;var m=_v(e,l),x=m[0],g=m[1],v=m[2],w=g-v-a*x;(x||w)&&Sv(e,l)&&(h+=w,p+=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(p)<1)&&(u=!0),u},Ii=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},Dp=function(e){return[e.deltaX,e.deltaY]},Op=function(e){return e&&"current"in e?e.current:e},LE=function(e,t){return e[0]===t[0]&&e[1]===t[1]},FE=function(e){return`
126
+ .block-interactivity-`.concat(e,` {pointer-events: none;}
127
+ .allow-interactivity-`).concat(e,` {pointer-events: all;}
128
+ `)},zE=0,Ss=[];function $E(e){var t=d.useRef([]),n=d.useRef([0,0]),r=d.useRef(),o=d.useState(zE++)[0],a=d.useState(yv)[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=iE([e.lockRef.current],(e.shards||[]).map(Op),!0).filter(Boolean);return g.forEach(function(v){return v.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),g.forEach(function(v){return v.classList.remove("allow-interactivity-".concat(o))})}}},[e.inert,e.lockRef.current,e.shards]);var l=d.useCallback(function(g,v){if("touches"in g&&g.touches.length===2||g.type==="wheel"&&g.ctrlKey)return!i.current.allowPinchZoom;var w=Ii(g),b=n.current,C="deltaX"in g?g.deltaX:b[0]-w[0],_="deltaY"in g?g.deltaY:b[1]-w[1],E,S=g.target,j=Math.abs(C)>Math.abs(_)?"h":"v";if("touches"in g&&j==="h"&&S.type==="range")return!1;var A=Mp(j,S);if(!A)return!0;if(A?E=j:(E=j==="v"?"h":"v",A=Mp(j,S)),!A)return!1;if(!r.current&&"changedTouches"in g&&(C||_)&&(r.current=E),!E)return!0;var I=r.current||E;return OE(I,v,g,I==="h"?C:_)},[]),c=d.useCallback(function(g){var v=g;if(!(!Ss.length||Ss[Ss.length-1]!==a)){var w="deltaY"in v?Dp(v):Ii(v),b=t.current.filter(function(E){return E.name===v.type&&(E.target===v.target||v.target===E.shadowParent)&&LE(E.delta,w)})[0];if(b&&b.should){v.cancelable&&v.preventDefault();return}if(!b){var C=(i.current.shards||[]).map(Op).filter(Boolean).filter(function(E){return E.contains(v.target)}),_=C.length>0?l(v,C[0]):!i.current.noIsolation;_&&v.cancelable&&v.preventDefault()}}},[]),u=d.useCallback(function(g,v,w,b){var C={name:g,delta:v,target:w,should:b,shadowParent:UE(w)};t.current.push(C),setTimeout(function(){t.current=t.current.filter(function(_){return _!==C})},1)},[]),f=d.useCallback(function(g){n.current=Ii(g),r.current=void 0},[]),h=d.useCallback(function(g){u(g.type,Dp(g),g.target,l(g,e.lockRef.current))},[]),p=d.useCallback(function(g){u(g.type,Ii(g),g.target,l(g,e.lockRef.current))},[]);d.useEffect(function(){return Ss.push(a),e.setCallbacks({onScrollCapture:h,onWheelCapture:h,onTouchMoveCapture:p}),document.addEventListener("wheel",c,Cs),document.addEventListener("touchmove",c,Cs),document.addEventListener("touchstart",f,Cs),function(){Ss=Ss.filter(function(g){return g!==a}),document.removeEventListener("wheel",c,Cs),document.removeEventListener("touchmove",c,Cs),document.removeEventListener("touchstart",f,Cs)}},[]);var m=e.removeScrollBar,x=e.inert;return d.createElement(d.Fragment,null,x?d.createElement(a,{styles:FE(o)}):null,m?d.createElement(TE,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function UE(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const BE=gE(bv,$E);var li=d.forwardRef(function(e,t){return d.createElement(sc,Hr({},e,{ref:t,sideCar:BE}))});li.classNames=sc.classNames;var VE=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},_s=new WeakMap,Ri=new WeakMap,Pi={},Qc=0,kv=function(e){return e&&(e.host||kv(e.parentNode))},WE=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=kv(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})},HE=function(e,t,n,r){var o=WE(t,Array.isArray(e)?e:[e]);Pi[n]||(Pi[n]=new WeakMap);var a=Pi[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(p){if(l.has(p))f(p);else try{var m=p.getAttribute(r),x=m!==null&&m!=="false",g=(_s.get(p)||0)+1,v=(a.get(p)||0)+1;_s.set(p,g),a.set(p,v),i.push(p),g===1&&x&&Ri.set(p,!0),v===1&&p.setAttribute(n,"true"),x||p.setAttribute(r,"true")}catch(w){console.error("aria-hidden: cannot operate on ",p,w)}})};return f(t),l.clear(),Qc++,function(){i.forEach(function(h){var p=_s.get(h)-1,m=a.get(h)-1;_s.set(h,p),a.set(h,m),p||(Ri.has(h)||h.removeAttribute(r),Ri.delete(h)),m||h.removeAttribute(n)}),Qc--,Qc||(_s=new WeakMap,_s=new WeakMap,Ri=new WeakMap,Pi={})}},ac=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),o=VE(e);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live], script"))),HE(r,o,n,"aria-hidden")):function(){return null}},ic="Dialog",[jv,g9]=ur(ic),[ZE,Ur]=jv(ic),Ev=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]=fo({prop:r,defaultProp:o??!1,onChange:a,caller:ic});return s.jsx(ZE,{scope:t,triggerRef:l,contentRef:c,contentId:ir(),titleId:ir(),descriptionId:ir(),open:u,onOpenChange:f,onOpenToggle:d.useCallback(()=>f(h=>!h),[f]),modal:i,children:n})};Ev.displayName=ic;var Nv="DialogTrigger",Tv=d.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Ur(Nv,n),a=ht(t,o.triggerRef);return s.jsx(nt.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":jf(o.open),...r,ref:a,onClick:Bt(e.onClick,o.onOpenToggle)})});Tv.displayName=Nv;var _f="DialogPortal",[GE,Av]=jv(_f,{forceMount:void 0}),Iv=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:o}=e,a=Ur(_f,t);return s.jsx(GE,{scope:t,forceMount:n,children:d.Children.map(r,i=>s.jsx(wo,{present:n||a.open,children:s.jsx(da,{asChild:!0,container:o,children:i})}))})};Iv.displayName=_f;var Cl="DialogOverlay",Rv=d.forwardRef((e,t)=>{const n=Av(Cl,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,a=Ur(Cl,e.__scopeDialog);return a.modal?s.jsx(wo,{present:r||a.open,children:s.jsx(KE,{...o,ref:t})}):null});Rv.displayName=Cl;var YE=Po("DialogOverlay.RemoveScroll"),KE=d.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Ur(Cl,n);return s.jsx(li,{as:YE,allowPinchZoom:!0,shards:[o.contentRef],children:s.jsx(nt.div,{"data-state":jf(o.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),rs="DialogContent",Pv=d.forwardRef((e,t)=>{const n=Av(rs,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,a=Ur(rs,e.__scopeDialog);return s.jsx(wo,{present:r||a.open,children:a.modal?s.jsx(qE,{...o,ref:t}):s.jsx(XE,{...o,ref:t})})});Pv.displayName=rs;var qE=d.forwardRef((e,t)=>{const n=Ur(rs,e.__scopeDialog),r=d.useRef(null),o=ht(t,n.contentRef,r);return d.useEffect(()=>{const a=r.current;if(a)return ac(a)},[]),s.jsx(Mv,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Bt(e.onCloseAutoFocus,a=>{var i;a.preventDefault(),(i=n.triggerRef.current)==null||i.focus()}),onPointerDownOutside:Bt(e.onPointerDownOutside,a=>{const i=a.detail.originalEvent,l=i.button===0&&i.ctrlKey===!0;(i.button===2||l)&&a.preventDefault()}),onFocusOutside:Bt(e.onFocusOutside,a=>a.preventDefault())})}),XE=d.forwardRef((e,t)=>{const n=Ur(rs,e.__scopeDialog),r=d.useRef(!1),o=d.useRef(!1);return s.jsx(Mv,{...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()}})}),Mv=d.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:a,...i}=e,l=Ur(rs,n),c=d.useRef(null),u=ht(t,c);return xv(),s.jsxs(s.Fragment,{children:[s.jsx(ii,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:a,children:s.jsx(Kl,{role:"dialog",id:l.contentId,"aria-describedby":l.descriptionId,"aria-labelledby":l.titleId,"data-state":jf(l.open),...i,ref:u,onDismiss:()=>l.onOpenChange(!1)})}),s.jsxs(s.Fragment,{children:[s.jsx(JE,{titleId:l.titleId}),s.jsx(eN,{contentRef:c,descriptionId:l.descriptionId})]})]})}),kf="DialogTitle",Dv=d.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Ur(kf,n);return s.jsx(nt.h2,{id:o.titleId,...r,ref:t})});Dv.displayName=kf;var Ov="DialogDescription",Lv=d.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Ur(Ov,n);return s.jsx(nt.p,{id:o.descriptionId,...r,ref:t})});Lv.displayName=Ov;var Fv="DialogClose",zv=d.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Ur(Fv,n);return s.jsx(nt.button,{type:"button",...r,ref:t,onClick:Bt(e.onClick,()=>o.onOpenChange(!1))})});zv.displayName=Fv;function jf(e){return e?"open":"closed"}var $v="DialogTitleWarning",[x9,Uv]=Sk($v,{contentName:rs,titleName:kf,docsSlug:"dialog"}),JE=({titleId:e})=>{const t=Uv($v),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},QE="DialogDescriptionWarning",eN=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${Uv(QE).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},tN=Ev,nN=Tv,rN=Iv,oN=Rv,sN=Pv,aN=Dv,iN=Lv,Bv=zv;function Pn({...e}){return s.jsx(tN,{"data-slot":"dialog",...e})}function Ju({...e}){return s.jsx(nN,{"data-slot":"dialog-trigger",...e})}function lN({...e}){return s.jsx(rN,{"data-slot":"dialog-portal",...e})}function Vv({...e}){return s.jsx(Bv,{"data-slot":"dialog-close",...e})}function cN({className:e,...t}){return s.jsx(oN,{"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 Mn({className:e,children:t,showCloseButton:n=!1,...r}){return s.jsxs(lN,{"data-slot":"dialog-portal",children:[s.jsx(cN,{}),s.jsxs(sN,{"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(Bv,{"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(Xr,{}),s.jsx("span",{className:"sr-only",children:"Close"})]})]})]})}function Vn({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 er({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 Dn({className:e,...t}){return s.jsx(aN,{"data-slot":"dialog-title",className:ze("text-lg leading-none font-semibold",e),...t})}function Wn({className:e,...t}){return s.jsx(iN,{"data-slot":"dialog-description",className:ze(e),...t})}const lc=d.createContext(null);lc.displayName="PanelGroupContext";const cn={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"},Ef=10,Xo=d.useLayoutEffect,Lp=Ad.useId,uN=typeof Lp=="function"?Lp:()=>null;let dN=0;function Nf(e=null){const t=uN(),n=d.useRef(e||t||null);return n.current===null&&(n.current=""+dN++),e??n.current}function Wv({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:p,style:m,tagName:x="div",...g}){const v=d.useContext(lc);if(v===null)throw Error("Panel components must be rendered within a PanelGroup container");const{collapsePanel:w,expandPanel:b,getPanelSize:C,getPanelStyle:_,groupId:E,isPanelCollapsed:S,reevaluatePanelConstraints:j,registerPanel:A,resizePanel:I,unregisterPanel:P}=v,F=Nf(i),N=d.useRef({callbacks:{onCollapse:u,onExpand:f,onResize:h},constraints:{collapsedSize:n,collapsible:r,defaultSize:o,maxSize:l,minSize:c},id:F,idIsFromProps:i!==void 0,order:p});d.useRef({didLogMissingDefaultSizeWarning:!1}),Xo(()=>{const{callbacks:y,constraints:T}=N.current,D={...T};N.current.id=F,N.current.idIsFromProps=i!==void 0,N.current.order=p,y.onCollapse=u,y.onExpand=f,y.onResize=h,T.collapsedSize=n,T.collapsible=r,T.defaultSize=o,T.maxSize=l,T.minSize=c,(D.collapsedSize!==T.collapsedSize||D.collapsible!==T.collapsible||D.maxSize!==T.maxSize||D.minSize!==T.minSize)&&j(N.current,D)}),Xo(()=>{const y=N.current;return A(y),()=>{P(y)}},[p,F,A,P]),d.useImperativeHandle(a,()=>({collapse:()=>{w(N.current)},expand:y=>{b(N.current,y)},getId(){return F},getSize(){return C(N.current)},isCollapsed(){return S(N.current)},isExpanded(){return!S(N.current)},resize:y=>{I(N.current,y)}}),[w,b,C,S,F,I]);const R=_(N.current,o);return d.createElement(x,{...g,children:e,className:t,id:F,style:{...R,...m},[cn.groupId]:E,[cn.panel]:"",[cn.panelCollapsible]:r||void 0,[cn.panelId]:F,[cn.panelSize]:parseFloat(""+R.flexGrow).toFixed(1)})}const Hv=d.forwardRef((e,t)=>d.createElement(Wv,{...e,forwardedRef:t}));Wv.displayName="Panel";Hv.displayName="forwardRef(Panel)";let Qu=null,sl=-1,Eo=null;function fN(e,t){if(t){const n=(t&qv)!==0,r=(t&Xv)!==0,o=(t&Jv)!==0,a=(t&Qv)!==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 hN(){Eo!==null&&(document.head.removeChild(Eo),Qu=null,Eo=null,sl=-1)}function eu(e,t){var n,r;const o=fN(e,t);if(Qu!==o){if(Qu=o,Eo===null&&(Eo=document.createElement("style"),document.head.appendChild(Eo)),sl>=0){var a;(a=Eo.sheet)===null||a===void 0||a.removeRule(sl)}sl=(n=(r=Eo.sheet)===null||r===void 0?void 0:r.insertRule(`*{cursor: ${o} !important;}`))!==null&&n!==void 0?n:-1}}function Zv(e){return e.type==="keydown"}function Gv(e){return e.type.startsWith("pointer")}function Yv(e){return e.type.startsWith("mouse")}function cc(e){if(Gv(e)){if(e.isPrimary)return{x:e.clientX,y:e.clientY}}else if(Yv(e))return{x:e.clientX,y:e.clientY};return{x:1/0,y:1/0}}function pN(){if(typeof matchMedia=="function")return matchMedia("(pointer:coarse)").matches?"coarse":"fine"}function mN(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 gN(e,t){if(e===t)throw new Error("Cannot compare node with itself");const n={a:$p(e),b:$p(t)};let r;for(;n.a.at(-1)===n.b.at(-1);)e=n.a.pop(),t=n.b.pop(),r=e;mt(r,"Stacking order can only be calculated for elements with a common ancestor");const o={a:zp(Fp(n.a)),b:zp(Fp(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 xN=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function vN(e){var t;const n=getComputedStyle((t=Kv(e))!==null&&t!==void 0?t:e).display;return n==="flex"||n==="inline-flex"}function wN(e){const t=getComputedStyle(e);return!!(t.position==="fixed"||t.zIndex!=="auto"&&(t.position!=="static"||vN(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"||xN.test(t.willChange)||t.webkitOverflowScrolling==="touch")}function Fp(e){let t=e.length;for(;t--;){const n=e[t];if(mt(n,"Missing node"),wN(n))return n}return null}function zp(e){return e&&Number(getComputedStyle(e).zIndex)||0}function $p(e){const t=[];for(;e;)t.push(e),e=Kv(e);return t}function Kv(e){const{parentNode:t}=e;return t&&t instanceof ShadowRoot?t.host:t}const qv=1,Xv=2,Jv=4,Qv=8,bN=pN()==="coarse";let Rr=[],Us=!1,No=new Map,uc=new Map;const Va=new Set;function yN(e,t,n,r,o){var a;const{ownerDocument:i}=t,l={direction:n,element:t,hitAreaMargins:r,setResizeHandlerState:o},c=(a=No.get(i))!==null&&a!==void 0?a:0;return No.set(i,c+1),Va.add(l),Sl(),function(){var f;uc.delete(e),Va.delete(l);const h=(f=No.get(i))!==null&&f!==void 0?f:1;if(No.set(i,h-1),Sl(),h===1&&No.delete(i),Rr.includes(l)){const p=Rr.indexOf(l);p>=0&&Rr.splice(p,1),Af(),o("up",!0,null)}}}function CN(e){const{target:t}=e,{x:n,y:r}=cc(e);Us=!0,Tf({target:t,x:n,y:r}),Sl(),Rr.length>0&&(_l("down",e),e.preventDefault(),ew(t)||e.stopImmediatePropagation())}function tu(e){const{x:t,y:n}=cc(e);if(Us&&e.buttons===0&&(Us=!1,_l("up",e)),!Us){const{target:r}=e;Tf({target:r,x:t,y:n})}_l("move",e),Af(),Rr.length>0&&e.preventDefault()}function nu(e){const{target:t}=e,{x:n,y:r}=cc(e);uc.clear(),Us=!1,Rr.length>0&&(e.preventDefault(),ew(t)||e.stopImmediatePropagation()),_l("up",e),Tf({target:t,x:n,y:r}),Af(),Sl()}function ew(e){let t=e;for(;t;){if(t.hasAttribute(cn.resizeHandle))return!0;t=t.parentElement}return!1}function Tf({target:e,x:t,y:n}){Rr.splice(0);let r=null;(e instanceof HTMLElement||e instanceof SVGElement)&&(r=e),Va.forEach(o=>{const{element:a,hitAreaMargins:i}=o,l=a.getBoundingClientRect(),{bottom:c,left:u,right:f,top:h}=l,p=bN?i.coarse:i.fine;if(t>=u-p&&t<=f+p&&n>=h-p&&n<=c+p){if(r!==null&&document.contains(r)&&a!==r&&!a.contains(r)&&!r.contains(a)&&gN(r,a)>0){let x=r,g=!1;for(;x&&!x.contains(a);){if(mN(x.getBoundingClientRect(),l)){g=!0;break}x=x.parentElement}if(g)return}Rr.push(o)}})}function ru(e,t){uc.set(e,t)}function Af(){let e=!1,t=!1;Rr.forEach(r=>{const{direction:o}=r;o==="horizontal"?e=!0:t=!0});let n=0;uc.forEach(r=>{n|=r}),e&&t?eu("intersection",n):e?eu("horizontal",n):t?eu("vertical",n):hN()}let ou;function Sl(){var e;(e=ou)===null||e===void 0||e.abort(),ou=new AbortController;const t={capture:!0,signal:ou.signal};Va.size&&(Us?(Rr.length>0&&No.forEach((n,r)=>{const{body:o}=r;n>0&&(o.addEventListener("contextmenu",nu,t),o.addEventListener("pointerleave",tu,t),o.addEventListener("pointermove",tu,t))}),No.forEach((n,r)=>{const{body:o}=r;o.addEventListener("pointerup",nu,t),o.addEventListener("pointercancel",nu,t)})):No.forEach((n,r)=>{const{body:o}=r;n>0&&(o.addEventListener("pointerdown",CN,t),o.addEventListener("pointermove",tu,t))}))}function _l(e,t){Va.forEach(n=>{const{setResizeHandlerState:r}=n,o=Rr.includes(n);r(e,o,t)})}function SN(){const[e,t]=d.useState(0);return d.useCallback(()=>t(n=>n+1),[])}function mt(e,t){if(!e)throw console.error(t),Error(t)}function os(e,t,n=Ef){return e.toFixed(n)===t.toFixed(n)?0:e>t?1:-1}function lo(e,t,n=Ef){return os(e,t,n)===0}function nr(e,t,n){return os(e,t,n)===0}function _N(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(!nr(o,a,n))return!1}return!0}function Rs({panelConstraints:e,panelIndex:t,size:n}){const r=e[t];mt(r!=null,`Panel constraints not found for index ${t}`);let{collapsedSize:o=0,collapsible:a,maxSize:i=100,minSize:l=0}=r;if(os(n,l)<0)if(a){const c=(o+l)/2;os(n,c)<0?n=o:n=l}else n=l;return n=Math.min(i,n),n=parseFloat(n.toFixed(Ef)),n}function Ea({delta:e,initialLayout:t,panelConstraints:n,pivotIndices:r,prevLayout:o,trigger:a}){if(nr(e,0))return t;const i=[...t],[l,c]=r;mt(l!=null,"Invalid first pivot index"),mt(c!=null,"Invalid second pivot index");let u=0;if(a==="keyboard"){{const h=e<0?c:l,p=n[h];mt(p,`Panel constraints not found for index ${h}`);const{collapsedSize:m=0,collapsible:x,minSize:g=0}=p;if(x){const v=t[h];if(mt(v!=null,`Previous layout not found for panel index ${h}`),nr(v,m)){const w=g-v;os(w,Math.abs(e))>0&&(e=e<0?0-w:w)}}}{const h=e<0?l:c,p=n[h];mt(p,`No panel constraints found for index ${h}`);const{collapsedSize:m=0,collapsible:x,minSize:g=0}=p;if(x){const v=t[h];if(mt(v!=null,`Previous layout not found for panel index ${h}`),nr(v,g)){const w=v-m;os(w,Math.abs(e))>0&&(e=e<0?0-w:w)}}}}{const h=e<0?1:-1;let p=e<0?c:l,m=0;for(;;){const g=t[p];mt(g!=null,`Previous layout not found for panel index ${p}`);const w=Rs({panelConstraints:n,panelIndex:p,size:100})-g;if(m+=w,p+=h,p<0||p>=n.length)break}const x=Math.min(Math.abs(e),Math.abs(m));e=e<0?0-x:x}{let p=e<0?l:c;for(;p>=0&&p<n.length;){const m=Math.abs(e)-Math.abs(u),x=t[p];mt(x!=null,`Previous layout not found for panel index ${p}`);const g=x-m,v=Rs({panelConstraints:n,panelIndex:p,size:g});if(!nr(x,v)&&(u+=x-v,i[p]=v,u.toPrecision(3).localeCompare(Math.abs(e).toPrecision(3),void 0,{numeric:!0})>=0))break;e<0?p--:p++}}if(_N(o,i))return o;{const h=e<0?c:l,p=t[h];mt(p!=null,`Previous layout not found for panel index ${h}`);const m=p+u,x=Rs({panelConstraints:n,panelIndex:h,size:m});if(i[h]=x,!nr(x,m)){let g=m-x,w=e<0?c:l;for(;w>=0&&w<n.length;){const b=i[w];mt(b!=null,`Previous layout not found for panel index ${w}`);const C=b+g,_=Rs({panelConstraints:n,panelIndex:w,size:C});if(nr(b,_)||(g-=_-b,i[w]=_),nr(g,0))break;e>0?w--:w++}}}const f=i.reduce((h,p)=>p+h,0);return nr(f,100)?i:o}function kN({layout:e,panelsArray:t,pivotIndices:n}){let r=0,o=100,a=0,i=0;const l=n[0];mt(l!=null,"No pivot index found"),t.forEach((h,p)=>{const{constraints:m}=h,{maxSize:x=100,minSize:g=0}=m;p===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 Wa(e,t=document){return Array.from(t.querySelectorAll(`[${cn.resizeHandleId}][data-panel-group-id="${e}"]`))}function tw(e,t,n=document){const o=Wa(e,n).findIndex(a=>a.getAttribute(cn.resizeHandleId)===t);return o??null}function nw(e,t,n){const r=tw(e,t,n);return r!=null?[r,r+1]:[-1,-1]}function jN(e){return e instanceof HTMLElement?!0:typeof e=="object"&&e!==null&&"tagName"in e&&"getAttribute"in e}function rw(e,t=document){if(jN(t)&&t.dataset.panelGroupId==e)return t;const n=t.querySelector(`[data-panel-group][data-panel-group-id="${e}"]`);return n||null}function dc(e,t=document){const n=t.querySelector(`[${cn.resizeHandleId}="${e}"]`);return n||null}function EN(e,t,n,r=document){var o,a,i,l;const c=dc(t,r),u=Wa(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,p=(i=(l=n[f+1])===null||l===void 0?void 0:l.id)!==null&&i!==void 0?i:null;return[h,p]}function NN({committedValuesRef:e,eagerValuesRef:t,groupId:n,layout:r,panelDataArray:o,panelGroupElement:a,setLayout:i}){d.useRef({didWarnAboutMissingResizeHandle:!1}),Xo(()=>{if(!a)return;const l=Wa(n,a);for(let c=0;c<o.length-1;c++){const{valueMax:u,valueMin:f,valueNow:h}=kN({layout:r,panelsArray:o,pivotIndices:[c,c+1]}),p=l[c];if(p!=null){const m=o[c];mt(m,`No panel data found for index "${c}"`),p.setAttribute("aria-controls",m.id),p.setAttribute("aria-valuemax",""+Math.round(u)),p.setAttribute("aria-valuemin",""+Math.round(f)),p.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;mt(l,"Eager values not found");const{panelDataArray:c}=l,u=rw(n,a);mt(u!=null,`No group found for id "${n}"`);const f=Wa(n,a);mt(f,`No resize handles found for group id "${n}"`);const h=f.map(p=>{const m=p.getAttribute(cn.resizeHandleId);mt(m,"Resize handle element has no handle id attribute");const[x,g]=EN(n,m,c,a);if(x==null||g==null)return()=>{};const v=w=>{if(!w.defaultPrevented)switch(w.key){case"Enter":{w.preventDefault();const b=c.findIndex(C=>C.id===x);if(b>=0){const C=c[b];mt(C,`No panel data found for index ${b}`);const _=r[b],{collapsedSize:E=0,collapsible:S,minSize:j=0}=C.constraints;if(_!=null&&S){const A=Ea({delta:nr(_,E)?j-E:E-_,initialLayout:r,panelConstraints:c.map(I=>I.constraints),pivotIndices:nw(n,m,a),prevLayout:r,trigger:"keyboard"});r!==A&&i(A)}}break}}};return p.addEventListener("keydown",v),()=>{p.removeEventListener("keydown",v)}});return()=>{h.forEach(p=>p())}},[a,e,t,n,r,o,i])}function Up(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 ow(e,t){const n=e==="horizontal",{x:r,y:o}=cc(t);return n?r:o}function TN(e,t,n,r,o){const a=n==="horizontal",i=dc(t,o);mt(i,`No resize handle element found for id "${t}"`);const l=i.getAttribute(cn.groupId);mt(l,"Resize handle element has no group id attribute");let{initialCursorPosition:c}=r;const u=ow(n,e),f=rw(l,o);mt(f,`No group element found for id "${l}"`);const h=f.getBoundingClientRect(),p=a?h.width:h.height;return(u-c)/p*100}function AN(e,t,n,r,o,a){if(Zv(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:TN(e,t,n,r,a)}function IN({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];mt(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];mt(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 ks(e,t,n){t.forEach((r,o)=>{const a=e[o];mt(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:p,onExpand:m,onResize:x}=i;x&&x(r,h),f&&(p||m)&&(m&&(h==null||lo(h,u))&&!lo(r,u)&&m(),p&&(h==null||!lo(h,u))&&lo(r,u)&&p())}})}function Mi(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 RN({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 PN(e,t=10){let n=null;return(...o)=>{n!==null&&clearTimeout(n),n=setTimeout(()=>{e(...o)},t)}}function Bp(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 sw(e){return`react-resizable-panels:${e}`}function aw(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 iw(e,t){try{const n=sw(e),r=t.getItem(n);if(r){const o=JSON.parse(r);if(typeof o=="object"&&o!=null)return o}}catch{}return null}function MN(e,t,n){var r,o;const a=(r=iw(e,n))!==null&&r!==void 0?r:{},i=aw(t);return(o=a[i])!==null&&o!==void 0?o:null}function DN(e,t,n,r,o){var a;const i=sw(e),l=aw(t),c=(a=iw(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 Vp({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(!nr(r,100)&&n.length>0)for(let a=0;a<t.length;a++){const i=n[a];mt(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];mt(i!=null,`No layout data found for index ${a}`);const l=Rs({panelConstraints:t,panelIndex:a,size:i});i!=l&&(o+=i-l,n[a]=l)}if(!nr(o,0))for(let a=0;a<t.length;a++){const i=n[a];mt(i!=null,`No layout data found for index ${a}`);const l=i+o,c=Rs({panelConstraints:t,panelIndex:a,size:l});if(i!==c&&(o-=c-i,n[a]=c,nr(o,0)))break}return n}const ON=100,Na={getItem:e=>(Bp(Na),Na.getItem(e)),setItem:(e,t)=>{Bp(Na),Na.setItem(e,t)}},Wp={};function lw({autoSaveId:e=null,children:t,className:n="",direction:r,forwardedRef:o,id:a=null,onLayout:i=null,keyboardResizeBy:l=null,storage:c=Na,style:u,tagName:f="div",...h}){const p=Nf(a),m=d.useRef(null),[x,g]=d.useState(null),[v,w]=d.useState([]),b=SN(),C=d.useRef({}),_=d.useRef(new Map),E=d.useRef(0),S=d.useRef({autoSaveId:e,direction:r,dragState:x,id:p,keyboardResizeBy:l,onLayout:i,storage:c}),j=d.useRef({layout:v,panelDataArray:[],panelDataArrayChanged:!1});d.useRef({didLogIdAndOrderWarning:!1,didLogPanelConstraintsWarning:!1,prevPanelIds:[]}),d.useImperativeHandle(o,()=>({getId:()=>S.current.id,getLayout:()=>{const{layout:U}=j.current;return U},setLayout:U=>{const{onLayout:X}=S.current,{layout:W,panelDataArray:te}=j.current,$=Vp({layout:U,panelConstraints:te.map(q=>q.constraints)});Up(W,$)||(w($),j.current.layout=$,X&&X($),ks(te,$,C.current))}}),[]),Xo(()=>{S.current.autoSaveId=e,S.current.direction=r,S.current.dragState=x,S.current.id=p,S.current.onLayout=i,S.current.storage=c}),NN({committedValuesRef:S,eagerValuesRef:j,groupId:p,layout:v,panelDataArray:j.current.panelDataArray,setLayout:w,panelGroupElement:m.current}),d.useEffect(()=>{const{panelDataArray:U}=j.current;if(e){if(v.length===0||v.length!==U.length)return;let X=Wp[e];X==null&&(X=PN(DN,ON),Wp[e]=X);const W=[...U],te=new Map(_.current);X(e,W,te,v,c)}},[e,v,c]),d.useEffect(()=>{});const A=d.useCallback(U=>{const{onLayout:X}=S.current,{layout:W,panelDataArray:te}=j.current;if(U.constraints.collapsible){const $=te.map(ue=>ue.constraints),{collapsedSize:q=0,panelSize:Y,pivotIndices:re}=Yo(te,U,W);if(mt(Y!=null,`Panel size not found for panel "${U.id}"`),!lo(Y,q)){_.current.set(U.id,Y);const ce=As(te,U)===te.length-1?Y-q:q-Y,pe=Ea({delta:ce,initialLayout:W,panelConstraints:$,pivotIndices:re,prevLayout:W,trigger:"imperative-api"});Mi(W,pe)||(w(pe),j.current.layout=pe,X&&X(pe),ks(te,pe,C.current))}}},[]),I=d.useCallback((U,X)=>{const{onLayout:W}=S.current,{layout:te,panelDataArray:$}=j.current;if(U.constraints.collapsible){const q=$.map(k=>k.constraints),{collapsedSize:Y=0,panelSize:re=0,minSize:ue=0,pivotIndices:ce}=Yo($,U,te),pe=X??ue;if(lo(re,Y)){const k=_.current.get(U.id),oe=k!=null&&k>=pe?k:pe,G=As($,U)===$.length-1?re-oe:oe-re,V=Ea({delta:G,initialLayout:te,panelConstraints:q,pivotIndices:ce,prevLayout:te,trigger:"imperative-api"});Mi(te,V)||(w(V),j.current.layout=V,W&&W(V),ks($,V,C.current))}}},[]),P=d.useCallback(U=>{const{layout:X,panelDataArray:W}=j.current,{panelSize:te}=Yo(W,U,X);return mt(te!=null,`Panel size not found for panel "${U.id}"`),te},[]),F=d.useCallback((U,X)=>{const{panelDataArray:W}=j.current,te=As(W,U);return RN({defaultSize:X,dragState:x,layout:v,panelData:W,panelIndex:te})},[x,v]),N=d.useCallback(U=>{const{layout:X,panelDataArray:W}=j.current,{collapsedSize:te=0,collapsible:$,panelSize:q}=Yo(W,U,X);return mt(q!=null,`Panel size not found for panel "${U.id}"`),$===!0&&lo(q,te)},[]),R=d.useCallback(U=>{const{layout:X,panelDataArray:W}=j.current,{collapsedSize:te=0,collapsible:$,panelSize:q}=Yo(W,U,X);return mt(q!=null,`Panel size not found for panel "${U.id}"`),!$||os(q,te)>0},[]),y=d.useCallback(U=>{const{panelDataArray:X}=j.current;X.push(U),X.sort((W,te)=>{const $=W.order,q=te.order;return $==null&&q==null?0:$==null?-1:q==null?1:$-q}),j.current.panelDataArrayChanged=!0,b()},[b]);Xo(()=>{if(j.current.panelDataArrayChanged){j.current.panelDataArrayChanged=!1;const{autoSaveId:U,onLayout:X,storage:W}=S.current,{layout:te,panelDataArray:$}=j.current;let q=null;if(U){const re=MN(U,$,W);re&&(_.current=new Map(Object.entries(re.expandToSizes)),q=re.layout)}q==null&&(q=IN({panelDataArray:$}));const Y=Vp({layout:q,panelConstraints:$.map(re=>re.constraints)});Up(te,Y)||(w(Y),j.current.layout=Y,X&&X(Y),ks($,Y,C.current))}}),Xo(()=>{const U=j.current;return()=>{U.layout=[]}},[]);const T=d.useCallback(U=>{let X=!1;const W=m.current;return W&&window.getComputedStyle(W,null).getPropertyValue("direction")==="rtl"&&(X=!0),function($){$.preventDefault();const q=m.current;if(!q)return()=>null;const{direction:Y,dragState:re,id:ue,keyboardResizeBy:ce,onLayout:pe}=S.current,{layout:k,panelDataArray:oe}=j.current,{initialLayout:ae}=re??{},G=nw(ue,U,q);let V=AN($,U,Y,re,ce,q);const ne=Y==="horizontal";ne&&X&&(V=-V);const B=oe.map(le=>le.constraints),K=Ea({delta:V,initialLayout:ae??k,panelConstraints:B,pivotIndices:G,prevLayout:k,trigger:Zv($)?"keyboard":"mouse-or-touch"}),Z=!Mi(k,K);(Gv($)||Yv($))&&E.current!=V&&(E.current=V,!Z&&V!==0?ne?ru(U,V<0?qv:Xv):ru(U,V<0?Jv:Qv):ru(U,0)),Z&&(w(K),j.current.layout=K,pe&&pe(K),ks(oe,K,C.current))}},[]),D=d.useCallback((U,X)=>{const{onLayout:W}=S.current,{layout:te,panelDataArray:$}=j.current,q=$.map(k=>k.constraints),{panelSize:Y,pivotIndices:re}=Yo($,U,te);mt(Y!=null,`Panel size not found for panel "${U.id}"`);const ce=As($,U)===$.length-1?Y-X:X-Y,pe=Ea({delta:ce,initialLayout:te,panelConstraints:q,pivotIndices:re,prevLayout:te,trigger:"imperative-api"});Mi(te,pe)||(w(pe),j.current.layout=pe,W&&W(pe),ks($,pe,C.current))},[]),L=d.useCallback((U,X)=>{const{layout:W,panelDataArray:te}=j.current,{collapsedSize:$=0,collapsible:q}=X,{collapsedSize:Y=0,collapsible:re,maxSize:ue=100,minSize:ce=0}=U.constraints,{panelSize:pe}=Yo(te,U,W);pe!=null&&(q&&re&&lo(pe,$)?lo($,Y)||D(U,Y):pe<ce?D(U,ce):pe>ue&&D(U,ue))},[D]),O=d.useCallback((U,X)=>{const{direction:W}=S.current,{layout:te}=j.current;if(!m.current)return;const $=dc(U,m.current);mt($,`Drag handle element not found for id "${U}"`);const q=ow(W,X);g({dragHandleId:U,dragHandleRect:$.getBoundingClientRect(),initialCursorPosition:q,initialLayout:te})},[]),M=d.useCallback(()=>{g(null)},[]),J=d.useCallback(U=>{const{panelDataArray:X}=j.current,W=As(X,U);W>=0&&(X.splice(W,1),delete C.current[U.id],j.current.panelDataArrayChanged=!0,b())},[b]),z=d.useMemo(()=>({collapsePanel:A,direction:r,dragState:x,expandPanel:I,getPanelSize:P,getPanelStyle:F,groupId:p,isPanelCollapsed:N,isPanelExpanded:R,reevaluatePanelConstraints:L,registerPanel:y,registerResizeHandle:T,resizePanel:D,startDragging:O,stopDragging:M,unregisterPanel:J,panelGroupElement:m.current}),[A,x,r,I,P,F,p,N,R,L,y,T,D,O,M,J]),H={display:"flex",flexDirection:r==="horizontal"?"row":"column",height:"100%",overflow:"hidden",width:"100%"};return d.createElement(lc.Provider,{value:z},d.createElement(f,{...h,children:t,className:n,id:a,ref:m,style:{...H,...u},[cn.group]:"",[cn.groupDirection]:r,[cn.groupId]:p}))}const cw=d.forwardRef((e,t)=>d.createElement(lw,{...e,forwardedRef:t}));lw.displayName="PanelGroup";cw.displayName="forwardRef(PanelGroup)";function As(e,t){return e.findIndex(n=>n===t||n.id===t.id)}function Yo(e,t,n){const r=As(e,t),a=r===e.length-1?[r-1,r]:[r,r+1],i=n[r];return{...t.constraints,panelSize:i,pivotIndices:a}}function LN({disabled:e,handleId:t,resizeHandler:n,panelGroupElement:r}){d.useEffect(()=>{if(e||n==null||r==null)return;const o=dc(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(cn.groupId);mt(l,`No group element found for id "${l}"`);const c=Wa(l,r),u=tw(l,t,r);mt(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 uw({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:p=0,tagName:m="div",...x}){var g,v;const w=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(lc);if(C===null)throw Error("PanelResizeHandle components must be rendered within a PanelGroup container");const{direction:_,groupId:E,registerResizeHandle:S,startDragging:j,stopDragging:A,panelGroupElement:I}=C,P=Nf(o),[F,N]=d.useState("inactive"),[R,y]=d.useState(!1),[T,D]=d.useState(null),L=d.useRef({state:F});Xo(()=>{L.current.state=F}),d.useEffect(()=>{if(n)D(null);else{const z=S(P);D(()=>z)}},[n,P,S]);const O=(g=r==null?void 0:r.coarse)!==null&&g!==void 0?g:15,M=(v=r==null?void 0:r.fine)!==null&&v!==void 0?v:5;d.useEffect(()=>{if(n||T==null)return;const z=w.current;mt(z,"Element ref not attached");let H=!1;return yN(P,z,_,{coarse:O,fine:M},(X,W,te)=>{if(!W){N("inactive");return}switch(X){case"down":{N("drag"),H=!1,mt(te,'Expected event to be defined for "down" action'),j(P,te);const{onDragging:$,onPointerDown:q}=b.current;$==null||$(!0),q==null||q();break}case"move":{const{state:$}=L.current;H=!0,$!=="drag"&&N("hover"),mt(te,'Expected event to be defined for "move" action'),T(te);break}case"up":{N("hover"),A();const{onClick:$,onDragging:q,onPointerUp:Y}=b.current;q==null||q(!1),Y==null||Y(),H||$==null||$();break}}})},[O,_,n,M,S,P,T,j,A]),LN({disabled:n,handleId:P,resizeHandler:T,panelGroupElement:I});const J={touchAction:"none",userSelect:"none"};return d.createElement(m,{...x,children:e,className:t,id:o,onBlur:()=>{y(!1),a==null||a()},onFocus:()=>{y(!0),c==null||c()},ref:w,role:"separator",style:{...J,...h},tabIndex:p,[cn.groupDirection]:_,[cn.groupId]:E,[cn.resizeHandle]:"",[cn.resizeHandleActive]:F==="drag"?"pointer":R?"keyboard":void 0,[cn.resizeHandleEnabled]:!n,[cn.resizeHandleId]:P,[cn.resizeHandleState]:F})}uw.displayName="PanelResizeHandle";function dw({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 kl({className:e,...t}){return s.jsx(Hv,{"data-slot":"resizable-panel",className:ze("bg-transparent",e),...t})}function fw({withHandle:e,className:t,...n}){return s.jsx(uw,{"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(N1,{className:"size-2.5"})})})}function ed({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 FN=d.forwardRef(({className:e,...t},n)=>s.jsx("ul",{ref:n,className:ze("flex flex-row items-center gap-1",e),...t}));FN.displayName="PaginationContent";const zN=d.forwardRef(({className:e,...t},n)=>s.jsx("li",{ref:n,className:ze("",e),...t}));zN.displayName="PaginationItem";function $N({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 UN({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 BN={x:0,y:0},pr=16,VN=["top-start","bottom-end","top-end"];function WN({anchorRef:e,placement:t="top-start",offset:n=BN,fallbackPlacements:r=VN}){const o=d.useCallback((c,u,f)=>{let h=0,p=0;switch(f){case"top":h=c.top-u.height-n.y,p=c.left+(c.width-u.width)/2+n.x;break;case"top-start":h=c.top-u.height-n.y,p=c.left+n.x;break;case"top-end":h=c.top-u.height-n.y,p=c.right-u.width-n.x;break;case"bottom":h=c.bottom+n.y,p=c.left+(c.width-u.width)/2+n.x;break;case"bottom-start":h=c.bottom+n.y,p=c.left+n.x;break;case"bottom-end":h=c.bottom+n.y,p=c.right-u.width-n.x;break;case"left":h=c.top+(c.height-u.height)/2+n.y,p=c.left-u.width-n.x;break;case"left-start":h=c.top+n.y,p=c.left-u.width-n.x;break;case"left-end":h=c.bottom-u.height-n.y,p=c.left-u.width-n.x;break;case"right":h=c.top+(c.height-u.height)/2+n.y,p=c.right+n.x;break;case"right-start":h=c.top+n.y,p=c.right+n.x;break;case"right-end":h=c.bottom-u.height-n.y,p=c.right+n.x;break}return console.log(`Calculated position for ${f}:`,{top:h,left:p}),{top:h,left:p,placement:f}},[n.x,n.y]),a=d.useCallback((c,u)=>{const f={width:window.innerWidth,height:window.innerHeight};return c.left<pr||c.top<pr||c.left+u.width>f.width-pr||c.top+u.height>f.height-pr},[]),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 p={width:window.innerWidth,height:window.innerHeight},m={...h};return m.left<pr?m.left=pr:m.left+f.width>p.width-pr&&(m.left=p.width-f.width-pr),m.top<pr?m.top=pr:m.top+f.height>p.height-pr&&(m.top=p.height-f.height-pr),m},[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 HN({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(w=>{w.preventDefault(),c(!0),u.current=w.clientX,f.current=a},[a]),p=d.useCallback(w=>{if(!l)return;const b=w.clientX-u.current,C=r==="right"?-b:b,_=Math.min(Math.max(f.current+C,t),n);i(_),o==null||o(_)},[l,t,n,r,o]),m=d.useCallback(()=>{c(!1)},[]),x=d.useCallback(w=>{w.preventDefault(),c(!0),u.current=w.touches[0].clientX,f.current=a},[a]),g=d.useCallback(w=>{if(!l)return;const b=w.touches[0].clientX-u.current,C=r==="right"?-b:b,_=Math.min(Math.max(f.current+C,t),n);i(_),o==null||o(_)},[l,t,n,r,o]),v=d.useCallback(()=>{c(!1)},[]);return d.useEffect(()=>{if(l)return document.addEventListener("mousemove",p),document.addEventListener("mouseup",m),document.addEventListener("touchmove",g),document.addEventListener("touchend",v),document.body.style.userSelect="none",document.body.style.cursor="col-resize",()=>{document.removeEventListener("mousemove",p),document.removeEventListener("mouseup",m),document.removeEventListener("touchmove",g),document.removeEventListener("touchend",v),document.body.style.userSelect="",document.body.style.cursor=""}},[l,p,m,g,v]),{width:a,isResizing:l,handleMouseDown:h,handleTouchStart:x,setWidth:i}}const ZN=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:p,handleTouchStart:m}=HN({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:p,onTouchStart:m,role:"separator","aria-orientation":"vertical","aria-label":`Resize ${o} panel`,tabIndex:0,onKeyDown:w=>{if(w.key==="ArrowLeft"||w.key==="ArrowRight"){w.preventDefault();const b=w.key==="ArrowRight"?10:-10,C=o==="right"?-b:b,_=Math.min(Math.max(f+C,n),r);l==null||l(_)}},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)]")})})]})});ZN.displayName="SidePanel";const GN="https://solace.com/a2a/extensions/display-name",YN="https://solace.com/a2a/extensions/peer-agent-topology",KN="https://solace.com/a2a/extensions/sam/tools",qN=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===GN);(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===YN);(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===KN);(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||[]}},XN=()=>{const[e,t]=d.useState([]),[n,r]=d.useState(!1),[o,a]=d.useState(null),i=d.useCallback(async()=>{r(!0),a(null);try{const u=(await je.webui.get("/api/v1/agentCards")).map(qN);t(u)}catch(c){console.error("Error fetching agents:",c),a(c instanceof Error?c.message:"Could not load agent information."),t([])}finally{r(!1)}},[]);d.useEffect(()=>{i()},[i]);const l=d.useMemo(()=>{const c={};return e.forEach(u=>{u.name&&(c[u.name]=u.displayName||u.name)}),c},[e]);return d.useMemo(()=>({agents:e,agentNameMap:l,isLoading:n,error:o,refetch:i}),[e,l,n,o,i])},JN=(e,t,n,r)=>{const o=e.find(a=>a.filename===t);return{name:t,mime_type:n,content:r,last_modified:(o==null?void 0:o.last_modified)||new Date().toISOString()}},QN=({sessionId:e,artifacts:t,setArtifacts:n,artifactsRefetch:r,addNotification:o,setError:a,previewArtifact:i,closePreview:l})=>{const[c,u]=d.useState(!1),[f,h]=d.useState(null),[p,m]=d.useState(!1),[x,g]=d.useState(!1),[v,w]=d.useState(new Set),b=d.useRef(new Set),C=d.useCallback(async(F,N,R,y=!1)=>{const T=N||e,D=new FormData;if(D.append("upload_file",F),D.append("filename",F.name),D.append("sessionId",T||""),R){const L={description:R};D.append("metadata_json",JSON.stringify(L))}try{const L=await je.webui.post("/api/v1/artifacts/upload",D,{fullResponse:!0});if(L.status===413){const M=await L.json().catch(()=>({message:`Failed to upload ${F.name}.`})),J=M.actual_size_bytes,z=M.max_size_bytes,H=J&&z?gk(F.name,J,z):M.message||`File "${F.name}" exceeds the maximum allowed size.`;return a({title:"File Upload Failed",error:H}),{error:H}}if(!L.ok)throw new Error(await L.json().then(M=>M.message).catch(()=>`Failed to upload ${F.name}.`));const O=await L.json();return y||o(`File "${F.name}" uploaded.`,"success"),await r(),O.uri&&O.sessionId?{uri:O.uri,sessionId:O.sessionId}:null}catch(L){const O=Ut(L,`Failed to upload "${F.name}".`);return a({title:"File Upload Failed",error:O}),{error:O}}},[e,o,r,a]),_=d.useCallback(async F=>{try{await je.webui.delete(`/api/v1/artifacts/${e}/${encodeURIComponent(F)}`),o(`File "${F}" deleted.`,"success"),r()}catch(N){a({title:"File Deletion Failed",error:Ut(N,`Failed to delete ${F}.`)})}},[e,o,r,a]),E=d.useCallback(F=>{h(F),u(!0)},[]),S=d.useCallback(()=>{h(null),u(!1)},[]),j=d.useCallback(async()=>{if(f){const F=(i==null?void 0:i.filename)===f.filename;await _(f.filename),F&&l()}S()},[f,_,S,i,l]),A=d.useCallback(()=>{v.size!==0&&m(!0)},[v]),I=d.useCallback(async()=>{m(!1);const F=Array.from(v);let N=0,R=0;for(const y of F)try{await je.webui.delete(`/api/v1/artifacts/${e}/${encodeURIComponent(y)}`),N++}catch(T){console.error(T),R++}N>0&&o(`${N} files(s) deleted.`,"success"),R>0&&a({title:"File Deletion Failed",error:`${R} file(s) failed to delete.`}),r(),w(new Set),g(!1)},[v,o,r,e,a]),P=d.useCallback(async F=>{if(b.current.has(F))return console.log(`[useArtifactOperations] Skipping duplicate download for ${F} - already in progress`),null;b.current.add(F);try{const N=t.find(M=>M.filename===F);if(!N)return console.error(`Artifact ${F} not found in state`),null;const R=await je.webui.get(`/api/v1/artifacts/${e}/${encodeURIComponent(F)}/versions`);if(!R||R.length===0)throw new Error("No versions available");const y=Math.max(...R),T=await je.webui.get(`/api/v1/artifacts/${e}/${encodeURIComponent(F)}/versions/${y}`,{fullResponse:!0});if(!T.ok)throw new Error(`Failed to fetch artifact content: ${T.statusText}`);const D=await T.blob(),L=await Sx(D),O=JN(t,F,N.mime_type||"application/octet-stream",L);return n(M=>M.map(J=>J.filename===F?{...J,accumulatedContent:void 0,needsEmbedResolution:!1}:J)),O}catch(N){return a({title:"File Download Failed",error:Ut(N,`Failed to download ${F}.`)}),null}finally{b.current.delete(F)}},[e,t,n,a]);return{uploadArtifactFile:C,isDeleteModalOpen:c,artifactToDelete:f,openDeleteModal:E,closeDeleteModal:S,confirmDelete:j,isArtifactEditMode:x,setIsArtifactEditMode:g,selectedArtifactFilenames:v,setSelectedArtifactFilenames:w,isBatchDeleteModalOpen:p,setIsBatchDeleteModalOpen:m,handleDeleteSelectedArtifacts:A,confirmBatchDeleteArtifacts:I,downloadAndResolveArtifact:P}},eT=({sessionId:e,projectId:t,artifacts:n,setError:r})=>{const[o,a]=d.useState({filename:null,availableVersions:null,currentVersion:null,content:null}),[i,l]=d.useState(!1),c=d.useRef(new Set),u=d.useMemo(()=>o.filename&&n.find(g=>g.filename===o.filename)||null,[n,o.filename]),f=d.useCallback((g,v,w)=>{const b=n.find(C=>C.filename===g);return{name:g,mime_type:v,content:w,last_modified:(b==null?void 0:b.last_modified)||new Date().toISOString()}},[n]),h=d.useCallback(async g=>{if(c.current.has(g))return null;c.current.add(g),l(!0),o.filename!==g&&a({filename:g,availableVersions:null,currentVersion:null,content:null});try{const v=_x({filename:g,sessionId:e,projectId:t}),w=await je.webui.get(v);if(!w||w.length===0)throw new Error("No versions available");const b=w.sort((j,A)=>j-A),C=Math.max(...w),{content:_,mimeType:E}=await ep({filename:g,sessionId:e,projectId:t,version:C}),S=f(g,E,_);return a({filename:g,availableVersions:b,currentVersion:C,content:S}),S}catch(v){const w=Ut(v,"Failed to load artifact preview.");return r==null||r({title:"Artifact Preview Failed",error:w}),null}finally{l(!1),c.current.delete(g)}},[e,t,o.filename,f,r]),p=d.useCallback(async(g,v)=>{if(!o.availableVersions||o.availableVersions.length===0)return null;if(!o.availableVersions.includes(v))return console.warn(`Requested version ${v} not available for ${g}`),null;l(!0),a(w=>({...w,content:null}));try{const{content:w,mimeType:b}=await ep({filename:g,sessionId:e,projectId:t,version:v}),C=f(g,b,w);return a(_=>({..._,currentVersion:v,content:C})),C}catch(w){const b=Ut(w,"Failed to fetch artifact version.");return r==null||r({title:"Artifact Version Preview Failed",error:b}),null}finally{l(!1)}},[e,t,o.availableVersions,f,r]),m=d.useCallback(()=>{a({filename:null,availableVersions:null,currentVersion:null,content:null})},[]),x=d.useCallback(g=>{g?o.filename!==g.filename&&a({filename:g.filename,availableVersions:null,currentVersion:null,content:null}):m()},[o.filename,m]);return{preview:o,previewArtifact:u,isLoading:i,openPreview:h,navigateToVersion:p,closePreview:m,setPreviewByArtifact:x}};function tT(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 nT(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 rT(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 oT(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 sT(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 aT(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 iT(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 lT(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 cT(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 Er(e,t){return nT(e,t)?"html":rT(e,t)?"mermaid":sT(e,t)?"image":lT(e,t)?"markdown":cT(e,t)?"audio":aT(e,t)?"json":iT(e,t)?"yaml":oT(e,t)?"csv":tT(e,t)?"text":null}function hw(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"],uT=["image","audio"],mw=e=>{if(!e||!e.content)return"";const t=Er(e.name,e.mime_type);if(!t||!pw.includes(t))return"";if(uT.includes(t))return e.content;if(e.isPlainText)return console.log("Content is plain text from streaming, returning as-is"),e.content;try{return hw(e.content)}catch(n){return console.error("Failed to decode base64 content:",n),""}},gw=5*1024*1024,dT=ri(gw);function fT(e){if(!e||!e.size)return{canPreview:!1,reason:"No artifact or content available."};const t=Er(e.filename,e.mime_type);return!t||!pw.includes(t)?{canPreview:!1,reason:"Preview not yet supported for this file type."}:e.size>gw?{canPreview:!1,reason:`Preview not supported for files this large. Maximum size is: ${dT}.`}:{canPreview:!0}}const If=(e,t="h-4 w-4")=>{if(!e)return s.jsx(Nu,{className:t});switch(Er(e.filename,e.mime_type)){case"image":case"mermaid":return s.jsx(Iu,{className:t});case"audio":return s.jsx(Au,{className:t});case"html":return s.jsx(pg,{className:t});case"text":return s.jsx(gr,{className:t});case"csv":return s.jsx(Tu,{className:t});case"json":return s.jsx(Da,{className:t});default:return s.jsx(Nu,{className:t})}},hT=(e,t)=>{const n=Er(e,t);return n==="image"||n==="audio"||n==="text"||n==="markdown"},pT=(e,t)=>{const n=Er(e,t);return n?["text","markdown","json","yaml","csv","html","image","audio"].includes(n):!1},mT=({filename:e,mimeType:t,shouldAutoExpand:n})=>{const r=d.useMemo(()=>hT(e,t),[e,t]),[o,a]=d.useState(()=>n??r),i=d.useRef(!1);d.useEffect(()=>{n&&!o&&!i.current&&a(!0)},[n,o]);const l=d.useMemo(()=>pT(e,t),[e,t]),c=d.useMemo(()=>l?o:!1,[l,o]),u=d.useMemo(()=>l,[l]),f=d.useCallback(()=>{if(!e||!u){console.log(`[useArtifactRendering] Toggle blocked - filename: ${e}, isExpandable: ${u}`);return}i.current=!0,a(h=>{const p=!h;return console.log(`[useArtifactRendering] ${p?"Expanding":"Collapsing"} ${e}`),p})},[e,u]);return{shouldRender:c,isExpandable:u,isExpanded:o,toggleExpanded:f}},su="lastViewedProjectId",xw=d.createContext(void 0);let td=null;const gT=e=>{td=e},xT=({children:e})=>{const{projectsEnabled:t}=sn(),[n,r]=d.useState([]),[o,a]=d.useState(!0),[i,l]=d.useState(null),[c,u]=d.useState(null),[f,h]=d.useState(null),[p,m]=d.useState(null),[x,g]=d.useState(""),v=d.useMemo(()=>{if(!x.trim())return n;const P=x.toLowerCase();return n.filter(F=>{var N;return F.name.toLowerCase().includes(P)||(((N=F.description)==null?void 0:N.toLowerCase().includes(P))??!1)})},[n,x]),w=d.useCallback(async()=>{if(!t){a(!1),r([]);return}a(!0),l(null);try{const F=[...(await je.webui.get("/api/v1/projects?include_artifact_count=true")).projects].sort((N,R)=>N.name.toLowerCase().localeCompare(R.name.toLowerCase()));r(F)}catch(P){console.error("Error fetching projects:",P),l(P instanceof Error?P.message:"Could not load projects."),r([])}finally{a(!1)}},[t]),b=d.useCallback(async P=>{if(!t)throw new Error("Projects feature is disabled");const F=await je.webui.post("/api/v1/projects",P);return r(N=>[F,...N].sort((y,T)=>y.name.toLowerCase().localeCompare(T.name.toLowerCase()))),F},[t]),C=d.useCallback(async(P,F)=>{if(!t)throw new Error("Projects feature is disabled");const N=await je.webui.post(`/api/v1/projects/${P}/artifacts`,F,{fullResponse:!0});if(!N.ok){const R=await N.text();let y=`Failed to add files: ${N.statusText}`;try{const T=JSON.parse(R);y=T.detail||T.message||y}catch{R&&R.length<500&&(y=R)}throw N.status===413&&!y.includes("exceeds maximum")&&!y.includes("too large")&&(y="One or more files exceed the maximum allowed size. Please try uploading smaller files."),new Error(y)}l(null),await w()},[t,w]),_=d.useCallback(async(P,F)=>{if(!t)throw new Error("Projects feature is disabled");await je.webui.delete(`/api/v1/projects/${P}/artifacts/${encodeURIComponent(F)}`),l(null),await w()},[t,w]),E=d.useCallback(async(P,F,N)=>{if(!t)throw new Error("Projects feature is disabled");const R=new FormData;R.append("description",N),await je.webui.patch(`/api/v1/projects/${P}/artifacts/${encodeURIComponent(F)}`,R),l(null)},[t]),S=d.useCallback(async(P,F)=>{if(!t)throw new Error("Projects feature is disabled");const N=await je.webui.put(`/api/v1/projects/${P}`,F,{fullResponse:!0});if(!N.ok){let y=`Failed to update project: ${N.statusText}`;try{const T=await N.json();N.status===422?T.detail&&(Array.isArray(T.detail)?y=`Validation error: ${T.detail.map(L=>{var M;return`${((M=L.loc)==null?void 0:M.join("."))||"field"}: ${L.msg}`}).join(", ")}`:typeof T.detail=="string"&&(y=T.detail)):y=T.detail||T.message||y}catch{}throw new Error(y)}const R=await N.json();return r(y=>y.map(D=>D.id===R.id?R:D).sort((D,L)=>D.name.toLowerCase().localeCompare(L.name.toLowerCase()))),u(y=>(y==null?void 0:y.id)===R.id?R:y),h(y=>(y==null?void 0:y.id)===R.id?R:y),m(y=>(y==null?void 0:y.id)===R.id?R:y),l(null),R},[t]),j=d.useCallback(async P=>{if(!t)throw new Error("Projects feature is disabled");await je.webui.delete(`/api/v1/projects/${P}`),r(F=>F.filter(N=>N.id!==P)),u(F=>(F==null?void 0:F.id)===P?null:F),h(F=>(F==null?void 0:F.id)===P?null:F),m(F=>(F==null?void 0:F.id)===P?null:F),l(null),td&&td(P)},[t]);d.useEffect(()=>{w()},[w]),d.useEffect(()=>{if(n.length>0&&!f){const P=localStorage.getItem(su);if(P){const F=n.find(N=>N.id===P);F&&h(F)}}},[n,f]);const A=d.useCallback(P=>{h(P),P?localStorage.setItem(su,P.id):localStorage.removeItem(su)},[]),I={projects:n,isLoading:o,error:i,createProject:b,refetch:w,currentProject:c,setCurrentProject:u,selectedProject:f,setSelectedProject:A,activeProject:p,setActiveProject:m,addFilesToProject:C,removeFileFromProject:_,updateFileMetadata:E,updateProject:S,deleteProject:j,searchQuery:x,setSearchQuery:g,filteredProjects:v};return s.jsx(xw.Provider,{value:I,children:e})},bo=()=>{const e=d.useContext(xw);if(e===void 0)throw new Error("useProjectContext must be used within a ProjectProvider");return e},vT=e=>{const{activeProject:t}=bo(),[n,r]=d.useState([]),[o,a]=d.useState(!0),[i,l]=d.useState(null),c=d.useCallback(async()=>{a(!0),l(null);try{let u;if(e&&e.trim()&&e!=="null"&&e!=="undefined")u=`/api/v1/artifacts/${e}`;else if(t!=null&&t.id)u=`/api/v1/artifacts/null?project_id=${t.id}`;else{r([]),a(!1);return}const h=(await je.webui.get(u)).map(p=>({...p,uri:p.uri||`artifact://${e}/${p.filename}`}));r(h)}catch(u){const f=u instanceof Error?u.message:"Failed to fetch artifacts.";l(f),r([])}finally{a(!1)}},[e,t==null?void 0:t.id]);return d.useEffect(()=>{c()},[c]),{artifacts:n,isLoading:o,error:i,refetch:c,setArtifacts:r}},vw=d.createContext(void 0),ao={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"},al={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 wT(){const e={...al};try{Object.entries(ao).forEach(([t,n])=>{const r=localStorage.getItem(n);if(r!==null){const o=t;typeof al[o]=="boolean"?e[o]=r==="true":typeof al[o]=="number"?e[o]=parseFloat(r):e[o]=r}})}catch(t){console.error("Error loading audio settings from storage:",t)}return e}const bT=({children:e})=>{const[t,n]=d.useState(wT),[r,o]=d.useState(!1),[a,i]=d.useState(!1);d.useEffect(()=>{(async()=>{try{const g=(await je.webui.get("/api/v1/config")).tts_settings||{};let v=!1,w=!1;try{const b=await je.webui.get("/api/v1/speech/config");v=b.sttExternal||!1,w=b.ttsExternal||!1}catch(b){console.error("Error fetching speech config:",b)}n(b=>{const C={...b};return Object.entries(g).forEach(([_,E])=>{const S=_,j=ao[S];S in C&&j&&localStorage.getItem(j)===null&&(C[S]=E)}),C.engineSTT==="external"&&!v&&(console.warn("External STT not configured, falling back to browser mode"),C.engineSTT="browser",C.sttProvider="browser",localStorage.setItem(ao.engineSTT,"browser"),localStorage.setItem(ao.sttProvider,"browser")),C.engineTTS==="external"&&!w&&(console.warn("External TTS not configured, falling back to browser mode"),C.engineTTS="browser",C.ttsProvider="browser",localStorage.setItem(ao.engineTTS,"browser"),localStorage.setItem(ao.ttsProvider,"browser")),C})}catch(x){console.error("Error fetching TTS config from config endpoint:",x)}finally{o(!0)}})()},[]);const l=d.useCallback((m,x)=>{n(g=>{const v={...g,[m]:x},w=ao[m];return w&&(localStorage.setItem(w,String(x)),console.log(`Saved ${m} = ${x} to localStorage as ${w}`)),v})},[]),c=d.useCallback(m=>{n(x=>{const g={...x,...m};return Object.entries(m).forEach(([v,w])=>{const b=ao[v];b&&localStorage.setItem(b,String(w))}),g})},[]),u=d.useCallback(()=>{n(al),Object.values(ao).forEach(m=>{localStorage.removeItem(m)})},[]),f=d.useCallback(()=>{i(!0)},[]),h=d.useCallback(()=>{i(!1)},[]),p={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(vw.Provider,{value:p,children:e})};function Uo(){const e=d.useContext(vw);if(!e)throw new Error("useAudioSettings must be used within AudioSettingsProvider");return e}const ww=d.createContext(null),bw=()=>{const e=d.useContext(ww);if(!e)throw new Error("useAuth must be used within an AuthProvider");return e},Di="sam_background_tasks";function yT({userId:e,onTaskCompleted:t,onTaskFailed:n}){const[r,o]=d.useState([]),[a,i]=d.useState([]);d.useEffect(()=>{const v=localStorage.getItem(Di);if(v)try{const w=JSON.parse(v);o(w)}catch(w){console.error("[BackgroundTaskMonitor] Failed to parse stored tasks:",w),localStorage.removeItem(Di)}},[]),d.useEffect(()=>{r.length>0?localStorage.setItem(Di,JSON.stringify(r)):localStorage.removeItem(Di)},[r]);const l=d.useCallback((v,w,b)=>{const C={taskId:v,sessionId:w,lastEventTimestamp:Date.now(),isBackground:!0,startTime:Date.now(),agentName:b};o(_=>_.some(E=>E.taskId===v)?_:[..._,C])},[]),c=d.useCallback(v=>{o(w=>w.filter(C=>C.taskId!==v))},[]),u=d.useCallback((v,w)=>{o(b=>b.map(C=>C.taskId===v?{...C,lastEventTimestamp:w}:C))},[]),f=d.useCallback(async v=>{try{const w=await je.webui.get(`/api/v1/tasks/${v}/status`,{fullResponse:!0});return w.ok?await w.json():(w.status===404&&c(v),null)}catch(w){return console.error(`[BackgroundTaskMonitor] Failed to check status for task ${v}:`,w),null}},[c]),h=d.useCallback(async()=>{if(r.length!==0)for(const v of r){const w=await f(v.taskId);if(w&&!w.is_running){const b=w.task.status;let C="completed",_="Background task completed";b==="failed"||b==="error"?(C="failed",_="Background task failed"):b==="timeout"&&(C="timeout",_="Background task timed out");const E={taskId:v.taskId,type:C,message:_,timestamp:Date.now()};i(S=>[...S,E]),C==="completed"&&t?t(v.taskId):C!=="completed"&&n&&n(v.taskId,_),c(v.taskId)}}},[r,f,t,n,c]),p=d.useCallback(async()=>{try{return(await je.webui.get(`/api/v1/tasks/background/active?user_id=${encodeURIComponent(e)}`)).tasks.map(w=>({taskId:w.id,sessionId:"",lastEventTimestamp:w.last_activity_time||w.start_time,isBackground:!0,startTime:w.start_time}))}catch(v){return console.error("[BackgroundTaskMonitor] Failed to fetch active background tasks:",v),[]}},[e]);d.useEffect(()=>{(async()=>{const w=await p();o(b=>{const C=[...b];for(const _ of w)C.some(E=>E.taskId===_.taskId)||C.push(_);return C})})()},[e,p]);const m=d.useCallback(v=>{i(w=>w.filter(b=>b.taskId!==v))},[]),x=d.useCallback(v=>r.filter(w=>w.sessionId===v),[r]),g=d.useCallback(v=>r.some(w=>w.taskId===v),[r]);return{backgroundTasks:r,notifications:a,registerBackgroundTask:l,unregisterBackgroundTask:c,updateTaskTimestamp:u,checkTaskStatus:f,checkAllBackgroundTasks:h,dismissNotification:m,getSessionBackgroundTasks:x,isTaskRunningInBackground:g,fetchActiveBackgroundTasks:p}}const yw=d.createContext(void 0),It=()=>{const e=d.useContext(yw);if(e===void 0)throw new Error("useChatContext must be used within a ChatProvider");return e},Cw=d.createContext(null),Sw=d.createContext(null),_w=d.createContext(void 0),kw=d.createContext(null);function sn(){const e=d.useContext(Cw);if(e===null)throw new Error("useConfig must be used within a ConfigProvider");return e}function CT(){const{messages:e}=It(),t=sn(),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 jw(){const e=d.useContext(Sw);if(!e)throw new Error("useCsrf must be used within a CsrfProvider");return e}function ST(e,t){const[n,r]=d.useState(e);return d.useEffect(()=>{const o=setTimeout(()=>{r(e)},t);return()=>{clearTimeout(o)}},[e,t]),n}const _T=async(e,t,n)=>{const r=e&&e.trim()&&e!=="null"&&e!=="undefined";let o;if(r)o=`/api/v1/artifacts/${e.trim()}/${encodeURIComponent(n.filename)}`;else if(t)o=`/api/v1/artifacts/null/${encodeURIComponent(n.filename)}?project_id=${t}`;else throw new Error("No valid session or project context for downloading artifact.");const a=await je.webui.get(o,{fullResponse:!0});if(!a.ok)throw new Error(`Failed to download artifact: ${a.statusText}`);const i=await a.blob();ni(i,n.filename)},Rf=e=>{const{addNotification:t,sessionId:n,displayError:r}=It(),{activeProject:o}=bo();return{onDownload:async i=>{try{const l=e||(o==null?void 0:o.id)||null;await _T(n,l,i),t(`Downloaded artifact: ${i.filename}.`,"success")}catch(l){r({title:"Failed to Download Artifact",error:Ut(l,"An unknown error occurred while downloading the artifact.")})}}}},kT=({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),p=t?h.filter(t):h;p.length!==0&&e(p)},[n,a,t,e]);return{isDragging:r,handleDragEnter:i,handleDragOver:l,handleDragLeave:c,handleDrop:u}};function jT(){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 ET(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 NT(e={}){const{onTranscriptionComplete:t,onTranscriptionUpdate:n,onError:r}=e,{settings:o,updateSetting:a}=Uo(),[i,l]=d.useState(!1),[c,u]=d.useState(!1),[f,h]=d.useState(null),[p,m]=d.useState(""),x=d.useRef(null),g=d.useRef(null),v=d.useRef([]),w=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{}w.current&&(w.current.getTracks().forEach(F=>F.stop()),w.current=null),v.current=[]},[]),_=d.useCallback(async()=>{const F=window.SpeechRecognition||window.webkitSpeechRecognition;if(!F){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 F;N.continuous=!0,N.interimResults=!0,N.lang=o.languageSTT||"en-US",N.onstart=()=>{l(!0),h(null)},N.onresult=R=>{let y="",T="";for(let L=R.resultIndex;L<R.results.length;L++){const O=R.results[L],M=O[0].transcript;O.isFinal?T+=M+" ":y+=M}const D=(T+y).trim();m(D),n==null||n(D),T&&(t==null||t(T.trim()))},N.onerror=R=>{const y=`Speech recognition error: ${R.error}`;h(y),r==null||r(y),l(!1)},N.onend=()=>{l(!1)},x.current=N,N.start()}catch(N){const R=`Failed to start speech recognition: ${N}`;h(R),r==null||r(R)}},[o.languageSTT,t,n,r]),E=d.useCallback(async()=>{x.current&&(x.current.stop(),x.current=null),l(!1)},[]),S=d.useCallback(async()=>{try{if(!(await je.webui.get("/api/v1/speech/config")).sttExternal){a("engineSTT","browser");const N="External STT is not configured. Switched to Browser mode. Please click the microphone button again.";h(N),r==null||r(N);return}}catch(F){const N=`Failed to check STT configuration: ${Ut(F,"Please try again.")}`;h(N),r==null||r(N);return}try{const F=await navigator.mediaDevices.getUserMedia({audio:!0,video:!1});w.current=F,v.current=[];const N=jT(),R=new MediaRecorder(F,{mimeType:N});R.ondataavailable=y=>{y.data.size>0&&v.current.push(y.data)},R.onstop=async()=>{u(!0);try{if(v.current.length===0)throw new Error("No audio data recorded");const y=new Blob(v.current,{type:N}),T=ET(N),D=new FormData;D.append("audio",y,`audio.${T}`),o.sttProvider&&o.sttProvider!=="browser"&&D.append("provider",o.sttProvider),o.languageSTT&&D.append("language",o.languageSTT);const L=await je.webui.post("/api/v1/speech/stt",D,{fullResponse:!0});if(!L.ok){const J=await L.text();let z="";try{const H=JSON.parse(J);z=H.detail||H.message||H.error||""}catch{z=J}throw new Error(z||`Transcription failed: ${L.statusText}`)}const M=(await L.json()).text||"";m(M),t==null||t(M)}catch(y){const T=`Transcription error: ${y}`;h(T),r==null||r(T)}finally{u(!1),C()}},g.current=R,R.start(100),l(!0),h(null)}catch(F){const N=`Failed to access microphone: ${F}`;h(N),r==null||r(N),C()}},[o.sttProvider,o.languageSTT,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),m(""),b?await _():await S()},[b,_,S]),I=d.useCallback(async()=>{b?await E():await j()},[b,E,j]),P=d.useCallback(()=>{m(""),h(null)},[]);return d.useEffect(()=>()=>{C()},[C]),{isListening:i,isLoading:c,error:f,transcript:p,startRecording:A,stopRecording:I,resetTranscript:P}}function TT(e){const{messageId:t,onStart:n,onEnd:r,onError:o}=e,{settings:a,onTTSStart:i,onTTSEnd:l}=Uo(),[c,u]=d.useState(!1),[f,h]=d.useState(!1),[p,m]=d.useState(null),x=d.useRef(new Set),g=d.useRef([]),v=d.useRef(!1),w=d.useRef(null),b=d.useRef(""),C=d.useRef(0),_=d.useRef(!1),E=d.useRef(!1),S=d.useRef(!1),j=d.useRef(null),A=d.useRef(null),I=d.useRef(n),P=d.useRef(r),F=d.useRef(o),N=d.useRef(i),R=d.useRef(l);d.useEffect(()=>{I.current=n,P.current=r,F.current=o,N.current=i,R.current=l},[n,r,o,i,l]);const y=d.useCallback(J=>{const z=/[^.!?]+[.!?]+(?:\s|$)/g;return(J.match(z)||[]).map(U=>U.trim()).filter(U=>U.length>0)},[]),T=d.useCallback(async J=>{var z;try{console.log(`[StreamingTTS] Requesting streaming TTS for text length: ${J.length}`);const H=await je.webui.post("/api/v1/speech/tts/stream",{input:J,voice:a.voice,runId:t},{fullResponse:!0});if(!H.ok)throw new Error(`TTS streaming failed: ${H.statusText}`);const U=(z=H.body)==null?void 0:z.getReader();if(!U)throw new Error("No response body reader available");const X=[];let W=0;for(;;){const{done:ue,value:ce}=await U.read();if(ue)break;ce&&(X.push(ce),W+=ce.length)}console.log(`[StreamingTTS] Received ${X.length} chunks, total size: ${W} bytes`);const te=new Uint8Array(W);let $=0;for(const ue of X)te.set(ue,$),$+=ue.length;const q=new Blob([te],{type:"audio/mpeg"});if(console.log(`[StreamingTTS] Created audio blob: size=${q.size}, type=${q.type}`),q.size===0)throw new Error("Received empty audio stream");const Y=URL.createObjectURL(q),re=new Audio;return re.onerror=ue=>{const ce=re.error;console.error(`[StreamingTTS] Audio error: code=${ce==null?void 0:ce.code}, message=${ce==null?void 0:ce.message}`,ue)},re.src=Y,re.playbackRate=a.playbackRate||1,re.load(),re}catch(H){return console.error("[StreamingTTS] Error generating streamed audio:",H),null}},[a.voice,a.playbackRate,t]),D=d.useCallback(()=>{if(_.current){console.log("[StreamingTTS] Skipping playback - stopped");return}if(v.current||g.current.length===0)return;v.current=!0;const J=g.current.shift();if(!J){v.current=!1;return}const{audio:z,sentence:H}=J;w.current=z,console.log(`[StreamingTTS] Playing sentence: "${H.substring(0,50)}..."`),z.onplay=()=>{var U;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,(U=I.current)==null||U.call(I),N.current&&N.current())},z.onended=()=>{var U;if(console.log("[StreamingTTS] Audio onended event fired"),URL.revokeObjectURL(z.src),w.current=null,v.current=!1,g.current.length>0)console.log("[StreamingTTS] More audio in queue, playing next"),D();else if(!S.current)console.log("[StreamingTTS] All audio played and generation complete, notifying global state"),u(!1),(U=P.current)==null||U.call(P),R.current&&R.current();else{console.log("[StreamingTTS] Queue empty but still generating, polling...");let X=0;const W=100,te=setInterval(()=>{var $,q;X++,g.current.length>0?(console.log("[StreamingTTS] New audio arrived during poll, playing"),clearInterval(te),D()):!S.current&&!v.current?(console.log("[StreamingTTS] Generation finished and not playing, notifying global state"),clearInterval(te),u(!1),($=P.current)==null||$.call(P),R.current&&R.current()):X>=W&&(console.log("[StreamingTTS] Poll timeout after 10s, forcing end"),clearInterval(te),S.current=!1,u(!1),(q=P.current)==null||q.call(P),R.current&&R.current())},100)}},z.onerror=()=>{var W,te;const U=(W=z.error)==null?void 0:W.code;if(U===1){console.log("[StreamingTTS] Ignoring ABORTED error (expected during stop)");return}const X=`Failed to play audio (code: ${U})`;m(X),(te=F.current)==null||te.call(F,X),URL.revokeObjectURL(z.src),w.current=null,v.current=!1,g.current.length>0?D():(u(!1),r==null||r(),l())},z.play().catch(U=>{if(U.name==="AbortError"){console.log("[StreamingTTS] Ignoring AbortError from play() (expected during stop)");return}console.error("[StreamingTTS] Error playing audio:",U),v.current=!1,D()})},[r,l]),L=d.useCallback(async(J,z)=>{if(console.log(`[StreamingTTS] doProcessing called: textLen=${J.length}, isComplete=${z}`),_.current){console.log("[StreamingTTS] Skipping - stopped");return}const H=y(J),U=H.join(" ");if(z){const W=H[H.length-1]||"",te=J.lastIndexOf(W)+W.length,$=J.substring(te).trim();$&&console.log(`[StreamingTTS] Adding remaining text: "${$.substring(0,50)}..."`)}const X=z?J:U;if(x.current.has(X)||X.length<10){console.log("[StreamingTTS] Skipping - already processed or too short");return}x.current.add(X),b.current=J,C.current=J.length,console.log(`[StreamingTTS] Processing text (${X.length} chars)`),h(!0),_.current=!1,S.current=!0;try{const W=await T(X);W&&!_.current&&(g.current.push({audio:W,sentence:X.substring(0,50),index:g.current.length}),console.log(`[StreamingTTS] Added audio to queue (size: ${g.current.length})`),v.current||(console.log("[StreamingTTS] Starting playback"),D()))}catch(W){console.error("[StreamingTTS] Error processing:",W)}h(!1),z&&(S.current=!1,console.log("[StreamingTTS] Message complete"))},[y,T,D]),O=d.useCallback(async(J,z)=>{if(j.current){console.log("[StreamingTTS] Already processing, queuing update"),A.current={text:J,isComplete:z};return}j.current=L(J,z);try{await j.current}finally{if(j.current=null,A.current){const H=A.current;A.current=null,console.log("[StreamingTTS] Processing queued update"),await O(H.text,H.isComplete)}}},[L]),M=d.useCallback(()=>{if(!(!v.current&&g.current.length===0)){if(console.log("[StreamingTTS] Stopping playback"),_.current=!0,w.current){try{w.current.pause(),w.current.currentTime=0,URL.revokeObjectURL(w.current.src)}catch{}w.current=null}g.current.forEach(J=>{try{URL.revokeObjectURL(J.audio.src)}catch{}}),g.current=[],v.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,_.current=!1,E.current=!1,S.current=!1,j.current=null,A.current=null,()=>{const z=x.current;if(v.current||g.current.length>0){if(console.log("[StreamingTTS] Cleanup: stopping playback for message change/unmount"),_.current=!0,w.current){try{w.current.pause(),URL.revokeObjectURL(w.current.src)}catch{}w.current=null}g.current.forEach(H=>{try{URL.revokeObjectURL(H.audio.src)}catch{}}),g.current=[],v.current=!1}z.clear(),b.current="",C.current=0,j.current=null,A.current=null}),[t]),{isPlaying:c,isLoading:f,error:p,processStreamingText:O,stop:M}}const Pf=()=>{const e=d.useContext(_w);if(e===void 0)throw new Error("useTaskContext must be used within a TaskProvider");return e};function AT(e={}){const{messageId:t,onStart:n,onEnd:r,onError:o}=e,{settings:a}=Uo(),[i,l]=d.useState(!1),[c,u]=d.useState(!1),[f,h]=d.useState(null),[p,m]=d.useState([]),x=d.useRef(null),g=d.useRef(null),v=d.useRef(null),w=d.useRef([]),b=d.useRef(!1),C=d.useRef(0),_=a.engineTTS==="browser";d.useEffect(()=>{if(!_)return;const R=()=>{const y=window.speechSynthesis;if(!y)return;const D=y.getVoices().filter(L=>a.cloudBrowserVoices?!0:L.localService).map(L=>({value:L.name,label:`${L.name} (${L.lang})`}));m(D)};return R(),window.speechSynthesis.onvoiceschanged!==void 0&&(window.speechSynthesis.onvoiceschanged=R),()=>{window.speechSynthesis.onvoiceschanged&&(window.speechSynthesis.onvoiceschanged=null)}},[_,a.cloudBrowserVoices]),d.useEffect(()=>{if(_)return;(async()=>{try{const y=a.ttsProvider||"gemini",D=((await je.webui.get(`/api/v1/speech/voices?provider=${y}`)).voices||[]).map(L=>({value:L,label:L}));m(D)}catch(y){console.error("Failed to load external voices:",y)}})()},[_,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),v.current&&(URL.revokeObjectURL(v.current),v.current=null),w.current.forEach(R=>{R.pause(),R.src&&URL.revokeObjectURL(R.src)}),w.current=[],b.current=!1,C.current=0},[]),S=d.useCallback(async R=>{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(R);if(T.rate=a.playbackRate||1,T.lang=a.languageSTT||"en-US",a.voice){const L=y.getVoices().find(O=>O.name===a.voice);L&&(T.voice=L)}T.onstart=()=>{l(!0),h(null),n==null||n()},T.onend=()=>{l(!1),x.current=null,r==null||r()},T.onerror=D=>{const L=`Speech synthesis error: ${D.error}`;h(L),o==null||o(L),l(!1),x.current=null},x.current=T,y.speak(T)}catch(T){const D=`Failed to speak: ${T}`;h(D),o==null||o(D)}},[a.playbackRate,a.languageSTT,a.voice,n,r,o]),j=d.useCallback(()=>{if(!b.current||C.current>=w.current.length){l(!1),b.current=!1,C.current=0,w.current.forEach(T=>{T.src&&URL.revokeObjectURL(T.src)}),w.current=[],r==null||r();return}const R=C.current,y=w.current[R];C.current++,y.onended=()=>{j()},y.onerror=()=>{j()},y.play().catch(T=>{console.error(`[TTS] Failed to play chunk ${R+1}:`,T),j()})},[r]),A=d.useCallback(async R=>{var y;E(),u(!0);try{if(a.cacheTTS){const M=await caches.open("tts-responses"),J=`${R}-${a.voice}-${a.ttsProvider||"default"}`,z=await M.match(J);if(z){const H=await z.blob(),U=URL.createObjectURL(H),X=new Audio(U);X.playbackRate=a.playbackRate||1,X.onplay=()=>{l(!0),u(!1),h(null),n==null||n()},X.onended=()=>{l(!1),URL.revokeObjectURL(U),g.current=null,r==null||r()},X.onerror=()=>{const W="Failed to play cached audio";h(W),o==null||o(W),l(!1),u(!1),URL.revokeObjectURL(U)},g.current=X,v.current=U,await X.play();return}}const T=await je.webui.post("/api/v1/speech/tts/stream",{input:R,voice:a.voice,runId:t||`tts-${Date.now()}`,provider:a.ttsProvider},{fullResponse:!0});if(!T.ok)throw new Error(`TTS request failed: ${T.statusText}`);const D=(y=T.body)==null?void 0:y.getReader();if(!D)throw new Error("No response body reader available");let L=!1;const O=[];for(w.current=[],C.current=0,b.current=!0;;){const{done:M,value:J}=await D.read();if(M){if(a.cacheTTS&&O.length>0){const z=O.reduce((q,Y)=>q+Y.length,0),H=new Uint8Array(z);let U=0;for(const q of O)H.set(q,U),U+=q.length;const X=new Blob([H],{type:"audio/mpeg"}),W=await caches.open("tts-responses"),te=`${R}-${a.voice}-${a.ttsProvider||"default"}`,$=new Response(X,{headers:{"Content-Type":"audio/mpeg","Content-Length":X.size.toString()}});await W.put(te,$)}break}if(J&&J.length>0){O.push(J);const z=new Blob([J],{type:"audio/mpeg"}),H=URL.createObjectURL(z),U=new Audio(H);if(U.playbackRate=a.playbackRate||1,w.current.push(U),!L){L=!0,l(!0),u(!1),h(null),n==null||n(),U.onended=()=>{j()},U.onerror=()=>{j()};try{await U.play(),C.current=1}catch(X){throw X instanceof Error&&X.name==="NotAllowedError"?(b.current=!1,u(!1),new Error("Click the speaker button again to play audio (browser autoplay policy)")):X}}}}}catch(T){const D=`TTS error: ${T}`;h(D),o==null||o(D),u(!1),b.current=!1}},[a.cacheTTS,a.voice,a.playbackRate,a.ttsProvider,t,n,r,o,E,j]),I=d.useCallback(async R=>{!R||!R.trim()||(h(null),_?await S(R):await A(R))},[_,S,A]),P=d.useCallback(()=>{_?(window.speechSynthesis.cancel(),l(!1)):(b.current=!1,g.current&&(g.current.pause(),g.current.currentTime=0),w.current.forEach(R=>{R.pause()}),l(!1))},[_]),F=d.useCallback(()=>{if(_)window.speechSynthesis.pause();else{const R=C.current-1;R>=0&&R<w.current.length?w.current[R].pause():g.current&&g.current.pause()}l(!1)},[_]),N=d.useCallback(()=>{if(_)window.speechSynthesis.resume(),l(!0);else{const R=C.current-1;R>=0&&R<w.current.length?(w.current[R].play(),l(!0)):g.current&&(g.current.play(),l(!0))}},[_]);return d.useEffect(()=>()=>{E()},[E]),{isSpeaking:i,isLoading:c,error:f,voices:p,speak:I,stop:P,pause:F,resume:N}}function ci(){const e=d.useContext(kw);if(e===null)throw new Error("useThemeContext must be used within a ThemeProvider");return e}const IT=e=>{const[t,n]=d.useState([]),[r,o]=d.useState(!0),[a,i]=d.useState(null),l=d.useCallback(async()=>{if(!e){n([]),o(!1);return}o(!0),i(null);try{const c=await je.webui.get(`/api/v1/sessions?project_id=${e}&pageNumber=1&pageSize=100`);n(c.data||[])}catch(c){const u=c instanceof Error?c.message:"Failed to fetch sessions.";i(u),n([])}finally{o(!1)}},[e]);return d.useEffect(()=>{l();const c=()=>{l()},u=()=>{l()};return window.addEventListener("session-moved",c),window.addEventListener("new-chat-session",u),()=>{window.removeEventListener("session-moved",c),window.removeEventListener("new-chat-session",u)}},[l]),{sessions:t,isLoading:r,error:a,refetch:l}},RT=()=>{const{agents:e,sessionId:t,setMessages:n,setSelectedAgentName:r,handleNewSession:o}=It();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])}},Bo=({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(Pn,{open:e,onOpenChange:l,children:[a&&s.jsx(Ju,{asChild:!0,children:a}),s.jsxs(Mn,{className:"w-xl max-w-xl sm:max-w-xl",children:[s.jsxs(Vn,{children:[s.jsx(Dn,{className:"flex max-w-[400px] flex-row gap-1",children:t}),s.jsx(Wn,{children:r})]}),s.jsx("div",{className:"min-w-0 break-words",children:n}),s.jsxs(er,{children:[s.jsx(Vv,{asChild:!0,children:s.jsx(me,{variant:"ghost",title:f,onClick:p=>{p.stopPropagation(),u==null||u()},disabled:i,children:f})}),s.jsx(me,{"data-testid":"dialogConfirmButton",variant:"outline",title:h,onClick:async p=>{p.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 PT(){const[e,t]=d.useState(!1),[n,r]=d.useState(!1),[o,a]=d.useState(!1),i=TS(({currentLocation:h,nextLocation:p})=>o&&!n&&h.pathname!==p.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(Bo,{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 MT=({title:e,subtitle:t,error:n,errorDetails:r,open:o,onOpenChange:a})=>s.jsx(Pn,{open:o,onOpenChange:a,children:s.jsxs(Mn,{className:"w-xl max-w-xl sm:max-w-xl",children:[s.jsxs(Vn,{children:[s.jsx(Dn,{className:"flex max-w-[400px] flex-row gap-1",children:e}),s.jsx(Wn,{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(mg,{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(er,{children:s.jsx(Vv,{asChild:!0,children:s.jsx(me,{variant:"outline",testid:"closeButton",title:"Close",children:"Close"})})})]})});function DT(){const[e,t]=d.useState(null),n=d.useCallback(o=>{o||t(null)},[]);return{ErrorDialog:d.useCallback(()=>s.jsx(MT,{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 fc(e){const t=e+"CollectionProvider",[n,r]=ur(t),[o,a]=n(t,{collectionRef:{current:null},itemMap:new Map}),i=g=>{const{scope:v,children:w}=g,b=At.useRef(null),C=At.useRef(new Map).current;return s.jsx(o,{scope:v,itemMap:C,collectionRef:b,children:w})};i.displayName=t;const l=e+"CollectionSlot",c=Po(l),u=At.forwardRef((g,v)=>{const{scope:w,children:b}=g,C=a(l,w),_=ht(v,C.collectionRef);return s.jsx(c,{ref:_,children:b})});u.displayName=l;const f=e+"CollectionItemSlot",h="data-radix-collection-item",p=Po(f),m=At.forwardRef((g,v)=>{const{scope:w,children:b,...C}=g,_=At.useRef(null),E=ht(v,_),S=a(f,w);return At.useEffect(()=>(S.itemMap.set(_,{ref:_,...C}),()=>void S.itemMap.delete(_))),s.jsx(p,{[h]:"",ref:E,children:b})});m.displayName=f;function x(g){const v=a(e+"CollectionConsumer",g);return At.useCallback(()=>{const b=v.collectionRef.current;if(!b)return[];const C=Array.from(b.querySelectorAll(`[${h}]`));return Array.from(v.itemMap.values()).sort((S,j)=>C.indexOf(S.ref.current)-C.indexOf(j.ref.current))},[v.collectionRef,v.itemMap])}return[{Provider:i,Slot:u,ItemSlot:m},x,r]}var OT=d.createContext(void 0);function ui(e){const t=d.useContext(OT);return e||t||"ltr"}const di=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,p,m;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(),(p=c[0])==null||p.focus();break;case"End":i.preventDefault(),(m=c[c.length-1])==null||m.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))})});di.displayName="Menu";var Mf="Popper",[Ew,Nw]=ur(Mf),[LT,Tw]=Ew(Mf),Aw=e=>{const{__scopePopper:t,children:n}=e,[r,o]=d.useState(null);return s.jsx(LT,{scope:t,anchor:r,onAnchorChange:o,children:n})};Aw.displayName=Mf;var Iw="PopperAnchor",Rw=d.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,a=Tw(Iw,n),i=d.useRef(null),l=ht(t,i);return d.useEffect(()=>{a.onAnchorChange((r==null?void 0:r.current)||i.current)}),r?null:s.jsx(nt.div,{...o,ref:l})});Rw.displayName=Iw;var Df="PopperContent",[FT,zT]=Ew(Df),Pw=d.forwardRef((e,t)=>{var $,q,Y,re,ue,ce;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:p=!1,updatePositionStrategy:m="optimized",onPlaced:x,...g}=e,v=Tw(Df,n),[w,b]=d.useState(null),C=ht(t,pe=>b(pe)),[_,E]=d.useState(null),S=df(_),j=(S==null?void 0:S.width)??0,A=(S==null?void 0:S.height)??0,I=r+(a!=="center"?"-"+a:""),P=typeof f=="number"?f:{top:0,right:0,bottom:0,left:0,...f},F=Array.isArray(u)?u:[u],N=F.length>0,R={padding:P,boundary:F.filter(UT),altBoundary:N},{refs:y,floatingStyles:T,placement:D,isPositioned:L,middlewareData:O}=tf({strategy:"fixed",placement:I,whileElementsMounted:(...pe)=>ef(...pe,{animationFrame:m==="always"}),elements:{reference:v.anchor},middleware:[nf({mainAxis:o+A,alignmentAxis:i}),c&&rf({mainAxis:!0,crossAxis:!1,limiter:h==="partial"?of():void 0,...R}),c&&sf({...R}),af({...R,apply:({elements:pe,rects:k,availableWidth:oe,availableHeight:ae})=>{const{width:G,height:V}=k.reference,ne=pe.floating.style;ne.setProperty("--radix-popper-available-width",`${oe}px`),ne.setProperty("--radix-popper-available-height",`${ae}px`),ne.setProperty("--radix-popper-anchor-width",`${G}px`),ne.setProperty("--radix-popper-anchor-height",`${V}px`)}}),_&&cf({element:_,padding:l}),BT({arrowWidth:j,arrowHeight:A}),p&&lf({strategy:"referenceHidden",...R})]}),[M,J]=Ow(D),z=In(x);dn(()=>{L&&(z==null||z())},[L,z]);const H=($=O.arrow)==null?void 0:$.x,U=(q=O.arrow)==null?void 0:q.y,X=((Y=O.arrow)==null?void 0:Y.centerOffset)!==0,[W,te]=d.useState();return dn(()=>{w&&te(window.getComputedStyle(w).zIndex)},[w]),s.jsx("div",{ref:y.setFloating,"data-radix-popper-content-wrapper":"",style:{...T,transform:L?T.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:W,"--radix-popper-transform-origin":[(re=O.transformOrigin)==null?void 0:re.x,(ue=O.transformOrigin)==null?void 0:ue.y].join(" "),...((ce=O.hide)==null?void 0:ce.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:s.jsx(FT,{scope:n,placedSide:M,onArrowChange:E,arrowX:H,arrowY:U,shouldHideArrow:X,children:s.jsx(nt.div,{"data-side":M,"data-align":J,...g,ref:C,style:{...g.style,animation:L?void 0:"none"}})})})});Pw.displayName=Df;var Mw="PopperArrow",$T={top:"bottom",right:"left",bottom:"top",left:"right"},Dw=d.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,a=zT(Mw,r),i=$T[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(uf,{...o,ref:n,style:{...o.style,display:"block"}})})});Dw.displayName=Mw;function UT(e){return e!==null}var BT=e=>({name:"transformOrigin",options:e,fn(t){var v,w,b;const{placement:n,rects:r,middlewareData:o}=t,i=((v=o.arrow)==null?void 0:v.centerOffset)!==0,l=i?0:e.arrowWidth,c=i?0:e.arrowHeight,[u,f]=Ow(n),h={start:"0%",center:"50%",end:"100%"}[f],p=(((w=o.arrow)==null?void 0:w.x)??0)+l/2,m=(((b=o.arrow)==null?void 0:b.y)??0)+c/2;let x="",g="";return u==="bottom"?(x=i?h:`${p}px`,g=`${-c}px`):u==="top"?(x=i?h:`${p}px`,g=`${r.floating.height+c}px`):u==="right"?(x=`${-c}px`,g=i?h:`${m}px`):u==="left"&&(x=`${r.floating.width+c}px`,g=i?h:`${m}px`),{data:{x,y:g}}}});function Ow(e){const[t,n="center"]=e.split("-");return[t,n]}var VT=Aw,Lw=Rw,WT=Pw,HT=Dw,hc="Popover",[Fw,v9]=ur(hc,[Nw]),fi=Nw(),[ZT,Vo]=Fw(hc),zw=e=>{const{__scopePopover:t,children:n,open:r,defaultOpen:o,onOpenChange:a,modal:i=!1}=e,l=fi(t),c=d.useRef(null),[u,f]=d.useState(!1),[h,p]=fo({prop:r,defaultProp:o??!1,onChange:a,caller:hc});return s.jsx(VT,{...l,children:s.jsx(ZT,{scope:t,contentId:ir(),triggerRef:c,open:h,onOpenChange:p,onOpenToggle:d.useCallback(()=>p(m=>!m),[p]),hasCustomAnchor:u,onCustomAnchorAdd:d.useCallback(()=>f(!0),[]),onCustomAnchorRemove:d.useCallback(()=>f(!1),[]),modal:i,children:n})})};zw.displayName=hc;var $w="PopoverAnchor",GT=d.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,o=Vo($w,n),a=fi(n),{onCustomAnchorAdd:i,onCustomAnchorRemove:l}=o;return d.useEffect(()=>(i(),()=>l()),[i,l]),s.jsx(Lw,{...a,...r,ref:t})});GT.displayName=$w;var Uw="PopoverTrigger",Bw=d.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,o=Vo(Uw,n),a=fi(n),i=ht(t,o.triggerRef),l=s.jsx(nt.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":Gw(o.open),...r,ref:i,onClick:Bt(e.onClick,o.onOpenToggle)});return o.hasCustomAnchor?l:s.jsx(Lw,{asChild:!0,...a,children:l})});Bw.displayName=Uw;var Of="PopoverPortal",[YT,KT]=Fw(Of,{forceMount:void 0}),Vw=e=>{const{__scopePopover:t,forceMount:n,children:r,container:o}=e,a=Vo(Of,t);return s.jsx(YT,{scope:t,forceMount:n,children:s.jsx(wo,{present:n||a.open,children:s.jsx(da,{asChild:!0,container:o,children:r})})})};Vw.displayName=Of;var qs="PopoverContent",Ww=d.forwardRef((e,t)=>{const n=KT(qs,e.__scopePopover),{forceMount:r=n.forceMount,...o}=e,a=Vo(qs,e.__scopePopover);return s.jsx(wo,{present:r||a.open,children:a.modal?s.jsx(XT,{...o,ref:t}):s.jsx(JT,{...o,ref:t})})});Ww.displayName=qs;var qT=Po("PopoverContent.RemoveScroll"),XT=d.forwardRef((e,t)=>{const n=Vo(qs,e.__scopePopover),r=d.useRef(null),o=ht(t,r),a=d.useRef(!1);return d.useEffect(()=>{const i=r.current;if(i)return ac(i)},[]),s.jsx(li,{as:qT,allowPinchZoom:!0,children:s.jsx(Hw,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Bt(e.onCloseAutoFocus,i=>{var l;i.preventDefault(),a.current||(l=n.triggerRef.current)==null||l.focus()}),onPointerDownOutside:Bt(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:Bt(e.onFocusOutside,i=>i.preventDefault(),{checkForDefaultPrevented:!1})})})}),JT=d.forwardRef((e,t)=>{const n=Vo(qs,e.__scopePopover),r=d.useRef(!1),o=d.useRef(!1);return s.jsx(Hw,{...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()}})}),Hw=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,p=Vo(qs,n),m=fi(n);return xv(),s.jsx(ii,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:a,children:s.jsx(Kl,{asChild:!0,disableOutsidePointerEvents:i,onInteractOutside:f,onEscapeKeyDown:l,onPointerDownOutside:c,onFocusOutside:u,onDismiss:()=>p.onOpenChange(!1),children:s.jsx(WT,{"data-state":Gw(p.open),role:"dialog",id:p.contentId,...m,...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)"}})})})}),Zw="PopoverClose",QT=d.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,o=Vo(Zw,n);return s.jsx(nt.button,{type:"button",...r,ref:t,onClick:Bt(e.onClick,()=>o.onOpenChange(!1))})});QT.displayName=Zw;var eA="PopoverArrow",tA=d.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,o=fi(n);return s.jsx(HT,{...o,...r,ref:t})});tA.displayName=eA;function Gw(e){return e?"open":"closed"}var nA=zw,rA=Bw,oA=Vw,sA=Ww;function pc({...e}){return s.jsx(nA,{"data-slot":"popover",...e})}function mc({...e}){return s.jsx(rA,{"data-slot":"popover-trigger",...e})}function gc({className:e,align:t="center",sideOffset:n=4,...r}){return s.jsx(oA,{children:s.jsx(sA,{"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 aA({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 p=d.useRef(null),[m,x]=d.useState({}),[g,v]=d.useState(!1);$N({ref:p,anchorRef:n,onClickOutside:t,enabled:e&&l}),UN({onEscape:t,enabled:e&&c});const{getPositionStyle:w}=WN({anchorRef:n,placement:o,offset:a,fallbackPlacements:h});if(d.useEffect(()=>{e&&p.current?(v(!1),requestAnimationFrame(()=>{if(p.current){const C=w(p.current);x(C),v(!0)}})):v(!1)},[e,w]),!e)return null;const b=s.jsx("div",{ref:p,role:"dialog","aria-modal":"false",className:ze("bg-background min-w-[8rem] overflow-hidden border shadow-md",i),style:{...m,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?oa.createPortal(b,document.body):b}function Hp(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 iA="DismissableLayer",nd="dismissableLayer.update",lA="dismissableLayer.pointerDownOutside",cA="dismissableLayer.focusOutside",Zp,Yw=d.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Kw=d.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:a,onInteractOutside:i,onDismiss:l,...c}=e,u=d.useContext(Yw),[f,h]=d.useState(null),p=(f==null?void 0:f.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,m]=d.useState({}),x=ht(t,j=>h(j)),g=Array.from(u.layers),[v]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),w=g.indexOf(v),b=f?g.indexOf(f):-1,C=u.layersWithOutsidePointerEventsDisabled.size>0,_=b>=w,E=fA(j=>{const A=j.target,I=[...u.branches].some(P=>P.contains(A));!_||I||(o==null||o(j),i==null||i(j),j.defaultPrevented||l==null||l())},p),S=hA(j=>{const A=j.target;[...u.branches].some(P=>P.contains(A))||(a==null||a(j),i==null||i(j),j.defaultPrevented||l==null||l())},p);return Gd(j=>{b===u.layers.size-1&&(r==null||r(j),!j.defaultPrevented&&l&&(j.preventDefault(),l()))},p),d.useEffect(()=>{if(f)return n&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(Zp=p.body.style.pointerEvents,p.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(f)),u.layers.add(f),Gp(),()=>{n&&u.layersWithOutsidePointerEventsDisabled.size===1&&(p.body.style.pointerEvents=Zp)}},[f,p,n,u]),d.useEffect(()=>()=>{f&&(u.layers.delete(f),u.layersWithOutsidePointerEventsDisabled.delete(f),Gp())},[f,u]),d.useEffect(()=>{const j=()=>m({});return document.addEventListener(nd,j),()=>document.removeEventListener(nd,j)},[]),s.jsx(nt.div,{...c,ref:x,style:{pointerEvents:C?_?"auto":"none":void 0,...e.style},onFocusCapture:xn(e.onFocusCapture,S.onFocusCapture),onBlurCapture:xn(e.onBlurCapture,S.onBlurCapture),onPointerDownCapture:xn(e.onPointerDownCapture,E.onPointerDownCapture)})});Kw.displayName=iA;var uA="DismissableLayerBranch",dA=d.forwardRef((e,t)=>{const n=d.useContext(Yw),r=d.useRef(null),o=ht(t,r);return d.useEffect(()=>{const a=r.current;if(a)return n.branches.add(a),()=>{n.branches.delete(a)}},[n.branches]),s.jsx(nt.div,{...e,ref:o})});dA.displayName=uA;function fA(e,t=globalThis==null?void 0:globalThis.document){const n=In(e),r=d.useRef(!1),o=d.useRef(()=>{});return d.useEffect(()=>{const a=l=>{if(l.target&&!r.current){let c=function(){qw(lA,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 hA(e,t=globalThis==null?void 0:globalThis.document){const n=In(e),r=d.useRef(!1);return d.useEffect(()=>{const o=a=>{a.target&&!r.current&&qw(cA,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 Gp(){const e=new CustomEvent(nd);document.dispatchEvent(e)}function qw(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?Yl(o,a):o.dispatchEvent(a)}var au=0;function pA(){d.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??Yp()),document.body.insertAdjacentElement("beforeend",e[1]??Yp()),au++,()=>{au===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),au--}},[])}function Yp(){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 Lf="Popper",[Xw,xc]=ur(Lf),[mA,Jw]=Xw(Lf),Qw=e=>{const{__scopePopper:t,children:n}=e,[r,o]=d.useState(null);return s.jsx(mA,{scope:t,anchor:r,onAnchorChange:o,children:n})};Qw.displayName=Lf;var e0="PopperAnchor",t0=d.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,a=Jw(e0,n),i=d.useRef(null),l=ht(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(nt.div,{...o,ref:l})});t0.displayName=e0;var Ff="PopperContent",[gA,xA]=Xw(Ff),n0=d.forwardRef((e,t)=>{var $,q,Y,re,ue,ce;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:p=!1,updatePositionStrategy:m="optimized",onPlaced:x,...g}=e,v=Jw(Ff,n),[w,b]=d.useState(null),C=ht(t,pe=>b(pe)),[_,E]=d.useState(null),S=df(_),j=(S==null?void 0:S.width)??0,A=(S==null?void 0:S.height)??0,I=r+(a!=="center"?"-"+a:""),P=typeof f=="number"?f:{top:0,right:0,bottom:0,left:0,...f},F=Array.isArray(u)?u:[u],N=F.length>0,R={padding:P,boundary:F.filter(wA),altBoundary:N},{refs:y,floatingStyles:T,placement:D,isPositioned:L,middlewareData:O}=tf({strategy:"fixed",placement:I,whileElementsMounted:(...pe)=>ef(...pe,{animationFrame:m==="always"}),elements:{reference:v.anchor},middleware:[nf({mainAxis:o+A,alignmentAxis:i}),c&&rf({mainAxis:!0,crossAxis:!1,limiter:h==="partial"?of():void 0,...R}),c&&sf({...R}),af({...R,apply:({elements:pe,rects:k,availableWidth:oe,availableHeight:ae})=>{const{width:G,height:V}=k.reference,ne=pe.floating.style;ne.setProperty("--radix-popper-available-width",`${oe}px`),ne.setProperty("--radix-popper-available-height",`${ae}px`),ne.setProperty("--radix-popper-anchor-width",`${G}px`),ne.setProperty("--radix-popper-anchor-height",`${V}px`)}}),_&&cf({element:_,padding:l}),bA({arrowWidth:j,arrowHeight:A}),p&&lf({strategy:"referenceHidden",...R})]}),[M,J]=s0(D),z=In(x);dn(()=>{L&&(z==null||z())},[L,z]);const H=($=O.arrow)==null?void 0:$.x,U=(q=O.arrow)==null?void 0:q.y,X=((Y=O.arrow)==null?void 0:Y.centerOffset)!==0,[W,te]=d.useState();return dn(()=>{w&&te(window.getComputedStyle(w).zIndex)},[w]),s.jsx("div",{ref:y.setFloating,"data-radix-popper-content-wrapper":"",style:{...T,transform:L?T.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:W,"--radix-popper-transform-origin":[(re=O.transformOrigin)==null?void 0:re.x,(ue=O.transformOrigin)==null?void 0:ue.y].join(" "),...((ce=O.hide)==null?void 0:ce.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:s.jsx(gA,{scope:n,placedSide:M,onArrowChange:E,arrowX:H,arrowY:U,shouldHideArrow:X,children:s.jsx(nt.div,{"data-side":M,"data-align":J,...g,ref:C,style:{...g.style,animation:L?void 0:"none"}})})})});n0.displayName=Ff;var r0="PopperArrow",vA={top:"bottom",right:"left",bottom:"top",left:"right"},o0=d.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,a=xA(r0,r),i=vA[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(uf,{...o,ref:n,style:{...o.style,display:"block"}})})});o0.displayName=r0;function wA(e){return e!==null}var bA=e=>({name:"transformOrigin",options:e,fn(t){var v,w,b;const{placement:n,rects:r,middlewareData:o}=t,i=((v=o.arrow)==null?void 0:v.centerOffset)!==0,l=i?0:e.arrowWidth,c=i?0:e.arrowHeight,[u,f]=s0(n),h={start:"0%",center:"50%",end:"100%"}[f],p=(((w=o.arrow)==null?void 0:w.x)??0)+l/2,m=(((b=o.arrow)==null?void 0:b.y)??0)+c/2;let x="",g="";return u==="bottom"?(x=i?h:`${p}px`,g=`${-c}px`):u==="top"?(x=i?h:`${p}px`,g=`${r.floating.height+c}px`):u==="right"?(x=`${-c}px`,g=i?h:`${m}px`):u==="left"&&(x=`${r.floating.width+c}px`,g=i?h:`${m}px`),{data:{x,y:g}}}});function s0(e){const[t,n="center"]=e.split("-");return[t,n]}var a0=Qw,i0=t0,l0=n0,c0=o0;function yA(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 CA=[" ","Enter","ArrowUp","ArrowDown"],SA=[" ","Enter"],ss="Select",[vc,wc,_A]=fc(ss),[fa,w9]=ur(ss,[_A,xc]),bc=xc(),[kA,Wo]=fa(ss),[jA,EA]=fa(ss),u0=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:p,required:m,form:x}=e,g=bc(t),[v,w]=d.useState(null),[b,C]=d.useState(null),[_,E]=d.useState(!1),S=ui(u),[j,A]=fo({prop:r,defaultProp:o??!1,onChange:a,caller:ss}),[I,P]=fo({prop:i,defaultProp:l,onChange:c,caller:ss}),F=d.useRef(null),N=v?x||!!v.closest("form"):!0,[R,y]=d.useState(new Set),T=Array.from(R).map(D=>D.props.value).join(";");return s.jsx(a0,{...g,children:s.jsxs(kA,{required:m,scope:t,trigger:v,onTriggerChange:w,valueNode:b,onValueNodeChange:C,valueNodeHasChildren:_,onValueNodeHasChildrenChange:E,contentId:ir(),value:I,onValueChange:P,open:j,onOpenChange:A,dir:S,triggerPointerDownPosRef:F,disabled:p,children:[s.jsx(vc.Provider,{scope:t,children:s.jsx(jA,{scope:e.__scopeSelect,onNativeOptionAdd:d.useCallback(D=>{y(L=>new Set(L).add(D))},[]),onNativeOptionRemove:d.useCallback(D=>{y(L=>{const O=new Set(L);return O.delete(D),O})},[]),children:n})}),N?s.jsxs(R0,{"aria-hidden":!0,required:m,tabIndex:-1,name:f,autoComplete:h,value:I,onChange:D=>P(D.target.value),disabled:p,form:x,children:[I===void 0?s.jsx("option",{value:""}):null,Array.from(R)]},T):null]})})};u0.displayName=ss;var d0="SelectTrigger",f0=d.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...o}=e,a=bc(n),i=Wo(d0,n),l=i.disabled||r,c=ht(t,i.onTriggerChange),u=wc(n),f=d.useRef("touch"),[h,p,m]=M0(g=>{const v=u().filter(C=>!C.disabled),w=v.find(C=>C.value===i.value),b=D0(v,g,w);b!==void 0&&i.onValueChange(b.value)}),x=g=>{l||(i.onOpenChange(!0),m()),g&&(i.triggerPointerDownPosRef.current={x:Math.round(g.pageX),y:Math.round(g.pageY)})};return s.jsx(i0,{asChild:!0,...a,children:s.jsx(nt.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":P0(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 v=g.target;v.hasPointerCapture(g.pointerId)&&v.releasePointerCapture(g.pointerId),g.button===0&&g.ctrlKey===!1&&g.pointerType==="mouse"&&(x(g),g.preventDefault())}),onKeyDown:xn(o.onKeyDown,g=>{const v=h.current!=="";!(g.ctrlKey||g.altKey||g.metaKey)&&g.key.length===1&&p(g.key),!(v&&g.key===" ")&&CA.includes(g.key)&&(x(),g.preventDefault())})})})});f0.displayName=d0;var h0="SelectValue",p0=d.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,children:a,placeholder:i="",...l}=e,c=Wo(h0,n),{onValueNodeHasChildrenChange:u}=c,f=a!==void 0,h=ht(t,c.onValueNodeChange);return dn(()=>{u(f)},[u,f]),s.jsx(nt.span,{...l,ref:h,style:{pointerEvents:"none"},children:P0(c.value)?s.jsx(s.Fragment,{children:i}):a})});p0.displayName=h0;var NA="SelectIcon",m0=d.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...o}=e;return s.jsx(nt.span,{"aria-hidden":!0,...o,ref:t,children:r||"▼"})});m0.displayName=NA;var TA="SelectPortal",g0=e=>s.jsx(da,{asChild:!0,...e});g0.displayName=TA;var as="SelectContent",x0=d.forwardRef((e,t)=>{const n=Wo(as,e.__scopeSelect),[r,o]=d.useState();if(dn(()=>{o(new DocumentFragment)},[]),!n.open){const a=r;return a?oa.createPortal(s.jsx(v0,{scope:e.__scopeSelect,children:s.jsx(vc.Slot,{scope:e.__scopeSelect,children:s.jsx("div",{children:e.children})})}),a):null}return s.jsx(w0,{...e,ref:t})});x0.displayName=as;var Sr=10,[v0,Ho]=fa(as),AA="SelectContentImpl",IA=Po("SelectContent.RemoveScroll"),w0=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:p,collisionPadding:m,sticky:x,hideWhenDetached:g,avoidCollisions:v,...w}=e,b=Wo(as,n),[C,_]=d.useState(null),[E,S]=d.useState(null),j=ht(t,$=>_($)),[A,I]=d.useState(null),[P,F]=d.useState(null),N=wc(n),[R,y]=d.useState(!1),T=d.useRef(!1);d.useEffect(()=>{if(C)return ac(C)},[C]),pA();const D=d.useCallback($=>{const[q,...Y]=N().map(ce=>ce.ref.current),[re]=Y.slice(-1),ue=document.activeElement;for(const ce of $)if(ce===ue||(ce==null||ce.scrollIntoView({block:"nearest"}),ce===q&&E&&(E.scrollTop=0),ce===re&&E&&(E.scrollTop=E.scrollHeight),ce==null||ce.focus(),document.activeElement!==ue))return},[N,E]),L=d.useCallback(()=>D([A,C]),[D,A,C]);d.useEffect(()=>{R&&L()},[R,L]);const{onOpenChange:O,triggerPointerDownPosRef:M}=b;d.useEffect(()=>{if(C){let $={x:0,y:0};const q=re=>{var ue,ce;$={x:Math.abs(Math.round(re.pageX)-(((ue=M.current)==null?void 0:ue.x)??0)),y:Math.abs(Math.round(re.pageY)-(((ce=M.current)==null?void 0:ce.y)??0))}},Y=re=>{$.x<=10&&$.y<=10?re.preventDefault():C.contains(re.target)||O(!1),document.removeEventListener("pointermove",q),M.current=null};return M.current!==null&&(document.addEventListener("pointermove",q),document.addEventListener("pointerup",Y,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",q),document.removeEventListener("pointerup",Y,{capture:!0})}}},[C,O,M]),d.useEffect(()=>{const $=()=>O(!1);return window.addEventListener("blur",$),window.addEventListener("resize",$),()=>{window.removeEventListener("blur",$),window.removeEventListener("resize",$)}},[O]);const[J,z]=M0($=>{const q=N().filter(ue=>!ue.disabled),Y=q.find(ue=>ue.ref.current===document.activeElement),re=D0(q,$,Y);re&&setTimeout(()=>re.ref.current.focus())}),H=d.useCallback(($,q,Y)=>{const re=!T.current&&!Y;(b.value!==void 0&&b.value===q||re)&&(I($),re&&(T.current=!0))},[b.value]),U=d.useCallback(()=>C==null?void 0:C.focus(),[C]),X=d.useCallback(($,q,Y)=>{const re=!T.current&&!Y;(b.value!==void 0&&b.value===q||re)&&F($)},[b.value]),W=r==="popper"?rd:b0,te=W===rd?{side:l,sideOffset:c,align:u,alignOffset:f,arrowPadding:h,collisionBoundary:p,collisionPadding:m,sticky:x,hideWhenDetached:g,avoidCollisions:v}:{};return s.jsx(v0,{scope:n,content:C,viewport:E,onViewportChange:S,itemRefCallback:H,selectedItem:A,onItemLeave:U,itemTextRefCallback:X,focusSelectedItem:L,selectedItemText:P,position:r,isPositioned:R,searchRef:J,children:s.jsx(li,{as:IA,allowPinchZoom:!0,children:s.jsx(ii,{asChild:!0,trapped:b.open,onMountAutoFocus:$=>{$.preventDefault()},onUnmountAutoFocus:xn(o,$=>{var q;(q=b.trigger)==null||q.focus({preventScroll:!0}),$.preventDefault()}),children:s.jsx(Kw,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:a,onPointerDownOutside:i,onFocusOutside:$=>$.preventDefault(),onDismiss:()=>b.onOpenChange(!1),children:s.jsx(W,{role:"listbox",id:b.contentId,"data-state":b.open?"open":"closed",dir:b.dir,onContextMenu:$=>$.preventDefault(),...w,...te,onPlaced:()=>y(!0),ref:j,style:{display:"flex",flexDirection:"column",outline:"none",...w.style},onKeyDown:xn(w.onKeyDown,$=>{const q=$.ctrlKey||$.altKey||$.metaKey;if($.key==="Tab"&&$.preventDefault(),!q&&$.key.length===1&&z($.key),["ArrowUp","ArrowDown","Home","End"].includes($.key)){let re=N().filter(ue=>!ue.disabled).map(ue=>ue.ref.current);if(["ArrowUp","End"].includes($.key)&&(re=re.slice().reverse()),["ArrowUp","ArrowDown"].includes($.key)){const ue=$.target,ce=re.indexOf(ue);re=re.slice(ce+1)}setTimeout(()=>D(re)),$.preventDefault()}})})})})})})});w0.displayName=AA;var RA="SelectItemAlignedPosition",b0=d.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...o}=e,a=Wo(as,n),i=Ho(as,n),[l,c]=d.useState(null),[u,f]=d.useState(null),h=ht(t,j=>f(j)),p=wc(n),m=d.useRef(!1),x=d.useRef(!0),{viewport:g,selectedItem:v,selectedItemText:w,focusSelectedItem:b}=i,C=d.useCallback(()=>{if(a.trigger&&a.valueNode&&l&&u&&g&&v&&w){const j=a.trigger.getBoundingClientRect(),A=u.getBoundingClientRect(),I=a.valueNode.getBoundingClientRect(),P=w.getBoundingClientRect();if(a.dir!=="rtl"){const ue=P.left-A.left,ce=I.left-ue,pe=j.left-ce,k=j.width+pe,oe=Math.max(k,A.width),ae=window.innerWidth-Sr,G=Hp(ce,[Sr,Math.max(Sr,ae-oe)]);l.style.minWidth=k+"px",l.style.left=G+"px"}else{const ue=A.right-P.right,ce=window.innerWidth-I.right-ue,pe=window.innerWidth-j.right-ce,k=j.width+pe,oe=Math.max(k,A.width),ae=window.innerWidth-Sr,G=Hp(ce,[Sr,Math.max(Sr,ae-oe)]);l.style.minWidth=k+"px",l.style.right=G+"px"}const F=p(),N=window.innerHeight-Sr*2,R=g.scrollHeight,y=window.getComputedStyle(u),T=parseInt(y.borderTopWidth,10),D=parseInt(y.paddingTop,10),L=parseInt(y.borderBottomWidth,10),O=parseInt(y.paddingBottom,10),M=T+D+R+O+L,J=Math.min(v.offsetHeight*5,M),z=window.getComputedStyle(g),H=parseInt(z.paddingTop,10),U=parseInt(z.paddingBottom,10),X=j.top+j.height/2-Sr,W=N-X,te=v.offsetHeight/2,$=v.offsetTop+te,q=T+D+$,Y=M-q;if(q<=X){const ue=F.length>0&&v===F[F.length-1].ref.current;l.style.bottom="0px";const ce=u.clientHeight-g.offsetTop-g.offsetHeight,pe=Math.max(W,te+(ue?U:0)+ce+L),k=q+pe;l.style.height=k+"px"}else{const ue=F.length>0&&v===F[0].ref.current;l.style.top="0px";const pe=Math.max(X,T+g.offsetTop+(ue?H:0)+te)+Y;l.style.height=pe+"px",g.scrollTop=q-X+g.offsetTop}l.style.margin=`${Sr}px 0`,l.style.minHeight=J+"px",l.style.maxHeight=N+"px",r==null||r(),requestAnimationFrame(()=>m.current=!0)}},[p,a.trigger,a.valueNode,l,u,g,v,w,a.dir,r]);dn(()=>C(),[C]);const[_,E]=d.useState();dn(()=>{u&&E(window.getComputedStyle(u).zIndex)},[u]);const S=d.useCallback(j=>{j&&x.current===!0&&(C(),b==null||b(),x.current=!1)},[C,b]);return s.jsx(MA,{scope:n,contentWrapper:l,shouldExpandOnScrollRef:m,onScrollButtonChange:S,children:s.jsx("div",{ref:c,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:_},children:s.jsx(nt.div,{...o,ref:h,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});b0.displayName=RA;var PA="SelectPopperPosition",rd=d.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:o=Sr,...a}=e,i=bc(n);return s.jsx(l0,{...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)"}})});rd.displayName=PA;var[MA,zf]=fa(as,{}),od="SelectViewport",y0=d.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...o}=e,a=Ho(od,n),i=zf(od,n),l=ht(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(vc.Slot,{scope:n,children:s.jsx(nt.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:p}=i;if(p!=null&&p.current&&h){const m=Math.abs(c.current-f.scrollTop);if(m>0){const x=window.innerHeight-Sr*2,g=parseFloat(h.style.minHeight),v=parseFloat(h.style.height),w=Math.max(g,v);if(w<x){const b=w+m,C=Math.min(x,b),_=b-C;h.style.height=C+"px",h.style.bottom==="0px"&&(f.scrollTop=_>0?_:0,h.style.justifyContent="flex-end")}}}c.current=f.scrollTop})})})]})});y0.displayName=od;var C0="SelectGroup",[DA,OA]=fa(C0),LA=d.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=ir();return s.jsx(DA,{scope:n,id:o,children:s.jsx(nt.div,{role:"group","aria-labelledby":o,...r,ref:t})})});LA.displayName=C0;var S0="SelectLabel",FA=d.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=OA(S0,n);return s.jsx(nt.div,{id:o.id,...r,ref:t})});FA.displayName=S0;var jl="SelectItem",[zA,_0]=fa(jl),k0=d.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:o=!1,textValue:a,...i}=e,l=Wo(jl,n),c=Ho(jl,n),u=l.value===r,[f,h]=d.useState(a??""),[p,m]=d.useState(!1),x=ht(t,b=>{var C;return(C=c.itemRefCallback)==null?void 0:C.call(c,b,r,o)}),g=ir(),v=d.useRef("touch"),w=()=>{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(zA,{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(vc.ItemSlot,{scope:n,value:r,disabled:o,textValue:f,children:s.jsx(nt.div,{role:"option","aria-labelledby":g,"data-highlighted":p?"":void 0,"aria-selected":u&&p,"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,()=>m(!0)),onBlur:xn(i.onBlur,()=>m(!1)),onClick:xn(i.onClick,()=>{v.current!=="mouse"&&w()}),onPointerUp:xn(i.onPointerUp,()=>{v.current==="mouse"&&w()}),onPointerDown:xn(i.onPointerDown,b=>{v.current=b.pointerType}),onPointerMove:xn(i.onPointerMove,b=>{var C;v.current=b.pointerType,o?(C=c.onItemLeave)==null||C.call(c):v.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 _;((_=c.searchRef)==null?void 0:_.current)!==""&&b.key===" "||(SA.includes(b.key)&&w(),b.key===" "&&b.preventDefault())})})})})});k0.displayName=jl;var Ta="SelectItemText",j0=d.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,...a}=e,i=Wo(Ta,n),l=Ho(Ta,n),c=_0(Ta,n),u=EA(Ta,n),[f,h]=d.useState(null),p=ht(t,w=>h(w),c.onItemTextChange,w=>{var b;return(b=l.itemTextRefCallback)==null?void 0:b.call(l,w,c.value,c.disabled)}),m=f==null?void 0:f.textContent,x=d.useMemo(()=>s.jsx("option",{value:c.value,disabled:c.disabled,children:m},c.value),[c.disabled,c.value,m]),{onNativeOptionAdd:g,onNativeOptionRemove:v}=u;return dn(()=>(g(x),()=>v(x)),[g,v,x]),s.jsxs(s.Fragment,{children:[s.jsx(nt.span,{id:c.textId,...a,ref:p}),c.isSelected&&i.valueNode&&!i.valueNodeHasChildren?oa.createPortal(a.children,i.valueNode):null]})});j0.displayName=Ta;var E0="SelectItemIndicator",N0=d.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return _0(E0,n).isSelected?s.jsx(nt.span,{"aria-hidden":!0,...r,ref:t}):null});N0.displayName=E0;var sd="SelectScrollUpButton",T0=d.forwardRef((e,t)=>{const n=Ho(sd,e.__scopeSelect),r=zf(sd,e.__scopeSelect),[o,a]=d.useState(!1),i=ht(t,r.onScrollButtonChange);return dn(()=>{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(I0,{...e,ref:i,onAutoScroll:()=>{const{viewport:l,selectedItem:c}=n;l&&c&&(l.scrollTop=l.scrollTop-c.offsetHeight)}}):null});T0.displayName=sd;var ad="SelectScrollDownButton",A0=d.forwardRef((e,t)=>{const n=Ho(ad,e.__scopeSelect),r=zf(ad,e.__scopeSelect),[o,a]=d.useState(!1),i=ht(t,r.onScrollButtonChange);return dn(()=>{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(I0,{...e,ref:i,onAutoScroll:()=>{const{viewport:l,selectedItem:c}=n;l&&c&&(l.scrollTop=l.scrollTop+c.offsetHeight)}}):null});A0.displayName=ad;var I0=d.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...o}=e,a=Ho("SelectScrollButton",n),i=d.useRef(null),l=wc(n),c=d.useCallback(()=>{i.current!==null&&(window.clearInterval(i.current),i.current=null)},[]);return d.useEffect(()=>()=>c(),[c]),dn(()=>{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(nt.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()})})}),$A="SelectSeparator",UA=d.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return s.jsx(nt.div,{"aria-hidden":!0,...r,ref:t})});UA.displayName=$A;var id="SelectArrow",BA=d.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=bc(n),a=Wo(id,n),i=Ho(id,n);return a.open&&i.position==="popper"?s.jsx(c0,{...o,...r,ref:t}):null});BA.displayName=id;var VA="SelectBubbleInput",R0=d.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{const o=d.useRef(null),a=ht(r,o),i=yA(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(nt.select,{...n,style:{...Kx,...n.style},ref:a,defaultValue:t})});R0.displayName=VA;function P0(e){return e===""||e===void 0}function M0(e){const t=In(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 D0(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=WA(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 WA(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var HA=u0,ZA=f0,GA=p0,YA=m0,KA=g0,qA=x0,XA=y0,JA=k0,QA=j0,eI=N0,tI=T0,nI=A0;function Nr({...e}){return s.jsx(HA,{"data-slot":"select",...e})}function Tr({...e}){return s.jsx(GA,{"data-slot":"select-value",...e})}function Ar({className:e,size:t="default",children:n,...r}){return s.jsxs(ZA,{"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(YA,{asChild:!0,children:s.jsx(ll,{className:"size-4 opacity-50"})})]})}function Ir({className:e,children:t,position:n="popper",...r}){return s.jsx(KA,{children:s.jsxs(qA,{"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(rI,{}),s.jsx(XA,{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(oI,{})]})})}function _t({className:e,children:t,...n}){return s.jsxs(JA,{"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(eI,{children:s.jsx(sa,{className:"size-4"})})}),s.jsx(QA,{children:t})]})}function rI({className:e,...t}){return s.jsx(tI,{"data-slot":"select-scroll-up-button",className:ze("flex cursor-default items-center justify-center py-1",e),...t,children:s.jsx(Ru,{className:"size-4"})})}function oI({className:e,...t}){return s.jsx(nI,{"data-slot":"select-scroll-down-button",className:ze("flex cursor-default items-center justify-center py-1",e),...t,children:s.jsx(ll,{className:"size-4"})})}var iu="rovingFocusGroup.onEntryFocus",sI={bubbles:!1,cancelable:!0},hi="RovingFocusGroup",[ld,O0,aI]=fc(hi),[iI,L0]=ur(hi,[aI]),[lI,cI]=iI(hi),F0=d.forwardRef((e,t)=>s.jsx(ld.Provider,{scope:e.__scopeRovingFocusGroup,children:s.jsx(ld.Slot,{scope:e.__scopeRovingFocusGroup,children:s.jsx(uI,{...e,ref:t})})}));F0.displayName=hi;var uI=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,p=d.useRef(null),m=ht(t,p),x=ui(a),[g,v]=fo({prop:i,defaultProp:l??null,onChange:c,caller:hi}),[w,b]=d.useState(!1),C=In(u),_=O0(n),E=d.useRef(!1),[S,j]=d.useState(0);return d.useEffect(()=>{const A=p.current;if(A)return A.addEventListener(iu,C),()=>A.removeEventListener(iu,C)},[C]),s.jsx(lI,{scope:n,orientation:r,dir:x,loop:o,currentTabStopId:g,onItemFocus:d.useCallback(A=>v(A),[v]),onItemShiftTab:d.useCallback(()=>b(!0),[]),onFocusableItemAdd:d.useCallback(()=>j(A=>A+1),[]),onFocusableItemRemove:d.useCallback(()=>j(A=>A-1),[]),children:s.jsx(nt.div,{tabIndex:w||S===0?-1:0,"data-orientation":r,...h,ref:m,style:{outline:"none",...e.style},onMouseDown:Bt(e.onMouseDown,()=>{E.current=!0}),onFocus:Bt(e.onFocus,A=>{const I=!E.current;if(A.target===A.currentTarget&&I&&!w){const P=new CustomEvent(iu,sI);if(A.currentTarget.dispatchEvent(P),!P.defaultPrevented){const F=_().filter(D=>D.focusable),N=F.find(D=>D.active),R=F.find(D=>D.id===g),T=[N,R,...F].filter(Boolean).map(D=>D.ref.current);U0(T,f)}}E.current=!1}),onBlur:Bt(e.onBlur,()=>b(!1))})})}),z0="RovingFocusGroupItem",$0=d.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:a,children:i,...l}=e,c=ir(),u=a||c,f=cI(z0,n),h=f.currentTabStopId===u,p=O0(n),{onFocusableItemAdd:m,onFocusableItemRemove:x,currentTabStopId:g}=f;return d.useEffect(()=>{if(r)return m(),()=>x()},[r,m,x]),s.jsx(ld.ItemSlot,{scope:n,id:u,focusable:r,active:o,children:s.jsx(nt.span,{tabIndex:h?0:-1,"data-orientation":f.orientation,...l,ref:t,onMouseDown:Bt(e.onMouseDown,v=>{r?f.onItemFocus(u):v.preventDefault()}),onFocus:Bt(e.onFocus,()=>f.onItemFocus(u)),onKeyDown:Bt(e.onKeyDown,v=>{if(v.key==="Tab"&&v.shiftKey){f.onItemShiftTab();return}if(v.target!==v.currentTarget)return;const w=hI(v,f.orientation,f.dir);if(w!==void 0){if(v.metaKey||v.ctrlKey||v.altKey||v.shiftKey)return;v.preventDefault();let C=p().filter(_=>_.focusable).map(_=>_.ref.current);if(w==="last")C.reverse();else if(w==="prev"||w==="next"){w==="prev"&&C.reverse();const _=C.indexOf(v.currentTarget);C=f.loop?pI(C,_+1):C.slice(_+1)}setTimeout(()=>U0(C))}}),children:typeof i=="function"?i({isCurrentTabStop:h,hasTabStop:g!=null}):i})})});$0.displayName=z0;var dI={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function fI(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function hI(e,t,n){const r=fI(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return dI[r]}function U0(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function pI(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var mI=F0,gI=$0,yc="Tabs",[xI,b9]=ur(yc,[L0]),B0=L0(),[vI,$f]=xI(yc),V0=d.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,onValueChange:o,defaultValue:a,orientation:i="horizontal",dir:l,activationMode:c="automatic",...u}=e,f=ui(l),[h,p]=fo({prop:r,onChange:o,defaultProp:a??"",caller:yc});return s.jsx(vI,{scope:n,baseId:ir(),value:h,onValueChange:p,orientation:i,dir:f,activationMode:c,children:s.jsx(nt.div,{dir:f,"data-orientation":i,...u,ref:t})})});V0.displayName=yc;var W0="TabsList",H0=d.forwardRef((e,t)=>{const{__scopeTabs:n,loop:r=!0,...o}=e,a=$f(W0,n),i=B0(n);return s.jsx(mI,{asChild:!0,...i,orientation:a.orientation,dir:a.dir,loop:r,children:s.jsx(nt.div,{role:"tablist","aria-orientation":a.orientation,...o,ref:t})})});H0.displayName=W0;var Z0="TabsTrigger",G0=d.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,disabled:o=!1,...a}=e,i=$f(Z0,n),l=B0(n),c=q0(i.baseId,r),u=X0(i.baseId,r),f=r===i.value;return s.jsx(gI,{asChild:!0,...l,focusable:!o,active:f,children:s.jsx(nt.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:Bt(e.onMouseDown,h=>{!o&&h.button===0&&h.ctrlKey===!1?i.onValueChange(r):h.preventDefault()}),onKeyDown:Bt(e.onKeyDown,h=>{[" ","Enter"].includes(h.key)&&i.onValueChange(r)}),onFocus:Bt(e.onFocus,()=>{const h=i.activationMode!=="manual";!f&&!o&&h&&i.onValueChange(r)})})})});G0.displayName=Z0;var Y0="TabsContent",K0=d.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,forceMount:o,children:a,...i}=e,l=$f(Y0,n),c=q0(l.baseId,r),u=X0(l.baseId,r),f=r===l.value,h=d.useRef(f);return d.useEffect(()=>{const p=requestAnimationFrame(()=>h.current=!1);return()=>cancelAnimationFrame(p)},[]),s.jsx(wo,{present:o||f,children:({present:p})=>s.jsx(nt.div,{"data-state":f?"active":"inactive","data-orientation":l.orientation,role:"tabpanel","aria-labelledby":c,hidden:!p,id:u,tabIndex:0,...i,ref:t,style:{...e.style,animationDuration:h.current?"0s":void 0},children:p&&a})})});K0.displayName=Y0;function q0(e,t){return`${e}-trigger-${t}`}function X0(e,t){return`${e}-content-${t}`}var wI=V0,bI=H0,yI=G0,CI=K0;function SI({className:e,...t}){return s.jsx(wI,{"data-slot":"tabs",className:ze("flex flex-col gap-2",e),...t})}function _I({className:e,...t}){return s.jsx(bI,{"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 Kp({className:e,...t}){return s.jsx(yI,{"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 qp({className:e,...t}){return s.jsx(CI,{"data-slot":"tabs-content",className:ze("flex-1 outline-none",e),...t})}function El(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 tn(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 kI="DismissableLayer",cd="dismissableLayer.update",jI="dismissableLayer.pointerDownOutside",EI="dismissableLayer.focusOutside",Xp,J0=d.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Q0=d.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:a,onInteractOutside:i,onDismiss:l,...c}=e,u=d.useContext(J0),[f,h]=d.useState(null),p=(f==null?void 0:f.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,m]=d.useState({}),x=ht(t,j=>h(j)),g=Array.from(u.layers),[v]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),w=g.indexOf(v),b=f?g.indexOf(f):-1,C=u.layersWithOutsidePointerEventsDisabled.size>0,_=b>=w,E=AI(j=>{const A=j.target,I=[...u.branches].some(P=>P.contains(A));!_||I||(o==null||o(j),i==null||i(j),j.defaultPrevented||l==null||l())},p),S=II(j=>{const A=j.target;[...u.branches].some(P=>P.contains(A))||(a==null||a(j),i==null||i(j),j.defaultPrevented||l==null||l())},p);return Gd(j=>{b===u.layers.size-1&&(r==null||r(j),!j.defaultPrevented&&l&&(j.preventDefault(),l()))},p),d.useEffect(()=>{if(f)return n&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(Xp=p.body.style.pointerEvents,p.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(f)),u.layers.add(f),Jp(),()=>{n&&u.layersWithOutsidePointerEventsDisabled.size===1&&(p.body.style.pointerEvents=Xp)}},[f,p,n,u]),d.useEffect(()=>()=>{f&&(u.layers.delete(f),u.layersWithOutsidePointerEventsDisabled.delete(f),Jp())},[f,u]),d.useEffect(()=>{const j=()=>m({});return document.addEventListener(cd,j),()=>document.removeEventListener(cd,j)},[]),s.jsx(nt.div,{...c,ref:x,style:{pointerEvents:C?_?"auto":"none":void 0,...e.style},onFocusCapture:tn(e.onFocusCapture,S.onFocusCapture),onBlurCapture:tn(e.onBlurCapture,S.onBlurCapture),onPointerDownCapture:tn(e.onPointerDownCapture,E.onPointerDownCapture)})});Q0.displayName=kI;var NI="DismissableLayerBranch",TI=d.forwardRef((e,t)=>{const n=d.useContext(J0),r=d.useRef(null),o=ht(t,r);return d.useEffect(()=>{const a=r.current;if(a)return n.branches.add(a),()=>{n.branches.delete(a)}},[n.branches]),s.jsx(nt.div,{...e,ref:o})});TI.displayName=NI;function AI(e,t=globalThis==null?void 0:globalThis.document){const n=In(e),r=d.useRef(!1),o=d.useRef(()=>{});return d.useEffect(()=>{const a=l=>{if(l.target&&!r.current){let c=function(){eb(jI,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 II(e,t=globalThis==null?void 0:globalThis.document){const n=In(e),r=d.useRef(!1);return d.useEffect(()=>{const o=a=>{a.target&&!r.current&&eb(EI,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 Jp(){const e=new CustomEvent(cd);document.dispatchEvent(e)}function eb(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?Yl(o,a):o.dispatchEvent(a)}var lu=0;function RI(){d.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??Qp()),document.body.insertAdjacentElement("beforeend",e[1]??Qp()),lu++,()=>{lu===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),lu--}},[])}function Qp(){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 PI(e,t){return d.useReducer((n,r)=>t[n][r]??n,e)}var pi=e=>{const{present:t,children:n}=e,r=MI(t),o=typeof n=="function"?n({present:r.isPresent}):d.Children.only(n),a=ht(r.ref,DI(o));return typeof n=="function"||r.isPresent?d.cloneElement(o,{ref:a}):null};pi.displayName="Presence";function MI(e){const[t,n]=d.useState(),r=d.useRef(null),o=d.useRef(e),a=d.useRef("none"),i=e?"mounted":"unmounted",[l,c]=PI(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return d.useEffect(()=>{const u=Oi(r.current);a.current=l==="mounted"?u:"none"},[l]),dn(()=>{const u=r.current,f=o.current;if(f!==e){const p=a.current,m=Oi(u);e?c("MOUNT"):m==="none"||(u==null?void 0:u.display)==="none"?c("UNMOUNT"):c(f&&p!==m?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,c]),dn(()=>{if(t){let u;const f=t.ownerDocument.defaultView??window,h=m=>{const g=Oi(r.current).includes(CSS.escape(m.animationName));if(m.target===t&&g&&(c("ANIMATION_END"),!o.current)){const v=t.style.animationFillMode;t.style.animationFillMode="forwards",u=f.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=v)})}},p=m=>{m.target===t&&(a.current=Oi(r.current))};return t.addEventListener("animationstart",p),t.addEventListener("animationcancel",h),t.addEventListener("animationend",h),()=>{f.clearTimeout(u),t.removeEventListener("animationstart",p),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 Oi(e){return(e==null?void 0:e.animationName)||"none"}function DI(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 Bs(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 cu="rovingFocusGroup.onEntryFocus",OI={bubbles:!1,cancelable:!0},mi="RovingFocusGroup",[ud,tb,LI]=fc(mi),[FI,nb]=ur(mi,[LI]),[zI,$I]=FI(mi),rb=d.forwardRef((e,t)=>s.jsx(ud.Provider,{scope:e.__scopeRovingFocusGroup,children:s.jsx(ud.Slot,{scope:e.__scopeRovingFocusGroup,children:s.jsx(UI,{...e,ref:t})})}));rb.displayName=mi;var UI=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,p=d.useRef(null),m=ht(t,p),x=ui(a),[g,v]=fo({prop:i,defaultProp:l??null,onChange:c,caller:mi}),[w,b]=d.useState(!1),C=In(u),_=tb(n),E=d.useRef(!1),[S,j]=d.useState(0);return d.useEffect(()=>{const A=p.current;if(A)return A.addEventListener(cu,C),()=>A.removeEventListener(cu,C)},[C]),s.jsx(zI,{scope:n,orientation:r,dir:x,loop:o,currentTabStopId:g,onItemFocus:d.useCallback(A=>v(A),[v]),onItemShiftTab:d.useCallback(()=>b(!0),[]),onFocusableItemAdd:d.useCallback(()=>j(A=>A+1),[]),onFocusableItemRemove:d.useCallback(()=>j(A=>A-1),[]),children:s.jsx(nt.div,{tabIndex:w||S===0?-1:0,"data-orientation":r,...h,ref:m,style:{outline:"none",...e.style},onMouseDown:Bs(e.onMouseDown,()=>{E.current=!0}),onFocus:Bs(e.onFocus,A=>{const I=!E.current;if(A.target===A.currentTarget&&I&&!w){const P=new CustomEvent(cu,OI);if(A.currentTarget.dispatchEvent(P),!P.defaultPrevented){const F=_().filter(D=>D.focusable),N=F.find(D=>D.active),R=F.find(D=>D.id===g),T=[N,R,...F].filter(Boolean).map(D=>D.ref.current);ab(T,f)}}E.current=!1}),onBlur:Bs(e.onBlur,()=>b(!1))})})}),ob="RovingFocusGroupItem",sb=d.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:a,children:i,...l}=e,c=ir(),u=a||c,f=$I(ob,n),h=f.currentTabStopId===u,p=tb(n),{onFocusableItemAdd:m,onFocusableItemRemove:x,currentTabStopId:g}=f;return d.useEffect(()=>{if(r)return m(),()=>x()},[r,m,x]),s.jsx(ud.ItemSlot,{scope:n,id:u,focusable:r,active:o,children:s.jsx(nt.span,{tabIndex:h?0:-1,"data-orientation":f.orientation,...l,ref:t,onMouseDown:Bs(e.onMouseDown,v=>{r?f.onItemFocus(u):v.preventDefault()}),onFocus:Bs(e.onFocus,()=>f.onItemFocus(u)),onKeyDown:Bs(e.onKeyDown,v=>{if(v.key==="Tab"&&v.shiftKey){f.onItemShiftTab();return}if(v.target!==v.currentTarget)return;const w=WI(v,f.orientation,f.dir);if(w!==void 0){if(v.metaKey||v.ctrlKey||v.altKey||v.shiftKey)return;v.preventDefault();let C=p().filter(_=>_.focusable).map(_=>_.ref.current);if(w==="last")C.reverse();else if(w==="prev"||w==="next"){w==="prev"&&C.reverse();const _=C.indexOf(v.currentTarget);C=f.loop?HI(C,_+1):C.slice(_+1)}setTimeout(()=>ab(C))}}),children:typeof i=="function"?i({isCurrentTabStop:h,hasTabStop:g!=null}):i})})});sb.displayName=ob;var BI={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function VI(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function WI(e,t,n){const r=VI(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return BI[r]}function ab(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function HI(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var ZI=rb,GI=sb,dd=["Enter"," "],YI=["ArrowDown","PageUp","Home"],ib=["ArrowUp","PageDown","End"],KI=[...YI,...ib],qI={ltr:[...dd,"ArrowRight"],rtl:[...dd,"ArrowLeft"]},XI={ltr:["ArrowLeft"],rtl:["ArrowRight"]},gi="Menu",[Ha,JI,QI]=fc(gi),[hs,lb]=ur(gi,[QI,xc,nb]),Cc=xc(),cb=nb(),[eR,ps]=hs(gi),[tR,xi]=hs(gi),ub=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:o,onOpenChange:a,modal:i=!0}=e,l=Cc(t),[c,u]=d.useState(null),f=d.useRef(!1),h=In(a),p=ui(o);return d.useEffect(()=>{const m=()=>{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",m,{capture:!0}),()=>{document.removeEventListener("keydown",m,{capture:!0}),document.removeEventListener("pointerdown",x,{capture:!0}),document.removeEventListener("pointermove",x,{capture:!0})}},[]),s.jsx(a0,{...l,children:s.jsx(eR,{scope:t,open:n,onOpenChange:h,content:c,onContentChange:u,children:s.jsx(tR,{scope:t,onClose:d.useCallback(()=>h(!1),[h]),isUsingKeyboardRef:f,dir:p,modal:i,children:r})})})};ub.displayName=gi;var nR="MenuAnchor",Uf=d.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=Cc(n);return s.jsx(i0,{...o,...r,ref:t})});Uf.displayName=nR;var Bf="MenuPortal",[rR,db]=hs(Bf,{forceMount:void 0}),fb=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:o}=e,a=ps(Bf,t);return s.jsx(rR,{scope:t,forceMount:n,children:s.jsx(pi,{present:n||a.open,children:s.jsx(da,{asChild:!0,container:o,children:r})})})};fb.displayName=Bf;var vr="MenuContent",[oR,Vf]=hs(vr),hb=d.forwardRef((e,t)=>{const n=db(vr,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,a=ps(vr,e.__scopeMenu),i=xi(vr,e.__scopeMenu);return s.jsx(Ha.Provider,{scope:e.__scopeMenu,children:s.jsx(pi,{present:r||a.open,children:s.jsx(Ha.Slot,{scope:e.__scopeMenu,children:i.modal?s.jsx(sR,{...o,ref:t}):s.jsx(aR,{...o,ref:t})})})})}),sR=d.forwardRef((e,t)=>{const n=ps(vr,e.__scopeMenu),r=d.useRef(null),o=ht(t,r);return d.useEffect(()=>{const a=r.current;if(a)return ac(a)},[]),s.jsx(Wf,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:tn(e.onFocusOutside,a=>a.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),aR=d.forwardRef((e,t)=>{const n=ps(vr,e.__scopeMenu);return s.jsx(Wf,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),iR=Po("MenuContent.ScrollLock"),Wf=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:p,onDismiss:m,disableOutsideScroll:x,...g}=e,v=ps(vr,n),w=xi(vr,n),b=Cc(n),C=cb(n),_=JI(n),[E,S]=d.useState(null),j=d.useRef(null),A=ht(t,j,v.onContentChange),I=d.useRef(0),P=d.useRef(""),F=d.useRef(0),N=d.useRef(null),R=d.useRef("right"),y=d.useRef(0),T=x?li:d.Fragment,D=x?{as:iR,allowPinchZoom:!0}:void 0,L=M=>{var $,q;const J=P.current+M,z=_().filter(Y=>!Y.disabled),H=document.activeElement,U=($=z.find(Y=>Y.ref.current===H))==null?void 0:$.textValue,X=z.map(Y=>Y.textValue),W=wR(X,J,U),te=(q=z.find(Y=>Y.textValue===W))==null?void 0:q.ref.current;(function Y(re){P.current=re,window.clearTimeout(I.current),re!==""&&(I.current=window.setTimeout(()=>Y(""),1e3))})(J),te&&setTimeout(()=>te.focus())};d.useEffect(()=>()=>window.clearTimeout(I.current),[]),RI();const O=d.useCallback(M=>{var z,H;return R.current===((z=N.current)==null?void 0:z.side)&&yR(M,(H=N.current)==null?void 0:H.area)},[]);return s.jsx(oR,{scope:n,searchRef:P,onItemEnter:d.useCallback(M=>{O(M)&&M.preventDefault()},[O]),onItemLeave:d.useCallback(M=>{var J;O(M)||((J=j.current)==null||J.focus(),S(null))},[O]),onTriggerLeave:d.useCallback(M=>{O(M)&&M.preventDefault()},[O]),pointerGraceTimerRef:F,onPointerGraceIntentChange:d.useCallback(M=>{N.current=M},[]),children:s.jsx(T,{...D,children:s.jsx(ii,{asChild:!0,trapped:o,onMountAutoFocus:tn(a,M=>{var J;M.preventDefault(),(J=j.current)==null||J.focus({preventScroll:!0})}),onUnmountAutoFocus:i,children:s.jsx(Q0,{asChild:!0,disableOutsidePointerEvents:l,onEscapeKeyDown:u,onPointerDownOutside:f,onFocusOutside:h,onInteractOutside:p,onDismiss:m,children:s.jsx(ZI,{asChild:!0,...C,dir:w.dir,orientation:"vertical",loop:r,currentTabStopId:E,onCurrentTabStopIdChange:S,onEntryFocus:tn(c,M=>{w.isUsingKeyboardRef.current||M.preventDefault()}),preventScrollOnEntryFocus:!0,children:s.jsx(l0,{role:"menu","aria-orientation":"vertical","data-state":Tb(v.open),"data-radix-menu-content":"",dir:w.dir,...b,...g,ref:A,style:{outline:"none",...g.style},onKeyDown:tn(g.onKeyDown,M=>{const z=M.target.closest("[data-radix-menu-content]")===M.currentTarget,H=M.ctrlKey||M.altKey||M.metaKey,U=M.key.length===1;z&&(M.key==="Tab"&&M.preventDefault(),!H&&U&&L(M.key));const X=j.current;if(M.target!==X||!KI.includes(M.key))return;M.preventDefault();const te=_().filter($=>!$.disabled).map($=>$.ref.current);ib.includes(M.key)&&te.reverse(),xR(te)}),onBlur:tn(e.onBlur,M=>{M.currentTarget.contains(M.target)||(window.clearTimeout(I.current),P.current="")}),onPointerMove:tn(e.onPointerMove,Za(M=>{const J=M.target,z=y.current!==M.clientX;if(M.currentTarget.contains(J)&&z){const H=M.clientX>y.current?"right":"left";R.current=H,y.current=M.clientX}}))})})})})})})});hb.displayName=vr;var lR="MenuGroup",Hf=d.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return s.jsx(nt.div,{role:"group",...r,ref:t})});Hf.displayName=lR;var cR="MenuLabel",pb=d.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return s.jsx(nt.div,{...r,ref:t})});pb.displayName=cR;var Nl="MenuItem",em="menu.itemSelect",Sc=d.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...o}=e,a=d.useRef(null),i=xi(Nl,e.__scopeMenu),l=Vf(Nl,e.__scopeMenu),c=ht(t,a),u=d.useRef(!1),f=()=>{const h=a.current;if(!n&&h){const p=new CustomEvent(em,{bubbles:!0,cancelable:!0});h.addEventListener(em,m=>r==null?void 0:r(m),{once:!0}),Yl(h,p),p.defaultPrevented?u.current=!1:i.onClose()}};return s.jsx(mb,{...o,ref:c,disabled:n,onClick:tn(e.onClick,f),onPointerDown:h=>{var p;(p=e.onPointerDown)==null||p.call(e,h),u.current=!0},onPointerUp:tn(e.onPointerUp,h=>{var p;u.current||(p=h.currentTarget)==null||p.click()}),onKeyDown:tn(e.onKeyDown,h=>{const p=l.searchRef.current!=="";n||p&&h.key===" "||dd.includes(h.key)&&(h.currentTarget.click(),h.preventDefault())})})});Sc.displayName=Nl;var mb=d.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:o,...a}=e,i=Vf(Nl,n),l=cb(n),c=d.useRef(null),u=ht(t,c),[f,h]=d.useState(!1),[p,m]=d.useState("");return d.useEffect(()=>{const x=c.current;x&&m((x.textContent??"").trim())},[a.children]),s.jsx(Ha.ItemSlot,{scope:n,disabled:r,textValue:o??p,children:s.jsx(GI,{asChild:!0,...l,focusable:!r,children:s.jsx(nt.div,{role:"menuitem","data-highlighted":f?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...a,ref:u,onPointerMove:tn(e.onPointerMove,Za(x=>{r?i.onItemLeave(x):(i.onItemEnter(x),x.defaultPrevented||x.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:tn(e.onPointerLeave,Za(x=>i.onItemLeave(x))),onFocus:tn(e.onFocus,()=>h(!0)),onBlur:tn(e.onBlur,()=>h(!1))})})})}),uR="MenuCheckboxItem",gb=d.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...o}=e;return s.jsx(yb,{scope:e.__scopeMenu,checked:n,children:s.jsx(Sc,{role:"menuitemcheckbox","aria-checked":Tl(n)?"mixed":n,...o,ref:t,"data-state":Gf(n),onSelect:tn(o.onSelect,()=>r==null?void 0:r(Tl(n)?!0:!n),{checkForDefaultPrevented:!1})})})});gb.displayName=uR;var xb="MenuRadioGroup",[dR,fR]=hs(xb,{value:void 0,onValueChange:()=>{}}),vb=d.forwardRef((e,t)=>{const{value:n,onValueChange:r,...o}=e,a=In(r);return s.jsx(dR,{scope:e.__scopeMenu,value:n,onValueChange:a,children:s.jsx(Hf,{...o,ref:t})})});vb.displayName=xb;var wb="MenuRadioItem",bb=d.forwardRef((e,t)=>{const{value:n,...r}=e,o=fR(wb,e.__scopeMenu),a=n===o.value;return s.jsx(yb,{scope:e.__scopeMenu,checked:a,children:s.jsx(Sc,{role:"menuitemradio","aria-checked":a,...r,ref:t,"data-state":Gf(a),onSelect:tn(r.onSelect,()=>{var i;return(i=o.onValueChange)==null?void 0:i.call(o,n)},{checkForDefaultPrevented:!1})})})});bb.displayName=wb;var Zf="MenuItemIndicator",[yb,hR]=hs(Zf,{checked:!1}),Cb=d.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...o}=e,a=hR(Zf,n);return s.jsx(pi,{present:r||Tl(a.checked)||a.checked===!0,children:s.jsx(nt.span,{...o,ref:t,"data-state":Gf(a.checked)})})});Cb.displayName=Zf;var pR="MenuSeparator",Sb=d.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return s.jsx(nt.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});Sb.displayName=pR;var mR="MenuArrow",_b=d.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=Cc(n);return s.jsx(c0,{...o,...r,ref:t})});_b.displayName=mR;var gR="MenuSub",[y9,kb]=hs(gR),Aa="MenuSubTrigger",jb=d.forwardRef((e,t)=>{const n=ps(Aa,e.__scopeMenu),r=xi(Aa,e.__scopeMenu),o=kb(Aa,e.__scopeMenu),a=Vf(Aa,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(Uf,{asChild:!0,...u,children:s.jsx(mb,{id:o.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":o.contentId,"data-state":Tb(n.open),...e,ref:Gl(t,o.onTriggerChange),onClick:h=>{var p;(p=e.onClick)==null||p.call(e,h),!(e.disabled||h.defaultPrevented)&&(h.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:tn(e.onPointerMove,Za(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:tn(e.onPointerLeave,Za(h=>{var m,x;f();const p=(m=n.content)==null?void 0:m.getBoundingClientRect();if(p){const g=(x=n.content)==null?void 0:x.dataset.side,v=g==="right",w=v?-5:5,b=p[v?"left":"right"],C=p[v?"right":"left"];a.onPointerGraceIntentChange({area:[{x:h.clientX+w,y:h.clientY},{x:b,y:p.top},{x:C,y:p.top},{x:C,y:p.bottom},{x:b,y:p.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:tn(e.onKeyDown,h=>{var m;const p=a.searchRef.current!=="";e.disabled||p&&h.key===" "||qI[r.dir].includes(h.key)&&(n.onOpenChange(!0),(m=n.content)==null||m.focus(),h.preventDefault())})})})});jb.displayName=Aa;var Eb="MenuSubContent",Nb=d.forwardRef((e,t)=>{const n=db(vr,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,a=ps(vr,e.__scopeMenu),i=xi(vr,e.__scopeMenu),l=kb(Eb,e.__scopeMenu),c=d.useRef(null),u=ht(t,c);return s.jsx(Ha.Provider,{scope:e.__scopeMenu,children:s.jsx(pi,{present:r||a.open,children:s.jsx(Ha.Slot,{scope:e.__scopeMenu,children:s.jsx(Wf,{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:tn(e.onFocusOutside,f=>{f.target!==l.trigger&&a.onOpenChange(!1)}),onEscapeKeyDown:tn(e.onEscapeKeyDown,f=>{i.onClose(),f.preventDefault()}),onKeyDown:tn(e.onKeyDown,f=>{var m;const h=f.currentTarget.contains(f.target),p=XI[i.dir].includes(f.key);h&&p&&(a.onOpenChange(!1),(m=l.trigger)==null||m.focus(),f.preventDefault())})})})})})});Nb.displayName=Eb;function Tb(e){return e?"open":"closed"}function Tl(e){return e==="indeterminate"}function Gf(e){return Tl(e)?"indeterminate":e?"checked":"unchecked"}function xR(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function vR(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function wR(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=vR(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 bR(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,p=c.y;f>r!=p>r&&n<(h-u)*(r-f)/(p-f)+u&&(o=!o)}return o}function yR(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return bR(n,t)}function Za(e){return t=>t.pointerType==="mouse"?e(t):void 0}var CR=ub,SR=Uf,_R=fb,kR=hb,jR=Hf,ER=pb,NR=Sc,TR=gb,AR=vb,IR=bb,RR=Cb,PR=Sb,MR=_b,DR=jb,OR=Nb,_c="DropdownMenu",[LR,C9]=ur(_c,[lb]),Hn=lb(),[FR,Ab]=LR(_c),Ib=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:o,defaultOpen:a,onOpenChange:i,modal:l=!0}=e,c=Hn(t),u=d.useRef(null),[f,h]=fo({prop:o,defaultProp:a??!1,onChange:i,caller:_c});return s.jsx(FR,{scope:t,triggerId:ir(),triggerRef:u,contentId:ir(),open:f,onOpenChange:h,onOpenToggle:d.useCallback(()=>h(p=>!p),[h]),modal:l,children:s.jsx(CR,{...c,open:f,onOpenChange:h,dir:r,modal:l,children:n})})};Ib.displayName=_c;var Rb="DropdownMenuTrigger",Pb=d.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...o}=e,a=Ab(Rb,n),i=Hn(n);return s.jsx(SR,{asChild:!0,...i,children:s.jsx(nt.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:Gl(t,a.triggerRef),onPointerDown:El(e.onPointerDown,l=>{!r&&l.button===0&&l.ctrlKey===!1&&(a.onOpenToggle(),a.open||l.preventDefault())}),onKeyDown:El(e.onKeyDown,l=>{r||(["Enter"," "].includes(l.key)&&a.onOpenToggle(),l.key==="ArrowDown"&&a.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(l.key)&&l.preventDefault())})})})});Pb.displayName=Rb;var zR="DropdownMenuPortal",Mb=e=>{const{__scopeDropdownMenu:t,...n}=e,r=Hn(t);return s.jsx(_R,{...r,...n})};Mb.displayName=zR;var Db="DropdownMenuContent",Ob=d.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ab(Db,n),a=Hn(n),i=d.useRef(!1);return s.jsx(kR,{id:o.contentId,"aria-labelledby":o.triggerId,...a,...r,ref:t,onCloseAutoFocus:El(e.onCloseAutoFocus,l=>{var c;i.current||(c=o.triggerRef.current)==null||c.focus(),i.current=!1,l.preventDefault()}),onInteractOutside:El(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)"}})});Ob.displayName=Db;var $R="DropdownMenuGroup",UR=d.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Hn(n);return s.jsx(jR,{...o,...r,ref:t})});UR.displayName=$R;var BR="DropdownMenuLabel",VR=d.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Hn(n);return s.jsx(ER,{...o,...r,ref:t})});VR.displayName=BR;var WR="DropdownMenuItem",Lb=d.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Hn(n);return s.jsx(NR,{...o,...r,ref:t})});Lb.displayName=WR;var HR="DropdownMenuCheckboxItem",ZR=d.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Hn(n);return s.jsx(TR,{...o,...r,ref:t})});ZR.displayName=HR;var GR="DropdownMenuRadioGroup",YR=d.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Hn(n);return s.jsx(AR,{...o,...r,ref:t})});YR.displayName=GR;var KR="DropdownMenuRadioItem",qR=d.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Hn(n);return s.jsx(IR,{...o,...r,ref:t})});qR.displayName=KR;var XR="DropdownMenuItemIndicator",JR=d.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Hn(n);return s.jsx(RR,{...o,...r,ref:t})});JR.displayName=XR;var QR="DropdownMenuSeparator",Fb=d.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Hn(n);return s.jsx(PR,{...o,...r,ref:t})});Fb.displayName=QR;var eP="DropdownMenuArrow",tP=d.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Hn(n);return s.jsx(MR,{...o,...r,ref:t})});tP.displayName=eP;var nP="DropdownMenuSubTrigger",rP=d.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Hn(n);return s.jsx(DR,{...o,...r,ref:t})});rP.displayName=nP;var oP="DropdownMenuSubContent",sP=d.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Hn(n);return s.jsx(OR,{...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)"}})});sP.displayName=oP;var aP=Ib,iP=Pb,lP=Mb,cP=Ob,uP=Lb,dP=Fb;function Xs({...e}){return s.jsx(aP,{"data-slot":"dropdown-menu",...e})}function Js({...e}){return s.jsx(iP,{"data-slot":"dropdown-menu-trigger",...e})}function Qs({className:e,sideOffset:t=4,...n}){return s.jsx(lP,{children:s.jsx(cP,{"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(uP,{"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 tm({className:e,...t}){return s.jsx(dP,{"data-slot":"dropdown-menu-separator",className:ze("bg-border -mx-1 my-1 h-px",e),...t})}function fP({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 hP({className:e,...t}){return s.jsx("tbody",{"data-slot":"table-body",className:ze("[&_tr:last-child]:border-0",e),...t})}function pP({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 nm({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 zb=d.forwardRef(({className:e,...t},n)=>s.jsx($r,{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}));zb.displayName="ChatInput";const mP=$o("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"}}),$b=d.forwardRef(({className:e,variant:t,layout:n,children:r,...o},a)=>s.jsx("div",{className:ze(mP({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)}));$b.displayName="ChatBubble";const gP=$o("",{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"}}),Ub=d.forwardRef(({className:e,variant:t,layout:n,children:r,...o},a)=>s.jsx("div",{className:ze(gP({variant:t,layout:n,className:e}),"relative max-w-full leading-[150%] break-words"),ref:a,...o,children:s.jsx(s.Fragment,{children:r})}));Ub.displayName="ChatBubbleMessage";const xP=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}));xP.displayName="ChatBubbleActionWrapper";const Bb={padding:"0 16px",maxWidth:"1280px",minWidth:"400px",margin:"0 auto",width:"100%"},Vb=At.forwardRef(({className:e="",children:t,...n},r)=>{const o=At.useRef(null),{scrollRef:a,isAtBottom:i,disableAutoScroll:l,scrollToBottom:c,userHasScrolled:u}=kP({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:Bb,ref:o,children:t})}),!i&&u&&s.jsx(me,{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(gg,{className:"h-4 w-4"})})]})});Vb.displayName="ChatMessageList";function vP({className:e=""}){return s.jsx(Qr,{size:"small",variant:"primary",className:e})}const Li={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)]"},wP=$o("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:Li.error,warning:Li.warning,info:Li.info,success:Li.success}},defaultVariants:{variant:"default"}});function Or({className:e,variant:t,type:n,asChild:r=!1,...o}){const a=r?ix:"span";return s.jsx(a,{"data-slot":"badge",className:ze(wP({variant:t,type:n}),e),...o})}const bP=$o("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 yP({className:e,variant:t,...n}){return s.jsx("div",{"data-slot":"alert",role:"alert",className:ze(bP({variant:t}),e),...n})}function CP({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 SP({id:e,message:t,type:n}){return s.jsx("div",{id:e,className:"transform transition-all duration-200 ease-in-out",children:s.jsx(yP,{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(CP,{className:"flex h-10 items-center",children:[n==="warning"&&s.jsx(Rd,{className:"mr-2 text-[var(--color-warning-wMain)]"}),n==="success"&&s.jsx(Pd,{className:"mr-2 text-[var(--color-success-wMain)]"}),s.jsx("div",{className:"truncate",children:t})]})})})}function _P(){const{notifications:e}=It();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(SP,{id:t.id,message:t.message,type:t.type})},t.id))})}function kP(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),[p,m]=d.useState({isAtBottom:!0,autoScrollEnabled:!0}),x=d.useCallback(b=>{const{scrollTop:C,scrollHeight:_,clientHeight:E}=b;return Math.abs(_-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,m({isAtBottom:!0,autoScrollEnabled:!0}),c.current=!1,setTimeout(()=>{i.current&&(u.current=i.current.scrollTop),h.current=!1},b?50:500)},[n]),v=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,m(()=>({isAtBottom:!0,autoScrollEnabled:!0}))):f.current?m(()=>({isAtBottom:!1,autoScrollEnabled:!1})):m(E=>({...E,isAtBottom:!1}))},[x]);d.useEffect(()=>{const b=i.current;if(b)return b.addEventListener("scroll",v,{passive:!0}),()=>b.removeEventListener("scroll",v)},[v]),d.useEffect(()=>{const b=i.current;if(!b)return;const C=b.scrollHeight;C!==l.current&&((p.autoScrollEnabled||o)&&requestAnimationFrame(()=>{g(l.current===0)}),l.current=C)},[r,p.autoScrollEnabled,g,o]),d.useEffect(()=>{const b=(a==null?void 0:a.current)||i.current;if(!b)return;const C=new ResizeObserver(()=>{p.autoScrollEnabled&&g(!0)});return C.observe(b),()=>C.disconnect()},[p.autoScrollEnabled,g,a]);const w=d.useCallback(()=>{(i.current?x(i.current):!1)||(c.current=!0,m(C=>({...C,autoScrollEnabled:!1})))},[x]);return{scrollRef:i,isAtBottom:p.isAtBottom,autoScrollEnabled:p.autoScrollEnabled,scrollToBottom:()=>g(),disableAutoScroll:w,userHasScrolled:c.current}}const jP=({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(me,{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(xg,{className:"h-3.5 w-3.5 flex-shrink-0"}),s.jsx("span",{className:"truncate",children:"Ask Followup"})]})})})};function EP(){const e=window.getSelection();return!e||e.rangeCount===0?null:e.toString().trim()||null}function Wb(){const e=window.getSelection();return!e||e.rangeCount===0?null:e.getRangeAt(0)}function NP(){const e=Wb();return e?e.getBoundingClientRect():null}function TP(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 AP(e){if(!e)return!1;const t=e.trim();return t.length>=3&&/\S/.test(t)}const IP=({messageId:e,children:t,isAIMessage:n})=>{const{setSelection:r,clearSelection:o}=ax(),a=d.useRef(null),i=d.useCallback(()=>{n&&setTimeout(()=>{const l=EP(),c=Wb(),u=NP();if(!AP(l)||!c||!u||!l)return;const f=a.current;if(!f||!c.intersectsNode(f))return;const h=TP(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})},Yf=d.forwardRef(({disabled:e=!1,onTranscriptionComplete:t,onError:n,onRecordingStateChange:r,className:o},a)=>{const{settings:i}=Uo(),l=d.useRef(""),c=d.useRef(!0),u=d.useCallback(_=>{console.log("Transcription update:",_)},[]),f=d.useCallback(_=>{if(c.current&&_&&_.trim()){const E=l.current?`${l.current} ${_}`.trim():_.trim();t(E),l.current=""}else c.current||(console.log("AudioRecorder: Transcription canceled, not sending"),l.current="");c.current=!0},[t]),h=d.useCallback(_=>{console.error("Speech-to-text error:",_),n&&n(_)},[n]),{isListening:p,isLoading:m,startRecording:x,stopRecording:g}=NT({onTranscriptionComplete:f,onTranscriptionUpdate:u,onError:h});d.useEffect(()=>{r==null||r(p)},[p,r]),d.useImperativeHandle(a,()=>({startRecording:async()=>{p||(l.current="",c.current=!0,await x())},stopRecording:async()=>{p&&(c.current=!0,await g())},cancelRecording:async()=>{p&&(console.log("AudioRecorder: Canceling recording"),c.current=!1,await g())}}),[p,x,g]);const v=d.useCallback(async()=>{p?(c.current=!0,await g()):(l.current="",c.current=!0,await x())},[p,x,g]),w=()=>m?s.jsx(ar,{className:"size-5 animate-spin"}):p?s.jsx(Pu,{className:"size-5 animate-pulse"}):s.jsx(Pu,{className:"size-5"}),b=()=>p?"Stop recording":m?"Processing...":i.speechToText?"Start voice recording":"Speech-to-text is disabled",C=()=>p?"Stop voice recording":"Start voice recording";return i.speechToText?s.jsx(me,{variant:"ghost",size:"icon",onClick:v,disabled:e||m,className:ze("transition-colors",p&&"bg-[var(--accent-background)] text-[var(--primary-wMain)] hover:bg-[var(--accent-background)]/80",o),tooltip:b(),"aria-label":C(),"aria-pressed":p,"aria-busy":m,children:w()}):null});Yf.displayName="AudioRecorder";function RP({width:e=24,height:t=24}){const{currentTheme:n}=ci(),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 PP({width:e=24,height:t=24}){const{currentTheme:n}=ci(),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 Pr({title:e,subtitle:t,image:n,variant:r="error",buttons:o,className:a}){const i={error:s.jsx(RP,{width:150,height:150}),notFound:s.jsx(PP,{width:150,height:150}),loading:s.jsx(Qr,{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(me,{testid:c,title:c,variant:u,onClick:f,children:[l||null,c]},`button-${c}-${h}`))})]})}const MP=({children:e,className:t=""})=>s.jsx("div",{className:`flex h-16 items-center justify-end gap-4 border-t px-8 ${t}`,children:e}),kc=({children:e,className:t,isSelected:n,onClick:r,...o})=>s.jsx(xf,{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:Hb,setPrototypeOf:rm,isFrozen:DP,getPrototypeOf:OP,getOwnPropertyDescriptor:LP}=Object;let{freeze:Un,seal:br,create:Zb}=Object,{apply:fd,construct:hd}=typeof Reflect<"u"&&Reflect;Un||(Un=function(t){return t});br||(br=function(t){return t});fd||(fd=function(t,n,r){return t.apply(n,r)});hd||(hd=function(t,n){return new t(...n)});const Fi=Bn(Array.prototype.forEach),FP=Bn(Array.prototype.lastIndexOf),om=Bn(Array.prototype.pop),wa=Bn(Array.prototype.push),zP=Bn(Array.prototype.splice),il=Bn(String.prototype.toLowerCase),uu=Bn(String.prototype.toString),sm=Bn(String.prototype.match),ba=Bn(String.prototype.replace),$P=Bn(String.prototype.indexOf),UP=Bn(String.prototype.trim),_r=Bn(Object.prototype.hasOwnProperty),Fn=Bn(RegExp.prototype.test),ya=BP(TypeError);function Bn(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 fd(e,t,r)}}function BP(e){return function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return hd(e,n)}}function bt(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:il;rm&&rm(e,null);let r=t.length;for(;r--;){let o=t[r];if(typeof o=="string"){const a=n(o);a!==o&&(DP(t)||(t[r]=a),o=a)}e[o]=!0}return e}function VP(e){for(let t=0;t<e.length;t++)_r(e,t)||(e[t]=null);return e}function io(e){const t=Zb(null);for(const[n,r]of Hb(e))_r(e,n)&&(Array.isArray(r)?t[n]=VP(r):r&&typeof r=="object"&&r.constructor===Object?t[n]=io(r):t[n]=r);return t}function Ca(e,t){for(;e!==null;){const r=LP(e,t);if(r){if(r.get)return Bn(r.get);if(typeof r.value=="function")return Bn(r.value)}e=OP(e)}function n(){return null}return n}const am=Un(["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"]),du=Un(["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"]),fu=Un(["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"]),WP=Un(["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"]),hu=Un(["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"]),HP=Un(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),im=Un(["#text"]),lm=Un(["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"]),pu=Un(["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"]),cm=Un(["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"]),zi=Un(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),ZP=br(/\{\{[\w\W]*|[\w\W]*\}\}/gm),GP=br(/<%[\w\W]*|[\w\W]*%>/gm),YP=br(/\$\{[\w\W]*/gm),KP=br(/^data-[\-\w.\u00B7-\uFFFF]+$/),qP=br(/^aria-[\-\w]+$/),Gb=br(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),XP=br(/^(?:\w+script|data):/i),JP=br(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Yb=br(/^html$/i),QP=br(/^[a-z][.\w]*(-[.\w]+)+$/i);var um=Object.freeze({__proto__:null,ARIA_ATTR:qP,ATTR_WHITESPACE:JP,CUSTOM_ELEMENT:QP,DATA_ATTR:KP,DOCTYPE_NAME:Yb,ERB_EXPR:GP,IS_ALLOWED_URI:Gb,IS_SCRIPT_OR_DATA:XP,MUSTACHE_EXPR:ZP,TMPLIT_EXPR:YP});const Sa={element:1,text:3,progressingInstruction:7,comment:8,document:9},e4=function(){return typeof window>"u"?null:window},t4=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}},dm=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function Kb(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:e4();const t=_e=>Kb(_e);if(t.version="3.2.6",t.removed=[],!e||!e.document||e.document.nodeType!==Sa.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:p,trustedTypes:m}=e,x=c.prototype,g=Ca(x,"cloneNode"),v=Ca(x,"remove"),w=Ca(x,"nextSibling"),b=Ca(x,"childNodes"),C=Ca(x,"parentNode");if(typeof i=="function"){const _e=n.createElement("template");_e.content&&_e.content.ownerDocument&&(n=_e.content.ownerDocument)}let _,E="";const{implementation:S,createNodeIterator:j,createDocumentFragment:A,getElementsByTagName:I}=n,{importNode:P}=r;let F=dm();t.isSupported=typeof Hb=="function"&&typeof C=="function"&&S&&S.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:N,ERB_EXPR:R,TMPLIT_EXPR:y,DATA_ATTR:T,ARIA_ATTR:D,IS_SCRIPT_OR_DATA:L,ATTR_WHITESPACE:O,CUSTOM_ELEMENT:M}=um;let{IS_ALLOWED_URI:J}=um,z=null;const H=bt({},[...am,...du,...fu,...hu,...im]);let U=null;const X=bt({},[...lm,...pu,...cm,...zi]);let W=Object.seal(Zb(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}})),te=null,$=null,q=!0,Y=!0,re=!1,ue=!0,ce=!1,pe=!0,k=!1,oe=!1,ae=!1,G=!1,V=!1,ne=!1,B=!0,K=!1;const Z="user-content-";let le=!0,de=!1,se={},he=null;const Ee=bt({},["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 pt=bt({},["audio","video","img","source","image","track"]);let Lt=null;const jt=bt({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Rt="http://www.w3.org/1998/Math/MathML",it="http://www.w3.org/2000/svg",Ot="http://www.w3.org/1999/xhtml";let Jt=Ot,Ft=!1,xe=null;const Re=bt({},[Rt,it,Ot],uu);let Ie=bt({},["mi","mo","mn","ms","mtext"]),Pe=bt({},["annotation-xml"]);const ot=bt({},["title","style","font","a","script"]);let Me=null;const Pt=["application/xhtml+xml","text/html"],Ke="text/html";let st=null,yt=null;const en=n.createElement("form"),Rn=function(Q){return Q instanceof RegExp||Q instanceof Function},ee=function(){let Q=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(yt&&yt===Q)){if((!Q||typeof Q!="object")&&(Q={}),Q=io(Q),Me=Pt.indexOf(Q.PARSER_MEDIA_TYPE)===-1?Ke:Q.PARSER_MEDIA_TYPE,st=Me==="application/xhtml+xml"?uu:il,z=_r(Q,"ALLOWED_TAGS")?bt({},Q.ALLOWED_TAGS,st):H,U=_r(Q,"ALLOWED_ATTR")?bt({},Q.ALLOWED_ATTR,st):X,xe=_r(Q,"ALLOWED_NAMESPACES")?bt({},Q.ALLOWED_NAMESPACES,uu):Re,Lt=_r(Q,"ADD_URI_SAFE_ATTR")?bt(io(jt),Q.ADD_URI_SAFE_ATTR,st):jt,Ae=_r(Q,"ADD_DATA_URI_TAGS")?bt(io(pt),Q.ADD_DATA_URI_TAGS,st):pt,he=_r(Q,"FORBID_CONTENTS")?bt({},Q.FORBID_CONTENTS,st):Ee,te=_r(Q,"FORBID_TAGS")?bt({},Q.FORBID_TAGS,st):io({}),$=_r(Q,"FORBID_ATTR")?bt({},Q.FORBID_ATTR,st):io({}),se=_r(Q,"USE_PROFILES")?Q.USE_PROFILES:!1,q=Q.ALLOW_ARIA_ATTR!==!1,Y=Q.ALLOW_DATA_ATTR!==!1,re=Q.ALLOW_UNKNOWN_PROTOCOLS||!1,ue=Q.ALLOW_SELF_CLOSE_IN_ATTR!==!1,ce=Q.SAFE_FOR_TEMPLATES||!1,pe=Q.SAFE_FOR_XML!==!1,k=Q.WHOLE_DOCUMENT||!1,G=Q.RETURN_DOM||!1,V=Q.RETURN_DOM_FRAGMENT||!1,ne=Q.RETURN_TRUSTED_TYPE||!1,ae=Q.FORCE_BODY||!1,B=Q.SANITIZE_DOM!==!1,K=Q.SANITIZE_NAMED_PROPS||!1,le=Q.KEEP_CONTENT!==!1,de=Q.IN_PLACE||!1,J=Q.ALLOWED_URI_REGEXP||Gb,Jt=Q.NAMESPACE||Ot,Ie=Q.MATHML_TEXT_INTEGRATION_POINTS||Ie,Pe=Q.HTML_INTEGRATION_POINTS||Pe,W=Q.CUSTOM_ELEMENT_HANDLING||{},Q.CUSTOM_ELEMENT_HANDLING&&Rn(Q.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(W.tagNameCheck=Q.CUSTOM_ELEMENT_HANDLING.tagNameCheck),Q.CUSTOM_ELEMENT_HANDLING&&Rn(Q.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(W.attributeNameCheck=Q.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),Q.CUSTOM_ELEMENT_HANDLING&&typeof Q.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(W.allowCustomizedBuiltInElements=Q.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),ce&&(Y=!1),V&&(G=!0),se&&(z=bt({},im),U=[],se.html===!0&&(bt(z,am),bt(U,lm)),se.svg===!0&&(bt(z,du),bt(U,pu),bt(U,zi)),se.svgFilters===!0&&(bt(z,fu),bt(U,pu),bt(U,zi)),se.mathMl===!0&&(bt(z,hu),bt(U,cm),bt(U,zi))),Q.ADD_TAGS&&(z===H&&(z=io(z)),bt(z,Q.ADD_TAGS,st)),Q.ADD_ATTR&&(U===X&&(U=io(U)),bt(U,Q.ADD_ATTR,st)),Q.ADD_URI_SAFE_ATTR&&bt(Lt,Q.ADD_URI_SAFE_ATTR,st),Q.FORBID_CONTENTS&&(he===Ee&&(he=io(he)),bt(he,Q.FORBID_CONTENTS,st)),le&&(z["#text"]=!0),k&&bt(z,["html","head","body"]),z.table&&(bt(z,["tbody"]),delete te.tbody),Q.TRUSTED_TYPES_POLICY){if(typeof Q.TRUSTED_TYPES_POLICY.createHTML!="function")throw ya('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof Q.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw ya('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');_=Q.TRUSTED_TYPES_POLICY,E=_.createHTML("")}else _===void 0&&(_=t4(m,o)),_!==null&&typeof E=="string"&&(E=_.createHTML(""));Un&&Un(Q),yt=Q}},ie=bt({},[...du,...fu,...WP]),fe=bt({},[...hu,...HP]),we=function(Q){let ve=C(Q);(!ve||!ve.tagName)&&(ve={namespaceURI:Jt,tagName:"template"});const be=il(Q.tagName),ut=il(ve.tagName);return xe[Q.namespaceURI]?Q.namespaceURI===it?ve.namespaceURI===Ot?be==="svg":ve.namespaceURI===Rt?be==="svg"&&(ut==="annotation-xml"||Ie[ut]):!!ie[be]:Q.namespaceURI===Rt?ve.namespaceURI===Ot?be==="math":ve.namespaceURI===it?be==="math"&&Pe[ut]:!!fe[be]:Q.namespaceURI===Ot?ve.namespaceURI===it&&!Pe[ut]||ve.namespaceURI===Rt&&!Ie[ut]?!1:!fe[be]&&(ot[be]||!ie[be]):!!(Me==="application/xhtml+xml"&&xe[Q.namespaceURI]):!1},ye=function(Q){wa(t.removed,{element:Q});try{C(Q).removeChild(Q)}catch{v(Q)}},Le=function(Q,ve){try{wa(t.removed,{attribute:ve.getAttributeNode(Q),from:ve})}catch{wa(t.removed,{attribute:null,from:ve})}if(ve.removeAttribute(Q),Q==="is")if(G||V)try{ye(ve)}catch{}else try{ve.setAttribute(Q,"")}catch{}},$e=function(Q){let ve=null,be=null;if(ae)Q="<remove></remove>"+Q;else{const tt=sm(Q,/^[\r\n\t ]+/);be=tt&&tt[0]}Me==="application/xhtml+xml"&&Jt===Ot&&(Q='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+Q+"</body></html>");const ut=_?_.createHTML(Q):Q;if(Jt===Ot)try{ve=new p().parseFromString(ut,Me)}catch{}if(!ve||!ve.documentElement){ve=S.createDocument(Jt,"template",null);try{ve.documentElement.innerHTML=Ft?E:ut}catch{}}const Fe=ve.body||ve.documentElement;return Q&&be&&Fe.insertBefore(n.createTextNode(be),Fe.childNodes[0]||null),Jt===Ot?I.call(ve,k?"html":"body")[0]:k?ve.documentElement:Fe},De=function(Q){return j.call(Q.ownerDocument||Q,Q,u.SHOW_ELEMENT|u.SHOW_COMMENT|u.SHOW_TEXT|u.SHOW_PROCESSING_INSTRUCTION|u.SHOW_CDATA_SECTION,null)},Ve=function(Q){return Q instanceof h&&(typeof Q.nodeName!="string"||typeof Q.textContent!="string"||typeof Q.removeChild!="function"||!(Q.attributes instanceof f)||typeof Q.removeAttribute!="function"||typeof Q.setAttribute!="function"||typeof Q.namespaceURI!="string"||typeof Q.insertBefore!="function"||typeof Q.hasChildNodes!="function")},Xe=function(Q){return typeof l=="function"&&Q instanceof l};function We(_e,Q,ve){Fi(_e,be=>{be.call(t,Q,ve,yt)})}const Ce=function(Q){let ve=null;if(We(F.beforeSanitizeElements,Q,null),Ve(Q))return ye(Q),!0;const be=st(Q.nodeName);if(We(F.uponSanitizeElement,Q,{tagName:be,allowedTags:z}),pe&&Q.hasChildNodes()&&!Xe(Q.firstElementChild)&&Fn(/<[/\w!]/g,Q.innerHTML)&&Fn(/<[/\w!]/g,Q.textContent)||Q.nodeType===Sa.progressingInstruction||pe&&Q.nodeType===Sa.comment&&Fn(/<[/\w]/g,Q.data))return ye(Q),!0;if(!z[be]||te[be]){if(!te[be]&&Je(be)&&(W.tagNameCheck instanceof RegExp&&Fn(W.tagNameCheck,be)||W.tagNameCheck instanceof Function&&W.tagNameCheck(be)))return!1;if(le&&!he[be]){const ut=C(Q)||Q.parentNode,Fe=b(Q)||Q.childNodes;if(Fe&&ut){const tt=Fe.length;for(let Ct=tt-1;Ct>=0;--Ct){const lt=g(Fe[Ct],!0);lt.__removalCount=(Q.__removalCount||0)+1,ut.insertBefore(lt,w(Q))}}}return ye(Q),!0}return Q instanceof c&&!we(Q)||(be==="noscript"||be==="noembed"||be==="noframes")&&Fn(/<\/no(script|embed|frames)/i,Q.innerHTML)?(ye(Q),!0):(ce&&Q.nodeType===Sa.text&&(ve=Q.textContent,Fi([N,R,y],ut=>{ve=ba(ve,ut," ")}),Q.textContent!==ve&&(wa(t.removed,{element:Q.cloneNode()}),Q.textContent=ve)),We(F.afterSanitizeElements,Q,null),!1)},ke=function(Q,ve,be){if(B&&(ve==="id"||ve==="name")&&(be in n||be in en))return!1;if(!(Y&&!$[ve]&&Fn(T,ve))){if(!(q&&Fn(D,ve))){if(!U[ve]||$[ve]){if(!(Je(Q)&&(W.tagNameCheck instanceof RegExp&&Fn(W.tagNameCheck,Q)||W.tagNameCheck instanceof Function&&W.tagNameCheck(Q))&&(W.attributeNameCheck instanceof RegExp&&Fn(W.attributeNameCheck,ve)||W.attributeNameCheck instanceof Function&&W.attributeNameCheck(ve))||ve==="is"&&W.allowCustomizedBuiltInElements&&(W.tagNameCheck instanceof RegExp&&Fn(W.tagNameCheck,be)||W.tagNameCheck instanceof Function&&W.tagNameCheck(be))))return!1}else if(!Lt[ve]){if(!Fn(J,ba(be,O,""))){if(!((ve==="src"||ve==="xlink:href"||ve==="href")&&Q!=="script"&&$P(be,"data:")===0&&Ae[Q])){if(!(re&&!Fn(L,ba(be,O,"")))){if(be)return!1}}}}}}return!0},Je=function(Q){return Q!=="annotation-xml"&&sm(Q,M)},He=function(Q){We(F.beforeSanitizeAttributes,Q,null);const{attributes:ve}=Q;if(!ve||Ve(Q))return;const be={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:U,forceKeepAttr:void 0};let ut=ve.length;for(;ut--;){const Fe=ve[ut],{name:tt,namespaceURI:Ct,value:lt}=Fe,Et=st(tt),hn=lt;let qe=tt==="value"?hn:UP(hn);if(be.attrName=Et,be.attrValue=qe,be.keepAttr=!0,be.forceKeepAttr=void 0,We(F.uponSanitizeAttribute,Q,be),qe=be.attrValue,K&&(Et==="id"||Et==="name")&&(Le(tt,Q),qe=Z+qe),pe&&Fn(/((--!?|])>)|<\/(style|title)/i,qe)){Le(tt,Q);continue}if(be.forceKeepAttr)continue;if(!be.keepAttr){Le(tt,Q);continue}if(!ue&&Fn(/\/>/i,qe)){Le(tt,Q);continue}ce&&Fi([N,R,y],Zn=>{qe=ba(qe,Zn," ")});const Qt=st(Q.nodeName);if(!ke(Qt,Et,qe)){Le(tt,Q);continue}if(_&&typeof m=="object"&&typeof m.getAttributeType=="function"&&!Ct)switch(m.getAttributeType(Qt,Et)){case"TrustedHTML":{qe=_.createHTML(qe);break}case"TrustedScriptURL":{qe=_.createScriptURL(qe);break}}if(qe!==hn)try{Ct?Q.setAttributeNS(Ct,tt,qe):Q.setAttribute(tt,qe),Ve(Q)?ye(Q):om(t.removed)}catch{Le(tt,Q)}}We(F.afterSanitizeAttributes,Q,null)},Tt=function _e(Q){let ve=null;const be=De(Q);for(We(F.beforeSanitizeShadowDOM,Q,null);ve=be.nextNode();)We(F.uponSanitizeShadowNode,ve,null),Ce(ve),He(ve),ve.content instanceof a&&_e(ve.content);We(F.afterSanitizeShadowDOM,Q,null)};return t.sanitize=function(_e){let Q=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},ve=null,be=null,ut=null,Fe=null;if(Ft=!_e,Ft&&(_e="<!-->"),typeof _e!="string"&&!Xe(_e))if(typeof _e.toString=="function"){if(_e=_e.toString(),typeof _e!="string")throw ya("dirty is not a string, aborting")}else throw ya("toString is not a function");if(!t.isSupported)return _e;if(oe||ee(Q),t.removed=[],typeof _e=="string"&&(de=!1),de){if(_e.nodeName){const lt=st(_e.nodeName);if(!z[lt]||te[lt])throw ya("root node is forbidden and cannot be sanitized in-place")}}else if(_e instanceof l)ve=$e("<!---->"),be=ve.ownerDocument.importNode(_e,!0),be.nodeType===Sa.element&&be.nodeName==="BODY"||be.nodeName==="HTML"?ve=be:ve.appendChild(be);else{if(!G&&!ce&&!k&&_e.indexOf("<")===-1)return _&&ne?_.createHTML(_e):_e;if(ve=$e(_e),!ve)return G?null:ne?E:""}ve&&ae&&ye(ve.firstChild);const tt=De(de?_e:ve);for(;ut=tt.nextNode();)Ce(ut),He(ut),ut.content instanceof a&&Tt(ut.content);if(de)return _e;if(G){if(V)for(Fe=A.call(ve.ownerDocument);ve.firstChild;)Fe.appendChild(ve.firstChild);else Fe=ve;return(U.shadowroot||U.shadowrootmode)&&(Fe=P.call(r,Fe,!0)),Fe}let Ct=k?ve.outerHTML:ve.innerHTML;return k&&z["!doctype"]&&ve.ownerDocument&&ve.ownerDocument.doctype&&ve.ownerDocument.doctype.name&&Fn(Yb,ve.ownerDocument.doctype.name)&&(Ct="<!DOCTYPE "+ve.ownerDocument.doctype.name+`>
143
+ `+Ct),ce&&Fi([N,R,y],lt=>{Ct=ba(Ct,lt," ")}),_&&ne?_.createHTML(Ct):Ct},t.setConfig=function(){let _e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};ee(_e),oe=!0},t.clearConfig=function(){yt=null,oe=!1},t.isValidAttribute=function(_e,Q,ve){yt||ee({});const be=st(_e),ut=st(Q);return ke(be,ut,ve)},t.addHook=function(_e,Q){typeof Q=="function"&&wa(F[_e],Q)},t.removeHook=function(_e,Q){if(Q!==void 0){const ve=FP(F[_e],Q);return ve===-1?void 0:zP(F[_e],ve,1)[0]}return om(F[_e])},t.removeHooks=function(_e){F[_e]=[]},t.removeAllHooks=function(){F=dm()},t}var qb=Kb();const n4=({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(me,{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(sa,{className:"h-4 w-4 text-[var(--color-success-wMain)]"}):s.jsx(vg,{className:"h-4 w-4"})})]})};function Vs({children:e,className:t}){if(!e)return null;const n={replace:r=>{var o;if(r instanceof mh.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 mh.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(n4,{code:i,language:u})}}}};try{const r=T1.parse(e,{gfm:!0}),o=qb.sanitize(r,{USE_PROFILES:{html:!0}}),a=A1(o,n);return s.jsx("div",{className:tp(t),children:a})}catch{return s.jsx("div",{className:tp(t),children:e})}}const r4={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)]"},o4=$o("flex items-center gap-3 px-4 py-3 text-sm font-medium transition-all border-l-4 border-solid ",{variants:{variant:r4},defaultVariants:{variant:"error"}}),s4={error:To,warning:Rd,info:Qa,success:Pd};function Vt({className:e,variant:t="error",message:n,icon:r,dismissible:o=!1,onDismiss:a,...i}){const l=s4[t||"error"];return s.jsxs("div",{"data-testid":"messageBanner",className:ze(o4({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(me,{variant:"link",className:"h-min self-center p-0",onClick:a,"aria-label":"Dismiss",children:s.jsx(Xr,{className:"size-3"})})})]})}const a4=({fileName:e,onRemove:t})=>s.jsxs(Or,{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(me,{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(Xr,{})})]}),Kf=({group:e,onSubmit:t,onClose:n})=>{var h;const r=((h=e.productionPrompt)==null?void 0:h.promptText)||"",o=Gs(r),[a,i]=d.useState(()=>{const p={};return o.forEach(m=>{p[m]=""}),p}),[l,c]=d.useState(!1),u=d.useRef(null),f=p=>{if(p.preventDefault(),!o.every(g=>{var v;return(v=a[g])==null?void 0:v.trim()})){c(!0),setTimeout(()=>c(!1),3e3);return}const x=xk(r,a);t(x)};return d.useEffect(()=>{u.current&&u.current.focus()},[]),d.useEffect(()=>{const p=m=>{m.key==="Escape"&&n()};return window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)},[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(Vt,{variant:"error",message:"Please fill in all variables before inserting the prompt"})}),s.jsxs("form",{onSubmit:f,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((p,m)=>s.jsxs("div",{children:[s.jsx("label",{htmlFor:`var-${p}`,className:"mb-1 block text-sm font-medium",children:p}),s.jsx("textarea",{id:`var-${p}`,ref:m===0?u:null,value:a[p],onChange:x=>i(g=>({...g,[p]:x.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})]},p))})}),s.jsxs("div",{className:"flex flex-shrink-0 justify-end gap-2 border-t border-[var(--border)] p-6 pt-4",children:[s.jsx(me,{type:"button",variant:"ghost",onClick:n,children:"Cancel"}),s.jsx(me,{type:"submit",children:"Insert Prompt"})]})]})]})})},fm=[{command:"create-template",name:"Create Template from Session",description:"Create a reusable prompt template from this conversation",icon:Qo}],i4=({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,p]=d.useState([]),[m,x]=d.useState(!1),[g,v]=d.useState(null),[w,b]=d.useState(!1),[C,_]=d.useState(!1),E=d.useRef(null),S=d.useRef(null),j=d.useRef(null);d.useEffect(()=>{if(!e)return;(async()=>{x(!0);try{const M=await je.webui.get("/api/v1/prompts/groups/all");p(M)}catch(M){console.error("Failed to fetch prompt groups:",M)}finally{x(!1)}})()},[e]);const A=d.useMemo(()=>{const O=o.some(M=>M.isUser&&!M.isStatusBubble);return fm.filter(M=>M.command==="create-template"?O:!0)},[o]),I=d.useMemo(()=>{if(!l)return h;const O=l.toLowerCase();return h.filter(M=>{var J,z,H;return M.name.toLowerCase().includes(O)||((J=M.description)==null?void 0:J.toLowerCase().includes(O))||((z=M.command)==null?void 0:z.toLowerCase().includes(O))||((H=M.category)==null?void 0:H.toLowerCase().includes(O))})},[h,l]),P=d.useMemo(()=>[...I,...A],[I,A]),F=d.useCallback(O=>O.filter(M=>!M.isStatusBubble&&!M.isError&&!M.authenticationLink).map(M=>{var H;const J=M.isUser?"User":"Assistant",z=((H=M.parts)==null?void 0:H.filter(U=>U.kind==="text").map(U=>U.text).join(`
144
+ `))||"";return`${J}: ${z}`}).join(`
145
+
146
+ `),[]),N=d.useCallback(O=>{if(O.command==="create-template"&&a){const M=F(o);a(O.command,M),t(),c("")}},[o,F,a,t]),R=d.useCallback(()=>{t(),c(""),i("/prompts/new?mode=ai-assisted")},[t,i]),y=d.useCallback(O=>{var H;const M=((H=O.productionPrompt)==null?void 0:H.promptText)||"";Gs(M).length>0?(v(O),b(!0)):(r(M),t(),c(""))},[r,t]),T=d.useCallback(O=>{"command"in O&&fm.some(M=>M.command===O.command)?N(O):y(O)},[N,y]),D=d.useCallback(O=>{r(O),b(!1),v(null),t(),c("")},[r,t]),L=d.useCallback(O=>{var M,J;O.key==="Escape"?(O.preventDefault(),O.stopPropagation(),t(),c(""),(M=n.current)==null||M.focus()):O.key==="ArrowDown"?(O.preventDefault(),_(!0),f(z=>Math.min(z+1,P.length-1))):O.key==="ArrowUp"?(O.preventDefault(),_(!0),f(z=>Math.max(z-1,0))):O.key==="Enter"||O.key==="Tab"?(O.preventDefault(),P[u]&&T(P[u])):O.key==="Backspace"&&l===""&&(t(),(J=n.current)==null||J.focus())},[P,u,l,T,t,n]);return d.useEffect(()=>{e&&E.current&&E.current.focus()},[e]),d.useEffect(()=>{f(0)},[l]),d.useEffect(()=>{const O=document.getElementById(`prompt-item-${u}`);O&&O.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:S,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(Id,{className:"size-4 text-[var(--muted-foreground)]"}),s.jsx("input",{ref:E,type:"text",value:l,onChange:O=>c(O.target.value),onKeyDown:L,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:m?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"})}):P.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:R,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(es,{className:"size-4"}),"Create Prompt"]})]}):s.jsxs("div",{className:"flex flex-col p-2",children:[I.map((O,M)=>s.jsx("button",{id:`prompt-item-${M}`,onClick:()=>y(O),onMouseEnter:()=>{_(!1),f(M)},className:`w-full rounded-md p-3 text-left transition-colors ${M===u?"bg-[var(--accent)]":C?"":"hover:bg-[var(--accent)]"}`,children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx(Qo,{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:[O.command&&s.jsxs("span",{className:"font-mono text-xs text-[var(--primary)]",children:["/",O.command]}),s.jsx("span",{className:"text-sm font-medium",children:O.name}),O.category&&s.jsx("span",{className:"rounded bg-[var(--muted)] px-1.5 py-0.5 text-xs text-[var(--muted-foreground)]",children:O.category})]}),O.description&&s.jsx("p",{className:"mt-1 line-clamp-2 text-xs text-[var(--muted-foreground)]",children:O.description})]})]})},O.id)),A.length>0&&s.jsxs(s.Fragment,{children:[I.length>0&&s.jsx("div",{className:"my-2 border-t border-[var(--border)]"}),A.map((O,M)=>{const J=I.length+M,z=O.icon;return s.jsx("button",{id:`prompt-item-${J}`,onClick:()=>N(O),onMouseEnter:()=>{_(!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(z,{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:["/",O.command]}),s.jsx("span",{className:"text-sm font-medium",children:O.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:O.description})]})]})},`reserved-${O.command}`)})]})]})})]})}),w&&g&&s.jsx(Kf,{group:g,onSubmit:D,onClose:()=>{b(!1),v(null)}})]}):null},l4=({content:e,onClick:t,onRemove:n,isConfigured:r,filename:o,defaultFilename:a})=>{const l=(u=>u.split(`
147
+ `).slice(0,2).map(h=>{const p=h.trim();return p.length>40?p.substring(0,37)+"...":p}))(e),c=r?`Click to edit: ${o}`:"Click to customize file settings";return s.jsxs(ho,{children:[s.jsx(po,{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(me,{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(Xr,{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(mo,{side:"top",children:s.jsx("p",{children:c})})]})},c4=e=>{const t=e.length,n=e.split(`
149
+ `).length;return t>=2e3||n>=50},u4=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}`},d4=e=>({id:`paste-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,content:e,timestamp:Date.now()}),f4=[{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"}],h4=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",p4=(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}`},$i="text/plain",m4=({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,p]=d.useState(""),[m,x]=d.useState($i),[g,v]=d.useState(""),[w,b]=d.useState(null),_=o.includes(u)&&u!==a;d.useEffect(()=>{if(e&&t)if(v(t),a)f(a),x(i||$i),p(l||"");else{x($i);const P=c||p4("snippet","txt",o);f(P);const F=u4(t);p(F)}},[e,t,o,a,i,l,c]),d.useEffect(()=>{const P=h4(m);if(u.match(/^snippet(-\d+)?\.[\w]+$/)){const F=u.match(/^(snippet(-\d+)?)\./),R=`${F?F[1]:"snippet"}.${P}`;R!==u&&f(R)}},[m,u]);const E=()=>{if(!g.trim()){b("Content cannot be empty. Please add some content before saving.");return}b(null),n({filename:u,mimeType:m,description:h.trim()||void 0,content:g}),j()},S=()=>{j(),r()},j=()=>{f("snippet.txt"),p(""),x($i),v(""),b(null)},A=g.length,I=g.split(`
151
+ `).length;return s.jsx(Pn,{open:e,onOpenChange:S,children:s.jsxs(Mn,{className:"flex max-h-[80vh] flex-col sm:max-w-2xl",children:[s.jsxs(Vn,{children:[s.jsx(Dn,{children:"Customize File"}),s.jsx(Wn,{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(Nt,{htmlFor:"title",children:"Filename"}),s.jsx(xr,{id:"title",value:u,onChange:P=>f(P.target.value),placeholder:"snippet.txt",autoFocus:!1,onFocus:P=>{setTimeout(()=>{P.target.setSelectionRange(P.target.value.length,P.target.value.length)},0)}}),_&&s.jsx(Vt,{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(Nt,{htmlFor:"description",children:"Description (optional)"}),s.jsx(xr,{id:"description",value:h,onChange:P=>p(P.target.value),placeholder:"Brief description of this file"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Nt,{htmlFor:"type",children:"Type"}),s.jsxs(Nr,{value:m,onValueChange:x,children:[s.jsx(Ar,{id:"type",children:s.jsx(Tr,{})}),s.jsx(Ir,{children:f4.map(P=>s.jsx(_t,{value:P.value,children:P.label},P.value))})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Nt,{htmlFor:"content",children:"Content"}),s.jsx($r,{id:"content",value:g,onChange:P=>{v(P.target.value),P.target.value.trim()&&w&&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, ",I," lines"]}),w&&s.jsx(Vt,{variant:"error",message:w,dismissible:!0,onDismiss:()=>b(null)})]})]}),s.jsxs(er,{children:[s.jsx(me,{variant:"ghost",onClick:S,children:"Cancel"}),s.jsx(me,{onClick:E,disabled:!u.trim(),children:"Customize"})]})]})})},g4=(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""}},x4=({agents:e=[],scrollToBottom:t})=>{const n=zo(),r=zr(),{isResponding:o,isCancelling:a,selectedAgentName:i,sessionId:l,setSessionId:c,handleSubmit:u,handleCancel:f,uploadArtifactFile:h,displayError:p,artifacts:m,messages:x,startNewChatWithPrompt:g,pendingPrompt:v,clearPendingPrompt:w}=It(),{handleAgentSelection:b}=RT(),{settings:C}=Uo(),{configFeatureEnablement:_}=sn(),E=(_==null?void 0:_.speechToText)??!0,S=d.useRef(null),[j,A]=d.useState([]),[I,P]=d.useState([]),[F,N]=d.useState(null),[R,y]=d.useState(!1),[T,D]=d.useState(null),[L,O]=d.useState(!1),M=d.useRef(null),J=d.useRef(o),[z,H]=d.useState(""),[U,X]=d.useState(!1),[W,te]=d.useState(!1),[$,q]=d.useState(null),[Y,re]=d.useState(null),[ue,ce]=d.useState(!1),pe=d.useRef(l),k=d.useRef(null);d.useEffect(()=>{var xe;if((xe=r.state)!=null&&xe.promptText&&k.current!==r.state.groupId){const{promptText:Re,groupId:Ie,groupName:Pe}=r.state;k.current=Ie,n(r.pathname,{replace:!0,state:{}}),g({promptText:Re,groupId:Ie,groupName:Pe}),setTimeout(()=>{k.current=null},1e3)}},[r.state,r.pathname,n,g]),d.useEffect(()=>{if(v&&i){const{promptText:xe,groupId:Re,groupName:Ie}=v;Gs(xe).length>0?(q({id:Re,name:Ie,productionPrompt:{promptText:xe}}),te(!0)):(H(xe),setTimeout(()=>{var ot;(ot=M.current)==null||ot.focus()},100)),w()}},[v,i,w]),d.useEffect(()=>{if(v){pe.current=l;return}pe.current&&pe.current!==l&&(H(""),X(!1),P([])),pe.current=l,D(null)},[v,l]),d.useEffect(()=>{J.current&&!o&&setTimeout(()=>{var xe;(xe=M.current)==null||xe.focus()},100),J.current=o},[o]),d.useEffect(()=>{const xe=()=>{setTimeout(()=>{var Re;(Re=M.current)==null||Re.focus()},100)};return window.addEventListener("focus-chat-input",xe),()=>{window.removeEventListener("focus-chat-input",xe)}},[]),d.useEffect(()=>{const xe=async Re=>{const Ie=Re,{text:Pe,prompt:ot,autoSubmit:Me}=Ie.detail;if(ot){if(D(Pe),H(ot+" "),Me){setTimeout(async()=>{const Pt=`${ot}
153
+
154
+ Context: "${Pe}"`,Ke=new Event("submit");await u(Ke,[],Pt),D(null),O(!1),H(""),t==null||t()},50);return}}else D(Pe),O(!0);setTimeout(()=>{var Pt;(Pt=M.current)==null||Pt.focus()},100)};return window.addEventListener("follow-up-question",xe),()=>{window.removeEventListener("follow-up-question",xe)}},[u,t]);const oe=()=>{var xe;o||(xe=S.current)==null||xe.click()},ae=xe=>{const Re=xe.target.files;if(Re){const Ie=Array.from(Re).filter(Pe=>!j.some(ot=>ot.name===Pe.name&&ot.size===Pe.size&&ot.lastModified===Pe.lastModified));Ie.length>0&&A(Pe=>[...Pe,...Ie])}xe.target&&(xe.target.value=""),setTimeout(()=>{var Ie;(Ie=M.current)==null||Ie.focus()},100)},G=async xe=>{if(o)return;const Re=xe.clipboardData;if(!Re)return;if(Re.files&&Re.files.length>0){xe.preventDefault();const Pe=Array.from(Re.files).filter(ot=>!j.some(Me=>Me.name===ot.name&&Me.size===ot.size&&Me.lastModified===ot.lastModified));Pe.length>0&&A(ot=>[...ot,...Pe]);return}const Ie=Re.getData("text");if(Ie&&c4(Ie)){xe.preventDefault();const Pe=d4(Ie);P(ot=>[...ot,Pe])}},V=xe=>{F&&(P(Re=>Re.map(Ie=>Ie.id===F?{...Ie,content:xe.content,filename:xe.filename,mimeType:xe.mimeType,description:xe.description,isConfigured:!0}:Ie)),N(null),y(!1))},ne=()=>{N(null),y(!1)},B=xe=>{N(xe),y(!0)},K=xe=>{P(Re=>Re.filter(Ie=>Ie.id!==xe))},Z=xe=>{A(Re=>Re.filter((Ie,Pe)=>Pe!==xe))},le=d.useMemo(()=>!o&&((z==null?void 0:z.trim())||j.length!==0||I.length!==0),[o,z,j,I]),de=async xe=>{if(xe.preventDefault(),le){let Re=z.trim();T&&L&&(Re=`Context: "${T}"
155
+
156
+ ${Re}`);const Ie=[];let Pe=l;const ot=new Set(m.map(Ke=>Ke.filename));for(let Ke=0;Ke<I.length;Ke++){const st=I[Ke];try{let yt,en,Rn;if(st.isConfigured&&st.filename&&st.mimeType)yt=st.filename,en=st.mimeType,Rn=st.description;else{en="text/plain";const we="txt";if(yt=`snippet.${we}`,ot.has(yt)){let ye=2;for(;ot.has(`snippet-${ye}.${we}`);)ye++;yt=`snippet-${ye}.${we}`}}ot.add(yt);const ee=new Blob([st.content],{type:en}),ie=new File([ee],yt,{type:en}),fe=await h(ie,Pe,Rn,!0);if(fe&&!("error"in fe))fe.sessionId&&fe.sessionId!==Pe&&(Pe=fe.sessionId,c(fe.sessionId)),Ie.push({uri:fe.uri,filename:yt,mimeType:en});else{const we=fe&&"error"in fe?fe.error:"An unknown upload error occurred.";throw new Error(we)}}catch(yt){p({title:"Failed to Save Pasted Text",error:Ut(yt)})}}const Me=Ie.map(Ke=>{const st=JSON.stringify({isArtifactReference:!0,uri:Ke.uri,filename:Ke.filename,mimeType:Ke.mimeType}),yt=new Blob([st],{type:"application/x-artifact-reference"});return new File([yt],Ke.filename,{type:"application/x-artifact-reference"})}),Pt=[...j,...Me];await u(xe,Pt,Re,Pe||null),A([]),P([]),H(""),D(null),O(!1),t==null||t()}},se=xe=>{if(o)return;const Re=xe.filter(Ie=>!j.some(Pe=>Pe.name===Ie.name&&Pe.size===Ie.size&&Pe.lastModified===Ie.lastModified));Re.length>0&&A(Ie=>[...Ie,...Re])},{isDragging:he,handleDragEnter:Ee,handleDragOver:Ae,handleDragLeave:pt,handleDrop:Lt}=kT({onFilesDropped:se,disabled:o}),jt=xe=>{const Re=xe.target.value;H(Re);const Ie=xe.target.selectionStart,Pe=Re.substring(0,Ie),ot=Pe[Pe.length-1],Me=Pe[Pe.length-2];ot==="/"&&(!Me||Me===" "||Me===`
157
+ `)?X(!0):U&&!Pe.includes("/")&&X(!1)},Rt=xe=>{var Pt;const Re=((Pt=M.current)==null?void 0:Pt.selectionStart)||0,Ie=z.substring(0,Re),Pe=z.substring(Re),ot=Ie.lastIndexOf("/"),Me=Ie.substring(0,ot)+xe+Pe;H(Me),X(!1),setTimeout(()=>{var Ke;(Ke=M.current)==null||Ke.focus()},100)},it=(xe,Re)=>{const Ie=g4(xe,Re);switch(xe){case"create-template":{n("/prompts/new?mode=ai-assisted",{state:{taskDescription:Ie}}),H(""),X(!1);break}}},Ot=xe=>{H(xe),te(!1),q(null),setTimeout(()=>{var Re;(Re=M.current)==null||Re.focus()},100)},Jt=d.useCallback(xe=>{const Re=z?`${z} ${xe}`:xe;H(Re),setTimeout(()=>{var Ie;(Ie=M.current)==null||Ie.focus()},100)},[z]),Ft=d.useCallback(xe=>{re(xe)},[]);return s.jsxs("div",{className:`bg-card rounded-lg border p-4 shadow-sm ${he?"border-dotted border-[var(--primary-wMain)] bg-[var(--accent-background)]":""}`,onDragEnter:Ee,onDragOver:Ae,onDragLeave:pt,onDrop:Lt,children:[Y&&s.jsx("div",{className:"mb-3",children:s.jsx(Vt,{variant:"error",message:Y,dismissible:!0,onDismiss:()=>re(null)})}),s.jsx("input",{type:"file",ref:S,className:"hidden",multiple:!0,onChange:ae,accept:"*/*",disabled:o}),j.length>0&&s.jsx("div",{className:"mb-2 flex flex-wrap gap-2",children:j.map((xe,Re)=>s.jsx(a4,{fileName:xe.name,onRemove:()=>Z(Re)},`${xe.name}-${xe.lastModified}-${Re}`))}),L&&T&&s.jsx("div",{className:"mb-2",children:s.jsxs("div",{className:"bg-muted/50 inline-flex max-w-full items-center gap-2 rounded-md border px-3 py-2 text-sm",children:[s.jsx(xg,{className:"text-muted-foreground h-4 w-4 flex-shrink-0"}),s.jsxs("span",{className:"text-muted-foreground truncate italic",children:['"',T,'"']}),s.jsx(me,{variant:"ghost",className:"h-5 w-5 shrink-0",onClick:()=>{D(null),O(!1)},tooltip:"Remove context",children:s.jsx(Xr,{})})]})}),I.length>0&&s.jsx("div",{className:"mb-2 flex max-h-32 flex-wrap gap-2 overflow-y-auto pt-2 pl-2",children:I.map((xe,Re)=>{let Ie="snippet.txt";if(!xe.isConfigured){const Pe=new Set(m.map(Me=>Me.filename));I.slice(0,Re).forEach(Me=>{Me.isConfigured&&Me.filename&&Pe.add(Me.filename)});let ot="snippet.txt";for(let Me=0;Me<Re;Me++)if(!I[Me].isConfigured&&(Pe.add(ot),Pe.has("snippet.txt"))){let Ke=2;for(;Pe.has(`snippet-${Ke}.txt`);)Ke++;ot=`snippet-${Ke}.txt`}if(Pe.has("snippet.txt")){let Me=2;for(;Pe.has(`snippet-${Me}.txt`);)Me++;Ie=`snippet-${Me}.txt`}}return s.jsx(l4,{id:xe.id,content:xe.content,onClick:()=>B(xe.id),onRemove:()=>K(xe.id),isConfigured:xe.isConfigured,filename:xe.filename,defaultFilename:Ie},xe.id)})}),(()=>{const xe=I.find(Me=>Me.id===F),Re=I.findIndex(Me=>Me.id===F),Ie=new Set(m.map(Me=>Me.filename));let Pe="snippet.txt";I.forEach((Me,Pt)=>{if(Me.id!==F)if(Me.isConfigured&&Me.filename)Ie.add(Me.filename);else if(Pt<Re||Re===-1){if(Ie.has(Pe)){let Ke=2;for(;Ie.has(`snippet-${Ke}.txt`);)Ke++;Pe=`snippet-${Ke}.txt`}if(Ie.add(Pe),Ie.has("snippet.txt")){let Ke=2;for(;Ie.has(`snippet-${Ke}.txt`);)Ke++;Pe=`snippet-${Ke}.txt`}else Pe="snippet.txt"}else{if(Ie.has(Pe)){let Ke=2;for(;Ie.has(`snippet-${Ke}.txt`);)Ke++;Pe=`snippet-${Ke}.txt`}if(Ie.add(Pe),Ie.has("snippet.txt")){let Ke=2;for(;Ie.has(`snippet-${Ke}.txt`);)Ke++;Pe=`snippet-${Ke}.txt`}else Pe="snippet.txt"}});let ot="snippet.txt";if(xe&&!xe.isConfigured&&Re>=0){const Me=new Set(m.map(Ke=>Ke.filename));I.slice(0,Re).forEach(Ke=>{Ke.isConfigured&&Ke.filename&&Me.add(Ke.filename)});let Pt="snippet.txt";for(let Ke=0;Ke<Re;Ke++)if(!I[Ke].isConfigured&&(Me.add(Pt),Me.has("snippet.txt"))){let yt=2;for(;Me.has(`snippet-${yt}.txt`);)yt++;Pt=`snippet-${yt}.txt`}if(Me.has("snippet.txt")){let Ke=2;for(;Me.has(`snippet-${Ke}.txt`);)Ke++;ot=`snippet-${Ke}.txt`}}return s.jsx(m4,{isOpen:R,content:(xe==null?void 0:xe.content)||"",onSaveMetadata:V,onCancel:ne,existingArtifacts:Array.from(Ie),initialFilename:xe==null?void 0:xe.filename,initialMimeType:xe==null?void 0:xe.mimeType,initialDescription:xe==null?void 0:xe.description,defaultFilename:ot})})(),s.jsx(i4,{isOpen:U,onClose:()=>{X(!1)},textAreaRef:M,onPromptSelect:Rt,messages:x,onReservedCommand:it}),W&&$&&s.jsx(Kf,{group:$,onSubmit:Ot,onClose:()=>{te(!1),q(null)}}),s.jsx(zb,{ref:M,value:z,onChange:jt,placeholder:ue?"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:G,disabled:ue,onKeyDown:xe=>{xe.key==="Enter"&&!xe.shiftKey&&le&&de(xe)}}),s.jsxs("div",{className:"m-2 flex items-center gap-2",children:[s.jsx(me,{variant:"ghost",onClick:oe,disabled:o,tooltip:"Attach file",children:s.jsx(wg,{className:"size-4"})}),s.jsx("div",{children:"Agent: "}),s.jsxs(Nr,{value:i,onValueChange:b,disabled:o||e.length===0,children:[s.jsx(Ar,{className:"w-[250px]",children:s.jsx(Tr,{placeholder:"Select an agent..."})}),s.jsx(Ir,{children:e.map(xe=>s.jsx(_t,{value:xe.name,children:xe.displayName||xe.name},xe.name))})]}),s.jsx("div",{className:"flex-1"}),E&&C.speechToText&&s.jsx(Yf,{disabled:o,onTranscriptionComplete:Jt,onError:Ft,onRecordingStateChange:ce}),o&&!a?s.jsxs(me,{"data-testid":"cancel",className:"ml-auto gap-1.5",onClick:f,variant:"outline",disabled:a,tooltip:"Cancel",children:[s.jsx(I1,{className:"size-4"}),"Stop"]}):s.jsx(me,{"data-testid":"sendMessage",variant:"ghost",className:"ml-auto gap-1.5",onClick:de,disabled:!le,tooltip:"Send message",children:s.jsx(bg,{className:"size-4"})})]})]})},v4=({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."]})})},w4=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},b4=({content:e,setRenderError:t})=>{d.useEffect(()=>{t(null)},[e,t]);const n=d.useMemo(()=>{try{return w4(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."})},y4=({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)})})},C4=({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 Xb(){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 S4=({content:e})=>{const{ref:t,handleKeyDown:n}=Xb();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(Vs,{className:"max-w-full break-words",children:e})})})},_4=({content:e,setRenderError:t})=>{const[n,r]=d.useState(""),o=d.useMemo(()=>qb.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 Jb(e){return typeof e>"u"||e===null}function k4(e){return typeof e=="object"&&e!==null}function j4(e){return Array.isArray(e)?e:Jb(e)?[]:[e]}function E4(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 N4(e,t){var n="",r;for(r=0;r<t;r+=1)n+=e;return n}function T4(e){return e===0&&Number.NEGATIVE_INFINITY===1/e}var A4=Jb,I4=k4,R4=j4,P4=N4,M4=T4,D4=E4,Sn={isNothing:A4,isObject:I4,toArray:R4,repeat:P4,isNegativeZero:M4,extend:D4};function Qb(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 Ga(e,t){Error.call(this),this.name="YAMLException",this.reason=e,this.mark=t,this.message=Qb(this,!1),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack||""}Ga.prototype=Object.create(Error.prototype);Ga.prototype.constructor=Ga;Ga.prototype.toString=function(t){return this.name+": "+Qb(this,t)};var $n=Ga;function mu(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 gu(e,t){return Sn.repeat(" ",t-e.length)+e}function O4(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=mu(e.buffer,r[i-c],o[i-c],e.position-(r[i]-r[i-c]),h),l=Sn.repeat(" ",t.indent)+gu((e.line-c+1).toString(),f)+" | "+u.str+`
341
+ `+l;for(u=mu(e.buffer,r[i],o[i],e.position,h),l+=Sn.repeat(" ",t.indent)+gu((e.line+1).toString(),f)+" | "+u.str+`
342
+ `,l+=Sn.repeat("-",t.indent+f+3+u.pos)+`^
343
+ `,c=1;c<=t.linesAfter&&!(i+c>=o.length);c++)u=mu(e.buffer,r[i+c],o[i+c],e.position-(r[i]-r[i+c]),h),l+=Sn.repeat(" ",t.indent)+gu((e.line+c+1).toString(),f)+" | "+u.str+`
344
+ `;return l.replace(/\n$/,"")}var L4=O4,F4=["kind","multi","resolve","construct","instanceOf","predicate","represent","representName","defaultStyle","styleAliases"],z4=["scalar","sequence","mapping"];function $4(e){var t={};return e!==null&&Object.keys(e).forEach(function(n){e[n].forEach(function(r){t[String(r)]=n})}),t}function U4(e,t){if(t=t||{},Object.keys(t).forEach(function(n){if(F4.indexOf(n)===-1)throw new $n('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=$4(t.styleAliases||null),z4.indexOf(this.kind)===-1)throw new $n('Unknown kind "'+this.kind+'" is specified for "'+e+'" YAML type.')}var An=U4;function hm(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 B4(){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 pd(e){return this.extend(e)}pd.prototype.extend=function(t){var n=[],r=[];if(t instanceof An)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 $n("Schema.extend argument should be a Type, [ Type ], or a schema definition ({ implicit: [...], explicit: [...] })");n.forEach(function(a){if(!(a instanceof An))throw new $n("Specified list of YAML types (or a single Type object) contains a non-Type object.");if(a.loadKind&&a.loadKind!=="scalar")throw new $n("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 $n("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 An))throw new $n("Specified list of YAML types (or a single Type object) contains a non-Type object.")});var o=Object.create(pd.prototype);return o.implicit=(this.implicit||[]).concat(n),o.explicit=(this.explicit||[]).concat(r),o.compiledImplicit=hm(o,"implicit"),o.compiledExplicit=hm(o,"explicit"),o.compiledTypeMap=B4(o.compiledImplicit,o.compiledExplicit),o};var ey=pd,ty=new An("tag:yaml.org,2002:str",{kind:"scalar",construct:function(e){return e!==null?e:""}}),ny=new An("tag:yaml.org,2002:seq",{kind:"sequence",construct:function(e){return e!==null?e:[]}}),ry=new An("tag:yaml.org,2002:map",{kind:"mapping",construct:function(e){return e!==null?e:{}}}),oy=new ey({explicit:[ty,ny,ry]});function V4(e){if(e===null)return!0;var t=e.length;return t===1&&e==="~"||t===4&&(e==="null"||e==="Null"||e==="NULL")}function W4(){return null}function H4(e){return e===null}var sy=new An("tag:yaml.org,2002:null",{kind:"scalar",resolve:V4,construct:W4,predicate:H4,represent:{canonical:function(){return"~"},lowercase:function(){return"null"},uppercase:function(){return"NULL"},camelcase:function(){return"Null"},empty:function(){return""}},defaultStyle:"lowercase"});function Z4(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 G4(e){return e==="true"||e==="True"||e==="TRUE"}function Y4(e){return Object.prototype.toString.call(e)==="[object Boolean]"}var ay=new An("tag:yaml.org,2002:bool",{kind:"scalar",resolve:Z4,construct:G4,predicate:Y4,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 K4(e){return 48<=e&&e<=57||65<=e&&e<=70||97<=e&&e<=102}function q4(e){return 48<=e&&e<=55}function X4(e){return 48<=e&&e<=57}function J4(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(!K4(e.charCodeAt(n)))return!1;r=!0}return r&&o!=="_"}if(o==="o"){for(n++;n<t;n++)if(o=e[n],o!=="_"){if(!q4(e.charCodeAt(n)))return!1;r=!0}return r&&o!=="_"}}if(o==="_")return!1;for(;n<t;n++)if(o=e[n],o!=="_"){if(!X4(e.charCodeAt(n)))return!1;r=!0}return!(!r||o==="_")}function Q4(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 e5(e){return Object.prototype.toString.call(e)==="[object Number]"&&e%1===0&&!Sn.isNegativeZero(e)}var iy=new An("tag:yaml.org,2002:int",{kind:"scalar",resolve:J4,construct:Q4,predicate:e5,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"]}}),t5=new RegExp("^(?:[-+]?(?:[0-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");function n5(e){return!(e===null||!t5.test(e)||e[e.length-1]==="_")}function r5(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 o5=/^[-+]?[0-9]+e/;function s5(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(Sn.isNegativeZero(e))return"-0.0";return n=e.toString(10),o5.test(n)?n.replace("e",".e"):n}function a5(e){return Object.prototype.toString.call(e)==="[object Number]"&&(e%1!==0||Sn.isNegativeZero(e))}var ly=new An("tag:yaml.org,2002:float",{kind:"scalar",resolve:n5,construct:r5,predicate:a5,represent:s5,defaultStyle:"lowercase"}),cy=oy.extend({implicit:[sy,ay,iy,ly]}),uy=cy,dy=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),fy=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 i5(e){return e===null?!1:dy.exec(e)!==null||fy.exec(e)!==null}function l5(e){var t,n,r,o,a,i,l,c=0,u=null,f,h,p;if(t=dy.exec(e),t===null&&(t=fy.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)),p=new Date(Date.UTC(n,r,o,a,i,l,c)),u&&p.setTime(p.getTime()-u),p}function c5(e){return e.toISOString()}var hy=new An("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:i5,construct:l5,instanceOf:Date,represent:c5});function u5(e){return e==="<<"||e===null}var py=new An("tag:yaml.org,2002:merge",{kind:"scalar",resolve:u5}),qf=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=
345
+ \r`;function d5(e){if(e===null)return!1;var t,n,r=0,o=e.length,a=qf;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 f5(e){var t,n,r=e.replace(/[\r\n=]/g,""),o=r.length,a=qf,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 h5(e){var t="",n=0,r,o,a=e.length,i=qf;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 p5(e){return Object.prototype.toString.call(e)==="[object Uint8Array]"}var my=new An("tag:yaml.org,2002:binary",{kind:"scalar",resolve:d5,construct:f5,predicate:p5,represent:h5}),m5=Object.prototype.hasOwnProperty,g5=Object.prototype.toString;function x5(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,g5.call(o)!=="[object Object]")return!1;for(a in o)if(m5.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 v5(e){return e!==null?e:[]}var gy=new An("tag:yaml.org,2002:omap",{kind:"sequence",resolve:x5,construct:v5}),w5=Object.prototype.toString;function b5(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],w5.call(r)!=="[object Object]"||(o=Object.keys(r),o.length!==1))return!1;a[t]=[o[0],r[o[0]]]}return!0}function y5(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 xy=new An("tag:yaml.org,2002:pairs",{kind:"sequence",resolve:b5,construct:y5}),C5=Object.prototype.hasOwnProperty;function S5(e){if(e===null)return!0;var t,n=e;for(t in n)if(C5.call(n,t)&&n[t]!==null)return!1;return!0}function _5(e){return e!==null?e:{}}var vy=new An("tag:yaml.org,2002:set",{kind:"mapping",resolve:S5,construct:_5}),Xf=uy.extend({implicit:[hy,py],explicit:[my,gy,xy,vy]}),Oo=Object.prototype.hasOwnProperty,Al=1,wy=2,by=3,Il=4,xu=1,k5=2,pm=3,j5=/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,E5=/[\x85\u2028\u2029]/,N5=/[,\[\]\{\}]/,yy=/^(?:!|!!|![a-z\-]+!)$/i,Cy=/^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i;function mm(e){return Object.prototype.toString.call(e)}function qr(e){return e===10||e===13}function Jo(e){return e===9||e===32}function Xn(e){return e===9||e===32||e===10||e===13}function Ps(e){return e===44||e===91||e===93||e===123||e===125}function T5(e){var t;return 48<=e&&e<=57?e-48:(t=e|32,97<=t&&t<=102?t-97+10:-1)}function A5(e){return e===120?2:e===117?4:e===85?8:0}function I5(e){return 48<=e&&e<=57?e-48:-1}function gm(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 R5(e){return e<=65535?String.fromCharCode(e):String.fromCharCode((e-65536>>10)+55296,(e-65536&1023)+56320)}function Sy(e,t,n){t==="__proto__"?Object.defineProperty(e,t,{configurable:!0,enumerable:!0,writable:!0,value:n}):e[t]=n}var _y=new Array(256),ky=new Array(256);for(var js=0;js<256;js++)_y[js]=gm(js)?1:0,ky[js]=gm(js);function P5(e,t){this.input=e,this.filename=t.filename||null,this.schema=t.schema||Xf,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 jy(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=L4(n),new $n(t,n)}function Qe(e,t){throw jy(e,t)}function Rl(e,t){e.onWarning&&e.onWarning.call(null,jy(e,t))}var xm={YAML:function(t,n,r){var o,a,i;t.version!==null&&Qe(t,"duplication of %YAML directive"),r.length!==1&&Qe(t,"YAML directive accepts exactly one argument"),o=/^([0-9]+)\.([0-9]+)$/.exec(r[0]),o===null&&Qe(t,"ill-formed argument of the YAML directive"),a=parseInt(o[1],10),i=parseInt(o[2],10),a!==1&&Qe(t,"unacceptable YAML version of the document"),t.version=r[0],t.checkLineBreaks=i<2,i!==1&&i!==2&&Rl(t,"unsupported YAML version of the document")},TAG:function(t,n,r){var o,a;r.length!==2&&Qe(t,"TAG directive accepts exactly two arguments"),o=r[0],a=r[1],yy.test(o)||Qe(t,"ill-formed tag handle (first argument) of the TAG directive"),Oo.call(t.tagMap,o)&&Qe(t,'there is a previously declared suffix for "'+o+'" tag handle'),Cy.test(a)||Qe(t,"ill-formed tag prefix (second argument) of the TAG directive");try{a=decodeURIComponent(a)}catch{Qe(t,"tag prefix is malformed: "+a)}t.tagMap[o]=a}};function Ao(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||Qe(e,"expected valid JSON character");else j5.test(l)&&Qe(e,"the stream contains non-printable characters");e.result+=l}}function vm(e,t,n,r){var o,a,i,l;for(Sn.isObject(n)||Qe(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],Oo.call(t,a)||(Sy(t,a,n[a]),r[a]=!0)}function Ms(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])&&Qe(e,"nested arrays are not supported inside keys"),typeof o=="object"&&mm(o[u])==="[object Object]"&&(o[u]="[object Object]");if(typeof o=="object"&&mm(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)vm(e,t,a[u],n);else vm(e,t,a,n);else!e.json&&!Oo.call(n,o)&&Oo.call(t,o)&&(e.line=i||e.line,e.lineStart=l||e.lineStart,e.position=c||e.position,Qe(e,"duplicated mapping key")),Sy(t,o,a),delete n[o];return t}function Jf(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++):Qe(e,"a line break is expected"),e.line+=1,e.lineStart=e.position,e.firstTabInLine=-1}function vn(e,t,n){for(var r=0,o=e.input.charCodeAt(e.position);o!==0;){for(;Jo(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(qr(o))for(Jf(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&&Rl(e,"deficient indentation"),r}function jc(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||Xn(n)))}function Qf(e,t){t===1?e.result+=" ":t>1&&(e.result+=Sn.repeat(`
347
+ `,t-1))}function M5(e,t,n){var r,o,a,i,l,c,u,f,h=e.kind,p=e.result,m;if(m=e.input.charCodeAt(e.position),Xn(m)||Ps(m)||m===35||m===38||m===42||m===33||m===124||m===62||m===39||m===34||m===37||m===64||m===96||(m===63||m===45)&&(o=e.input.charCodeAt(e.position+1),Xn(o)||n&&Ps(o)))return!1;for(e.kind="scalar",e.result="",a=i=e.position,l=!1;m!==0;){if(m===58){if(o=e.input.charCodeAt(e.position+1),Xn(o)||n&&Ps(o))break}else if(m===35){if(r=e.input.charCodeAt(e.position-1),Xn(r))break}else{if(e.position===e.lineStart&&jc(e)||n&&Ps(m))break;if(qr(m))if(c=e.line,u=e.lineStart,f=e.lineIndent,vn(e,!1,-1),e.lineIndent>=t){l=!0,m=e.input.charCodeAt(e.position);continue}else{e.position=i,e.line=c,e.lineStart=u,e.lineIndent=f;break}}l&&(Ao(e,a,i,!1),Qf(e,e.line-c),a=i=e.position,l=!1),Jo(m)||(i=e.position+1),m=e.input.charCodeAt(++e.position)}return Ao(e,a,i,!1),e.result?!0:(e.kind=h,e.result=p,!1)}function D5(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(Ao(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 qr(n)?(Ao(e,r,o,!0),Qf(e,vn(e,!1,t)),r=o=e.position):e.position===e.lineStart&&jc(e)?Qe(e,"unexpected end of the document within a single quoted scalar"):(e.position++,o=e.position);Qe(e,"unexpected end of the stream within a single quoted scalar")}function O5(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 Ao(e,n,e.position,!0),e.position++,!0;if(l===92){if(Ao(e,n,e.position,!0),l=e.input.charCodeAt(++e.position),qr(l))vn(e,!1,t);else if(l<256&&_y[l])e.result+=ky[l],e.position++;else if((i=A5(l))>0){for(o=i,a=0;o>0;o--)l=e.input.charCodeAt(++e.position),(i=T5(l))>=0?a=(a<<4)+i:Qe(e,"expected hexadecimal character");e.result+=R5(a),e.position++}else Qe(e,"unknown escape sequence");n=r=e.position}else qr(l)?(Ao(e,n,r,!0),Qf(e,vn(e,!1,t)),n=r=e.position):e.position===e.lineStart&&jc(e)?Qe(e,"unexpected end of the document within a double quoted scalar"):(e.position++,r=e.position)}Qe(e,"unexpected end of the stream within a double quoted scalar")}function L5(e,t){var n=!0,r,o,a,i=e.tag,l,c=e.anchor,u,f,h,p,m,x=Object.create(null),g,v,w,b;if(b=e.input.charCodeAt(e.position),b===91)f=93,m=!1,l=[];else if(b===123)f=125,m=!0,l={};else return!1;for(e.anchor!==null&&(e.anchorMap[e.anchor]=l),b=e.input.charCodeAt(++e.position);b!==0;){if(vn(e,!0,t),b=e.input.charCodeAt(e.position),b===f)return e.position++,e.tag=i,e.anchor=c,e.kind=m?"mapping":"sequence",e.result=l,!0;n?b===44&&Qe(e,"expected the node content, but found ','"):Qe(e,"missed comma between flow collection entries"),v=g=w=null,h=p=!1,b===63&&(u=e.input.charCodeAt(e.position+1),Xn(u)&&(h=p=!0,e.position++,vn(e,!0,t))),r=e.line,o=e.lineStart,a=e.position,ea(e,t,Al,!1,!0),v=e.tag,g=e.result,vn(e,!0,t),b=e.input.charCodeAt(e.position),(p||e.line===r)&&b===58&&(h=!0,b=e.input.charCodeAt(++e.position),vn(e,!0,t),ea(e,t,Al,!1,!0),w=e.result),m?Ms(e,l,x,v,g,w,r,o,a):h?l.push(Ms(e,null,x,v,g,w,r,o,a)):l.push(g),vn(e,!0,t),b=e.input.charCodeAt(e.position),b===44?(n=!0,b=e.input.charCodeAt(++e.position)):n=!1}Qe(e,"unexpected end of the stream within a flow collection")}function F5(e,t){var n,r,o=xu,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)xu===o?o=h===43?pm:k5:Qe(e,"repeat of a chomping mode identifier");else if((f=I5(h))>=0)f===0?Qe(e,"bad explicit indentation width of a block scalar; it cannot be less than one"):i?Qe(e,"repeat of an indentation width identifier"):(l=t+f-1,i=!0);else break;if(Jo(h)){do h=e.input.charCodeAt(++e.position);while(Jo(h));if(h===35)do h=e.input.charCodeAt(++e.position);while(!qr(h)&&h!==0)}for(;h!==0;){for(Jf(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),qr(h)){c++;continue}if(e.lineIndent<l){o===pm?e.result+=Sn.repeat(`
348
+ `,a?1+c:c):o===xu&&a&&(e.result+=`
349
+ `);break}for(r?Jo(h)?(u=!0,e.result+=Sn.repeat(`
350
+ `,a?1+c:c)):u?(u=!1,e.result+=Sn.repeat(`
351
+ `,c+1)):c===0?a&&(e.result+=" "):e.result+=Sn.repeat(`
352
+ `,c):e.result+=Sn.repeat(`
353
+ `,a?1+c:c),a=!0,i=!0,c=0,n=e.position;!qr(h)&&h!==0;)h=e.input.charCodeAt(++e.position);Ao(e,n,e.position,!1)}return!0}function wm(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,Qe(e,"tab characters must not be used in indentation")),!(c!==45||(i=e.input.charCodeAt(e.position+1),!Xn(i))));){if(l=!0,e.position++,vn(e,!0,-1)&&e.lineIndent<=t){a.push(null),c=e.input.charCodeAt(e.position);continue}if(n=e.line,ea(e,t,by,!1,!0),a.push(e.result),vn(e,!0,-1),c=e.input.charCodeAt(e.position),(e.line===n||e.lineIndent>t)&&c!==0)Qe(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 z5(e,t,n){var r,o,a,i,l,c,u=e.tag,f=e.anchor,h={},p=Object.create(null),m=null,x=null,g=null,v=!1,w=!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(!v&&e.firstTabInLine!==-1&&(e.position=e.firstTabInLine,Qe(e,"tab characters must not be used in indentation")),r=e.input.charCodeAt(e.position+1),a=e.line,(b===63||b===58)&&Xn(r))b===63?(v&&(Ms(e,h,p,m,x,null,i,l,c),m=x=g=null),w=!0,v=!0,o=!0):v?(v=!1,o=!0):Qe(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,!ea(e,n,wy,!1,!0))break;if(e.line===a){for(b=e.input.charCodeAt(e.position);Jo(b);)b=e.input.charCodeAt(++e.position);if(b===58)b=e.input.charCodeAt(++e.position),Xn(b)||Qe(e,"a whitespace character is expected after the key-value separator within a block mapping"),v&&(Ms(e,h,p,m,x,null,i,l,c),m=x=g=null),w=!0,v=!1,o=!1,m=e.tag,x=e.result;else if(w)Qe(e,"can not read an implicit mapping pair; a colon is missed");else return e.tag=u,e.anchor=f,!0}else if(w)Qe(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)&&(v&&(i=e.line,l=e.lineStart,c=e.position),ea(e,t,Il,!0,o)&&(v?x=e.result:g=e.result),v||(Ms(e,h,p,m,x,g,i,l,c),m=x=g=null),vn(e,!0,-1),b=e.input.charCodeAt(e.position)),(e.line===a||e.lineIndent>t)&&b!==0)Qe(e,"bad indentation of a mapping entry");else if(e.lineIndent<t)break}return v&&Ms(e,h,p,m,x,null,i,l,c),w&&(e.tag=u,e.anchor=f,e.kind="mapping",e.result=h),w}function $5(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&&Qe(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)):Qe(e,"unexpected end of the stream within a verbatim tag")}else{for(;i!==0&&!Xn(i);)i===33&&(r?Qe(e,"tag suffix cannot contain exclamation marks"):(o=e.input.slice(t-1,e.position+1),yy.test(o)||Qe(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),N5.test(a)&&Qe(e,"tag suffix cannot contain flow indicator characters")}a&&!Cy.test(a)&&Qe(e,"tag name cannot contain such characters: "+a);try{a=decodeURIComponent(a)}catch{Qe(e,"tag name is malformed: "+a)}return n?e.tag=a:Oo.call(e.tagMap,o)?e.tag=e.tagMap[o]+a:o==="!"?e.tag="!"+a:o==="!!"?e.tag="tag:yaml.org,2002:"+a:Qe(e,'undeclared tag handle "'+o+'"'),!0}function U5(e){var t,n;if(n=e.input.charCodeAt(e.position),n!==38)return!1;for(e.anchor!==null&&Qe(e,"duplication of an anchor property"),n=e.input.charCodeAt(++e.position),t=e.position;n!==0&&!Xn(n)&&!Ps(n);)n=e.input.charCodeAt(++e.position);return e.position===t&&Qe(e,"name of an anchor node must contain at least one character"),e.anchor=e.input.slice(t,e.position),!0}function B5(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&&!Xn(r)&&!Ps(r);)r=e.input.charCodeAt(++e.position);return e.position===t&&Qe(e,"name of an alias node must contain at least one character"),n=e.input.slice(t,e.position),Oo.call(e.anchorMap,n)||Qe(e,'unidentified alias "'+n+'"'),e.result=e.anchorMap[n],vn(e,!0,-1),!0}function ea(e,t,n,r,o){var a,i,l,c=1,u=!1,f=!1,h,p,m,x,g,v;if(e.listener!==null&&e.listener("open",e),e.tag=null,e.anchor=null,e.kind=null,e.result=null,a=i=l=Il===n||by===n,r&&vn(e,!0,-1)&&(u=!0,e.lineIndent>t?c=1:e.lineIndent===t?c=0:e.lineIndent<t&&(c=-1)),c===1)for(;$5(e)||U5(e);)vn(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||Il===n)&&(Al===n||wy===n?g=t:g=t+1,v=e.position-e.lineStart,c===1?l&&(wm(e,v)||z5(e,v,g))||L5(e,g)?f=!0:(i&&F5(e,g)||D5(e,g)||O5(e,g)?f=!0:B5(e)?(f=!0,(e.tag!==null||e.anchor!==null)&&Qe(e,"alias node should not have any properties")):M5(e,g,Al===n)&&(f=!0,e.tag===null&&(e.tag="?")),e.anchor!==null&&(e.anchorMap[e.anchor]=e.result)):c===0&&(f=l&&wm(e,v))),e.tag===null)e.anchor!==null&&(e.anchorMap[e.anchor]=e.result);else if(e.tag==="?"){for(e.result!==null&&e.kind!=="scalar"&&Qe(e,'unacceptable node kind for !<?> tag; it should be "scalar", not "'+e.kind+'"'),h=0,p=e.implicitTypes.length;h<p;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(Oo.call(e.typeMap[e.kind||"fallback"],e.tag))x=e.typeMap[e.kind||"fallback"][e.tag];else for(x=null,m=e.typeMap.multi[e.kind||"fallback"],h=0,p=m.length;h<p;h+=1)if(e.tag.slice(0,m[h].tag.length)===m[h].tag){x=m[h];break}x||Qe(e,"unknown tag !<"+e.tag+">"),e.result!==null&&x.kind!==e.kind&&Qe(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)):Qe(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 V5(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&&(vn(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&&!Xn(i);)i=e.input.charCodeAt(++e.position);for(r=e.input.slice(n,e.position),o=[],r.length<1&&Qe(e,"directive name must not be less than one character in length");i!==0;){for(;Jo(i);)i=e.input.charCodeAt(++e.position);if(i===35){do i=e.input.charCodeAt(++e.position);while(i!==0&&!qr(i));break}if(qr(i))break;for(n=e.position;i!==0&&!Xn(i);)i=e.input.charCodeAt(++e.position);o.push(e.input.slice(n,e.position))}i!==0&&Jf(e),Oo.call(xm,r)?xm[r](e,r,o):Rl(e,'unknown document directive "'+r+'"')}if(vn(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,vn(e,!0,-1)):a&&Qe(e,"directives end mark is expected"),ea(e,e.lineIndent-1,Il,!1,!0),vn(e,!0,-1),e.checkLineBreaks&&E5.test(e.input.slice(t,e.position))&&Rl(e,"non-ASCII line breaks are interpreted as content"),e.documents.push(e.result),e.position===e.lineStart&&jc(e)){e.input.charCodeAt(e.position)===46&&(e.position+=3,vn(e,!0,-1));return}if(e.position<e.length-1)Qe(e,"end of the stream or a document separator is expected");else return}function Ey(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 P5(e,t),r=e.indexOf("\0");for(r!==-1&&(n.position=r,Qe(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;)V5(n);return n.documents}function W5(e,t,n){t!==null&&typeof t=="object"&&typeof n>"u"&&(n=t,t=null);var r=Ey(e,n);if(typeof t!="function")return r;for(var o=0,a=r.length;o<a;o+=1)t(r[o])}function H5(e,t){var n=Ey(e,t);if(n.length!==0){if(n.length===1)return n[0];throw new $n("expected a single document in the stream, but found more")}}var Z5=W5,G5=H5,Ny={loadAll:Z5,load:G5},Ty=Object.prototype.toString,Ay=Object.prototype.hasOwnProperty,eh=65279,Y5=9,Ya=10,K5=13,q5=32,X5=33,J5=34,md=35,Q5=37,e3=38,t3=39,n3=42,Iy=44,r3=45,Pl=58,o3=61,s3=62,a3=63,i3=64,Ry=91,Py=93,l3=96,My=123,c3=124,Dy=125,On={};On[0]="\\0";On[7]="\\a";On[8]="\\b";On[9]="\\t";On[10]="\\n";On[11]="\\v";On[12]="\\f";On[13]="\\r";On[27]="\\e";On[34]='\\"';On[92]="\\\\";On[133]="\\N";On[160]="\\_";On[8232]="\\L";On[8233]="\\P";var u3=["y","Y","yes","Yes","YES","on","On","ON","n","N","no","No","NO","off","Off","OFF"],d3=/^[-+]?[0-9_]+(?::[0-9_]+)+(?:\.[0-9_]*)?$/;function f3(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&&Ay.call(c.styleAliases,l)&&(l=c.styleAliases[l]),n[i]=l;return n}function h3(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 $n("code point within a string may not be greater than 0xFFFFFFFF");return"\\"+n+Sn.repeat("0",r-t.length)+t}var p3=1,Ka=2;function m3(e){this.schema=e.schema||Xf,this.indent=Math.max(1,e.indent||2),this.noArrayIndent=e.noArrayIndent||!1,this.skipInvalid=e.skipInvalid||!1,this.flowLevel=Sn.isNothing(e.flowLevel)?-1:e.flowLevel,this.styleMap=f3(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==='"'?Ka:p3,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 bm(e,t){for(var n=Sn.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 gd(e,t){return`
357
+ `+Sn.repeat(" ",e.indent*t)}function g3(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 Ml(e){return e===q5||e===Y5}function qa(e){return 32<=e&&e<=126||161<=e&&e<=55295&&e!==8232&&e!==8233||57344<=e&&e<=65533&&e!==eh||65536<=e&&e<=1114111}function ym(e){return qa(e)&&e!==eh&&e!==K5&&e!==Ya}function Cm(e,t,n){var r=ym(e),o=r&&!Ml(e);return(n?r:r&&e!==Iy&&e!==Ry&&e!==Py&&e!==My&&e!==Dy)&&e!==md&&!(t===Pl&&!o)||ym(t)&&!Ml(t)&&e===md||t===Pl&&o}function x3(e){return qa(e)&&e!==eh&&!Ml(e)&&e!==r3&&e!==a3&&e!==Pl&&e!==Iy&&e!==Ry&&e!==Py&&e!==My&&e!==Dy&&e!==md&&e!==e3&&e!==n3&&e!==X5&&e!==c3&&e!==o3&&e!==s3&&e!==t3&&e!==J5&&e!==Q5&&e!==i3&&e!==l3}function v3(e){return!Ml(e)&&e!==Pl}function Ia(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 Oy(e){var t=/^\n* /;return t.test(e)}var Ly=1,xd=2,Fy=3,zy=4,Is=5;function w3(e,t,n,r,o,a,i,l){var c,u=0,f=null,h=!1,p=!1,m=r!==-1,x=-1,g=x3(Ia(e,0))&&v3(Ia(e,e.length-1));if(t||i)for(c=0;c<e.length;u>=65536?c+=2:c++){if(u=Ia(e,c),!qa(u))return Is;g=g&&Cm(u,f,l),f=u}else{for(c=0;c<e.length;u>=65536?c+=2:c++){if(u=Ia(e,c),u===Ya)h=!0,m&&(p=p||c-x-1>r&&e[x+1]!==" ",x=c);else if(!qa(u))return Is;g=g&&Cm(u,f,l),f=u}p=p||m&&c-x-1>r&&e[x+1]!==" "}return!h&&!p?g&&!i&&!o(e)?Ly:a===Ka?Is:xd:n>9&&Oy(e)?Is:i?a===Ka?Is:xd:p?zy:Fy}function b3(e,t,n,r,o){e.dump=function(){if(t.length===0)return e.quotingType===Ka?'""':"''";if(!e.noCompatMode&&(u3.indexOf(t)!==-1||d3.test(t)))return e.quotingType===Ka?'"'+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 g3(e,u)}switch(w3(t,l,e.indent,i,c,e.quotingType,e.forceQuotes&&!r,o)){case Ly:return t;case xd:return"'"+t.replace(/'/g,"''")+"'";case Fy:return"|"+Sm(t,e.indent)+_m(bm(t,a));case zy:return">"+Sm(t,e.indent)+_m(bm(y3(t,i),a));case Is:return'"'+C3(t)+'"';default:throw new $n("impossible error: invalid scalar style")}}()}function Sm(e,t){var n=Oy(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 _m(e){return e[e.length-1]===`
362
+ `?e.slice(0,-1):e}function y3(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,km(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
+ `:"")+km(c,t),o=a}return r}function km(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 C3(e){for(var t="",n=0,r,o=0;o<e.length;n>=65536?o+=2:o++)n=Ia(e,o),r=On[n],!r&&qa(n)?(t+=e[o],n>=65536&&(t+=e[o+1])):t+=r||h3(n);return t}function S3(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)),(go(e,t,l,!1,!1)||typeof l>"u"&&go(e,t,null,!1,!1))&&(r!==""&&(r+=","+(e.condenseFlow?"":" ")),r+=e.dump);e.tag=o,e.dump="["+r+"]"}function jm(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)),(go(e,t+1,c,!0,!0,!1,!0)||typeof c>"u"&&go(e,t+1,null,!0,!0,!1,!0))&&((!r||o!=="")&&(o+=gd(e,t)),e.dump&&Ya===e.dump.charCodeAt(0)?o+="-":o+="- ",o+=e.dump);e.tag=a,e.dump=o||"[]"}function _3(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)),go(e,t,c,!1,!1)&&(e.dump.length>1024&&(f+="? "),f+=e.dump+(e.condenseFlow?'"':"")+":"+(e.condenseFlow?"":" "),go(e,t,u,!1,!1)&&(f+=e.dump,r+=f));e.tag=o,e.dump="{"+r+"}"}function k3(e,t,n,r){var o="",a=e.tag,i=Object.keys(n),l,c,u,f,h,p;if(e.sortKeys===!0)i.sort();else if(typeof e.sortKeys=="function")i.sort(e.sortKeys);else if(e.sortKeys)throw new $n("sortKeys must be a boolean or a function");for(l=0,c=i.length;l<c;l+=1)p="",(!r||o!=="")&&(p+=gd(e,t)),u=i[l],f=n[u],e.replacer&&(f=e.replacer.call(n,u,f)),go(e,t+1,u,!0,!0,!0)&&(h=e.tag!==null&&e.tag!=="?"||e.dump&&e.dump.length>1024,h&&(e.dump&&Ya===e.dump.charCodeAt(0)?p+="?":p+="? "),p+=e.dump,h&&(p+=gd(e,t)),go(e,t+1,f,!0,h)&&(e.dump&&Ya===e.dump.charCodeAt(0)?p+=":":p+=": ",p+=e.dump,o+=p));e.tag=a,e.dump=o||"{}"}function Em(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,Ty.call(l.represent)==="[object Function]")r=l.represent(t,c);else if(Ay.call(l.represent,c))r=l.represent[c](t,c);else throw new $n("!<"+l.tag+'> tag resolver accepts not "'+c+'" style');e.dump=r}return!0}return!1}function go(e,t,n,r,o,a,i){e.tag=null,e.dump=n,Em(e,n,!1)||Em(e,n,!0);var l=Ty.call(e.dump),c=r,u;r&&(r=e.flowLevel<0||e.flowLevel>t);var f=l==="[object Object]"||l==="[object Array]",h,p;if(f&&(h=e.duplicates.indexOf(n),p=h!==-1),(e.tag!==null&&e.tag!=="?"||p||e.indent!==2&&t>0)&&(o=!1),p&&e.usedDuplicates[h])e.dump="*ref_"+h;else{if(f&&p&&!e.usedDuplicates[h]&&(e.usedDuplicates[h]=!0),l==="[object Object]")r&&Object.keys(e.dump).length!==0?(k3(e,t,e.dump,o),p&&(e.dump="&ref_"+h+e.dump)):(_3(e,t,e.dump),p&&(e.dump="&ref_"+h+" "+e.dump));else if(l==="[object Array]")r&&e.dump.length!==0?(e.noArrayIndent&&!i&&t>0?jm(e,t-1,e.dump,o):jm(e,t,e.dump,o),p&&(e.dump="&ref_"+h+e.dump)):(S3(e,t,e.dump),p&&(e.dump="&ref_"+h+" "+e.dump));else if(l==="[object String]")e.tag!=="?"&&b3(e,e.dump,t,a,c);else{if(l==="[object Undefined]")return!1;if(e.skipInvalid)return!1;throw new $n("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 j3(e,t){var n=[],r=[],o,a;for(vd(e,n,r),o=0,a=r.length;o<a;o+=1)t.duplicates.push(n[r[o]]);t.usedDuplicates=new Array(a)}function vd(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)vd(e[o],t,n);else for(r=Object.keys(e),o=0,a=r.length;o<a;o+=1)vd(e[r[o]],t,n)}function E3(e,t){t=t||{};var n=new m3(t);n.noRefs||j3(e,n);var r=e;return n.replacer&&(r=n.replacer.call({"":r},"",r)),go(n,0,r,!0,!0)?n.dump+`
369
+ `:""}var N3=E3,T3={dump:N3};function th(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 A3=An,I3=ey,R3=oy,P3=cy,M3=uy,D3=Xf,O3=Ny.load,L3=Ny.loadAll,F3=T3.dump,z3=$n,$3={binary:my,float:ly,map:ry,null:sy,pairs:xy,set:vy,timestamp:hy,bool:ay,int:iy,merge:py,omap:gy,seq:ny,str:ty},U3=th("safeLoad","load"),B3=th("safeLoadAll","loadAll"),V3=th("safeDump","dump"),W3={Type:A3,Schema:I3,FAILSAFE_SCHEMA:R3,JSON_SCHEMA:P3,CORE_SCHEMA:M3,DEFAULT_SCHEMA:D3,load:O3,loadAll:L3,dump:F3,YAMLException:z3,types:$3,safeLoad:U3,safeLoadAll:B3,safeDump:V3};const H3=({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=W3.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(me,{onClick:()=>o(!r),title:r?"Show Structured View":"Show Raw Text",children:r?s.jsxs(s.Fragment,{children:[s.jsx(yg,{})," Structured"]}):s.jsxs(s.Fragment,{children:[s.jsx(Md,{})," 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($y,{content:a,setRenderError:n}):s.jsx(Td,{data:i,maxDepth:4,className:"min-h-16 border-none p-2"})})})]})},$y=({content:e,className:t=""})=>{const{ref:n,handleKeyDown:r}=Xb();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})})},nh=({content:e,rendererType:t,mime_type:n,setRenderError:r})=>{switch(t){case"csv":return s.jsx(b4,{content:e,setRenderError:r});case"mermaid":return s.jsx(_4,{content:e,setRenderError:r});case"html":return s.jsx(y4,{content:e,setRenderError:r});case"json":case"yaml":return s.jsx(H3,{content:e,rendererType:t,setRenderError:r});case"image":return s.jsx(C4,{content:e,mime_type:n,setRenderError:r});case"markdown":return s.jsx(S4,{content:e,setRenderError:r});case"audio":return s.jsx(v4,{content:e,mime_type:n,setRenderError:r});default:return s.jsx($y,{content:e,setRenderError:r})}},rh=e=>{const t=e.split(".");return t.length>1?t[t.length-1].toUpperCase():"FILE"},Cr=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"}},Z3=(e,t)=>{const n={className:"text-secondary-foreground/60"};if(e){if(e.startsWith("image/"))return s.jsx(Iu,{...n});if(e.startsWith("video/"))return s.jsx(gh,{...n});if(e.startsWith("audio/"))return s.jsx(Au,{...n});if(e==="application/pdf")return s.jsx(gr,{...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(xh,{...n});if(e.includes("word")||e.includes("document"))return s.jsx(gr,{...n});if(e.includes("excel")||e.includes("spreadsheet"))return s.jsx(Tu,{...n});if(e.includes("powerpoint")||e.includes("presentation"))return s.jsx(vh,{...n});if(e==="application/x-executable"||e==="application/x-msdownload")return s.jsx(Oa,{...n})}switch(t?rh(t).toLowerCase():""){case"jpg":case"jpeg":case"png":case"gif":case"bmp":case"webp":case"svg":case"ico":return s.jsx(Iu,{...n});case"mp4":case"avi":case"mov":case"wmv":case"flv":case"webm":case"mkv":return s.jsx(gh,{...n});case"mp3":case"wav":case"flac":case"aac":case"ogg":case"m4a":return s.jsx(Au,{...n});case"pdf":case"doc":case"docx":return s.jsx(gr,{...n});case"xls":case"xlsx":case"csv":return s.jsx(Tu,{...n});case"ppt":case"pptx":return s.jsx(vh,{...n});case"zip":case"rar":case"7z":case"tar":case"gz":return s.jsx(xh,{...n});case"exe":case"msi":case"dmg":case"pkg":case"deb":case"rpm":return s.jsx(Oa,{...n});case"ttf":case"otf":case"woff":case"woff2":return s.jsx(Cg,{...n});case"htm":case"html":return s.jsx(pg,{...n});default:return null}},G3=(e,t)=>{if(e){if(e.startsWith("text/html")||e==="application/xhtml+xml")return Cr("html");if(e==="application/json"||e==="text/json")return Cr("json");if(e==="application/yaml"||e==="text/yaml"||e==="application/x-yaml"||e==="text/x-yaml")return Cr("yaml");if(e.startsWith("text/"))return Cr("text");if(e.startsWith("text/markdown")||e==="application/markdown")return Cr("markdown")}switch(t?rh(t).toLowerCase():""){case"html":case"htm":return Cr("html");case"json":return Cr("json");case"yaml":case"yml":return Cr("yaml");case"md":case"markdown":return Cr("markdown");case"txt":return Cr("text");default:return Cr("default")}},Y3=({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=rh(e),o=G3(t,e),a=Z3(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(Nu,{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})]})})},Nm=({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]})}),K3=({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:p="chat",isDeleted:m=!1,version:x,source:g})=>{const[v,w]=d.useState(h),[b,C]=d.useState(()=>document.documentElement.classList.contains("dark"));if(d.useEffect(()=>{if(h)w(h);else{const T=setTimeout(()=>{w(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(Nm,{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(Nm,{message:"Invalid artifact status"});const E=(()=>{if(m)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,D=100)=>{if(!T||typeof T!="string")return"";const L=T.replace(/\s+/g," ").trim();if(L.length<=D)return L;const O=L.substring(0,D),M=O.lastIndexOf(" ");return M>D*.7?O.substring(0,M)+"...":O+"..."})(t),A=t&&t.trim(),I=()=>{if(o==="completed"&&(c!=null&&c.onPreview))try{c.onPreview()}catch(T){console.error("Preview failed:",T)}},P=b?"var(--color-background-wMain)":"var(--color-background-w10)",F=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)",R=o==="completed"&&(c==null?void 0:c.onPreview)&&!m,y=p==="chat"&&!m;return s.jsxs("div",{className:`w-full ${R?"cursor-pointer":""} ${p==="list"?"border-b":""} ${m?"opacity-60":""} transition-shadow duration-200 ease-in-out`,style:{backgroundColor:P,boxShadow:y?F:void 0,borderRadius:p==="list"?void 0:"4px"},onMouseEnter:T=>{R&&(T.currentTarget.style.boxShadow=N)},onMouseLeave:T=>{R&&(T.currentTarget.style.boxShadow=F)},onClick:m?void 0:I,children:[s.jsxs("div",{className:"flex min-h-[60px] items-center gap-3 p-3",children:[s.jsx(Y3,{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(Or,{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&&p==="chat"&&s.jsxs("span",{className:"ml-1.5",children:["(v",x,")"]})]}):s.jsxs(s.Fragment,{children:[o==="in-progress"&&s.jsx(Qr,{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(Qr,{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)&&!m&&s.jsx(me,{variant:"ghost",size:"icon",onClick:T=>{var D;T.stopPropagation();try{(D=c.onInfo)==null||D.call(c)}catch(L){console.error("Info failed:",L)}},tooltip:"Info",children:s.jsx(Qa,{className:"h-4 w-4"})}),o==="completed"&&(c==null?void 0:c.onDownload)&&!m&&s.jsx(me,{variant:"ghost",size:"icon",onClick:T=>{var D;T.stopPropagation();try{(D=c.onDownload)==null||D.call(c)}catch(L){console.error("Download failed:",L)}},tooltip:"Download",children:s.jsx(xo,{className:"h-4 w-4"})}),o==="completed"&&(c==null?void 0:c.onExpand)&&!m&&s.jsx(me,{variant:"ghost",size:"icon",onClick:T=>{var D;T.stopPropagation();try{(D=c.onExpand)==null||D.call(c)}catch(L){console.error("Expand failed:",L)}},tooltip:i?"Collapse":"Expand",children:i?s.jsx(Ru,{className:"h-4 w-4"}):s.jsx(ll,{className:"h-4 w-4"})}),o==="completed"&&(c==null?void 0:c.onDelete)&&!m&&s.jsx(me,{variant:"ghost",size:"icon",onClick:T=>{var D;T.stopPropagation();try{(D=c.onDelete)==null||D.call(c)}catch(L){console.error("Delete failed:",L)}},tooltip:"Delete",children:s.jsx(zl,{className:"h-4 w-4"})}),o==="failed"&&s.jsx("div",{className:"pr-4",title:"Artifact action failed",children:s.jsx(To,{className:"h-4 w-4 text-[var(--color-error-wMain)]"})})]}),a&&l&&!m&&s.jsx(me,{variant:"ghost",size:"icon",onClick:T=>{T.stopPropagation();try{l()}catch(D){console.error("Toggle expand failed:",D)}},tooltip:i?"Collapse":"Expand",children:i?s.jsx(Ru,{className:"h-4 w-4 transition-transform duration-200"}):s.jsx(ll,{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:v&&s.jsxs(s.Fragment,{children:[s.jsx("hr",{className:"border-t"}),s.jsx("div",{className:"p-3",children:v})]})})})]})},Uy=({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(ar,{className:"h-6 w-6 animate-spin text-primary"}),s.jsx("p",{className:"text-sm text-muted-foreground",children:t})]})}):null,Ra=e=>{const{artifacts:t,setPreviewArtifact:n,openSidePanelTab:r,sessionId:o,openDeleteModal:a,markArtifactAsDisplayed:i,downloadAndResolveArtifact:l,navigateArtifactVersion:c}=It(),{activeProject:u}=bo(),[f,h]=d.useState(!1),[p,m]=d.useState(null),[x,g]=d.useState(null),[v,w]=d.useState(null),[b,C]=d.useState(!1),[_,E]=d.useState(!1),S=d.useMemo(()=>t.find(k=>k.filename===e.name),[t,e.name]),j=e.context||"chat",A=(S==null?void 0:S.source)==="project",I=d.useMemo(()=>{const k=e.status==="completed"?e.fileAttachment:void 0;if(k!=null&&k.uri){const oe=Uu(k.uri);return(oe==null?void 0:oe.version)!==null&&(oe==null?void 0:oe.version)!==void 0?parseInt(oe.version):void 0}},[e]),P=e.status==="completed"?e.fileAttachment:void 0,F=(P==null?void 0:P.name)||e.name,N=P==null?void 0:P.mime_type,R=d.useMemo(()=>e.status==="completed"&&!S,[e.status,S]),y=d.useMemo(()=>{if(R)return!1;const k=Er(F,N),oe=k==="image"||k==="audio"||k==="markdown",ae=F.toLowerCase().endsWith(".txt")||F.toLowerCase().endsWith(".text");return(oe||k==="text"&&ae)&&j==="chat"},[F,N,j,R]),{shouldRender:T,isExpandable:D,isExpanded:L,toggleExpanded:O}=mT({filename:F,mimeType:N,shouldAutoExpand:y}),M=d.useCallback(async()=>{S&&(r("files"),n(S),I!==void 0&&setTimeout(async()=>{await c(S.filename,I)},100))},[S,r,n,I,c]),J=d.useCallback(()=>{let k=null;S?(k={name:S.filename,mime_type:S.mime_type,uri:S.uri,size:S.size,last_modified:S.last_modified},!k.uri&&(P!=null&&P.content)&&(k.content=P.content)):P&&(k=P),k?Cx(k,o,u==null?void 0:u.id):console.error(`No file to download for artifact: ${e.name}`)},[S,P,o,u==null?void 0:u.id,e.name]),z=d.useCallback(()=>{S&&a(S)},[S,a]),H=d.useCallback(()=>{C(!b)},[b]);d.useEffect(()=>{const k=S==null?void 0:S.filename;return T&&k&&i(k,!0),()=>{k&&i(k,!1)}},[T,S==null?void 0:S.filename,i]);const U=d.useMemo(()=>Er(F,N)==="image",[F,N]),X=d.useMemo(()=>{const k=Er(F,N);return k==="text"||k==="markdown"},[F,N]);d.useEffect(()=>{e.status==="in-progress"&&(S!=null&&S.accumulatedContent)&&T&&g(S.accumulatedContent)},[S==null?void 0:S.accumulatedContent,e.status,F,T,L]),d.useEffect(()=>{(async()=>{if(S!=null&&S.needsEmbedResolution&&e.status==="completed"&&T&&!_){E(!0);try{const oe=await l(S.filename);oe!=null&&oe.content&&g(oe.content)}catch(oe){console.error(`Error downloading ${F}:`,oe)}finally{E(!1)}}})()},[S==null?void 0:S.needsEmbedResolution,e.status,T,F,S==null?void 0:S.filename,l,_]),d.useEffect(()=>{(async()=>{if(f||!T)return;if(e.status==="in-progress"){S!=null&&S.accumulatedContent&&g(S.accumulatedContent);return}if(e.status!=="completed")return;if(S!=null&&S.accumulatedContent){g(S.accumulatedContent);return}const oe=P==null?void 0:P.content;if(x||oe){oe&&!x&&g(oe);return}const ae=P==null?void 0:P.uri;if(ae){h(!0),m(null);try{const G=Uu(ae);if(!G)throw new Error("Invalid artifact URI.");const{filename:V,version:ne}=G;let B;o&&o.trim()&&o!=="null"&&o!=="undefined"?B=`/api/v1/artifacts/${o}/${encodeURIComponent(V)}/versions/${ne||"latest"}`:u!=null&&u.id?B=`/api/v1/artifacts/null/${encodeURIComponent(V)}/versions/${ne||"latest"}?project_id=${u.id}`:B=`/api/v1/artifacts/null/${encodeURIComponent(V)}/versions/${ne||"latest"}`;const K=await je.webui.get(B,{fullResponse:!0});if(!K.ok)throw new Error(`Failed to fetch artifact content: ${K.statusText}`);const Z=await K.blob(),le=await new Promise((de,se)=>{const he=new FileReader;he.onloadend=()=>{typeof he.result=="string"?de(he.result.split(",")[1]):se(new Error("Failed to read artifact content as a data URL."))},he.onerror=()=>{se(he.error||new Error("An unknown error occurred while reading the file."))},he.readAsDataURL(Z)});g(le)}catch(G){console.error("Error fetching inline content:",G),m(G instanceof Error?G.message:"Unknown error fetching content.")}finally{h(!1)}}})()},[e.status,T,P,o,u==null?void 0:u.id,f,x,S==null?void 0:S.accumulatedContent,F,L,S]);const W=d.useMemo(()=>{if(e.status!=="failed")return j==="list"?{onInfo:H,onDownload:e.status==="completed"?J:void 0,onDelete:S&&e.status==="completed"&&!A?z:void 0}:{onPreview:e.status==="completed"?M:void 0,onDownload:e.status==="completed"?J:void 0,onInfo:H}},[e.status,j,J,S,z,H,M,A]),te=d.useMemo(()=>t.find(k=>k.filename===e.name),[t,e.name]),$=te==null?void 0:te.description,q=x||(P==null?void 0:P.content),Y=Er(F,N);let re=null;if(f)re=s.jsx("div",{className:"bg-muted flex h-25 items-center justify-center",children:s.jsx(Qr,{})});else if(p)re=s.jsx(Vt,{variant:"error",message:p});else if(q&&Y)try{const oe=mw({...P||{name:F,mime_type:N},content:q,isPlainText:(S==null?void 0:S.isAccumulatedContentPlainText)&&x===(S==null?void 0:S.accumulatedContent)||e.status==="in-progress"&&!!x});if(oe){let ae,G,V;U?(ae="none",V="visible"):X?(ae="6000px",V="auto"):Y==="audio"?(ae="300px",V="auto"):Y==="html"?(G="600px",ae="600px",V="auto"):(ae="600px",V="auto"),re=s.jsxs("div",{className:"group relative max-w-full overflow-hidden",children:[v&&s.jsx(Vt,{variant:"error",message:v}),s.jsx("div",{style:{height:G,maxHeight:ae,overflowY:V},className:U?"drop-shadow-md":"",children:s.jsx(nh,{content:oe,rendererType:Y,mime_type:P==null?void 0:P.mime_type,setRenderError:w})}),s.jsx(Uy,{isVisible:_,message:"Resolving embeds..."})]})}}catch(k){console.error("Failed to process file content:",k),re=s.jsx(Vt,{variant:"error",message:"Failed to process file content for rendering"})}const ue=T&&L,ce=d.useMemo(()=>!b||!S?null:s.jsxs("div",{className:"space-y-2 text-sm",children:[S.description&&s.jsxs("div",{children:[s.jsx("span",{className:"text-secondary-foreground",children:"Description:"}),s.jsx("div",{className:"mt-1",children:S.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:ri(S.size)})]}),s.jsxs("div",{children:[s.jsx("span",{className:"text-secondary-foreground",children:"Modified:"}),s.jsx("div",{children:Zs(S.last_modified)})]})]}),S.mime_type&&s.jsxs("div",{children:[s.jsx("span",{className:"text-secondary-foreground",children:"Type:"}),s.jsx("div",{children:S.mime_type})]})]}),[b,S]),pe=d.useMemo(()=>{const k=b&&ce,oe=ue&&re;if(k&&oe)return s.jsxs("div",{className:"space-y-4",children:[ce,s.jsx("hr",{className:"border-t"}),re]});if(k)return ce;if(oe)return re},[b,ce,ue,re]);return s.jsx(K3,{filename:F,description:$||"",mimeType:N,size:P==null?void 0:P.size,status:e.status,expandable:D&&j==="chat",expanded:L||b,onToggleExpand:D&&j==="chat"?O:void 0,actions:W,bytesTransferred:e.status==="in-progress"?e.bytesTransferred:void 0,error:e.status==="failed"?e.error:void 0,expandedContent:pe,context:j,isDeleted:R,version:I,source:S==null?void 0:S.source})},By=({filename:e,mimeType:t,className:n,onDownload:r,isEmbedded:o=!1})=>{const{artifacts:a,setPreviewArtifact:i,openSidePanelTab:l}=It(),c=d.useMemo(()=>a.find(p=>p.filename===e),[a,e]),u=d.useMemo(()=>If(c||{filename:e,mime_type:t||""}),[c,e,t]),f=d.useCallback(p=>{p.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(--message-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(me,{variant:"ghost",onClick:f,tooltip:"Preview",children:s.jsx(yg,{className:"h-4 w-4"})}),r&&s.jsx(me,{variant:"ghost",onClick:h,tooltip:"Download file",children:s.jsx(xo,{className:"h-4 w-4"})})]})},q3=At.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 p;(p=c.current)==null||p.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(Pn,{open:e,onOpenChange:f,children:s.jsxs(Mn,{className:"sm:max-w-[750px]",showCloseButton:!1,children:[s.jsxs(Vn,{children:[s.jsx(Dn,{children:"Provide Feedback"}),s.jsxs(Wn,{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($r,{ref:c,value:o,onChange:p=>a(p.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(er,{children:[s.jsx(me,{variant:"ghost",onClick:f,disabled:i,children:"Cancel"}),s.jsx(me,{variant:"default",onClick:u,disabled:i,children:"Submit"})]})]})})}),X3={"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 J3(e,t){const n=X3[e]||"bin";return`embedded_file_${t+1}.${n}`}function Q3(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=Er(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:J3(i,o++)})}}return t}function eM(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 tM(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 nM(e){return!e||typeof e!="string"?[]:[...Q3(e),...eM(e),...tM(e)]}const rM={LAYOUT:"layout"},zn=({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})]}),oM=({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($l,{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(zn,{label:"Version",value:e.version,icon:s.jsx(wh,{size:14})}),e.capabilities&&Object.keys(e.capabilities).length>0&&s.jsx(zn,{label:"Key Capabilities",value:r(e.capabilities),icon:s.jsx(bh,{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(zn,{label:"Name",value:e.name,icon:s.jsx(Qa,{size:14})}),s.jsx(zn,{label:"Description",value:e.description,icon:s.jsx(R1,{size:14}),fullWidthValue:!0}),s.jsx(zn,{label:"Version",value:e.version,icon:s.jsx(wh,{size:14})}),s.jsx(zn,{label:"Endpoint",value:e.url||"N/A",icon:s.jsx(Sg,{size:14})}),s.jsx(zn,{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(wg,{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(zn,{label:"Name",value:e.provider.organization}),s.jsx(zn,{label:"URL",value:e.provider.url||"N/A"})]}),s.jsx(zn,{label:"Capabilities",value:r(e.capabilities),icon:s.jsx(bh,{size:14}),fullWidthValue:!0}),s.jsx(zn,{label:"Input Modes",value:o(e.defaultInputModes),icon:s.jsx(yh,{size:14}),fullWidthValue:!0}),s.jsx(zn,{label:"Output Modes",value:o(e.defaultOutputModes),icon:s.jsx(yh,{size:14}),fullWidthValue:!0}),s.jsx(zn,{label:"Skills",value:a(e.skills),icon:s.jsx(P1,{size:14}),fullWidthValue:!0}),s.jsx(zn,{label:"Tools Info",value:i(e.tools),icon:s.jsx(Md,{size:14}),fullWidthValue:!0}),s.jsx("div",{className:"text-2xs mt-1.5 pt-1.5",children:s.jsx(zn,{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"})]})]})})},sM=s.jsx($l,{className:"text-muted-foreground",size:64}),Vy=({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(Pr,{image:sM,title:"No agents found",subtitle:"No agents discovered in the current namespace."}):s.jsxs("div",{className:"bg-card-background h-full w-full pt-6 pl-6",children:[s.jsx(gf,{value:r,onChange:o,placeholder:"Filter by name...",testid:"agentSearchInput",className:"mb-4 w-xs"}),i.length===0&&r?s.jsx(Pr,{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-180px)] overflow-y-auto",children:s.jsx("div",{className:"flex flex-wrap gap-10",children:i.map(l=>s.jsx(oM,{agent:l,isExpanded:t===l.name,onToggleExpand:()=>a(l.name)},l.name))})})]})})};class aM{constructor(){ws(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:rM.LAYOUT,id:"cards",label:"Cards",icon:M1,priority:100,render:t=>s.jsx(Vy,{agents:t.agents||[]})})}renderPlugin(t,n){const r=this.getPluginById(t);if(r)return r.render(n)}}new aM;const iM=({message:e})=>{const{handleCancel:t,setMessages:n,isResponding:r,isCancelling:o}=It();if(e.authenticationLink){const a=e.authenticationLink.authenticationAttempted||!1,i=e.authenticationLink.rejected||!1,l=()=>{if(a||i)return;n(h=>h.map(p=>{var m,x;return((m=p.metadata)==null?void 0:m.messageId)===((x=e.metadata)==null?void 0:x.messageId)&&p.authenticationLink?{...p,authenticationLink:{...p.authenticationLink,authenticationAttempted:!0}}:p}));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 p,m;return((p=h.metadata)==null?void 0:p.messageId)===((m=e.metadata)==null?void 0:m.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(me,{variant:"ghost",onClick:c,disabled:a||i||!r||o,children:"Reject"}),s.jsx(me,{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(Vt,{message:"Authentication request was rejected"})]})}return null},Tm=new Set;let Nn=null;function lM(e){return!e.parts||e.parts.length===0?"":e.parts.filter(n=>n.kind==="text").map(n=>n.text).join(" ").trim()}const cM=({message:e,className:t})=>{var F;const{settings:n,onTTSStart:r,onTTSEnd:o}=Uo(),{configFeatureEnablement:a}=sn(),i=((F=e.metadata)==null?void 0:F.messageId)||"",l=d.useMemo(()=>lM(e),[e]),c=!e.isComplete,u=(a==null?void 0:a.textToSpeech)??!0,{isSpeaking:f,isLoading:h,speak:p,stop:m}=AT({messageId:i,onStart:()=>{r()},onEnd:()=>{Nn===i&&(Nn=null),o()},onError:N=>{console.error("TTS error:",N),Nn===i&&(Nn=null),o()}}),{isPlaying:x,isLoading:g,processStreamingText:v,stop:w}=TT({messageId:i,onStart:()=>{},onEnd:()=>{Nn===i&&(Nn=null)},onError:N=>{console.error("Streaming TTS error:",N),Nn===i&&(Nn=null)}}),b=c?x:f,C=c?g:h,_=d.useRef(!1),E=d.useRef(!1),[S,j]=d.useState(!1);d.useEffect(()=>{e.isComplete&&i&&(j(!0),Tm.add(i))},[]),d.useEffect(()=>{const N=n.conversationMode;if(N&&!e.isUser&&c&&l&&l.length>20&&!_.current){if(Nn&&Nn!==i)return;Nn=i,_.current=!0,v(l,!1)}else if(N&&!e.isUser&&c&&_.current)v(l,!1);else if(N&&!e.isUser&&e.isComplete&&_.current&&!E.current)E.current=!0,v(l,!0);else if(N&&!e.isUser&&e.isComplete&&!_.current&&!E.current&&l&&!S){if(Nn&&Nn!==i)return;Nn=i,_.current=!0,E.current=!0,v(l,!0)}},[n.conversationMode,n.automaticPlayback,e.isUser,c,e.isComplete,l,i,v,S]),d.useEffect(()=>{if(n.conversationMode&&!e.isUser&&e.isComplete&&l&&!b&&!C&&!E.current&&!_.current&&!S){if(Nn&&Nn!==i)return;Nn=i,E.current=!0;const R=setTimeout(()=>{p(l)},100);return()=>clearTimeout(R)}},[n.conversationMode,n.automaticPlayback,e.isUser,e.isComplete,l,b,C,i,p,S]),d.useEffect(()=>{E.current=!1,_.current=!1,e.isComplete&&i?(j(!0),Tm.add(i)):j(!1)},[i,e.isComplete]);const A=d.useCallback(async()=>{b?c?w():m():l&&(c?(_.current=!0,await v(l,!1)):await p(l))},[b,c,l,p,m,w,v]),I=()=>C?s.jsx(ar,{className:"size-4 animate-spin"}):b?s.jsx(D1,{className:"size-4"}):s.jsx(cl,{className:"size-4"}),P=()=>b?"Stop reading":C?"Generating audio...":n.textToSpeech?"Read aloud":"Text-to-speech is disabled";return!u||!n.textToSpeech||!l?null:s.jsx(me,{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:P(),"aria-label":b?"Stop reading aloud":"Read aloud","aria-pressed":b,"aria-busy":C,children:I()})},Wy=({message:e,className:t})=>{const{addNotification:n}=It(),[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(cM,{message:e}),s.jsx(me,{ref:a,variant:"ghost",size:"icon",className:"h-8 w-8",onClick:l,tooltip:r?"Copied!":"Copy to clipboard",children:r?s.jsx(sa,{className:"h-4 w-4 text-[var(--color-success-wMain)]"}):s.jsx(vg,{className:"h-4 w-4"})})]})},uM=["image","audio"],vu=({message:e,showWorkflowButton:t,showFeedbackActions:n,handleViewWorkflowClick:r})=>{var b;const{configCollectFeedback:o,submittedFeedback:a,handleFeedbackSubmit:i,addNotification:l}=It(),[c,u]=d.useState(!1),[f,h]=d.useState(null),p=e.taskId,m=p?(b=a[p])==null?void 0:b.type:void 0,x=C=>{h(C),u(!0)},g=()=>{u(!1),h(null)},v=async C=>{!f||!p||(await i(p,f,C),l("Feedback submitted successfully","success"))},w=n&&o;return!t&&!w?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(av,{onClick:r}),w&&s.jsxs("div",{className:"flex items-center",children:[s.jsx(me,{tooltip:"Like",variant:"ghost",size:"sm",className:`${m?"!opacity-100":""}`,onClick:()=>x("up"),disabled:!!m,children:s.jsx(O1,{className:`h-4 w-4 ${m==="up"?"fill-[var(--color-brand-wMain)] text-[var(--color-brand-wMain)] !opacity-100":""}`})}),s.jsx(me,{tooltip:"Dislike",variant:"ghost",size:"sm",className:`${m?"!opacity-100":""}`,onClick:()=>x("down"),disabled:!!m,children:s.jsx(L1,{className:`h-4 w-4 ${m==="down"?"fill-[var(--color-brand-wMain)] text-[var(--color-brand-wMain)] opacity-100":""}`})})]}),s.jsx(Wy,{message:e})]})}),f&&s.jsx(q3,{isOpen:c,onClose:g,feedbackType:f,onSubmit:v})]})},dM=At.memo(({message:e})=>{var l,c;const[t,n]=d.useState(null),{sessionId:r}=It(),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(To,{className:"mr-2 self-start text-[var(--color-error-wMain)]"}),s.jsx(Vs,{children:a})]});const u=nM(a);if(u.length===0)return s.jsx(Vs,{children:a});let f=a;const h=[];return u.forEach((p,m)=>{if(f=f.replace(p.originalMatch,""),p.type==="file"){const x={name:p.filename||"downloaded_file",content:p.content,mime_type:p.mimeType};h.push(s.jsx("div",{className:"my-2",children:s.jsx(By,{filename:x.name,mimeType:x.mime_type,onDownload:()=>Cx(x,r),isEmbedded:!0})},`embedded-file-${m}`))}else if(!uM.includes(p.type)){const x=hw(p.content);x&&h.push(s.jsx("div",{className:"my-2 h-auto w-md max-w-md",children:s.jsx(nh,{content:x,rendererType:p.type,mime_type:p.mimeType,setRenderError:n})},`embedded-${m}`))}}),s.jsxs("div",{children:[t&&s.jsx(Vt,{variant:"error",message:"Error rendering preview"}),s.jsx(Vs,{children:f}),h]})};return e.isUser?i():s.jsx(IP,{messageId:((c=e.metadata)==null?void 0:c.messageId)||"",isAIMessage:!0,children:i()})}),fM=At.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})),hM=e=>e.uploadedFiles&&e.uploadedFiles.length>0?s.jsx(fM,{message:e,className:"flex flex-wrap justify-end gap-2",children:e.uploadedFiles.map((t,n)=>{var r;return s.jsx(By,{filename:t.name,mimeType:t.type},`uploaded-${(r=e.metadata)==null?void 0:r.messageId}-${n}`)})}):null,pM=(e,t,n)=>{var g,v,w;const{openSidePanelTab:r,setTaskIdInSidePanel:o}=t;if(e.isStatusBubble)return null;if(e.authenticationLink)return s.jsx(iM,{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"))},p=(b,C)=>{var E;const _=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(Ra,{status:"completed",name:A.name,fileAttachment:A,uniqueKey:_},`part-file-${C}`)}if(b.kind==="artifact"){const S=b;switch(S.status){case"completed":return s.jsx(Ra,{status:"completed",name:S.name,fileAttachment:S.file,uniqueKey:_},`part-artifact-${C}`);case"in-progress":return s.jsx(Ra,{status:"in-progress",name:S.name,bytesTransferred:S.bytesTransferred,uniqueKey:_},`part-artifact-${C}`);case"failed":return s.jsx(Ra,{status:"failed",name:S.name,error:S.error,uniqueKey:_},`part-artifact-${C}`);default:return null}}return null},m=a.length-1,x=(v=a[m])==null?void 0:v.kind;return s.jsxs("div",{className:"space-y-6",children:[a.map((b,C)=>{const _=C===m;if(b.kind==="text"){const E=b.text;return!E||!E.trim()?_&&(u||f)?s.jsx("div",{className:`flex ${e.isUser?"justify-end pr-4":"justify-start pl-4"}`,children:s.jsx(vu,{message:e,showWorkflowButton:!!u,showFeedbackActions:!!f,handleViewWorkflowClick:h})},`part-${C}`):null:s.jsx($b,{variant:c,children:s.jsxs(Ub,{variant:c,children:[s.jsx(dM,{message:{...e,parts:[{kind:"text",text:E}]}}),_&&s.jsx(vu,{message:e,showWorkflowButton:!!u,showFeedbackActions:!!f,handleViewWorkflowClick:h})]})},`part-${C}`)}else if(b.kind==="artifact"||b.kind==="file")return p(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(vu,{message:e,showWorkflowButton:!!u,showFeedbackActions:!!f,handleViewWorkflowClick:h})}):null,e.isUser&&s.jsx("div",{className:"flex justify-end",children:s.jsx(Wy,{message:e})})]},(w=e.metadata)==null?void 0:w.messageId)},mM=({message:e,isLastWithTaskId:t})=>{const n=It();return e?s.jsxs(s.Fragment,{children:[pM(e,n,t),hM(e)]}):null};var wd=new Map,Ui=new WeakMap,Am=0,gM=void 0;function xM(e){return e?(Ui.has(e)||(Am+=1,Ui.set(e,Am.toString())),Ui.get(e)):"0"}function vM(e){return Object.keys(e).sort().filter(t=>e[t]!==void 0).map(t=>`${t}_${t==="root"?xM(e.root):e[t]}`).toString()}function wM(e){const t=vM(e);let n=wd.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},wd.set(t,n)}return n}function bM(e,t,n={},r=gM){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}=wM(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(),wd.delete(o))}}function yM({threshold:e,delay:t,trackVisibility:n,rootMargin:r,root:o,triggerOnce:a,skip:i,initialInView:l,fallbackInView:c,onChange:u}={}){var f;const[h,p]=d.useState(null),m=d.useRef(u),[x,g]=d.useState({inView:!!l,entry:void 0});m.current=u,d.useEffect(()=>{if(i||!h)return;let C;return C=bM(h,(_,E)=>{g({inView:_,entry:E}),m.current&&m.current(_,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 v=(f=x.entry)==null?void 0:f.target,w=d.useRef(void 0);!h&&v&&!a&&!i&&w.current!==v&&(w.current=v,g({inView:!!l,entry:void 0}));const b=[p,x.inView,x.entry];return b.ref=b[0],b.inView=b[1],b.entry=b[2],b}const CM=({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(w){console.error("Failed to move session:",w)}finally{u(!1)}},h=o.filter(w=>w.id!==a),p=()=>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.`,m=()=>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,v=()=>{c||t()};return s.jsx(Pn,{open:e,onOpenChange:w=>!w&&v(),children:s.jsxs(Mn,{children:[s.jsxs(Vn,{children:[s.jsx(Dn,{children:"Move Chat Session"}),s.jsx(Wn,{children:p()})]}),s.jsx("div",{className:"py-4",children:s.jsxs(Nr,{value:i===null?"none":i||"",onValueChange:w=>l(w==="none"?null:w),children:[s.jsx(Ar,{className:"w-full rounded-md",children:s.jsx(Tr,{placeholder:x()})}),s.jsxs(Ir,{children:[a&&s.jsx(_t,{value:"none",children:m()}),h.map(w=>s.jsx(_t,{value:w.id,children:s.jsx("p",{className:"max-w-sm truncate",children:w.name})},w.id))]})]})}),s.jsxs(er,{children:[s.jsx(me,{variant:"ghost",onClick:v,disabled:c,children:"Cancel"}),s.jsx(me,{onClick:f,disabled:g,children:c?"Moving...":"Move"})]})]})})},SM=({onSessionSelect:e,projectId:t})=>{const[n,r]=d.useState(""),[o,a]=d.useState([]),[i,l]=d.useState(!1),[c,u]=d.useState(!1),f=ST(n,300),h=d.useCallback(async(g,v)=>{if(!g.trim()){a([]),u(!1);return}l(!0);try{const w=new URLSearchParams({query:g.trim(),pageNumber:"1",pageSize:"20"});v&&w.append("projectId",v);const b=await je.webui.get(`/api/v1/sessions/search?${w.toString()}`);a(b.data||[]),u(!0)}catch(w){console.error("Search error:",w),a([])}finally{l(!1)}},[]);d.useEffect(()=>{h(f,t)},[f,t,h]);const p=()=>{r(""),a([]),u(!1)},m=g=>{e(g),p()};return s.jsxs("div",{className:"relative w-full",children:[s.jsxs("div",{className:"relative",children:[s.jsx(Id,{className:"text-muted-foreground absolute top-1/2 left-3 h-4 w-4 -translate-y-1/2"}),s.jsx(xr,{type:"text",placeholder:"Search chats by title",value:n,onChange:g=>r(g.target.value),className:"pr-9 pl-9"}),n&&s.jsx(me,{variant:"ghost",size:"sm",className:"absolute top-1/2 right-1 h-7 w-7 -translate-y-1/2 p-0",onClick:p,children:s.jsx(Xr,{className:"h-4 w-4"})})]}),c&&s.jsx("div",{className:"bg-popover absolute z-50 mt-2 w-full rounded-md border p-2 shadow-md",children:i?s.jsx("div",{className:"text-muted-foreground p-4 text-center text-sm",children:"Searching..."}):o.length>0?s.jsx("div",{className:"max-h-[300px] overflow-y-auto",children:o.map(g=>s.jsxs("button",{onClick:()=>m(g.id),className:"hover:bg-accent hover:text-accent-foreground w-full rounded-sm px-3 py-2 text-left text-sm",children:[s.jsxs("div",{className:"mb-1 flex items-center justify-between gap-2",children:[s.jsx("div",{className:"flex-1 truncate font-medium",children:g.name||"Untitled Session"}),g.projectName&&s.jsx(Or,{variant:"outline",className:"bg-primary/10 border-primary/30 text-primary flex-shrink-0 px-2 py-0.5 text-xs font-semibold shadow-sm",children:g.projectName})]}),s.jsx("div",{className:"text-muted-foreground text-xs",children:new Date(g.updatedTime).toLocaleDateString()})]},g.id))}):s.jsx("div",{className:"text-muted-foreground p-4 text-center text-sm",children:"No results found"})})]})},_M=({projects:e=[]})=>{const t=zo(),{sessionId:n,handleSwitchSession:r,updateSessionName:o,openSessionDeleteModal:a,addNotification:i,displayError:l}=It(),{persistenceEnabled:c}=sn(),u=d.useRef(null),[f,h]=d.useState([]),[p,m]=d.useState(null),[x,g]=d.useState(""),[v,w]=d.useState(1),[b,C]=d.useState(!0),[_,E]=d.useState(!1),[S,j]=d.useState("all"),[A,I]=d.useState(!1),[P,F]=d.useState(null),{ref:N,inView:R}=yM({threshold:0,triggerOnce:!1}),y=d.useCallback(async($=1,q=!1)=>{E(!0);try{const Y=await je.webui.get(`/api/v1/sessions?pageNumber=${$}&pageSize=20`);h(q?re=>[...re,...Y.data]:Y.data),C(Y.meta.pagination.nextPage!==null),w($)}catch(Y){console.error("An error occurred while fetching sessions:",Y)}finally{E(!1)}},[]);d.useEffect(()=>{y(1,!1);const $=()=>{y(1,!1)},q=re=>{const{sessionId:ue}=re.detail;h(ce=>{const pe=ce.find(k=>k.id===ue);if(pe){const k=ce.filter(oe=>oe.id!==ue);return[pe,...k]}return ce})},Y=()=>{y(1,!1)};return window.addEventListener("new-chat-session",$),window.addEventListener("session-updated",q),window.addEventListener("background-task-completed",Y),()=>{window.removeEventListener("new-chat-session",$),window.removeEventListener("session-updated",q),window.removeEventListener("background-task-completed",Y)}},[y]),d.useEffect(()=>{if(!f.some(Y=>Y.hasRunningBackgroundTask))return;const q=setInterval(()=>{y(1,!1)},1e4);return()=>{clearInterval(q)}},[f,y]),d.useEffect(()=>{R&&b&&!_&&y(v+1,!0)},[R,b,_,v,y]),d.useEffect(()=>{p&&u.current&&u.current.focus()},[p]);const T=async $=>{p!==$&&await r($)},D=$=>{m($.id),g($.name||"")},L=async()=>{if(p){const $=p,q=x;m(null),await o($,q)}},O=$=>{a($)},M=$=>{F($),I(!0)},J=$=>{$.projectId&&t(`/projects/${$.projectId}`)},z=async $=>{if(P)try{await je.webui.patch(`/api/v1/sessions/${P.id}/project`,{projectId:$}),h(q=>q.map(Y=>{var re;return Y.id===P.id?{...Y,projectId:$,projectName:$&&((re=e.find(ue=>ue.id===$))==null?void 0:re.name)||null}:Y})),typeof window<"u"&&window.dispatchEvent(new CustomEvent("session-moved",{detail:{sessionId:P.id,projectId:$}})),i==null||i("Session moved successfully","success"),I(!1),F(null)}catch(q){l({title:"Failed to Move Session",error:Ut(q,"An unknown error occurred while moving the session.")})}},H=$=>Zd($),U=$=>{if($.name&&$.name.trim())return $.name;const q=$.id;return q.startsWith("web-session-")?`Chat ${q.replace("web-session-","").substring(0,8)}`:`Session ${q.substring(0,8)}`},X=d.useMemo(()=>{const $=new Set;let q=!1;f.forEach(re=>{re.projectName?$.add(re.projectName):q=!0});const Y=Array.from($).sort((re,ue)=>re.localeCompare(ue));return q&&Y.unshift("(No Project)"),Y},[f]),W=d.useMemo(()=>S==="all"?f:S==="(No Project)"?f.filter($=>!$.projectName):f.filter($=>$.projectName===S),[f,S]),te=d.useMemo(()=>{if(S==="all")return null;const $=e.find(q=>q.name===S);return($==null?void 0:$.id)||null},[S,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(SM,{onSessionSelect:r,projectId:te})}),c&&X.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(Nr,{value:S,onValueChange:j,children:[s.jsx(Ar,{className:"flex-1 rounded-md",children:s.jsx(Tr,{})}),s.jsxs(Ir,{children:[s.jsx(_t,{value:"all",children:"All Chats"}),X.map($=>s.jsx(_t,{value:$,children:$},$))]})]})]})]}),s.jsxs("div",{className:"flex-1 overflow-y-auto",children:[W.length>0&&s.jsx("ul",{children:W.map($=>s.jsx("li",{className:"group my-2 pr-4",children:s.jsxs("div",{className:`flex items-center gap-2 rounded px-2 py-2 ${$.id===n?"bg-muted":""}`,children:[p===$.id?s.jsx("input",{ref:u,type:"text",value:x,onChange:q=>g(q.target.value),onKeyDown:q=>{q.key==="Enter"&&(q.preventDefault(),L())},className:"min-w-0 flex-1 bg-transparent focus:outline-none"}):s.jsx("button",{onClick:()=>T($.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:U($)}),$.hasRunningBackgroundTask&&s.jsxs(ho,{children:[s.jsx(po,{asChild:!0,children:s.jsx(ar,{className:"text-primary h-4 w-4 flex-shrink-0 animate-spin"})}),s.jsx(mo,{children:"Background task running"})]})]}),s.jsx("span",{className:"text-muted-foreground truncate text-xs",children:H($.updatedTime)})]}),$.projectName&&s.jsxs(ho,{children:[s.jsx(po,{asChild:!0,children:s.jsx(Or,{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:$.projectName})})}),s.jsx(mo,{children:$.projectName})]})]})}),s.jsx("div",{className:"flex flex-shrink-0 items-center",children:p===$.id?s.jsxs(s.Fragment,{children:[s.jsx(me,{variant:"ghost",size:"sm",onClick:L,className:"h-8 w-8 p-0",children:s.jsx(sa,{size:16})}),s.jsx(me,{variant:"ghost",size:"sm",onClick:()=>m(null),className:"h-8 w-8 p-0",children:s.jsx(Xr,{size:16})})]}):s.jsxs(Xs,{children:[s.jsx(Js,{asChild:!0,children:s.jsx(me,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:q=>q.stopPropagation(),children:s.jsx(Io,{size:16})})}),s.jsxs(Qs,{align:"end",className:"w-48",children:[$.projectId&&s.jsxs(s.Fragment,{children:[s.jsxs(jn,{onClick:q=>{q.stopPropagation(),J($)},children:[s.jsx(F1,{size:16,className:"mr-2"}),"Go to Project"]}),s.jsx(tm,{})]}),s.jsxs(jn,{onClick:q=>{q.stopPropagation(),D($)},children:[s.jsx(eo,{size:16,className:"mr-2"}),"Rename"]}),s.jsxs(jn,{onClick:q=>{q.stopPropagation(),M($)},children:[s.jsx(z1,{size:16,className:"mr-2"}),"Move to Project"]}),s.jsx(tm,{}),s.jsxs(jn,{onClick:q=>{q.stopPropagation(),O($)},children:[s.jsx(ts,{size:16,className:"mr-2"}),"Delete"]})]})]})})]})},$.id))}),W.length===0&&f.length>0&&!_&&s.jsxs("div",{className:"text-muted-foreground flex h-full flex-col items-center justify-center text-sm",children:[s.jsx(ul,{className:"mx-auto mb-4 h-12 w-12"}),"No sessions found for this project"]}),f.length===0&&!_&&s.jsxs("div",{className:"text-muted-foreground flex h-full flex-col items-center justify-center text-sm",children:[s.jsx(ul,{className:"mx-auto mb-4 h-12 w-12"}),"No chat sessions available"]}),b&&s.jsx("div",{ref:N,className:"flex justify-center py-4",children:_&&s.jsx(Qr,{size:"small",variant:"muted"})})]}),s.jsx(CM,{isOpen:A,onClose:()=>{I(!1),F(null)},onConfirm:z,session:P,projects:e,currentProjectId:P==null?void 0:P.projectId})]})},kM=()=>{const{persistenceEnabled:e}=sn(),{sessionName:t}=It(),{projects:n}=bo();return e?s.jsx(_M,{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."})]})})},jM=({artifact:e,isPreview:t})=>{const{setPreviewArtifact:n}=It(),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(Ra,{status:"completed",name:e.filename,fileAttachment:r,context:"list"})})},EM=()=>{const{isDeleteModalOpen:e,artifactToDelete:t,closeDeleteModal:n,confirmDelete:r}=It();return t?s.jsx(Bo,{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},NM=({artifact:e,message:t})=>{const{onDownload:n}=Rf();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(me,{onClick:()=>n(e),children:[s.jsx(xo,{className:"h-4 w-4"}),"Download"]})]})},wu=({children:e})=>s.jsx("div",{className:"text-muted-foreground flex h-[50vh] items-center justify-center",children:e||"No preview available"}),TM=({artifact:e})=>{const{openArtifactForPreview:t,previewFileContent:n,markArtifactAsDisplayed:r,downloadAndResolveArtifact:o}=It(),a=d.useMemo(()=>fT(e),[e]),[i,l]=d.useState(!1),[c,u]=d.useState(null),[f,h]=d.useState(null),[p,m]=d.useState(!1),x=d.useRef(!1),g=d.useRef(null),v=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(S){console.error("Error fetching artifact content:",S),u(S instanceof Error?S.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&&!p&&!v.current){v.current=!0,m(!0);try{const S=await o(e.filename);S&&h({...S,isPlainText:!1})}catch(S){console.error(`[ArtifactPreviewContent] Error downloading ${e.filename}:`,S)}finally{m(!1),v.current=!1}}}E()},[e.needsEmbedResolution,e.filename,o,p]),c)return s.jsxs("div",{className:"flex h-full w-full flex-col",children:[s.jsx(Vt,{variant:"error",message:"Error rendering preview"}),s.jsx(wu,{children:"No preview available"})]});if(i)return s.jsx(wu,{children:s.jsx(ar,{className:"text-muted-foreground h-6 w-6 animate-spin"})});if(!a.canPreview)return s.jsx(NM,{artifact:e,message:a.reason??""});const w=f||((n==null?void 0:n.name)===e.filename?n:null),b=(w==null?void 0:w.mime_type)||e.mime_type,C=Er(e.filename,b),_=mw(w);return!C||!_?s.jsx(wu,{children:"No preview available"}):s.jsxs("div",{className:"relative h-full w-full",children:[s.jsx(nh,{content:_,rendererType:C,mime_type:w==null?void 0:w.mime_type,setRenderError:u}),s.jsx(Uy,{isVisible:p,message:"Resolving embeds..."})]})},Gr={NameAsc:"name_asc",NameDesc:"name_desc",DateAsc:"date_asc",DateDesc:"date_desc"},AM=e=>{switch(e){case Gr.NameAsc:return"Name (A-Z)";case Gr.NameDesc:return"Name (Z-A)";case Gr.DateAsc:return"Date (oldest first)";case Gr.DateDesc:return"Date (newest first)"}},IM=({currentSortOption:e,onSortChange:t,children:n})=>{const r=Object.values(Gr).map(o=>({id:o,label:AM(o),onClick:()=>t(o),icon:e===o?s.jsx(sa,{}):void 0,iconPosition:"right"}));return s.jsxs(pc,{children:[s.jsx(mc,{asChild:!0,children:n}),s.jsx(gc,{align:"end",side:"bottom",className:"w-auto",sideOffset:0,children:s.jsx(di,{actions:r})})]})},RM=({children:e,hideDeleteAll:t=!1})=>{const{artifactsRefetch:n,setIsBatchDeleteModalOpen:r}=It(),o=[{id:"refreshAll",label:"Refresh",onClick:()=>{n()},icon:s.jsx(Ul,{}),iconPosition:"left"}];return t||o.push({id:"deleteAll",label:"Delete All",onClick:()=>{r(!0)},icon:s.jsx(zl,{}),iconPosition:"left",divider:!0}),s.jsxs(pc,{children:[s.jsx(mc,{asChild:!0,children:e}),s.jsx(gc,{align:"end",side:"bottom",className:"w-auto",sideOffset:0,children:s.jsx(di,{actions:o})})]})},PM=()=>{const{artifacts:e,isBatchDeleteModalOpen:t,setIsBatchDeleteModalOpen:n,confirmBatchDeleteArtifacts:r,setSelectedArtifactFilenames:o}=It();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(Bo,{title:"Delete All?",description:c(),actionLabels:{confirm:"Delete"},onCancel:()=>n(!1),onConfirm:r,open:t,onOpenChange:n})},MM=({artifactInfo:e,isPreview:t=!1,isExpanded:n=!1,onDelete:r,onDownload:o,setIsExpanded:a,badge:i})=>{const{previewedArtifactAvailableVersions:l,currentPreviewedVersionNumber:c,navigateArtifactVersion:u}=It(),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:Zs(e.last_modified),children:Zs(e.last_modified)})]}),t&&f.length>1&&s.jsx("div",{className:"align-right",children:s.jsxs(Nr,{value:c==null?void 0:c.toString(),onValueChange:h=>{u(e.filename,parseInt(h))},children:[s.jsx(Ar,{className:"h-[16px] py-0 text-xs shadow-none",children:s.jsx(Tr,{placeholder:"Version"})}),s.jsx(Ir,{children:f.map(h=>s.jsxs(_t,{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(me,{variant:"ghost",size:"sm",onClick:h=>{h.stopPropagation(),h.preventDefault(),a(!n)},tooltip:n?"Collapse Details":"Expand Details",children:s.jsx(Qa,{})}),o&&s.jsx(me,{variant:"ghost",size:"sm",onClick:async h=>{h.stopPropagation(),h.preventDefault(),await o(e)},tooltip:"Download",children:s.jsx(xo,{})}),r&&s.jsx(me,{variant:"ghost",size:"sm",onClick:h=>{h.preventDefault(),h.stopPropagation(),r()},tooltip:"Delete",children:s.jsx(zl,{})})]})]})},DM={[Gr.NameAsc]:(e,t)=>e.filename.localeCompare(t.filename),[Gr.NameDesc]:(e,t)=>t.filename.localeCompare(e.filename),[Gr.DateAsc]:(e,t)=>e.last_modified>t.last_modified?1:-1,[Gr.DateDesc]:(e,t)=>e.last_modified<t.last_modified?1:-1},OM=()=>{const{artifacts:e,artifactsLoading:t,previewArtifact:n,setPreviewArtifact:r,artifactsRefetch:o,openDeleteModal:a}=It(),{onDownload:i}=Rf(),[l,c]=d.useState(Gr.DateDesc),[u,f]=d.useState(!1),h=d.useMemo(()=>t?[]:e?[...e].sort(DM[l]):[],[e,t,l]),p=d.useMemo(()=>h.some(x=>x.source!=="project"),[h]),m=d.useMemo(()=>n?s.jsxs("div",{className:"flex items-center gap-2 border-b p-2",children:[s.jsx(me,{variant:"ghost",onClick:()=>r(null),children:s.jsx($1,{})}),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(IM,{currentSortOption:l,onSortChange:c,children:s.jsxs(me,{variant:"ghost",title:"Sort By",children:[s.jsx(gg,{className:"h-5 w-5"}),s.jsx("div",{children:"Sort By"})]})},"sort-popover"),s.jsx(RM,{hideDeleteAll:!p,children:s.jsx(me,{variant:"ghost",tooltip:"More",children:s.jsx(Io,{className:"h-5 w-5"})})},"more-popover")]}),[n,h.length,l,r,p]);return s.jsxs("div",{className:"flex h-full flex-col",children:[m,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(jM,{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(ar,{className:"size-6 animate-spin"}),!t&&s.jsxs(s.Fragment,{children:[s.jsx(gr,{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(me,{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(MM,{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:ri(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(TM,{artifact:n})})]})]}),s.jsx(EM,{}),s.jsx(PM,{})]})},LM=({onCollapsedToggle:e,isSidePanelCollapsed:t,setIsSidePanelCollapsed:n,isSidePanelTransitioning:r})=>{const{activeSidePanelTab:o,setActiveSidePanelTab:a,setPreviewArtifact:i,taskIdInSidePanel:l}=It(),{isReconnecting:c,isTaskMonitorConnecting:u,isTaskMonitorConnected:f,monitoredTasks:h,connectTaskMonitorStream:p,loadTaskFromBackend:m}=Pf(),[x,g]=d.useState(null),[v,w]=d.useState(!1),b=At.useRef(new Set);d.useEffect(()=>{if(!l){g(null);return}const j=h[l];if(!b.current.has(l))b.current.add(l),w(!0),m(l).then(A=>{if(!A)if(j&&j.events&&j.events.length>0){const I=bu(j.events,h,j);g(I)}else g(null)}).catch(()=>{if(j&&j.events&&j.events.length>0){const A=bu(j.events,h,j);g(A)}else g(null)}).finally(()=>{w(!1)});else if(j&&j.events&&j.events.length>0){const A=bu(j.events,h,j);g(A),w(!1)}else g(null)},[l,h,m]),d.useEffect(()=>{if(l)return()=>{setTimeout(()=>{b.current.delete(l)},1e3)}},[l]);const C=()=>v?{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:U1,buttonAction:p},_=()=>{const j=!t;n(j),e(j)},E=j=>{j==="files"&&i(null),a(j)},S=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(me,{"data-testid":"expandPanel",variant:"ghost",size:"sm",onClick:_,className:"h-10 w-10 p-0",tooltip:"Expand Panel",children:s.jsx(Ch,{className:"size-5"})}),s.jsx("div",{className:"bg-border my-4 h-px w-8"}),s.jsx(me,{variant:"ghost",size:"sm",onClick:()=>S("files"),className:"mb-2 h-10 w-10 p-0",tooltip:"Files",children:s.jsx(gr,{className:"size-5"})}),s.jsx(me,{variant:"ghost",size:"sm",onClick:()=>S("workflow"),className:"h-10 w-10 p-0",tooltip:"Workflow",children:s.jsx(Xi,{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(SI,{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(me,{"data-testid":"collapsePanel",variant:"ghost",onClick:_,className:"p-1",tooltip:"Collapse Panel",children:s.jsx(Ch,{className:"size-5"})}),s.jsxs(_I,{className:"grid w-full grid-cols-2 bg-transparent p-0",children:[s.jsxs(Kp,{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(gr,{className:"mr-2 h-4 w-4"}),"Files"]}),s.jsxs(Kp,{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(Xi,{className:"mr-2 h-4 w-4"}),"Workflow"]})]})]}),s.jsxs("div",{className:"min-h-0 flex-1",children:[s.jsx(qp,{value:"files",className:"m-0 h-full",children:s.jsx("div",{className:"h-full",children:s.jsx(OM,{})})}),s.jsx(qp,{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($M,{task:x}),s.jsx(wD,{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(Xi,{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(me,{onClick:j.buttonAction,children:[j.buttonIcon&&(()=>{const A=j.buttonIcon;return s.jsx(A,{className:"h-4 w-4"})})(),j.buttonText]})})]})})})()})})]})]})})})},bd=At.memo(({statusText:e,onViewWorkflow:t})=>s.jsxs("div",{className:"flex h-8 items-center space-x-3 py-1",children:[t?s.jsx(av,{onClick:t}):s.jsx(vP,{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})})]})),Im=({text:e,onClick:t})=>s.jsxs(me,{"data-testid":"startNewChat",variant:"ghost",onClick:t,tooltip:"Start New Chat Session",children:[s.jsx(_g,{className:"size-5"}),e]}),Hy=({buttonText:e})=>{const{handleNewSession:t}=It(),{persistenceEnabled:n}=sn(),[r,o]=d.useState(!1);return n?s.jsx(Im,{text:e,onClick:()=>t()}):s.jsx(Bo,{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(Im,{text:e})})},FM=({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(me,{variant:"ghost",onClick:e,"data-testid":"hideChatSessions",tooltip:"Hide Chat Sessions",children:s.jsx(kg,{className:"size-5"})}),s.jsx("div",{className:"text-xl",children:"Chats"})]}),s.jsx("div",{className:"flex items-center",children:s.jsx(Hy,{buttonText:"New Chat"})})]}),s.jsx("div",{className:"mt-1 min-h-0 flex-1",children:s.jsx(kM,{})})]}),_a=(e,t)=>s.jsx(Or,{type:t,className:"rounded-full border-none",children:s.jsx("span",{className:"text-xs font-semibold",title:e,children:e})}),zM=(e,t)=>{var r;if(e.currentStatusText)return s.jsx("div",{title:e.currentStatusText,children:s.jsx(bd,{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(bd,{statusText:n||e.status})});case"input-required":return _a("Input Required","info");case"completed":return _a("Completed","success");case"canceled":return _a("Canceled","info");case"failed":return _a("Failed","error");default:return _a("Unknown","info")}},$M=({task:e})=>{const{messages:t,addNotification:n,displayError:r}=It(),{configFeatureEnablement:o}=sn(),a=(o==null?void 0:o.taskLogging)??!1,i=d.useMemo(()=>{const c=t.find(u=>u.isStatusBubble);return e?zM(e,c):null},[t,e]),l=async()=>{try{const c=await je.webui.get(`/api/v1/tasks/${e.taskId}`,{fullResponse:!0});if(!c.ok)throw new Error(`Failed to download task log: ${c.statusText}`);const u=await c.blob();ni(u,`${e.taskId}.stim`),n("Task log downloaded","success")}catch(c){r({title:"Failed to Download Task Log",error:Ut(c,"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:i}),s.jsx("div",{children:a&&s.jsx(me,{variant:"ghost",size:"icon",onClick:l,tooltip:"Download Task Log (.stim)",disabled:!e.taskId,children:s.jsx(xo,{})})})]}):null};class Zy{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 Gy(e,t){return(t==null?void 0:t[e])||e}const wr={USER:50,MAIN_FLOW:300,TOOLS:600},UM=50,_n=50,cr=330,is=50,Wr=20,ls=10,Rm=_n+20,BM=90;function Lo(e,t,n){return e.push(n),t.add(n.id),n}function VM(e,t){return e.push(t),t}function Fo(e,t){return e.nodeIdCounter++,`${t.replace(/[^a-zA-Z0-9_]/g,"_")}_${e.nodeIdCounter}`}function Ln(e){return e.currentPhaseIndex===-1||e.currentPhaseIndex>=e.phases.length?null:e.phases[e.currentPhaseIndex]}function vi(e){const t=Ln(e);return!t||e.currentSubflowIndex===-1||e.currentSubflowIndex>=t.subflows.length?null:t.subflows[e.currentSubflowIndex]}function WM(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 HM(e,t){if(!t)return null;const n=Ln(e);return n&&n.subflows.findLast(r=>r.functionCallId===t)||null}function ZM(e,t){if(!t)return null;const n=Ln(e);return n&&n.subflows.findLast(r=>r.id===t)||null}function wi(e,t){var o;const n=Ln(e);if(!n)return null;if(t.functionCallId){const a=HM(e,t.functionCallId);if(a)return a}if(t.owningTaskId&&t.isSubTaskStep){const a=ZM(e,t.owningTaskId);if(a){const i=n.subflows||[];if(!(new Set(i.map(c=>c.id)).size!==i.length))return a}}const r=vi(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 Yy(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 oh(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 WM(e,t,n)}function GM(e,t,n){const r=Ln(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 Ky(r,l)}return null}function Ky(e,t){if(t.isParallel)return t;if(t.parentSubflowId){const n=e.subflows.find(r=>r.id===t.parentSubflowId);if(n)return Ky(e,n)}return null}function ta(e,t,n,r){const o=`phase_${e.phases.length}`,a=Fo(e,`${t}_${o}`),i=e.nextAvailableGlobalY,l=Gy(t,e.agentNameMap),c={id:a,type:"orchestratorNode",position:{x:wr.MAIN_FLOW,y:i},data:{label:l,visualizerStepId:n.id}};Lo(r,e.allCreatedNodeIds,c),e.nodePositions.set(a,c.position);const u={id:a,yPosition:i,height:_n,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+_n};return e.phases.push(h),e.currentPhaseIndex=e.phases.length-1,e.currentSubflowIndex=-1,e.nextAvailableGlobalY=h.maxY+is,h}function yd(e,t,n,r,o){var P,F,N,R,y;const a=Ln(e);if(!a)return null;const i=n.type==="AGENT_TOOL_EXECUTION_RESULT"&&((P=n.data.toolResult)==null?void 0:P.isPeerResponse)===!0,l=n.source||"",c=n.target||"",u=na(l);!i&&!u&&!o&&e.indentationLevel++;const f=((N=(F=n.delegationInfo)==null?void 0:F[0])==null?void 0:N.subTaskId)||n.owningTaskId,h=Fo(e,`${t}_${f}`),p=Fo(e,`group_${t}_${f}`),m=((y=(R=n.data)==null?void 0:R.toolInvocationStart)==null?void 0:y.functionCallId)||n.functionCallId||"";let x,g,v;const w=Array.from(e.parallelFlows.values()).find(T=>T.subflowFunctionCallIds.includes(m)),b=vi(e),C=GM(e,l,c);o&&w?(x=w.startX+w.currentXOffset,g=w.startY,v=g+Wr,w.currentXOffset+=(cr+ls)*2.2):C?(v=e.nextAvailableGlobalY,x=(C.groupNode.xPosition||wr.MAIN_FLOW-50)+e.indentationLevel*e.indentationStep,g=v-Wr):(v=e.nextAvailableGlobalY,x=wr.MAIN_FLOW-50+e.indentationLevel*e.indentationStep,g=v-Wr);const _=Gy(t,e.agentNameMap),E={id:h,type:"genericAgentNode",position:{x:50,y:Wr},data:{label:_,visualizerStepId:n.id},parentId:p},S={id:p,type:"group",position:{x,y:g},data:{label:`${_} Sub-flow`},style:{backgroundColor:"rgba(220, 220, 255, 0.1)",border:"1px solid #aac",borderRadius:"8px",minHeight:`${_n+2*Wr}px`}};Lo(r,e.allCreatedNodeIds,S),Lo(r,e.allCreatedNodeIds,E),e.nodePositions.set(h,E.position),e.nodePositions.set(p,S.position);const j={id:h,xPosition:wr.MAIN_FLOW,yPosition:v,height:_n,width:cr},A={id:h,name:t,type:"peer",phaseId:a.id,subflowId:f,context:"subflow",nodeInstance:j};e.agentRegistry.registerAgent(A);const I={id:f,functionCallId:m,isParallel:o,peerAgent:j,groupNode:{id:p,xPosition:x,yPosition:g,height:_n+2*Wr,width:0},toolInstances:[],currentToolYOffset:0,maxY:v+_n,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(I),C&&(C.lastSubflow=I),e.currentSubflowIndex=a.subflows.length-1,o&&w?(w.maxHeight=Math.max(w.maxHeight,I.groupNode.height),e.nextAvailableGlobalY=w.startY+w.maxHeight+is):e.nextAvailableGlobalY=I.groupNode.yPosition+I.groupNode.height+is,I}function qy(e,t,n,r,o,a,i=!1){const l=Ln(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 p,m,x,g;if(a){if(p=a.peerAgent.yPosition+a.currentToolYOffset,a.currentToolYOffset+=Rm,x=50+300,a.groupNode.xPosition===void 0||a.groupNode.yPosition===void 0)return null;m=a.groupNode.xPosition+x,g=p-a.groupNode.yPosition}else m=wr.TOOLS,p=l.orchestratorAgent.yPosition+l.currentToolYOffset,l.currentToolYOffset+=Rm,x=m,g=p;const v=Fo(e,`${f}_${r.id}`),w={id:v,type:n,position:{x,y:g},data:{label:u,visualizerStepId:r.id,toolName:t},parentId:h};Lo(o,e.allCreatedNodeIds,w),e.nodePositions.set(v,{x,y:g});const b={id:v,xPosition:m,yPosition:p,height:_n,width:cr,functionCallId:r.functionCallId};c.push(b);const C=p+_n;if(a){a.maxY=Math.max(a.maxY,C),a.maxContentXRelative=Math.max(a.maxContentXRelative,x+cr);const _=a.maxY-a.groupNode.yPosition+Wr;a.groupNode.height=Math.max(a.groupNode.height,_);const E=a.maxContentXRelative+ls;a.groupNode.width=Math.max(a.groupNode.width||0,E);const S=o.find(j=>j.id===a.groupNode.id);S&&(S.style={...S.style,height:`${a.groupNode.height}px`,width:`${a.groupNode.width}px`}),e.nextAvailableGlobalY=Math.max(e.nextAvailableGlobalY,a.groupNode.yPosition+a.groupNode.height+is)}else l.maxY=Math.max(l.maxY,C),e.nextAvailableGlobalY=Math.max(e.nextAvailableGlobalY,l.maxY+is);return b}function sh(e,t,n,r){e.userNodeCounter++;const o=Fo(e,`User_response_${e.userNodeCounter}`),a=e.nextAvailableGlobalY+20,i={id:o,type:"userNode",position:{x:wr.USER,y:a},data:{label:"User",visualizerStepId:n.id,isBottomNode:!0}};Lo(r,e.allCreatedNodeIds,i),e.nodePositions.set(o,i.position);const l={id:o,yPosition:a,height:_n,width:cr};t.userNodes.push(l),e.allUserNodes.push(l);const c=a+_n;return t.maxY=Math.max(t.maxY,c),l}function Jn(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(m=>m.id===h)){const m=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:m,type:"defaultFlowEdge",data:{visualizerStepId:n.id,isAnimated:x,animationType:x?"request":"static",duration:1}};l&&(g.sourceHandle=l),c&&(g.targetHandle=c),VM(r,g)}}function YM(){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 Cd(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 na(e){return e==="OrchestratorAgent"||e.toLowerCase().includes("orchestrator")}const KM=["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","AGENT_ARTIFACT_NOTIFICATION","TASK_COMPLETED","TASK_FAILED"];function qM(e,t,n,r,o,a){const i=e.target,l=i.replace(/[^a-zA-Z0-9_]/g,"_"),c=Ln(t),u=vi(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 p=Fo(t,`User_continue_${t.userNodeCounter}`),m=t.nextAvailableGlobalY,x={id:p,type:"userNode",position:{x:wr.USER,y:m},data:{label:"User",visualizerStepId:e.id}};Lo(n,t.allCreatedNodeIds,x),t.nodePositions.set(p,x.position);const g={id:p,yPosition:m,height:_n,width:cr};c.userNodes.push(g),t.allUserNodes.push(g);const v=m+_n;f.yPosition=Math.max(f.yPosition,m),c.maxY=Math.max(c.maxY,v,f.yPosition+_n),t.nextAvailableGlobalY=c.maxY+is;const w=na(i)?"orch-left-input":"peer-left-input";Jn(g.id,f.id,e,r,t,o,a,"user-right-output",w)}else{const p=ta(t,i,e,n),m=Fo(t,`User_${p.id}`),x={id:m,type:"userNode",position:{x:wr.USER,y:p.orchestratorAgent.yPosition-BM},data:{label:"User",visualizerStepId:e.id,isTopNode:!0}};Lo(n,t.allCreatedNodeIds,x),t.nodePositions.set(m,x.position);const g={id:m,yPosition:x.position.y,height:_n,width:cr};p.userNodes.push(g),t.allUserNodes.push(g),t.userNodeCounter++,p.maxY=Math.max(p.maxY,x.position.y+_n),t.nextAvailableGlobalY=p.maxY+is,Jn(m,p.orchestratorAgent.id,e,r,t,o,a,"user-bottom-output","orch-top-input")}}function XM(e,t,n,r,o,a){const i=Ln(t);if(!i)return;const l=wi(t,e),c=l?l.peerAgent.id:i.orchestratorAgent.id,u=qy(t,"LLM","llmNode",e,n,l,!0);u&&Jn(c,u.id,e,r,t,o,a,l?"peer-right-output-tools":"orch-right-output-tools","llm-left-input")}function JM(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(v=>v.isPeerDelegation).length>1&&t.parallelFlows.set(g,{subflowFunctionCallIds:e.data.toolDecision.decisions.filter(v=>v.isPeerDelegation).map(v=>v.functionCallId),completedSubflows:new Set,startX:wr.MAIN_FLOW-50,startY:t.nextAvailableGlobalY,currentXOffset:0,maxHeight:0})}const i=Ln(t);if(!i)return;const l=wi(t,e);let c;const f=oh((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 p,m;l?(p=l.peerAgent.id,m="peer-right-input-tools"):i.orchestratorAgent.id.startsWith(h.replace(/[^a-zA-Z0-9_]/g,"_")+"_")&&(p=i.orchestratorAgent.id,m="orch-right-input-tools"),c&&p&&m?Jn(c,p,e,r,t,o,a,"llm-bottom-output",m):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 QM(e,t,n,r,o,a){var f;const i=Ln(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,p=t.agentRegistry.findAgentByName(l);if(!p){console.error(`[Timeline] Could not find source agent in registry: ${l} for step ${e.id}`);return}const m=p.nodeInstance,x=Cd(p.type,"output","bottom"),g=Yy(e,t),v=yd(t,h,e,n,g);v&&Jn(m.id,v.peerAgent.id,e,r,t,o,a,x,"peer-top-input")}else{const h=wi(t,e);let p,m;if(h)p=h.peerAgent.id,m="peer-right-output-tools";else{const g=t.agentRegistry.findAgentByName(l);g?(p=g.id,m=Cd(g.type,"output","right")):(p=i.orchestratorAgent.id,m="orch-right-output-tools")}const x=qy(t,c,"genericToolNode",e,n,h);x&&Jn(p,x.id,e,r,t,o,a,m,`${x.id}-tool-left-input`)}}function eD(e,t,n,r,o,a){var u,f;const i=Ln(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,p=Array.from(t.parallelFlows.entries()).find(([x,g])=>g.subflowFunctionCallIds.includes(h||""));if(p){const[x,g]=p;if(g.completedSubflows.add(h||""),g.completedSubflows.size<g.subflowFunctionCallIds.length)return;const v=i.subflows.filter(_=>g.subflowFunctionCallIds.includes(_.functionCallId)),w=e.target||"OrchestratorAgent";let b,C;if(na(w))t.indentationLevel=0,b=ta(t,w,e,n).orchestratorAgent,C="orch-top-input",t.currentSubflowIndex=-1;else{t.indentationLevel=Math.max(0,t.indentationLevel-1);const _=yd(t,w,e,n,!1);if(!_)return;b=_.peerAgent,C="peer-top-input"}v.forEach(_=>{var E;Jn(((E=_.lastSubflow)==null?void 0:E.peerAgent.id)??_.peerAgent.id,b.id,e,r,t,o,a,"peer-bottom-output",C)}),t.parallelFlows.delete(x);return}const m=t.agentRegistry.findAgentByName(l.startsWith("peer_")?l.substring(5):l);if(!m){console.error(`[Timeline] Source peer agent not found for peer response: ${l}.`);return}if(na(c)){t.indentationLevel=0;const x=ta(t,c,e,n);Jn(m.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=Yy(e,t)||Array.from(t.parallelFlows.values()).some(v=>v.subflowFunctionCallIds.some(w=>i.subflows.some(b=>b.functionCallId===w))),g=yd(t,c,e,n,x);g&&Jn(m.id,g.peerAgent.id,e,r,t,o,a,"peer-bottom-output","peer-top-input")}}else{let h;const p=wi(t,e),x=oh((p||i).toolInstances,l,n,e.functionCallId);if(x&&(h=x.id),h){let g,v;if(p)g=p.peerAgent.id,v="peer-right-input-tools";else{const w=t.agentRegistry.findAgentByName(c);w?(g=w.id,v=Cd(w.type,"input","right")):(g=i.orchestratorAgent.id,v="orch-right-input-tools")}Jn(h,g,e,r,t,o,a,l==="LLM"?"llm-bottom-output":`${h}-tool-bottom-output`,v)}else console.error(`[Timeline] Could not find source tool node for regular tool result: ${e.id}. Step source (tool name): ${l}.`)}}function tD(e,t,n,r,o,a){const i=Ln(t);if(!i)return;const l=e.data.artifactNotification,c=(l==null?void 0:l.artifactName)||"Unnamed Artifact",u=wi(t,e),f=u||i;let h;e.functionCallId&&(h=oh(f.toolInstances,"",n,e.functionCallId)??void 0),!h&&f.toolInstances.length>0&&(h=f.toolInstances[f.toolInstances.length-1]);let p,m;if(h)p=h.id,m=`${h.id}-tool-right-output-artifact`;else return;const x=Fo(t,`Artifact_${c}_${e.id}`),g=u?u.groupNode.id:void 0;let v,w;const b=300,C=100;if(u){const A=n.find(F=>F.id===h.id);let I,P;if(A)I=A.position.x,P=A.position.y;else{const F=u.groupNode.xPosition??wr.TOOLS;I=(h.xPosition??wr.TOOLS)-F,P=(h.yPosition??t.nextAvailableGlobalY)-(u.groupNode.yPosition??t.nextAvailableGlobalY)}v=I+b,w=P}else v=(h.xPosition??wr.TOOLS)+b,w=h.yPosition??t.nextAvailableGlobalY;const _={id:x,type:"artifactNode",position:{x:v,y:w},data:{label:"Artifact",visualizerStepId:e.id},parentId:g};Lo(n,t.allCreatedNodeIds,_),t.nodePositions.set(x,{x:v,y:w});const E={id:x};Jn(p,E.id,e,r,t,o,a,m,`${E.id}-artifact-left-input`);const S=w+_n,j=v+cr;if(u){u.maxY=Math.max(u.maxY,S),u.maxContentXRelative=Math.max(u.maxContentXRelative,j-C);const A=u.maxContentXRelative+ls;u.groupNode.width=Math.max(u.groupNode.width||0,A);const I=n.find(P=>P.id===u.groupNode.id);I&&I.style&&(I.style.width=`${u.groupNode.width}px`)}i.maxY=Math.max(i.maxY,S)}function nD(e,t,n,r,o,a){const i=Ln(t);if(!i||e.isSubTaskStep)return;const l=i.orchestratorAgent.id,c=sh(t,i,e,n);Jn(l,c.id,e,r,t,o,a,"orch-bottom-output","user-top-input")}function rD(e,t,n,r,o,a){const i=Ln(t);if(!i)return;const l=Array.from(t.parallelFlows.values()).find(m=>m.subflowFunctionCallIds.includes(e.functionCallId||""));if(l){if(l.completedSubflows.add(e.functionCallId||""),l.completedSubflows.size===l.subflowFunctionCallIds.length){t.indentationLevel=0;const m=ta(t,"OrchestratorAgent",e,n);i.subflows.forEach(x=>{l.subflowFunctionCallIds.includes(x.functionCallId)&&Jn(x.peerAgent.id,m.orchestratorAgent.id,e,r,t,o,a,"peer-bottom-output","orch-top-input")}),t.currentSubflowIndex=-1}return}if(!e.isSubTaskStep)return;const c=vi(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(m=>typeof m.data.label=="string"&&na(m.data.label));let h,p;f?(t.indentationLevel=0,h=ta(t,"OrchestratorAgent",e,n).orchestratorAgent.id,p="orch-top-input"):(h=sh(t,i,e,n).id,p="user-top-input"),Jn(u.id,h,e,r,t,o,a,"peer-bottom-output",p),t.currentSubflowIndex=-1}function oD(e,t,n,r){const o=Ln(t);if(!o)return;const a=e.source||"UnknownSource",i=e.target||"User";let l,c="orch-bottom-output";const u=vi(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 p of o.subflows)if(p.peerAgent.id.includes(a.replace(/[^a-zA-Z0-9_]/g,"_"))){l=p.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;na(i)?(t.indentationLevel=0,f=ta(t,i,e,n).orchestratorAgent.id,h="orch-top-input",t.currentSubflowIndex=-1):(f=sh(t,o,e,n).id,h="user-top-input"),sD(l.id,f,e,r,t,c,h)}function sD(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(p=>p.id===u)){const p=((h=n.data.errorDetails)==null?void 0:h.message)||"Task failed",m=p.length>30?"Error":p,x={id:u,source:e,target:t,label:m,type:"defaultFlowEdge",data:{visualizerStepId:n.id,isAnimated:!1,animationType:"static",isError:!0,errorMessage:p}};a&&(x.sourceHandle=a),i&&(x.targetHandle=i),r.push(x)}}const aD=(e,t={})=>{const n=[],r=[];if(!e||e.length===0)return{nodes:n,edges:r};const o=new Zy,a={phases:[],currentPhaseIndex:-1,currentSubflowIndex:-1,parallelFlows:new Map,nextAvailableGlobalY:UM,nodeIdCounter:0,allCreatedNodeIds:new Set,nodePositions:new Map,allUserNodes:[],userNodeCounter:0,agentRegistry:YM(),indentationLevel:0,indentationStep:50,agentNameMap:t},i=e.filter(u=>KM.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":qM(u,a,n,r,o,e);break;case"AGENT_LLM_CALL":XM(u,a,n,r,o,e);break;case"AGENT_LLM_RESPONSE_TO_AGENT":case"AGENT_LLM_RESPONSE_TOOL_DECISION":JM(u,a,n,r,o,e);break;case"AGENT_TOOL_INVOCATION_START":QM(u,a,n,r,o,e);break;case"AGENT_TOOL_EXECUTION_RESULT":eD(u,a,n,r,o,e);break;case"AGENT_RESPONSE_TEXT":nD(u,a,n,r,o,e);break;case"AGENT_ARTIFACT_NOTIFICATION":tD(u,a,n,r,o,e);break;case"TASK_COMPLETED":rD(u,a,n,r,o,e);break;case"TASK_FAILED":oD(u,a,n,r);break}return a.phases.forEach(u=>{u.subflows.forEach(f=>{const h=n.find(p=>p.id===f.groupNode.id);if(h&&h.style){const m=f.maxY-f.groupNode.yPosition+Wr;h.style.height=`${Math.max(_n+2*Wr,m)}px`;const x=f.maxContentXRelative+ls,g=cr+2*ls+a.indentationLevel*a.indentationStep;h.style.width=`${Math.max(x,g)}px`}})}),{nodes:n,edges:r}},iD=({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),[p]=B1({sourceX:t,sourceY:n,sourcePosition:a,targetX:r,targetY:o,targetPosition:i}),m=()=>{const v={strokeWidth:f?3:2,stroke:"var(--color-muted-foreground)",...l},w=u;return w!=null&&w.isError?{...v,stroke:f?"var(--color-error-wMain)":"var(--color-error-w70)",strokeWidth:f?3:2}:w!=null&&w.isSelected?{...v,stroke:"#3b82f6",strokeWidth:3}:w!=null&&w.isAnimated?{...v,stroke:f?"#1d4ed8":"#3b82f6",strokeWidth:f?4:3}:f?{...v,stroke:"var(--edge-hover-color)"}:v},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:p,onMouseEnter:x,onMouseLeave:g}),s.jsx("path",{id:e,style:{...m(),cursor:"pointer",transition:"all 0.2s ease-in-out"},className:"react-flow__edge-path",d:p,markerEnd:c,onMouseEnter:x,onMouseLeave:g})]})},lD=({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(yn,{type:"target",position:Cn.Top,id:"peer-top-input",className:"!bg-blue-700",isConnectable:!0}),s.jsx(yn,{type:"source",position:Cn.Right,id:"peer-right-output-tools",className:"!bg-blue-700",style:{top:"25%"},isConnectable:!0}),s.jsx(yn,{type:"target",position:Cn.Right,id:"peer-right-input-tools",className:"!bg-blue-700",style:{top:"75%"},isConnectable:!0}),s.jsx(yn,{type:"source",position:Cn.Bottom,id:"peer-bottom-output",className:"!bg-blue-700",isConnectable:!0}),s.jsx(yn,{type:"target",position:Cn.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})})]}),cD=({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(yn,{type:"target",position:Cn.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(yn,{type:"source",position:Cn.Left,id:`${t}-tool-bottom-output`,className:"!bg-cyan-500",isConnectable:!0,style:{top:"75%"}}),s.jsx(yn,{type:"source",position:Cn.Right,id:`${t}-tool-right-output-artifact`,className:"!bg-cyan-500",isConnectable:!0,style:{top:"50%"}})]})},uD=({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(yn,{type:"target",position:Cn.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(yn,{type:"source",position:Cn.Left,id:"llm-bottom-output",className:"!bg-teal-500",isConnectable:!0,style:{top:"75%"}})]})},dD=({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(yn,{type:"source",position:Cn.Right,id:"orch-right-output-tools",className:"!bg-indigo-500",style:{top:"25%"},isConnectable:!0}),s.jsx(yn,{type:"target",position:Cn.Right,id:"orch-right-input-tools",className:"!bg-indigo-500",style:{top:"75%"},isConnectable:!0}),s.jsx(yn,{type:"target",position:Cn.Top,id:"orch-top-input",className:"!bg-indigo-500",isConnectable:!0}),s.jsx(yn,{type:"source",position:Cn.Bottom,id:"orch-bottom-output",className:"!bg-indigo-500",isConnectable:!0}),s.jsx(yn,{type:"target",position:Cn.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})})]}),fD=({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(yn,{type:"source",position:Cn.Bottom,id:"user-bottom-output",className:"!bg-gray-500",isConnectable:!0}),e.isBottomNode&&s.jsx(yn,{type:"target",position:Cn.Top,id:"user-top-input",className:"!bg-gray-500",isConnectable:!0}),!e.isTopNode&&!e.isBottomNode&&s.jsx(yn,{type:"source",position:Cn.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})]})]})},hD=({data:e,id:t})=>s.jsxs("div",{className:"cursor-pointer rounded-lg border-2 border-purple-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-purple-400 dark:bg-gray-800 dark:text-gray-200",style:{minWidth:"120px",textAlign:"center"},children:[s.jsx(yn,{type:"target",position:Cn.Left,id:`${t}-artifact-left-input`,className:"!bg-purple-500",isConnectable:!0}),s.jsx("div",{className:"flex flex-col items-center justify-center gap-1",children:s.jsxs("div",{className:"flex items-center justify-center",children:[s.jsx("div",{className:"mr-2 h-2 w-2 rounded-full bg-purple-500"}),s.jsx("div",{className:"text-md",children:e.label})]})})]}),pD=({step:e,isHighlighted:t,onClick:n,variant:r="list"})=>{const{artifacts:o,setPreviewArtifact:a,setActiveSidePanelTab:i,setIsSidePanelCollapsed:l,navigateArtifactVersion:c}=It(),u=()=>{var S,j,A;switch(e.type){case"USER_REQUEST":return s.jsx(dl,{className:"mr-2 text-blue-500 dark:text-blue-400",size:18});case"AGENT_RESPONSE_TEXT":return s.jsx(Dc,{className:"mr-2 text-teal-500 dark:text-teal-400",size:18});case"TASK_COMPLETED":return s.jsx(Pd,{className:"mr-2 text-green-500 dark:text-green-400",size:18});case"TASK_FAILED":return s.jsx(mg,{className:"mr-2 text-red-500 dark:text-red-400",size:18});case"AGENT_LLM_CALL":return s.jsx(Dc,{className:"mr-2 text-purple-500 dark:text-purple-400",size:18});case"AGENT_LLM_RESPONSE_TO_AGENT":return s.jsx(Dc,{className:"mr-2 text-teal-500 dark:text-teal-400",size:18});case"AGENT_LLM_RESPONSE_TOOL_DECISION":{const I=(j=(S=e.data.toolDecision)==null?void 0:S.decisions)==null?void 0:j[0];return(I==null?void 0:I.isPeerDelegation)?s.jsx(Sh,{className:"mr-2 text-orange-500 dark:text-orange-400",size:18}):s.jsx(_h,{className:"mr-2 text-orange-500 dark:text-orange-400",size:18})}case"AGENT_TOOL_INVOCATION_START":return(A=e.data.toolInvocationStart)!=null&&A.isPeerInvocation?s.jsx(Sh,{className:"mr-2 text-cyan-500 dark:text-cyan-400",size:18}):s.jsx(_h,{className:"mr-2 text-cyan-500 dark:text-cyan-400",size:18});case"AGENT_TOOL_EXECUTION_RESULT":return s.jsx(W1,{className:"mr-2 text-teal-500 dark:text-teal-400",size:18});case"AGENT_ARTIFACT_NOTIFICATION":return s.jsx(gr,{className:"mr-2 text-indigo-500 dark:text-indigo-400",size:18});default:return s.jsx(jg,{className:"mr-2 text-gray-500 dark:text-gray-400",size:18})}},f=new Date(e.timestamp).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"}),h=String(new Date(e.timestamp).getMilliseconds()).padStart(3,"0"),p=`${f}.${h}`,m=S=>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:"})," ",S.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:S.promptPreview})]}),x=({data:S})=>{const[j,A]=At.useState(!1),I=P=>{P.stopPropagation(),A(!j)};return j?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:I,className:"text-xs text-blue-500 underline hover:text-blue-700 dark:text-blue-400 dark:hover:text-blue-300",children:"Hide details"})]}),S.modelName&&s.jsxs("p",{children:[s.jsx("strong",{children:"Model:"})," ",S.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:S.responsePreview})]}),S.isFinalResponse!==void 0&&s.jsxs("p",{className:"mt-1",children:[s.jsx("strong",{children:"Final Response:"})," ",S.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:I,className:"text-xs text-blue-500 underline hover:text-blue-700 dark:text-blue-400 dark:hover:text-blue-300",children:"Show details"})]})},g=S=>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:["🔧 ",S.isParallel?"Parallel Tool Calls:":"Tool Call:"]})}),s.jsx("ul",{className:"space-y-1 pl-2",children:S.decisions.map(j=>s.jsxs("li",{className:"flex items-center",children:[s.jsx("span",{className:"mr-2",children:"•"}),s.jsx("code",{children:j.toolName})]},j.functionCallId))})]}),v=S=>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:"})," ",S.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(Td,{data:S.toolArguments})})]}),w=S=>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:"})," ",S.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 S.resultData=="object"?s.jsx(Td,{data:S.resultData}):s.jsx("pre",{className:"font-mono text-xs break-all whitespace-pre-wrap",children:String(S.resultData)})})]}),b=S=>{const j=async A=>{A.stopPropagation();const I=o.find(P=>P.filename===S.artifactName);I&&(i("files"),l(!1),a(I),S.version!==void 0&&S.version!==I.version&&setTimeout(()=>{c(I.filename,S.version)},100))};return 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:"flex items-center justify-between",children:[s.jsxs("p",{children:[s.jsx("strong",{children:"Artifact:"})," ",S.artifactName,S.version!==void 0&&s.jsxs("span",{className:"text-gray-500 dark:text-gray-400",children:[" (v",S.version,")"]})]}),s.jsxs("button",{onClick:j,className:"flex items-center gap-1 text-blue-600 transition-colors hover:text-blue-800 dark:text-blue-400 dark:hover:text-blue-300",title:"View in Files tab",children:[s.jsx("span",{className:"text-xs",children:"View File"}),s.jsx(V1,{size:12})]})]}),S.mimeType&&s.jsxs("p",{children:[s.jsx("strong",{children:"Type:"})," ",S.mimeType]}),S.description&&s.jsxs("p",{className:"mt-1",children:[s.jsx("strong",{children:"Description:"})," ",S.description]})]})},C=r==="list"&&e.nestingLevel&&e.nestingLevel>0?{marginLeft:`${e.nestingLevel*24}px`}:{},_=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
+ `,E=()=>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:_,style:C,onClick:n,children:[s.jsxs("div",{className:"mb-1.5 flex w-full items-center gap-1",children:[u(),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:p})]})]}),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(S=>s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center font-semibold text-blue-700 dark:text-blue-300",children:[s.jsx(Sg,{className:"mr-2 h-4 w-4 flex-shrink-0"}),s.jsxs("span",{children:[E(),S.peerAgentName]})]}),S.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:S.subTaskId,children:[S.subTaskId.substring(0,15),"..."]})]})]},S.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(Vs,{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(Vs,{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&&m(e.data.llmCall),e.data.llmResponseToAgent&&s.jsx(x,{data:e.data.llmResponseToAgent}),e.data.toolDecision&&g(e.data.toolDecision),e.data.toolInvocationStart&&v(e.data.toolInvocationStart),e.data.toolResult&&w(e.data.toolResult),e.data.artifactNotification&&b(e.data.artifactNotification)]})},mD={genericAgentNode:lD,userNode:fD,llmNode:uD,orchestratorNode:dD,genericToolNode:cD,artifactNode:hD},gD={defaultFlowEdge:iD},xD={x:16,y:0},vD=({processedSteps:e,isRightPanelVisible:t=!1,isSidePanelTransitioning:n=!1})=>{const[r,o,a]=Z1([]),[i,l,c]=G1([]),{fitView:u}=Y1(),{highlightedStepId:f,setHighlightedStepId:h}=Pf(),{taskIdInSidePanel:p,agentNameDisplayNameMap:m}=It(),x=d.useRef([]),[g,v]=d.useState(!1),[w,b]=d.useState(null),[C,_]=d.useState(!1),E=d.useRef(null),[S,j]=d.useState(null),A=d.useRef(new Zy),I=d.useMemo(()=>!e||e.length===0?{nodes:[],edges:[]}:aD(e,m),[e,m]),P=d.useMemo(()=>I.edges.length?I.edges.map(O=>{const M=O.data;let J={isAnimated:!1,animationType:"none"};if(M!=null&&M.visualizerStepId){const H=e.length-1;J=A.current.getEdgeAnimationState(M.visualizerStepId,H,e)}let z=O.id===S;return f&&(M==null?void 0:M.visualizerStepId)===f&&(z=!0),{...O,animated:J.isAnimated,data:{...M,isAnimated:J.isAnimated,animationType:J.animationType,isSelected:z}}}):[],[I.edges,e,S,f]),F=d.useCallback(()=>{o(O=>O.map(M=>{var ue,ce,pe,k;if(M.type!=="group")return M;const J=O.filter(oe=>oe.parentId===M.id);if(J.length===0)return M;let z=0,H=0;J.forEach(oe=>{const ae=oe.position.x+cr,G=oe.position.y+_n;z=Math.max(z,ae),H=Math.max(H,G)});const U=z+ls,X=H+Wr;let W=0;const te=M.id.split("_");if(te.length>2){const oe=te.find(ae=>ae.startsWith("subflow"));if(oe){const ae=parseInt(oe.replace("subflow",""));isNaN(ae)||(W=ae)}}const $=cr+2*ls+W*50,q=Math.max(U,$),Y=parseInt(((ce=(ue=M.style)==null?void 0:ue.width)==null?void 0:ce.toString().replace("px",""))||"0"),re=parseInt(((k=(pe=M.style)==null?void 0:pe.height)==null?void 0:k.toString().replace("px",""))||"0");return Y!==q||re!==X?{...M,style:{...M.style,width:`${q}px`,height:`${X}px`}}:M}))},[o]);d.useEffect(()=>{o(I.nodes),l(P),F()},[I.nodes,P,o,l,F]);const N=d.useCallback((O,M)=>i.find(J=>J.source===O&&(M?J.sourceHandle===M:!0))||null,[i]),R=d.useCallback((O,M)=>{var z;v(!0);const J=(z=M.data)==null?void 0:z.visualizerStepId;if(J){const H=e.find(U=>U.id===J);H&&(j(M.id),t?h(J):(h(J),b(H),_(!0)))}},[e,t,h]),y=d.useCallback(O=>{switch(O.type){case"userNode":{const M=O.data;return M!=null&&M.isTopNode?["user-bottom-output"]:M!=null&&M.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[`${O.id}-tool-bottom-output`];default:return[]}},[]),T=d.useCallback(()=>{_(!1),b(null)},[]),D=d.useCallback((O,M)=>{if(v(!0),M.type==="group"){h(null),j(null),T();return}const J=y(M);let z=null;for(const H of J)if(z=N(M.id,H),z)break;if(!z&&M.type==="userNode"){const H=M.data;H!=null&&H.isBottomNode&&(z=i.find(U=>U.target===M.id)||null)}!z&&M.type==="artifactNode"&&(z=i.find(H=>H.target===M.id)||null),z&&R(O,z)},[y,h,T,N,i,R]),L=d.useCallback(O=>{O!=null&&O.isTrusted&&v(!0)},[]);return d.useEffect(()=>{v(!1)},[p]),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(O=>O.map(M=>{var U;const J=((U=M.data)==null?void 0:U.visualizerStepId)&&M.data.visualizerStepId===f,z=I.nodes.find(X=>X.id===M.id),H=(z==null?void 0:z.style)||{};return{...M,style:{...H,boxShadow:J?"0px 4px 12px rgba(0, 0, 0, 0.2)":H.boxShadow||"none",transition:"box-shadow 0.2s ease-in-out"}}})),f){const O=P.find(M=>{const J=M.data;return(J==null?void 0:J.visualizerStepId)===f});O&&j(O.id)}else j(null)},[f,o,I.nodes,P]),!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."}):I.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(K1,{nodes:r,edges:i.map(O=>({...O,markerEnd:{type:Q1.ArrowClosed,color:"#888"}})),onNodesChange:a,onEdgesChange:c,onEdgeClick:R,onNodeClick:D,onPaneClick:()=>{h(null),j(null),T()},onMoveStart:L,nodeTypes:mD,edgeTypes:gD,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(q1,{}),s.jsx(X1,{className:Ck()}),s.jsx(J1,{position:"top-right",className:"flex items-center space-x-4",children:s.jsx("div",{ref:E})})]}),s.jsx(aA,{isOpen:C,onClose:T,anchorRef:E,offset:xD,placement:"right-start",className:"max-w-[500px] min-w-[400px] p-2",children:w&&s.jsx(pD,{step:w,variant:"popover"})})]})},wD=e=>s.jsx(H1,{children:s.jsx(vD,{...e})}),Xy=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}},ka=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},Jy=(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;Xy(l)===e&&(a=a.concat(Jy(l.taskId,t,n,r+1)))}return a},bu=(e,t,n)=>{var O,M,J,z,H;if(!n)return null;if(!((O=n.events)==null?void 0:O.some(U=>U.direction==="request"&&U.task_id===n.taskId))&&n.initialRequestText&&n.events&&n.events.length>0){const U=((M=n.events[0])==null?void 0:M.timestamp)||n.firstSeen.toISOString(),X=new Date(new Date(U).getTime()-1).toISOString();let W="Orchestrator";const te=n.events[0];te!=null&&te.source_entity?W=te.source_entity:(H=(z=(J=te==null?void 0:te.full_payload)==null?void 0:J.result)==null?void 0:z.metadata)!=null&&H.agent_name&&(W=te.full_payload.result.metadata.agent_name);const $={task_id:n.taskId,direction:"request",timestamp:X,source_entity:"User",target_entity:W,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=[$,...n.events]}const o={overall:{totalTaskDurationMs:0},agents:{}},a=new Map,i=new Map,l=(U,X)=>(o.agents[U]||(o.agents[U]={agentName:X,instanceId:U,displayName:X,llmCalls:[],toolCalls:[],totalLlmTimeMs:0,totalToolTimeMs:0}),o.agents[U]),c=new Map,u=new Map,f=Jy(n.taskId,t,c,0);if(f.length===0)return{taskId:n.taskId,initialRequestText:n.initialRequestText,status:"working",startTime:n.firstSeen.toISOString(),steps:[]};const h=f.sort((U,X)=>new Date(ka(U)).getTime()-new Date(ka(X)).getTime()),p=[];let m,x="",g,v,w=[],b=null,C;const _=new Map,E=new Map,S=new Map,j=U=>{if(x.trim()&&g&&v){const X=x.trim();let W=n.taskId;if(w.length>0){const q=w[0].split("-");q.length>2&&q[1]!=="global"&&(W=q.slice(1,q.length-1).join("-"))}else U&&(W=U);const te=c.get(W)??0,$=_.get(W)||S.get(W);p.push({id:`vstep-agenttext-${p.length}-${w[0]||"unknown"}`,type:"AGENT_RESPONSE_TEXT",timestamp:v,title:`${g}: Response`,source:g,target:"User",data:{text:X},rawEventIds:[...w],isSubTaskStep:te>0,nestingLevel:te,owningTaskId:W,functionCallId:$}),b=X}x="",g=void 0,v=void 0,w=[],C=void 0};h.forEach((U,X)=>{var oe,ae,G,V,ne,B,K,Z,le,de,se,he,Ee,Ae,pt,Lt,jt,Rt,it,Ot,Jt,Ft,xe,Re,Ie,Pe,ot,Me,Pt,Ke,st,yt,en,Rn,ee,ie,fe,we,ye,Le,$e,De,Ve,Xe,We;const W=ka(U),te=`raw-${U.task_id||"global"}-${X}`,$=U.full_payload,q=U.task_id||n.taskId,Y=c.get(q)??0;let re=U.source_entity||"UnknownAgent";(G=(ae=(oe=$==null?void 0:$.params)==null?void 0:oe.message)==null?void 0:ae.metadata)!=null&&G.agent_name?re=$.params.message.metadata.agent_name:(ne=(V=$==null?void 0:$.result)==null?void 0:V.metadata)!=null&&ne.agent_name?re=$.result.metadata.agent_name:(le=(Z=(K=(B=$==null?void 0:$.result)==null?void 0:B.status)==null?void 0:K.message)==null?void 0:Z.metadata)!=null&&le.agent_name?re=$.result.status.message.metadata.agent_name:(he=(se=(de=$==null?void 0:$.result)==null?void 0:de.artifact)==null?void 0:se.metadata)!=null&&he.agent_name&&(re=$.result.artifact.metadata.agent_name);let ue;if(Y>0?ue=_.get(q):ue=S.get(q),U.direction==="request"&&Y>0){const Ce=(Ee=$.params)==null?void 0:Ee.metadata,ke=Ce==null?void 0:Ce.function_call_id,Je=U.task_id;if(Je&&ke){_.set(Je,ke);return}}if(U.payload_summary.method&&U.payload_summary.method==="tasks/cancel")return;if(U.direction==="request"&&Y===0&&U.task_id===n.taskId){j(q),b=null;const Ce=$.params;let ke="User request";if((Ae=Ce==null?void 0:Ce.message)!=null&&Ae.parts){const Je=Ce.message.parts.filter(He=>He.kind==="text"&&He.text);Je.length>0&&(ke=Je[Je.length-1].text)}p.push({id:`vstep-userreq-${p.length}-${te}`,type:"USER_REQUEST",timestamp:W,title:"User Input",source:"User",target:U.target_entity||re,data:{text:ke},rawEventIds:[te],isSubTaskStep:!1,nestingLevel:0,owningTaskId:q});return}if(U.direction==="status-update"&&($!=null&&$.result)){const Ce=$.result,ke=(pt=Ce.status)==null?void 0:pt.message,Je=ke==null?void 0:ke.metadata;let He;const Tt=!!(Je!=null&&Je.forwarded_from_peer);Tt?He=Je.forwarded_from_peer:(Lt=Ce.metadata)!=null&&Lt.agent_name?He=Ce.metadata.agent_name:Je!=null&&Je.agent_name?He=Je.agent_name:He=U.source_entity||"Agent";const _e=`${He}:${q}`;if(!Tt&&(ke!=null&&ke.parts))for(const Q of ke.parts){if(Q.kind==="data"){const ve=Q.data;ve.type==="agent_progress_update"?m=ve.status_text:ve.type==="artifact_creation_progress"&&(m=`Saving artifact: ${ve.filename} (${ve.bytes_saved} bytes)`)}if(Q.kind==="data"){j(q);const be=Q.data;switch(be==null?void 0:be.type){case"agent_progress_update":{p.push({id:`vstep-progress-${p.length}-${te}`,type:"AGENT_RESPONSE_TEXT",timestamp:W,title:`${He}: Progress Update`,source:He,target:"User",data:{text:be.status_text},rawEventIds:[te],isSubTaskStep:Y>0,nestingLevel:Y,owningTaskId:q,functionCallId:ue});break}case"llm_invocation":{const Fe=be.request;let tt="System-initiated LLM call";if(Fe!=null&&Fe.contents&&Array.isArray(Fe.contents)&&Fe.contents.length>0){const lt=[...Fe.contents].reverse().find(Et=>Et.role==="user");lt&&lt.parts&&(tt=lt.parts.map(Et=>Et.text||"").join(`
378
+ `).trim())}const Ct={modelName:(Fe==null?void 0:Fe.model)||"Unknown Model",promptPreview:tt||"No text in user prompt."};l(_e,He),a.set(_e,{timestamp:W,modelName:Ct.modelName}),p.push({id:`vstep-llmcall-${p.length}-${te}`,type:"AGENT_LLM_CALL",timestamp:W,title:`${He}: LLM Call`,source:He,target:"LLM",data:{llmCall:Ct},rawEventIds:[te],isSubTaskStep:Y>0,nestingLevel:Y,owningTaskId:q,functionCallId:ue});break}case"llm_response":{const Fe=a.get(_e);if(Fe){const Et=new Date(W).getTime()-new Date(Fe.timestamp).getTime();l(_e,He).llmCalls.push({modelName:Fe.modelName,durationMs:Et,timestamp:Fe.timestamp}),a.delete(_e)}const tt=be.data,Ct=(jt=tt.content)==null?void 0:jt.parts,lt=Ct==null?void 0:Ct.filter(Et=>Et.function_call);if(lt&&lt.length>0){j(q),b=null,S.delete(q);const Et=lt.map(Wt=>{var fr;return{functionCallId:Wt.function_call.id,toolName:Wt.function_call.name,toolArguments:Wt.function_call.args||{},isPeerDelegation:(fr=Wt.function_call.name)==null?void 0:fr.startsWith("peer_")}}),hn={decisions:Et,isParallel:Et.length>1},qe=[],Qt=new Set;Et.forEach(Wt=>{if(Wt.isPeerDelegation){const fr=Wt.toolName.substring(5);for(const no in t){const hr=t[no];if(Qt.has(hr.taskId))continue;if(Xy(hr)===q&&hr.events&&hr.events.length>0){const Se=hr.events.find(Te=>{var Ne,Ue,rt,Be;return Te.direction==="request"&&((Be=(rt=(Ue=(Ne=Te.full_payload)==null?void 0:Ne.params)==null?void 0:Ue.message)==null?void 0:rt.metadata)==null?void 0:Be.function_call_id)===Wt.functionCallId});if(Se&&new Date(ka(Se)).getTime()>=new Date(W).getTime()){const Te={functionCallId:Wt.functionCallId,peerAgentName:fr,subTaskId:hr.taskId};qe.push(Te),E.set(Wt.functionCallId,Te),hr.taskId&&(_.set(hr.taskId,Wt.functionCallId),Qt.add(hr.taskId));break}}}}});const Zn={id:`vstep-tooldecision-${p.length}-${te}`,type:"AGENT_LLM_RESPONSE_TOOL_DECISION",timestamp:W,title:`LLM: Tool Decision${hn.isParallel?" (Parallel)":""}`,source:"LLM",target:He,data:{toolDecision:hn},rawEventIds:[te],delegationInfo:qe.length>0?qe:void 0,isSubTaskStep:Y>0,nestingLevel:Y,owningTaskId:q,functionCallId:ue};p.push(Zn);const dr=hn.isParallel?Zn.id:void 0,Gt=_e;l(Gt,He),Et.forEach(Wt=>{var no;const fr=Wt.isPeerDelegation?(no=E.get(Wt.functionCallId))==null?void 0:no.subTaskId:void 0;i.has(Wt.functionCallId)||i.set(Wt.functionCallId,{timestamp:W,toolName:Wt.toolName,isPeer:Wt.isPeerDelegation,invokingAgentInstanceId:Gt,subTaskId:fr,parallelBlockId:dr})})}else{const Et=(Ct==null?void 0:Ct.filter(qe=>qe.text).map(qe=>qe.text).join(`
379
+ `))||"",hn={responsePreview:Et.substring(0,200)+(Et.length>200?"...":""),isFinalResponse:(tt==null?void 0:tt.partial)===!1};p.push({id:`vstep-llmrespagent-${p.length}-${te}`,type:"AGENT_LLM_RESPONSE_TO_AGENT",timestamp:W,title:`${He}: LLM Response`,source:"LLM",target:He,data:{llmResponseToAgent:hn},rawEventIds:[te],isSubTaskStep:Y>0,nestingLevel:Y,owningTaskId:q,functionCallId:ue})}break}case"tool_invocation_start":{const Fe={functionCallId:be.function_call_id,toolName:be.tool_name,toolArguments:be.tool_args,isPeerInvocation:(Rt=be.tool_name)==null?void 0:Rt.startsWith("peer_")};p.push({id:`vstep-toolinvokestart-${p.length}-${te}`,type:"AGENT_TOOL_INVOCATION_START",timestamp:W,title:`${He}: Executing tool ${Fe.toolName}`,source:He,target:Fe.toolName,data:{toolInvocationStart:Fe},rawEventIds:[te],isSubTaskStep:Y>0,nestingLevel:Y,owningTaskId:q,functionCallId:ue});break}case"tool_result":{const Fe=be.function_call_id,tt=i.get(Fe);if(tt){const lt=new Date(W).getTime()-new Date(tt.timestamp).getTime(),Et=o.agents[tt.invokingAgentInstanceId];if(Et){const hn={toolName:tt.toolName,durationMs:lt,isPeer:tt.isPeer,timestamp:tt.timestamp,peerAgentName:tt.isPeer?tt.toolName.substring(5):void 0,subTaskId:tt.subTaskId,parallelBlockId:tt.parallelBlockId};Et.toolCalls.push(hn)}i.delete(Fe)}const Ct={toolName:be.tool_name,functionCallId:Fe,resultData:be.result_data,isPeerResponse:(it=be.tool_name)==null?void 0:it.startsWith("peer_")};if(p.push({id:`vstep-toolresult-${p.length}-${te}`,type:"AGENT_TOOL_EXECUTION_RESULT",timestamp:W,title:`${He}: Tool Result - ${Ct.toolName}`,source:Ct.toolName,target:He,data:{toolResult:Ct},rawEventIds:[te],isSubTaskStep:Y>0,nestingLevel:Y,owningTaskId:q,functionCallId:ue}),be.tool_name==="_notify_artifact_save"&&Fe){const lt=u.get(Fe);if(lt){const Et={artifactName:lt.filename,version:lt.version,description:lt.description,mimeType:lt.mimeType};p.push({id:`vstep-artifactcreated-${p.length}-${lt.eventId}`,type:"AGENT_ARTIFACT_NOTIFICATION",timestamp:lt.timestamp,title:`${lt.agentName}: Created Artifact - ${Et.artifactName}`,source:lt.agentName,target:"User/System",data:{artifactNotification:Et},rawEventIds:[lt.eventId],isSubTaskStep:lt.nestingLevel>0,nestingLevel:lt.nestingLevel,owningTaskId:lt.taskId,functionCallId:Fe}),u.delete(Fe)}}break}case"artifact_creation_progress":break;case"artifact_saved":{if(j(q),be.function_call_id&&be.function_call_id.startsWith("host-notify-"))u.set(be.function_call_id,{filename:be.filename||"Unnamed Artifact",version:be.version,description:be.description,mimeType:be.mime_type,timestamp:W,agentName:He,taskId:q,nestingLevel:Y,eventId:te});else{const tt={artifactName:be.filename||"Unnamed Artifact",version:be.version,description:be.description,mimeType:be.mime_type};p.push({id:`vstep-artifactsaved-${p.length}-${te}`,type:"AGENT_ARTIFACT_NOTIFICATION",timestamp:W,title:`${He}: Created Artifact - ${tt.artifactName}`,source:He,target:"User/System",data:{artifactNotification:tt},rawEventIds:[te],isSubTaskStep:Y>0,nestingLevel:Y,owningTaskId:q,functionCallId:be.function_call_id||ue})}break}}}else Q.kind==="text"&&Q.text&&(g&&g!==He&&(j(q),b=null),g||(g=He,v=W,C=Tt),x+=Q.text,w.push(te))}return}if(U.direction==="artifact_update"&&((Ot=$==null?void 0:$.result)!=null&&Ot.artifact)){j(q);const Ce=$.result.artifact,ke=((Jt=Ce.metadata)==null?void 0:Jt.agent_name)||U.source_entity||"Agent";let Je;if(Ce.parts&&Ce.parts.length>0){const Tt=Ce.parts[0];Tt.kind==="file"?Je=Tt.file.mimeType||void 0:(Ft=Tt.metadata)!=null&&Ft.mime_type&&(Je=Tt.metadata.mime_type)}const He={artifactName:Ce.name||"Unnamed Artifact",version:typeof((xe=Ce.metadata)==null?void 0:xe.version)=="number"?Ce.metadata.version:void 0,description:Ce.description||void 0,mimeType:Je};p.push({id:`vstep-artifactnotify-${p.length}-${te}`,type:"AGENT_ARTIFACT_NOTIFICATION",timestamp:W,title:`${ke}: Artifact Update - ${He.artifactName}`,source:ke,target:"User/System",data:{artifactNotification:He},rawEventIds:[te],isSubTaskStep:Y>0,nestingLevel:Y,owningTaskId:q,functionCallId:ue});return}if(["response","task"].includes(U.direction)&&((Ie=(Re=$==null?void 0:$.result)==null?void 0:Re.status)!=null&&Ie.state)){x.trim()&&j(q);const Ce=$.result,ke=Ce.status.state,Je=((Pe=Ce.metadata)==null?void 0:Pe.agent_name)||((Pt=(Me=(ot=Ce.status)==null?void 0:ot.message)==null?void 0:Me.metadata)==null?void 0:Pt.agent_name)||U.source_entity||"Agent";if(["completed","failed","canceled"].includes(ke)&&Y==0){const He=ke==="completed"?"TASK_COMPLETED":"TASK_FAILED",Tt=`${Je}: Task ${ke.charAt(0).toUpperCase()+ke.slice(1)}`;let _e={},Q="";if((Ke=Ce.status.message)!=null&&Ke.parts){const ut=Ce.status.message.parts.find(Fe=>Fe.kind==="text");ut!=null&&ut.text&&(Q=ut.text.trim())}const ve=q===n.taskId,be=Q&&(!ve||Q!==b);if(He==="TASK_COMPLETED")_e={finalMessage:be?Q:void 0};else{const Fe={message:be?Q:`Task ${ke}.`},tt=$.error;tt&&(Fe.message=tt.message||Fe.message,Fe.code=tt.code,tt.data&&(Fe.details=tt.data)),Ce.error&&(Fe.message=Ce.error.message||Fe.message,Fe.code=Ce.error.code||Fe.code,Fe.details=Ce.error.data||Fe.details),_e={errorDetails:Fe}}p.push({id:`vstep-${ke}-${p.length}-${te}`,type:He,timestamp:W,title:Tt,source:Je,target:"User",data:_e,rawEventIds:[te],isSubTaskStep:Y>0,nestingLevel:Y,owningTaskId:q,functionCallId:ue}),ve&&(b=null);return}}const pe=U.direction==="status-update"&&((Rn=(en=(yt=(st=$==null?void 0:$.result)==null?void 0:st.status)==null?void 0:yt.message)==null?void 0:en.parts)==null?void 0:Rn.some(Ce=>Ce.kind==="text"));let k=U.source_entity;(we=(fe=(ie=(ee=$==null?void 0:$.result)==null?void 0:ee.status)==null?void 0:ie.message)==null?void 0:fe.metadata)!=null&&we.forwarded_from_peer?k=$.result.status.message.metadata.forwarded_from_peer:(Le=(ye=$==null?void 0:$.result)==null?void 0:ye.metadata)!=null&&Le.agent_name?k=$.result.metadata.agent_name:(Xe=(Ve=(De=($e=$==null?void 0:$.result)==null?void 0:$e.status)==null?void 0:De.message)==null?void 0:Ve.metadata)!=null&&Xe.agent_name&&(k=$.result.status.message.metadata.agent_name),x.trim()&&g&&(!pe||pe&&k!==g)&&(j(q),c.get(((We=w[0])==null?void 0:We.split("-")[1])||n.taskId)===0&&!C&&(b=null))});const A=h.length>0&&h[h.length-1].task_id||n.taskId;j(A);const I=h[0]?ka(h[0]):n.firstSeen.toISOString();let P,F="working";const N=p.filter(U=>U.owningTaskId===n.taskId),R=N.length>0?N[N.length-1]:null;if(R&&(R.type==="TASK_COMPLETED"?(F="completed",P=R.timestamp):R.type==="TASK_FAILED"&&(F="failed",P=R.timestamp)),F==="working"&&h.length>0){const U=h[h.length-1];t[U.task_id||n.taskId]}let y;I&&P&&(y=new Date(P).getTime()-new Date(I).getTime()),["completed","failed","canceled","rejected"].includes(F)&&(m=void 0);const T={taskId:n.taskId,initialRequestText:n.initialRequestText,status:F,currentStatusText:m,startTime:I,endTime:P,durationMs:y,steps:p};T.steps.forEach((U,X)=>{if(U.type==="TASK_COMPLETED"){let W="";for(let te=X-1;te>=0;te--){const $=T.steps[te];if($.type!=="AGENT_RESPONSE_TEXT"||$.source!==U.source)break;W=$.data.text+W}U.data.finalMessage&&(W+=U.data.finalMessage),U.data.finalMessage=W.trim()||void 0}}),Object.values(o.agents).forEach(U=>{U.totalLlmTimeMs=U.llmCalls.reduce((q,Y)=>q+Y.durationMs,0);const X=U.toolCalls.filter(q=>!q.parallelBlockId),W=new Map;U.toolCalls.forEach(q=>{q.parallelBlockId&&(W.has(q.parallelBlockId)||W.set(q.parallelBlockId,[]),W.get(q.parallelBlockId).push(q))});const te=X.reduce((q,Y)=>q+Y.durationMs,0);let $=0;W.forEach(q=>{if(q.length>0){const Y=Math.min(...q.map(ue=>new Date(ue.timestamp).getTime())),re=Math.max(...q.map(ue=>new Date(ue.timestamp).getTime()+ue.durationMs));$+=re-Y}}),U.totalToolTimeMs=te+$});const D=new Map;Object.values(o.agents).forEach(U=>{D.has(U.agentName)||D.set(U.agentName,[]),D.get(U.agentName).push(U)}),D.forEach(U=>{U.length>1&&(U.sort((X,W)=>{const te=$=>{const q=[...$.llmCalls.map(Y=>new Date(Y.timestamp).getTime()),...$.toolCalls.map(Y=>new Date(Y.timestamp).getTime())];return q.length>0?Math.min(...q):1/0};return te(X)-te(W)}),U.forEach((X,W)=>{X.displayName=`${X.agentName} (${W+1})`}))});const L=new Map;return Object.values(o.agents).forEach(U=>{const X=U.instanceId.split(":").slice(1).join(":");X&&L.set(X,U.displayName)}),Object.values(o.agents).forEach(U=>{U.toolCalls.forEach(X=>{if(X.isPeer&&X.subTaskId){const W=L.get(X.subTaskId);W&&(X.peerAgentName=W)}})}),y!==void 0&&(o.overall.totalTaskDurationMs=y),T.performanceReport=o,T},bD=({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(CD,{onClick:o}),s.jsx(kD,{items:e,bottomItems:i,activeItem:n,onItemClick:a})]})},Pm="webui_logo_url",yD=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"})]})}),CD=({onClick:e})=>{const t=sn(),[n,r]=d.useState(!1),[o,a]=d.useState("");d.useEffect(()=>{try{const l=localStorage.getItem(Pm);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(Pm,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)})}):yD})},SD=()=>{const{settings:e,updateSetting:t}=Uo(),{configFeatureEnablement:n}=sn(),[r,o]=d.useState([]),[a,i]=d.useState(!1),[l,c]=d.useState(null),[u,f]=d.useState(null),[h,p]=d.useState(null),[m,x]=d.useState(null),[g,v]=d.useState(!1),[w,b]=d.useState(!1),[C,_]=d.useState(null),E=(n==null?void 0:n.speechToText)??!0,S=(n==null?void 0:n.textToSpeech)??!0;d.useEffect(()=>{(async()=>{try{const I=await je.webui.get("/api/v1/speech/config"),P=I.sttExternal||!1,F=I.ttsExternal||!1;c(P),f(F),I.sttProviders&&p(I.sttProviders),I.ttsProviders&&x(I.ttsProviders),!P&&e.sttProvider!=="browser"&&(console.warn("External STT not configured, resetting provider to browser"),t("sttProvider","browser"),t("engineSTT","browser")),!F&&e.ttsProvider!=="browser"&&(console.warn("External TTS not configured, resetting provider to browser"),t("ttsProvider","browser"),t("engineTTS","browser"))}catch(I){console.error("Error checking speech config:",I)}})()},[e.sttProvider,e.ttsProvider,t]),d.useEffect(()=>{(async()=>{if(e.ttsProvider==="browser"){o([]);return}i(!0);try{const I=e.ttsProvider||"gemini",P=await je.webui.get(`/api/v1/speech/voices?provider=${I}`);o(P.voices||[])}catch(I){console.error("Error loading voices:",I)}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,_(null)),b(!0),v(!1);const I=new FormData;I.append("voice",A),e.ttsProvider!=="browser"&&I.append("provider",e.ttsProvider);const P=await je.webui.post("/api/v1/speech/voice-sample",I,{fullResponse:!0});if(!P.ok)throw new Error(`Failed to load voice sample: ${P.statusText}`);const F=await P.blob(),N=URL.createObjectURL(F);b(!1),v(!0);const R=new Audio(N);R.onended=()=>{v(!1),_(null),URL.revokeObjectURL(N)},R.onerror=()=>{v(!1),_(null),URL.revokeObjectURL(N)},R.playbackRate=e.playbackRate||1,_(R),await R.play()}catch(I){console.error("Error playing voice sample:",I),b(!1),v(!1),_(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(Pu,{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(Nt,{className:"font-medium",children:"Enable Speech-to-Text"}),s.jsx(ed,{checked:e.speechToText,onCheckedChange:A=>t("speechToText",A)})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx(Nt,{className:"font-medium",children:"Speech-to-Text Provider"}),s.jsxs(Nr,{value:e.sttProvider,onValueChange:A=>{t("sttProvider",A),t("engineSTT",A==="browser"?"browser":"external")},disabled:!e.speechToText,children:[s.jsx(Ar,{className:"w-44",children:s.jsx(Tr,{})}),s.jsxs(Ir,{children:[s.jsx(_t,{value:"browser",children:"Browser (Free)"}),(h==null?void 0:h.openai)&&s.jsx(_t,{value:"openai",children:"OpenAI Whisper"}),(h==null?void 0:h.azure)&&s.jsx(_t,{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(To,{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(Nt,{className:"font-medium",children:"Language"}),s.jsxs(Nr,{value:e.languageSTT,onValueChange:A=>t("languageSTT",A),disabled:!e.speechToText,children:[s.jsx(Ar,{className:"w-44",children:s.jsx(Tr,{})}),s.jsxs(Ir,{children:[s.jsx(_t,{value:"en-US",children:"English (US)"}),s.jsx(_t,{value:"en-GB",children:"English (UK)"}),s.jsx(_t,{value:"es-ES",children:"Spanish"}),s.jsx(_t,{value:"fr-FR",children:"French"}),s.jsx(_t,{value:"de-DE",children:"German"}),s.jsx(_t,{value:"it-IT",children:"Italian"}),s.jsx(_t,{value:"ja-JP",children:"Japanese"}),s.jsx(_t,{value:"ko-KR",children:"Korean"}),s.jsx(_t,{value:"zh-CN",children:"Chinese (Simplified)"})]})]})]})]}),S&&s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex items-center gap-2 border-b pb-2",children:[s.jsx(cl,{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(Nt,{className:"font-medium",children:"Enable Text-to-Speech"}),s.jsx(ed,{checked:e.textToSpeech,onCheckedChange:A=>t("textToSpeech",A)})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx(Nt,{className:"font-medium",children:"Text-to-Speech Provider"}),s.jsxs(Nr,{value:e.ttsProvider,onValueChange:A=>{t("ttsProvider",A),t("engineTTS",A==="browser"?"browser":"external")},disabled:!e.textToSpeech,children:[s.jsx(Ar,{className:"w-44",children:s.jsx(Tr,{})}),s.jsxs(Ir,{children:[s.jsx(_t,{value:"browser",children:"Browser (Free)"}),(m==null?void 0:m.gemini)&&s.jsx(_t,{value:"gemini",children:"Google Gemini"}),(m==null?void 0:m.azure)&&s.jsx(_t,{value:"azure",children:"Azure Neural"}),(m==null?void 0:m.polly)&&s.jsx(_t,{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(To,{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(To,{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(Nt,{className:"font-medium",children:"Voice"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs(Nr,{value:e.voice,onValueChange:A=>t("voice",A),disabled:!e.textToSpeech||a,children:[s.jsx(Ar,{className:"w-[112px]",children:s.jsx(Tr,{placeholder:a?"Loading...":"Select voice"})}),s.jsx(Ir,{children:r.length>0?(()=>{if(r.some(I=>I.includes("DragonHD"))&&e.ttsProvider==="azure"){const I=r.filter(F=>F.includes("DragonHD")),P=r.filter(F=>!F.includes("DragonHD"));return s.jsxs(s.Fragment,{children:[I.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)"}),I.map(F=>{const N=F.split("-"),y=(N[N.length-1]||F).replace("MultilingualNeural:DragonHDLatestNeural","").replace("Neural:DragonHDLatestNeural","").replace(":DragonHDLatestNeural","");return s.jsx(_t,{value:F,children:y},F)})]}),P.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"}),P.map(F=>{const N=F.split("-"),y=(N[N.length-1]||F).replace("MultilingualNeural","").replace("Neural","");return s.jsx(_t,{value:F,children:y},F)})]})]})}else return r.map(I=>{let P=I;if(I.includes("-")){const F=I.split("-");P=F[F.length-1].replace("Neural","").replace("Multilingual","")||I}return s.jsx(_t,{value:I,children:P},I)})})():s.jsx(_t,{value:"loading",disabled:!0,children:a?"Loading...":"No voices available"})})]}),s.jsx(me,{variant:g?"default":"outline",size:"sm",onClick:()=>{!g&&!w&&j(e.voice)},disabled:!e.textToSpeech||!e.voice||a||g||w,title:w?"Loading sample...":g?"Playing sample...":"Play voice sample",className:"w-10 px-3",children:w?s.jsx(ar,{className:"size-4 animate-spin"}):g?s.jsx(cl,{className:"size-4"}):s.jsx(eC,{className:"size-4"})})]})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx(Nt,{className:"font-medium",children:"Playback Speed"}),s.jsx(xr,{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"})]})]})]})},Mm=()=>{const{currentTheme:e,toggleTheme:t}=ci();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(Eg,{className:"size-4"}),s.jsx(Nt,{className:"font-medium",children:"Dark Mode"})]}),s.jsx(ed,{checked:e==="dark",onCheckedChange:t})]})]})})},_D=()=>{const[e,t]=d.useState(null),[n,r]=d.useState(!0),[o,a]=d.useState(null),i=()=>n?s.jsx(Qr,{className:"mt-8"}):o?s.jsx(Vt,{variant:"error",message:`Error loading application information. ${o}`}):e?s.jsx(fP,{children:s.jsx(hP,{children:e.products.toSorted((l,c)=>l.name.localeCompare(c.name)).map(l=>s.jsxs(pP,{className:"hover:bg-transparent",children:[s.jsx(nm,{className:"font-medium",children:l.name}),s.jsx(nm,{children:l.version})]},l.id))})}):null;return d.useEffect(()=>{(async()=>{try{const c=await je.webui.get("/api/v1/version");t(c)}catch(c){a(Ut(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()]})})},yu=({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})]}),Dm=({iconOnly:e=!1,open:t,onOpenChange:n})=>{const{configFeatureEnablement:r}=sn(),[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,p=(r==null?void 0:r.textToSpeech)??!0,m=h||p,x=()=>{switch(i){case"about":return s.jsx(_D,{});case"general":return s.jsx(Mm,{});case"speech":return s.jsx(SD,{});default:return s.jsx(Mm,{})}},g=()=>{switch(i){case"about":return"About";case"general":return"General";case"speech":return"Speech";default:return"Settings"}};return s.jsxs(Pn,{open:u,onOpenChange:f,children:[!c&&(e?s.jsxs(ho,{children:[s.jsx(po,{asChild:!0,children:s.jsx(Ju,{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(Oa,{className:"h-6 w-6"})})})}),s.jsx(mo,{side:"right",children:"Settings"})]}):s.jsx(Ju,{asChild:!0,children:s.jsxs(me,{variant:"outline",className:"w-full justify-start gap-2",children:[s.jsx(Oa,{className:"size-5"}),s.jsx("span",{children:"Settings"})]})})),s.jsxs(Mn,{className:"max-h-[90vh] w-[90vw] !max-w-[1200px] gap-0 p-0",showCloseButton:!0,children:[s.jsxs(ec,{children:[s.jsx(Dn,{children:"Settings"}),s.jsx(Wn,{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(yu,{icon:s.jsx(Cg,{className:"size-4"}),label:"General",active:i==="general",onClick:()=>l("general")}),m&&s.jsx(yu,{icon:s.jsx(cl,{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(yu,{icon:s.jsx(Qa,{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()})})]})]})]})]})},kD=({items:e,bottomItems:t,activeItem:n,onItemClick:r})=>{const[o,a]=d.useState(!1),[i,l]=d.useState(!1),{configUseAuthorization:c,configFeatureEnablement:u}=sn(),f=!!(c&&(u!=null&&u.logout)),{userInfo:h,logout:p}=bw(),m=typeof(h==null?void 0:h.username)=="string"?h.username:"Guest",x=()=>{a(!1),l(!0)},g=async()=>{a(!1),await p()};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(v=>s.jsxs("li",{children:[s.jsx(Om,{item:v,isActive:n===v.id,onItemClick:r}),v.showDividerAfter&&s.jsx("div",{className:"mx-4 my-3 border-t border-[var(--color-secondary-w70)]"})]},v.id))}),s.jsx("div",{className:"flex-1"}),s.jsxs("ul",{className:"space-y-1",children:[t&&t.length>0&&t.map(v=>s.jsx("li",{className:"my-4",children:s.jsx(Om,{item:v,isActive:n===v.id,onItemClick:r},v.id)},v.id)),f?s.jsx("li",{className:"my-4 flex justify-center",children:s.jsxs(pc,{open:o,onOpenChange:a,children:[s.jsxs(ho,{children:[s.jsx(po,{asChild:!0,children:s.jsx(mc,{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(dl,{className:"h-6 w-6"})})})}),s.jsx(mo,{side:"right",children:"User & Settings"})]}),s.jsxs(gc,{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(dl,{className:"size-4 shrink-0"}),s.jsx("div",{className:"min-w-0 truncate text-sm font-medium",title:m,children:m})]}),s.jsx(di,{actions:[{id:"settings",label:"Settings",icon:s.jsx(Oa,{}),onClick:x},{id:"logout",label:"Log Out",icon:s.jsx(tC,{}),onClick:g,divider:!0}]})]})]})}):s.jsx("li",{className:"my-4 flex justify-center",children:s.jsx(Dm,{iconOnly:!0})})]}),i&&s.jsx(Dm,{iconOnly:!1,open:i,onOpenChange:l})]})},Om=({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(ho,{children:[s.jsx(po,{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(Or,{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(mo,{side:"right",children:o})]})},jD=e=>{const t=[{id:"chat",label:"Chat",icon:ul},{id:"agentMesh",label:"Agents",icon:$l}];return((e==null?void 0:e.projects)??!1)&&t.push({id:"projects",label:"Projects",icon:Ng}),((e==null?void 0:e.promptLibrary)??!1)&&t.push({id:"prompts",label:"Prompts",icon:Qo,badge:"EXPERIMENTAL"}),t},Lm=[{id:"theme-toggle",label:"Theme",icon:Eg,onClick:()=>{}}],ms=({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(At.Fragment,{children:[i>0&&s.jsx("span",{className:"mx-1",children:s.jsx(nC,{size:16})}),a.onClick?s.jsx(me,{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(At.Fragment,{children:a},i))})]});function ED(){const{agents:e,agentsLoading:t,agentsError:n,agentsRefetch:r}=It();return s.jsxs("div",{className:"flex h-full w-full flex-col",children:[s.jsx(ms,{title:"Agents",buttons:[s.jsxs(me,{"data-testid":"refreshAgents",disabled:t,variant:"ghost",title:"Refresh Agents",onClick:()=>r(),children:[s.jsx(Ul,{className:"size-4"}),"Refresh Agents"]})]}),t?s.jsx(Pr,{title:"Loading agents...",variant:"loading"}):n?s.jsx(Pr,{variant:"error",title:"Error loading agents",subtitle:n}):s.jsx("div",{className:"relative flex-1",children:s.jsx(Vy,{agents:e})})]})}const ND=At.memo(({open:e,onCancel:t,onConfirm:n,sessionName:r})=>s.jsx(Bo,{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})),Bi=4,Sd={chatPanelSizes:{default:50,min:30,max:96},sidePanelSizes:{default:50,min:20,max:70}},TD={chatPanelSizes:{...Sd.chatPanelSizes,min:50},sidePanelSizes:{...Sd.sidePanelSizes,max:50}};function AD(){var X;const{activeProject:e}=bo(),{currentTheme:t}=ci(),{agents:n,sessionName:r,messages:o,isSidePanelCollapsed:a,setIsSidePanelCollapsed:i,openSidePanelTab:l,setTaskIdInSidePanel:c,isResponding:u,latestStatusText:f,isLoadingSession:h,sessionToDelete:p,closeSessionDeleteModal:m,confirmSessionDelete:x,currentTaskId:g}=It(),{isTaskMonitorConnected:v,isTaskMonitorConnecting:w,taskMonitorSseError:b,connectTaskMonitorStream:C}=Pf(),[_,E]=d.useState(!0),[S,j]=d.useState(!1),A=d.useRef(null),I=d.useRef(null),P=d.useRef(null),{chatPanelSizes:F,sidePanelSizes:N}=d.useMemo(()=>_?Sd:TD,[_]),R=d.useCallback(W=>{if(j(!0),I.current)if(W)I.current.resize(Bi);else{const te=P.current||N.default;I.current.resize(te)}setTimeout(()=>j(!1),300)},[N.default]),y=d.useCallback(()=>{i(!0)},[i]),T=d.useCallback(()=>{i(!1)},[i]),D=d.useCallback(W=>{W>Bi+1&&(P.current=W)},[]),L=d.useCallback(()=>{E(!_)},[_]),O=void 0,M=d.useMemo(()=>r||"New Chat",[r]);d.useEffect(()=>{I.current&&a&&I.current.resize(Bi);const W=()=>{if(I.current&&a){j(!0);const te=P.current||N.default;I.current.resize(te),i(!1),setTimeout(()=>j(!1),300)}};return window.addEventListener("expand-side-panel",W),()=>{window.removeEventListener("expand-side-panel",W)}},[a,i,N.default]);const J=d.useMemo(()=>{const W=new Map;return o.forEach((te,$)=>{te.taskId&&W.set(te.taskId,$)}),W},[o]),z=d.useMemo(()=>o.find(W=>W.isStatusBubble),[o]),H=d.useMemo(()=>{if(!z||!z.parts)return null;const W=z.parts.find(te=>te.kind==="text");return(W==null?void 0:W.text)||null},[z]),U=d.useMemo(()=>{if(g)return()=>{c(g),l("workflow")}},[g,c,l]);return d.useEffect(()=>{const W=()=>{!v&&!w&&b&&(console.log("ChatPage: Window focused while disconnected, attempting reconnection..."),C())};return window.addEventListener("focus",W),()=>{window.removeEventListener("focus",W)}},[v,w,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 ${_?"-translate-x-full":"translate-x-0"}`,children:s.jsx(FM,{onToggle:L})}),s.jsx("div",{className:`transition-all duration-300 ${_?"ml-0":"ml-100"}`,children:s.jsx(ms,{title:s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsxs(ho,{delayDuration:300,children:[s.jsx(po,{className:"font-inherit max-w-[400px] cursor-default truncate border-0 bg-transparent p-0 text-left text-inherit hover:bg-transparent",children:M}),s.jsx(mo,{side:"bottom",children:s.jsx("p",{children:M})})]}),e&&s.jsx(Or,{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:O,leadingAction:_?s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(me,{"data-testid":"showSessionsPanel",variant:"ghost",onClick:L,className:"h-10 w-10 p-0",tooltip:"Show Chat Sessions",children:s.jsx(kg,{className:"size-5"})}),s.jsx("div",{className:"h-6 border-r"}),s.jsx(Hy,{})]}):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 ${_?"ml-0":"ml-100"}`,children:s.jsxs(dw,{direction:"horizontal",autoSaveId:"chat-side-panel",className:"h-full",children:[s.jsx(kl,{defaultSize:F.default,minSize:F.min,maxSize:F.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(Qr,{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(Vb,{className:"text-base",ref:A,children:o.map((W,te)=>{var Y;const $=!!(W.taskId&&J.get(W.taskId)===te),q=((Y=W.metadata)==null?void 0:Y.messageId)||`temp-${te}`;return s.jsx(mM,{message:W,isLastWithTaskId:$},q)})}),s.jsxs("div",{style:Bb,children:[u&&s.jsx(bd,{statusText:(H||f.current)??void 0,onViewWorkflow:U}),s.jsx(x4,{agents:n,scrollToBottom:(X=A.current)==null?void 0:X.scrollToBottom})]})]})})})}),s.jsx(fw,{}),s.jsx(kl,{ref:I,defaultSize:N.default,minSize:N.min,maxSize:N.max,collapsedSize:Bi,collapsible:!0,onCollapse:y,onExpand:T,onResize:D,id:"chat-side-panel",className:S?"transition-all duration-300 ease-in-out":"",children:s.jsx("div",{className:"h-full",children:s.jsx(LM,{onCollapsedToggle:R,isSidePanelCollapsed:a,setIsSidePanelCollapsed:i,isSidePanelTransitioning:S})})})]})})}),s.jsx(ND,{open:!!p,onCancel:m,onConfirm:x,sessionName:(p==null?void 0:p.name)||""})]})}const ID=({prompt:e,isSelected:t,onPromptClick:n,onEdit:r,onDelete:o,onViewVersions:a,onUseInChat:i,onTogglePin:l,onExport:c})=>{const{configFeatureEnablement:u}=sn(),f=(u==null?void 0:u.promptVersionHistory)??!0,[h,p]=d.useState(!1),m=f&&a,x=_=>{_.stopPropagation(),p(!1),r(e)},g=_=>{_.stopPropagation(),p(!1),o(e.id,e.name)},v=_=>{_.stopPropagation(),p(!1),a&&a(e)},w=_=>{_.stopPropagation(),p(!1),i&&i(e)},b=_=>{_.stopPropagation(),l&&l(e.id,e.isPinned)},C=_=>{_.stopPropagation(),p(!1),c&&c(e)};return s.jsx(kc,{"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(Qo,{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(me,{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(rC,{size:16,fill:e.isPinned?"currentColor":"none"})}),s.jsxs(Xs,{open:h,onOpenChange:p,children:[s.jsx(Js,{asChild:!0,children:s.jsx(me,{variant:"ghost",size:"icon",onClick:_=>{_.stopPropagation(),p(!h)},tooltip:"Actions",className:"cursor-pointer",children:s.jsx(Io,{size:16})})}),s.jsxs(Qs,{align:"end",onClick:_=>_.stopPropagation(),children:[i&&s.jsxs(jn,{onClick:w,children:[s.jsx(jg,{size:14,className:"mr-2"}),"Use in New Chat"]}),c&&s.jsxs(jn,{onClick:C,children:[s.jsx(xo,{size:14,className:"mr-2"}),"Export Prompt"]}),s.jsxs(jn,{onClick:x,children:[s.jsx(eo,{size:14,className:"mr-2"}),"Edit Prompt"]}),m&&s.jsxs(jn,{onClick:v,children:[s.jsx(Tg,{size:14,className:"mr-2"}),"Open Version History"]}),s.jsxs(jn,{onClick:g,children:[s.jsx(ts,{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(Ag,{size:12}),e.category]})]})})]})]})})},RD=({onManualCreate:e,onAIAssisted:t,isCentered:n=!1})=>{const{configFeatureEnablement:r}=sn(),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(me,{"data-testid":"buildWithAIButton",onClick:t,disabled:!o,variant:"default",size:"lg",className:"w-full",children:[s.jsx(Hs,{className:"mr-2 h-4 w-4"}),"Build with AI",!o&&s.jsx("span",{className:"ml-1 text-xs",children:"(Disabled)"})]}),s.jsxs(me,{onClick:e,variant:"outline",size:"lg",className:"w-full",children:[s.jsx(es,{className:"mr-2 h-4 w-4"}),"Create Manually"]})]})]})}):s.jsx(kc,{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(me,{"data-testid":"buildWithAIButton",onClick:t,disabled:!o,variant:"outline",className:"w-full",children:[s.jsx(Hs,{}),"Build with AI",!o&&s.jsx("span",{className:"ml-1 text-xs",children:"(Disabled)"})]}),s.jsxs(me,{onClick:e,variant:"ghost",className:"w-full",children:[s.jsx(es,{}),"Create Manually"]})]})]})})},PD=({prompt:e,onClose:t,onEdit:n,onDelete:r,onViewVersions:o,onUseInChat:a,onExport:i})=>{const{configFeatureEnablement:l}=sn(),u=((l==null?void 0:l.promptVersionHistory)??!0)&&o;if(!e)return null;const f=()=>{n(e)},h=()=>{r(e.id,e.name)},p=()=>{o&&o(e)},m=()=>{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(Qo,{className:"text-muted-foreground h-5 w-5 flex-shrink-0"}),s.jsxs(ho,{delayDuration:300,children:[s.jsx(po,{asChild:!0,children:s.jsx("h2",{className:"cursor-default truncate text-lg font-semibold",children:e.name})}),s.jsx(mo,{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(Xs,{children:[s.jsx(Js,{asChild:!0,children:s.jsx(me,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",tooltip:"Actions",children:s.jsx(Io,{className:"h-4 w-4"})})}),s.jsxs(Qs,{align:"end",children:[i&&s.jsxs(jn,{onClick:x,children:[s.jsx(xo,{size:14,className:"mr-2"}),"Export Prompt"]}),s.jsxs(jn,{onClick:f,children:[s.jsx(eo,{size:14,className:"mr-2"}),"Edit Prompt"]}),u&&s.jsxs(jn,{onClick:p,children:[s.jsx(Tg,{size:14,className:"mr-2"}),"Open Version History"]}),s.jsxs(jn,{onClick:h,children:[s.jsx(ts,{size:14,className:"mr-2"}),"Delete All Versions"]})]})]}),s.jsx(me,{variant:"ghost",size:"sm",onClick:t,className:"h-8 w-8 p-0",tooltip:"Close",children:s.jsx(Xr,{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(Ag,{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(me,{"data-testid":"startNewChatButton",onClick:m,className:"w-full",children:[s.jsx(_g,{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,v)=>g.match(/\{\{[^}]+\}\}/)?s.jsx("span",{className:"bg-primary/20 text-primary rounded px-1 font-medium",children:g},v):s.jsx("span",{children:g},v))})]})]}),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(dl,{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(Ig,{size:12}),s.jsxs("span",{children:["Last updated: ",Bu(e.updatedAt)]})]})]})]})},MD=({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),[p,m]=d.useState(""),[x,g]=d.useState([]),[v,w]=d.useState(!1),b=d.useRef(new Map),{configFeatureEnablement:C}=sn(),_=(C==null?void 0:C.promptAIAssisted)??!0,E=T=>{h(D=>(D==null?void 0:D.id)===T.id?null:T)},S=()=>{h(null)},j=d.useMemo(()=>{const T=new Set;return e.forEach(D=>{D.category&&T.add(D.category)}),Array.from(T).sort()},[e]),A=d.useMemo(()=>e.filter(D=>{var M,J,z;const L=((M=D.name)==null?void 0:M.toLowerCase().includes(p.toLowerCase()))||((J=D.description)==null?void 0:J.toLowerCase().includes(p.toLowerCase()))||((z=D.command)==null?void 0:z.toLowerCase().includes(p.toLowerCase())),O=x.length===0||D.category&&x.includes(D.category);return L&&O}).sort((D,L)=>{if(D.isPinned!==L.isPinned)return D.isPinned?-1:1;const O=(D.name||"").toLowerCase(),M=(L.name||"").toLowerCase();return O.localeCompare(M)}),[e,p,x]),I=T=>{g(D=>D.includes(T)?D.filter(L=>L!==T):[...D,T])},P=()=>{g([])},F=()=>{m(""),g([])},N=p.length>0||x.length>0,R=e.length===0;d.useEffect(()=>{if(u&&e.length>0){const T=e.find(D=>D.id===u);T&&(h(T),setTimeout(()=>{const D=b.current.get(u);D&&D.scrollIntoView({behavior:"smooth",block:"center"})},100))}},[u,e]);const y=d.useMemo(()=>{const T=[];return _&&T.push({icon:s.jsx(Hs,{}),text:"Build with AI",variant:"default",onClick:n}),T.push({icon:s.jsx(es,{}),text:"Create Manually",variant:"outline",onClick:t}),T},[_,n,t]);return s.jsx("div",{className:"absolute inset-0 h-full w-full",children:s.jsxs(dw,{id:"promptCardsPanelGroup",direction:"horizontal",className:"h-full",children:[s.jsx(kl,{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:[!R&&s.jsxs("div",{className:"mb-4 flex items-center gap-2",children:[s.jsx(gf,{value:p,onChange:m,placeholder:"Filter by name...",testid:"promptSearchInput"}),j.length>0&&s.jsxs("div",{className:"relative",children:[s.jsxs(me,{onClick:()=>w(!v),variant:"outline",testid:"promptTags",children:[s.jsx(oC,{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})]}),v&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>w(!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:P,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(Xr,{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:()=>I(T),className:"rounded"}),s.jsx("span",{className:"text-sm",children:T})]},T))})]})]})]}),N&&s.jsxs(me,{variant:"ghost",onClick:F,"data-testid":"clearAllFiltersButton",children:[s.jsx(Xr,{size:16}),"Clear All"]})]}),A.length===0&&p?s.jsx(Pr,{title:"No Prompts Match Your Filter",subtitle:"Try adjusting your filter terms.",variant:"notFound",buttons:[{text:"Clear Filter",variant:"default",onClick:()=>m("")}]}):R?s.jsx(Pr,{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(RD,{onManualCreate:t,onAIAssisted:n}),A.map(T=>s.jsx("div",{ref:D=>{D?b.current.set(T.id,D):b.current.delete(T.id)},children:s.jsx(ID,{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(fw,{}),s.jsx(kl,{defaultSize:30,minSize:20,maxSize:50,id:"promptDetailSidePanel",children:s.jsx(PD,{prompt:f,onClose:S,onEdit:r,onDelete:o,onViewVersions:a,onUseInChat:i,onTogglePin:l,onExport:c})})]})]})})},DD=["create-template"];function OD(e){return DD.includes(e)}function LD(e){const{addNotification:t}=It(),[n,r]=d.useState(()=>{var g,v;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:Gs(((v=e.productionPrompt)==null?void 0:v.promptText)||"")}:{}}),[o,a]=d.useState({}),[i,l]=d.useState(!1),[c,u]=d.useState("idle"),f=d.useCallback(g=>{r(v=>{const w={...v,...g};if(g.promptText!==void 0){const b=Gs(g.promptText||"");w.detected_variables=b}return w}),a(v=>{const w={...v};return Object.keys(g).forEach(b=>{delete w[b]}),w})},[]),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":OD(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 w=vk(n.promptText);w.valid||(g.promptText=w.error||"Invalid prompt text")}a(g);const v=Object.keys(g).length===0;return v&&t("Template is valid and ready to save!","success"),v},[n,t]),p=d.useCallback(async()=>{l(!0),u("saving");try{if(!await h())return u("error"),l(!1),null;const v={name:n.name,description:n.description||null,category:n.category||null,command:n.command||null,initial_prompt:n.promptText},w=await je.webui.post("/api/v1/prompts/groups",v);return u("success"),t("Template saved","success"),l(!1),w.id}catch(g){console.error("Error saving template:",g),u("error"),l(!1);const v=Ut(g,"Failed to save template");return a(w=>({...w,_general:v})),null}},[n,h,t]),m=d.useCallback(async(g,v)=>{var w;l(!0),u("saving");try{if(!await h())return u("error"),l(!1),!1;const C=n.promptText!==((w=e==null?void 0:e.productionPrompt)==null?void 0:w.promptText),_=(e==null?void 0:e._isEditingActiveVersion)??!0,E=(e==null?void 0:e._editingPromptId)||(e==null?void 0:e.productionPromptId);if(v){const S={};return n.name!==(e==null?void 0:e.name)&&(S.name=n.name),n.description!==(e==null?void 0:e.description)&&(S.description=n.description),n.category!==(e==null?void 0:e.category)&&(S.category=n.category),n.command!==(e==null?void 0:e.command)&&(S.command=n.command),S.initial_prompt=n.promptText,await je.webui.patch(`/api/v1/prompts/groups/${g}`,S),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 je.webui.patch(`/api/v1/prompts/groups/${g}`,A)}return C&&E&&await je.webui.patch(`/api/v1/prompts/${E}`,{promptText:n.promptText}),u("success"),t(_?"Active version updated":"Version updated","success"),l(!1),!0}}catch(b){console.error("Error updating template:",b),u("error"),l(!1);const C=Ut(b,"Failed to update template");return a(_=>({..._,_general:C})),!1}},[n,e,h,t]),x=d.useCallback(()=>{r({}),a({}),u("idle")},[]);return{config:n,updateConfig:f,validateConfig:h,saveTemplate:p,updateTemplate:m,resetConfig:x,validationErrors:o,isLoading:i,saveStatus:c}}const FD=({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,p]=d.useState(!0),[m,x]=d.useState(!1),g=d.useRef(null),v=d.useRef(null),w=d.useRef(!1),{settings:b}=Uo(),{configFeatureEnablement:C}=sn(),_=(C==null?void 0:C.speechToText)??!0,[E,S]=d.useState(null),[j,A]=d.useState(!1),I=()=>{var y;(y=g.current)==null||y.scrollIntoView({behavior:"smooth"})};d.useEffect(()=>{I()},[a]),d.useEffect(()=>{if(w.current)return;w.current=!0,(async()=>{try{const T=await je.webui.get("/api/v1/prompts/chat/init"),D=o?"Hi! I'll help you edit this prompt template. What changes would you like to make?":T.message;if(i([{role:"assistant",content:D,timestamp:new Date}]),r){x(!0);const L={role:"user",content:r,timestamp:new Date};i(O=>[...O,L]),setTimeout(()=>I(),100),f(!0);try{const O=await je.webui.post("/api/v1/prompts/chat",{message:r,conversation_history:[{role:"assistant",content:T.message}],current_template:t},{fullResponse:!0});if(O.ok){const M=await O.json(),J={role:"assistant",content:M.message,timestamp:new Date};i(z=>[...z,J]),Object.keys(M.template_updates).length>0&&e(M.template_updates),n(M.ready_to_save),setTimeout(()=>I(),100)}else{const M=await O.json().catch(()=>({}));console.error("Prompt builder API error:",M);const J={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(z=>[...z,J])}}catch(O){console.error("Error sending initial message:",O);const M={role:"assistant",content:"I encountered an error processing your request. Please try describing your task manually.",timestamp:new Date};i(J=>[...J,M])}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{p(!1)}})()},[]),d.useEffect(()=>{!h&&!u&&v.current&&v.current.focus()},[h,u]),d.useEffect(()=>{const y=v.current;if(!y)return;(()=>{y.style.height="auto";const D=Math.min(y.scrollHeight,200);y.style.height=`${D}px`})()},[l]);const P=d.useCallback(y=>{const T=l?`${l} ${y}`:y;c(T),setTimeout(()=>{var D;(D=v.current)==null||D.focus()},100)},[l]),F=d.useCallback(y=>{S(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 je.webui.post("/api/v1/prompts/chat",{message:y.content,conversation_history:a.filter(L=>L.content&&L.content.trim().length>0).map(L=>({role:L.role,content:L.content})),current_template:t}),D={role:"assistant",content:T.message,timestamp:new Date};i(L=>[...L,D]),Object.keys(T.template_updates).length>0&&e(T.template_updates),n(T.ready_to_save)}catch(T){console.error("Error sending message:",T);const D={role:"assistant",content:"I encountered an error. Could you please try again?",timestamp:new Date};i(L=>[...L,D])}finally{f(!1),setTimeout(()=>{var T;return(T=v.current)==null?void 0:T.focus()},100)}},R=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(ar,{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(Hs,{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(ar,{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(Vt,{variant:"error",message:E,dismissible:!0,onDismiss:()=>S(null)})}),s.jsxs("form",{onSubmit:R,className:"relative",children:[s.jsx($r,{ref:v,value:l,onChange:y=>c(y.target.value),onKeyDown:y=>{y.key==="Enter"&&!y.shiftKey&&(y.preventDefault(),N())},placeholder:j?"Recording...":m?"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:[_&&b.speechToText&&s.jsx(Yf,{disabled:u,onTranscriptionComplete:P,onError:F,onRecordingStateChange:A}),s.jsx(me,{type:"submit",disabled:!l.trim()||u,variant:"ghost",size:"icon",tooltip:"Send message",children:u?s.jsx(ar,{className:"h-4 w-4 animate-spin"}):s.jsx(bg,{className:"h-4 w-4"})})]})]})]})]})},zD=({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,p=!1)=>{const m=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(Nt,{className:"text-muted-foreground text-sm font-medium",children:u}),m&&a&&s.jsx(Or,{variant:"default",className:"bg-primary text-primary-foreground text-xs",children:"Updated"})]}),p?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=p=>p.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(Or,{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(Qo,{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(zs,{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(zs,{className:"mb-4 text-base",children:"Content"}),l()]}),s.jsxs("div",{children:[s.jsx(zs,{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(Qo,{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."})]})})]})},$D=({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:p}=LD(r),[m,x]=d.useState(a||"ai-assisted"),[g,v]=d.useState(!1),[w,b]=d.useState([]),[C,_]=d.useState(null),{allowNavigation:E,NavigationBlocker:S,setBlockingEnabled:j}=PT();d.useEffect(()=>{var D;if(r&&o){const L={name:r.name,description:r.description,category:r.category,command:r.command,promptText:((D=r.productionPrompt)==null?void 0:D.promptText)||""};l(L),_(L)}else _({name:"",description:"",category:void 0,command:"",promptText:""})},[r,o,l]),d.useEffect(()=>{var O,M,J,z;if(!C){j(!1);return}if(!!!((O=i.name)!=null&&O.trim()||(M=i.description)!=null&&M.trim()||i.category||(J=i.command)!=null&&J.trim()||(z=i.promptText)!=null&&z.trim())){j(!1);return}const L=i.name!==C.name||i.description!==C.description||i.category!==C.category||i.command!==C.command||i.promptText!==C.promptText;j(L)},[i,C,j]);const A=(D=!1)=>{D?E(()=>{f(),x("ai-assisted"),v(!1),b([]),_(null),e()}):e()},I=Object.keys(h).length>0,P=Object.values(h).filter(Boolean),F=async()=>{if(o&&r)await u(r.id,!1)&&E(()=>{A(!0),t&&t(r.id)});else{const D=await c();D&&E(()=>{A(!0),t&&t(D)})}},N=async()=>{if(!o||!r)return;await u(r.id,!0)&&E(()=>{A(!0),t&&t(r.id)})},R=D=>{const L=Object.keys(D).filter(O=>{const M=i[O],J=D[O],z=M==null||M===""?"":M,H=J==null||J===""?"":J;return z!==H});l(D),b(L)},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(ms,{title:o?"Edit Prompt":"Create Prompt",breadcrumbs:[{label:"Prompts",onClick:()=>A()},{label:o?"Edit Prompt":"Create Prompt"}],buttons:m==="ai-assisted"?[s.jsxs(me,{"data-testid":"editManuallyButton",onClick:y,variant:"ghost",size:"sm",children:[s.jsx(eo,{className:"mr-1 h-3 w-3"}),"Edit Manually"]},"edit-manually")]:[s.jsxs(me,{"data-testid":"buildWithAIButton",onClick:T,variant:"ghost",size:"sm",children:[s.jsx(Hs,{className:"mr-1 h-3 w-3"}),o?"Edit with AI":"Build with AI"]},"build-with-ai")]}),I&&s.jsx("div",{className:"px-8 py-3",children:s.jsx(Vt,{variant:"error",message:`Please fix the following errors: ${P.join(", ")}`})}),s.jsxs("div",{className:"flex min-h-0 flex-1",children:[s.jsx("div",{className:`w-[40%] overflow-hidden border-r ${m==="manual"?"hidden":""}`,children:s.jsx(FD,{onConfigUpdate:R,currentConfig:i,onReadyToSave:v,initialMessage:n,isEditing:o})}),m==="ai-assisted"&&s.jsx("div",{className:"w-[60%] overflow-hidden",children:s.jsx(zD,{config:i,highlightedFields:w,isReadyToSave:g})}),m==="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(zs,{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(Nt,{htmlFor:"template-name",children:["Name ",s.jsx("span",{className:"text-[var(--color-primary-wMain)]",children:"*"})]}),s.jsx(xr,{id:"template-name",placeholder:"e.g., Code Review Template",value:i.name||"",onChange:D=>l({name:D.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(To,{className:"h-3 w-3"}),h.name]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Nt,{htmlFor:"template-description",children:"Description"}),s.jsx(xr,{id:"template-description",placeholder:"e.g., Reviews code for best practices and potential issues",value:i.description||"",onChange:D=>l({description:D.target.value}),className:"placeholder:text-muted-foreground/50"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Nt,{htmlFor:"template-category",children:"Tag"}),s.jsxs(Nr,{value:i.category||"none",onValueChange:D=>l({category:D==="none"?void 0:D}),children:[s.jsx(Ar,{children:s.jsx(Tr,{placeholder:"Select tag"})}),s.jsxs(Ir,{children:[s.jsx(_t,{value:"none",children:"No Tag"}),s.jsx(_t,{value:"Development",children:"Development"}),s.jsx(_t,{value:"Analysis",children:"Analysis"}),s.jsx(_t,{value:"Documentation",children:"Documentation"}),s.jsx(_t,{value:"Communication",children:"Communication"}),s.jsx(_t,{value:"Testing",children:"Testing"}),s.jsx(_t,{value:"Other",children:"Other"})]})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs(Nt,{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(xr,{id:"template-command",placeholder:"e.g., code-review",value:i.command||"",onChange:D=>l({command:D.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(zs,{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(iv,{id:"template-prompt","data-testid":"prompt-text-input",placeholder:"Enter your prompt template here. Use {{Variable Name}} for placeholders.",value:i.promptText||"",onChange:D=>l({promptText:D.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(To,{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((D,L)=>s.jsx("span",{className:"bg-primary/10 text-primary rounded px-2 py-1 font-mono text-xs",children:`{{${D}}}`},L))})]})]})]})]})})]}),s.jsx(S,{}),s.jsxs("div",{className:"flex justify-end gap-2 border-t p-4",children:[s.jsx(me,{variant:"ghost",onClick:()=>A(),disabled:p,children:o?"Discard Changes":"Cancel"}),o&&s.jsx(me,{variant:"outline",onClick:N,disabled:p,children:p?s.jsxs(s.Fragment,{children:[s.jsx(ar,{className:"mr-2 h-4 w-4 animate-spin"}),"Saving..."]}):"Save New Version"}),s.jsx(me,{"data-testid":"createPromptButton",onClick:F,disabled:p,children:p?s.jsxs(s.Fragment,{children:[s.jsx(ar,{className:"mr-2 h-4 w-4 animate-spin"}),o?"Saving...":"Creating..."]}):o?"Save":"Create"})]})]})})},Cu=At.memo(({isOpen:e,onClose:t,onConfirm:n,promptName:r})=>s.jsx(Bo,{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})),UD=({group:e,onBack:t,onEdit:n,onDeleteAll:r,onRestoreVersion:o})=>{const{addNotification:a,displayError:i}=It(),[l,c]=d.useState([]),[u,f]=d.useState(null),[h,p]=d.useState(!1),[m,x]=d.useState(e),[g,v]=d.useState(!1),w=d.useRef(!1);d.useEffect(()=>{x(e)},[e]);const b=d.useCallback(async(A=!1)=>{p(!0);try{const I=await je.webui.get(`/api/v1/prompts/groups/${e.id}/prompts`);c(I),f(P=>{if(e._selectedVersionId){const F=I.find(N=>N.id===e._selectedVersionId);if(F)return F}if(A&&P){const F=I.find(N=>N.id===P.id);return F||I.find(N=>N.id===e.productionPromptId)||I[0]}else if(I.length>0&&!w.current)return w.current=!0,I.find(F=>F.id===e.productionPromptId)||I[0];return P})}catch(I){console.error("Failed to fetch versions:",I)}finally{p(!1)}},[e.id,e.productionPromptId,e._selectedVersionId]),C=d.useCallback(async()=>{try{const A=await je.webui.get(`/api/v1/prompts/groups/${e.id}`);x(A)}catch(A){console.error("Failed to fetch group data:",A)}},[e.id]);d.useEffect(()=>{b(!0)},[b]);const _=()=>{const A={...m,name:(u==null?void 0:u.name)||m.name,description:(u==null?void 0:u.description)||m.description,category:(u==null?void 0:u.category)||m.category,command:(u==null?void 0:u.command)||m.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}:m.productionPrompt,_editingPromptId:u==null?void 0:u.id,_isEditingActiveVersion:(u==null?void 0:u.id)===m.productionPromptId,_selectedVersionId:u==null?void 0:u.id};n(A)},E=async()=>{if(u){if(u.id===m.productionPromptId){v(!0),setTimeout(()=>v(!1),5e3);return}try{await je.webui.delete(`/api/v1/prompts/${u.id}`),a("Version deleted successfully","success"),f(null),await b(!1)}catch(A){i({title:"Failed to Delete Version",error:Ut(A,"An unknown error occurred while deleting the version.")})}}},S=async()=>{u&&u.id!==m.productionPromptId&&(await o(u.id),await C(),await b(!0))},j=(u==null?void 0:u.id)===m.productionPromptId;return s.jsxs("div",{className:"flex h-full flex-col",children:[s.jsx(ms,{title:`Version History: ${m.name}`,breadcrumbs:[{label:"Prompts",onClick:t},{label:"Version History"}],buttons:[s.jsxs(Xs,{children:[s.jsx(Js,{asChild:!0,children:s.jsx(me,{variant:"ghost",size:"sm",children:s.jsx(Io,{className:"h-4 w-4"})})}),s.jsx(Qs,{align:"end",children:s.jsxs(jn,{onClick:()=>r(m.id,m.name),children:[s.jsx(ts,{size:14,className:"mr-2"}),"Delete All Versions"]})})]},"actions-menu")]}),g&&s.jsx(Vt,{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 I=A.id===m.productionPromptId,P=(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 ${P?"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]}),I&&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:Bu(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(Xs,{children:[s.jsx(Js,{asChild:!0,children:s.jsx(me,{variant:"ghost",size:"sm",children:s.jsx(Io,{className:"h-4 w-4"})})}),s.jsxs(Qs,{align:"end",children:[s.jsxs(jn,{onClick:_,children:[s.jsx(eo,{size:14,className:"mr-2"}),"Edit Version"]}),!j&&s.jsxs(jn,{onClick:S,children:[s.jsx(sa,{size:14,className:"mr-2"}),"Make Active Version"]}),s.jsxs(jn,{onClick:E,children:[s.jsx(ts,{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(Nt,{className:"text-[var(--color-secondaryText-wMain)]",children:"Name"}),s.jsx("div",{className:"rounded p-3 text-sm",children:u.name||m.name})]}),(u.description||m.description)&&s.jsxs("div",{className:"space-y-2",children:[s.jsx(Nt,{className:"text-[var(--color-secondaryText-wMain)]",children:"Description"}),s.jsx("div",{className:"rounded p-3 text-sm",children:u.description||m.description})]}),(u.command||m.command)&&s.jsxs("div",{className:"space-y-2",children:[s.jsx(Nt,{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||m.command]})})]}),(u.category||m.category)&&s.jsxs("div",{className:"space-y-2",children:[s.jsx(Nt,{className:"text-[var(--color-secondaryText-wMain)]",children:"Tag"}),s.jsx("div",{className:"rounded p-3 text-sm",children:u.category||m.category})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Nt,{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,I)=>A.match(/\{\{[^}]+\}\}/)?s.jsx("span",{className:"bg-primary/20 text-primary rounded px-1 font-medium",children:A},I):s.jsx("span",{children:A},I))})]}),s.jsx("div",{className:"border-t pt-4",children:s.jsxs("div",{className:"text-muted-foreground text-xs",children:["Created: ",Bu(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"})})})]})]})},BD=[{icon:gr,label:"Summarize a document"},{icon:sC,label:"Write me an email"},{icon:Md,label:"Translate code"}],Fm=({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(Pn,{open:e,onOpenChange:()=>{},children:s.jsxs(Mn,{className:"sm:max-w-[600px]",children:[s.jsxs(Vn,{children:[s.jsx(Dn,{className:"text-xl",children:"Create Prompt"}),s.jsx(Wn,{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(Vt,{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($r,{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:BD.map((h,p)=>{const m=h.icon;return s.jsxs(Or,{variant:"outline",className:"hover:bg-primary/10 cursor-pointer px-3 py-1.5 transition-colors",onClick:()=>c(h.label),children:[s.jsx(m,{className:"mr-1.5 h-3 w-3"}),h.label]},p)})})]}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(me,{variant:"ghost",onClick:u,children:"Cancel"}),s.jsxs(me,{"data-testid":"generatePromptButton",onClick:l,children:[s.jsx(Hs,{className:"mr-2 h-4 w-4"}),"Generate"]})]})]})})},zm=(e,t,n)=>{if(e&&"reportValidity"in e){const r=Ye(n,t);e.setCustomValidity(r&&r.message||""),e.reportValidity()}},_d=(e,t)=>{for(const n in t.fields){const r=t.fields[n];r&&r.ref&&"reportValidity"in r.ref?zm(r.ref,n,e):r&&r.refs&&r.refs.forEach(o=>zm(o,n,e))}},$m=(e,t)=>{t.shouldUseNativeValidation&&_d(e,t);const n={};for(const r in e){const o=Ye(t.fields,r),a=Object.assign(e[r]||{},{ref:o&&o.ref});if(VD(t.names||Object.keys(e),r)){const i=Object.assign({},Ye(n,r));Zt(i,"root",a),Zt(n,r,i)}else Zt(n,r,a)}return n},VD=(e,t)=>{const n=Um(t);return e.some(r=>Um(r).match(`^${n}\\.\\d+`))};function Um(e){return e.replace(/\]|\[/g,"")}function ge(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 Ws extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class Qy extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}const e1={};function cs(e){return e1}function WD(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 kd(e,t){return typeof t=="bigint"?t.toString():t}function ah(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function ih(e){return e==null}function lh(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function HD(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 Bm=Symbol("evaluating");function Xt(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==Bm)return r===void 0&&(r=Bm,r=n()),r},set(o){Object.defineProperty(e,t,{value:o})},configurable:!0})}function gs(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function xs(...e){const t={};for(const n of e){const r=Object.getOwnPropertyDescriptors(n);Object.assign(t,r)}return Object.defineProperties({},t)}function Vm(e){return JSON.stringify(e)}const t1="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Dl(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const ZD=ah(()=>{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 Xa(e){if(Dl(e)===!1)return!1;const t=e.constructor;if(t===void 0)return!0;const n=t.prototype;return!(Dl(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function n1(e){return Xa(e)?{...e}:Array.isArray(e)?[...e]:e}const GD=new Set(["string","number","symbol"]);function ra(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Zo(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 et(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 YD(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}const KD={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=xs(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 gs(this,"shape",o),o},checks:[]});return Zo(e,r)}function XD(e,t){const n=e._zod.def,r=xs(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 gs(this,"shape",o),o},checks:[]});return Zo(e,r)}function JD(e,t){if(!Xa(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=xs(e._zod.def,{get shape(){const a={...e._zod.def.shape,...t};return gs(this,"shape",a),a},checks:[]});return Zo(e,o)}function QD(e,t){if(!Xa(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 gs(this,"shape",r),r},checks:e._zod.def.checks};return Zo(e,n)}function e6(e,t){const n=xs(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t._zod.def.shape};return gs(this,"shape",r),r},get catchall(){return t._zod.def.catchall},checks:[]});return Zo(e,n)}function t6(e,t,n){const r=xs(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 gs(this,"shape",a),a},checks:[]});return Zo(t,r)}function n6(e,t,n){const r=xs(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 gs(this,"shape",a),a},checks:[]});return Zo(t,r)}function Ds(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 r1(e,t){return t.map(n=>{var r;return(r=n).path??(r.path=[]),n.path.unshift(e),n})}function Vi(e){return typeof e=="string"?e:e==null?void 0:e.message}function us(e,t,n){var o,a,i,l,c,u;const r={...e,path:e.path??[]};if(!e.message){const f=Vi((i=(a=(o=e.inst)==null?void 0:o._zod.def)==null?void 0:a.error)==null?void 0:i.call(a,e))??Vi((l=t==null?void 0:t.error)==null?void 0:l.call(t,e))??Vi((c=n.customError)==null?void 0:c.call(n,e))??Vi((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 ch(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function Ja(...e){const[t,n,r]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:r}:{...t}}const o1=(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,kd,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},uh=ge("$ZodError",o1),Ec=ge("$ZodError",o1,{Parent:Error});function r6(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 o6(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 Nc=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 Ws;if(i.issues.length){const l=new((o==null?void 0:o.Err)??e)(i.issues.map(c=>us(c,a,cs())));throw t1(l,o==null?void 0:o.callee),l}return i.value},s6=Nc(Ec),Tc=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=>us(c,a,cs())));throw t1(l,o==null?void 0:o.callee),l}return i.value},a6=Tc(Ec),Ac=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 Ws;return a.issues.length?{success:!1,error:new(e??uh)(a.issues.map(i=>us(i,o,cs())))}:{success:!0,data:a.value}},i6=Ac(Ec),Ic=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=>us(i,o,cs())))}:{success:!0,data:a.value}},l6=Ic(Ec),c6=e=>(t,n,r)=>{const o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Nc(e)(t,n,o)},u6=e=>(t,n,r)=>Nc(e)(t,n,r),d6=e=>async(t,n,r)=>{const o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Tc(e)(t,n,o)},f6=e=>async(t,n,r)=>Tc(e)(t,n,r),h6=e=>(t,n,r)=>{const o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Ac(e)(t,n,o)},p6=e=>(t,n,r)=>Ac(e)(t,n,r),m6=e=>async(t,n,r)=>{const o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Ic(e)(t,n,o)},g6=e=>async(t,n,r)=>Ic(e)(t,n,r),x6=/^[cC][^\s-]{8,}$/,v6=/^[0-9a-z]+$/,w6=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,b6=/^[0-9a-vA-V]{20}$/,y6=/^[A-Za-z0-9]{27}$/,C6=/^[a-zA-Z0-9_-]{21}$/,S6=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,_6=/^([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})$/,Wm=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)$/,k6=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,j6="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function E6(){return new RegExp(j6,"u")}const N6=/^(?:(?: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])$/,T6=/^(([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}|:))$/,A6=/^((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])$/,I6=/^(([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])$/,R6=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,s1=/^[A-Za-z0-9_-]*$/,P6=/^(?=.{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])?)*\.?$/,M6=/^\+(?:[0-9]){6,14}[0-9]$/,a1="(?:(?:\\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])))",D6=new RegExp(`^${a1}$`);function i1(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 O6(e){return new RegExp(`^${i1(e)}$`)}function L6(e){const t=i1({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(`^${a1}T(?:${r})$`)}const F6=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}$`)},z6=/^-?\d+$/,$6=/^-?\d+(?:\.\d+)?/,U6=/^null$/i,B6=/^[^A-Z]*$/,V6=/^[^a-z]*$/,tr=ge("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),l1={number:"number",bigint:"bigint",object:"date"},c1=ge("$ZodCheckLessThan",(e,t)=>{tr.init(e,t);const n=l1[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})}}),u1=ge("$ZodCheckGreaterThan",(e,t)=>{tr.init(e,t);const n=l1[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})}}),W6=ge("$ZodCheckMultipleOf",(e,t)=>{tr.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):HD(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})}}),H6=ge("$ZodCheckNumberFormat",(e,t)=>{var i;tr.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]=KD[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=z6)}),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})}}),Z6=ge("$ZodCheckMaxLength",(e,t)=>{var n;tr.init(e,t),(n=e._zod.def).when??(n.when=r=>{const o=r.value;return!ih(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=ch(o);r.issues.push({origin:i,code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),G6=ge("$ZodCheckMinLength",(e,t)=>{var n;tr.init(e,t),(n=e._zod.def).when??(n.when=r=>{const o=r.value;return!ih(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=ch(o);r.issues.push({origin:i,code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),Y6=ge("$ZodCheckLengthEquals",(e,t)=>{var n;tr.init(e,t),(n=e._zod.def).when??(n.when=r=>{const o=r.value;return!ih(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=ch(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})}}),Rc=ge("$ZodCheckStringFormat",(e,t)=>{var n,r;tr.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=()=>{})}),K6=ge("$ZodCheckRegex",(e,t)=>{Rc.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=ge("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=B6),Rc.init(e,t)}),X6=ge("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=V6),Rc.init(e,t)}),J6=ge("$ZodCheckIncludes",(e,t)=>{tr.init(e,t);const n=ra(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})}}),Q6=ge("$ZodCheckStartsWith",(e,t)=>{tr.init(e,t);const n=new RegExp(`^${ra(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})}}),e8=ge("$ZodCheckEndsWith",(e,t)=>{tr.init(e,t);const n=new RegExp(`.*${ra(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})}}),t8=ge("$ZodCheckOverwrite",(e,t)=>{tr.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class n8{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 r8={major:4,minor:1,patch:12},fn=ge("$ZodType",(e,t)=>{var o;var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=r8;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=Ds(l),h;for(const p of c){if(p._zod.def.when){if(!p._zod.def.when(l))continue}else if(f)continue;const m=l.issues.length,x=p._zod.check(l);if(x instanceof Promise&&(u==null?void 0:u.async)===!1)throw new Ws;if(h||x instanceof Promise)h=(h??Promise.resolve()).then(async()=>{await x,l.issues.length!==m&&(f||(f=Ds(l,m)))});else{if(l.issues.length===m)continue;f||(f=Ds(l,m))}}return h?h.then(()=>l):l},i=(l,c,u)=>{if(Ds(l))return l.aborted=!0,l;const f=a(c,r,u);if(f instanceof Promise){if(u.async===!1)throw new Ws;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 Ws;return u.then(f=>a(f,r,c))}return a(u,r,c)}}e["~standard"]={validate:a=>{var i;try{const l=i6(e,a);return l.success?{value:l.data}:{issues:(i=l.error)==null?void 0:i.issues}}catch{return l6(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}}),dh=ge("$ZodString",(e,t)=>{var n;fn.init(e,t),e._zod.pattern=[...((n=e==null?void 0:e._zod.bag)==null?void 0:n.patterns)??[]].pop()??F6(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}}),nn=ge("$ZodStringFormat",(e,t)=>{Rc.init(e,t),dh.init(e,t)}),o8=ge("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=_6),nn.init(e,t)}),s8=ge("$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=Wm(r))}else t.pattern??(t.pattern=Wm());nn.init(e,t)}),a8=ge("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=k6),nn.init(e,t)}),i8=ge("$ZodURL",(e,t)=>{nn.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:P6.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})}}}),l8=ge("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=E6()),nn.init(e,t)}),c8=ge("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=C6),nn.init(e,t)}),u8=ge("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=x6),nn.init(e,t)}),d8=ge("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=v6),nn.init(e,t)}),f8=ge("$ZodULID",(e,t)=>{t.pattern??(t.pattern=w6),nn.init(e,t)}),h8=ge("$ZodXID",(e,t)=>{t.pattern??(t.pattern=b6),nn.init(e,t)}),p8=ge("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=y6),nn.init(e,t)}),m8=ge("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=L6(t)),nn.init(e,t)}),g8=ge("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=D6),nn.init(e,t)}),x8=ge("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=O6(t)),nn.init(e,t)}),v8=ge("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=S6),nn.init(e,t)}),w8=ge("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=N6),nn.init(e,t),e._zod.onattach.push(n=>{const r=n._zod.bag;r.format="ipv4"})}),b8=ge("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=T6),nn.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})}}}),y8=ge("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=A6),nn.init(e,t)}),C8=ge("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=I6),nn.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 d1(e){if(e==="")return!0;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const S8=ge("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=R6),nn.init(e,t),e._zod.onattach.push(n=>{n._zod.bag.contentEncoding="base64"}),e._zod.check=n=>{d1(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});function _8(e){if(!s1.test(e))return!1;const t=e.replace(/[-_]/g,r=>r==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return d1(n)}const k8=ge("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=s1),nn.init(e,t),e._zod.onattach.push(n=>{n._zod.bag.contentEncoding="base64url"}),e._zod.check=n=>{_8(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),j8=ge("$ZodE164",(e,t)=>{t.pattern??(t.pattern=M6),nn.init(e,t)});function E8(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 N8=ge("$ZodJWT",(e,t)=>{nn.init(e,t),e._zod.check=n=>{E8(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),f1=ge("$ZodNumber",(e,t)=>{fn.init(e,t),e._zod.pattern=e._zod.bag.pattern??$6,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}}),T8=ge("$ZodNumber",(e,t)=>{H6.init(e,t),f1.init(e,t)}),A8=ge("$ZodNull",(e,t)=>{fn.init(e,t),e._zod.pattern=U6,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}}),I8=ge("$ZodUnknown",(e,t)=>{fn.init(e,t),e._zod.parse=n=>n}),R8=ge("$ZodNever",(e,t)=>{fn.init(e,t),e._zod.parse=(n,r)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function Hm(e,t,n){e.issues.length&&t.issues.push(...r1(n,e.issues)),t.value[n]=e.value}const P8=ge("$ZodArray",(e,t)=>{fn.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=>Hm(u,n,i))):Hm(c,n,i)}return a.length?Promise.all(a).then(()=>n):n}});function Ol(e,t,n,r){e.issues.length&&t.issues.push(...r1(n,e.issues)),e.value===void 0?n in r&&(t.value[n]=void 0):t.value[n]=e.value}function h1(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=YD(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function p1(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(p=>Ol(p,n,f,t))):Ol(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 M8=ge("$ZodObject",(e,t)=>{fn.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=ah(()=>h1(t));Xt(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=Dl,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 p of i.keys){const x=h[p]._zod.run({value:u[p],issues:[]},c);x instanceof Promise?f.push(x.then(g=>Ol(g,l,p,u))):Ol(x,l,p,u)}return a?p1(f,u,l,c,r.value,e):f.length?Promise.all(f).then(()=>l):l}}),D8=ge("$ZodObjectJIT",(e,t)=>{M8.init(e,t);const n=e._zod.parse,r=ah(()=>h1(t)),o=p=>{const m=new n8(["shape","payload","ctx"]),x=r.value,g=C=>{const _=Vm(C);return`shape[${_}]._zod.run({ value: input[${_}], issues: [] }, ctx)`};m.write("const input = payload.value;");const v=Object.create(null);let w=0;for(const C of x.keys)v[C]=`key_${w++}`;m.write("const newResult = {};");for(const C of x.keys){const _=v[C],E=Vm(C);m.write(`const ${_} = ${g(C)};`),m.write(`
406
+ if (${_}.issues.length) {
407
+ payload.issues = payload.issues.concat(${_}.issues.map(iss => ({
408
+ ...iss,
409
+ path: iss.path ? [${E}, ...iss.path] : [${E}]
410
+ })));
411
+ }
412
+
413
+
414
+ if (${_}.value === undefined) {
415
+ if (${E} in input) {
416
+ newResult[${E}] = undefined;
417
+ }
418
+ } else {
419
+ newResult[${E}] = ${_}.value;
420
+ }
421
+
422
+ `)}m.write("payload.value = newResult;"),m.write("return payload;");const b=m.compile();return(C,_)=>b(p,C,_)};let a;const i=Dl,l=!e1.jitless,u=l&&ZD.value,f=t.catchall;let h;e._zod.parse=(p,m)=>{h??(h=r.value);const x=p.value;return i(x)?l&&u&&(m==null?void 0:m.async)===!1&&m.jitless!==!0?(a||(a=o(t.shape)),p=a(p,m),f?p1([],x,p,m,h,e):p):n(p,m):(p.issues.push({expected:"object",code:"invalid_type",input:x,inst:e}),p)}});function Zm(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=>!Ds(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=>us(i,r,cs())))}),t)}const O8=ge("$ZodUnion",(e,t)=>{fn.init(e,t),Xt(e._zod,"optin",()=>t.options.some(o=>o._zod.optin==="optional")?"optional":void 0),Xt(e._zod,"optout",()=>t.options.some(o=>o._zod.optout==="optional")?"optional":void 0),Xt(e._zod,"values",()=>{if(t.options.every(o=>o._zod.values))return new Set(t.options.flatMap(o=>Array.from(o._zod.values)))}),Xt(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=>lh(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=>Zm(c,o,e,a)):Zm(l,o,e,a)}}),L8=ge("$ZodIntersection",(e,t)=>{fn.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])=>Gm(n,c,u)):Gm(n,a,i)}});function jd(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(Xa(e)&&Xa(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=jd(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=jd(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 Gm(e,t,n){if(t.issues.length&&e.issues.push(...t.issues),n.issues.length&&e.issues.push(...n.issues),Ds(e))return e;const r=jd(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 F8=ge("$ZodEnum",(e,t)=>{fn.init(e,t);const n=WD(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=new RegExp(`^(${n.filter(o=>GD.has(typeof o)).map(o=>typeof o=="string"?ra(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}}),z8=ge("$ZodLiteral",(e,t)=>{if(fn.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"?ra(n):n?ra(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}}),$8=ge("$ZodTransform",(e,t)=>{fn.init(e,t),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new Qy(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 Ws;return n.value=o,n}});function Ym(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}const U8=ge("$ZodOptional",(e,t)=>{fn.init(e,t),e._zod.optin="optional",e._zod.optout="optional",Xt(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),Xt(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${lh(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=>Ym(a,n.value)):Ym(o,n.value)}return n.value===void 0?n:t.innerType._zod.run(n,r)}}),B8=ge("$ZodNullable",(e,t)=>{fn.init(e,t),Xt(e._zod,"optin",()=>t.innerType._zod.optin),Xt(e._zod,"optout",()=>t.innerType._zod.optout),Xt(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${lh(n.source)}|null)$`):void 0}),Xt(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)}),V8=ge("$ZodDefault",(e,t)=>{fn.init(e,t),e._zod.optin="optional",Xt(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=>Km(a,t)):Km(o,t)}});function Km(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const W8=ge("$ZodPrefault",(e,t)=>{fn.init(e,t),e._zod.optin="optional",Xt(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))}),H8=ge("$ZodNonOptional",(e,t)=>{fn.init(e,t),Xt(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=>qm(a,e)):qm(o,e)}});function qm(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 Z8=ge("$ZodCatch",(e,t)=>{fn.init(e,t),Xt(e._zod,"optin",()=>t.innerType._zod.optin),Xt(e._zod,"optout",()=>t.innerType._zod.optout),Xt(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=>us(i,r,cs()))},input:n.value}),n.issues=[]),n)):(n.value=o.value,o.issues.length&&(n.value=t.catchValue({...n,error:{issues:o.issues.map(a=>us(a,r,cs()))},input:n.value}),n.issues=[]),n)}}),G8=ge("$ZodPipe",(e,t)=>{fn.init(e,t),Xt(e._zod,"values",()=>t.in._zod.values),Xt(e._zod,"optin",()=>t.in._zod.optin),Xt(e._zod,"optout",()=>t.out._zod.optout),Xt(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=>Wi(i,t.in,r)):Wi(a,t.in,r)}const o=t.in._zod.run(n,r);return o instanceof Promise?o.then(a=>Wi(a,t.out,r)):Wi(o,t.out,r)}});function Wi(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}const Y8=ge("$ZodReadonly",(e,t)=>{fn.init(e,t),Xt(e._zod,"propValues",()=>t.innerType._zod.propValues),Xt(e._zod,"values",()=>t.innerType._zod.values),Xt(e._zod,"optin",()=>t.innerType._zod.optin),Xt(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(Xm):Xm(o)}});function Xm(e){return e.value=Object.freeze(e.value),e}const K8=ge("$ZodCustom",(e,t)=>{tr.init(e,t),fn.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=>Jm(a,n,r,e));Jm(o,n,r,e)}});function Jm(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(Ja(o))}}class q8{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 X8(){return new q8}const Hi=X8();function J8(e,t){return new e({type:"string",...et(t)})}function Q8(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...et(t)})}function Qm(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...et(t)})}function eO(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...et(t)})}function tO(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...et(t)})}function nO(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...et(t)})}function rO(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...et(t)})}function oO(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...et(t)})}function sO(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...et(t)})}function aO(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...et(t)})}function iO(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...et(t)})}function lO(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...et(t)})}function cO(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...et(t)})}function uO(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...et(t)})}function dO(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...et(t)})}function fO(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...et(t)})}function hO(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...et(t)})}function pO(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...et(t)})}function mO(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...et(t)})}function gO(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...et(t)})}function xO(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...et(t)})}function vO(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...et(t)})}function wO(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...et(t)})}function bO(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...et(t)})}function yO(e,t){return new e({type:"string",format:"date",check:"string_format",...et(t)})}function CO(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...et(t)})}function SO(e,t){return new e({type:"string",format:"duration",check:"string_format",...et(t)})}function _O(e,t){return new e({type:"number",checks:[],...et(t)})}function kO(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...et(t)})}function jO(e,t){return new e({type:"null",...et(t)})}function EO(e){return new e({type:"unknown"})}function NO(e,t){return new e({type:"never",...et(t)})}function eg(e,t){return new c1({check:"less_than",...et(t),value:e,inclusive:!1})}function Su(e,t){return new c1({check:"less_than",...et(t),value:e,inclusive:!0})}function tg(e,t){return new u1({check:"greater_than",...et(t),value:e,inclusive:!1})}function _u(e,t){return new u1({check:"greater_than",...et(t),value:e,inclusive:!0})}function ng(e,t){return new W6({check:"multiple_of",...et(t),value:e})}function m1(e,t){return new Z6({check:"max_length",...et(t),maximum:e})}function Ll(e,t){return new G6({check:"min_length",...et(t),minimum:e})}function g1(e,t){return new Y6({check:"length_equals",...et(t),length:e})}function TO(e,t){return new K6({check:"string_format",format:"regex",...et(t),pattern:e})}function AO(e){return new q6({check:"string_format",format:"lowercase",...et(e)})}function IO(e){return new X6({check:"string_format",format:"uppercase",...et(e)})}function RO(e,t){return new J6({check:"string_format",format:"includes",...et(t),includes:e})}function PO(e,t){return new Q6({check:"string_format",format:"starts_with",...et(t),prefix:e})}function MO(e,t){return new e8({check:"string_format",format:"ends_with",...et(t),suffix:e})}function bi(e){return new t8({check:"overwrite",tx:e})}function DO(e){return bi(t=>t.normalize(e))}function OO(){return bi(e=>e.trim())}function LO(){return bi(e=>e.toLowerCase())}function FO(){return bi(e=>e.toUpperCase())}function zO(e,t,n){return new e({type:"array",element:t,...et(n)})}function $O(e,t,n){return new e({type:"custom",check:"custom",fn:t,...et(n)})}function UO(e){const t=BO(n=>(n.addIssue=r=>{if(typeof r=="string")n.issues.push(Ja(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(Ja(o))}},e(n.value,n)));return t}function BO(e,t){const n=new tr({check:"custom",...et(t)});return n._zod.check=e,n}function rg(e,t){try{var n=e()}catch(r){return t(r)}return n&&n.then?n.then(void 0,t):n}function VO(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]=yf(i,t,n,o,u?[].concat(u,r.message):r.message)}e.shift()}return n}function WO(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]=yf(i,t,n,o,u?[].concat(u,r.message):r.message)}e.shift()}return n}function HO(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(rg(function(){return Promise.resolve(e[n.mode==="sync"?"parse":"parseAsync"](r,t)).then(function(i){return a.shouldUseNativeValidation&&_d({},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:$m(VO(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(rg(function(){return Promise.resolve((n.mode==="sync"?s6:a6)(e,r,t)).then(function(i){return a.shouldUseNativeValidation&&_d({},a),{errors:{},values:n.raw?Object.assign({},r):i}})},function(i){if(function(l){return l instanceof uh}(i))return{values:{},errors:$m(WO(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 ZO=ge("ZodISODateTime",(e,t)=>{m8.init(e,t),an.init(e,t)});function GO(e){return bO(ZO,e)}const YO=ge("ZodISODate",(e,t)=>{g8.init(e,t),an.init(e,t)});function KO(e){return yO(YO,e)}const qO=ge("ZodISOTime",(e,t)=>{x8.init(e,t),an.init(e,t)});function XO(e){return CO(qO,e)}const JO=ge("ZodISODuration",(e,t)=>{v8.init(e,t),an.init(e,t)});function QO(e){return SO(JO,e)}const eL=(e,t)=>{uh.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:n=>o6(e,n)},flatten:{value:n=>r6(e,n)},addIssue:{value:n=>{e.issues.push(n),e.message=JSON.stringify(e.issues,kd,2)}},addIssues:{value:n=>{e.issues.push(...n),e.message=JSON.stringify(e.issues,kd,2)}},isEmpty:{get(){return e.issues.length===0}}})},yr=ge("ZodError",eL,{Parent:Error}),tL=Nc(yr),nL=Tc(yr),rL=Ac(yr),oL=Ic(yr),sL=c6(yr),aL=u6(yr),iL=d6(yr),lL=f6(yr),cL=h6(yr),uL=p6(yr),dL=m6(yr),fL=g6(yr),mn=ge("ZodType",(e,t)=>(fn.init(e,t),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.check=(...n)=>e.clone(xs(t,{checks:[...t.checks??[],...n.map(r=>typeof r=="function"?{_zod:{check:r,def:{check:"custom"},onattach:[]}}:r)]})),e.clone=(n,r)=>Zo(e,n,r),e.brand=()=>e,e.register=(n,r)=>(n.add(e,r),e),e.parse=(n,r)=>tL(e,n,r,{callee:e.parse}),e.safeParse=(n,r)=>rL(e,n,r),e.parseAsync=async(n,r)=>nL(e,n,r,{callee:e.parseAsync}),e.safeParseAsync=async(n,r)=>oL(e,n,r),e.spa=e.safeParseAsync,e.encode=(n,r)=>sL(e,n,r),e.decode=(n,r)=>aL(e,n,r),e.encodeAsync=async(n,r)=>iL(e,n,r),e.decodeAsync=async(n,r)=>lL(e,n,r),e.safeEncode=(n,r)=>cL(e,n,r),e.safeDecode=(n,r)=>uL(e,n,r),e.safeEncodeAsync=async(n,r)=>dL(e,n,r),e.safeDecodeAsync=async(n,r)=>fL(e,n,r),e.refine=(n,r)=>e.check(oF(n,r)),e.superRefine=n=>e.check(sF(n)),e.overwrite=n=>e.check(bi(n)),e.optional=()=>ig(e),e.nullable=()=>lg(e),e.nullish=()=>ig(lg(e)),e.nonoptional=n=>XL(e,n),e.array=()=>LL(e),e.or=n=>Pc([e,n]),e.and=n=>UL(e,n),e.transform=n=>cg(e,HL(n)),e.default=n=>YL(e,n),e.prefault=n=>qL(e,n),e.catch=n=>QL(e,n),e.pipe=n=>cg(e,n),e.readonly=()=>nF(e),e.describe=n=>{const r=e.clone();return Hi.add(r,{description:n}),r},Object.defineProperty(e,"description",{get(){var n;return(n=Hi.get(e))==null?void 0:n.description},configurable:!0}),e.meta=(...n)=>{if(n.length===0)return Hi.get(e);const r=e.clone();return Hi.add(r,n[0]),r},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e)),x1=ge("_ZodString",(e,t)=>{dh.init(e,t),mn.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(TO(...r)),e.includes=(...r)=>e.check(RO(...r)),e.startsWith=(...r)=>e.check(PO(...r)),e.endsWith=(...r)=>e.check(MO(...r)),e.min=(...r)=>e.check(Ll(...r)),e.max=(...r)=>e.check(m1(...r)),e.length=(...r)=>e.check(g1(...r)),e.nonempty=(...r)=>e.check(Ll(1,...r)),e.lowercase=r=>e.check(AO(r)),e.uppercase=r=>e.check(IO(r)),e.trim=()=>e.check(OO()),e.normalize=(...r)=>e.check(DO(...r)),e.toLowerCase=()=>e.check(LO()),e.toUpperCase=()=>e.check(FO())}),hL=ge("ZodString",(e,t)=>{dh.init(e,t),x1.init(e,t),e.email=n=>e.check(Q8(pL,n)),e.url=n=>e.check(oO(mL,n)),e.jwt=n=>e.check(wO(AL,n)),e.emoji=n=>e.check(sO(gL,n)),e.guid=n=>e.check(Qm(og,n)),e.uuid=n=>e.check(eO(Zi,n)),e.uuidv4=n=>e.check(tO(Zi,n)),e.uuidv6=n=>e.check(nO(Zi,n)),e.uuidv7=n=>e.check(rO(Zi,n)),e.nanoid=n=>e.check(aO(xL,n)),e.guid=n=>e.check(Qm(og,n)),e.cuid=n=>e.check(iO(vL,n)),e.cuid2=n=>e.check(lO(wL,n)),e.ulid=n=>e.check(cO(bL,n)),e.base64=n=>e.check(gO(EL,n)),e.base64url=n=>e.check(xO(NL,n)),e.xid=n=>e.check(uO(yL,n)),e.ksuid=n=>e.check(dO(CL,n)),e.ipv4=n=>e.check(fO(SL,n)),e.ipv6=n=>e.check(hO(_L,n)),e.cidrv4=n=>e.check(pO(kL,n)),e.cidrv6=n=>e.check(mO(jL,n)),e.e164=n=>e.check(vO(TL,n)),e.datetime=n=>e.check(GO(n)),e.date=n=>e.check(KO(n)),e.time=n=>e.check(XO(n)),e.duration=n=>e.check(QO(n))});function ds(e){return J8(hL,e)}const an=ge("ZodStringFormat",(e,t)=>{nn.init(e,t),x1.init(e,t)}),pL=ge("ZodEmail",(e,t)=>{a8.init(e,t),an.init(e,t)}),og=ge("ZodGUID",(e,t)=>{o8.init(e,t),an.init(e,t)}),Zi=ge("ZodUUID",(e,t)=>{s8.init(e,t),an.init(e,t)}),mL=ge("ZodURL",(e,t)=>{i8.init(e,t),an.init(e,t)}),gL=ge("ZodEmoji",(e,t)=>{l8.init(e,t),an.init(e,t)}),xL=ge("ZodNanoID",(e,t)=>{c8.init(e,t),an.init(e,t)}),vL=ge("ZodCUID",(e,t)=>{u8.init(e,t),an.init(e,t)}),wL=ge("ZodCUID2",(e,t)=>{d8.init(e,t),an.init(e,t)}),bL=ge("ZodULID",(e,t)=>{f8.init(e,t),an.init(e,t)}),yL=ge("ZodXID",(e,t)=>{h8.init(e,t),an.init(e,t)}),CL=ge("ZodKSUID",(e,t)=>{p8.init(e,t),an.init(e,t)}),SL=ge("ZodIPv4",(e,t)=>{w8.init(e,t),an.init(e,t)}),_L=ge("ZodIPv6",(e,t)=>{b8.init(e,t),an.init(e,t)}),kL=ge("ZodCIDRv4",(e,t)=>{y8.init(e,t),an.init(e,t)}),jL=ge("ZodCIDRv6",(e,t)=>{C8.init(e,t),an.init(e,t)}),EL=ge("ZodBase64",(e,t)=>{S8.init(e,t),an.init(e,t)}),NL=ge("ZodBase64URL",(e,t)=>{k8.init(e,t),an.init(e,t)}),TL=ge("ZodE164",(e,t)=>{j8.init(e,t),an.init(e,t)}),AL=ge("ZodJWT",(e,t)=>{N8.init(e,t),an.init(e,t)}),v1=ge("ZodNumber",(e,t)=>{f1.init(e,t),mn.init(e,t),e.gt=(r,o)=>e.check(tg(r,o)),e.gte=(r,o)=>e.check(_u(r,o)),e.min=(r,o)=>e.check(_u(r,o)),e.lt=(r,o)=>e.check(eg(r,o)),e.lte=(r,o)=>e.check(Su(r,o)),e.max=(r,o)=>e.check(Su(r,o)),e.int=r=>e.check(sg(r)),e.safe=r=>e.check(sg(r)),e.positive=r=>e.check(tg(0,r)),e.nonnegative=r=>e.check(_u(0,r)),e.negative=r=>e.check(eg(0,r)),e.nonpositive=r=>e.check(Su(0,r)),e.multipleOf=(r,o)=>e.check(ng(r,o)),e.step=(r,o)=>e.check(ng(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 Ed(e){return _O(v1,e)}const IL=ge("ZodNumberFormat",(e,t)=>{T8.init(e,t),v1.init(e,t)});function sg(e){return kO(IL,e)}const RL=ge("ZodNull",(e,t)=>{A8.init(e,t),mn.init(e,t)});function fh(e){return jO(RL,e)}const PL=ge("ZodUnknown",(e,t)=>{I8.init(e,t),mn.init(e,t)});function ag(){return EO(PL)}const ML=ge("ZodNever",(e,t)=>{R8.init(e,t),mn.init(e,t)});function DL(e){return NO(ML,e)}const OL=ge("ZodArray",(e,t)=>{P8.init(e,t),mn.init(e,t),e.element=t.element,e.min=(n,r)=>e.check(Ll(n,r)),e.nonempty=n=>e.check(Ll(1,n)),e.max=(n,r)=>e.check(m1(n,r)),e.length=(n,r)=>e.check(g1(n,r)),e.unwrap=()=>e.element});function LL(e,t){return zO(OL,e,t)}const FL=ge("ZodObject",(e,t)=>{D8.init(e,t),mn.init(e,t),Xt(e,"shape",()=>t.shape),e.keyof=()=>BL(Object.keys(e._zod.def.shape)),e.catchall=n=>e.clone({...e._zod.def,catchall:n}),e.passthrough=()=>e.clone({...e._zod.def,catchall:ag()}),e.loose=()=>e.clone({...e._zod.def,catchall:ag()}),e.strict=()=>e.clone({...e._zod.def,catchall:DL()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=n=>JD(e,n),e.safeExtend=n=>QD(e,n),e.merge=n=>e6(e,n),e.pick=n=>qD(e,n),e.omit=n=>XD(e,n),e.partial=(...n)=>t6(w1,e,n[0]),e.required=(...n)=>n6(b1,e,n[0])});function yi(e,t){const n={type:"object",shape:e??{},...et(t)};return new FL(n)}const zL=ge("ZodUnion",(e,t)=>{O8.init(e,t),mn.init(e,t),e.options=t.options});function Pc(e,t){return new zL({type:"union",options:e,...et(t)})}const $L=ge("ZodIntersection",(e,t)=>{L8.init(e,t),mn.init(e,t)});function UL(e,t){return new $L({type:"intersection",left:e,right:t})}const Nd=ge("ZodEnum",(e,t)=>{F8.init(e,t),mn.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 Nd({...t,checks:[],...et(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 Nd({...t,checks:[],...et(o),entries:a})}});function BL(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(r=>[r,r])):e;return new Nd({type:"enum",entries:n,...et(t)})}const VL=ge("ZodLiteral",(e,t)=>{z8.init(e,t),mn.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 hh(e,t){return new VL({type:"literal",values:Array.isArray(e)?e:[e],...et(t)})}const WL=ge("ZodTransform",(e,t)=>{$8.init(e,t),mn.init(e,t),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new Qy(e.constructor.name);n.addIssue=a=>{if(typeof a=="string")n.issues.push(Ja(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(Ja(i))}};const o=t.transform(n.value,n);return o instanceof Promise?o.then(a=>(n.value=a,n)):(n.value=o,n)}});function HL(e){return new WL({type:"transform",transform:e})}const w1=ge("ZodOptional",(e,t)=>{U8.init(e,t),mn.init(e,t),e.unwrap=()=>e._zod.def.innerType});function ig(e){return new w1({type:"optional",innerType:e})}const ZL=ge("ZodNullable",(e,t)=>{B8.init(e,t),mn.init(e,t),e.unwrap=()=>e._zod.def.innerType});function lg(e){return new ZL({type:"nullable",innerType:e})}const GL=ge("ZodDefault",(e,t)=>{V8.init(e,t),mn.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function YL(e,t){return new GL({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():n1(t)}})}const KL=ge("ZodPrefault",(e,t)=>{W8.init(e,t),mn.init(e,t),e.unwrap=()=>e._zod.def.innerType});function qL(e,t){return new KL({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():n1(t)}})}const b1=ge("ZodNonOptional",(e,t)=>{H8.init(e,t),mn.init(e,t),e.unwrap=()=>e._zod.def.innerType});function XL(e,t){return new b1({type:"nonoptional",innerType:e,...et(t)})}const JL=ge("ZodCatch",(e,t)=>{Z8.init(e,t),mn.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function QL(e,t){return new JL({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}const eF=ge("ZodPipe",(e,t)=>{G8.init(e,t),mn.init(e,t),e.in=t.in,e.out=t.out});function cg(e,t){return new eF({type:"pipe",in:e,out:t})}const tF=ge("ZodReadonly",(e,t)=>{Y8.init(e,t),mn.init(e,t),e.unwrap=()=>e._zod.def.innerType});function nF(e){return new tF({type:"readonly",innerType:e})}const rF=ge("ZodCustom",(e,t)=>{K8.init(e,t),mn.init(e,t)});function oF(e,t={}){return $O(rF,e,t)}function sF(e){return UO(e)}const on={NAME_MAX:255,DESCRIPTION_MAX:1e3,TAG_MAX:100,COMMAND_MAX:50,PROMPT_TEXT_MAX:1e4},aF=yi({authorName:Pc([ds(),fh()]).optional(),originalVersion:Ed().int().positive(),originalCreatedAt:Ed().int().positive()}),ku=()=>Pc([ds(),fh()]).optional(),iF=yi({name:ds().min(1,"Name is required"),description:ku(),category:ku(),command:ku(),promptText:ds().min(1,"Prompt text is required"),metadata:Pc([aF,fh()]).optional()}),lF=yi({version:hh("1.0",{message:"Unsupported export format version. Only version 1.0 is currently supported."}),exportedAt:Ed().int().positive("Export timestamp must be a valid positive number"),prompt:iF});yi({command:ds().max(on.COMMAND_MAX,`Command must be ${on.COMMAND_MAX} characters or less`).optional().or(hh(""))});function cF(e){const t=[],n=e.prompt;return n.name&&n.name.length>on.NAME_MAX&&t.push({field:"Name",currentLength:n.name.length,maxLength:on.NAME_MAX,message:`Name will be truncated from ${n.name.length} to ${on.NAME_MAX} characters`}),n.description&&n.description.length>on.DESCRIPTION_MAX&&t.push({field:"Description",currentLength:n.description.length,maxLength:on.DESCRIPTION_MAX,message:`Description will be truncated from ${n.description.length} to ${on.DESCRIPTION_MAX} characters`}),n.category&&n.category.length>on.TAG_MAX&&t.push({field:"Tag",currentLength:n.category.length,maxLength:on.TAG_MAX,message:`Tag will be truncated from ${n.category.length} to ${on.TAG_MAX} characters`}),n.command&&n.command.length>on.COMMAND_MAX&&t.push({field:"Command",currentLength:n.command.length,maxLength:on.COMMAND_MAX,message:`Command will be truncated from ${n.command.length} to ${on.COMMAND_MAX} characters`}),n.promptText&&n.promptText.length>on.PROMPT_TEXT_MAX&&t.push({field:"Prompt text",currentLength:n.promptText.length,maxLength:on.PROMPT_TEXT_MAX,message:`Prompt text will be truncated from ${n.promptText.length.toLocaleString()} to ${on.PROMPT_TEXT_MAX.toLocaleString()} characters`}),t}function uF(e){return e.issues.map(t=>{const n=t.path.join(".");return n?`${n}: ${t.message}`:t.message})}function dF(e,t){return e.issues.some(n=>n.path.includes(t))}function fF(e,t){const n=e.issues.find(r=>r.path.includes(t));return n==null?void 0:n.message}const hF=yi({name:ds().min(1,"Name is required").max(on.NAME_MAX,`Name must be ${on.NAME_MAX} characters or less`),command:ds().max(on.COMMAND_MAX,`Chat shortcut must be ${on.COMMAND_MAX} characters or less`).optional().or(hh(""))}),pF=({open:e,onOpenChange:t,onImport:n,existingPrompts:r})=>{var q;const[o,a]=d.useState(null),[i,l]=d.useState(null),[c,u]=d.useState([]),[f,h]=d.useState([]),[p,m]=d.useState(!1),[x,g]=d.useState(!1),[v,w]=d.useState(""),b=d.useRef(null),[C,_]=d.useState(!1),[E,S]=d.useState(!1),{register:j,handleSubmit:A,formState:{errors:I},reset:P,setValue:F,watch:N}=Xj({resolver:HO(hF),defaultValues:{name:"",command:""},mode:"onChange"}),R=N("name"),y=N("command"),T=d.useCallback((Y,re)=>{var oe,ae;const ue=Y.trim().toLowerCase(),ce=re.trim().toLowerCase();let pe=!1,k=!1;for(const G of r)ue&&((oe=G.name)==null?void 0:oe.toLowerCase())===ue&&(pe=!0),ce&&((ae=G.command)==null?void 0:ae.toLowerCase())===ce&&(k=!0);return{hasNameConflict:pe,hasCommandConflict:k}},[r]),D=d.useMemo(()=>o?T(R||"",y||""):{hasNameConflict:!1,hasCommandConflict:!1},[o,R,y,T]),L=D.hasNameConflict||D.hasCommandConflict,O=d.useCallback(async Y=>{if(l(null),u([]),h([]),a(null),!Y.name.endsWith(".json"))return l("Please select a JSON file"),null;if(Y.size>1024*1024)return l("File size must be less than 1MB"),null;try{const re=await Y.text();let ue;try{ue=JSON.parse(re)}catch{return l("Failed to parse JSON file. Please ensure it's a valid JSON format."),null}const ce=lF.safeParse(ue);if(!ce.success){const k=uF(ce.error);if(dF(ce.error,"version")){const oe=fF(ce.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 pe=cF(ce.data);return h(pe),ce.data}catch{return l("Failed to read file. Please try again."),null}},[]),M=d.useCallback(Y=>{const re=Y.prompt.name||"",ue=Y.prompt.command||"",ce=T(re,ue);_(ce.hasNameConflict),S(ce.hasCommandConflict)},[T]),J=async Y=>{var ce;const re=(ce=Y.target.files)==null?void 0:ce[0];if(!re)return;const ue=await O(re);ue&&(a(ue),w(re.name),F("name",ue.prompt.name||""),F("command",ue.prompt.command||""),M(ue)),Y.target&&(Y.target.value="")},z=Y=>{Y.preventDefault(),Y.stopPropagation(),g(!0)},H=Y=>{Y.preventDefault(),Y.stopPropagation(),g(!1)},U=async Y=>{Y.preventDefault(),Y.stopPropagation(),g(!1);const re=Y.dataTransfer.files;if(re&&re.length>0){const ue=re[0],ce=await O(ue);ce&&(a(ce),w(ue.name),F("name",ce.prompt.name||""),F("command",ce.prompt.command||""),M(ce))}},X=()=>{var Y;(Y=b.current)==null||Y.click()},W=async Y=>{if(!o){l("Please select a JSON file to import");return}if(!L){m(!0),l(null);try{const re={...o,prompt:{...o.prompt,name:Y.name,command:Y.command||void 0}};await n(re,{preserveCommand:!!Y.command,preserveCategory:!0}),te(),t(!1)}catch(re){l(re instanceof Error?re.message:"Failed to import prompt")}finally{m(!1)}}},te=()=>{a(null),w(""),l(null),u([]),h([]),_(!1),S(!1),P()},$=()=>{p||(te(),t(!1))};return s.jsx(Pn,{open:e,onOpenChange:$,children:s.jsxs(Mn,{className:"max-h-[90vh] overflow-y-auto sm:max-w-[500px]",children:[s.jsx(Vn,{children:s.jsx(Dn,{children:"Import Prompt"})}),s.jsxs("form",{onSubmit:A(W),className:"space-y-4 overflow-x-hidden py-4",children:[v?s.jsxs("div",{className:"bg-muted/30 flex items-center gap-3 rounded-md border p-4",children:[s.jsx(Da,{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:v})}),s.jsx(me,{type:"button",variant:"ghost",size:"sm",onClick:te,disabled:p,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:z,onDragLeave:H,onDrop:U,onClick:X,children:[s.jsx(Da,{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:p,className:"hidden"})]}),i&&s.jsxs("div",{className:"space-y-2",children:[s.jsx(Vt,{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((Y,re)=>s.jsx("li",{children:Y},re))})})]}),o&&!i&&s.jsxs("div",{className:"space-y-4",children:[L&&s.jsx(Vt,{variant:"error",message:s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"font-medium",children:"Conflicts found: "}),D.hasNameConflict&&s.jsx("span",{className:"font-semibold",children:R}),D.hasNameConflict&&D.hasCommandConflict&&" name and ",D.hasCommandConflict&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"font-semibold",children:y})," chat shortcut"]}),D.hasNameConflict&&!D.hasCommandConflict&&" name",D.hasNameConflict&&D.hasCommandConflict?" already exist.":" already exists."]})}),f.length>0&&!L&&s.jsx(Vt,{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((Y,re)=>s.jsx("li",{children:Y.message},re))})]})}),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(Nt,{htmlFor:"import-name",className:"text-muted-foreground text-xs",children:["Name",D.hasNameConflict&&s.jsx("span",{className:"text-destructive",children:"*"})]}),C?s.jsxs("div",{className:"space-y-2",children:[s.jsx(xr,{id:"import-name",...j("name"),className:`${I.name||D.hasNameConflict?"border-red-500 focus-visible:ring-red-500":""}`,maxLength:on.NAME_MAX}),D.hasNameConflict&&!I.name&&s.jsx(Vt,{variant:"error",message:"Already exists. Change name."}),I.name&&s.jsx("p",{className:"text-xs text-[#647481] dark:text-[#B1B9C0]",children:I.name.message})]}):s.jsx("p",{className:"overflow-wrap-anywhere text-sm break-words",children:R})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(Nt,{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(Nt,{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(Nt,{htmlFor:"import-command",className:"text-muted-foreground text-xs",children:["Chat Shortcut",D.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(xr,{id:"import-command",...j("command"),placeholder:"e.g., code-review",className:`flex-1 ${I.command||D.hasCommandConflict?"border-red-500 focus-visible:ring-red-500":""}`,maxLength:on.COMMAND_MAX})]}),D.hasCommandConflict&&!I.command&&s.jsx(Vt,{variant:"error",message:"Already exists. Change chat shortcut."}),I.command&&s.jsx("p",{className:"text-xs text-[#647481] dark:text-[#B1B9C0]",children:I.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(Nt,{className:"text-muted-foreground text-xs",children:"Original Author"}),(q=o.prompt.metadata)!=null&&q.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(er,{children:[s.jsx(me,{type:"button",variant:"ghost",onClick:$,disabled:p,children:"Cancel"}),s.jsx(me,{"data-testid":"importPromptButton",type:"submit",disabled:p||!o||L,children:p?"Importing...":"Import"})]})]})]})})},Gi=()=>{var q;const e=zo(),t=zr(),n=Xg(),{addNotification:r,displayError:o}=It(),[a,i]=d.useState([]),[l,c]=d.useState(!1),[u,f]=d.useState(!1),[h,p]=d.useState(!1),[m,x]=d.useState(null),[g,v]=d.useState(null),[w,b]=d.useState("ai-assisted"),[C,_]=d.useState(0),[E,S]=d.useState(null),[j,A]=d.useState(null),[I,P]=d.useState(null),[F,N]=d.useState(!1),[R,y]=d.useState(null),[T,D]=d.useState(!1),L=d.useCallback(async()=>{c(!0);try{const Y=await je.webui.get("/api/v1/prompts/groups/all");i(Y)}catch(Y){o({title:"Failed to Load Prompts",error:Ut(Y,"An error occurred while fetching prompt groups.")})}finally{c(!1)}},[o]);d.useEffect(()=>{L()},[L]),d.useEffect(()=>{var Y;if((n==null?void 0:n.view)==="builder")if(n.mode==="edit"&&n.promptId)(async()=>{try{const ue=await je.webui.get(`/api/v1/prompts/groups/${n.promptId}`);v(ue),b("ai-assisted"),f(!0)}catch(ue){o({title:"Failed to Edit Prompt",error:Ut(ue,"An error occurred while fetching prompt.")})}})();else{v(null);const re=n.mode==="ai-assisted"?"ai-assisted":"manual";b(re),re==="ai-assisted"&&((Y=t.state)!=null&&Y.taskDescription)?x(t.state.taskDescription):x(null),_(ue=>ue+1),f(!0)}else(n==null?void 0:n.view)==="versions"&&n.promptId?(async()=>{try{const ue=await je.webui.get(`/api/v1/prompts/groups/${n.promptId}`);S(ue)}catch(ue){o({title:"Failed to View Versions",error:Ut(ue,"An error occurred while fetching versions.")})}})():(f(!1),S(null),v(null))},[n,(q=t.state)==null?void 0:q.taskDescription,o]);const O=(Y,re)=>{A({id:Y,name:re})},M=async()=>{if(j)try{await je.webui.delete(`/api/v1/prompts/groups/${j.id}`),(E==null?void 0:E.id)===j.id&&S(null),await L(),A(null),r("Prompt deleted","success")}catch(Y){A(null),o({title:"Failed to Delete Prompt",error:Ut(Y,"An error occurred while deleting the prompt.")})}},J=Y=>{e(`/prompts/${Y.id}/edit`)},z=async Y=>{try{await je.webui.patch(`/api/v1/prompts/${Y}/make-production`),L(),r("Version made active","success")}catch(re){o({title:"Failed to Update Version",error:Ut(re,"An error occurred while making the version active.")})}},H=Y=>{p(!1),e("/prompts/new?mode=ai-assisted",{state:{taskDescription:Y}})},U=Y=>{var pe;const re=((pe=Y.productionPrompt)==null?void 0:pe.promptText)||"";Gs(re).length>0?(y(Y),N(!0)):e("/chat",{state:{promptText:re,groupId:Y.id,groupName:Y.name}})},X=Y=>{R&&(e("/chat",{state:{promptText:Y,groupId:R.id,groupName:R.name}}),N(!1),y(null))},W=async(Y,re)=>{try{i(ue=>ue.map(ce=>ce.id===Y?{...ce,isPinned:!re}:ce)),await je.webui.patch(`/api/v1/prompts/groups/${Y}/pin`)}catch(ue){i(ce=>ce.map(pe=>pe.id===Y?{...pe,isPinned:re}:pe)),o({title:"Failed to Update Pin Status",error:Ut(ue,"An error occurred while updating the pin status.")})}},te=async Y=>{try{const re=await je.webui.get(`/api/v1/prompts/groups/${Y.id}/export`),ue=new Blob([JSON.stringify(re,null,2)],{type:"application/json"}),ce=`prompt-${Y.name.replace(/[^a-z0-9]/gi,"-").toLowerCase()}-${Date.now()}.json`;ni(ue,ce),r("Prompt exported successfully","success")}catch(re){o({title:"Failed to Export Prompt",error:Ut(re,"An error occurred while exporting the prompt.")})}},$=async(Y,re)=>{try{const ue={prompt_data:{version:Y.version,exported_at:Y.exportedAt,prompt:{name:Y.prompt.name,description:Y.prompt.description,category:Y.prompt.category,command:Y.prompt.command,prompt_text:Y.prompt.promptText,metadata:Y.prompt.metadata?{author_name:Y.prompt.metadata.authorName,original_version:Y.prompt.metadata.originalVersion,original_created_at:Y.prompt.metadata.originalCreatedAt}:void 0}},options:{preserve_command:re.preserveCommand,preserve_category:re.preserveCategory}},ce=await je.webui.post("/api/v1/prompts/import",ue);f(!1),D(!1),x(null),v(null),await L(),P(ce.prompt_group_id);const pe=(ce.warnings||[]).filter(k=>!k.toLowerCase().includes("truncated"));if(pe.length>0){const k=pe.length===1?pe[0]:pe.join("; ");r(`Prompt imported with notes: ${k}`,"info")}else r("Prompt imported","success")}catch(ue){throw console.error("Failed to import prompt:",ue),ue}};return u?s.jsxs(s.Fragment,{children:[s.jsx($D,{onBack:()=>{e("/prompts")},onSuccess:async Y=>{Y&&P(Y),await L(),e("/prompts")},initialMessage:m,editingGroup:g,isEditing:!!g,initialMode:w},`builder-${C}-${(g==null?void 0:g.id)||"new"}`),j&&s.jsx(Cu,{isOpen:!0,onClose:()=>A(null),onConfirm:M,promptName:j.name},`delete-${j.id}`),s.jsx(Fm,{isOpen:h,onClose:()=>p(!1),onGenerate:H})]}):E?s.jsxs(s.Fragment,{children:[s.jsx(UD,{group:E,onBack:()=>e("/prompts"),onBackToPromptDetail:()=>e("/prompts"),onEdit:J,onDeleteAll:O,onRestoreVersion:z}),j&&s.jsx(Cu,{isOpen:!0,onClose:()=>A(null),onConfirm:M,promptName:j.name},`delete-${j.id}`)]}):s.jsxs("div",{className:"flex h-full w-full flex-col",children:[s.jsx(ms,{title:"Prompts",buttons:[s.jsxs(me,{variant:"ghost",title:"Import Prompt",onClick:()=>D(!0),children:[s.jsx(Os,{className:"size-4"}),"Import Prompt"]},"importPrompt"),s.jsxs(me,{"data-testid":"refreshPrompts",disabled:l,variant:"ghost",title:"Refresh Prompts",onClick:()=>L(),children:[s.jsx(Ul,{className:"size-4"}),"Refresh Prompts"]},"refreshPrompts")]}),l?s.jsx(Pr,{title:"Loading prompts...",variant:"loading"}):s.jsx("div",{className:"bg-card-background relative flex-1 p-4",children:s.jsx(MD,{prompts:a,onManualCreate:()=>e("/prompts/new?mode=manual"),onAIAssisted:()=>p(!0),onEdit:J,onDelete:O,onViewVersions:Y=>e(`/prompts/${Y.id}/versions`),onUseInChat:U,onTogglePin:W,onExport:te,newlyCreatedPromptId:I})}),j&&s.jsx(Cu,{isOpen:!0,onClose:()=>A(null),onConfirm:M,promptName:j.name},`delete-${j.id}`),s.jsx(Fm,{isOpen:h,onClose:()=>p(!1),onGenerate:H}),F&&R&&s.jsx(Kf,{group:R,onSubmit:X,onClose:()=>{N(!1),y(null)}}),s.jsx(pF,{open:T,onOpenChange:D,onImport:$,existingPrompts:a})]})},mF=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)"}}),Td=({data:e,maxDepth:t=2,className:n=""})=>{const{currentTheme:r}=ci(),o=d.useMemo(()=>mF(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(aC,{data:i,theme:o,viewOnly:!0,collapse:a,showStringQuotes:!0,showCollectionCount:"when-closed"})})},gF=({isOpen:e,onClose:t,onSubmit:n,isSubmitting:r=!1})=>{const[o,a]=d.useState(""),[i,l]=d.useState(""),[c,u]=d.useState(null),[f,h]=d.useState(null),p=async x=>{x.preventDefault();const g=o.trim();if(g.length===0){h("Project name is required");return}else if(g.length>255){h("Project name must be less than 255 characters");return}else h(null);try{await n({name:g,description:i.trim()}),a(""),l(""),u(null)}catch(v){u(Ut(v,"Failed to create project"))}},m=()=>{r||(a(""),l(""),h(null),u(null),t())};return s.jsx(Pn,{open:e,onOpenChange:x=>!x&&m(),children:s.jsx(Mn,{className:"sm:max-w-[500px]",children:s.jsxs("form",{onSubmit:p,children:[s.jsxs(Vn,{children:[s.jsx(Dn,{children:"Create New Project"}),s.jsx(Wn,{children:"Create a new project to organize your chats and files. You can add more details after creation."})]}),s.jsxs("div",{className:"flex flex-col gap-4 pt-4",children:[c&&s.jsx(Vt,{variant:"error",message:c}),s.jsxs("div",{children:[s.jsxs("label",{htmlFor:"project-name",className:"font-medium",children:["Project Name ",s.jsx("span",{className:"text-[var(--color-brand-wMain)]",children:"*"})]}),s.jsx(xr,{id:"project-name",value:o,onChange:x=>{a(x.target.value),h(null)},disabled:r,maxLength:256,className:f?"border-destructive":""}),f&&s.jsx("div",{className:"text-destructive text-xs",children:f})]}),s.jsxs("div",{children:[s.jsx("label",{htmlFor:"project-description",className:"font-medium",children:"Description"}),s.jsx($r,{id:"project-description",value:i,onChange:x=>l(x.target.value),disabled:r,rows:3,maxLength:1e3}),s.jsxs("div",{className:"text-secondary-foreground text-right text-xs",children:[i.length,"/1000"]})]})]}),s.jsxs(er,{children:[s.jsx(me,{type:"button",variant:"ghost",onClick:m,disabled:r,children:"Cancel"}),s.jsx(me,{type:"submit",disabled:r,children:"Create Project"})]})]})})})},xF=({onClick:e})=>s.jsx(kc,{className:"border border-dashed border-[var(--color-primary-wMain)]",onClick:e,children:s.jsx(rc,{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(es,{className:"text-primary h-8 w-8"})})}),s.jsx("h3",{className:"text-foreground text-lg font-semibold",children:"Create New Project"})]})})}),vF=({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((m,x)=>{c(g=>({...g,[m]:x}))},[]),h=d.useCallback(()=>{if(!t)return;const m=new FormData,x={};for(const g of Array.from(t))m.append("files",g),l[g.name]&&(x[g.name]=l[g.name]);Object.keys(x).length>0&&m.append("fileMetadata",JSON.stringify(x)),r(m)},[t,l,r]),p=t?Array.from(t):[];return s.jsx(Pn,{open:e,onOpenChange:m=>!m&&u(),children:s.jsxs(Mn,{className:"sm:max-w-[600px]",children:[s.jsxs(Vn,{children:[s.jsx(Dn,{children:"Upload Files to Project"}),s.jsx(Wn,{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(Vt,{variant:"error",message:a,dismissible:!0,onDismiss:i}),p.length>0?s.jsx("div",{className:"max-h-[50vh] space-y-2 overflow-y-auto pr-2",children:p.map((m,x)=>s.jsx(xf,{noPadding:!0,className:"bg-muted/50 overflow-hidden py-3 shadow-none",children:s.jsxs(rc,{noPadding:!0,className:"overflow-hidden px-3",children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[s.jsx(gr,{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:m.name,children:m.name}),s.jsxs("p",{className:"text-muted-foreground text-xs",children:[(m.size/1024).toFixed(1)," KB"]})]})]}),s.jsx($r,{className:"bg-background text-foreground mt-2",rows:2,disabled:o,value:l[m.name]||"",onChange:g=>f(m.name,g.target.value)})]})},x))}):s.jsx("p",{className:"text-muted-foreground",children:"No files selected."})]}),s.jsxs(er,{children:[s.jsx(me,{variant:"ghost",onClick:u,disabled:o,children:"Cancel"}),s.jsx(me,{onClick:h,disabled:o||p.length===0,children:o?"Uploading...":`Upload ${p.length} File(s)`})]})]})})},wF=({project:e,onClick:t,onDelete:n,onExport:r})=>{const[o,a]=d.useState(!1),i=[...r?[{id:"export",label:"Export Project",icon:s.jsx(xo,{size:14}),onClick:()=>{a(!1),r(e)}}]:[],{id:"delete",label:"Delete",icon:s.jsx(ts,{size:14}),onClick:()=>{a(!1),n&&n(e)}}];return s.jsxs(kc,{onClick:t,children:[s.jsx(Ej,{children:s.jsxs("div",{className:"flex items-start justify-between gap-2",children:[s.jsxs(zs,{className:"flex min-w-0 flex-1 items-center gap-2",title:e.name,children:[s.jsx(Ng,{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(pc,{open:o,onOpenChange:a,children:[s.jsx(mc,{asChild:!0,children:s.jsx(me,{variant:"ghost",size:"icon",className:"h-8 w-8",tooltip:"More options",onClick:l=>l.stopPropagation(),children:s.jsx(Io,{className:"h-4 w-4"})})}),s.jsx(gc,{align:"start",side:"bottom",className:"w-48 p-1",sideOffset:0,onClick:l=>l.stopPropagation(),children:s.jsx(di,{actions:i})})]})})]})}),s.jsxs(rc,{className:"flex flex-1 flex-col justify-between",children:[s.jsx("div",{children:e.description?s.jsx(Nj,{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: ",Zd(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(Or,{variant:"secondary",className:"flex h-6 items-center gap-1",title:`${e.artifactCount} ${e.artifactCount===1?"file":"files"}`,children:[s.jsx(gr,{className:"h-3.5 w-3.5"}),s.jsx("span",{children:e.artifactCount})]})})]})]})]})},y1=({isOpen:e,onClose:t,onConfirm:n,project:r,isDeleting:o=!1})=>r?s.jsx(Bo,{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 Yi(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 ju={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 ug;function bF(){return ug||(ug=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 Yi=="function"&&Yi;if(!f&&h)return h(u,!0);if(l)return l(u,!0);var p=new Error("Cannot find module '"+u+"'");throw p.code="MODULE_NOT_FOUND",p}var m=o[u]={exports:{}};r[u][0].call(m.exports,function(x){var g=r[u][1][x];return i(g||x)},m,m.exports,n,r,o,a)}return o[u].exports}for(var l=typeof Yi=="function"&&Yi,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,p,m,x,g,v=[],w=0,b=c.length,C=b,_=a.getTypeOf(c)!=="string";w<c.length;)C=b-w,h=_?(u=c[w++],f=w<b?c[w++]:0,w<b?c[w++]:0):(u=c.charCodeAt(w++),f=w<b?c.charCodeAt(w++):0,w<b?c.charCodeAt(w++):0),p=u>>2,m=(3&u)<<4|f>>4,x=1<C?(15&f)<<2|h>>6:64,g=2<C?63&h:64,v.push(l.charAt(p)+l.charAt(m)+l.charAt(x)+l.charAt(g));return v.join("")},o.decode=function(c){var u,f,h,p,m,x,g=0,v=0,w="data:";if(c.substr(0,w.length)===w)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|(p=l.indexOf(c.charAt(g++)))>>4,f=(15&p)<<4|(m=l.indexOf(c.charAt(g++)))>>2,h=(3&m)<<6|(x=l.indexOf(c.charAt(g++))),b[v++]=u,m!==64&&(b[v++]=f),x!==64&&(b[v++]=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,p,m,x){this.compressedSize=f,this.uncompressedSize=h,this.crc32=p,this.compression=m,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,p){return f.pipe(new l).pipe(new c("uncompressedSize")).pipe(h.compressWorker(p)).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,p){var m=i,x=p+h;u^=-1;for(var g=p;g<x;g++)u=u>>>8^m[255&(u^f[g])];return-1^u}(0|c,l,l.length,0):function(u,f,h,p){var m=i,x=p+h;u^=-1;for(var g=p;g<x;g++)u=u>>>8^m[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,p){c.call(this,"FlateWorker/"+h),this._pako=null,this._pakoAction=h,this._pakoOptions=p,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(p){h.push({data:p,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(m,x){var g,v="";for(g=0;g<x;g++)v+=String.fromCharCode(255&m),m>>>=8;return v}function i(m,x,g,v,w,b){var C,_,E=m.file,S=m.compression,j=b!==u.utf8encode,A=l.transformTo("string",b(E.name)),I=l.transformTo("string",u.utf8encode(E.name)),P=E.comment,F=l.transformTo("string",b(P)),N=l.transformTo("string",u.utf8encode(P)),R=I.length!==E.name.length,y=N.length!==P.length,T="",D="",L="",O=E.dir,M=E.date,J={crc32:0,compressedSize:0,uncompressedSize:0};x&&!g||(J.crc32=m.crc32,J.compressedSize=m.compressedSize,J.uncompressedSize=m.uncompressedSize);var z=0;x&&(z|=8),j||!R&&!y||(z|=2048);var H=0,U=0;O&&(H|=16),w==="UNIX"?(U=798,H|=function(W,te){var $=W;return W||($=te?16893:33204),(65535&$)<<16}(E.unixPermissions,O)):(U=20,H|=function(W){return 63&(W||0)}(E.dosPermissions)),C=M.getUTCHours(),C<<=6,C|=M.getUTCMinutes(),C<<=5,C|=M.getUTCSeconds()/2,_=M.getUTCFullYear()-1980,_<<=4,_|=M.getUTCMonth()+1,_<<=5,_|=M.getUTCDate(),R&&(D=a(1,1)+a(f(A),4)+I,T+="up"+a(D.length,2)+D),y&&(L=a(1,1)+a(f(F),4)+N,T+="uc"+a(L.length,2)+L);var X="";return X+=`
433
+ \0`,X+=a(z,2),X+=S.magic,X+=a(C,2),X+=a(_,2),X+=a(J.crc32,4),X+=a(J.compressedSize,4),X+=a(J.uncompressedSize,4),X+=a(A.length,2),X+=a(T.length,2),{fileRecord:h.LOCAL_FILE_HEADER+X+A+T,dirRecord:h.CENTRAL_FILE_HEADER+a(U,2)+X+a(F.length,2)+"\0\0\0\0"+a(H,4)+a(v,4)+A+T+F}}var l=n("../utils"),c=n("../stream/GenericWorker"),u=n("../utf8"),f=n("../crc32"),h=n("../signature");function p(m,x,g,v){c.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=x,this.zipPlatform=g,this.encodeFileName=v,this.streamFiles=m,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}l.inherits(p,c),p.prototype.push=function(m){var x=m.meta.percent||0,g=this.entriesCount,v=this._sources.length;this.accumulate?this.contentBuffer.push(m):(this.bytesWritten+=m.data.length,c.prototype.push.call(this,{data:m.data,meta:{currentFile:this.currentFile,percent:g?(x+100*(g-v-1))/g:100}}))},p.prototype.openedSource=function(m){this.currentSourceOffset=this.bytesWritten,this.currentFile=m.file.name;var x=this.streamFiles&&!m.file.dir;if(x){var g=i(m,x,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:g.fileRecord,meta:{percent:0}})}else this.accumulate=!0},p.prototype.closedSource=function(m){this.accumulate=!1;var x=this.streamFiles&&!m.file.dir,g=i(m,x,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(g.dirRecord),x)this.push({data:function(v){return h.DATA_DESCRIPTOR+a(v.crc32,4)+a(v.compressedSize,4)+a(v.uncompressedSize,4)}(m),meta:{percent:100}});else for(this.push({data:g.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},p.prototype.flush=function(){for(var m=this.bytesWritten,x=0;x<this.dirRecords.length;x++)this.push({data:this.dirRecords[x],meta:{percent:100}});var g=this.bytesWritten-m,v=function(w,b,C,_,E){var S=l.transformTo("string",E(_));return h.CENTRAL_DIRECTORY_END+"\0\0\0\0"+a(w,2)+a(w,2)+a(b,4)+a(C,4)+a(S.length,2)+S}(this.dirRecords.length,g,m,this.zipComment,this.encodeFileName);this.push({data:v,meta:{percent:100}})},p.prototype.prepareNextSource=function(){this.previous=this._sources.shift(),this.openedSource(this.previous.streamInfo),this.isPaused?this.previous.pause():this.previous.resume()},p.prototype.registerPrevious=function(m){this._sources.push(m);var x=this;return m.on("data",function(g){x.processChunk(g)}),m.on("end",function(){x.closedSource(x.previous.streamInfo),x._sources.length?x.prepareNextSource():x.end()}),m.on("error",function(g){x.error(g)}),this},p.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))},p.prototype.error=function(m){var x=this._sources;if(!c.prototype.error.call(this,m))return!1;for(var g=0;g<x.length;g++)try{x[g].error(m)}catch{}return!0},p.prototype.lock=function(){c.prototype.lock.call(this);for(var m=this._sources,x=0;x<m.length;x++)m[x].lock()},r.exports=p},{"../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(p,m){h++;var x=function(b,C){var _=b||C,E=a[_];if(!E)throw new Error(_+" is not a valid compression method !");return E}(m.options.compression,c.compression),g=m.options.compressionOptions||c.compressionOptions||{},v=m.dir,w=m.date;m._compressWorker(x,g).withStreamInfo("file",{name:p,dir:v,date:w,comment:m.comment||"",unixPermissions:m.unixPermissions,dosPermissions:m.dosPermissions}).pipe(f)}),f.entriesCount=h}catch(p){f.error(p)}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(p){return new i.Promise(function(m,x){var g=p.decompressed.getContentWorker().pipe(new u);g.on("error",function(v){x(v)}).on("end",function(){g.streamInfo.crc32!==p.decompressed.crc32?x(new Error("Corrupted zip : CRC32 mismatch")):m()}).resume()})}r.exports=function(p,m){var x=this;return m=a.extend(m||{},{base64:!1,checkCRC32:!1,optimizedBinaryString:!1,createFolders:!1,decodeFileName:l.utf8decode}),f.isNode&&f.isStream(p)?i.Promise.reject(new Error("JSZip can't accept a stream when loading a zip file.")):a.prepareContent("the loaded zip file",p,!0,m.optimizedBinaryString,m.base64).then(function(g){var v=new c(m);return v.load(g),v}).then(function(g){var v=[i.Promise.resolve(g)],w=g.files;if(m.checkCRC32)for(var b=0;b<w.length;b++)v.push(h(w[b]));return i.Promise.all(v)}).then(function(g){for(var v=g.shift(),w=v.files,b=0;b<w.length;b++){var C=w[b],_=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:m.createFolders}),C.dir||(x.file(E).unsafeOriginalName=_)}return v.zipComment.length&&(x.comment=v.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,p){f.push(h)||f._helper.pause(),u&&u(p)}).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,S,j){var A,I=l.getTypeOf(S),P=l.extend(j||{},f);P.date=P.date||new Date,P.compression!==null&&(P.compression=P.compression.toUpperCase()),typeof P.unixPermissions=="string"&&(P.unixPermissions=parseInt(P.unixPermissions,8)),P.unixPermissions&&16384&P.unixPermissions&&(P.dir=!0),P.dosPermissions&&16&P.dosPermissions&&(P.dir=!0),P.dir&&(E=w(E)),P.createFolders&&(A=v(E))&&b.call(this,A,!0);var F=I==="string"&&P.binary===!1&&P.base64===!1;j&&j.binary!==void 0||(P.binary=!F),(S instanceof h&&S.uncompressedSize===0||P.dir||!S||S.length===0)&&(P.base64=!1,P.binary=!0,S="",P.compression="STORE",I="string");var N=null;N=S instanceof h||S instanceof c?S:x.isNode&&x.isStream(S)?new g(E,S):l.prepareContent(E,S,P.binary,P.optimizedBinaryString,P.base64);var R=new p(E,N,P);this.files[E]=R}var i=n("./utf8"),l=n("./utils"),c=n("./stream/GenericWorker"),u=n("./stream/StreamHelper"),f=n("./defaults"),h=n("./compressedObject"),p=n("./zipObject"),m=n("./generate"),x=n("./nodejsUtils"),g=n("./nodejs/NodejsStreamInputAdapter"),v=function(E){E.slice(-1)==="/"&&(E=E.substring(0,E.length-1));var S=E.lastIndexOf("/");return 0<S?E.substring(0,S):""},w=function(E){return E.slice(-1)!=="/"&&(E+="/"),E},b=function(E,S){return S=S!==void 0?S:f.createFolders,E=w(E),this.files[E]||a.call(this,E,null,{dir:!0,createFolders:S}),this.files[E]};function C(E){return Object.prototype.toString.call(E)==="[object RegExp]"}var _={load:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},forEach:function(E){var S,j,A;for(S in this.files)A=this.files[S],(j=S.slice(this.root.length,S.length))&&S.slice(0,this.root.length)===this.root&&E(j,A)},filter:function(E){var S=[];return this.forEach(function(j,A){E(j,A)&&S.push(A)}),S},file:function(E,S,j){if(arguments.length!==1)return E=this.root+E,a.call(this,E,S,j),this;if(C(E)){var A=E;return this.filter(function(P,F){return!F.dir&&A.test(P)})}var I=this.files[this.root+E];return I&&!I.dir?I:null},folder:function(E){if(!E)return this;if(C(E))return this.filter(function(I,P){return P.dir&&E.test(I)});var S=this.root+E,j=b.call(this,S),A=this.clone();return A.root=j.name,A},remove:function(E){E=this.root+E;var S=this.files[E];if(S||(E.slice(-1)!=="/"&&(E+="/"),S=this.files[E]),S&&!S.dir)delete this.files[E];else for(var j=this.filter(function(I,P){return P.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 S,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||"";S=m.generateWorker(this,j,A)}catch(I){(S=new c("error")).error(I)}return new u(S,j.type||"string",j.mimeType)},generateAsync:function(E,S){return this.generateInternalStream(E).accumulate(S)},generateNodeStream:function(E,S){return(E=E||{}).type||(E.type="nodebuffer"),this.generateInternalStream(E).toNodejsStream(S)}};r.exports=_},{"./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),p=this.length-4;0<=p;--p)if(this.data[p]===c&&this.data[p+1]===u&&this.data[p+2]===f&&this.data[p+3]===h)return p-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),p=this.readData(4);return c===p[0]&&u===p[1]&&f===p[2]&&h===p[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 p=a.getTypeOf(h);return a.checkSupport(p),p!=="string"||i.uint8array?p==="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 p(x,g){return new f.Promise(function(v,w){var b=[],C=x._internalType,_=x._outputType,E=x._mimeType;x.on("data",function(S,j){b.push(S),g&&g(j)}).on("error",function(S){b=[],w(S)}).on("end",function(){try{var S=function(j,A,I){switch(j){case"blob":return a.newBlob(a.transformTo("arraybuffer",A),I);case"base64":return c.encode(A);default:return a.transformTo(j,A)}}(_,function(j,A){var I,P=0,F=null,N=0;for(I=0;I<A.length;I++)N+=A[I].length;switch(j){case"string":return A.join("");case"array":return Array.prototype.concat.apply([],A);case"uint8array":for(F=new Uint8Array(N),I=0;I<A.length;I++)F.set(A[I],P),P+=A[I].length;return F;case"nodebuffer":return Buffer.concat(A);default:throw new Error("concat : unsupported type '"+j+"'")}}(C,b),E);v(S)}catch(j){w(j)}b=[]}).resume()})}function m(x,g,v){var w=g;switch(g){case"blob":case"arraybuffer":w="uint8array";break;case"base64":w="string"}try{this._internalType=w,this._outputType=g,this._mimeType=v,a.checkSupport(w),this._worker=x.pipe(new i(w)),x.lock()}catch(b){this._worker=new l("error"),this._worker.error(b)}}m.prototype={accumulate:function(x){return p(this,x)},on:function(x,g){var v=this;return x==="data"?this._worker.on(x,function(w){g.call(v,w.data,w.meta)}):this._worker.on(x,function(){a.delay(g,arguments,v)}),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=m},{"../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 p(){c.call(this,"utf-8 encode")}o.utf8encode=function(m){return i.nodebuffer?l.newBufferFrom(m,"utf-8"):function(x){var g,v,w,b,C,_=x.length,E=0;for(b=0;b<_;b++)(64512&(v=x.charCodeAt(b)))==55296&&b+1<_&&(64512&(w=x.charCodeAt(b+1)))==56320&&(v=65536+(v-55296<<10)+(w-56320),b++),E+=v<128?1:v<2048?2:v<65536?3:4;for(g=i.uint8array?new Uint8Array(E):new Array(E),b=C=0;C<E;b++)(64512&(v=x.charCodeAt(b)))==55296&&b+1<_&&(64512&(w=x.charCodeAt(b+1)))==56320&&(v=65536+(v-55296<<10)+(w-56320),b++),v<128?g[C++]=v:(v<2048?g[C++]=192|v>>>6:(v<65536?g[C++]=224|v>>>12:(g[C++]=240|v>>>18,g[C++]=128|v>>>12&63),g[C++]=128|v>>>6&63),g[C++]=128|63&v);return g}(m)},o.utf8decode=function(m){return i.nodebuffer?a.transformTo("nodebuffer",m).toString("utf-8"):function(x){var g,v,w,b,C=x.length,_=new Array(2*C);for(g=v=0;g<C;)if((w=x[g++])<128)_[v++]=w;else if(4<(b=u[w]))_[v++]=65533,g+=b-1;else{for(w&=b===2?31:b===3?15:7;1<b&&g<C;)w=w<<6|63&x[g++],b--;1<b?_[v++]=65533:w<65536?_[v++]=w:(w-=65536,_[v++]=55296|w>>10&1023,_[v++]=56320|1023&w)}return _.length!==v&&(_.subarray?_=_.subarray(0,v):_.length=v),a.applyFromCharCode(_)}(m=a.transformTo(i.uint8array?"uint8array":"array",m))},a.inherits(h,c),h.prototype.processChunk=function(m){var x=a.transformTo(i.uint8array?"uint8array":"array",m.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 v=function(b,C){var _;for((C=C||b.length)>b.length&&(C=b.length),_=C-1;0<=_&&(192&b[_])==128;)_--;return _<0||_===0?C:_+u[b[_]]>C?_:C}(x),w=x;v!==x.length&&(i.uint8array?(w=x.subarray(0,v),this.leftOver=x.subarray(v,x.length)):(w=x.slice(0,v),this.leftOver=x.slice(v,x.length))),this.push({data:o.utf8decode(w),meta:m.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(p,c),p.prototype.processChunk=function(m){this.push({data:o.utf8encode(m.data),meta:m.meta})},o.Utf8EncodeWorker=p},{"./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,v){for(var w=0;w<g.length;++w)v[w]=255&g.charCodeAt(w);return v}n("setimmediate"),o.newBlob=function(g,v){o.checkSupport("blob");try{return new Blob([g],{type:v})}catch{try{var w=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);return w.append(g),w.getBlob(v)}catch{throw new Error("Bug : can't construct the Blob.")}}};var h={stringifyByChunk:function(g,v,w){var b=[],C=0,_=g.length;if(_<=w)return String.fromCharCode.apply(null,g);for(;C<_;)v==="array"||v==="nodebuffer"?b.push(String.fromCharCode.apply(null,g.slice(C,Math.min(C+w,_)))):b.push(String.fromCharCode.apply(null,g.subarray(C,Math.min(C+w,_)))),C+=w;return b.join("")},stringifyByChar:function(g){for(var v="",w=0;w<g.length;w++)v+=String.fromCharCode(g[w]);return v},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 p(g){var v=65536,w=o.getTypeOf(g),b=!0;if(w==="uint8array"?b=h.applyCanBeUsed.uint8array:w==="nodebuffer"&&(b=h.applyCanBeUsed.nodebuffer),b)for(;1<v;)try{return h.stringifyByChunk(g,w,v)}catch{v=Math.floor(v/2)}return h.stringifyByChar(g)}function m(g,v){for(var w=0;w<g.length;w++)v[w]=g[w];return v}o.applyFromCharCode=p;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:p,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 p(new Uint8Array(g))},array:function(g){return m(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:p,array:function(g){return m(g,new Array(g.length))},arraybuffer:function(g){return g.buffer},uint8array:u,nodebuffer:function(g){return l.newBufferFrom(g)}},x.nodebuffer={string:p,array:function(g){return m(g,new Array(g.length))},arraybuffer:function(g){return x.nodebuffer.uint8array(g).buffer},uint8array:function(g){return m(g,new Uint8Array(g.length))},nodebuffer:u},o.transformTo=function(g,v){if(v=v||"",!g)return v;o.checkSupport(g);var w=o.getTypeOf(v);return x[w][g](v)},o.resolve=function(g){for(var v=g.split("/"),w=[],b=0;b<v.length;b++){var C=v[b];C==="."||C===""&&b!==0&&b!==v.length-1||(C===".."?w.pop():w.push(C))}return w.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 v,w,b="";for(w=0;w<(g||"").length;w++)b+="\\x"+((v=g.charCodeAt(w))<16?"0":"")+v.toString(16).toUpperCase();return b},o.delay=function(g,v,w){setImmediate(function(){g.apply(w||null,v||[])})},o.inherits=function(g,v){function w(){}w.prototype=v.prototype,g.prototype=new w},o.extend=function(){var g,v,w={};for(g=0;g<arguments.length;g++)for(v in arguments[g])Object.prototype.hasOwnProperty.call(arguments[g],v)&&w[v]===void 0&&(w[v]=arguments[g][v]);return w},o.prepareContent=function(g,v,w,b,C){return c.Promise.resolve(v).then(function(_){return a.blob&&(_ instanceof Blob||["[object File]","[object Blob]"].indexOf(Object.prototype.toString.call(_))!==-1)&&typeof FileReader<"u"?new c.Promise(function(E,S){var j=new FileReader;j.onload=function(A){E(A.target.result)},j.onerror=function(A){S(A.target.error)},j.readAsArrayBuffer(_)}):_}).then(function(_){var E=o.getTypeOf(_);return E?(E==="arraybuffer"?_=o.transformTo("uint8array",_):E==="string"&&(C?_=i.decode(_):w&&b!==!0&&(_=function(S){return f(S,a.uint8array?new Uint8Array(S.length):new Array(S.length))}(_))),_):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 p=this.reader.readString(4);throw new Error("Corrupted zip or bug: unexpected signature ("+i.pretty(p)+", expected "+i.pretty(h)+")")}},isSignature:function(h,p){var m=this.reader.index;this.reader.setIndex(h);var x=this.reader.readString(4)===p;return this.reader.setIndex(m),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),p=u.uint8array?"uint8array":"array",m=i.transformTo(p,h);this.zipComment=this.loadOptions.decodeFileName(m)},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,p,m,x=this.zip64EndOfCentralSize-44;0<x;)h=this.reader.readInt(2),p=this.reader.readInt(4),m=this.reader.readData(p),this.zip64ExtensibleData[h]={id:h,length:p,value:m}},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,p;for(h=0;h<this.files.length;h++)p=this.files[h],this.reader.setIndex(p.localHeaderOffset),this.checkSignature(l.LOCAL_FILE_HEADER),p.readLocalPart(this.reader),p.handleUTF8(),p.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 p=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 m=this.centralDirOffset+this.centralDirSize;this.zip64&&(m+=20,m+=12+this.zip64EndOfCentralSize);var x=p-m;if(0<x)this.isSignature(p,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 p(m,x){this.options=m,this.loadOptions=x}p.prototype={isEncrypted:function(){return(1&this.bitFlag)==1},useUTF8:function(){return(2048&this.bitFlag)==2048},readLocalPart:function(m){var x,g;if(m.skip(22),this.fileNameLength=m.readInt(2),g=m.readInt(2),this.fileName=m.readData(this.fileNameLength),m.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(v){for(var w in f)if(Object.prototype.hasOwnProperty.call(f,w)&&f[w].magic===v)return f[w];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,m.readData(this.compressedSize))},readCentralPart:function(m){this.versionMadeBy=m.readInt(2),m.skip(2),this.bitFlag=m.readInt(2),this.compressionMethod=m.readString(2),this.date=m.readDate(),this.crc32=m.readInt(4),this.compressedSize=m.readInt(4),this.uncompressedSize=m.readInt(4);var x=m.readInt(2);if(this.extraFieldsLength=m.readInt(2),this.fileCommentLength=m.readInt(2),this.diskNumberStart=m.readInt(2),this.internalFileAttributes=m.readInt(2),this.externalFileAttributes=m.readInt(4),this.localHeaderOffset=m.readInt(4),this.isEncrypted())throw new Error("Encrypted zip are not supported");m.skip(x),this.readExtraFields(m),this.parseZIP64ExtraField(m),this.fileComment=m.readData(this.fileCommentLength)},processAttributes:function(){this.unixPermissions=null,this.dosPermissions=null;var m=this.versionMadeBy>>8;this.dir=!!(16&this.externalFileAttributes),m==0&&(this.dosPermissions=63&this.externalFileAttributes),m==3&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||this.fileNameStr.slice(-1)!=="/"||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var m=a(this.extraFields[1].value);this.uncompressedSize===i.MAX_VALUE_32BITS&&(this.uncompressedSize=m.readInt(8)),this.compressedSize===i.MAX_VALUE_32BITS&&(this.compressedSize=m.readInt(8)),this.localHeaderOffset===i.MAX_VALUE_32BITS&&(this.localHeaderOffset=m.readInt(8)),this.diskNumberStart===i.MAX_VALUE_32BITS&&(this.diskNumberStart=m.readInt(4))}},readExtraFields:function(m){var x,g,v,w=m.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});m.index+4<w;)x=m.readInt(2),g=m.readInt(2),v=m.readData(g),this.extraFields[x]={id:x,length:g,value:v};m.setIndex(w)},handleUTF8:function(){var m=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(m,this.fileName);this.fileNameStr=this.loadOptions.decodeFileName(g)}var v=this.findExtraFieldUnicodeComment();if(v!==null)this.fileCommentStr=v;else{var w=i.transformTo(m,this.fileComment);this.fileCommentStr=this.loadOptions.decodeFileName(w)}}},findExtraFieldUnicodePath:function(){var m=this.extraFields[28789];if(m){var x=a(m.value);return x.readInt(1)!==1||c(this.fileName)!==x.readInt(4)?null:u.utf8decode(x.readData(m.length-5))}return null},findExtraFieldUnicodeComment:function(){var m=this.extraFields[25461];if(m){var x=a(m.value);return x.readInt(1)!==1||c(this.fileComment)!==x.readInt(4)?null:u.utf8decode(x.readData(m.length-5))}return null}},r.exports=p},{"./compressedObject":2,"./compressions":3,"./crc32":4,"./reader/readerFor":22,"./support":30,"./utf8":31,"./utils":32}],35:[function(n,r,o){function a(x,g,v){this.name=x,this.dir=v.dir,this.date=v.date,this.comment=v.comment,this.unixPermissions=v.unixPermissions,this.dosPermissions=v.dosPermissions,this._data=g,this._dataBinary=v.binary,this.options={compression:v.compression,compressionOptions:v.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,v="string";try{if(!x)throw new Error("No output type specified.");var w=(v=x.toLowerCase())==="string"||v==="text";v!=="binarystring"&&v!=="text"||(v="string"),g=this._decompressWorker();var b=!this._dataBinary;b&&!w&&(g=g.pipe(new c.Utf8EncodeWorker)),!b&&w&&(g=g.pipe(new c.Utf8DecodeWorker))}catch(C){(g=new f("error")).error(C)}return new i(g,v,"")},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 v=this._decompressWorker();return this._dataBinary||(v=v.pipe(new c.Utf8EncodeWorker)),u.createWorkerFrom(v,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"],p=function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},m=0;m<h.length;m++)a.prototype[h[m]]=p;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 p=new a.MessageChannel;p.port1.onmessage=x,i=function(){p.port2.postMessage(0)}}var m=[];function x(){var g,v;l=!0;for(var w=m.length;w;){for(v=m,m=[],g=-1;++g<w;)v[g]();w=m.length}l=!1}r.exports=function(g){m.push(g)!==1||l||i()}}).call(this,typeof Ci<"u"?Ci: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(w){if(typeof w!="function")throw new TypeError("resolver must be a function");this.state=f,this.queue=[],this.outcome=void 0,w!==i&&g(this,w)}function p(w,b,C){this.promise=w,typeof b=="function"&&(this.onFulfilled=b,this.callFulfilled=this.otherCallFulfilled),typeof C=="function"&&(this.onRejected=C,this.callRejected=this.otherCallRejected)}function m(w,b,C){a(function(){var _;try{_=b(C)}catch(E){return l.reject(w,E)}_===w?l.reject(w,new TypeError("Cannot resolve promise with itself")):l.resolve(w,_)})}function x(w){var b=w&&w.then;if(w&&(typeof w=="object"||typeof w=="function")&&typeof b=="function")return function(){b.apply(w,arguments)}}function g(w,b){var C=!1;function _(j){C||(C=!0,l.reject(w,j))}function E(j){C||(C=!0,l.resolve(w,j))}var S=v(function(){b(E,_)});S.status==="error"&&_(S.value)}function v(w,b){var C={};try{C.value=w(b),C.status="success"}catch(_){C.status="error",C.value=_}return C}(r.exports=h).prototype.finally=function(w){if(typeof w!="function")return this;var b=this.constructor;return this.then(function(C){return b.resolve(w()).then(function(){return C})},function(C){return b.resolve(w()).then(function(){throw C})})},h.prototype.catch=function(w){return this.then(null,w)},h.prototype.then=function(w,b){if(typeof w!="function"&&this.state===u||typeof b!="function"&&this.state===c)return this;var C=new this.constructor(i);return this.state!==f?m(C,this.state===u?w:b,this.outcome):this.queue.push(new p(C,w,b)),C},p.prototype.callFulfilled=function(w){l.resolve(this.promise,w)},p.prototype.otherCallFulfilled=function(w){m(this.promise,this.onFulfilled,w)},p.prototype.callRejected=function(w){l.reject(this.promise,w)},p.prototype.otherCallRejected=function(w){m(this.promise,this.onRejected,w)},l.resolve=function(w,b){var C=v(x,b);if(C.status==="error")return l.reject(w,C.value);var _=C.value;if(_)g(w,_);else{w.state=u,w.outcome=b;for(var E=-1,S=w.queue.length;++E<S;)w.queue[E].callFulfilled(b)}return w},l.reject=function(w,b){w.state=c,w.outcome=b;for(var C=-1,_=w.queue.length;++C<_;)w.queue[C].callRejected(b);return w},h.resolve=function(w){return w instanceof this?w:l.resolve(new this(i),w)},h.reject=function(w){var b=new this(i);return l.reject(b,w)},h.all=function(w){var b=this;if(Object.prototype.toString.call(w)!=="[object Array]")return this.reject(new TypeError("must be an array"));var C=w.length,_=!1;if(!C)return this.resolve([]);for(var E=new Array(C),S=0,j=-1,A=new this(i);++j<C;)I(w[j],j);return A;function I(P,F){b.resolve(P).then(function(N){E[F]=N,++S!==C||_||(_=!0,l.resolve(A,E))},function(N){_||(_=!0,l.reject(A,N))})}},h.race=function(w){var b=this;if(Object.prototype.toString.call(w)!=="[object Array]")return this.reject(new TypeError("must be an array"));var C=w.length,_=!1;if(!C)return this.resolve([]);for(var E=-1,S=new this(i);++E<C;)j=w[E],b.resolve(j).then(function(A){_||(_=!0,l.resolve(S,A))},function(A){_||(_=!0,l.reject(S,A))});var j;return S}},{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,p=-1,m=0,x=8;function g(w){if(!(this instanceof g))return new g(w);this.options=i.assign({level:p,method:x,chunkSize:16384,windowBits:15,memLevel:8,strategy:m,to:""},w||{});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 _;if(_=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,_))!==h)throw new Error(c[C]);this._dict_set=!0}}function v(w,b){var C=new g(b);if(C.push(w,!0),C.err)throw C.msg||c[C.err];return C.result}g.prototype.push=function(w,b){var C,_,E=this.strm,S=this.options.chunkSize;if(this.ended)return!1;_=b===~~b?b:b===!0?4:0,typeof w=="string"?E.input=l.string2buf(w):f.call(w)==="[object ArrayBuffer]"?E.input=new Uint8Array(w):E.input=w,E.next_in=0,E.avail_in=E.input.length;do{if(E.avail_out===0&&(E.output=new i.Buf8(S),E.next_out=0,E.avail_out=S),(C=a.deflate(E,_))!==1&&C!==h)return this.onEnd(C),!(this.ended=!0);E.avail_out!==0&&(E.avail_in!==0||_!==4&&_!==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 _===4?(C=a.deflateEnd(this.strm),this.onEnd(C),this.ended=!0,C===h):_!==2||(this.onEnd(h),!(E.avail_out=0))},g.prototype.onData=function(w){this.chunks.push(w)},g.prototype.onEnd=function(w){w===h&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=i.flattenChunks(this.chunks)),this.chunks=[],this.err=w,this.msg=this.strm.msg},o.Deflate=g,o.deflate=v,o.deflateRaw=function(w,b){return(b=b||{}).raw=!0,v(w,b)},o.gzip=function(w,b){return(b=b||{}).gzip=!0,v(w,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"),p=Object.prototype.toString;function m(g){if(!(this instanceof m))return new m(g);this.options=i.assign({chunkSize:16384,windowBits:0,to:""},g||{});var v=this.options;v.raw&&0<=v.windowBits&&v.windowBits<16&&(v.windowBits=-v.windowBits,v.windowBits===0&&(v.windowBits=-15)),!(0<=v.windowBits&&v.windowBits<16)||g&&g.windowBits||(v.windowBits+=32),15<v.windowBits&&v.windowBits<48&&(15&v.windowBits)==0&&(v.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new f,this.strm.avail_out=0;var w=a.inflateInit2(this.strm,v.windowBits);if(w!==c.Z_OK)throw new Error(u[w]);this.header=new h,a.inflateGetHeader(this.strm,this.header)}function x(g,v){var w=new m(v);if(w.push(g,!0),w.err)throw w.msg||u[w.err];return w.result}m.prototype.push=function(g,v){var w,b,C,_,E,S,j=this.strm,A=this.options.chunkSize,I=this.options.dictionary,P=!1;if(this.ended)return!1;b=v===~~v?v:v===!0?c.Z_FINISH:c.Z_NO_FLUSH,typeof g=="string"?j.input=l.binstring2buf(g):p.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),(w=a.inflate(j,c.Z_NO_FLUSH))===c.Z_NEED_DICT&&I&&(S=typeof I=="string"?l.string2buf(I):p.call(I)==="[object ArrayBuffer]"?new Uint8Array(I):I,w=a.inflateSetDictionary(this.strm,S)),w===c.Z_BUF_ERROR&&P===!0&&(w=c.Z_OK,P=!1),w!==c.Z_STREAM_END&&w!==c.Z_OK)return this.onEnd(w),!(this.ended=!0);j.next_out&&(j.avail_out!==0&&w!==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),_=j.next_out-C,E=l.buf2string(j.output,C),j.next_out=_,j.avail_out=A-_,_&&i.arraySet(j.output,j.output,C,_,0),this.onData(E)):this.onData(i.shrinkBuf(j.output,j.next_out)))),j.avail_in===0&&j.avail_out===0&&(P=!0)}while((0<j.avail_in||j.avail_out===0)&&w!==c.Z_STREAM_END);return w===c.Z_STREAM_END&&(b=c.Z_FINISH),b===c.Z_FINISH?(w=a.inflateEnd(this.strm),this.onEnd(w),this.ended=!0,w===c.Z_OK):b!==c.Z_SYNC_FLUSH||(this.onEnd(c.Z_OK),!(j.avail_out=0))},m.prototype.onData=function(g){this.chunks.push(g)},m.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=m,o.inflate=x,o.inflateRaw=function(g,v){return(v=v||{}).raw=!0,x(g,v)},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,p){if(u.subarray&&c.subarray)c.set(u.subarray(f,f+h),p);else for(var m=0;m<h;m++)c[p+m]=u[f+m]},flattenChunks:function(c){var u,f,h,p,m,x;for(u=h=0,f=c.length;u<f;u++)h+=c[u].length;for(x=new Uint8Array(h),u=p=0,f=c.length;u<f;u++)m=c[u],x.set(m,p),p+=m.length;return x}},l={arraySet:function(c,u,f,h,p){for(var m=0;m<h;m++)c[p+m]=u[f+m]},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,p){if(p<65537&&(h.subarray&&l||!h.subarray&&i))return String.fromCharCode.apply(null,a.shrinkBuf(h,p));for(var m="",x=0;x<p;x++)m+=String.fromCharCode(h[x]);return m}c[254]=c[254]=1,o.string2buf=function(h){var p,m,x,g,v,w=h.length,b=0;for(g=0;g<w;g++)(64512&(m=h.charCodeAt(g)))==55296&&g+1<w&&(64512&(x=h.charCodeAt(g+1)))==56320&&(m=65536+(m-55296<<10)+(x-56320),g++),b+=m<128?1:m<2048?2:m<65536?3:4;for(p=new a.Buf8(b),g=v=0;v<b;g++)(64512&(m=h.charCodeAt(g)))==55296&&g+1<w&&(64512&(x=h.charCodeAt(g+1)))==56320&&(m=65536+(m-55296<<10)+(x-56320),g++),m<128?p[v++]=m:(m<2048?p[v++]=192|m>>>6:(m<65536?p[v++]=224|m>>>12:(p[v++]=240|m>>>18,p[v++]=128|m>>>12&63),p[v++]=128|m>>>6&63),p[v++]=128|63&m);return p},o.buf2binstring=function(h){return f(h,h.length)},o.binstring2buf=function(h){for(var p=new a.Buf8(h.length),m=0,x=p.length;m<x;m++)p[m]=h.charCodeAt(m);return p},o.buf2string=function(h,p){var m,x,g,v,w=p||h.length,b=new Array(2*w);for(m=x=0;m<w;)if((g=h[m++])<128)b[x++]=g;else if(4<(v=c[g]))b[x++]=65533,m+=v-1;else{for(g&=v===2?31:v===3?15:7;1<v&&m<w;)g=g<<6|63&h[m++],v--;1<v?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,p){var m;for((p=p||h.length)>h.length&&(p=h.length),m=p-1;0<=m&&(192&h[m])==128;)m--;return m<0||m===0?p:m+c[h[m]]>p?m:p}},{"./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 p=u;p<h;p++)i=i>>>8^f[255&(i^l[p])];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,p=4,m=0,x=-2,g=-1,v=4,w=2,b=8,C=9,_=286,E=30,S=19,j=2*_+1,A=15,I=3,P=258,F=P+I+1,N=42,R=113,y=1,T=2,D=3,L=4;function O(k,oe){return k.msg=f[oe],oe}function M(k){return(k<<1)-(4<k?9:0)}function J(k){for(var oe=k.length;0<=--oe;)k[oe]=0}function z(k){var oe=k.state,ae=oe.pending;ae>k.avail_out&&(ae=k.avail_out),ae!==0&&(i.arraySet(k.output,oe.pending_buf,oe.pending_out,ae,k.next_out),k.next_out+=ae,oe.pending_out+=ae,k.total_out+=ae,k.avail_out-=ae,oe.pending-=ae,oe.pending===0&&(oe.pending_out=0))}function H(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,z(k.strm)}function U(k,oe){k.pending_buf[k.pending++]=oe}function X(k,oe){k.pending_buf[k.pending++]=oe>>>8&255,k.pending_buf[k.pending++]=255&oe}function W(k,oe){var ae,G,V=k.max_chain_length,ne=k.strstart,B=k.prev_length,K=k.nice_match,Z=k.strstart>k.w_size-F?k.strstart-(k.w_size-F):0,le=k.window,de=k.w_mask,se=k.prev,he=k.strstart+P,Ee=le[ne+B-1],Ae=le[ne+B];k.prev_length>=k.good_match&&(V>>=2),K>k.lookahead&&(K=k.lookahead);do if(le[(ae=oe)+B]===Ae&&le[ae+B-1]===Ee&&le[ae]===le[ne]&&le[++ae]===le[ne+1]){ne+=2,ae++;do;while(le[++ne]===le[++ae]&&le[++ne]===le[++ae]&&le[++ne]===le[++ae]&&le[++ne]===le[++ae]&&le[++ne]===le[++ae]&&le[++ne]===le[++ae]&&le[++ne]===le[++ae]&&le[++ne]===le[++ae]&&ne<he);if(G=P-(he-ne),ne=he-P,B<G){if(k.match_start=oe,K<=(B=G))break;Ee=le[ne+B-1],Ae=le[ne+B]}}while((oe=se[oe&de])>Z&&--V!=0);return B<=k.lookahead?B:k.lookahead}function te(k){var oe,ae,G,V,ne,B,K,Z,le,de,se=k.w_size;do{if(V=k.window_size-k.lookahead-k.strstart,k.strstart>=se+(se-F)){for(i.arraySet(k.window,k.window,se,se,0),k.match_start-=se,k.strstart-=se,k.block_start-=se,oe=ae=k.hash_size;G=k.head[--oe],k.head[oe]=se<=G?G-se:0,--ae;);for(oe=ae=se;G=k.prev[--oe],k.prev[oe]=se<=G?G-se:0,--ae;);V+=se}if(k.strm.avail_in===0)break;if(B=k.strm,K=k.window,Z=k.strstart+k.lookahead,le=V,de=void 0,de=B.avail_in,le<de&&(de=le),ae=de===0?0:(B.avail_in-=de,i.arraySet(K,B.input,B.next_in,de,Z),B.state.wrap===1?B.adler=c(B.adler,K,de,Z):B.state.wrap===2&&(B.adler=u(B.adler,K,de,Z)),B.next_in+=de,B.total_in+=de,de),k.lookahead+=ae,k.lookahead+k.insert>=I)for(ne=k.strstart-k.insert,k.ins_h=k.window[ne],k.ins_h=(k.ins_h<<k.hash_shift^k.window[ne+1])&k.hash_mask;k.insert&&(k.ins_h=(k.ins_h<<k.hash_shift^k.window[ne+I-1])&k.hash_mask,k.prev[ne&k.w_mask]=k.head[k.ins_h],k.head[k.ins_h]=ne,ne++,k.insert--,!(k.lookahead+k.insert<I)););}while(k.lookahead<F&&k.strm.avail_in!==0)}function $(k,oe){for(var ae,G;;){if(k.lookahead<F){if(te(k),k.lookahead<F&&oe===h)return y;if(k.lookahead===0)break}if(ae=0,k.lookahead>=I&&(k.ins_h=(k.ins_h<<k.hash_shift^k.window[k.strstart+I-1])&k.hash_mask,ae=k.prev[k.strstart&k.w_mask]=k.head[k.ins_h],k.head[k.ins_h]=k.strstart),ae!==0&&k.strstart-ae<=k.w_size-F&&(k.match_length=W(k,ae)),k.match_length>=I)if(G=l._tr_tally(k,k.strstart-k.match_start,k.match_length-I),k.lookahead-=k.match_length,k.match_length<=k.max_lazy_match&&k.lookahead>=I){for(k.match_length--;k.strstart++,k.ins_h=(k.ins_h<<k.hash_shift^k.window[k.strstart+I-1])&k.hash_mask,ae=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 G=l._tr_tally(k,0,k.window[k.strstart]),k.lookahead--,k.strstart++;if(G&&(H(k,!1),k.strm.avail_out===0))return y}return k.insert=k.strstart<I-1?k.strstart:I-1,oe===p?(H(k,!0),k.strm.avail_out===0?D:L):k.last_lit&&(H(k,!1),k.strm.avail_out===0)?y:T}function q(k,oe){for(var ae,G,V;;){if(k.lookahead<F){if(te(k),k.lookahead<F&&oe===h)return y;if(k.lookahead===0)break}if(ae=0,k.lookahead>=I&&(k.ins_h=(k.ins_h<<k.hash_shift^k.window[k.strstart+I-1])&k.hash_mask,ae=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=I-1,ae!==0&&k.prev_length<k.max_lazy_match&&k.strstart-ae<=k.w_size-F&&(k.match_length=W(k,ae),k.match_length<=5&&(k.strategy===1||k.match_length===I&&4096<k.strstart-k.match_start)&&(k.match_length=I-1)),k.prev_length>=I&&k.match_length<=k.prev_length){for(V=k.strstart+k.lookahead-I,G=l._tr_tally(k,k.strstart-1-k.prev_match,k.prev_length-I),k.lookahead-=k.prev_length-1,k.prev_length-=2;++k.strstart<=V&&(k.ins_h=(k.ins_h<<k.hash_shift^k.window[k.strstart+I-1])&k.hash_mask,ae=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=I-1,k.strstart++,G&&(H(k,!1),k.strm.avail_out===0))return y}else if(k.match_available){if((G=l._tr_tally(k,0,k.window[k.strstart-1]))&&H(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&&(G=l._tr_tally(k,0,k.window[k.strstart-1]),k.match_available=0),k.insert=k.strstart<I-1?k.strstart:I-1,oe===p?(H(k,!0),k.strm.avail_out===0?D:L):k.last_lit&&(H(k,!1),k.strm.avail_out===0)?y:T}function Y(k,oe,ae,G,V){this.good_length=k,this.max_lazy=oe,this.nice_length=ae,this.max_chain=G,this.func=V}function re(){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*S+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*_+1),J(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new i.Buf16(2*_+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 ue(k){var oe;return k&&k.state?(k.total_in=k.total_out=0,k.data_type=w,(oe=k.state).pending=0,oe.pending_out=0,oe.wrap<0&&(oe.wrap=-oe.wrap),oe.status=oe.wrap?N:R,k.adler=oe.wrap===2?0:1,oe.last_flush=h,l._tr_init(oe),m):O(k,x)}function ce(k){var oe=ue(k);return oe===m&&function(ae){ae.window_size=2*ae.w_size,J(ae.head),ae.max_lazy_match=a[ae.level].max_lazy,ae.good_match=a[ae.level].good_length,ae.nice_match=a[ae.level].nice_length,ae.max_chain_length=a[ae.level].max_chain,ae.strstart=0,ae.block_start=0,ae.lookahead=0,ae.insert=0,ae.match_length=ae.prev_length=I-1,ae.match_available=0,ae.ins_h=0}(k.state),oe}function pe(k,oe,ae,G,V,ne){if(!k)return x;var B=1;if(oe===g&&(oe=6),G<0?(B=0,G=-G):15<G&&(B=2,G-=16),V<1||C<V||ae!==b||G<8||15<G||oe<0||9<oe||ne<0||v<ne)return O(k,x);G===8&&(G=9);var K=new re;return(k.state=K).strm=k,K.wrap=B,K.gzhead=null,K.w_bits=G,K.w_size=1<<K.w_bits,K.w_mask=K.w_size-1,K.hash_bits=V+7,K.hash_size=1<<K.hash_bits,K.hash_mask=K.hash_size-1,K.hash_shift=~~((K.hash_bits+I-1)/I),K.window=new i.Buf8(2*K.w_size),K.head=new i.Buf16(K.hash_size),K.prev=new i.Buf16(K.w_size),K.lit_bufsize=1<<V+6,K.pending_buf_size=4*K.lit_bufsize,K.pending_buf=new i.Buf8(K.pending_buf_size),K.d_buf=1*K.lit_bufsize,K.l_buf=3*K.lit_bufsize,K.level=oe,K.strategy=ne,K.method=ae,ce(k)}a=[new Y(0,0,0,0,function(k,oe){var ae=65535;for(ae>k.pending_buf_size-5&&(ae=k.pending_buf_size-5);;){if(k.lookahead<=1){if(te(k),k.lookahead===0&&oe===h)return y;if(k.lookahead===0)break}k.strstart+=k.lookahead,k.lookahead=0;var G=k.block_start+ae;if((k.strstart===0||k.strstart>=G)&&(k.lookahead=k.strstart-G,k.strstart=G,H(k,!1),k.strm.avail_out===0)||k.strstart-k.block_start>=k.w_size-F&&(H(k,!1),k.strm.avail_out===0))return y}return k.insert=0,oe===p?(H(k,!0),k.strm.avail_out===0?D:L):(k.strstart>k.block_start&&(H(k,!1),k.strm.avail_out),y)}),new Y(4,4,8,4,$),new Y(4,5,16,8,$),new Y(4,6,32,32,$),new Y(4,4,16,16,q),new Y(8,16,32,32,q),new Y(8,16,128,128,q),new Y(8,32,128,256,q),new Y(32,128,258,1024,q),new Y(32,258,258,4096,q)],o.deflateInit=function(k,oe){return pe(k,oe,b,15,8,0)},o.deflateInit2=pe,o.deflateReset=ce,o.deflateResetKeep=ue,o.deflateSetHeader=function(k,oe){return k&&k.state?k.state.wrap!==2?x:(k.state.gzhead=oe,m):x},o.deflate=function(k,oe){var ae,G,V,ne;if(!k||!k.state||5<oe||oe<0)return k?O(k,x):x;if(G=k.state,!k.output||!k.input&&k.avail_in!==0||G.status===666&&oe!==p)return O(k,k.avail_out===0?-5:x);if(G.strm=k,ae=G.last_flush,G.last_flush=oe,G.status===N)if(G.wrap===2)k.adler=0,U(G,31),U(G,139),U(G,8),G.gzhead?(U(G,(G.gzhead.text?1:0)+(G.gzhead.hcrc?2:0)+(G.gzhead.extra?4:0)+(G.gzhead.name?8:0)+(G.gzhead.comment?16:0)),U(G,255&G.gzhead.time),U(G,G.gzhead.time>>8&255),U(G,G.gzhead.time>>16&255),U(G,G.gzhead.time>>24&255),U(G,G.level===9?2:2<=G.strategy||G.level<2?4:0),U(G,255&G.gzhead.os),G.gzhead.extra&&G.gzhead.extra.length&&(U(G,255&G.gzhead.extra.length),U(G,G.gzhead.extra.length>>8&255)),G.gzhead.hcrc&&(k.adler=u(k.adler,G.pending_buf,G.pending,0)),G.gzindex=0,G.status=69):(U(G,0),U(G,0),U(G,0),U(G,0),U(G,0),U(G,G.level===9?2:2<=G.strategy||G.level<2?4:0),U(G,3),G.status=R);else{var B=b+(G.w_bits-8<<4)<<8;B|=(2<=G.strategy||G.level<2?0:G.level<6?1:G.level===6?2:3)<<6,G.strstart!==0&&(B|=32),B+=31-B%31,G.status=R,X(G,B),G.strstart!==0&&(X(G,k.adler>>>16),X(G,65535&k.adler)),k.adler=1}if(G.status===69)if(G.gzhead.extra){for(V=G.pending;G.gzindex<(65535&G.gzhead.extra.length)&&(G.pending!==G.pending_buf_size||(G.gzhead.hcrc&&G.pending>V&&(k.adler=u(k.adler,G.pending_buf,G.pending-V,V)),z(k),V=G.pending,G.pending!==G.pending_buf_size));)U(G,255&G.gzhead.extra[G.gzindex]),G.gzindex++;G.gzhead.hcrc&&G.pending>V&&(k.adler=u(k.adler,G.pending_buf,G.pending-V,V)),G.gzindex===G.gzhead.extra.length&&(G.gzindex=0,G.status=73)}else G.status=73;if(G.status===73)if(G.gzhead.name){V=G.pending;do{if(G.pending===G.pending_buf_size&&(G.gzhead.hcrc&&G.pending>V&&(k.adler=u(k.adler,G.pending_buf,G.pending-V,V)),z(k),V=G.pending,G.pending===G.pending_buf_size)){ne=1;break}ne=G.gzindex<G.gzhead.name.length?255&G.gzhead.name.charCodeAt(G.gzindex++):0,U(G,ne)}while(ne!==0);G.gzhead.hcrc&&G.pending>V&&(k.adler=u(k.adler,G.pending_buf,G.pending-V,V)),ne===0&&(G.gzindex=0,G.status=91)}else G.status=91;if(G.status===91)if(G.gzhead.comment){V=G.pending;do{if(G.pending===G.pending_buf_size&&(G.gzhead.hcrc&&G.pending>V&&(k.adler=u(k.adler,G.pending_buf,G.pending-V,V)),z(k),V=G.pending,G.pending===G.pending_buf_size)){ne=1;break}ne=G.gzindex<G.gzhead.comment.length?255&G.gzhead.comment.charCodeAt(G.gzindex++):0,U(G,ne)}while(ne!==0);G.gzhead.hcrc&&G.pending>V&&(k.adler=u(k.adler,G.pending_buf,G.pending-V,V)),ne===0&&(G.status=103)}else G.status=103;if(G.status===103&&(G.gzhead.hcrc?(G.pending+2>G.pending_buf_size&&z(k),G.pending+2<=G.pending_buf_size&&(U(G,255&k.adler),U(G,k.adler>>8&255),k.adler=0,G.status=R)):G.status=R),G.pending!==0){if(z(k),k.avail_out===0)return G.last_flush=-1,m}else if(k.avail_in===0&&M(oe)<=M(ae)&&oe!==p)return O(k,-5);if(G.status===666&&k.avail_in!==0)return O(k,-5);if(k.avail_in!==0||G.lookahead!==0||oe!==h&&G.status!==666){var K=G.strategy===2?function(Z,le){for(var de;;){if(Z.lookahead===0&&(te(Z),Z.lookahead===0)){if(le===h)return y;break}if(Z.match_length=0,de=l._tr_tally(Z,0,Z.window[Z.strstart]),Z.lookahead--,Z.strstart++,de&&(H(Z,!1),Z.strm.avail_out===0))return y}return Z.insert=0,le===p?(H(Z,!0),Z.strm.avail_out===0?D:L):Z.last_lit&&(H(Z,!1),Z.strm.avail_out===0)?y:T}(G,oe):G.strategy===3?function(Z,le){for(var de,se,he,Ee,Ae=Z.window;;){if(Z.lookahead<=P){if(te(Z),Z.lookahead<=P&&le===h)return y;if(Z.lookahead===0)break}if(Z.match_length=0,Z.lookahead>=I&&0<Z.strstart&&(se=Ae[he=Z.strstart-1])===Ae[++he]&&se===Ae[++he]&&se===Ae[++he]){Ee=Z.strstart+P;do;while(se===Ae[++he]&&se===Ae[++he]&&se===Ae[++he]&&se===Ae[++he]&&se===Ae[++he]&&se===Ae[++he]&&se===Ae[++he]&&se===Ae[++he]&&he<Ee);Z.match_length=P-(Ee-he),Z.match_length>Z.lookahead&&(Z.match_length=Z.lookahead)}if(Z.match_length>=I?(de=l._tr_tally(Z,1,Z.match_length-I),Z.lookahead-=Z.match_length,Z.strstart+=Z.match_length,Z.match_length=0):(de=l._tr_tally(Z,0,Z.window[Z.strstart]),Z.lookahead--,Z.strstart++),de&&(H(Z,!1),Z.strm.avail_out===0))return y}return Z.insert=0,le===p?(H(Z,!0),Z.strm.avail_out===0?D:L):Z.last_lit&&(H(Z,!1),Z.strm.avail_out===0)?y:T}(G,oe):a[G.level].func(G,oe);if(K!==D&&K!==L||(G.status=666),K===y||K===D)return k.avail_out===0&&(G.last_flush=-1),m;if(K===T&&(oe===1?l._tr_align(G):oe!==5&&(l._tr_stored_block(G,0,0,!1),oe===3&&(J(G.head),G.lookahead===0&&(G.strstart=0,G.block_start=0,G.insert=0))),z(k),k.avail_out===0))return G.last_flush=-1,m}return oe!==p?m:G.wrap<=0?1:(G.wrap===2?(U(G,255&k.adler),U(G,k.adler>>8&255),U(G,k.adler>>16&255),U(G,k.adler>>24&255),U(G,255&k.total_in),U(G,k.total_in>>8&255),U(G,k.total_in>>16&255),U(G,k.total_in>>24&255)):(X(G,k.adler>>>16),X(G,65535&k.adler)),z(k),0<G.wrap&&(G.wrap=-G.wrap),G.pending!==0?m: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!==R&&oe!==666?O(k,x):(k.state=null,oe===R?O(k,-3):m):x},o.deflateSetDictionary=function(k,oe){var ae,G,V,ne,B,K,Z,le,de=oe.length;if(!k||!k.state||(ne=(ae=k.state).wrap)===2||ne===1&&ae.status!==N||ae.lookahead)return x;for(ne===1&&(k.adler=c(k.adler,oe,de,0)),ae.wrap=0,de>=ae.w_size&&(ne===0&&(J(ae.head),ae.strstart=0,ae.block_start=0,ae.insert=0),le=new i.Buf8(ae.w_size),i.arraySet(le,oe,de-ae.w_size,ae.w_size,0),oe=le,de=ae.w_size),B=k.avail_in,K=k.next_in,Z=k.input,k.avail_in=de,k.next_in=0,k.input=oe,te(ae);ae.lookahead>=I;){for(G=ae.strstart,V=ae.lookahead-(I-1);ae.ins_h=(ae.ins_h<<ae.hash_shift^ae.window[G+I-1])&ae.hash_mask,ae.prev[G&ae.w_mask]=ae.head[ae.ins_h],ae.head[ae.ins_h]=G,G++,--V;);ae.strstart=G,ae.lookahead=I-1,te(ae)}return ae.strstart+=ae.lookahead,ae.block_start=ae.strstart,ae.insert=ae.lookahead,ae.lookahead=0,ae.match_length=ae.prev_length=I-1,ae.match_available=0,k.next_in=K,k.input=Z,k.avail_in=B,ae.wrap=ne,m},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,p,m,x,g,v,w,b,C,_,E,S,j,A,I,P,F,N,R,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),p=f+(a.avail_out-257),m=l.dmax,x=l.wsize,g=l.whave,v=l.wnext,w=l.window,b=l.hold,C=l.bits,_=l.lencode,E=l.distcode,S=(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=_[b&S];t:for(;;){if(b>>>=I=A>>>24,C-=I,(I=A>>>16&255)===0)T[f++]=65535&A;else{if(!(16&I)){if((64&I)==0){A=_[(65535&A)+(b&(1<<I)-1)];continue t}if(32&I){l.mode=12;break e}a.msg="invalid literal/length code",l.mode=30;break e}P=65535&A,(I&=15)&&(C<I&&(b+=y[c++]<<C,C+=8),P+=b&(1<<I)-1,b>>>=I,C-=I),C<15&&(b+=y[c++]<<C,C+=8,b+=y[c++]<<C,C+=8),A=E[b&j];n:for(;;){if(b>>>=I=A>>>24,C-=I,!(16&(I=A>>>16&255))){if((64&I)==0){A=E[(65535&A)+(b&(1<<I)-1)];continue n}a.msg="invalid distance code",l.mode=30;break e}if(F=65535&A,C<(I&=15)&&(b+=y[c++]<<C,(C+=8)<I&&(b+=y[c++]<<C,C+=8)),m<(F+=b&(1<<I)-1)){a.msg="invalid distance too far back",l.mode=30;break e}if(b>>>=I,C-=I,(I=f-h)<F){if(g<(I=F-I)&&l.sane){a.msg="invalid distance too far back",l.mode=30;break e}if(R=w,(N=0)===v){if(N+=x-I,I<P){for(P-=I;T[f++]=w[N++],--I;);N=f-F,R=T}}else if(v<I){if(N+=x+v-I,(I-=v)<P){for(P-=I;T[f++]=w[N++],--I;);if(N=0,v<P){for(P-=I=v;T[f++]=w[N++],--I;);N=f-F,R=T}}}else if(N+=v-I,I<P){for(P-=I;T[f++]=w[N++],--I;);N=f-F,R=T}for(;2<P;)T[f++]=R[N++],T[f++]=R[N++],T[f++]=R[N++],P-=3;P&&(T[f++]=R[N++],1<P&&(T[f++]=R[N++]))}else{for(N=f-F;T[f++]=T[N++],T[f++]=T[N++],T[f++]=T[N++],2<(P-=3););P&&(T[f++]=T[N++],1<P&&(T[f++]=T[N++]))}break}}break}}while(c<u&&f<p);c-=P=C>>3,b&=(1<<(C-=P<<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<p?p-f+257:257-(f-p),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,p=0,m=-2,x=1,g=852,v=592;function w(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 R;return N&&N.state?(R=N.state,N.total_in=N.total_out=R.total=0,N.msg="",R.wrap&&(N.adler=1&R.wrap),R.mode=x,R.last=0,R.havedict=0,R.dmax=32768,R.head=null,R.hold=0,R.bits=0,R.lencode=R.lendyn=new a.Buf32(g),R.distcode=R.distdyn=new a.Buf32(v),R.sane=1,R.back=-1,p):m}function _(N){var R;return N&&N.state?((R=N.state).wsize=0,R.whave=0,R.wnext=0,C(N)):m}function E(N,R){var y,T;return N&&N.state?(T=N.state,R<0?(y=0,R=-R):(y=1+(R>>4),R<48&&(R&=15)),R&&(R<8||15<R)?m:(T.window!==null&&T.wbits!==R&&(T.window=null),T.wrap=y,T.wbits=R,_(N))):m}function S(N,R){var y,T;return N?(T=new b,(N.state=T).window=null,(y=E(N,R))!==p&&(N.state=null),y):m}var j,A,I=!0;function P(N){if(I){var R;for(j=new a.Buf32(512),A=new a.Buf32(32),R=0;R<144;)N.lens[R++]=8;for(;R<256;)N.lens[R++]=9;for(;R<280;)N.lens[R++]=7;for(;R<288;)N.lens[R++]=8;for(u(f,N.lens,0,288,j,0,N.work,{bits:9}),R=0;R<32;)N.lens[R++]=5;u(h,N.lens,0,32,A,0,N.work,{bits:5}),I=!1}N.lencode=j,N.lenbits=9,N.distcode=A,N.distbits=5}function F(N,R,y,T){var D,L=N.state;return L.window===null&&(L.wsize=1<<L.wbits,L.wnext=0,L.whave=0,L.window=new a.Buf8(L.wsize)),T>=L.wsize?(a.arraySet(L.window,R,y-L.wsize,L.wsize,0),L.wnext=0,L.whave=L.wsize):(T<(D=L.wsize-L.wnext)&&(D=T),a.arraySet(L.window,R,y-T,D,L.wnext),(T-=D)?(a.arraySet(L.window,R,y-T,T,0),L.wnext=T,L.whave=L.wsize):(L.wnext+=D,L.wnext===L.wsize&&(L.wnext=0),L.whave<L.wsize&&(L.whave+=D))),0}o.inflateReset=_,o.inflateReset2=E,o.inflateResetKeep=C,o.inflateInit=function(N){return S(N,15)},o.inflateInit2=S,o.inflate=function(N,R){var y,T,D,L,O,M,J,z,H,U,X,W,te,$,q,Y,re,ue,ce,pe,k,oe,ae,G,V=0,ne=new a.Buf8(4),B=[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 m;(y=N.state).mode===12&&(y.mode=13),O=N.next_out,D=N.output,J=N.avail_out,L=N.next_in,T=N.input,M=N.avail_in,z=y.hold,H=y.bits,U=M,X=J,oe=p;e:for(;;)switch(y.mode){case x:if(y.wrap===0){y.mode=13;break}for(;H<16;){if(M===0)break e;M--,z+=T[L++]<<H,H+=8}if(2&y.wrap&&z===35615){ne[y.check=0]=255&z,ne[1]=z>>>8&255,y.check=l(y.check,ne,2,0),H=z=0,y.mode=2;break}if(y.flags=0,y.head&&(y.head.done=!1),!(1&y.wrap)||(((255&z)<<8)+(z>>8))%31){N.msg="incorrect header check",y.mode=30;break}if((15&z)!=8){N.msg="unknown compression method",y.mode=30;break}if(H-=4,k=8+(15&(z>>>=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&z?10:12,H=z=0;break;case 2:for(;H<16;){if(M===0)break e;M--,z+=T[L++]<<H,H+=8}if(y.flags=z,(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=z>>8&1),512&y.flags&&(ne[0]=255&z,ne[1]=z>>>8&255,y.check=l(y.check,ne,2,0)),H=z=0,y.mode=3;case 3:for(;H<32;){if(M===0)break e;M--,z+=T[L++]<<H,H+=8}y.head&&(y.head.time=z),512&y.flags&&(ne[0]=255&z,ne[1]=z>>>8&255,ne[2]=z>>>16&255,ne[3]=z>>>24&255,y.check=l(y.check,ne,4,0)),H=z=0,y.mode=4;case 4:for(;H<16;){if(M===0)break e;M--,z+=T[L++]<<H,H+=8}y.head&&(y.head.xflags=255&z,y.head.os=z>>8),512&y.flags&&(ne[0]=255&z,ne[1]=z>>>8&255,y.check=l(y.check,ne,2,0)),H=z=0,y.mode=5;case 5:if(1024&y.flags){for(;H<16;){if(M===0)break e;M--,z+=T[L++]<<H,H+=8}y.length=z,y.head&&(y.head.extra_len=z),512&y.flags&&(ne[0]=255&z,ne[1]=z>>>8&255,y.check=l(y.check,ne,2,0)),H=z=0}else y.head&&(y.head.extra=null);y.mode=6;case 6:if(1024&y.flags&&(M<(W=y.length)&&(W=M),W&&(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,L,W,k)),512&y.flags&&(y.check=l(y.check,T,W,L)),M-=W,L+=W,y.length-=W),y.length))break e;y.length=0,y.mode=7;case 7:if(2048&y.flags){if(M===0)break e;for(W=0;k=T[L+W++],y.head&&k&&y.length<65536&&(y.head.name+=String.fromCharCode(k)),k&&W<M;);if(512&y.flags&&(y.check=l(y.check,T,W,L)),M-=W,L+=W,k)break e}else y.head&&(y.head.name=null);y.length=0,y.mode=8;case 8:if(4096&y.flags){if(M===0)break e;for(W=0;k=T[L+W++],y.head&&k&&y.length<65536&&(y.head.comment+=String.fromCharCode(k)),k&&W<M;);if(512&y.flags&&(y.check=l(y.check,T,W,L)),M-=W,L+=W,k)break e}else y.head&&(y.head.comment=null);y.mode=9;case 9:if(512&y.flags){for(;H<16;){if(M===0)break e;M--,z+=T[L++]<<H,H+=8}if(z!==(65535&y.check)){N.msg="header crc mismatch",y.mode=30;break}H=z=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(;H<32;){if(M===0)break e;M--,z+=T[L++]<<H,H+=8}N.adler=y.check=w(z),H=z=0,y.mode=11;case 11:if(y.havedict===0)return N.next_out=O,N.avail_out=J,N.next_in=L,N.avail_in=M,y.hold=z,y.bits=H,2;N.adler=y.check=1,y.mode=12;case 12:if(R===5||R===6)break e;case 13:if(y.last){z>>>=7&H,H-=7&H,y.mode=27;break}for(;H<3;){if(M===0)break e;M--,z+=T[L++]<<H,H+=8}switch(y.last=1&z,H-=1,3&(z>>>=1)){case 0:y.mode=14;break;case 1:if(P(y),y.mode=20,R!==6)break;z>>>=2,H-=2;break e;case 2:y.mode=17;break;case 3:N.msg="invalid block type",y.mode=30}z>>>=2,H-=2;break;case 14:for(z>>>=7&H,H-=7&H;H<32;){if(M===0)break e;M--,z+=T[L++]<<H,H+=8}if((65535&z)!=(z>>>16^65535)){N.msg="invalid stored block lengths",y.mode=30;break}if(y.length=65535&z,H=z=0,y.mode=15,R===6)break e;case 15:y.mode=16;case 16:if(W=y.length){if(M<W&&(W=M),J<W&&(W=J),W===0)break e;a.arraySet(D,T,L,W,O),M-=W,L+=W,J-=W,O+=W,y.length-=W;break}y.mode=12;break;case 17:for(;H<14;){if(M===0)break e;M--,z+=T[L++]<<H,H+=8}if(y.nlen=257+(31&z),z>>>=5,H-=5,y.ndist=1+(31&z),z>>>=5,H-=5,y.ncode=4+(15&z),z>>>=4,H-=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(;H<3;){if(M===0)break e;M--,z+=T[L++]<<H,H+=8}y.lens[B[y.have++]]=7&z,z>>>=3,H-=3}for(;y.have<19;)y.lens[B[y.have++]]=0;if(y.lencode=y.lendyn,y.lenbits=7,ae={bits:y.lenbits},oe=u(0,y.lens,0,19,y.lencode,0,y.work,ae),y.lenbits=ae.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(;Y=(V=y.lencode[z&(1<<y.lenbits)-1])>>>16&255,re=65535&V,!((q=V>>>24)<=H);){if(M===0)break e;M--,z+=T[L++]<<H,H+=8}if(re<16)z>>>=q,H-=q,y.lens[y.have++]=re;else{if(re===16){for(G=q+2;H<G;){if(M===0)break e;M--,z+=T[L++]<<H,H+=8}if(z>>>=q,H-=q,y.have===0){N.msg="invalid bit length repeat",y.mode=30;break}k=y.lens[y.have-1],W=3+(3&z),z>>>=2,H-=2}else if(re===17){for(G=q+3;H<G;){if(M===0)break e;M--,z+=T[L++]<<H,H+=8}H-=q,k=0,W=3+(7&(z>>>=q)),z>>>=3,H-=3}else{for(G=q+7;H<G;){if(M===0)break e;M--,z+=T[L++]<<H,H+=8}H-=q,k=0,W=11+(127&(z>>>=q)),z>>>=7,H-=7}if(y.have+W>y.nlen+y.ndist){N.msg="invalid bit length repeat",y.mode=30;break}for(;W--;)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,ae={bits:y.lenbits},oe=u(f,y.lens,0,y.nlen,y.lencode,0,y.work,ae),y.lenbits=ae.bits,oe){N.msg="invalid literal/lengths set",y.mode=30;break}if(y.distbits=6,y.distcode=y.distdyn,ae={bits:y.distbits},oe=u(h,y.lens,y.nlen,y.ndist,y.distcode,0,y.work,ae),y.distbits=ae.bits,oe){N.msg="invalid distances set",y.mode=30;break}if(y.mode=20,R===6)break e;case 20:y.mode=21;case 21:if(6<=M&&258<=J){N.next_out=O,N.avail_out=J,N.next_in=L,N.avail_in=M,y.hold=z,y.bits=H,c(N,X),O=N.next_out,D=N.output,J=N.avail_out,L=N.next_in,T=N.input,M=N.avail_in,z=y.hold,H=y.bits,y.mode===12&&(y.back=-1);break}for(y.back=0;Y=(V=y.lencode[z&(1<<y.lenbits)-1])>>>16&255,re=65535&V,!((q=V>>>24)<=H);){if(M===0)break e;M--,z+=T[L++]<<H,H+=8}if(Y&&(240&Y)==0){for(ue=q,ce=Y,pe=re;Y=(V=y.lencode[pe+((z&(1<<ue+ce)-1)>>ue)])>>>16&255,re=65535&V,!(ue+(q=V>>>24)<=H);){if(M===0)break e;M--,z+=T[L++]<<H,H+=8}z>>>=ue,H-=ue,y.back+=ue}if(z>>>=q,H-=q,y.back+=q,y.length=re,Y===0){y.mode=26;break}if(32&Y){y.back=-1,y.mode=12;break}if(64&Y){N.msg="invalid literal/length code",y.mode=30;break}y.extra=15&Y,y.mode=22;case 22:if(y.extra){for(G=y.extra;H<G;){if(M===0)break e;M--,z+=T[L++]<<H,H+=8}y.length+=z&(1<<y.extra)-1,z>>>=y.extra,H-=y.extra,y.back+=y.extra}y.was=y.length,y.mode=23;case 23:for(;Y=(V=y.distcode[z&(1<<y.distbits)-1])>>>16&255,re=65535&V,!((q=V>>>24)<=H);){if(M===0)break e;M--,z+=T[L++]<<H,H+=8}if((240&Y)==0){for(ue=q,ce=Y,pe=re;Y=(V=y.distcode[pe+((z&(1<<ue+ce)-1)>>ue)])>>>16&255,re=65535&V,!(ue+(q=V>>>24)<=H);){if(M===0)break e;M--,z+=T[L++]<<H,H+=8}z>>>=ue,H-=ue,y.back+=ue}if(z>>>=q,H-=q,y.back+=q,64&Y){N.msg="invalid distance code",y.mode=30;break}y.offset=re,y.extra=15&Y,y.mode=24;case 24:if(y.extra){for(G=y.extra;H<G;){if(M===0)break e;M--,z+=T[L++]<<H,H+=8}y.offset+=z&(1<<y.extra)-1,z>>>=y.extra,H-=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(W=X-J,y.offset>W){if((W=y.offset-W)>y.whave&&y.sane){N.msg="invalid distance too far back",y.mode=30;break}te=W>y.wnext?(W-=y.wnext,y.wsize-W):y.wnext-W,W>y.length&&(W=y.length),$=y.window}else $=D,te=O-y.offset,W=y.length;for(J<W&&(W=J),J-=W,y.length-=W;D[O++]=$[te++],--W;);y.length===0&&(y.mode=21);break;case 26:if(J===0)break e;D[O++]=y.length,J--,y.mode=21;break;case 27:if(y.wrap){for(;H<32;){if(M===0)break e;M--,z|=T[L++]<<H,H+=8}if(X-=J,N.total_out+=X,y.total+=X,X&&(N.adler=y.check=y.flags?l(y.check,D,X,O-X):i(y.check,D,X,O-X)),X=J,(y.flags?z:w(z))!==y.check){N.msg="incorrect data check",y.mode=30;break}H=z=0}y.mode=28;case 28:if(y.wrap&&y.flags){for(;H<32;){if(M===0)break e;M--,z+=T[L++]<<H,H+=8}if(z!==(4294967295&y.total)){N.msg="incorrect length check",y.mode=30;break}H=z=0}y.mode=29;case 29:oe=1;break e;case 30:oe=-3;break e;case 31:return-4;case 32:default:return m}return N.next_out=O,N.avail_out=J,N.next_in=L,N.avail_in=M,y.hold=z,y.bits=H,(y.wsize||X!==N.avail_out&&y.mode<30&&(y.mode<27||R!==4))&&F(N,N.output,N.next_out,X-N.avail_out)?(y.mode=31,-4):(U-=N.avail_in,X-=N.avail_out,N.total_in+=U,N.total_out+=X,y.total+=X,y.wrap&&X&&(N.adler=y.check=y.flags?l(y.check,D,X,N.next_out-X):i(y.check,D,X,N.next_out-X)),N.data_type=y.bits+(y.last?64:0)+(y.mode===12?128:0)+(y.mode===20||y.mode===15?256:0),(U==0&&X===0||R===4)&&oe===p&&(oe=-5),oe)},o.inflateEnd=function(N){if(!N||!N.state)return m;var R=N.state;return R.window&&(R.window=null),N.state=null,p},o.inflateGetHeader=function(N,R){var y;return N&&N.state?(2&(y=N.state).wrap)==0?m:((y.head=R).done=!1,p):m},o.inflateSetDictionary=function(N,R){var y,T=R.length;return N&&N.state?(y=N.state).wrap!==0&&y.mode!==11?m:y.mode===11&&i(1,R,T,0)!==y.check?-3:F(N,R,T,T)?(y.mode=31,-4):(y.havedict=1,p):m},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,p,m,x,g,v,w){var b,C,_,E,S,j,A,I,P,F=w.bits,N=0,R=0,y=0,T=0,D=0,L=0,O=0,M=0,J=0,z=0,H=null,U=0,X=new a.Buf16(16),W=new a.Buf16(16),te=null,$=0;for(N=0;N<=15;N++)X[N]=0;for(R=0;R<m;R++)X[h[p+R]]++;for(D=F,T=15;1<=T&&X[T]===0;T--);if(T<D&&(D=T),T===0)return x[g++]=20971520,x[g++]=20971520,w.bits=1,0;for(y=1;y<T&&X[y]===0;y++);for(D<y&&(D=y),N=M=1;N<=15;N++)if(M<<=1,(M-=X[N])<0)return-1;if(0<M&&(f===0||T!==1))return-1;for(W[1]=0,N=1;N<15;N++)W[N+1]=W[N]+X[N];for(R=0;R<m;R++)h[p+R]!==0&&(v[W[h[p+R]]++]=R);if(j=f===0?(H=te=v,19):f===1?(H=i,U-=257,te=l,$-=257,256):(H=c,te=u,-1),N=y,S=g,O=R=z=0,_=-1,E=(J=1<<(L=D))-1,f===1&&852<J||f===2&&592<J)return 1;for(;;){for(A=N-O,P=v[R]<j?(I=0,v[R]):v[R]>j?(I=te[$+v[R]],H[U+v[R]]):(I=96,0),b=1<<N-O,y=C=1<<L;x[S+(z>>O)+(C-=b)]=A<<24|I<<16|P|0,C!==0;);for(b=1<<N-1;z&b;)b>>=1;if(b!==0?(z&=b-1,z+=b):z=0,R++,--X[N]==0){if(N===T)break;N=h[p+v[R]]}if(D<N&&(z&E)!==_){for(O===0&&(O=D),S+=y,M=1<<(L=N-O);L+O<T&&!((M-=X[L+O])<=0);)L++,M<<=1;if(J+=1<<L,f===1&&852<J||f===2&&592<J)return 1;x[_=z&E]=D<<24|L<<16|S-g|0}}return z!==0&&(x[S+z]=N-O<<24|64<<16|0),w.bits=D,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(V){for(var ne=V.length;0<=--ne;)V[ne]=0}var u=0,f=29,h=256,p=h+1+f,m=30,x=19,g=2*p+1,v=15,w=16,b=7,C=256,_=16,E=17,S=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],I=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],P=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],F=new Array(2*(p+2));c(F);var N=new Array(2*m);c(N);var R=new Array(512);c(R);var y=new Array(256);c(y);var T=new Array(f);c(T);var D,L,O,M=new Array(m);function J(V,ne,B,K,Z){this.static_tree=V,this.extra_bits=ne,this.extra_base=B,this.elems=K,this.max_length=Z,this.has_stree=V&&V.length}function z(V,ne){this.dyn_tree=V,this.max_code=0,this.stat_desc=ne}function H(V){return V<256?R[V]:R[256+(V>>>7)]}function U(V,ne){V.pending_buf[V.pending++]=255&ne,V.pending_buf[V.pending++]=ne>>>8&255}function X(V,ne,B){V.bi_valid>w-B?(V.bi_buf|=ne<<V.bi_valid&65535,U(V,V.bi_buf),V.bi_buf=ne>>w-V.bi_valid,V.bi_valid+=B-w):(V.bi_buf|=ne<<V.bi_valid&65535,V.bi_valid+=B)}function W(V,ne,B){X(V,B[2*ne],B[2*ne+1])}function te(V,ne){for(var B=0;B|=1&V,V>>>=1,B<<=1,0<--ne;);return B>>>1}function $(V,ne,B){var K,Z,le=new Array(v+1),de=0;for(K=1;K<=v;K++)le[K]=de=de+B[K-1]<<1;for(Z=0;Z<=ne;Z++){var se=V[2*Z+1];se!==0&&(V[2*Z]=te(le[se]++,se))}}function q(V){var ne;for(ne=0;ne<p;ne++)V.dyn_ltree[2*ne]=0;for(ne=0;ne<m;ne++)V.dyn_dtree[2*ne]=0;for(ne=0;ne<x;ne++)V.bl_tree[2*ne]=0;V.dyn_ltree[2*C]=1,V.opt_len=V.static_len=0,V.last_lit=V.matches=0}function Y(V){8<V.bi_valid?U(V,V.bi_buf):0<V.bi_valid&&(V.pending_buf[V.pending++]=V.bi_buf),V.bi_buf=0,V.bi_valid=0}function re(V,ne,B,K){var Z=2*ne,le=2*B;return V[Z]<V[le]||V[Z]===V[le]&&K[ne]<=K[B]}function ue(V,ne,B){for(var K=V.heap[B],Z=B<<1;Z<=V.heap_len&&(Z<V.heap_len&&re(ne,V.heap[Z+1],V.heap[Z],V.depth)&&Z++,!re(ne,K,V.heap[Z],V.depth));)V.heap[B]=V.heap[Z],B=Z,Z<<=1;V.heap[B]=K}function ce(V,ne,B){var K,Z,le,de,se=0;if(V.last_lit!==0)for(;K=V.pending_buf[V.d_buf+2*se]<<8|V.pending_buf[V.d_buf+2*se+1],Z=V.pending_buf[V.l_buf+se],se++,K===0?W(V,Z,ne):(W(V,(le=y[Z])+h+1,ne),(de=j[le])!==0&&X(V,Z-=T[le],de),W(V,le=H(--K),B),(de=A[le])!==0&&X(V,K-=M[le],de)),se<V.last_lit;);W(V,C,ne)}function pe(V,ne){var B,K,Z,le=ne.dyn_tree,de=ne.stat_desc.static_tree,se=ne.stat_desc.has_stree,he=ne.stat_desc.elems,Ee=-1;for(V.heap_len=0,V.heap_max=g,B=0;B<he;B++)le[2*B]!==0?(V.heap[++V.heap_len]=Ee=B,V.depth[B]=0):le[2*B+1]=0;for(;V.heap_len<2;)le[2*(Z=V.heap[++V.heap_len]=Ee<2?++Ee:0)]=1,V.depth[Z]=0,V.opt_len--,se&&(V.static_len-=de[2*Z+1]);for(ne.max_code=Ee,B=V.heap_len>>1;1<=B;B--)ue(V,le,B);for(Z=he;B=V.heap[1],V.heap[1]=V.heap[V.heap_len--],ue(V,le,1),K=V.heap[1],V.heap[--V.heap_max]=B,V.heap[--V.heap_max]=K,le[2*Z]=le[2*B]+le[2*K],V.depth[Z]=(V.depth[B]>=V.depth[K]?V.depth[B]:V.depth[K])+1,le[2*B+1]=le[2*K+1]=Z,V.heap[1]=Z++,ue(V,le,1),2<=V.heap_len;);V.heap[--V.heap_max]=V.heap[1],function(Ae,pt){var Lt,jt,Rt,it,Ot,Jt,Ft=pt.dyn_tree,xe=pt.max_code,Re=pt.stat_desc.static_tree,Ie=pt.stat_desc.has_stree,Pe=pt.stat_desc.extra_bits,ot=pt.stat_desc.extra_base,Me=pt.stat_desc.max_length,Pt=0;for(it=0;it<=v;it++)Ae.bl_count[it]=0;for(Ft[2*Ae.heap[Ae.heap_max]+1]=0,Lt=Ae.heap_max+1;Lt<g;Lt++)Me<(it=Ft[2*Ft[2*(jt=Ae.heap[Lt])+1]+1]+1)&&(it=Me,Pt++),Ft[2*jt+1]=it,xe<jt||(Ae.bl_count[it]++,Ot=0,ot<=jt&&(Ot=Pe[jt-ot]),Jt=Ft[2*jt],Ae.opt_len+=Jt*(it+Ot),Ie&&(Ae.static_len+=Jt*(Re[2*jt+1]+Ot)));if(Pt!==0){do{for(it=Me-1;Ae.bl_count[it]===0;)it--;Ae.bl_count[it]--,Ae.bl_count[it+1]+=2,Ae.bl_count[Me]--,Pt-=2}while(0<Pt);for(it=Me;it!==0;it--)for(jt=Ae.bl_count[it];jt!==0;)xe<(Rt=Ae.heap[--Lt])||(Ft[2*Rt+1]!==it&&(Ae.opt_len+=(it-Ft[2*Rt+1])*Ft[2*Rt],Ft[2*Rt+1]=it),jt--)}}(V,ne),$(le,Ee,V.bl_count)}function k(V,ne,B){var K,Z,le=-1,de=ne[1],se=0,he=7,Ee=4;for(de===0&&(he=138,Ee=3),ne[2*(B+1)+1]=65535,K=0;K<=B;K++)Z=de,de=ne[2*(K+1)+1],++se<he&&Z===de||(se<Ee?V.bl_tree[2*Z]+=se:Z!==0?(Z!==le&&V.bl_tree[2*Z]++,V.bl_tree[2*_]++):se<=10?V.bl_tree[2*E]++:V.bl_tree[2*S]++,le=Z,Ee=(se=0)===de?(he=138,3):Z===de?(he=6,3):(he=7,4))}function oe(V,ne,B){var K,Z,le=-1,de=ne[1],se=0,he=7,Ee=4;for(de===0&&(he=138,Ee=3),K=0;K<=B;K++)if(Z=de,de=ne[2*(K+1)+1],!(++se<he&&Z===de)){if(se<Ee)for(;W(V,Z,V.bl_tree),--se!=0;);else Z!==0?(Z!==le&&(W(V,Z,V.bl_tree),se--),W(V,_,V.bl_tree),X(V,se-3,2)):se<=10?(W(V,E,V.bl_tree),X(V,se-3,3)):(W(V,S,V.bl_tree),X(V,se-11,7));le=Z,Ee=(se=0)===de?(he=138,3):Z===de?(he=6,3):(he=7,4)}}c(M);var ae=!1;function G(V,ne,B,K){X(V,(u<<1)+(K?1:0),3),function(Z,le,de,se){Y(Z),U(Z,de),U(Z,~de),a.arraySet(Z.pending_buf,Z.window,le,de,Z.pending),Z.pending+=de}(V,ne,B)}o._tr_init=function(V){ae||(function(){var ne,B,K,Z,le,de=new Array(v+1);for(Z=K=0;Z<f-1;Z++)for(T[Z]=K,ne=0;ne<1<<j[Z];ne++)y[K++]=Z;for(y[K-1]=Z,Z=le=0;Z<16;Z++)for(M[Z]=le,ne=0;ne<1<<A[Z];ne++)R[le++]=Z;for(le>>=7;Z<m;Z++)for(M[Z]=le<<7,ne=0;ne<1<<A[Z]-7;ne++)R[256+le++]=Z;for(B=0;B<=v;B++)de[B]=0;for(ne=0;ne<=143;)F[2*ne+1]=8,ne++,de[8]++;for(;ne<=255;)F[2*ne+1]=9,ne++,de[9]++;for(;ne<=279;)F[2*ne+1]=7,ne++,de[7]++;for(;ne<=287;)F[2*ne+1]=8,ne++,de[8]++;for($(F,p+1,de),ne=0;ne<m;ne++)N[2*ne+1]=5,N[2*ne]=te(ne,5);D=new J(F,j,h+1,p,v),L=new J(N,A,0,m,v),O=new J(new Array(0),I,0,x,b)}(),ae=!0),V.l_desc=new z(V.dyn_ltree,D),V.d_desc=new z(V.dyn_dtree,L),V.bl_desc=new z(V.bl_tree,O),V.bi_buf=0,V.bi_valid=0,q(V)},o._tr_stored_block=G,o._tr_flush_block=function(V,ne,B,K){var Z,le,de=0;0<V.level?(V.strm.data_type===2&&(V.strm.data_type=function(se){var he,Ee=4093624447;for(he=0;he<=31;he++,Ee>>>=1)if(1&Ee&&se.dyn_ltree[2*he]!==0)return i;if(se.dyn_ltree[18]!==0||se.dyn_ltree[20]!==0||se.dyn_ltree[26]!==0)return l;for(he=32;he<h;he++)if(se.dyn_ltree[2*he]!==0)return l;return i}(V)),pe(V,V.l_desc),pe(V,V.d_desc),de=function(se){var he;for(k(se,se.dyn_ltree,se.l_desc.max_code),k(se,se.dyn_dtree,se.d_desc.max_code),pe(se,se.bl_desc),he=x-1;3<=he&&se.bl_tree[2*P[he]+1]===0;he--);return se.opt_len+=3*(he+1)+5+5+4,he}(V),Z=V.opt_len+3+7>>>3,(le=V.static_len+3+7>>>3)<=Z&&(Z=le)):Z=le=B+5,B+4<=Z&&ne!==-1?G(V,ne,B,K):V.strategy===4||le===Z?(X(V,2+(K?1:0),3),ce(V,F,N)):(X(V,4+(K?1:0),3),function(se,he,Ee,Ae){var pt;for(X(se,he-257,5),X(se,Ee-1,5),X(se,Ae-4,4),pt=0;pt<Ae;pt++)X(se,se.bl_tree[2*P[pt]+1],3);oe(se,se.dyn_ltree,he-1),oe(se,se.dyn_dtree,Ee-1)}(V,V.l_desc.max_code+1,V.d_desc.max_code+1,de+1),ce(V,V.dyn_ltree,V.dyn_dtree)),q(V),K&&Y(V)},o._tr_tally=function(V,ne,B){return V.pending_buf[V.d_buf+2*V.last_lit]=ne>>>8&255,V.pending_buf[V.d_buf+2*V.last_lit+1]=255&ne,V.pending_buf[V.l_buf+V.last_lit]=255&B,V.last_lit++,ne===0?V.dyn_ltree[2*B]++:(V.matches++,ne--,V.dyn_ltree[2*(y[B]+h+1)]++,V.dyn_dtree[2*H(ne)]++),V.last_lit===V.lit_bufsize-1},o._tr_align=function(V){X(V,2,3),W(V,C,F),function(ne){ne.bi_valid===16?(U(ne,ne.bi_buf),ne.bi_buf=0,ne.bi_valid=0):8<=ne.bi_valid&&(ne.pending_buf[ne.pending++]=255&ne.bi_buf,ne.bi_buf>>=8,ne.bi_valid-=8)}(V)}},{"../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,p=1,m={},x=!1,g=i.document,v=Object.getPrototypeOf&&Object.getPrototypeOf(i);v=v&&v.setTimeout?v:i,c={}.toString.call(i.process)==="[object process]"?function(_){process.nextTick(function(){b(_)})}:function(){if(i.postMessage&&!i.importScripts){var _=!0,E=i.onmessage;return i.onmessage=function(){_=!1},i.postMessage("","*"),i.onmessage=E,_}}()?(h="setImmediate$"+Math.random()+"$",i.addEventListener?i.addEventListener("message",C,!1):i.attachEvent("onmessage",C),function(_){i.postMessage(h+_,"*")}):i.MessageChannel?((f=new MessageChannel).port1.onmessage=function(_){b(_.data)},function(_){f.port2.postMessage(_)}):g&&"onreadystatechange"in g.createElement("script")?(u=g.documentElement,function(_){var E=g.createElement("script");E.onreadystatechange=function(){b(_),E.onreadystatechange=null,u.removeChild(E),E=null},u.appendChild(E)}):function(_){setTimeout(b,0,_)},v.setImmediate=function(_){typeof _!="function"&&(_=new Function(""+_));for(var E=new Array(arguments.length-1),S=0;S<E.length;S++)E[S]=arguments[S+1];var j={callback:_,args:E};return m[p]=j,c(p),p++},v.clearImmediate=w}function w(_){delete m[_]}function b(_){if(x)setTimeout(b,0,_);else{var E=m[_];if(E){x=!0;try{(function(S){var j=S.callback,A=S.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{w(_),x=!1}}}}function C(_){_.source===i&&typeof _.data=="string"&&_.data.indexOf(h)===0&&b(+_.data.slice(h.length))}})(typeof self>"u"?a===void 0?this:a:self)}).call(this,typeof Ci<"u"?Ci:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})}(ju)),ju.exports}var yF=bF();const CF=iC(yF),SF=100*1024*1024,_F=({open:e,onOpenChange:t,onImport:n})=>{const{validationLimits:r}=sn(),o=r==null?void 0:r.maxUploadSizeBytes,a=(r==null?void 0:r.maxZipUploadSizeBytes)??SF,[i,l]=d.useState(null),[c,u]=d.useState(""),[f,h]=d.useState(null),[p,m]=d.useState(""),[x,g]=d.useState(null),[v,w]=d.useState(!1),[b,C]=d.useState(!1),_=d.useRef(null),E=()=>{v||(l(null),u(""),h(null),m(""),g(null),t(!1))},S=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 CF.loadAsync(y);if(!T.files["project.json"])return g("Invalid project export: missing project.json"),!1;const D=await T.files["project.json"].async("string"),L=JSON.parse(D);if(L.version!=="1.0")return g(`Unsupported export version: ${L.version}. Only version 1.0 is currently supported.`),!1;const O=Object.keys(T.files).filter(X=>X.startsWith("artifacts/")&&X!=="artifacts/"),M=O.map(X=>X.replace("artifacts/","")),J=L.artifacts||[],z=new Map;for(const X of J)X.filename&&typeof X.size=="number"&&z.set(X.filename,X.size);const H=[],U=[];for(const X of O){const W=T.files[X],te=X.replace("artifacts/","");let $=z.get(te);if($===void 0)try{$=(await W.async("uint8array")).length}catch{$=0}const q=o?$>o:!1,Y={name:te,size:$,isOversized:q};H.push(Y),q&&U.push(Y)}return h({name:L.project.name,description:L.project.description,systemPrompt:L.project.systemPrompt,defaultAgentId:L.project.defaultAgentId,artifactCount:O.length,artifactNames:M,artifacts:H,oversizedArtifacts:U}),m(L.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 S(y)},A=async y=>{var D;const T=(D=y.target.files)==null?void 0:D[0];T&&await j(T)},I=y=>{y.preventDefault(),C(!0)},P=y=>{y.preventDefault(),C(!1)},F=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}w(!0),g(null);try{await n(i,{preserveName:!1,customName:p.trim()||void 0}),E()}catch(y){const T=y instanceof Error?y.message:"Failed to import project";g(T)}finally{w(!1)}},R=()=>{var y;l(null),u(""),h(null),m(""),g(null),(y=_.current)==null||y.click()};return s.jsx(Pn,{open:e,onOpenChange:E,children:s.jsxs(Mn,{className:"sm:max-w-[500px]",children:[s.jsxs(Vn,{children:[s.jsx(Dn,{children:"Import Project"}),s.jsx(Wn,{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(Nt,{children:"Project File"}),i?s.jsxs("div",{className:"bg-muted/50 flex items-center gap-3 rounded-lg border p-3",children:[s.jsx(Da,{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(me,{variant:"ghost",size:"sm",onClick:R,disabled:v,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:I,onDragLeave:P,onDrop:F,onClick:()=>{var y;return(y=_.current)==null?void 0:y.click()},children:[s.jsx(Os,{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:_,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(Nt,{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(Nt,{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(Nt,{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(Nt,{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(Nt,{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(Rd,{className:"text-destructive h-3 w-3 flex-shrink-0"}):s.jsx(Da,{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(Vt,{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(Nt,{htmlFor:"customName",children:"Project Name"}),s.jsx(xr,{id:"customName",value:p,onChange:y=>m(y.target.value),placeholder:"Enter project name",disabled:v}),s.jsx("p",{className:"text-muted-foreground text-xs",children:"Name conflicts will be resolved automatically"})]}),x&&s.jsx(Vt,{variant:"error",message:x})]}),s.jsxs(er,{children:[s.jsx(me,{variant:"outline",onClick:E,disabled:v,children:"Cancel"}),s.jsx(me,{onClick:N,disabled:v,children:v?"Importing...":"Import"})]})]})})},C1="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.",S1="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.",kF=`${C1} ${S1}`,jF=()=>s.jsxs("span",{children:[C1,s.jsx("br",{}),s.jsx("br",{}),S1]}),EF=({projects:e,searchQuery:t,onSearchChange:n,onProjectClick:r,onCreateNew:o,onDelete:a,onExport:i,isLoading:l=!1})=>s.jsx("div",{className:"bg-card-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(gf,{value:t,onChange:n,placeholder:"Filter by name...",className:"mb-4 w-xs"}):null,l?s.jsx(Pr,{variant:"loading",title:"Loading projects..."}):e.length===0&&t?s.jsx(Pr,{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(Pr,{variant:"noImage",title:"No Projects Found",subtitle:s.jsx(jF,{}),buttons:[{text:"Create New Project",variant:"default",onClick:()=>o()}]}):s.jsxs("div",{className:"flex-1 overflow-y-auto",children:[s.jsx(Vt,{variant:"info",message:kF,className:"mr-6 mb-4"}),s.jsxs("div",{className:"flex flex-wrap gap-6",children:[s.jsx(xF,{onClick:o}),e.map(c=>s.jsx(wF,{project:c,onClick:()=>r(c),onDelete:a,onExport:i},c.id))]})]})]})}),NF=({isOpen:e,onClose:t,onSave:n,project:r,isSaving:o,error:a})=>{const{validationLimits:i}=sn(),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 p=async()=>{if(h(null),c.trim()!==(r.systemPrompt||""))try{await n(c.trim()),t()}catch{}else t()},m=()=>{u(r.systemPrompt||""),h(null),t()},x=c.length,g=x>l;return s.jsx(Pn,{open:e,onOpenChange:v=>!v&&m(),children:s.jsxs(Mn,{className:"flex max-h-[80vh] max-w-3xl flex-col",children:[s.jsxs(Vn,{children:[s.jsx(Dn,{children:"Edit Project Instructions"}),s.jsx(Wn,{children:"Provide instructions that will guide the AI when working with this project."})]}),s.jsxs("div",{className:"min-h-0 flex-1 pt-4",children:[s.jsxs("div",{className:"relative",children:[s.jsx($r,{value:c,onChange:v=>u(v.target.value),placeholder:"Add instructions for this project...",rows:15,disabled:o,maxLength:l+1,className:`resize-none text-sm ${g?"border-destructive":""}`}),s.jsxs("div",{className:`text-xs ${g?"text-destructive":"text-muted-foreground text-right"}`,children:[g&&`Instructions must be less than ${l} characters`,!g&&`${x} / ${l}`]})]}),f&&s.jsx(Vt,{variant:"error",message:f,className:"py-3"})]}),s.jsxs(er,{children:[s.jsx(me,{variant:"outline",onClick:m,disabled:o,children:"Discard Changes"}),s.jsx(me,{onClick:p,disabled:o||g,children:"Save"})]})]})})},TF=({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(me,{variant:"ghost",size:"sm",onClick:()=>a(!0),className:"h-8 w-8 p-0",tooltip:"Edit",children:s.jsx(eo,{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(NF,{isOpen:o,onClose:()=>a(!1),onSave:t,project:e,isSaving:n,error:r})]})},AF=({project:e,onSave:t,isSaving:n})=>{const{agents:r,agentsLoading:o,agentNameDisplayNameMap:a}=It(),[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(me,{variant:"ghost",size:"sm",onClick:()=>l(!0),disabled:o,className:"h-8 w-8 p-0",tooltip:"Edit",children:s.jsx(eo,{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($l,{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(Pn,{open:i,onOpenChange:l,children:s.jsxs(Mn,{children:[s.jsxs(Vn,{children:[s.jsx(Dn,{children:"Edit Default Agent"}),s.jsx(Wn,{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(Nr,{value:c||"none",onValueChange:p=>u(p==="none"?null:p),disabled:n||o,children:[s.jsx(Ar,{className:"w-full",children:s.jsx(Tr,{placeholder:"Select default agent..."})}),s.jsxs(Ir,{children:[s.jsx(_t,{value:"none",children:s.jsx("span",{className:"text-muted-foreground italic",children:"No default agent"})}),r.map(p=>s.jsx(_t,{value:p.name||"",children:p.displayName||p.name},p.name))]})]})}),s.jsxs(er,{children:[s.jsx(me,{variant:"ghost",onClick:h,disabled:n,children:"Cancel"}),s.jsx(me,{onClick:f,disabled:n||o,children:"Save"})]})]})})]})},IF=e=>{const[t,n]=d.useState([]),[r,o]=d.useState(!0),[a,i]=d.useState(null),l=d.useCallback(async()=>{if(!e){n([]),o(!1);return}o(!0),i(null);try{const c=await je.webui.get(`/api/v1/projects/${e}/artifacts`);n(c)}catch(c){const u=c instanceof Error?c.message:"Failed to fetch project artifacts.";i(u),n([])}finally{o(!1)}},[e]);return d.useEffect(()=>{l()},[l]),{artifacts:t,isLoading:r,error:a,refetch:l}},RF=({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:[If(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:Zs(e.last_modified),children:Zs(e.last_modified)}),e.size!==void 0&&s.jsxs(s.Fragment,{children:[e.last_modified&&s.jsx("span",{children:"•"}),s.jsx("span",{children:ri(e.size)})]})]})]})]}),s.jsxs("div",{className:"flex items-center gap-1 opacity-0 transition-opacity group-hover:opacity-100",children:[o&&s.jsx(me,{variant:"ghost",onClick:l=>{l.stopPropagation(),o()},tooltip:"Edit Description",children:s.jsx(eo,{})}),s.jsx(me,{variant:"ghost",onClick:l=>{l.stopPropagation(),t()},tooltip:"Download",children:s.jsx(xo,{})}),n&&s.jsx(me,{variant:"ghost",tooltip:"Delete",onClick:l=>{l.stopPropagation(),i(!0)},children:s.jsx(zl,{})})]})]}),n&&s.jsx(Bo,{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})]})},PF=({isOpen:e,artifact:t,onClose:n,onEdit:r})=>t?s.jsx(Pn,{open:e,onOpenChange:n,children:s.jsxs(Mn,{className:"sm:max-w-[700px]",children:[s.jsxs(Vn,{children:[s.jsxs("div",{className:"flex justify-between gap-4",children:[s.jsxs("div",{className:"flex min-w-0 flex-1 gap-2",children:[If(t,"flex-shrink-0 text-muted-foreground"),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx(Dn,{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?Zs(t.last_modified):null}),s.jsx("div",{children:ri(t.size)})]})]})]}),s.jsxs(me,{variant:"ghost",size:"sm",onClick:r,className:"flex-shrink-0 gap-2 text-sm",children:[s.jsx(eo,{className:"h-4 w-4"}),"Edit Description"]})]}),s.jsx(ec,{children:s.jsx(Wn,{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(er,{children:s.jsx(me,{variant:"outline",onClick:n,children:"Close"})})]})}):null,MF=({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(Pn,{open:e,onOpenChange:u=>!u&&n(),children:s.jsxs(Mn,{className:"sm:max-w-[600px]",children:[s.jsxs(Vn,{children:[s.jsx(Dn,{children:"Edit File Description"}),s.jsx(Wn,{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(xf,{noPadding:!0,className:"bg-muted/50 overflow-hidden py-3 shadow-none",children:s.jsxs(rc,{noPadding:!0,className:"overflow-hidden px-3",children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[s.jsx(gr,{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($r,{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(er,{children:[s.jsx(me,{variant:"ghost",onClick:c,disabled:o,children:"Discard Changes"}),s.jsx(me,{onClick:l,disabled:o,children:o?"Saving...":"Save"})]})]})}):null},DF=({project:e})=>{const{artifacts:t,isLoading:n,error:r,refetch:o}=IF(e.id),{addFilesToProject:a,removeFileFromProject:i,updateFileMetadata:l}=bo(),{onDownload:c}=Rf(e.id),{validationLimits:u}=sn(),f=d.useRef(null),h=u==null?void 0:u.maxUploadSizeBytes,[p,m]=d.useState(null),[x,g]=d.useState(!1),[v,w]=d.useState(!1),[b,C]=d.useState(null),[_,E]=d.useState(!1),[S,j]=d.useState(!1),[A,I]=d.useState(!1),[P,F]=d.useState(null),[N,R]=d.useState(null),y=At.useMemo(()=>[...t].sort((ce,pe)=>{const k=ce.last_modified?new Date(ce.last_modified).getTime():0;return(pe.last_modified?new Date(pe.last_modified).getTime():0)-k}),[t]),T=d.useCallback(ce=>mk(ce,{maxSizeBytes:h}),[h]),D=()=>{var ce;(ce=f.current)==null||ce.click()},L=ce=>{const pe=ce.target.files;if(pe&&pe.length>0){const k=T(pe);if(!k.valid){R(k.error||"One or more files exceed the maximum allowed size."),ce.target&&(ce.target.value="");return}R(null);const oe=new DataTransfer;Array.from(pe).forEach(ae=>oe.items.add(ae)),m(oe.files)}ce.target&&(ce.target.value="")},O=ce=>{ce.preventDefault(),ce.stopPropagation(),w(!0)},M=ce=>{ce.preventDefault(),ce.stopPropagation(),w(!1)},J=ce=>{ce.preventDefault(),ce.stopPropagation(),w(!1);const pe=ce.dataTransfer.files;if(pe&&pe.length>0){const k=T(pe);if(!k.valid){R(k.error||"One or more files exceed the maximum allowed size.");return}R(null);const oe=new DataTransfer;Array.from(pe).forEach(ae=>oe.items.add(ae)),m(oe.files)}},z=async ce=>{g(!0),F(null);try{await a(e.id,ce),await o(),m(null)}catch(pe){console.error("Failed to add files:",pe);const k=pe instanceof Error?pe.message:"Failed to upload files. Please try again.";F(k)}finally{g(!1)}},H=()=>{m(null),F(null)},U=()=>{F(null)},X=()=>{R(null)},W=async ce=>{try{await i(e.id,ce),await o()}catch(pe){console.error(`Failed to delete file ${ce}:`,pe)}},te=ce=>{C(ce),E(!0)},$=ce=>{C(ce),j(!0)},q=async ce=>{if(b){I(!0);try{await l(e.id,b.filename,ce),await o(),j(!1),C(null)}catch(pe){console.error("Failed to update file description:",pe)}finally{I(!1)}}},Y=()=>{E(!1),C(null)},re=()=>{j(!1),_||C(null)},ue=()=>{E(!1),j(!0)};return s.jsxs("div",{className:"mb-6",children:[N&&s.jsx("div",{className:"px-4 pb-3",children:s.jsx(Vt,{variant:"error",message:N,dismissible:!0,onDismiss:X})}),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(me,{variant:"ghost",size:"sm",onClick:D,children:[s.jsx(Os,{className:"mr-2 h-4 w-4"}),"Upload"]})]}),s.jsxs("div",{className:"px-4 pb-3",onDragOver:O,onDragLeave:M,onDrop:J,children:[n&&s.jsx("div",{className:"flex items-center justify-center p-4",children:s.jsx(Qr,{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 ${v?"border-primary bg-primary/10 scale-[1.02]":"border-muted-foreground/30"}`,children:[s.jsx(Os,{className:`mb-3 h-10 w-10 transition-colors ${v?"text-primary":"text-muted-foreground"}`}),s.jsx("p",{className:`text-sm transition-colors ${v?"text-primary font-medium":"text-muted-foreground"}`,children:v?"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 ${v?"border-primary bg-primary/10 scale-[1.02]":"border-muted-foreground/20 bg-muted/30"}`,children:[s.jsx(Os,{className:`mx-auto mb-1 h-5 w-5 transition-colors ${v?"text-primary":"text-muted-foreground"}`}),s.jsx("p",{className:`text-xs transition-colors ${v?"text-primary font-medium":"text-muted-foreground"}`,children:v?"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(ce=>s.jsx(RF,{artifact:ce,onDownload:()=>c(ce),onDelete:()=>W(ce.filename),onClick:()=>te(ce),onEditDescription:()=>$(ce)},ce.filename))})]}),s.jsx("input",{type:"file",ref:f,onChange:L,className:"hidden",multiple:!0})]}),s.jsx(vF,{isOpen:!!p,files:p,onClose:H,onConfirm:z,isSubmitting:x,error:P,onClearError:U}),s.jsx(PF,{isOpen:_,artifact:b,onClose:Y,onEdit:ue}),s.jsx(MF,{isOpen:S,artifact:b,onClose:re,onSave:q,isSaving:A})]})},OF=({project:e,onChatClick:t,onStartNewChat:n})=>{const{sessions:r,isLoading:o,error:a}=IT(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(me,{onClick:n,size:"sm",children:[s.jsx(es,{className:"mr-2 h-4 w-4"}),"New Chat"]})]}),o&&s.jsx("div",{className:"flex items-center justify-center p-8",children:s.jsx(Qr,{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(ul,{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(me,{onClick:n,size:"sm",children:[s.jsx(es,{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(Ig,{className:"h-3 w-3"}),s.jsx("span",{children:Zd(i.updatedTime)})]})]})})},i.id))})]})},LF=({project:e,onBack:t,onStartNewChat:n,onChatClick:r})=>{const{updateProject:o,projects:a,deleteProject:i}=bo(),[l,c]=d.useState(!1),[u,f]=d.useState(null),[h,p]=d.useState(!1),[m,x]=d.useState(e.name),[g,v]=d.useState(e.description||""),[w,b]=d.useState(null),[C,_]=d.useState(!1),[E,S]=d.useState(!1),j=async R=>{f(null),c(!0);try{const y={systemPrompt:R};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 R=>{c(!0);try{const y={defaultAgentId:R};await o(e.id,y)}catch(y){throw console.error("Failed to update default agent:",y),y}finally{c(!1)}},I=async()=>{const R=m.trim(),y=g.trim();if(a.some(D=>D.id!==e.id&&D.name.toLowerCase()===R.toLowerCase())){b("A project with this name already exists");return}b(null),c(!0);try{const D={};R!==e.name&&(D.name=R),y!==(e.description||"")&&(D.description=y),Object.keys(D).length>0&&await o(e.id,D),p(!1)}catch(D){console.error("Failed to update project:",D),b(D instanceof Error?D.message:"Failed to update project")}finally{c(!1)}},P=()=>{x(e.name),v(e.description||""),p(!1),b(null)},F=()=>{_(!0)},N=async()=>{S(!0);try{await i(e.id),_(!1),t()}catch(R){console.error("Failed to delete project:",R)}finally{S(!1)}};return s.jsxs("div",{className:"flex h-full flex-col",children:[s.jsx(ms,{title:e.name,breadcrumbs:[{label:"Projects",onClick:t},{label:e.name}],buttons:[s.jsxs(me,{variant:"ghost",size:"sm",onClick:()=>p(!0),className:"gap-2",children:[s.jsx(eo,{className:"h-4 w-4"}),"Edit Details"]},"edit"),s.jsxs(Xs,{children:[s.jsx(Js,{asChild:!0,children:s.jsx(me,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",children:s.jsx(Io,{className:"h-4 w-4"})})}),s.jsx(Qs,{align:"end",children:s.jsxs(jn,{onClick:F,children:[s.jsx(ts,{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(OF,{project:e,onChatClick:r,onStartNewChat:n})]}),s.jsxs("div",{className:"w-[40%] overflow-y-auto",children:[s.jsx(TF,{project:e,onSave:j,isSaving:l,error:u}),s.jsx(AF,{project:e,onSave:A,isSaving:l}),s.jsx(DF,{project:e})]})]}),s.jsx(MP,{children:s.jsx(me,{variant:"outline","data-testid":"closeButton",title:"Close",onClick:t,children:"Close"})}),s.jsx(Pn,{open:h,onOpenChange:p,children:s.jsxs(Mn,{onOpenAutoFocus:R=>R.preventDefault(),children:[s.jsxs(Vn,{children:[s.jsx(Dn,{children:"Edit Project Details"}),s.jsx(Wn,{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(xr,{value:m,onChange:R=>x(R.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($r,{value:g,onChange:R=>v(R.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"]})]}),w&&s.jsx(Vt,{variant:"error",message:w})]}),s.jsxs(er,{children:[s.jsx(me,{variant:"outline",onClick:P,disabled:l,children:"Discard Changes"}),s.jsx(me,{onClick:I,disabled:l,children:"Save"})]})]})}),s.jsx(y1,{isOpen:C,onClose:()=>_(!1),onConfirm:N,project:e,isDeleting:E})]})},dg=()=>{const e=zo(),t=Xg(),{projects:n,isLoading:r,createProject:o,activeProject:a,setActiveProject:i,refetch:l,searchQuery:c,setSearchQuery:u,filteredProjects:f,deleteProject:h}=bo(),{handleNewSession:p,handleSwitchSession:m,addNotification:x,displayError:g}=It(),[v,w]=d.useState(!1),[b,C]=d.useState(!1),[_,E]=d.useState(!1),[S,j]=d.useState(null),[A,I]=d.useState(!1),[P,F]=d.useState(!1),[N,R]=d.useState(null);d.useEffect(()=>{if(t!=null&&t.projectId){const W=n.find(te=>te.id===t.projectId)||null;R(W)}else a?e(`/projects/${a.id}`,{replace:!0}):(R(null),i(null))},[t==null?void 0:t.projectId,a,n,e,i]);const y=async W=>{C(!0);try{const te=new FormData;te.append("name",W.name),W.description&&te.append("description",W.description);const $=await o(te);w(!1),await l(),e(`/projects/${$.id}`)}finally{C(!1)}},T=W=>{e(`/projects/${W.id}`)},D=()=>{i(null),e("/projects")},L=async W=>{N&&i(N),await m(W),e("chat")},O=()=>{w(!0)},M=W=>{j(W),E(!0)},J=async()=>{if(S){I(!0);try{await h(S.id),E(!1),j(null)}catch(W){console.error("Failed to delete project:",W)}finally{I(!1)}}},z=d.useCallback(async()=>{N&&(i(N),await p(!0),e("chat"))},[N,i,p,e]),H=async W=>{try{const te=await je.webui.get(`/api/v1/projects/${W.id}/export`,{fullResponse:!0});if(!te.ok)throw new Error(`Failed to export project: ${te.statusText}`);const $=await te.blob(),q=`project-${W.name.replace(/[^a-z0-9]/gi,"-").toLowerCase()}-${Date.now()}.zip`;ni($,q),x("Project exported","success")}catch(te){console.error("Failed to export project:",te),g({title:"Failed to Export Project",error:Ut(te,"An unknown error occurred while exporting the project.")})}},U=async(W,te)=>{try{const $=new FormData;$.append("file",W),$.append("options",JSON.stringify(te));const q=await je.webui.post("/api/v1/projects/import",$);if(q.warnings&&q.warnings.length>0){const Y=q.warnings.length===1?q.warnings[0]:`Import completed with ${q.warnings.length} warnings:
434
+ ${q.warnings.join(`
435
+ `)}`;x(Y,"info")}await l(),e(`/projects/${q.projectId}`),x(`Project imported with ${q.artifactsImported} artifacts`,"success")}catch($){throw console.error("Failed to import project:",$),$}},X=N!==null;return s.jsxs("div",{className:"flex h-full w-full flex-col",children:[!X&&s.jsx(ms,{title:"Projects",buttons:[s.jsxs(me,{variant:"ghost",title:"Import Project",onClick:()=>F(!0),children:[s.jsx(Os,{className:"size-4"}),"Import Project"]},"importProject"),s.jsxs(me,{"data-testid":"refreshProjects",disabled:r,variant:"ghost",title:"Refresh Projects",onClick:()=>l(),children:[s.jsx(Ul,{className:"size-4"}),"Refresh Projects"]},"refreshProjects")]}),s.jsx("div",{className:"min-h-0 flex-1",children:X?s.jsx(LF,{project:N,onBack:D,onStartNewChat:z,onChatClick:L}):s.jsx(EF,{projects:f,searchQuery:c,onSearchChange:u,onProjectClick:T,onCreateNew:O,onDelete:M,onExport:H,isLoading:r})}),s.jsx(gF,{isOpen:v,onClose:()=>w(!1),onSubmit:y,isSubmitting:b}),s.jsx(y1,{isOpen:_,onClose:()=>{E(!1),j(null)},onConfirm:J,project:S,isDeleting:A}),s.jsx(_F,{open:P,onOpenChange:F,onImport:U})]})};let Ki=null,qi=null;function FF({children:e}){const{fetchCsrfToken:t}=jw(),[n,r]=d.useState(Ki),[o,a]=d.useState(!Ki&&!qi),[i,l]=d.useState(qi);return d.useEffect(()=>{if(Ki||qi)return;let c=!0;return(async()=>{var f,h,p;a(!0),l(null);try{let m=await je.webui.get("/api/v1/config",{credentials:"include",headers:{Accept:"application/json"},fullResponse:!0}),x;if(m.ok)x=await m.json();else{const E=await m.text();if(console.error("Initial config fetch failed:",m.status,E),m.status===403){console.log("Config fetch failed with 403, attempting to get CSRF token first...");const S=await t();if(!S)throw new Error("Failed to obtain CSRF token after config fetch failed.");if(console.log("Retrying config fetch with CSRF token..."),m=await je.webui.get("/api/v1/config",{credentials:"include",headers:{"X-CSRF-TOKEN":S,Accept:"application/json"},fullResponse:!0}),!m.ok){const j=await m.text();throw console.error("Config fetch retry failed:",m.status,j),new Error(`Failed to fetch config on retry: ${m.status} ${j}`)}x=await m.json()}else throw new Error(`Failed to fetch config: ${m.status} ${E}`)}const g=x.frontend_use_authorization??!1;g&&(console.log("Fetching CSRF token for config-related requests..."),await t());const v=((f=x.frontend_feature_enablement)==null?void 0:f.projects)??!1,w=((h=x.frontend_feature_enablement)==null?void 0:h.background_tasks)??!1,b=((p=x.background_tasks_config)==null?void 0:p.default_timeout_ms)??36e5,C=!!x.frontend_platform_server_url,_={webuiServerUrl:x.frontend_server_url,platformServerUrl:x.frontend_platform_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:v,validationLimits:x.validation_limits,backgroundTasksEnabled:w,backgroundTasksDefaultTimeoutMs:b,platformConfigured:C};c&&(Ki=_,r(_),je.configure(_.webuiServerUrl,_.platformServerUrl),console.log("API client configured with:",{webui:_.webuiServerUrl,platform:_.platformServerUrl})),console.log("App config processed and set:",_)}catch(m){if(console.error("Error initializing app:",m),c){const x=m.message||"Failed to load application configuration.";qi=x,l(x)}}finally{c&&a(!1)}})(),()=>{c=!1}},[t]),n?s.jsx(Cw.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(Pr,{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 zF=({children:e})=>{const[t,n]=d.useState(null),[r,o]=d.useState(!1),[a,i]=d.useState(!1),[l,c]=d.useState(null),[u,f]=d.useState({}),[h,p]=d.useState([]),[m,x]=d.useState(null),[g,v]=d.useState(0),[w,b]=d.useState(!1),C=10,_=d.useRef(null),E=d.useRef(null),S=d.useRef(null);d.useEffect(()=>{E.current=t},[t]);const j=d.useCallback(L=>{f(O=>{var H,U,X;const M=L.task_id;if(!M)return L.direction==="discovery"||console.warn("TaskMonitorContext: Received event without task_id, skipping:",L),O;const J=O[M],z=new Date(L.timestamp);if(J){const W=[...J.events,L].sort((te,$)=>new Date(te.timestamp).getTime()-new Date($.timestamp).getTime());return{...O,[M]:{...J,events:W,lastUpdated:z}}}else{let W="Task started...";if(L.direction==="request"&&((U=(H=L.full_payload)==null?void 0:H.method)!=null&&U.startsWith("message/"))){const $=L.full_payload.params;if((X=$==null?void 0:$.message)!=null&&X.parts){const q=$.message.parts.filter(Y=>Y.kind==="text"&&Y.text);q.length>0&&(W=q[q.length-1].text)}}const te={taskId:M,initialRequestText:W,events:[L],firstSeen:z,lastUpdated:z};return p($=>[M,...$.filter(q=>q!==M)]),{...O,[M]:te}}})},[]),A=d.useCallback(()=>{console.log("TaskMonitorContext: SSE connection opened."),o(!1),i(!0),c(null),v(0),b(!1),S.current&&(clearTimeout(S.current),S.current=null)},[]),I=d.useCallback(L=>{try{const O=JSON.parse(L.data);j(O)}catch(O){console.error("TaskMonitorContext: Failed to parse SSE 'a2a_message' event data:",O,"Raw data:",L.data),c("Received unparseable 'a2a_message' event from server.")}},[j]),P=d.useCallback(L=>{console.error("TaskMonitorContext: SSE connection error:",L),o(!1),i(!1),_.current&&_.current.readyState===EventSource.CLOSED?c("Task Monitor SSE connection closed by server or network issue."):c("Task Monitor SSE connection error occurred."),_.current&&(_.current.close(),_.current=null),S.current&&(clearTimeout(S.current),S.current=null)},[]),F=d.useCallback(async()=>{if(a||r){console.warn("TaskMonitorContext: Stream is already active or connecting.");return}console.log("TaskMonitorContext: Attempting to connect stream..."),o(!0);try{const L=await je.webui.post("/api/v1/visualization/subscribe",{subscription_targets:[{type:"my_a2a_messages"}]},{fullResponse:!0});if(!L.ok){const U=await L.json().catch(()=>({detail:"Failed to subscribe"}));if(U.error_type==="authorization_failure"){const X=U.message||"Access denied: insufficient permissions",W=U.suggested_action?` ${U.suggested_action}`:"";throw new Error(`${X}${W}`)}else if(U.error_type==="subscription_failure"){const X=U.message||"Subscription failed",W=U.suggested_action?` ${U.suggested_action}`:"";throw new Error(`${X}${W}`)}else throw new Error(U.detail||U.message||`Subscription failed: ${L.statusText}`)}const O=await L.json();n(O.stream_id);const M=O.sse_endpoint_url.startsWith("/")?je.webui.getFullUrl(O.sse_endpoint_url):O.sse_endpoint_url;_.current&&_.current.close();const J=Wd(),z=`${M}${J?`?token=${J}`:""}`,H=new EventSource(z,{withCredentials:!0});_.current=H,H.onopen=A,H.addEventListener("a2a_message",I),H.onerror=P}catch(L){console.error("TaskMonitorContext: Error connecting stream:",L),c(L instanceof Error?L.message:String(L)),o(!1),i(!1),n(null),_.current&&(_.current.close(),_.current=null),S.current&&(clearTimeout(S.current),S.current=null)}},[a,r,A,I,P]),N=d.useCallback(()=>{if(S.current){console.log("TaskMonitorContext: Reconnection already in progress, skipping...");return}if(g>=C){console.warn("TaskMonitorContext: Max reconnection attempts reached. Stopping auto-reconnection."),b(!1),c(`Connection lost. Max reconnection attempts (${C}) reached.`);return}const L=2e3;console.log(`TaskMonitorContext: Attempting reconnection ${g+1}/${C} in ${L}ms...`),b(!0),v(O=>O+1),S.current=setTimeout(()=>{F()},L)},[g,F]),R=d.useCallback(async()=>{console.log("TaskMonitorContext: Disconnecting stream..."),S.current&&(clearTimeout(S.current),S.current=null),_.current&&(_.current.close(),_.current=null);const L=E.current;if(L)try{await je.webui.delete(`/api/v1/visualization/${L}/unsubscribe`)}catch(O){console.error(`TaskMonitorContext: Error unsubscribing from stream ID: ${L}`,O)}n(null),o(!1),i(!1),c(null),f({}),p([]),x(null),v(0),b(!1)},[]);d.useEffect(()=>()=>{console.log("TaskMonitorProvider: Unmounting. Cleaning up Task Monitor SSE connection."),_.current&&(_.current.close(),_.current=null);const L=E.current;if(L){const O=je.webui.getFullUrl(`/api/v1/visualization/${L}/unsubscribe`);if(navigator.sendBeacon){const M=new FormData;navigator.sendBeacon(O,M)}else je.webui.delete(`/api/v1/visualization/${L}/unsubscribe`,{credentials:"include",keepalive:!0}).catch(M=>console.error("TaskMonitorProvider: Error in final unsubscribe on unmount (fetch):",M))}},[]),d.useEffect(()=>{!a&&!r&&(console.log("TaskProvider: Auto-connecting to task monitor stream..."),F())},[]),d.useEffect(()=>{!a&&!r&&l&&(console.log("TaskMonitorContext: Connection lost, initiating auto-reconnection..."),N())},[a,r,l,N]),d.useEffect(()=>()=>{S.current&&(clearTimeout(S.current),S.current=null)},[]);const y=d.useCallback(L=>{x(L)},[]),T=d.useCallback(async L=>{var O,M;try{const z=(await je.webui.get(`/api/v1/tasks/${L}/events`)).tasks,H={};for(const[U,X]of Object.entries(z)){const W=X.events,te={taskId:U,initialRequestText:X.initial_request_text||"Task loaded from history",events:W,firstSeen:new Date(((O=W[0])==null?void 0:O.timestamp)||Date.now()),lastUpdated:new Date(((M=W[W.length-1])==null?void 0:M.timestamp)||Date.now())};H[U]=te}return f(U=>({...U,...H})),p(U=>U.includes(L)?U:[L,...U]),H[L]||null}catch(J){return console.error(`TaskProvider: Error loading task ${L} from backend:`,J),null}},[]),D={isTaskMonitorConnecting:r,isTaskMonitorConnected:a,taskMonitorSseError:l,monitoredTasks:u,monitoredTaskOrder:h,highlightedStepId:m,isReconnecting:w,reconnectionAttempts:g,connectTaskMonitorStream:F,disconnectTaskMonitorStream:R,setHighlightedStepId:y,loadTaskFromBackend:T};return s.jsx(_w.Provider,{value:D,children:e})},Tn=[];for(let e=0;e<256;++e)Tn.push((e+256).toString(16).slice(1));function $F(e,t=0){return(Tn[e[t+0]]+Tn[e[t+1]]+Tn[e[t+2]]+Tn[e[t+3]]+"-"+Tn[e[t+4]]+Tn[e[t+5]]+"-"+Tn[e[t+6]]+Tn[e[t+7]]+"-"+Tn[e[t+8]]+Tn[e[t+9]]+"-"+Tn[e[t+10]]+Tn[e[t+11]]+Tn[e[t+12]]+Tn[e[t+13]]+Tn[e[t+14]]+Tn[e[t+15]]).toLowerCase()}let Eu;const UF=new Uint8Array(16);function BF(){if(!Eu){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");Eu=crypto.getRandomValues.bind(crypto)}return Eu(UF)}const VF=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),fg={randomUUID:VF};function WF(e,t,n){var o;e=e||{};const r=e.random??((o=e.rng)==null?void 0:o.call(e))??BF();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,$F(r)}function Br(e,t,n){return fg.randomUUID&&!e?fg.randomUUID():WF(e)}const HF=1*1024*1024,ZF=({children:e})=>{const{configWelcomeMessage:t,persistenceEnabled:n,configCollectFeedback:r,backgroundTasksEnabled:o,backgroundTasksDefaultTimeoutMs:a}=sn(),{activeProject:i,setActiveProject:l,projects:c}=bo(),{ErrorDialog:u,setError:f}=DT(),[h,p]=d.useState(""),[m,x]=d.useState([]),[g,v]=d.useState(!1),[w,b]=d.useState([]),[C,_]=d.useState(null),E=d.useRef(null),[S,j]=d.useState(""),[A,I]=d.useState(!1),P=d.useRef(new Set),F=d.useRef(A);d.useEffect(()=>{F.current=A},[A]);const N=d.useRef(h);d.useEffect(()=>{N.current=h},[h]);const[R,y]=d.useState(null),T=d.useRef(null),D=d.useRef(!1),L=d.useRef(null),O=d.useRef(0),M=d.useRef([]),J=d.useRef([]),{agents:z,agentNameMap:H,error:U,isLoading:X,refetch:W}=XN(),{artifacts:te,isLoading:$,refetch:q,setArtifacts:Y}=vT(h),[re,ue]=d.useState(!0),[ce,pe]=d.useState("files"),[k,oe]=d.useState({}),[ae,G]=d.useState(null),V=d.useCallback((Se,Te)=>{b(Ne=>{if(Ne.find(Oe=>Oe.message===Se))return Ne;const rt=Date.now().toString(),Be={id:rt,message:Se,type:Te||"info"};return setTimeout(()=>{b(Oe=>Oe.filter(at=>at.id!==rt))},4e3),[...Ne,Be]})},[]),{preview:{availableVersions:ne,currentVersion:B,content:K},previewArtifact:Z,openPreview:le,navigateToVersion:de,closePreview:se,setPreviewByArtifact:he}=eT({sessionId:h,projectId:i==null?void 0:i.id,artifacts:te,setError:f}),{uploadArtifactFile:Ee,isDeleteModalOpen:Ae,artifactToDelete:pt,openDeleteModal:Lt,closeDeleteModal:jt,confirmDelete:Rt,isArtifactEditMode:it,setIsArtifactEditMode:Ot,selectedArtifactFilenames:Jt,setSelectedArtifactFilenames:Ft,isBatchDeleteModalOpen:xe,setIsBatchDeleteModalOpen:Re,handleDeleteSelectedArtifacts:Ie,confirmBatchDeleteArtifacts:Pe,downloadAndResolveArtifact:ot}=QN({sessionId:h,artifacts:te,setArtifacts:Y,artifactsRefetch:q,addNotification:V,setError:f,previewArtifact:Z,closePreview:se}),{backgroundTasks:Me,notifications:Pt,registerBackgroundTask:Ke,unregisterBackgroundTask:st,updateTaskTimestamp:yt,isTaskRunningInBackground:en,checkTaskStatus:Rn}=yT({userId:"sam_dev_user",onTaskCompleted:d.useCallback(Se=>{V("Background task completed","success"),typeof window<"u"&&(window.dispatchEvent(new CustomEvent("background-task-completed",{detail:{taskId:Se}})),window.dispatchEvent(new CustomEvent("new-chat-session")))},[V]),onTaskFailed:d.useCallback((Se,Te)=>{f({title:"Background Task Failed",error:Te}),typeof window<"u"&&(window.dispatchEvent(new CustomEvent("background-task-completed",{detail:{taskId:Se}})),window.dispatchEvent(new CustomEvent("new-chat-session")))},[f])});d.useEffect(()=>{M.current=Me},[Me]),d.useEffect(()=>{J.current=m},[m]);const ee=d.useCallback(Se=>{var Ue,rt;let Te="";const Ne=Se.parts||[];for(const Be of Ne)Be.kind==="text"?Te+=Be.text:Be.kind==="artifact"&&(Te+=`«artifact_return:${Be.name}»`);return{id:((Ue=Se.metadata)==null?void 0:Ue.messageId)||`msg-${Br()}`,type:Se.isUser?"user":"agent",text:Te,parts:Se.parts,uploadedFiles:(rt=Se.uploadedFiles)==null?void 0:rt.map(Be=>({name:Be.name,type:Be.type})),isError:Se.isError}},[]),ie=d.useCallback(async(Se,Te)=>{const Ne=Te||h;if(!n||!Ne||P.current.has(Se.task_id))return!1;P.current.add(Se.task_id);try{return await je.webui.post(`/api/v1/sessions/${Ne}/chat-tasks`,{taskId:Se.task_id,userMessage:Se.user_message,messageBubbles:JSON.stringify(Se.message_bubbles),taskMetadata:Se.task_metadata?JSON.stringify(Se.task_metadata):null}),!0}catch(Ue){return console.error(`Failed saving task ${Se.task_id}:`,Ue),!1}finally{setTimeout(()=>{P.current.delete(Se.task_id)},100)}},[h,n]),fe=d.useCallback((Se,Te,Ne,Ue)=>{const rt=/«artifact_return:([^»]+)»/g,Be=/«artifact:([^»]+)»/g,Oe=gt=>({kind:"artifact",status:"completed",name:gt,file:{name:gt,uri:`artifact://${Te}/${gt}`}});let at;for(;(at=rt.exec(Se))!==null;){const gt=at[1];Ne.has(gt)||(Ne.add(gt),Ue.push(Oe(gt)))}for(;(at=Be.exec(Se))!==null;){const gt=at[1];Ne.has(gt)||(Ne.add(gt),Ue.push(Oe(gt)))}},[]),we=d.useCallback((Se,Te)=>Se.messageBubbles.map(Ne=>{const Ue=[],rt=Ne.parts||[{kind:"text",text:Ne.text||""}],Be=new Set;Ne.text&&fe(Ne.text,Te,Be,Ue);for(const Oe of rt)if(Oe.kind==="text"&&Oe.text){let at=Oe.text;fe(at,Te,Be,Ue),at=at.replace(/«artifact_return:[^»]+»/g,""),at=at.replace(/«artifact:[^»]+»/g,""),at=at.replace(/«status_update:[^»]+»\n?/g,""),at.trim()&&Ue.push({kind:"text",text:at})}else if(Oe.kind==="artifact"){const at=Oe.name;at&&!Be.has(at)&&(Be.add(at),Ue.push(Oe))}else Ue.push(Oe);return{taskId:Se.taskId,role:Ne.type==="user"?"user":"agent",parts:Ue,isUser:Ne.type==="user",isComplete:!0,files:Ne.files,uploadedFiles:Ne.uploadedFiles,artifactNotification:Ne.artifactNotification,isError:Ne.isError,metadata:{messageId:Ne.id,sessionId:Te,lastProcessedEventSequence:0}}}),[fe]),ye=d.useCallback(async Se=>{var gt,Ht;const Te=await je.webui.get(`/api/v1/sessions/${Se}/chat-tasks`);if(N.current!==Se){console.log(`Session ${Se} is no longer the active session: ${N.current}`);return}const rt=(Te.tasks||[]).map(Mt=>({...Mt,messageBubbles:JSON.parse(Mt.messageBubbles),taskMetadata:Mt.taskMetadata?JSON.parse(Mt.taskMetadata):null})).map(yk),Be=[];for(const Mt of rt){const yo=we(Mt,Se);Be.push(...yo)}const Oe={};for(const Mt of rt)(gt=Mt.taskMetadata)!=null&&gt.feedback&&(Oe[Mt.taskId]={type:Mt.taskMetadata.feedback.type,text:Mt.taskMetadata.feedback.text||""});let at=null;for(let Mt=rt.length-1;Mt>=0;Mt--)if((Ht=rt[Mt].taskMetadata)!=null&&Ht.agent_name){at=rt[Mt].taskMetadata.agent_name;break}if(x(Be),oe(Oe),at&&j(at),rt.length>0){const Mt=rt[rt.length-1];y(Mt.taskId)}},[we]),[Le,$e]=d.useState(null),[De,Ve]=d.useState(null),[Xe,We]=d.useState(!1),Ce=d.useCallback(Se=>{ue(!1),pe(Se),typeof window<"u"&&window.dispatchEvent(new CustomEvent("expand-side-panel",{detail:{tab:Se}}))},[]),ke=d.useCallback(()=>{T.current&&(clearTimeout(T.current),T.current=null),E.current&&(E.current.close(),E.current=null),D.current=!1},[]),Je=d.useCallback(Se=>{var Ht,Mt,yo;O.current+=1;const Te=O.current;let Ne;try{Ne=JSON.parse(Se.data)}catch(zt){console.error("Failed to parse SSE message:",zt);return}if("result"in Ne&&Ne.result){const zt=Ne.result,dt=zt.kind==="task"?zt.id:zt.kind==="status-update"?zt.taskId:void 0;dt&&en(dt)&&yt(dt,Date.now())}if("error"in Ne&&Ne.error){const dt=`Error: ${Ne.error.message}`;x(ft=>{const ct=ft.filter(vt=>!vt.isStatusBubble);return ct.push({role:"agent",parts:[{kind:"text",text:dt}],isUser:!1,isError:!0,isComplete:!0,metadata:{messageId:`msg-${Br()}`,lastProcessedEventSequence:Te}}),ct}),v(!1),ke(),_(null);return}if(!("result"in Ne)||!Ne.result){console.warn("Received SSE message without a result or error field.",Ne);return}const Ue=Ne.result;let rt=!1,Be,Oe;switch(Ue.kind){case"task":rt=!0,Be=void 0,Oe=Ue.id;break;case"status-update":rt=Ue.final,Be=(Ht=Ue.status)==null?void 0:Ht.message,Oe=Ue.taskId;break;case"artifact-update":q();return;default:console.warn("Received unknown result kind in SSE message:",Ue);return}if(Be!=null&&Be.parts){const zt=Be.parts.filter(dt=>dt.kind==="data");if(zt.length>0)for(const dt of zt){const ft=dt.data;if(ft&&typeof ft=="object"&&"type"in ft)switch(ft.type){case"agent_progress_update":{if(L.current=String((ft==null?void 0:ft.status_text)??"Processing..."),Be.parts.filter(vt=>vt.kind!=="data").length===0)return;break}case"artifact_creation_progress":{const{filename:ct,status:vt,bytes_transferred:kt,mime_type:Yt,description:En,artifact_chunk:$t,version:ha}=ft;let Kt=!1;Y(St=>{const Dt=St.findIndex(rn=>rn.filename===ct);if(Dt>=0){const rn=[...St],qt=rn[Dt],Gn=qt.isDisplayed||!1;return vt==="completed"&&Gn&&(Kt=!0),rn[Dt]={...qt,description:En!==void 0?En:qt.description,size:kt||qt.size,last_modified:new Date().toISOString(),uri:qt.uri||`artifact://${h}/${ct}`,accumulatedContent:vt==="in-progress"&&$t?(qt.accumulatedContent||"")+$t:vt==="completed"&&!Gn?void 0:qt.accumulatedContent,isAccumulatedContentPlainText:vt==="in-progress"&&$t?!0:qt.isAccumulatedContentPlainText,mime_type:vt==="completed"&&Yt?Yt:qt.mime_type,needsEmbedResolution:vt==="completed"?!0:qt.needsEmbedResolution},rn}else if(En!==void 0||vt==="in-progress")return[...St,{filename:ct,description:En||null,mime_type:Yt||"application/octet-stream",size:kt||0,last_modified:new Date().toISOString(),uri:`artifact://${h}/${ct}`,accumulatedContent:vt==="in-progress"&&$t?$t:void 0,isAccumulatedContentPlainText:!!(vt==="in-progress"&&$t),needsEmbedResolution:vt==="completed"}];return St}),Kt&&setTimeout(()=>{ot(ct).catch(St=>{console.error(`Auto-download failed for ${ct}:`,St)})},100),x(St=>{const Dt=[...St];let rn=Dt.findLastIndex(ln=>!ln.isUser&&ln.taskId===Oe);if(rn===-1){const ln={role:"agent",parts:[],taskId:Oe,isUser:!1,isComplete:!1,isStatusBubble:!1,metadata:{lastProcessedEventSequence:Te}};Dt.push(ln),rn=Dt.length-1}const qt={...Dt[rn],parts:[...Dt[rn].parts]};qt.isStatusBubble=!1;const Gn=qt.parts.findIndex(ln=>ln.kind==="artifact"&&ln.name===ct);if(vt==="in-progress")if(Gn>-1){const vs={...qt.parts[Gn],bytesTransferred:kt,status:"in-progress"};qt.parts[Gn]=vs}else{const ln={kind:"artifact",status:"in-progress",name:ct,bytesTransferred:kt};qt.parts.push(ln)}else if(vt==="completed"){const ln={name:ct,mime_type:Yt,uri:ha!==void 0?`artifact://${h}/${ct}?version=${ha}`:`artifact://${h}/${ct}`};if(Gn>-1){const pa={...qt.parts[Gn],status:"completed",file:ln};delete pa.bytesTransferred,qt.parts[Gn]=pa}else qt.parts.push({kind:"artifact",status:"completed",name:ct,file:ln});q()}else{const ln=`Failed to create artifact: ${ct}`;if(Gn>-1){const pa={...qt.parts[Gn],status:"failed",error:ln};delete pa.bytesTransferred,qt.parts[Gn]=pa}else qt.parts.push({kind:"artifact",status:"failed",name:ct,error:ln});qt.isError=!0}return Dt[rn]=qt,Dt.filter(ln=>!ln.isStatusBubble||ln.parts.some(vs=>vs.kind==="artifact"||vs.kind==="file"))});return}case"tool_invocation_start":break;case"authentication_required":{const ct=ft==null?void 0:ft.auth_uri,vt=typeof(ft==null?void 0:ft.target_agent)=="string"?ft.target_agent:"Agent",kt=typeof(ft==null?void 0:ft.gateway_task_id)=="string"?ft.gateway_task_id:void 0;if(typeof ct=="string"&&ct.startsWith("http")){const Yt={role:"agent",parts:[{kind:"text",text:""}],authenticationLink:{url:ct,text:"Click to Authenticate",targetAgent:vt,gatewayTaskId:kt},isUser:!1,isComplete:!0,metadata:{messageId:`auth-${Br()}`}};x(En=>[...En,Yt])}break}default:console.warn("Received unknown data part type:",ft.type)}}}const at=((Mt=Be==null?void 0:Be.parts)==null?void 0:Mt.filter(zt=>zt.kind!=="data"))||[],gt=at.some(zt=>zt.kind==="file");if(x(zt=>{var ct;const dt=[...zt];let ft=dt[dt.length-1];if(ft!=null&&ft.isStatusBubble&&(dt.pop(),ft=dt[dt.length-1]),ft&&!ft.isUser&&ft.taskId===Ue.taskId&&at.length>0){const vt={...ft,parts:[...ft.parts,...at],isComplete:rt||gt,metadata:{...ft.metadata,lastProcessedEventSequence:Te}};dt[dt.length-1]=vt}else if(at.some(kt=>kt.kind==="text"&&kt.text.trim()||kt.kind==="file")){const kt={role:"agent",parts:at,taskId:Ue.taskId,isUser:!1,isComplete:rt||gt,metadata:{messageId:((ct=Ne.id)==null?void 0:ct.toString())||`msg-${Br()}`,sessionId:Ue.contextId,lastProcessedEventSequence:Te}};dt.push(kt)}if(rt){L.current=null;for(let kt=dt.length-1;kt>=0;kt--){const Yt=dt[kt];if(Yt.taskId===Oe&&Yt.parts.some(En=>En.kind==="artifact"&&En.status==="in-progress")){const En=Yt.parts.map($t=>$t.kind==="artifact"&&$t.status==="in-progress"?{...$t,status:"failed",error:`Artifact creation for "${$t.name}" did not complete.`}:$t);dt[kt]={...Yt,parts:En,isError:!0,isComplete:!0}}}const vt=dt.findLastIndex(kt=>!kt.isUser&&kt.taskId===Oe);vt!==-1&&(dt[vt]={...dt[vt],isComplete:!0,metadata:{...dt[vt].metadata,lastProcessedEventSequence:Te}})}return dt}),rt){if(F.current&&(V("Task cancelled.","success"),T.current&&clearTimeout(T.current),I(!1)),Oe)if(en(Oe))st(Oe),typeof window<"u"&&window.dispatchEvent(new CustomEvent("new-chat-session"));else{const dt=J.current.filter(ft=>ft.taskId===Oe&&!ft.isStatusBubble);if(dt.length>0){const ft=dt.map(ee),ct=dt.find($t=>$t.isUser),vt=((yo=ct==null?void 0:ct.parts)==null?void 0:yo.filter($t=>$t.kind==="text").map($t=>$t.text).join(""))||"",Yt=dt.some($t=>$t.isError)?"error":"completed",En=Ue.contextId||h;ie({task_id:Oe,user_message:vt,message_bubbles:ft,task_metadata:{schema_version:ml,status:Yt,agent_name:S}},En).then($t=>{$t&&typeof window<"u"&&window.dispatchEvent(new CustomEvent("new-chat-session"))}).catch($t=>{console.error(`[ChatProvider] Error saving task ${Oe}:`,$t)})}}x(zt=>zt.map(dt=>dt.isUser||!dt.parts.some(ct=>ct.kind==="artifact"&&ct.status==="in-progress")?dt:{...dt,parts:dt.parts.map(ct=>{var vt;if(ct.kind==="artifact"&&ct.status==="in-progress"){const kt=ct,Yt={name:kt.name,mime_type:(vt=kt.file)==null?void 0:vt.mime_type,uri:`artifact://${h}/${kt.name}`};return{kind:"artifact",status:"completed",name:kt.name,file:Yt}}return ct})})),v(!1),ke(),_(null),D.current=!0,q(),setTimeout(()=>{D.current=!1},100)}},[V,ke,q,h,S,ie,ee,ot,Y,en,yt,st]),He=d.useCallback(async(Se=!1)=>{const Te="ChatProvider.handleNewSession:";ke(),g&&C&&S&&!A&&(en(C)||je.webui.post(`/api/v1/tasks/${C}:cancel`,{jsonrpc:"2.0",id:`req-${Br()}`,method:"tasks/cancel",params:{id:C}}).catch(Ue=>console.warn(`${Te} Failed to cancel current task:`,Ue))),T.current&&(clearTimeout(T.current),T.current=null),I(!1),p(""),$e(null),i&&!Se?l(null):i&&Se&&console.log(`${Te} Preserving project context: ${i.name}`),j(""),x([]),v(!1),_(null),y(null),se(),D.current=!1,L.current=null,O.current=0,typeof window<"u"&&window.dispatchEvent(new CustomEvent("focus-chat-input"))},[g,C,S,A,ke,i,l,se,en]),Tt=d.useCallback(Se=>{G(Se),He()},[He]),_e=d.useCallback(()=>{G(null)},[]),Q=d.useCallback(async Se=>{const Te="ChatProvider.handleSwitchSession:";console.log(`${Te} Switching to session ${Se}...`),We(!0);const Ne=Me.filter(Be=>Be.sessionId===h),Ue=Ne.some(Be=>Be.taskId===C),rt=Ne.length>0;if(!Ue&&!rt&&x([]),ke(),g&&C&&S&&!A&&!en(C)){console.log(`${Te} Cancelling current task ${C}`);try{await je.webui.post(`/api/v1/tasks/${C}:cancel`,{jsonrpc:"2.0",id:`req-${Br()}`,method:"tasks/cancel",params:{id:C}})}catch(Oe){console.warn(`${Te} Failed to cancel current task:`,Oe)}}T.current&&(clearTimeout(T.current),T.current=null),I(!1);try{const Be=await je.webui.get(`/api/v1/sessions/${Se}`),Oe=Be==null?void 0:Be.data;if($e((Oe==null?void 0:Oe.name)??"N/A"),Gt.current=!0,Oe!=null&&Oe.projectId)if(console.log(`${Te} Session belongs to project ${Oe.projectId}`),(i==null?void 0:i.id)!==Oe.projectId){const gt=c.find(Ht=>Ht.id===(Oe==null?void 0:Oe.projectId));gt?(console.log(`${Te} Activating project context: ${gt.name}`),l(gt)):console.warn(`${Te} Project ${Oe.projectId} not found in projects array`)}else console.log(`${Te} Already in correct project context`);else i!==null&&(console.log(`${Te} Session has no project, deactivating project context`),l(null));p(Se),v(!1),_(null),y(null),se(),D.current=!1,L.current=null,O.current=0,await ye(Se);const at=Me.filter(gt=>gt.sessionId===Se);if(at.length>0)for(const gt of at){const Ht=await Rn(gt.taskId);if(Ht&&Ht.is_running){console.log(`[ChatProvider] Reconnecting to running background task ${gt.taskId}`),_(gt.taskId),v(!0),gt.agentName&&j(gt.agentName);break}else console.log(`[ChatProvider] Background task ${gt.taskId} is not running, unregistering`),st(gt.taskId)}}catch(Be){f({title:"Switching Chats Failed",error:Ut(Be,"Failed to switch chat sessions.")})}finally{We(!1)}},[ke,g,C,S,A,ye,i,c,l,se,f,Me,Rn,h,st,en]),ve=d.useCallback(async(Se,Te)=>{try{const Ne=await je.webui.patch(`/api/v1/sessions/${Se}`,{name:Te},{fullResponse:!0});if(Ne.status===422)throw new Error("Invalid name");if(!Ne.ok){const Ue=await Ne.json().catch(()=>({}));throw new Error(Ue.message||"Failed to update session name")}$e(Te),typeof window<"u"&&window.dispatchEvent(new CustomEvent("new-chat-session"))}catch(Ne){f({title:"Session Name Update Failed",error:Ut(Ne,"Failed to update session name.")})}},[f]),be=d.useCallback(async Se=>{try{await je.webui.delete(`/api/v1/sessions/${Se}`),V("Session deleted.","success"),Se===h&&He(),typeof window<"u"&&window.dispatchEvent(new CustomEvent("new-chat-session"))}catch(Te){f({title:"Chat Deletion Failed",error:Ut(Te,"Failed to delete session.")})}},[V,He,h,f]),ut=d.useCallback((Se,Te)=>{Y(Ne=>Ne.map(Ue=>Ue.filename===Se?{...Ue,isDisplayed:Te}:Ue))},[]),Fe=d.useCallback(Se=>{Ve(Se)},[]),tt=d.useCallback(()=>{Ve(null)},[]),Ct=d.useCallback(async()=>{De&&(await be(De.id),Ve(null))},[De,be]),lt=d.useCallback(async()=>{if(!(!g&&!A||!C)&&!A){I(!0);try{const Se={jsonrpc:"2.0",id:`req-${Br()}`,method:"tasks/cancel",params:{id:C}},Te=await je.webui.post(`/api/v1/tasks/${C}:cancel`,Se,{fullResponse:!0});if(Te.status===202)T.current&&clearTimeout(T.current),T.current=setTimeout(()=>{V("Cancellation timed out. Allowing new input."),I(!1),v(!1),ke(),_(null),T.current=null,x(Ne=>Ne.filter(Ue=>!Ue.isStatusBubble))},15e3);else{const Ne=await Te.json().catch(()=>({message:"Unknown cancellation error"}));throw new Error(Ne.message||`HTTP error ${Te.status}`)}}catch(Se){f({title:"Task Cancellation Failed",error:Ut(Se,"An unknown error occurred.")}),I(!1)}}},[g,A,C,V,f,ke]),Et=d.useCallback(async(Se,Te,Ne)=>{if(!h){console.error("Cannot submit feedback without a session ID.");return}try{await je.webui.post("/api/v1/feedback",{taskId:Se,sessionId:h,feedbackType:Te,feedbackText:Ne}),oe(Ue=>({...Ue,[Se]:{type:Te,text:Ne}}))}catch(Ue){throw console.error("Failed to submit feedback:",Ue),Ue}},[h]),hn=d.useCallback(()=>{},[]),qe=d.useCallback(()=>{g&&!D.current&&!F.current&&f({title:"Connection Failed",error:"Connection lost. Please try again."}),D.current||(v(!1),F.current||(ke(),_(null)),L.current=null),x(Se=>Se.filter(Te=>!Te.isStatusBubble).map((Te,Ne,Ue)=>Ne===Ue.length-1&&!Te.isUser?{...Te,isComplete:!0}:Te))},[ke,g,f]),Qt=d.useCallback(async Se=>{if(Se.length!==0)for(const{filename:Te,sessionId:Ne}of Se)try{await je.webui.delete(`/api/v1/artifacts/${Ne}/${encodeURIComponent(Te)}`)}catch(Ue){console.error(`[cleanupUploadedFiles] Exception while cleaning up file ${Te}:`,Ue)}},[]),Zn=d.useCallback(async(Se,Te,Ne,Ue)=>{Se.preventDefault();const rt=(Ne==null?void 0:Ne.trim())||"",Be=Te||[];if(!rt&&Be.length===0||g||A||!S)return;ke(),D.current=!1,v(!0),_(null),L.current=null,O.current=0;const Oe={role:"user",parts:[{kind:"text",text:rt}],isUser:!0,uploadedFiles:Be.length>0?Be:void 0,metadata:{messageId:`msg-${Br()}`,sessionId:Ue||h,lastProcessedEventSequence:0}};L.current="Thinking",x(at=>[...at,Oe]);try{const at=[],gt=[];let Ht=Ue||h;console.log(`[handleSubmit] Processing ${Be.length} file(s)`);for(const Kt of Be){if(Kt.type==="application/x-artifact-reference")try{const St=await Kt.text(),Dt=JSON.parse(St);if(Dt.isArtifactReference&&Dt.uri){console.log(`[handleSubmit] Adding artifact reference: ${Dt.filename} (${Dt.uri})`),at.push({kind:"file",file:{uri:Dt.uri,name:Dt.filename,mimeType:Dt.mimeType||"application/octet-stream"}});continue}}catch(St){console.error("[handleSubmit] Error processing artifact reference:",St)}if(Kt.size<HF){const St=await pk(Kt);at.push({kind:"file",file:{bytes:St,name:Kt.name,mimeType:Kt.type}})}else{const St=await Ee(Kt,Ht);if(St&&"uri"in St&&St.uri&&St.sessionId)Ht||(Ht=St.sessionId),gt.push({filename:Kt.name,sessionId:St.sessionId}),at.push({kind:"file",file:{uri:St.uri,name:Kt.name,mimeType:Kt.type}});else{console.error(`[handleSubmit] File upload failed for "${Kt.name}". Result:`,St),await Qt(gt);const Dt=gt.length>0?" Previously uploaded files have been cleaned up.":"",rn=St&&"error"in St?` (${St.error})`:"";f({title:"File Upload Failed",error:`Message not sent. File upload failed for "${Kt.name}"${rn}.${Dt}.`}),v(!1),x(qt=>qt.filter(Gn=>{var Mc,ln;return((Mc=Gn.metadata)==null?void 0:Mc.messageId)!==((ln=Oe.metadata)==null?void 0:ln.messageId)}));return}}}const Mt=[];if(rt&&Mt.push({kind:"text",text:rt}),Mt.push(...at),Mt.length===0)return;console.log(`ChatProvider handleSubmit: Using effectiveSessionId for contextId: ${Ht}`);const yo=o??!1;console.log(`[ChatProvider] Building metadata for ${S}, enableBackground=${yo}`);const zt={agent_name:S};i!=null&&i.id&&(zt.project_id=i.id),yo&&(zt.background_execution=!0,zt.max_execution_time_ms=a??36e5,console.log(`[ChatProvider] Enabling background execution for ${S}`),console.log("[ChatProvider] Metadata object:",zt));const dt={role:"user",parts:Mt,messageId:`msg-${Br()}`,kind:"message",contextId:Ht,metadata:zt};console.log("[ChatProvider] A2A message metadata:",dt.metadata);const ft={jsonrpc:"2.0",id:`req-${Br()}`,method:"message/stream",params:{message:dt}};console.log("ChatProvider handleSubmit: Sending POST to /message:stream");const ct=await je.webui.post("/api/v1/message:stream",ft),vt=ct==null?void 0:ct.result,kt=vt==null?void 0:vt.id,Yt=vt==null?void 0:vt.contextId;if(console.log(`ChatProvider handleSubmit: Extracted responseSessionId: ${Yt}, current sessionId: ${h}`),console.log("ChatProvider handleSubmit: Full result object:",ct),!kt)throw console.error("ChatProvider handleSubmit: Backend did not return a valid taskId. Result:",ct),new Error("Backend did not return a valid taskId.");console.log(`ChatProvider handleSubmit: Checking session update condition - responseSessionId: ${Yt}, sessionId: ${h}, different: ${Yt!==h}`);const En=!h||h==="",$t=Yt||h;if(Yt&&Yt!==h){if(console.log(`ChatProvider handleSubmit: Updating sessionId from ${h} to ${Yt}`),p(Yt),x(Kt=>Kt.map(St=>{var Dt,rn;return((Dt=St.metadata)==null?void 0:Dt.messageId)===((rn=Oe.metadata)==null?void 0:rn.messageId)?{...St,metadata:{...St.metadata,sessionId:Yt}}:St})),En){let Kt="New Chat";const Dt=Oe.parts.filter(rn=>rn.kind==="text").map(rn=>rn.text).join(" ").trim();Dt?Kt=Dt.length>100?`${Dt.substring(0,100)}...`:Dt:Be.length>0&&(Be.length===1?Kt=Be[0].name:Kt=`${Be[0].name} +${Be.length-1} more`),Kt&&($e(Kt),await ve(Yt,Kt))}En&&typeof window<"u"&&window.dispatchEvent(new CustomEvent("new-chat-session"))}const ha=o??!1;$t&&await ie({task_id:kt,user_message:rt,message_bubbles:[ee(Oe)],task_metadata:{schema_version:ml,status:"pending",agent_name:S,is_background_task:ha}},$t),console.log(`ChatProvider handleSubmit: Received taskId ${kt}. Setting currentTaskId and taskIdInSidePanel.`),_(kt),y(kt),ha&&(console.log(`[ChatProvider] Registering ${kt} as background task`),Ke(kt,$t,S),typeof window<"u"&&window.dispatchEvent(new CustomEvent("new-chat-session"))),x(Kt=>Kt.map(St=>{var Dt,rn;return((Dt=St.metadata)==null?void 0:Dt.messageId)===((rn=Oe.metadata)==null?void 0:rn.messageId)?{...St,taskId:kt}:St}))}catch(at){f({title:"Message Failed",error:Ut(at,"An error occurred. Please try again.")}),v(!1),x(gt=>gt.filter(Ht=>!Ht.isStatusBubble)),_(null),D.current=!1,L.current=null}},[h,g,A,S,ke,Ee,ve,ie,ee,i,Qt,f,a,o,Ke]),dr=d.useRef(""),Gt=d.useRef(!1),Wt=d.useRef(!1);d.useEffect(()=>{gT(Te=>{(i==null?void 0:i.id)===Te&&(console.log(`Project ${Te} was deleted, clearing session context`),He(!1))})},[i,He]),d.useEffect(()=>{const Se=async Te=>{const Ne=Te,{sessionId:Ue,projectId:rt}=Ne.detail;if(Ue===h)if(Wt.current=!0,rt){const Be=c.find(Oe=>Oe.id===rt);Be&&l(Be)}else l(null)};return window.addEventListener("session-moved",Se),()=>{window.removeEventListener("session-moved",Se)}},[h,c,l]),d.useEffect(()=>{const Se=async Te=>{const Ne=Te,{taskId:Ue}=Ne.detail,rt=M.current.find(Be=>Be.taskId===Ue);rt&&(console.log(`[ChatProvider] Background task ${Ue} completed, will reload session ${rt.sessionId} after delay`),setTimeout(async()=>{N.current===rt.sessionId&&(console.log(`[ChatProvider] Reloading current session ${rt.sessionId} to get latest data`),await ye(rt.sessionId))},1500))};return window.addEventListener("background-task-completed",Se),()=>{window.removeEventListener("background-task-completed",Se)}},[ye]),d.useEffect(()=>{const Se=dr.current,Te=i==null?void 0:i.id;Te!==void 0&&Se!==Te&&!Gt.current&&!Wt.current&&(console.log("Active project changed explicitly, resetting chat view and preserving project context."),He(!0)),dr.current=Te,Gt.current=!1,Wt.current=!1},[i,He]),d.useEffect(()=>{if(!S&&z.length>0&&m.length===0&&!Xe){let Se=z[0];const Ne=new URLSearchParams(window.location.search).get("agent");let Ue;if(Ne&&(Ue=z.find(Be=>Be.name===Ne),Ue?(Se=Ue,console.log(`Using URL parameter agent: ${Se.name}`)):console.warn(`URL parameter agent "${Ne}" not found in available agents, falling back to priority order`)),!Ue)if(i!=null&&i.defaultAgentId){const Be=z.find(Oe=>Oe.name===i.defaultAgentId);Be?(Se=Be,console.log(`Using project default agent: ${Se.name}`)):(console.warn(`Project default agent "${i.defaultAgentId}" not found, falling back to OrchestratorAgent`),Se=z.find(Oe=>Oe.name==="OrchestratorAgent")??z[0])}else Se=z.find(Be=>Be.name==="OrchestratorAgent")??z[0];j(Se.name);const rt=t||`Hi! I'm the ${Se==null?void 0:Se.displayName}. How can I help?`;x([{parts:[{kind:"text",text:rt}],isUser:!1,isComplete:!0,role:"agent",metadata:{sessionId:"",lastProcessedEventSequence:0}}])}},[z,t,m.length,S,h,Xe,i]);const fr=d.useRef(Je),no=d.useRef(hn),hr=d.useRef(qe);d.useEffect(()=>{fr.current=Je,no.current=hn,hr.current=qe},[Je,hn,qe]),d.useEffect(()=>{if(C){const Se=Wd(),Ne=M.current.find(Mt=>Mt.taskId===C)!==void 0,Ue=new URLSearchParams;Se&&Ue.append("token",Se),Ne&&(Ue.append("reconnect","true"),Ue.append("last_event_timestamp","0"),console.log(`[ChatProvider] Reconnecting to background task ${C} - requesting full event replay`),x(Mt=>Mt.filter(zt=>!!(zt.isUser||zt.taskId!==C))));const rt=je.webui.getFullUrl(`/api/v1/sse/subscribe/${C}`),Be=Ue.toString()?`${rt}?${Ue.toString()}`:rt,Oe=new EventSource(Be,{withCredentials:!0});E.current=Oe;const at=()=>{no.current()},gt=()=>{hr.current()},Ht=Mt=>{fr.current(Mt)};return Oe.onopen=at,Oe.onerror=gt,Oe.addEventListener("status_update",Ht),Oe.addEventListener("artifact_update",Ht),Oe.addEventListener("final_response",Ht),Oe.addEventListener("error",Ht),()=>{Oe.removeEventListener("status_update",Ht),Oe.removeEventListener("artifact_update",Ht),Oe.removeEventListener("final_response",Ht),Oe.removeEventListener("error",Ht),Oe.close()}}else ke()},[C,ke]);const ph={configCollectFeedback:r,submittedFeedback:k,handleFeedbackSubmit:Et,sessionId:h,setSessionId:p,sessionName:Le,setSessionName:$e,messages:m,setMessages:x,isResponding:g,currentTaskId:C,isCancelling:A,latestStatusText:L,isLoadingSession:Xe,agents:z,agentsLoading:X,agentsError:U,agentsRefetch:W,agentNameDisplayNameMap:H,handleNewSession:He,handleSwitchSession:Q,handleSubmit:Zn,handleCancel:lt,notifications:w,addNotification:V,selectedAgentName:S,setSelectedAgentName:j,artifacts:te,artifactsLoading:$,artifactsRefetch:q,setArtifacts:Y,uploadArtifactFile:Ee,isSidePanelCollapsed:re,activeSidePanelTab:ce,setIsSidePanelCollapsed:ue,setActiveSidePanelTab:pe,openSidePanelTab:Ce,taskIdInSidePanel:R,setTaskIdInSidePanel:y,isDeleteModalOpen:Ae,artifactToDelete:pt,openDeleteModal:Lt,closeDeleteModal:jt,confirmDelete:Rt,openSessionDeleteModal:Fe,closeSessionDeleteModal:tt,confirmSessionDelete:Ct,sessionToDelete:De,isArtifactEditMode:it,setIsArtifactEditMode:Ot,selectedArtifactFilenames:Jt,setSelectedArtifactFilenames:Ft,handleDeleteSelectedArtifacts:Ie,confirmBatchDeleteArtifacts:Pe,isBatchDeleteModalOpen:xe,setIsBatchDeleteModalOpen:Re,previewedArtifactAvailableVersions:ne,currentPreviewedVersionNumber:B,previewFileContent:K,openArtifactForPreview:le,navigateArtifactVersion:de,previewArtifact:Z,setPreviewArtifact:he,updateSessionName:ve,deleteSession:be,markArtifactAsDisplayed:ut,downloadAndResolveArtifact:ot,displayError:f,pendingPrompt:ae,startNewChatWithPrompt:Tt,clearPendingPrompt:_e,backgroundTasks:Me,backgroundNotifications:Pt,isTaskRunningInBackground:en};return s.jsxs(yw.Provider,{value:ph,children:[e,s.jsx(u,{})]})},GF=({children:e})=>{const{configUseAuthorization:t,configAuthLoginUrl:n}=sn(),{fetchCsrfToken:r,clearCsrfToken:o}=jw(),[a,i]=d.useState(!1),[l,c]=d.useState(!0),[u,f]=d.useState(null);d.useEffect(()=>{let m=!0;const x=async()=>{if(!t){m&&(i(!0),c(!1));return}try{const v=await je.webui.get("/api/v1/users/me");console.log("User is authenticated:",v),m&&(f(v),i(!0)),console.log("Fetching CSRF token for authenticated requests..."),await r()}catch(v){console.error("Error checking authentication:",v),m&&i(!1)}finally{m&&c(!1)}};x();const g=v=>{v.key==="access_token"&&x()};return window.addEventListener("storage",g),()=>{m=!1,window.removeEventListener("storage",g)}},[t,n,r]);const h=()=>{window.location.href=n},p=async()=>{try{t&&await je.webui.post("/api/v1/auth/logout")}catch(m){console.error("Error calling logout endpoint:",m)}finally{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(ww.Provider,{value:{isAuthenticated:a,useAuthorization:t,login:h,logout:p,userInfo:u},children:e})};function YF(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 KF=e=>new Promise(t=>setTimeout(t,e)),qF=async(e=5,t=50)=>{try{const n=await je.webui.get("/api/v1/csrf-token",{credentials:"include",fullResponse:!0});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=YF("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 KF(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 XF({children:e}){const[t,n]=d.useState(null),r=d.useCallback(async()=>{if(t)return t;const i=await qF();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(Sw.Provider,{value:a,children:e})}const JF={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"}},QF={light:{background:"background.w10","card-background":"background.w20",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","card-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"}},e9={"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 hg(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 t9(e,t){const n={},r=QF[t];for(const[o,a]of Object.entries(r)){const i=hg(e,a);n[`--${o}`]=i}for(const[o,a]of Object.entries(e9)){const i=hg(e,a);n[`--color-${o}`]=i}return n}const Fl="sam-theme";function n9(e){var n,r,o,a,i,l,c,u,f,h,p,m,x,g,v,w,b,C,_,E,S,j,A,I,P,F,N,R,y,T,D,L,O,M,J,z,H,U,X,W,te,$,q,Y,re,ue,ce,pe,k,oe,ae,G,V,ne,B,K,Z,le,de,se,he,Ee,Ae,pt,Lt,jt,Rt,it,Ot,Jt,Ft,xe,Re,Ie,Pe,ot,Me,Pt,Ke,st,yt,en,Rn,ee,ie,fe,we,ye,Le,$e,De,Ve,Xe,We,Ce,ke,Je,He,Tt,_e,Q,ve,be;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),(p=e.error)!=null&&p.w20&&(t["--color-error-w20"]=e.error.w20),(m=e.error)!=null&&m.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),(v=e.warning)!=null&&v.w70&&(t["--color-warning-w70"]=e.warning.w70),(w=e.warning)!=null&&w.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),(_=e.success)!=null&&_.wMain&&(t["--color-success-wMain"]=e.success.wMain),(E=e.success)!=null&&E.w100&&(t["--color-success-w100"]=e.success.w100),(S=e.success)!=null&&S.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),(I=e.success)!=null&&I.w10&&(t["--color-success-w10"]=e.success.w10),(P=e.stateLayer)!=null&&P.w10&&(t["--color-stateLayer-w10"]=e.stateLayer.w10),(F=e.stateLayer)!=null&&F.w20&&(t["--color-stateLayer-w20"]=e.stateLayer.w20),(R=(N=e.accent)==null?void 0:N.n0)!=null&&R.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),(L=(D=e.accent)==null?void 0:D.n0)!=null&&L.w30&&(t["--color-accent-n0-w30"]=e.accent.n0.w30),(M=(O=e.accent)==null?void 0:O.n0)!=null&&M.w10&&(t["--color-accent-n0-w10"]=e.accent.n0.w10),(z=(J=e.accent)==null?void 0:J.n1)!=null&&z.wMain&&(t["--color-accent-n1-wMain"]=e.accent.n1.wMain),(U=(H=e.accent)==null?void 0:H.n1)!=null&&U.w100&&(t["--color-accent-n1-w100"]=e.accent.n1.w100),(W=(X=e.accent)==null?void 0:X.n1)!=null&&W.w60&&(t["--color-accent-n1-w60"]=e.accent.n1.w60),($=(te=e.accent)==null?void 0:te.n1)!=null&&$.w30&&(t["--color-accent-n1-w30"]=e.accent.n1.w30),(Y=(q=e.accent)==null?void 0:q.n1)!=null&&Y.w20&&(t["--color-accent-n1-w20"]=e.accent.n1.w20),(ue=(re=e.accent)==null?void 0:re.n1)!=null&&ue.w10&&(t["--color-accent-n1-w10"]=e.accent.n1.w10),(pe=(ce=e.accent)==null?void 0:ce.n2)!=null&&pe.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),(G=(ae=e.accent)==null?void 0:ae.n2)!=null&&G.w30&&(t["--color-accent-n2-w30"]=e.accent.n2.w30),(ne=(V=e.accent)==null?void 0:V.n2)!=null&&ne.w20&&(t["--color-accent-n2-w20"]=e.accent.n2.w20),(K=(B=e.accent)==null?void 0:B.n2)!=null&&K.w10&&(t["--color-accent-n2-w10"]=e.accent.n2.w10),(le=(Z=e.accent)==null?void 0:Z.n3)!=null&&le.wMain&&(t["--color-accent-n3-wMain"]=e.accent.n3.wMain),(se=(de=e.accent)==null?void 0:de.n3)!=null&&se.w100&&(t["--color-accent-n3-w100"]=e.accent.n3.w100),(Ee=(he=e.accent)==null?void 0:he.n3)!=null&&Ee.w30&&(t["--color-accent-n3-w30"]=e.accent.n3.w30),(pt=(Ae=e.accent)==null?void 0:Ae.n3)!=null&&pt.w10&&(t["--color-accent-n3-w10"]=e.accent.n3.w10),(jt=(Lt=e.accent)==null?void 0:Lt.n4)!=null&&jt.wMain&&(t["--color-accent-n4-wMain"]=e.accent.n4.wMain),(it=(Rt=e.accent)==null?void 0:Rt.n4)!=null&&it.w100&&(t["--color-accent-n4-w100"]=e.accent.n4.w100),(Jt=(Ot=e.accent)==null?void 0:Ot.n4)!=null&&Jt.w30&&(t["--color-accent-n4-w30"]=e.accent.n4.w30),(xe=(Ft=e.accent)==null?void 0:Ft.n5)!=null&&xe.wMain&&(t["--color-accent-n5-wMain"]=e.accent.n5.wMain),(Ie=(Re=e.accent)==null?void 0:Re.n5)!=null&&Ie.w100&&(t["--color-accent-n5-w100"]=e.accent.n5.w100),(ot=(Pe=e.accent)==null?void 0:Pe.n5)!=null&&ot.w60&&(t["--color-accent-n5-w60"]=e.accent.n5.w60),(Pt=(Me=e.accent)==null?void 0:Me.n5)!=null&&Pt.w30&&(t["--color-accent-n5-w30"]=e.accent.n5.w30),(st=(Ke=e.accent)==null?void 0:Ke.n6)!=null&&st.wMain&&(t["--color-accent-n6-wMain"]=e.accent.n6.wMain),(en=(yt=e.accent)==null?void 0:yt.n6)!=null&&en.w100&&(t["--color-accent-n6-w100"]=e.accent.n6.w100),(ee=(Rn=e.accent)==null?void 0:Rn.n6)!=null&&ee.w30&&(t["--color-accent-n6-w30"]=e.accent.n6.w30),(fe=(ie=e.accent)==null?void 0:ie.n7)!=null&&fe.wMain&&(t["--color-accent-n7-wMain"]=e.accent.n7.wMain),(ye=(we=e.accent)==null?void 0:we.n7)!=null&&ye.w100&&(t["--color-accent-n7-w100"]=e.accent.n7.w100),($e=(Le=e.accent)==null?void 0:Le.n7)!=null&&$e.w30&&(t["--color-accent-n7-w30"]=e.accent.n7.w30),(Ve=(De=e.accent)==null?void 0:De.n8)!=null&&Ve.wMain&&(t["--color-accent-n8-wMain"]=e.accent.n8.wMain),(We=(Xe=e.accent)==null?void 0:Xe.n8)!=null&&We.w100&&(t["--color-accent-n8-w100"]=e.accent.n8.w100),(ke=(Ce=e.accent)==null?void 0:Ce.n8)!=null&&ke.w30&&(t["--color-accent-n8-w30"]=e.accent.n8.w30),(He=(Je=e.accent)==null?void 0:Je.n9)!=null&&He.wMain&&(t["--color-accent-n9-wMain"]=e.accent.n9.wMain),(Tt=e.learning)!=null&&Tt.wMain&&(t["--color-learning-wMain"]=e.learning.wMain),(_e=e.learning)!=null&&_e.w100&&(t["--color-learning-w100"]=e.learning.w100),(Q=e.learning)!=null&&Q.w90&&(t["--color-learning-w90"]=e.learning.w90),(ve=e.learning)!=null&&ve.w20&&(t["--color-learning-w20"]=e.learning.w20),(be=e.learning)!=null&&be.w10&&(t["--color-learning-w10"]=e.learning.w10),t}function r9(e,t="light"){const n={};if(e){const o=n9(e);Object.assign(n,o)}const r=t9(e,t);return Object.assign(n,r),n}function o9(){const e=localStorage.getItem(Fl);return e==="dark"||e==="light"?e:window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function s9(e,t){const n=r9(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(Fl,t)})}const a9=({children:e})=>{const t=d.useMemo(()=>JF,[]),[n,r]=d.useState(()=>o9()),o=d.useMemo(()=>({currentTheme:n,toggleTheme:()=>{const a=n==="light"?"dark":"light";r(a),localStorage.setItem(Fl,a)}}),[n]);return d.useEffect(()=>{if(!(localStorage.getItem(Fl)!==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"),s9(t,n)},[n,t]),s.jsx(kw.Provider,{value:o,children:e})};function i9(){const e=zr(),t=zo(),{isAuthenticated:n,login:r,useAuthorization:o}=bw(),{configFeatureEnablement:a}=sn(),{isMenuOpen:i,menuPosition:l,selectedText:c,clearSelection:u}=ax();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=jD(a);CT();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(me,{onClick:r,children:"Login"})});const p=x=>{const g=f.find(v=>v.id===x)||Lm.find(v=>v.id===x);g!=null&&g.onClick&&x!=="settings"?g.onClick():x!=="settings"&&t(`/${x==="agentMesh"?"agents":x}`)},m=()=>{t("/chat")};return s.jsxs("div",{className:"relative flex h-screen",children:[s.jsx(bD,{items:f,bottomItems:Lm,activeItem:h(),onItemChange:p,onHeaderClick:m}),s.jsx("main",{className:"h-full w-full flex-1 overflow-auto",children:s.jsx(LS,{})}),s.jsx(_P,{}),s.jsx(jP,{isOpen:i,position:l,selectedText:c||"",onClose:u})]})}function l9(){return s.jsx(ZF,{children:s.jsx(i9,{})})}const c9=()=>i_([{path:"/",element:s.jsx(l9,{}),children:[{index:!0,element:s.jsx(Hh,{to:"/chat",replace:!0})},{path:"chat",element:s.jsx(AD,{})},{path:"projects",children:[{index:!0,element:s.jsx(dg,{})},{path:":id",element:s.jsx(dg,{}),loader:({params:e})=>({projectId:e.id})}]},{path:"prompts",children:[{index:!0,element:s.jsx(Gi,{})},{path:"new",element:s.jsx(Gi,{}),loader:({request:e})=>({view:"builder",mode:new URL(e.url).searchParams.get("mode")||"manual"})},{path:":id/edit",element:s.jsx(Gi,{}),loader:({params:e})=>({promptId:e.id,view:"builder",mode:"edit"})},{path:":id/versions",element:s.jsx(Gi,{}),loader:({params:e})=>({promptId:e.id,view:"versions"})}]},{path:"agents",element:s.jsx(ED,{})},{path:"*",element:s.jsx(Hh,{to:"/chat",replace:!0})}]}]);function u9(){return s.jsx(w_,{router:c9()})}function d9(){return s.jsx(a9,{children:s.jsx(XF,{children:s.jsx(FF,{children:s.jsx(GF,{children:s.jsx(xT,{children:s.jsx(bT,{children:s.jsx(zF,{children:s.jsx(b_,{children:s.jsx(u9,{})})})})})})})})})}j1.createRoot(document.getElementById("root")).render(s.jsx(d.StrictMode,{children:s.jsx(d9,{})}));