daemora 1.0.0-alpha.0

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 (1238) hide show
  1. package/LICENSE +661 -0
  2. package/README.md +645 -0
  3. package/crew/_template/plugin.json +18 -0
  4. package/crew/analyst/plugin.json +29 -0
  5. package/crew/architect/plugin.json +29 -0
  6. package/crew/assistant/plugin.json +29 -0
  7. package/crew/backend/plugin.json +31 -0
  8. package/crew/devops/plugin.json +30 -0
  9. package/crew/facebook/plugin.json +36 -0
  10. package/crew/frontend/plugin.json +30 -0
  11. package/crew/github/plugin.json +18 -0
  12. package/crew/gmail/plugin.json +34 -0
  13. package/crew/google-calendar/plugin.json +26 -0
  14. package/crew/google-services/plugin.json +25 -0
  15. package/crew/imessage/plugin.json +24 -0
  16. package/crew/instagram/plugin.json +34 -0
  17. package/crew/linkedin/plugin.json +24 -0
  18. package/crew/meeting-attendant/plugin.json +27 -0
  19. package/crew/notifications/plugin.json +23 -0
  20. package/crew/notion/plugin.json +18 -0
  21. package/crew/planner/plugin.json +25 -0
  22. package/crew/reddit/plugin.json +32 -0
  23. package/crew/researcher/plugin.json +29 -0
  24. package/crew/reviewer/plugin.json +29 -0
  25. package/crew/security/plugin.json +30 -0
  26. package/crew/smart-home/plugin.json +23 -0
  27. package/crew/ssh-remote/plugin.json +28 -0
  28. package/crew/tiktok/plugin.json +26 -0
  29. package/crew/twitter/plugin.json +46 -0
  30. package/crew/video-editor/plugin.json +19 -0
  31. package/crew/video-editor/rules/3d.md +86 -0
  32. package/crew/video-editor/rules/animations.md +31 -0
  33. package/crew/video-editor/rules/assets/charts-bar-chart.tsx +173 -0
  34. package/crew/video-editor/rules/assets/text-animations-typewriter.tsx +100 -0
  35. package/crew/video-editor/rules/assets/text-animations-word-highlight.tsx +103 -0
  36. package/crew/video-editor/rules/assets.md +78 -0
  37. package/crew/video-editor/rules/audio-visualization.md +198 -0
  38. package/crew/video-editor/rules/audio.md +169 -0
  39. package/crew/video-editor/rules/calculate-metadata.md +134 -0
  40. package/crew/video-editor/rules/can-decode.md +81 -0
  41. package/crew/video-editor/rules/charts.md +120 -0
  42. package/crew/video-editor/rules/compositions.md +154 -0
  43. package/crew/video-editor/rules/cursor-and-clicks.md +108 -0
  44. package/crew/video-editor/rules/display-captions.md +184 -0
  45. package/crew/video-editor/rules/extract-frames.md +229 -0
  46. package/crew/video-editor/rules/ffmpeg.md +34 -0
  47. package/crew/video-editor/rules/focus-zoom.md +108 -0
  48. package/crew/video-editor/rules/fonts.md +152 -0
  49. package/crew/video-editor/rules/get-audio-duration.md +58 -0
  50. package/crew/video-editor/rules/get-video-dimensions.md +68 -0
  51. package/crew/video-editor/rules/get-video-duration.md +60 -0
  52. package/crew/video-editor/rules/gifs.md +141 -0
  53. package/crew/video-editor/rules/images.md +134 -0
  54. package/crew/video-editor/rules/import-srt-captions.md +69 -0
  55. package/crew/video-editor/rules/light-leaks.md +73 -0
  56. package/crew/video-editor/rules/lottie.md +70 -0
  57. package/crew/video-editor/rules/maps.md +412 -0
  58. package/crew/video-editor/rules/measuring-dom-nodes.md +34 -0
  59. package/crew/video-editor/rules/measuring-text.md +140 -0
  60. package/crew/video-editor/rules/parameters.md +109 -0
  61. package/crew/video-editor/rules/sequencing.md +118 -0
  62. package/crew/video-editor/rules/sfx.md +30 -0
  63. package/crew/video-editor/rules/silence-detection.md +71 -0
  64. package/crew/video-editor/rules/subtitles.md +36 -0
  65. package/crew/video-editor/rules/tailwind.md +11 -0
  66. package/crew/video-editor/rules/text-animations.md +20 -0
  67. package/crew/video-editor/rules/theme-switching.md +103 -0
  68. package/crew/video-editor/rules/timing.md +136 -0
  69. package/crew/video-editor/rules/transcribe-captions.md +70 -0
  70. package/crew/video-editor/rules/transitions.md +197 -0
  71. package/crew/video-editor/rules/transparent-videos.md +106 -0
  72. package/crew/video-editor/rules/trimming.md +51 -0
  73. package/crew/video-editor/rules/ui-chrome.md +139 -0
  74. package/crew/video-editor/rules/videos.md +171 -0
  75. package/crew/video-editor/rules/voiceover.md +99 -0
  76. package/crew/video-editor/template/README.md +42 -0
  77. package/crew/video-editor/template/package.json +24 -0
  78. package/crew/video-editor/template/public/.gitkeep +0 -0
  79. package/crew/video-editor/template/public/image.png +0 -0
  80. package/crew/video-editor/template/public/logo.png +0 -0
  81. package/crew/video-editor/template/remotion.config.ts +5 -0
  82. package/crew/video-editor/template/src/Root.tsx +21 -0
  83. package/crew/video-editor/template/src/Video.tsx +38 -0
  84. package/crew/video-editor/template/src/components/LogoStinger.tsx +77 -0
  85. package/crew/video-editor/template/src/index.ts +4 -0
  86. package/crew/video-editor/template/tsconfig.json +16 -0
  87. package/crew/youtube/plugin.json +42 -0
  88. package/dist/auth/AuthProvider.d.ts +35 -0
  89. package/dist/auth/AuthProvider.d.ts.map +1 -0
  90. package/dist/auth/AuthProvider.js +13 -0
  91. package/dist/auth/AuthProvider.js.map +1 -0
  92. package/dist/auth/AuthStore.d.ts +79 -0
  93. package/dist/auth/AuthStore.d.ts.map +1 -0
  94. package/dist/auth/AuthStore.js +139 -0
  95. package/dist/auth/AuthStore.js.map +1 -0
  96. package/dist/auth/LocalAuthProvider.d.ts +28 -0
  97. package/dist/auth/LocalAuthProvider.d.ts.map +1 -0
  98. package/dist/auth/LocalAuthProvider.js +70 -0
  99. package/dist/auth/LocalAuthProvider.js.map +1 -0
  100. package/dist/auth/TokenService.d.ts +83 -0
  101. package/dist/auth/TokenService.d.ts.map +1 -0
  102. package/dist/auth/TokenService.js +129 -0
  103. package/dist/auth/TokenService.js.map +1 -0
  104. package/dist/auth/fileToken.d.ts +33 -0
  105. package/dist/auth/fileToken.d.ts.map +1 -0
  106. package/dist/auth/fileToken.js +69 -0
  107. package/dist/auth/fileToken.js.map +1 -0
  108. package/dist/auth/index.d.ts +47 -0
  109. package/dist/auth/index.d.ts.map +1 -0
  110. package/dist/auth/index.js +76 -0
  111. package/dist/auth/index.js.map +1 -0
  112. package/dist/auth/jwt.d.ts +27 -0
  113. package/dist/auth/jwt.d.ts.map +1 -0
  114. package/dist/auth/jwt.js +67 -0
  115. package/dist/auth/jwt.js.map +1 -0
  116. package/dist/channels/BaseChannel.d.ts +139 -0
  117. package/dist/channels/BaseChannel.d.ts.map +1 -0
  118. package/dist/channels/BaseChannel.js +103 -0
  119. package/dist/channels/BaseChannel.js.map +1 -0
  120. package/dist/channels/BlueBubblesChannel.d.ts +37 -0
  121. package/dist/channels/BlueBubblesChannel.d.ts.map +1 -0
  122. package/dist/channels/BlueBubblesChannel.js +115 -0
  123. package/dist/channels/BlueBubblesChannel.js.map +1 -0
  124. package/dist/channels/ChannelManager.d.ts +85 -0
  125. package/dist/channels/ChannelManager.d.ts.map +1 -0
  126. package/dist/channels/ChannelManager.js +557 -0
  127. package/dist/channels/ChannelManager.js.map +1 -0
  128. package/dist/channels/ChannelRegistry.d.ts +57 -0
  129. package/dist/channels/ChannelRegistry.d.ts.map +1 -0
  130. package/dist/channels/ChannelRegistry.js +93 -0
  131. package/dist/channels/ChannelRegistry.js.map +1 -0
  132. package/dist/channels/DiscordChannel.d.ts +87 -0
  133. package/dist/channels/DiscordChannel.d.ts.map +1 -0
  134. package/dist/channels/DiscordChannel.js +469 -0
  135. package/dist/channels/DiscordChannel.js.map +1 -0
  136. package/dist/channels/EmailChannel.d.ts +64 -0
  137. package/dist/channels/EmailChannel.d.ts.map +1 -0
  138. package/dist/channels/EmailChannel.js +226 -0
  139. package/dist/channels/EmailChannel.js.map +1 -0
  140. package/dist/channels/FeishuChannel.d.ts +40 -0
  141. package/dist/channels/FeishuChannel.d.ts.map +1 -0
  142. package/dist/channels/FeishuChannel.js +169 -0
  143. package/dist/channels/FeishuChannel.js.map +1 -0
  144. package/dist/channels/GoogleChatChannel.d.ts +46 -0
  145. package/dist/channels/GoogleChatChannel.d.ts.map +1 -0
  146. package/dist/channels/GoogleChatChannel.js +184 -0
  147. package/dist/channels/GoogleChatChannel.js.map +1 -0
  148. package/dist/channels/IRCChannel.d.ts +50 -0
  149. package/dist/channels/IRCChannel.d.ts.map +1 -0
  150. package/dist/channels/IRCChannel.js +149 -0
  151. package/dist/channels/IRCChannel.js.map +1 -0
  152. package/dist/channels/LineChannel.d.ts +35 -0
  153. package/dist/channels/LineChannel.d.ts.map +1 -0
  154. package/dist/channels/LineChannel.js +118 -0
  155. package/dist/channels/LineChannel.js.map +1 -0
  156. package/dist/channels/MatrixChannel.d.ts +45 -0
  157. package/dist/channels/MatrixChannel.d.ts.map +1 -0
  158. package/dist/channels/MatrixChannel.js +156 -0
  159. package/dist/channels/MatrixChannel.js.map +1 -0
  160. package/dist/channels/MattermostChannel.d.ts +42 -0
  161. package/dist/channels/MattermostChannel.d.ts.map +1 -0
  162. package/dist/channels/MattermostChannel.js +144 -0
  163. package/dist/channels/MattermostChannel.js.map +1 -0
  164. package/dist/channels/NextcloudChannel.d.ts +46 -0
  165. package/dist/channels/NextcloudChannel.d.ts.map +1 -0
  166. package/dist/channels/NextcloudChannel.js +146 -0
  167. package/dist/channels/NextcloudChannel.js.map +1 -0
  168. package/dist/channels/SignalChannel.d.ts +39 -0
  169. package/dist/channels/SignalChannel.d.ts.map +1 -0
  170. package/dist/channels/SignalChannel.js +160 -0
  171. package/dist/channels/SignalChannel.js.map +1 -0
  172. package/dist/channels/SlackChannel.d.ts +81 -0
  173. package/dist/channels/SlackChannel.d.ts.map +1 -0
  174. package/dist/channels/SlackChannel.js +363 -0
  175. package/dist/channels/SlackChannel.js.map +1 -0
  176. package/dist/channels/StreamingEditor.d.ts +37 -0
  177. package/dist/channels/StreamingEditor.d.ts.map +1 -0
  178. package/dist/channels/StreamingEditor.js +108 -0
  179. package/dist/channels/StreamingEditor.js.map +1 -0
  180. package/dist/channels/TelegramChannel.d.ts +84 -0
  181. package/dist/channels/TelegramChannel.d.ts.map +1 -0
  182. package/dist/channels/TelegramChannel.js +469 -0
  183. package/dist/channels/TelegramChannel.js.map +1 -0
  184. package/dist/channels/TwitchChannel.d.ts +45 -0
  185. package/dist/channels/TwitchChannel.d.ts.map +1 -0
  186. package/dist/channels/TwitchChannel.js +117 -0
  187. package/dist/channels/TwitchChannel.js.map +1 -0
  188. package/dist/channels/WhatsAppChannel.d.ts +45 -0
  189. package/dist/channels/WhatsAppChannel.d.ts.map +1 -0
  190. package/dist/channels/WhatsAppChannel.js +153 -0
  191. package/dist/channels/WhatsAppChannel.js.map +1 -0
  192. package/dist/channels/ZaloChannel.d.ts +42 -0
  193. package/dist/channels/ZaloChannel.d.ts.map +1 -0
  194. package/dist/channels/ZaloChannel.js +114 -0
  195. package/dist/channels/ZaloChannel.js.map +1 -0
  196. package/dist/cli/commands/config.d.ts +10 -0
  197. package/dist/cli/commands/config.d.ts.map +1 -0
  198. package/dist/cli/commands/config.js +107 -0
  199. package/dist/cli/commands/config.js.map +1 -0
  200. package/dist/cli/commands/daemon.d.ts +17 -0
  201. package/dist/cli/commands/daemon.d.ts.map +1 -0
  202. package/dist/cli/commands/daemon.js +82 -0
  203. package/dist/cli/commands/daemon.js.map +1 -0
  204. package/dist/cli/commands/doctor.d.ts +17 -0
  205. package/dist/cli/commands/doctor.d.ts.map +1 -0
  206. package/dist/cli/commands/doctor.js +138 -0
  207. package/dist/cli/commands/doctor.js.map +1 -0
  208. package/dist/cli/commands/setup.d.ts +16 -0
  209. package/dist/cli/commands/setup.d.ts.map +1 -0
  210. package/dist/cli/commands/setup.js +206 -0
  211. package/dist/cli/commands/setup.js.map +1 -0
  212. package/dist/cli/commands/start.d.ts +8 -0
  213. package/dist/cli/commands/start.d.ts.map +1 -0
  214. package/dist/cli/commands/start.js +444 -0
  215. package/dist/cli/commands/start.js.map +1 -0
  216. package/dist/cli/commands/vault.d.ts +15 -0
  217. package/dist/cli/commands/vault.d.ts.map +1 -0
  218. package/dist/cli/commands/vault.js +167 -0
  219. package/dist/cli/commands/vault.js.map +1 -0
  220. package/dist/cli/index.d.ts +13 -0
  221. package/dist/cli/index.d.ts.map +1 -0
  222. package/dist/cli/index.js +93 -0
  223. package/dist/cli/index.js.map +1 -0
  224. package/dist/cli/loadEnv.d.ts +14 -0
  225. package/dist/cli/loadEnv.d.ts.map +1 -0
  226. package/dist/cli/loadEnv.js +18 -0
  227. package/dist/cli/loadEnv.js.map +1 -0
  228. package/dist/config/ConfigManager.d.ts +79 -0
  229. package/dist/config/ConfigManager.d.ts.map +1 -0
  230. package/dist/config/ConfigManager.js +118 -0
  231. package/dist/config/ConfigManager.js.map +1 -0
  232. package/dist/config/Secret.d.ts +29 -0
  233. package/dist/config/Secret.d.ts.map +1 -0
  234. package/dist/config/Secret.js +47 -0
  235. package/dist/config/Secret.js.map +1 -0
  236. package/dist/config/SecretVault.d.ts +53 -0
  237. package/dist/config/SecretVault.d.ts.map +1 -0
  238. package/dist/config/SecretVault.js +205 -0
  239. package/dist/config/SecretVault.js.map +1 -0
  240. package/dist/config/SettingsStore.d.ts +46 -0
  241. package/dist/config/SettingsStore.d.ts.map +1 -0
  242. package/dist/config/SettingsStore.js +132 -0
  243. package/dist/config/SettingsStore.js.map +1 -0
  244. package/dist/config/env.d.ts +21 -0
  245. package/dist/config/env.d.ts.map +1 -0
  246. package/dist/config/env.js +62 -0
  247. package/dist/config/env.js.map +1 -0
  248. package/dist/config/schema.d.ts +127 -0
  249. package/dist/config/schema.d.ts.map +1 -0
  250. package/dist/config/schema.js +346 -0
  251. package/dist/config/schema.js.map +1 -0
  252. package/dist/core/AgentLoop.d.ts +180 -0
  253. package/dist/core/AgentLoop.d.ts.map +1 -0
  254. package/dist/core/AgentLoop.js +428 -0
  255. package/dist/core/AgentLoop.js.map +1 -0
  256. package/dist/core/AttachmentProcessor.d.ts +75 -0
  257. package/dist/core/AttachmentProcessor.d.ts.map +1 -0
  258. package/dist/core/AttachmentProcessor.js +191 -0
  259. package/dist/core/AttachmentProcessor.js.map +1 -0
  260. package/dist/core/Compaction.d.ts +62 -0
  261. package/dist/core/Compaction.d.ts.map +1 -0
  262. package/dist/core/Compaction.js +260 -0
  263. package/dist/core/Compaction.js.map +1 -0
  264. package/dist/core/InboundDebouncer.d.ts +42 -0
  265. package/dist/core/InboundDebouncer.d.ts.map +1 -0
  266. package/dist/core/InboundDebouncer.js +81 -0
  267. package/dist/core/InboundDebouncer.js.map +1 -0
  268. package/dist/core/LoopDetector.d.ts +36 -0
  269. package/dist/core/LoopDetector.d.ts.map +1 -0
  270. package/dist/core/LoopDetector.js +139 -0
  271. package/dist/core/LoopDetector.js.map +1 -0
  272. package/dist/core/TaskRunner.d.ts +134 -0
  273. package/dist/core/TaskRunner.d.ts.map +1 -0
  274. package/dist/core/TaskRunner.js +454 -0
  275. package/dist/core/TaskRunner.js.map +1 -0
  276. package/dist/costs/CostTracker.d.ts +70 -0
  277. package/dist/costs/CostTracker.d.ts.map +1 -0
  278. package/dist/costs/CostTracker.js +176 -0
  279. package/dist/costs/CostTracker.js.map +1 -0
  280. package/dist/crew/CrewAgentRunner.d.ts +55 -0
  281. package/dist/crew/CrewAgentRunner.d.ts.map +1 -0
  282. package/dist/crew/CrewAgentRunner.js +208 -0
  283. package/dist/crew/CrewAgentRunner.js.map +1 -0
  284. package/dist/crew/CrewLoader.d.ts +43 -0
  285. package/dist/crew/CrewLoader.d.ts.map +1 -0
  286. package/dist/crew/CrewLoader.js +122 -0
  287. package/dist/crew/CrewLoader.js.map +1 -0
  288. package/dist/crew/CrewRegistry.d.ts +30 -0
  289. package/dist/crew/CrewRegistry.d.ts.map +1 -0
  290. package/dist/crew/CrewRegistry.js +56 -0
  291. package/dist/crew/CrewRegistry.js.map +1 -0
  292. package/dist/crew/types.d.ts +79 -0
  293. package/dist/crew/types.d.ts.map +1 -0
  294. package/dist/crew/types.js +36 -0
  295. package/dist/crew/types.js.map +1 -0
  296. package/dist/cron/CronScheduler.d.ts +40 -0
  297. package/dist/cron/CronScheduler.d.ts.map +1 -0
  298. package/dist/cron/CronScheduler.js +119 -0
  299. package/dist/cron/CronScheduler.js.map +1 -0
  300. package/dist/cron/CronStore.d.ts +73 -0
  301. package/dist/cron/CronStore.d.ts.map +1 -0
  302. package/dist/cron/CronStore.js +209 -0
  303. package/dist/cron/CronStore.js.map +1 -0
  304. package/dist/cron/cronParser.d.ts +33 -0
  305. package/dist/cron/cronParser.d.ts.map +1 -0
  306. package/dist/cron/cronParser.js +211 -0
  307. package/dist/cron/cronParser.js.map +1 -0
  308. package/dist/daemon/DaemonManager.d.ts +59 -0
  309. package/dist/daemon/DaemonManager.d.ts.map +1 -0
  310. package/dist/daemon/DaemonManager.js +380 -0
  311. package/dist/daemon/DaemonManager.js.map +1 -0
  312. package/dist/embeddings/Embeddings.d.ts +70 -0
  313. package/dist/embeddings/Embeddings.d.ts.map +1 -0
  314. package/dist/embeddings/Embeddings.js +252 -0
  315. package/dist/embeddings/Embeddings.js.map +1 -0
  316. package/dist/embeddings/TfIdf.d.ts +26 -0
  317. package/dist/embeddings/TfIdf.d.ts.map +1 -0
  318. package/dist/embeddings/TfIdf.js +88 -0
  319. package/dist/embeddings/TfIdf.js.map +1 -0
  320. package/dist/events/eventBus.d.ts +97 -0
  321. package/dist/events/eventBus.d.ts.map +1 -0
  322. package/dist/events/eventBus.js +26 -0
  323. package/dist/events/eventBus.js.map +1 -0
  324. package/dist/goals/GoalStore.d.ts +40 -0
  325. package/dist/goals/GoalStore.d.ts.map +1 -0
  326. package/dist/goals/GoalStore.js +82 -0
  327. package/dist/goals/GoalStore.js.map +1 -0
  328. package/dist/hooks/HookRunner.d.ts +80 -0
  329. package/dist/hooks/HookRunner.d.ts.map +1 -0
  330. package/dist/hooks/HookRunner.js +218 -0
  331. package/dist/hooks/HookRunner.js.map +1 -0
  332. package/dist/integrations/IntegrationCrewSync.d.ts +33 -0
  333. package/dist/integrations/IntegrationCrewSync.d.ts.map +1 -0
  334. package/dist/integrations/IntegrationCrewSync.js +96 -0
  335. package/dist/integrations/IntegrationCrewSync.js.map +1 -0
  336. package/dist/integrations/IntegrationManager.d.ts +116 -0
  337. package/dist/integrations/IntegrationManager.d.ts.map +1 -0
  338. package/dist/integrations/IntegrationManager.js +580 -0
  339. package/dist/integrations/IntegrationManager.js.map +1 -0
  340. package/dist/integrations/IntegrationStore.d.ts +42 -0
  341. package/dist/integrations/IntegrationStore.d.ts.map +1 -0
  342. package/dist/integrations/IntegrationStore.js +146 -0
  343. package/dist/integrations/IntegrationStore.js.map +1 -0
  344. package/dist/integrations/authFetch.d.ts +21 -0
  345. package/dist/integrations/authFetch.d.ts.map +1 -0
  346. package/dist/integrations/authFetch.js +36 -0
  347. package/dist/integrations/authFetch.js.map +1 -0
  348. package/dist/integrations/facebook/FacebookClient.d.ts +33 -0
  349. package/dist/integrations/facebook/FacebookClient.d.ts.map +1 -0
  350. package/dist/integrations/facebook/FacebookClient.js +88 -0
  351. package/dist/integrations/facebook/FacebookClient.js.map +1 -0
  352. package/dist/integrations/facebook/tools.d.ts +9 -0
  353. package/dist/integrations/facebook/tools.d.ts.map +1 -0
  354. package/dist/integrations/facebook/tools.js +324 -0
  355. package/dist/integrations/facebook/tools.js.map +1 -0
  356. package/dist/integrations/gmail/GmailClient.d.ts +34 -0
  357. package/dist/integrations/gmail/GmailClient.d.ts.map +1 -0
  358. package/dist/integrations/gmail/GmailClient.js +69 -0
  359. package/dist/integrations/gmail/GmailClient.js.map +1 -0
  360. package/dist/integrations/gmail/tools.d.ts +14 -0
  361. package/dist/integrations/gmail/tools.d.ts.map +1 -0
  362. package/dist/integrations/gmail/tools.js +295 -0
  363. package/dist/integrations/gmail/tools.js.map +1 -0
  364. package/dist/integrations/google-calendar/CalendarClient.d.ts +16 -0
  365. package/dist/integrations/google-calendar/CalendarClient.d.ts.map +1 -0
  366. package/dist/integrations/google-calendar/CalendarClient.js +39 -0
  367. package/dist/integrations/google-calendar/CalendarClient.js.map +1 -0
  368. package/dist/integrations/google-calendar/tools.d.ts +15 -0
  369. package/dist/integrations/google-calendar/tools.d.ts.map +1 -0
  370. package/dist/integrations/google-calendar/tools.js +246 -0
  371. package/dist/integrations/google-calendar/tools.js.map +1 -0
  372. package/dist/integrations/instagram/InstagramClient.d.ts +33 -0
  373. package/dist/integrations/instagram/InstagramClient.d.ts.map +1 -0
  374. package/dist/integrations/instagram/InstagramClient.js +93 -0
  375. package/dist/integrations/instagram/InstagramClient.js.map +1 -0
  376. package/dist/integrations/instagram/tools.d.ts +17 -0
  377. package/dist/integrations/instagram/tools.d.ts.map +1 -0
  378. package/dist/integrations/instagram/tools.js +348 -0
  379. package/dist/integrations/instagram/tools.js.map +1 -0
  380. package/dist/integrations/keys.d.ts +56 -0
  381. package/dist/integrations/keys.d.ts.map +1 -0
  382. package/dist/integrations/keys.js +174 -0
  383. package/dist/integrations/keys.js.map +1 -0
  384. package/dist/integrations/linkedin/LinkedInClient.d.ts +24 -0
  385. package/dist/integrations/linkedin/LinkedInClient.d.ts.map +1 -0
  386. package/dist/integrations/linkedin/LinkedInClient.js +56 -0
  387. package/dist/integrations/linkedin/LinkedInClient.js.map +1 -0
  388. package/dist/integrations/linkedin/tools.d.ts +14 -0
  389. package/dist/integrations/linkedin/tools.d.ts.map +1 -0
  390. package/dist/integrations/linkedin/tools.js +154 -0
  391. package/dist/integrations/linkedin/tools.js.map +1 -0
  392. package/dist/integrations/pkce.d.ts +17 -0
  393. package/dist/integrations/pkce.d.ts.map +1 -0
  394. package/dist/integrations/pkce.js +22 -0
  395. package/dist/integrations/pkce.js.map +1 -0
  396. package/dist/integrations/providers/github.d.ts +20 -0
  397. package/dist/integrations/providers/github.d.ts.map +1 -0
  398. package/dist/integrations/providers/github.js +113 -0
  399. package/dist/integrations/providers/github.js.map +1 -0
  400. package/dist/integrations/providers/google.d.ts +17 -0
  401. package/dist/integrations/providers/google.d.ts.map +1 -0
  402. package/dist/integrations/providers/google.js +115 -0
  403. package/dist/integrations/providers/google.js.map +1 -0
  404. package/dist/integrations/providers/linkedin.d.ts +22 -0
  405. package/dist/integrations/providers/linkedin.d.ts.map +1 -0
  406. package/dist/integrations/providers/linkedin.js +103 -0
  407. package/dist/integrations/providers/linkedin.js.map +1 -0
  408. package/dist/integrations/providers/meta.d.ts +19 -0
  409. package/dist/integrations/providers/meta.d.ts.map +1 -0
  410. package/dist/integrations/providers/meta.js +116 -0
  411. package/dist/integrations/providers/meta.js.map +1 -0
  412. package/dist/integrations/providers/notion.d.ts +21 -0
  413. package/dist/integrations/providers/notion.d.ts.map +1 -0
  414. package/dist/integrations/providers/notion.js +96 -0
  415. package/dist/integrations/providers/notion.js.map +1 -0
  416. package/dist/integrations/providers/reddit.d.ts +18 -0
  417. package/dist/integrations/providers/reddit.d.ts.map +1 -0
  418. package/dist/integrations/providers/reddit.js +104 -0
  419. package/dist/integrations/providers/reddit.js.map +1 -0
  420. package/dist/integrations/providers/tiktok.d.ts +28 -0
  421. package/dist/integrations/providers/tiktok.d.ts.map +1 -0
  422. package/dist/integrations/providers/tiktok.js +138 -0
  423. package/dist/integrations/providers/tiktok.js.map +1 -0
  424. package/dist/integrations/providers/twitter.d.ts +26 -0
  425. package/dist/integrations/providers/twitter.d.ts.map +1 -0
  426. package/dist/integrations/providers/twitter.js +141 -0
  427. package/dist/integrations/providers/twitter.js.map +1 -0
  428. package/dist/integrations/reddit/RedditClient.d.ts +18 -0
  429. package/dist/integrations/reddit/RedditClient.d.ts.map +1 -0
  430. package/dist/integrations/reddit/RedditClient.js +54 -0
  431. package/dist/integrations/reddit/RedditClient.js.map +1 -0
  432. package/dist/integrations/reddit/tools.d.ts +16 -0
  433. package/dist/integrations/reddit/tools.d.ts.map +1 -0
  434. package/dist/integrations/reddit/tools.js +293 -0
  435. package/dist/integrations/reddit/tools.js.map +1 -0
  436. package/dist/integrations/tiktok/TikTokClient.d.ts +21 -0
  437. package/dist/integrations/tiktok/TikTokClient.d.ts.map +1 -0
  438. package/dist/integrations/tiktok/TikTokClient.js +44 -0
  439. package/dist/integrations/tiktok/TikTokClient.js.map +1 -0
  440. package/dist/integrations/tiktok/tools.d.ts +17 -0
  441. package/dist/integrations/tiktok/tools.d.ts.map +1 -0
  442. package/dist/integrations/tiktok/tools.js +258 -0
  443. package/dist/integrations/tiktok/tools.js.map +1 -0
  444. package/dist/integrations/tools.d.ts +20 -0
  445. package/dist/integrations/tools.d.ts.map +1 -0
  446. package/dist/integrations/tools.js +43 -0
  447. package/dist/integrations/tools.js.map +1 -0
  448. package/dist/integrations/twitter/TwitterClient.d.ts +19 -0
  449. package/dist/integrations/twitter/TwitterClient.d.ts.map +1 -0
  450. package/dist/integrations/twitter/TwitterClient.js +51 -0
  451. package/dist/integrations/twitter/TwitterClient.js.map +1 -0
  452. package/dist/integrations/twitter/tools.d.ts +11 -0
  453. package/dist/integrations/twitter/tools.d.ts.map +1 -0
  454. package/dist/integrations/twitter/tools.js +459 -0
  455. package/dist/integrations/twitter/tools.js.map +1 -0
  456. package/dist/integrations/types.d.ts +118 -0
  457. package/dist/integrations/types.d.ts.map +1 -0
  458. package/dist/integrations/types.js +10 -0
  459. package/dist/integrations/types.js.map +1 -0
  460. package/dist/integrations/youtube/YouTubeClient.d.ts +45 -0
  461. package/dist/integrations/youtube/YouTubeClient.d.ts.map +1 -0
  462. package/dist/integrations/youtube/YouTubeClient.js +115 -0
  463. package/dist/integrations/youtube/YouTubeClient.js.map +1 -0
  464. package/dist/integrations/youtube/tools.d.ts +14 -0
  465. package/dist/integrations/youtube/tools.d.ts.map +1 -0
  466. package/dist/integrations/youtube/tools.js +500 -0
  467. package/dist/integrations/youtube/tools.js.map +1 -0
  468. package/dist/learning/BackgroundReviewer.d.ts +43 -0
  469. package/dist/learning/BackgroundReviewer.d.ts.map +1 -0
  470. package/dist/learning/BackgroundReviewer.js +143 -0
  471. package/dist/learning/BackgroundReviewer.js.map +1 -0
  472. package/dist/learning/ExtractionPipeline.d.ts +46 -0
  473. package/dist/learning/ExtractionPipeline.d.ts.map +1 -0
  474. package/dist/learning/ExtractionPipeline.js +220 -0
  475. package/dist/learning/ExtractionPipeline.js.map +1 -0
  476. package/dist/learning/MemoryDecay.d.ts +63 -0
  477. package/dist/learning/MemoryDecay.d.ts.map +1 -0
  478. package/dist/learning/MemoryDecay.js +204 -0
  479. package/dist/learning/MemoryDecay.js.map +1 -0
  480. package/dist/learning/SmartRecall.d.ts +58 -0
  481. package/dist/learning/SmartRecall.d.ts.map +1 -0
  482. package/dist/learning/SmartRecall.js +182 -0
  483. package/dist/learning/SmartRecall.js.map +1 -0
  484. package/dist/mcp/MCPIntegrationBridge.d.ts +40 -0
  485. package/dist/mcp/MCPIntegrationBridge.d.ts.map +1 -0
  486. package/dist/mcp/MCPIntegrationBridge.js +136 -0
  487. package/dist/mcp/MCPIntegrationBridge.js.map +1 -0
  488. package/dist/mcp/MCPManager.d.ts +126 -0
  489. package/dist/mcp/MCPManager.d.ts.map +1 -0
  490. package/dist/mcp/MCPManager.js +418 -0
  491. package/dist/mcp/MCPManager.js.map +1 -0
  492. package/dist/mcp/MCPStore.d.ts +41 -0
  493. package/dist/mcp/MCPStore.d.ts.map +1 -0
  494. package/dist/mcp/MCPStore.js +102 -0
  495. package/dist/mcp/MCPStore.js.map +1 -0
  496. package/dist/mcp/defaults.d.ts +51 -0
  497. package/dist/mcp/defaults.d.ts.map +1 -0
  498. package/dist/mcp/defaults.js +243 -0
  499. package/dist/mcp/defaults.js.map +1 -0
  500. package/dist/memory/DeclarativeMemoryStore.d.ts +54 -0
  501. package/dist/memory/DeclarativeMemoryStore.d.ts.map +1 -0
  502. package/dist/memory/DeclarativeMemoryStore.js +195 -0
  503. package/dist/memory/DeclarativeMemoryStore.js.map +1 -0
  504. package/dist/memory/MemoryStore.d.ts +65 -0
  505. package/dist/memory/MemoryStore.d.ts.map +1 -0
  506. package/dist/memory/MemoryStore.js +189 -0
  507. package/dist/memory/MemoryStore.js.map +1 -0
  508. package/dist/memory/SessionStore.d.ts +207 -0
  509. package/dist/memory/SessionStore.d.ts.map +1 -0
  510. package/dist/memory/SessionStore.js +391 -0
  511. package/dist/memory/SessionStore.js.map +1 -0
  512. package/dist/models/ModelRouter.d.ts +57 -0
  513. package/dist/models/ModelRouter.d.ts.map +1 -0
  514. package/dist/models/ModelRouter.js +301 -0
  515. package/dist/models/ModelRouter.js.map +1 -0
  516. package/dist/models/discovery.d.ts +44 -0
  517. package/dist/models/discovery.d.ts.map +1 -0
  518. package/dist/models/discovery.js +456 -0
  519. package/dist/models/discovery.js.map +1 -0
  520. package/dist/models/providers.d.ts +82 -0
  521. package/dist/models/providers.d.ts.map +1 -0
  522. package/dist/models/providers.js +455 -0
  523. package/dist/models/providers.js.map +1 -0
  524. package/dist/models/registry.d.ts +13 -0
  525. package/dist/models/registry.d.ts.map +1 -0
  526. package/dist/models/registry.js +42 -0
  527. package/dist/models/registry.js.map +1 -0
  528. package/dist/models/types.d.ts +24 -0
  529. package/dist/models/types.d.ts.map +1 -0
  530. package/dist/models/types.js +8 -0
  531. package/dist/models/types.js.map +1 -0
  532. package/dist/projects/ProjectStore.d.ts +73 -0
  533. package/dist/projects/ProjectStore.d.ts.map +1 -0
  534. package/dist/projects/ProjectStore.js +132 -0
  535. package/dist/projects/ProjectStore.js.map +1 -0
  536. package/dist/safety/AuditLog.d.ts +53 -0
  537. package/dist/safety/AuditLog.d.ts.map +1 -0
  538. package/dist/safety/AuditLog.js +170 -0
  539. package/dist/safety/AuditLog.js.map +1 -0
  540. package/dist/safety/CircuitBreaker.d.ts +53 -0
  541. package/dist/safety/CircuitBreaker.d.ts.map +1 -0
  542. package/dist/safety/CircuitBreaker.js +112 -0
  543. package/dist/safety/CircuitBreaker.js.map +1 -0
  544. package/dist/safety/CommandGuard.d.ts +32 -0
  545. package/dist/safety/CommandGuard.d.ts.map +1 -0
  546. package/dist/safety/CommandGuard.js +157 -0
  547. package/dist/safety/CommandGuard.js.map +1 -0
  548. package/dist/safety/DockerSandbox.d.ts +72 -0
  549. package/dist/safety/DockerSandbox.d.ts.map +1 -0
  550. package/dist/safety/DockerSandbox.js +188 -0
  551. package/dist/safety/DockerSandbox.js.map +1 -0
  552. package/dist/safety/EgressGuard.d.ts +35 -0
  553. package/dist/safety/EgressGuard.d.ts.map +1 -0
  554. package/dist/safety/EgressGuard.js +95 -0
  555. package/dist/safety/EgressGuard.js.map +1 -0
  556. package/dist/safety/ExecApproval.d.ts +53 -0
  557. package/dist/safety/ExecApproval.d.ts.map +1 -0
  558. package/dist/safety/ExecApproval.js +120 -0
  559. package/dist/safety/ExecApproval.js.map +1 -0
  560. package/dist/safety/FilesystemGuard.d.ts +94 -0
  561. package/dist/safety/FilesystemGuard.d.ts.map +1 -0
  562. package/dist/safety/FilesystemGuard.js +275 -0
  563. package/dist/safety/FilesystemGuard.js.map +1 -0
  564. package/dist/safety/GitRollback.d.ts +47 -0
  565. package/dist/safety/GitRollback.d.ts.map +1 -0
  566. package/dist/safety/GitRollback.js +161 -0
  567. package/dist/safety/GitRollback.js.map +1 -0
  568. package/dist/safety/HumanApproval.d.ts +65 -0
  569. package/dist/safety/HumanApproval.d.ts.map +1 -0
  570. package/dist/safety/HumanApproval.js +157 -0
  571. package/dist/safety/HumanApproval.js.map +1 -0
  572. package/dist/safety/InputSanitizer.d.ts +59 -0
  573. package/dist/safety/InputSanitizer.d.ts.map +1 -0
  574. package/dist/safety/InputSanitizer.js +111 -0
  575. package/dist/safety/InputSanitizer.js.map +1 -0
  576. package/dist/safety/PermissionGuard.d.ts +49 -0
  577. package/dist/safety/PermissionGuard.d.ts.map +1 -0
  578. package/dist/safety/PermissionGuard.js +136 -0
  579. package/dist/safety/PermissionGuard.js.map +1 -0
  580. package/dist/safety/Sandbox.d.ts +38 -0
  581. package/dist/safety/Sandbox.d.ts.map +1 -0
  582. package/dist/safety/Sandbox.js +82 -0
  583. package/dist/safety/Sandbox.js.map +1 -0
  584. package/dist/safety/SecretScanner.d.ts +67 -0
  585. package/dist/safety/SecretScanner.d.ts.map +1 -0
  586. package/dist/safety/SecretScanner.js +150 -0
  587. package/dist/safety/SecretScanner.js.map +1 -0
  588. package/dist/safety/Supervisor.d.ts +69 -0
  589. package/dist/safety/Supervisor.d.ts.map +1 -0
  590. package/dist/safety/Supervisor.js +165 -0
  591. package/dist/safety/Supervisor.js.map +1 -0
  592. package/dist/scheduler/CronExecutor.d.ts +18 -0
  593. package/dist/scheduler/CronExecutor.d.ts.map +1 -0
  594. package/dist/scheduler/CronExecutor.js +57 -0
  595. package/dist/scheduler/CronExecutor.js.map +1 -0
  596. package/dist/scheduler/DailyLog.d.ts +29 -0
  597. package/dist/scheduler/DailyLog.d.ts.map +1 -0
  598. package/dist/scheduler/DailyLog.js +84 -0
  599. package/dist/scheduler/DailyLog.js.map +1 -0
  600. package/dist/scheduler/DeliveryPresetStore.d.ts +47 -0
  601. package/dist/scheduler/DeliveryPresetStore.d.ts.map +1 -0
  602. package/dist/scheduler/DeliveryPresetStore.js +101 -0
  603. package/dist/scheduler/DeliveryPresetStore.js.map +1 -0
  604. package/dist/scheduler/GoalPulse.d.ts +42 -0
  605. package/dist/scheduler/GoalPulse.d.ts.map +1 -0
  606. package/dist/scheduler/GoalPulse.js +123 -0
  607. package/dist/scheduler/GoalPulse.js.map +1 -0
  608. package/dist/scheduler/Heartbeat.d.ts +87 -0
  609. package/dist/scheduler/Heartbeat.d.ts.map +1 -0
  610. package/dist/scheduler/Heartbeat.js +313 -0
  611. package/dist/scheduler/Heartbeat.js.map +1 -0
  612. package/dist/scheduler/MorningPulse.d.ts +23 -0
  613. package/dist/scheduler/MorningPulse.d.ts.map +1 -0
  614. package/dist/scheduler/MorningPulse.js +45 -0
  615. package/dist/scheduler/MorningPulse.js.map +1 -0
  616. package/dist/server/index.d.ts +77 -0
  617. package/dist/server/index.d.ts.map +1 -0
  618. package/dist/server/index.js +227 -0
  619. package/dist/server/index.js.map +1 -0
  620. package/dist/server/middleware/requireAuth.d.ts +41 -0
  621. package/dist/server/middleware/requireAuth.d.ts.map +1 -0
  622. package/dist/server/middleware/requireAuth.js +72 -0
  623. package/dist/server/middleware/requireAuth.js.map +1 -0
  624. package/dist/server/middleware/security.d.ts +83 -0
  625. package/dist/server/middleware/security.d.ts.map +1 -0
  626. package/dist/server/middleware/security.js +171 -0
  627. package/dist/server/middleware/security.js.map +1 -0
  628. package/dist/server/routes/auth.d.ts +24 -0
  629. package/dist/server/routes/auth.d.ts.map +1 -0
  630. package/dist/server/routes/auth.js +65 -0
  631. package/dist/server/routes/auth.js.map +1 -0
  632. package/dist/server/routes/channels.d.ts +7 -0
  633. package/dist/server/routes/channels.d.ts.map +1 -0
  634. package/dist/server/routes/channels.js +90 -0
  635. package/dist/server/routes/channels.js.map +1 -0
  636. package/dist/server/routes/chat.d.ts +19 -0
  637. package/dist/server/routes/chat.d.ts.map +1 -0
  638. package/dist/server/routes/chat.js +209 -0
  639. package/dist/server/routes/chat.js.map +1 -0
  640. package/dist/server/routes/compat.d.ts +8 -0
  641. package/dist/server/routes/compat.d.ts.map +1 -0
  642. package/dist/server/routes/compat.js +661 -0
  643. package/dist/server/routes/compat.js.map +1 -0
  644. package/dist/server/routes/config.d.ts +10 -0
  645. package/dist/server/routes/config.d.ts.map +1 -0
  646. package/dist/server/routes/config.js +142 -0
  647. package/dist/server/routes/config.js.map +1 -0
  648. package/dist/server/routes/costs.d.ts +7 -0
  649. package/dist/server/routes/costs.d.ts.map +1 -0
  650. package/dist/server/routes/costs.js +23 -0
  651. package/dist/server/routes/costs.js.map +1 -0
  652. package/dist/server/routes/crew.d.ts +21 -0
  653. package/dist/server/routes/crew.d.ts.map +1 -0
  654. package/dist/server/routes/crew.js +372 -0
  655. package/dist/server/routes/crew.js.map +1 -0
  656. package/dist/server/routes/cron.d.ts +9 -0
  657. package/dist/server/routes/cron.d.ts.map +1 -0
  658. package/dist/server/routes/cron.js +91 -0
  659. package/dist/server/routes/cron.js.map +1 -0
  660. package/dist/server/routes/deliveryPresets.d.ts +13 -0
  661. package/dist/server/routes/deliveryPresets.d.ts.map +1 -0
  662. package/dist/server/routes/deliveryPresets.js +42 -0
  663. package/dist/server/routes/deliveryPresets.js.map +1 -0
  664. package/dist/server/routes/goals.d.ts +7 -0
  665. package/dist/server/routes/goals.d.ts.map +1 -0
  666. package/dist/server/routes/goals.js +65 -0
  667. package/dist/server/routes/goals.js.map +1 -0
  668. package/dist/server/routes/integrations.d.ts +35 -0
  669. package/dist/server/routes/integrations.d.ts.map +1 -0
  670. package/dist/server/routes/integrations.js +448 -0
  671. package/dist/server/routes/integrations.js.map +1 -0
  672. package/dist/server/routes/mcp.d.ts +7 -0
  673. package/dist/server/routes/mcp.d.ts.map +1 -0
  674. package/dist/server/routes/mcp.js +88 -0
  675. package/dist/server/routes/mcp.js.map +1 -0
  676. package/dist/server/routes/memory.d.ts +15 -0
  677. package/dist/server/routes/memory.d.ts.map +1 -0
  678. package/dist/server/routes/memory.js +104 -0
  679. package/dist/server/routes/memory.js.map +1 -0
  680. package/dist/server/routes/providers.d.ts +15 -0
  681. package/dist/server/routes/providers.d.ts.map +1 -0
  682. package/dist/server/routes/providers.js +209 -0
  683. package/dist/server/routes/providers.js.map +1 -0
  684. package/dist/server/routes/security.d.ts +15 -0
  685. package/dist/server/routes/security.d.ts.map +1 -0
  686. package/dist/server/routes/security.js +117 -0
  687. package/dist/server/routes/security.js.map +1 -0
  688. package/dist/server/routes/sessions.d.ts +12 -0
  689. package/dist/server/routes/sessions.d.ts.map +1 -0
  690. package/dist/server/routes/sessions.js +172 -0
  691. package/dist/server/routes/sessions.js.map +1 -0
  692. package/dist/server/routes/skills.d.ts +11 -0
  693. package/dist/server/routes/skills.d.ts.map +1 -0
  694. package/dist/server/routes/skills.js +214 -0
  695. package/dist/server/routes/skills.js.map +1 -0
  696. package/dist/server/routes/tasks.d.ts +10 -0
  697. package/dist/server/routes/tasks.d.ts.map +1 -0
  698. package/dist/server/routes/tasks.js +38 -0
  699. package/dist/server/routes/tasks.js.map +1 -0
  700. package/dist/server/routes/teams.d.ts +7 -0
  701. package/dist/server/routes/teams.d.ts.map +1 -0
  702. package/dist/server/routes/teams.js +61 -0
  703. package/dist/server/routes/teams.js.map +1 -0
  704. package/dist/server/routes/tunnel.d.ts +12 -0
  705. package/dist/server/routes/tunnel.d.ts.map +1 -0
  706. package/dist/server/routes/tunnel.js +18 -0
  707. package/dist/server/routes/tunnel.js.map +1 -0
  708. package/dist/server/routes/vault.d.ts +15 -0
  709. package/dist/server/routes/vault.d.ts.map +1 -0
  710. package/dist/server/routes/vault.js +82 -0
  711. package/dist/server/routes/vault.js.map +1 -0
  712. package/dist/server/routes/voice.d.ts +16 -0
  713. package/dist/server/routes/voice.d.ts.map +1 -0
  714. package/dist/server/routes/voice.js +431 -0
  715. package/dist/server/routes/voice.js.map +1 -0
  716. package/dist/server/routes/watchers.d.ts +14 -0
  717. package/dist/server/routes/watchers.d.ts.map +1 -0
  718. package/dist/server/routes/watchers.js +143 -0
  719. package/dist/server/routes/watchers.js.map +1 -0
  720. package/dist/services/Cleanup.d.ts +50 -0
  721. package/dist/services/Cleanup.d.ts.map +1 -0
  722. package/dist/services/Cleanup.js +104 -0
  723. package/dist/services/Cleanup.js.map +1 -0
  724. package/dist/skills/SecurityScanner.d.ts +18 -0
  725. package/dist/skills/SecurityScanner.d.ts.map +1 -0
  726. package/dist/skills/SecurityScanner.js +49 -0
  727. package/dist/skills/SecurityScanner.js.map +1 -0
  728. package/dist/skills/SkillLoader.d.ts +45 -0
  729. package/dist/skills/SkillLoader.d.ts.map +1 -0
  730. package/dist/skills/SkillLoader.js +336 -0
  731. package/dist/skills/SkillLoader.js.map +1 -0
  732. package/dist/skills/SkillRegistry.d.ts +78 -0
  733. package/dist/skills/SkillRegistry.d.ts.map +1 -0
  734. package/dist/skills/SkillRegistry.js +185 -0
  735. package/dist/skills/SkillRegistry.js.map +1 -0
  736. package/dist/skills/SkillSnapshot.d.ts +37 -0
  737. package/dist/skills/SkillSnapshot.d.ts.map +1 -0
  738. package/dist/skills/SkillSnapshot.js +106 -0
  739. package/dist/skills/SkillSnapshot.js.map +1 -0
  740. package/dist/skills/types.d.ts +184 -0
  741. package/dist/skills/types.d.ts.map +1 -0
  742. package/dist/skills/types.js +58 -0
  743. package/dist/skills/types.js.map +1 -0
  744. package/dist/tasks/TaskStore.d.ts +70 -0
  745. package/dist/tasks/TaskStore.d.ts.map +1 -0
  746. package/dist/tasks/TaskStore.js +200 -0
  747. package/dist/tasks/TaskStore.js.map +1 -0
  748. package/dist/teams/TeamRunner.d.ts +46 -0
  749. package/dist/teams/TeamRunner.d.ts.map +1 -0
  750. package/dist/teams/TeamRunner.js +186 -0
  751. package/dist/teams/TeamRunner.js.map +1 -0
  752. package/dist/teams/TeamStore.d.ts +84 -0
  753. package/dist/teams/TeamStore.d.ts.map +1 -0
  754. package/dist/teams/TeamStore.js +231 -0
  755. package/dist/teams/TeamStore.js.map +1 -0
  756. package/dist/teams/templates.d.ts +18 -0
  757. package/dist/teams/templates.d.ts.map +1 -0
  758. package/dist/teams/templates.js +89 -0
  759. package/dist/teams/templates.js.map +1 -0
  760. package/dist/tools/core/applyPatch.d.ts +19 -0
  761. package/dist/tools/core/applyPatch.d.ts.map +1 -0
  762. package/dist/tools/core/applyPatch.js +51 -0
  763. package/dist/tools/core/applyPatch.js.map +1 -0
  764. package/dist/tools/core/broadcast.d.ts +67 -0
  765. package/dist/tools/core/broadcast.d.ts.map +1 -0
  766. package/dist/tools/core/broadcast.js +93 -0
  767. package/dist/tools/core/broadcast.js.map +1 -0
  768. package/dist/tools/core/clipboard.d.ts +17 -0
  769. package/dist/tools/core/clipboard.d.ts.map +1 -0
  770. package/dist/tools/core/clipboard.js +38 -0
  771. package/dist/tools/core/clipboard.js.map +1 -0
  772. package/dist/tools/core/createDocument.d.ts +27 -0
  773. package/dist/tools/core/createDocument.d.ts.map +1 -0
  774. package/dist/tools/core/createDocument.js +297 -0
  775. package/dist/tools/core/createDocument.js.map +1 -0
  776. package/dist/tools/core/cronTool.d.ts +55 -0
  777. package/dist/tools/core/cronTool.d.ts.map +1 -0
  778. package/dist/tools/core/cronTool.js +162 -0
  779. package/dist/tools/core/cronTool.js.map +1 -0
  780. package/dist/tools/core/desktop.d.ts +16 -0
  781. package/dist/tools/core/desktop.d.ts.map +1 -0
  782. package/dist/tools/core/desktop.js +480 -0
  783. package/dist/tools/core/desktop.js.map +1 -0
  784. package/dist/tools/core/editFile.d.ts +43 -0
  785. package/dist/tools/core/editFile.d.ts.map +1 -0
  786. package/dist/tools/core/editFile.js +104 -0
  787. package/dist/tools/core/editFile.js.map +1 -0
  788. package/dist/tools/core/executeCommand.d.ts +36 -0
  789. package/dist/tools/core/executeCommand.d.ts.map +1 -0
  790. package/dist/tools/core/executeCommand.js +92 -0
  791. package/dist/tools/core/executeCommand.js.map +1 -0
  792. package/dist/tools/core/fetchUrl.d.ts +38 -0
  793. package/dist/tools/core/fetchUrl.d.ts.map +1 -0
  794. package/dist/tools/core/fetchUrl.js +111 -0
  795. package/dist/tools/core/fetchUrl.js.map +1 -0
  796. package/dist/tools/core/generateImage.d.ts +42 -0
  797. package/dist/tools/core/generateImage.d.ts.map +1 -0
  798. package/dist/tools/core/generateImage.js +143 -0
  799. package/dist/tools/core/generateImage.js.map +1 -0
  800. package/dist/tools/core/generateMusic.d.ts +42 -0
  801. package/dist/tools/core/generateMusic.d.ts.map +1 -0
  802. package/dist/tools/core/generateMusic.js +158 -0
  803. package/dist/tools/core/generateMusic.js.map +1 -0
  804. package/dist/tools/core/generateVideo.d.ts +45 -0
  805. package/dist/tools/core/generateVideo.d.ts.map +1 -0
  806. package/dist/tools/core/generateVideo.js +447 -0
  807. package/dist/tools/core/generateVideo.js.map +1 -0
  808. package/dist/tools/core/gitTool.d.ts +81 -0
  809. package/dist/tools/core/gitTool.d.ts.map +1 -0
  810. package/dist/tools/core/gitTool.js +196 -0
  811. package/dist/tools/core/gitTool.js.map +1 -0
  812. package/dist/tools/core/glob.d.ts +26 -0
  813. package/dist/tools/core/glob.d.ts.map +1 -0
  814. package/dist/tools/core/glob.js +104 -0
  815. package/dist/tools/core/glob.js.map +1 -0
  816. package/dist/tools/core/goalTool.d.ts +50 -0
  817. package/dist/tools/core/goalTool.d.ts.map +1 -0
  818. package/dist/tools/core/goalTool.js +150 -0
  819. package/dist/tools/core/goalTool.js.map +1 -0
  820. package/dist/tools/core/grep.d.ts +32 -0
  821. package/dist/tools/core/grep.d.ts.map +1 -0
  822. package/dist/tools/core/grep.js +83 -0
  823. package/dist/tools/core/grep.js.map +1 -0
  824. package/dist/tools/core/imageAnalysis.d.ts +18 -0
  825. package/dist/tools/core/imageAnalysis.d.ts.map +1 -0
  826. package/dist/tools/core/imageAnalysis.js +77 -0
  827. package/dist/tools/core/imageAnalysis.js.map +1 -0
  828. package/dist/tools/core/imageOps.d.ts +70 -0
  829. package/dist/tools/core/imageOps.d.ts.map +1 -0
  830. package/dist/tools/core/imageOps.js +179 -0
  831. package/dist/tools/core/imageOps.js.map +1 -0
  832. package/dist/tools/core/index.d.ts +50 -0
  833. package/dist/tools/core/index.d.ts.map +1 -0
  834. package/dist/tools/core/index.js +159 -0
  835. package/dist/tools/core/index.js.map +1 -0
  836. package/dist/tools/core/listCrews.d.ts +41 -0
  837. package/dist/tools/core/listCrews.d.ts.map +1 -0
  838. package/dist/tools/core/listCrews.js +50 -0
  839. package/dist/tools/core/listCrews.js.map +1 -0
  840. package/dist/tools/core/listDirectory.d.ts +33 -0
  841. package/dist/tools/core/listDirectory.d.ts.map +1 -0
  842. package/dist/tools/core/listDirectory.js +89 -0
  843. package/dist/tools/core/listDirectory.js.map +1 -0
  844. package/dist/tools/core/manageAgents.d.ts +48 -0
  845. package/dist/tools/core/manageAgents.d.ts.map +1 -0
  846. package/dist/tools/core/manageAgents.js +104 -0
  847. package/dist/tools/core/manageAgents.js.map +1 -0
  848. package/dist/tools/core/manageMCP.d.ts +52 -0
  849. package/dist/tools/core/manageMCP.d.ts.map +1 -0
  850. package/dist/tools/core/manageMCP.js +160 -0
  851. package/dist/tools/core/manageMCP.js.map +1 -0
  852. package/dist/tools/core/memory.d.ts +49 -0
  853. package/dist/tools/core/memory.d.ts.map +1 -0
  854. package/dist/tools/core/memory.js +80 -0
  855. package/dist/tools/core/memory.js.map +1 -0
  856. package/dist/tools/core/memoryRecall.d.ts +39 -0
  857. package/dist/tools/core/memoryRecall.d.ts.map +1 -0
  858. package/dist/tools/core/memoryRecall.js +42 -0
  859. package/dist/tools/core/memoryRecall.js.map +1 -0
  860. package/dist/tools/core/memorySave.d.ts +33 -0
  861. package/dist/tools/core/memorySave.d.ts.map +1 -0
  862. package/dist/tools/core/memorySave.js +41 -0
  863. package/dist/tools/core/memorySave.js.map +1 -0
  864. package/dist/tools/core/messageChannel.d.ts +27 -0
  865. package/dist/tools/core/messageChannel.d.ts.map +1 -0
  866. package/dist/tools/core/messageChannel.js +59 -0
  867. package/dist/tools/core/messageChannel.js.map +1 -0
  868. package/dist/tools/core/parallelCrew.d.ts +54 -0
  869. package/dist/tools/core/parallelCrew.d.ts.map +1 -0
  870. package/dist/tools/core/parallelCrew.js +60 -0
  871. package/dist/tools/core/parallelCrew.js.map +1 -0
  872. package/dist/tools/core/pollTool.d.ts +36 -0
  873. package/dist/tools/core/pollTool.d.ts.map +1 -0
  874. package/dist/tools/core/pollTool.js +69 -0
  875. package/dist/tools/core/pollTool.js.map +1 -0
  876. package/dist/tools/core/projectTracker.d.ts +71 -0
  877. package/dist/tools/core/projectTracker.d.ts.map +1 -0
  878. package/dist/tools/core/projectTracker.js +181 -0
  879. package/dist/tools/core/projectTracker.js.map +1 -0
  880. package/dist/tools/core/readFile.d.ts +24 -0
  881. package/dist/tools/core/readFile.d.ts.map +1 -0
  882. package/dist/tools/core/readFile.js +49 -0
  883. package/dist/tools/core/readFile.js.map +1 -0
  884. package/dist/tools/core/readPDF.d.ts +32 -0
  885. package/dist/tools/core/readPDF.d.ts.map +1 -0
  886. package/dist/tools/core/readPDF.js +135 -0
  887. package/dist/tools/core/readPDF.js.map +1 -0
  888. package/dist/tools/core/reloadTool.d.ts +36 -0
  889. package/dist/tools/core/reloadTool.d.ts.map +1 -0
  890. package/dist/tools/core/reloadTool.js +109 -0
  891. package/dist/tools/core/reloadTool.js.map +1 -0
  892. package/dist/tools/core/replyToUser.d.ts +14 -0
  893. package/dist/tools/core/replyToUser.d.ts.map +1 -0
  894. package/dist/tools/core/replyToUser.js +19 -0
  895. package/dist/tools/core/replyToUser.js.map +1 -0
  896. package/dist/tools/core/screenCapture.d.ts +17 -0
  897. package/dist/tools/core/screenCapture.d.ts.map +1 -0
  898. package/dist/tools/core/screenCapture.js +34 -0
  899. package/dist/tools/core/screenCapture.js.map +1 -0
  900. package/dist/tools/core/sendEmail.d.ts +34 -0
  901. package/dist/tools/core/sendEmail.d.ts.map +1 -0
  902. package/dist/tools/core/sendEmail.js +56 -0
  903. package/dist/tools/core/sendEmail.js.map +1 -0
  904. package/dist/tools/core/sendFile.d.ts +37 -0
  905. package/dist/tools/core/sendFile.d.ts.map +1 -0
  906. package/dist/tools/core/sendFile.js +53 -0
  907. package/dist/tools/core/sendFile.js.map +1 -0
  908. package/dist/tools/core/sessionSearch.d.ts +62 -0
  909. package/dist/tools/core/sessionSearch.d.ts.map +1 -0
  910. package/dist/tools/core/sessionSearch.js +154 -0
  911. package/dist/tools/core/sessionSearch.js.map +1 -0
  912. package/dist/tools/core/skillManage.d.ts +71 -0
  913. package/dist/tools/core/skillManage.d.ts.map +1 -0
  914. package/dist/tools/core/skillManage.js +353 -0
  915. package/dist/tools/core/skillManage.js.map +1 -0
  916. package/dist/tools/core/skillView.d.ts +46 -0
  917. package/dist/tools/core/skillView.d.ts.map +1 -0
  918. package/dist/tools/core/skillView.js +101 -0
  919. package/dist/tools/core/skillView.js.map +1 -0
  920. package/dist/tools/core/teamTool.d.ts +71 -0
  921. package/dist/tools/core/teamTool.d.ts.map +1 -0
  922. package/dist/tools/core/teamTool.js +132 -0
  923. package/dist/tools/core/teamTool.js.map +1 -0
  924. package/dist/tools/core/textToSpeech.d.ts +25 -0
  925. package/dist/tools/core/textToSpeech.d.ts.map +1 -0
  926. package/dist/tools/core/textToSpeech.js +87 -0
  927. package/dist/tools/core/textToSpeech.js.map +1 -0
  928. package/dist/tools/core/transcribeAudio.d.ts +21 -0
  929. package/dist/tools/core/transcribeAudio.d.ts.map +1 -0
  930. package/dist/tools/core/transcribeAudio.js +27 -0
  931. package/dist/tools/core/transcribeAudio.js.map +1 -0
  932. package/dist/tools/core/useCrew.d.ts +38 -0
  933. package/dist/tools/core/useCrew.d.ts.map +1 -0
  934. package/dist/tools/core/useCrew.js +48 -0
  935. package/dist/tools/core/useCrew.js.map +1 -0
  936. package/dist/tools/core/useMCP.d.ts +40 -0
  937. package/dist/tools/core/useMCP.d.ts.map +1 -0
  938. package/dist/tools/core/useMCP.js +64 -0
  939. package/dist/tools/core/useMCP.js.map +1 -0
  940. package/dist/tools/core/watcherTool.d.ts +47 -0
  941. package/dist/tools/core/watcherTool.d.ts.map +1 -0
  942. package/dist/tools/core/watcherTool.js +119 -0
  943. package/dist/tools/core/watcherTool.js.map +1 -0
  944. package/dist/tools/core/webFetch.d.ts +48 -0
  945. package/dist/tools/core/webFetch.d.ts.map +1 -0
  946. package/dist/tools/core/webFetch.js +265 -0
  947. package/dist/tools/core/webFetch.js.map +1 -0
  948. package/dist/tools/core/webSearch.d.ts +55 -0
  949. package/dist/tools/core/webSearch.d.ts.map +1 -0
  950. package/dist/tools/core/webSearch.js +429 -0
  951. package/dist/tools/core/webSearch.js.map +1 -0
  952. package/dist/tools/core/writeFile.d.ts +27 -0
  953. package/dist/tools/core/writeFile.d.ts.map +1 -0
  954. package/dist/tools/core/writeFile.js +51 -0
  955. package/dist/tools/core/writeFile.js.map +1 -0
  956. package/dist/tools/registry.d.ts +36 -0
  957. package/dist/tools/registry.d.ts.map +1 -0
  958. package/dist/tools/registry.js +73 -0
  959. package/dist/tools/registry.js.map +1 -0
  960. package/dist/tools/types.d.ts +50 -0
  961. package/dist/tools/types.d.ts.map +1 -0
  962. package/dist/tools/types.js +20 -0
  963. package/dist/tools/types.js.map +1 -0
  964. package/dist/tunnels/TunnelManager.d.ts +52 -0
  965. package/dist/tunnels/TunnelManager.d.ts.map +1 -0
  966. package/dist/tunnels/TunnelManager.js +183 -0
  967. package/dist/tunnels/TunnelManager.js.map +1 -0
  968. package/dist/tunnels/urls.d.ts +20 -0
  969. package/dist/tunnels/urls.d.ts.map +1 -0
  970. package/dist/tunnels/urls.js +22 -0
  971. package/dist/tunnels/urls.js.map +1 -0
  972. package/dist/util/errors.d.ts +54 -0
  973. package/dist/util/errors.d.ts.map +1 -0
  974. package/dist/util/errors.js +102 -0
  975. package/dist/util/errors.js.map +1 -0
  976. package/dist/util/logger.d.ts +21 -0
  977. package/dist/util/logger.d.ts.map +1 -0
  978. package/dist/util/logger.js +62 -0
  979. package/dist/util/logger.js.map +1 -0
  980. package/dist/util/msgText.d.ts +16 -0
  981. package/dist/util/msgText.d.ts.map +1 -0
  982. package/dist/util/msgText.js +65 -0
  983. package/dist/util/msgText.js.map +1 -0
  984. package/dist/util/result.d.ts +24 -0
  985. package/dist/util/result.d.ts.map +1 -0
  986. package/dist/util/result.js +35 -0
  987. package/dist/util/result.js.map +1 -0
  988. package/dist/util/tokenEstimate.d.ts +12 -0
  989. package/dist/util/tokenEstimate.d.ts.map +1 -0
  990. package/dist/util/tokenEstimate.js +22 -0
  991. package/dist/util/tokenEstimate.js.map +1 -0
  992. package/dist/voice/DaemoraLLM.d.ts +44 -0
  993. package/dist/voice/DaemoraLLM.d.ts.map +1 -0
  994. package/dist/voice/DaemoraLLM.js +185 -0
  995. package/dist/voice/DaemoraLLM.js.map +1 -0
  996. package/dist/voice/ElevenLabsSTT.d.ts +41 -0
  997. package/dist/voice/ElevenLabsSTT.d.ts.map +1 -0
  998. package/dist/voice/ElevenLabsSTT.js +98 -0
  999. package/dist/voice/ElevenLabsSTT.js.map +1 -0
  1000. package/dist/voice/GroqTTS.d.ts +38 -0
  1001. package/dist/voice/GroqTTS.d.ts.map +1 -0
  1002. package/dist/voice/GroqTTS.js +208 -0
  1003. package/dist/voice/GroqTTS.js.map +1 -0
  1004. package/dist/voice/LiveKitServer.d.ts +30 -0
  1005. package/dist/voice/LiveKitServer.d.ts.map +1 -0
  1006. package/dist/voice/LiveKitServer.js +119 -0
  1007. package/dist/voice/LiveKitServer.js.map +1 -0
  1008. package/dist/voice/LiveKitToken.d.ts +25 -0
  1009. package/dist/voice/LiveKitToken.d.ts.map +1 -0
  1010. package/dist/voice/LiveKitToken.js +44 -0
  1011. package/dist/voice/LiveKitToken.js.map +1 -0
  1012. package/dist/voice/SidecarSupervisor.d.ts +39 -0
  1013. package/dist/voice/SidecarSupervisor.d.ts.map +1 -0
  1014. package/dist/voice/SidecarSupervisor.js +194 -0
  1015. package/dist/voice/SidecarSupervisor.js.map +1 -0
  1016. package/dist/voice/VoiceAgent.d.ts +23 -0
  1017. package/dist/voice/VoiceAgent.d.ts.map +1 -0
  1018. package/dist/voice/VoiceAgent.js +265 -0
  1019. package/dist/voice/VoiceAgent.js.map +1 -0
  1020. package/dist/voice/VoiceProviders.d.ts +29 -0
  1021. package/dist/voice/VoiceProviders.d.ts.map +1 -0
  1022. package/dist/voice/VoiceProviders.js +177 -0
  1023. package/dist/voice/VoiceProviders.js.map +1 -0
  1024. package/dist/voice/VoiceSession.d.ts +106 -0
  1025. package/dist/voice/VoiceSession.d.ts.map +1 -0
  1026. package/dist/voice/VoiceSession.js +454 -0
  1027. package/dist/voice/VoiceSession.js.map +1 -0
  1028. package/dist/voice/VoiceSocket.d.ts +49 -0
  1029. package/dist/voice/VoiceSocket.d.ts.map +1 -0
  1030. package/dist/voice/VoiceSocket.js +274 -0
  1031. package/dist/voice/VoiceSocket.js.map +1 -0
  1032. package/dist/voice/stt/DeepgramSTT.d.ts +26 -0
  1033. package/dist/voice/stt/DeepgramSTT.d.ts.map +1 -0
  1034. package/dist/voice/stt/DeepgramSTT.js +188 -0
  1035. package/dist/voice/stt/DeepgramSTT.js.map +1 -0
  1036. package/dist/voice/stt/GroqSTT.d.ts +28 -0
  1037. package/dist/voice/stt/GroqSTT.d.ts.map +1 -0
  1038. package/dist/voice/stt/GroqSTT.js +169 -0
  1039. package/dist/voice/stt/GroqSTT.js.map +1 -0
  1040. package/dist/voice/stt/STTAdapter.d.ts +47 -0
  1041. package/dist/voice/stt/STTAdapter.d.ts.map +1 -0
  1042. package/dist/voice/stt/STTAdapter.js +27 -0
  1043. package/dist/voice/stt/STTAdapter.js.map +1 -0
  1044. package/dist/voice/transcribe.d.ts +33 -0
  1045. package/dist/voice/transcribe.d.ts.map +1 -0
  1046. package/dist/voice/transcribe.js +73 -0
  1047. package/dist/voice/transcribe.js.map +1 -0
  1048. package/dist/voice/transcriptFilter.d.ts +16 -0
  1049. package/dist/voice/transcriptFilter.d.ts.map +1 -0
  1050. package/dist/voice/transcriptFilter.js +36 -0
  1051. package/dist/voice/transcriptFilter.js.map +1 -0
  1052. package/dist/voice/tts/CartesiaTTS.d.ts +31 -0
  1053. package/dist/voice/tts/CartesiaTTS.d.ts.map +1 -0
  1054. package/dist/voice/tts/CartesiaTTS.js +201 -0
  1055. package/dist/voice/tts/CartesiaTTS.js.map +1 -0
  1056. package/dist/voice/tts/ElevenLabsTTS.d.ts +29 -0
  1057. package/dist/voice/tts/ElevenLabsTTS.d.ts.map +1 -0
  1058. package/dist/voice/tts/ElevenLabsTTS.js +210 -0
  1059. package/dist/voice/tts/ElevenLabsTTS.js.map +1 -0
  1060. package/dist/voice/tts/OpenAITTS.d.ts +23 -0
  1061. package/dist/voice/tts/OpenAITTS.d.ts.map +1 -0
  1062. package/dist/voice/tts/OpenAITTS.js +124 -0
  1063. package/dist/voice/tts/OpenAITTS.js.map +1 -0
  1064. package/dist/voice/tts/TTSAdapter.d.ts +46 -0
  1065. package/dist/voice/tts/TTSAdapter.d.ts.map +1 -0
  1066. package/dist/voice/tts/TTSAdapter.js +26 -0
  1067. package/dist/voice/tts/TTSAdapter.js.map +1 -0
  1068. package/dist/voice-worker.mjs +607 -0
  1069. package/dist/watchers/FileWatcher.d.ts +47 -0
  1070. package/dist/watchers/FileWatcher.d.ts.map +1 -0
  1071. package/dist/watchers/FileWatcher.js +103 -0
  1072. package/dist/watchers/FileWatcher.js.map +1 -0
  1073. package/dist/watchers/IntegrationWatcher.d.ts +68 -0
  1074. package/dist/watchers/IntegrationWatcher.d.ts.map +1 -0
  1075. package/dist/watchers/IntegrationWatcher.js +347 -0
  1076. package/dist/watchers/IntegrationWatcher.js.map +1 -0
  1077. package/dist/watchers/PollWatcher.d.ts +54 -0
  1078. package/dist/watchers/PollWatcher.d.ts.map +1 -0
  1079. package/dist/watchers/PollWatcher.js +135 -0
  1080. package/dist/watchers/PollWatcher.js.map +1 -0
  1081. package/dist/watchers/WatcherRunner.d.ts +49 -0
  1082. package/dist/watchers/WatcherRunner.d.ts.map +1 -0
  1083. package/dist/watchers/WatcherRunner.js +203 -0
  1084. package/dist/watchers/WatcherRunner.js.map +1 -0
  1085. package/dist/watchers/WatcherStore.d.ts +43 -0
  1086. package/dist/watchers/WatcherStore.d.ts.map +1 -0
  1087. package/dist/watchers/WatcherStore.js +78 -0
  1088. package/dist/watchers/WatcherStore.js.map +1 -0
  1089. package/dist/webhooks/WebhookHandler.d.ts +36 -0
  1090. package/dist/webhooks/WebhookHandler.d.ts.map +1 -0
  1091. package/dist/webhooks/WebhookHandler.js +264 -0
  1092. package/dist/webhooks/WebhookHandler.js.map +1 -0
  1093. package/dist/webhooks/WebhookTokenStore.d.ts +48 -0
  1094. package/dist/webhooks/WebhookTokenStore.d.ts.map +1 -0
  1095. package/dist/webhooks/WebhookTokenStore.js +136 -0
  1096. package/dist/webhooks/WebhookTokenStore.js.map +1 -0
  1097. package/dist/webhooks/hmac.d.ts +43 -0
  1098. package/dist/webhooks/hmac.d.ts.map +1 -0
  1099. package/dist/webhooks/hmac.js +98 -0
  1100. package/dist/webhooks/hmac.js.map +1 -0
  1101. package/dist/webhooks/watcherTemplates.d.ts +21 -0
  1102. package/dist/webhooks/watcherTemplates.d.ts.map +1 -0
  1103. package/dist/webhooks/watcherTemplates.js +164 -0
  1104. package/dist/webhooks/watcherTemplates.js.map +1 -0
  1105. package/package.json +119 -0
  1106. package/public/architecture.svg +99 -0
  1107. package/public/banner.png +0 -0
  1108. package/public/banner.svg +141 -0
  1109. package/public/multi-agent.svg +109 -0
  1110. package/public/security.svg +84 -0
  1111. package/public/steer-inject.svg +73 -0
  1112. package/public/task-lifecycle.svg +77 -0
  1113. package/skills/_template/SKILL.md +11 -0
  1114. package/skills/api-development.md +35 -0
  1115. package/skills/apple-notes/SKILL.md +77 -0
  1116. package/skills/apple-reminders/SKILL.md +118 -0
  1117. package/skills/artifacts-builder/SKILL.md +74 -0
  1118. package/skills/artifacts-builder/scripts/bundle-artifact.sh +54 -0
  1119. package/skills/artifacts-builder/scripts/init-artifact.sh +322 -0
  1120. package/skills/artifacts-builder/scripts/shadcn-components.tar.gz +0 -0
  1121. package/skills/brand-guidelines.md +73 -0
  1122. package/skills/browser.md +77 -0
  1123. package/skills/camsnap/SKILL.md +45 -0
  1124. package/skills/changelog-generator.md +104 -0
  1125. package/skills/coding-agent/SKILL.md +316 -0
  1126. package/skills/content-research-writer.md +538 -0
  1127. package/skills/create-new-skill.md +564 -0
  1128. package/skills/data-analysis.md +27 -0
  1129. package/skills/debugging.md +33 -0
  1130. package/skills/devops.md +37 -0
  1131. package/skills/discord/SKILL.md +197 -0
  1132. package/skills/document-docx.md +197 -0
  1133. package/skills/document-pptx.md +484 -0
  1134. package/skills/document-xlsx.md +289 -0
  1135. package/skills/documents.md +13 -0
  1136. package/skills/domain-name-brainstormer.md +212 -0
  1137. package/skills/email.md +13 -0
  1138. package/skills/example-pdf/SKILL.md +17 -0
  1139. package/skills/file-organizer.md +433 -0
  1140. package/skills/frontend-design.md +42 -0
  1141. package/skills/gif-search.md +53 -0
  1142. package/skills/github/SKILL.md +163 -0
  1143. package/skills/google-workspace.md +64 -0
  1144. package/skills/image-enhancer.md +99 -0
  1145. package/skills/image-gen.md +48 -0
  1146. package/skills/invoice-organizer.md +446 -0
  1147. package/skills/lead-research-assistant.md +199 -0
  1148. package/skills/link-understanding.md +21 -0
  1149. package/skills/macos-automation.md +62 -0
  1150. package/skills/mcp-builder/SKILL.md +328 -0
  1151. package/skills/mcp-builder/reference/evaluation.md +602 -0
  1152. package/skills/mcp-builder/reference/mcp_best_practices.md +915 -0
  1153. package/skills/mcp-builder/reference/node_mcp_server.md +916 -0
  1154. package/skills/mcp-builder/reference/python_mcp_server.md +752 -0
  1155. package/skills/mcp-builder/scripts/connections.py +151 -0
  1156. package/skills/mcp-builder/scripts/evaluation.py +373 -0
  1157. package/skills/mcp-builder/scripts/example_evaluation.xml +22 -0
  1158. package/skills/mcp-builder/scripts/requirements.txt +2 -0
  1159. package/skills/meeting-attendance.md +37 -0
  1160. package/skills/meeting-insights-analyzer.md +327 -0
  1161. package/skills/model-usage/SKILL.md +69 -0
  1162. package/skills/model-usage/references/codexbar-cli.md +33 -0
  1163. package/skills/model-usage/scripts/model_usage.py +320 -0
  1164. package/skills/model-usage/scripts/test_model_usage.py +40 -0
  1165. package/skills/notion/SKILL.md +174 -0
  1166. package/skills/obsidian/SKILL.md +81 -0
  1167. package/skills/orchestration.md +114 -0
  1168. package/skills/pdf.md +60 -0
  1169. package/skills/planning/SKILL.md +98 -0
  1170. package/skills/planning.md +168 -0
  1171. package/skills/raffle-winner-picker.md +159 -0
  1172. package/skills/remotion.md +126 -0
  1173. package/skills/research.md +13 -0
  1174. package/skills/skill-creator/SKILL.md +372 -0
  1175. package/skills/skill-creator/license.txt +202 -0
  1176. package/skills/skill-creator/scripts/init_skill.py +378 -0
  1177. package/skills/skill-creator/scripts/package_skill.py +139 -0
  1178. package/skills/skill-creator/scripts/quick_validate.py +159 -0
  1179. package/skills/skill-creator/scripts/test_package_skill.py +160 -0
  1180. package/skills/skill-creator/scripts/test_quick_validate.py +72 -0
  1181. package/skills/slack/SKILL.md +144 -0
  1182. package/skills/slack-gif-creator/SKILL.md +646 -0
  1183. package/skills/slack-gif-creator/core/color_palettes.py +302 -0
  1184. package/skills/slack-gif-creator/core/easing.py +230 -0
  1185. package/skills/slack-gif-creator/core/frame_composer.py +469 -0
  1186. package/skills/slack-gif-creator/core/gif_builder.py +246 -0
  1187. package/skills/slack-gif-creator/core/typography.py +357 -0
  1188. package/skills/slack-gif-creator/core/validators.py +264 -0
  1189. package/skills/slack-gif-creator/core/visual_effects.py +494 -0
  1190. package/skills/slack-gif-creator/requirements.txt +4 -0
  1191. package/skills/slack-gif-creator/templates/bounce.py +106 -0
  1192. package/skills/slack-gif-creator/templates/explode.py +331 -0
  1193. package/skills/slack-gif-creator/templates/fade.py +329 -0
  1194. package/skills/slack-gif-creator/templates/flip.py +291 -0
  1195. package/skills/slack-gif-creator/templates/kaleidoscope.py +211 -0
  1196. package/skills/slack-gif-creator/templates/morph.py +329 -0
  1197. package/skills/slack-gif-creator/templates/move.py +293 -0
  1198. package/skills/slack-gif-creator/templates/pulse.py +268 -0
  1199. package/skills/slack-gif-creator/templates/shake.py +127 -0
  1200. package/skills/slack-gif-creator/templates/slide.py +291 -0
  1201. package/skills/slack-gif-creator/templates/spin.py +269 -0
  1202. package/skills/slack-gif-creator/templates/wiggle.py +300 -0
  1203. package/skills/slack-gif-creator/templates/zoom.py +312 -0
  1204. package/skills/summarize/SKILL.md +87 -0
  1205. package/skills/system-admin.md +44 -0
  1206. package/skills/tailored-resume-generator.md +345 -0
  1207. package/skills/task-decomposition/SKILL.md +113 -0
  1208. package/skills/theme-factory/SKILL.md +59 -0
  1209. package/skills/theme-factory/theme-showcase.pdf +0 -0
  1210. package/skills/theme-factory/themes/arctic-frost.md +19 -0
  1211. package/skills/theme-factory/themes/botanical-garden.md +19 -0
  1212. package/skills/theme-factory/themes/desert-rose.md +19 -0
  1213. package/skills/theme-factory/themes/forest-canopy.md +19 -0
  1214. package/skills/theme-factory/themes/golden-hour.md +19 -0
  1215. package/skills/theme-factory/themes/midnight-galaxy.md +19 -0
  1216. package/skills/theme-factory/themes/modern-minimalist.md +19 -0
  1217. package/skills/theme-factory/themes/ocean-depths.md +19 -0
  1218. package/skills/theme-factory/themes/sunset-boulevard.md +19 -0
  1219. package/skills/theme-factory/themes/tech-innovation.md +19 -0
  1220. package/skills/things-mac/SKILL.md +86 -0
  1221. package/skills/tmux/SKILL.md +170 -0
  1222. package/skills/tmux/scripts/find-sessions.sh +112 -0
  1223. package/skills/tmux/scripts/wait-for-text.sh +83 -0
  1224. package/skills/trello/SKILL.md +108 -0
  1225. package/skills/video-downloader.md +99 -0
  1226. package/skills/video-frames/SKILL.md +46 -0
  1227. package/skills/video-frames/scripts/frame.sh +81 -0
  1228. package/skills/weather/SKILL.md +129 -0
  1229. package/skills/web-development.md +32 -0
  1230. package/skills/webapp-testing/SKILL.md +96 -0
  1231. package/skills/webapp-testing/examples/console_logging.py +35 -0
  1232. package/skills/webapp-testing/examples/element_discovery.py +40 -0
  1233. package/skills/webapp-testing/examples/static_html_automation.py +33 -0
  1234. package/skills/webapp-testing/scripts/with_server.py +106 -0
  1235. package/ui/dist/assets/index-DuybLBDW.css +1 -0
  1236. package/ui/dist/assets/index-kK4jTnXz.js +569 -0
  1237. package/ui/dist/favicon.svg +29 -0
  1238. package/ui/dist/index.html +16 -0
@@ -0,0 +1,569 @@
1
+ function OI(t,e){for(var n=0;n<e.length;n++){const r=e[n];if(typeof r!="string"&&!Array.isArray(r)){for(const i in r)if(i!=="default"&&!(i in t)){const s=Object.getOwnPropertyDescriptor(r,i);s&&Object.defineProperty(t,i,s.get?s:{enumerable:!0,get:()=>r[i]})}}}return Object.freeze(Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}))}(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))r(i);new MutationObserver(i=>{for(const s of i)if(s.type==="childList")for(const a of s.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&r(a)}).observe(document,{childList:!0,subtree:!0});function n(i){const s={};return i.integrity&&(s.integrity=i.integrity),i.referrerPolicy&&(s.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?s.credentials="include":i.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function r(i){if(i.ep)return;i.ep=!0;const s=n(i);fetch(i.href,s)}})();function up(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var jg={exports:{}},mu={},Pg={exports:{}},Mt={};/**
2
+ * @license React
3
+ * react.production.min.js
4
+ *
5
+ * Copyright (c) Facebook, Inc. and its affiliates.
6
+ *
7
+ * This source code is licensed under the MIT license found in the
8
+ * LICENSE file in the root directory of this source tree.
9
+ */var Mw;function LI(){if(Mw)return Mt;Mw=1;var t=Symbol.for("react.element"),e=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),s=Symbol.for("react.provider"),a=Symbol.for("react.context"),c=Symbol.for("react.forward_ref"),h=Symbol.for("react.suspense"),d=Symbol.for("react.memo"),f=Symbol.for("react.lazy"),p=Symbol.iterator;function g(z){return z===null||typeof z!="object"?null:(z=p&&z[p]||z["@@iterator"],typeof z=="function"?z:null)}var v={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},k=Object.assign,w={};function S(z,ee,B){this.props=z,this.context=ee,this.refs=w,this.updater=B||v}S.prototype.isReactComponent={},S.prototype.setState=function(z,ee){if(typeof z!="object"&&typeof z!="function"&&z!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,z,ee,"setState")},S.prototype.forceUpdate=function(z){this.updater.enqueueForceUpdate(this,z,"forceUpdate")};function T(){}T.prototype=S.prototype;function C(z,ee,B){this.props=z,this.context=ee,this.refs=w,this.updater=B||v}var j=C.prototype=new T;j.constructor=C,k(j,S.prototype),j.isPureReactComponent=!0;var R=Array.isArray,_=Object.prototype.hasOwnProperty,I={current:null},M={key:!0,ref:!0,__self:!0,__source:!0};function L(z,ee,B){var X,ye={},se=null,oe=null;if(ee!=null)for(X in ee.ref!==void 0&&(oe=ee.ref),ee.key!==void 0&&(se=""+ee.key),ee)_.call(ee,X)&&!M.hasOwnProperty(X)&&(ye[X]=ee[X]);var U=arguments.length-2;if(U===1)ye.children=B;else if(1<U){for(var ue=Array(U),ke=0;ke<U;ke++)ue[ke]=arguments[ke+2];ye.children=ue}if(z&&z.defaultProps)for(X in U=z.defaultProps,U)ye[X]===void 0&&(ye[X]=U[X]);return{$$typeof:t,type:z,key:se,ref:oe,props:ye,_owner:I.current}}function $(z,ee){return{$$typeof:t,type:z.type,key:ee,ref:z.ref,props:z.props,_owner:z._owner}}function E(z){return typeof z=="object"&&z!==null&&z.$$typeof===t}function P(z){var ee={"=":"=0",":":"=2"};return"$"+z.replace(/[=:]/g,function(B){return ee[B]})}var V=/\/+/g;function F(z,ee){return typeof z=="object"&&z!==null&&z.key!=null?P(""+z.key):ee.toString(36)}function K(z,ee,B,X,ye){var se=typeof z;(se==="undefined"||se==="boolean")&&(z=null);var oe=!1;if(z===null)oe=!0;else switch(se){case"string":case"number":oe=!0;break;case"object":switch(z.$$typeof){case t:case e:oe=!0}}if(oe)return oe=z,ye=ye(oe),z=X===""?"."+F(oe,0):X,R(ye)?(B="",z!=null&&(B=z.replace(V,"$&/")+"/"),K(ye,ee,B,"",function(ke){return ke})):ye!=null&&(E(ye)&&(ye=$(ye,B+(!ye.key||oe&&oe.key===ye.key?"":(""+ye.key).replace(V,"$&/")+"/")+z)),ee.push(ye)),1;if(oe=0,X=X===""?".":X+":",R(z))for(var U=0;U<z.length;U++){se=z[U];var ue=X+F(se,U);oe+=K(se,ee,B,ue,ye)}else if(ue=g(z),typeof ue=="function")for(z=ue.call(z),U=0;!(se=z.next()).done;)se=se.value,ue=X+F(se,U++),oe+=K(se,ee,B,ue,ye);else if(se==="object")throw ee=String(z),Error("Objects are not valid as a React child (found: "+(ee==="[object Object]"?"object with keys {"+Object.keys(z).join(", ")+"}":ee)+"). If you meant to render a collection of children, use an array instead.");return oe}function J(z,ee,B){if(z==null)return z;var X=[],ye=0;return K(z,X,"","",function(se){return ee.call(B,se,ye++)}),X}function Q(z){if(z._status===-1){var ee=z._result;ee=ee(),ee.then(function(B){(z._status===0||z._status===-1)&&(z._status=1,z._result=B)},function(B){(z._status===0||z._status===-1)&&(z._status=2,z._result=B)}),z._status===-1&&(z._status=0,z._result=ee)}if(z._status===1)return z._result.default;throw z._result}var Z={current:null},D={transition:null},ne={ReactCurrentDispatcher:Z,ReactCurrentBatchConfig:D,ReactCurrentOwner:I};function A(){throw Error("act(...) is not supported in production builds of React.")}return Mt.Children={map:J,forEach:function(z,ee,B){J(z,function(){ee.apply(this,arguments)},B)},count:function(z){var ee=0;return J(z,function(){ee++}),ee},toArray:function(z){return J(z,function(ee){return ee})||[]},only:function(z){if(!E(z))throw Error("React.Children.only expected to receive a single React element child.");return z}},Mt.Component=S,Mt.Fragment=n,Mt.Profiler=i,Mt.PureComponent=C,Mt.StrictMode=r,Mt.Suspense=h,Mt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=ne,Mt.act=A,Mt.cloneElement=function(z,ee,B){if(z==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+z+".");var X=k({},z.props),ye=z.key,se=z.ref,oe=z._owner;if(ee!=null){if(ee.ref!==void 0&&(se=ee.ref,oe=I.current),ee.key!==void 0&&(ye=""+ee.key),z.type&&z.type.defaultProps)var U=z.type.defaultProps;for(ue in ee)_.call(ee,ue)&&!M.hasOwnProperty(ue)&&(X[ue]=ee[ue]===void 0&&U!==void 0?U[ue]:ee[ue])}var ue=arguments.length-2;if(ue===1)X.children=B;else if(1<ue){U=Array(ue);for(var ke=0;ke<ue;ke++)U[ke]=arguments[ke+2];X.children=U}return{$$typeof:t,type:z.type,key:ye,ref:se,props:X,_owner:oe}},Mt.createContext=function(z){return z={$$typeof:a,_currentValue:z,_currentValue2:z,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},z.Provider={$$typeof:s,_context:z},z.Consumer=z},Mt.createElement=L,Mt.createFactory=function(z){var ee=L.bind(null,z);return ee.type=z,ee},Mt.createRef=function(){return{current:null}},Mt.forwardRef=function(z){return{$$typeof:c,render:z}},Mt.isValidElement=E,Mt.lazy=function(z){return{$$typeof:f,_payload:{_status:-1,_result:z},_init:Q}},Mt.memo=function(z,ee){return{$$typeof:d,type:z,compare:ee===void 0?null:ee}},Mt.startTransition=function(z){var ee=D.transition;D.transition={};try{z()}finally{D.transition=ee}},Mt.unstable_act=A,Mt.useCallback=function(z,ee){return Z.current.useCallback(z,ee)},Mt.useContext=function(z){return Z.current.useContext(z)},Mt.useDebugValue=function(){},Mt.useDeferredValue=function(z){return Z.current.useDeferredValue(z)},Mt.useEffect=function(z,ee){return Z.current.useEffect(z,ee)},Mt.useId=function(){return Z.current.useId()},Mt.useImperativeHandle=function(z,ee,B){return Z.current.useImperativeHandle(z,ee,B)},Mt.useInsertionEffect=function(z,ee){return Z.current.useInsertionEffect(z,ee)},Mt.useLayoutEffect=function(z,ee){return Z.current.useLayoutEffect(z,ee)},Mt.useMemo=function(z,ee){return Z.current.useMemo(z,ee)},Mt.useReducer=function(z,ee,B){return Z.current.useReducer(z,ee,B)},Mt.useRef=function(z){return Z.current.useRef(z)},Mt.useState=function(z){return Z.current.useState(z)},Mt.useSyncExternalStore=function(z,ee,B){return Z.current.useSyncExternalStore(z,ee,B)},Mt.useTransition=function(){return Z.current.useTransition()},Mt.version="18.3.1",Mt}var Dw;function oy(){return Dw||(Dw=1,Pg.exports=LI()),Pg.exports}/**
10
+ * @license React
11
+ * react-jsx-runtime.production.min.js
12
+ *
13
+ * Copyright (c) Facebook, Inc. and its affiliates.
14
+ *
15
+ * This source code is licensed under the MIT license found in the
16
+ * LICENSE file in the root directory of this source tree.
17
+ */var Aw;function FI(){if(Aw)return mu;Aw=1;var t=oy(),e=Symbol.for("react.element"),n=Symbol.for("react.fragment"),r=Object.prototype.hasOwnProperty,i=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,s={key:!0,ref:!0,__self:!0,__source:!0};function a(c,h,d){var f,p={},g=null,v=null;d!==void 0&&(g=""+d),h.key!==void 0&&(g=""+h.key),h.ref!==void 0&&(v=h.ref);for(f in h)r.call(h,f)&&!s.hasOwnProperty(f)&&(p[f]=h[f]);if(c&&c.defaultProps)for(f in h=c.defaultProps,h)p[f]===void 0&&(p[f]=h[f]);return{$$typeof:e,type:c,key:g,ref:v,props:p,_owner:i.current}}return mu.Fragment=n,mu.jsx=a,mu.jsxs=a,mu}var Ow;function UI(){return Ow||(Ow=1,jg.exports=FI()),jg.exports}var o=UI(),Ah={},_g={exports:{}},Vr={},Rg={exports:{}},Ig={};/**
18
+ * @license React
19
+ * scheduler.production.min.js
20
+ *
21
+ * Copyright (c) Facebook, Inc. and its affiliates.
22
+ *
23
+ * This source code is licensed under the MIT license found in the
24
+ * LICENSE file in the root directory of this source tree.
25
+ */var Lw;function BI(){return Lw||(Lw=1,(function(t){function e(D,ne){var A=D.length;D.push(ne);e:for(;0<A;){var z=A-1>>>1,ee=D[z];if(0<i(ee,ne))D[z]=ne,D[A]=ee,A=z;else break e}}function n(D){return D.length===0?null:D[0]}function r(D){if(D.length===0)return null;var ne=D[0],A=D.pop();if(A!==ne){D[0]=A;e:for(var z=0,ee=D.length,B=ee>>>1;z<B;){var X=2*(z+1)-1,ye=D[X],se=X+1,oe=D[se];if(0>i(ye,A))se<ee&&0>i(oe,ye)?(D[z]=oe,D[se]=A,z=se):(D[z]=ye,D[X]=A,z=X);else if(se<ee&&0>i(oe,A))D[z]=oe,D[se]=A,z=se;else break e}}return ne}function i(D,ne){var A=D.sortIndex-ne.sortIndex;return A!==0?A:D.id-ne.id}if(typeof performance=="object"&&typeof performance.now=="function"){var s=performance;t.unstable_now=function(){return s.now()}}else{var a=Date,c=a.now();t.unstable_now=function(){return a.now()-c}}var h=[],d=[],f=1,p=null,g=3,v=!1,k=!1,w=!1,S=typeof setTimeout=="function"?setTimeout:null,T=typeof clearTimeout=="function"?clearTimeout:null,C=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function j(D){for(var ne=n(d);ne!==null;){if(ne.callback===null)r(d);else if(ne.startTime<=D)r(d),ne.sortIndex=ne.expirationTime,e(h,ne);else break;ne=n(d)}}function R(D){if(w=!1,j(D),!k)if(n(h)!==null)k=!0,Q(_);else{var ne=n(d);ne!==null&&Z(R,ne.startTime-D)}}function _(D,ne){k=!1,w&&(w=!1,T(L),L=-1),v=!0;var A=g;try{for(j(ne),p=n(h);p!==null&&(!(p.expirationTime>ne)||D&&!P());){var z=p.callback;if(typeof z=="function"){p.callback=null,g=p.priorityLevel;var ee=z(p.expirationTime<=ne);ne=t.unstable_now(),typeof ee=="function"?p.callback=ee:p===n(h)&&r(h),j(ne)}else r(h);p=n(h)}if(p!==null)var B=!0;else{var X=n(d);X!==null&&Z(R,X.startTime-ne),B=!1}return B}finally{p=null,g=A,v=!1}}var I=!1,M=null,L=-1,$=5,E=-1;function P(){return!(t.unstable_now()-E<$)}function V(){if(M!==null){var D=t.unstable_now();E=D;var ne=!0;try{ne=M(!0,D)}finally{ne?F():(I=!1,M=null)}}else I=!1}var F;if(typeof C=="function")F=function(){C(V)};else if(typeof MessageChannel<"u"){var K=new MessageChannel,J=K.port2;K.port1.onmessage=V,F=function(){J.postMessage(null)}}else F=function(){S(V,0)};function Q(D){M=D,I||(I=!0,F())}function Z(D,ne){L=S(function(){D(t.unstable_now())},ne)}t.unstable_IdlePriority=5,t.unstable_ImmediatePriority=1,t.unstable_LowPriority=4,t.unstable_NormalPriority=3,t.unstable_Profiling=null,t.unstable_UserBlockingPriority=2,t.unstable_cancelCallback=function(D){D.callback=null},t.unstable_continueExecution=function(){k||v||(k=!0,Q(_))},t.unstable_forceFrameRate=function(D){0>D||125<D?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):$=0<D?Math.floor(1e3/D):5},t.unstable_getCurrentPriorityLevel=function(){return g},t.unstable_getFirstCallbackNode=function(){return n(h)},t.unstable_next=function(D){switch(g){case 1:case 2:case 3:var ne=3;break;default:ne=g}var A=g;g=ne;try{return D()}finally{g=A}},t.unstable_pauseExecution=function(){},t.unstable_requestPaint=function(){},t.unstable_runWithPriority=function(D,ne){switch(D){case 1:case 2:case 3:case 4:case 5:break;default:D=3}var A=g;g=D;try{return ne()}finally{g=A}},t.unstable_scheduleCallback=function(D,ne,A){var z=t.unstable_now();switch(typeof A=="object"&&A!==null?(A=A.delay,A=typeof A=="number"&&0<A?z+A:z):A=z,D){case 1:var ee=-1;break;case 2:ee=250;break;case 5:ee=1073741823;break;case 4:ee=1e4;break;default:ee=5e3}return ee=A+ee,D={id:f++,callback:ne,priorityLevel:D,startTime:A,expirationTime:ee,sortIndex:-1},A>z?(D.sortIndex=A,e(d,D),n(h)===null&&D===n(d)&&(w?(T(L),L=-1):w=!0,Z(R,A-z))):(D.sortIndex=ee,e(h,D),k||v||(k=!0,Q(_))),D},t.unstable_shouldYield=P,t.unstable_wrapCallback=function(D){var ne=g;return function(){var A=g;g=ne;try{return D.apply(this,arguments)}finally{g=A}}}})(Ig)),Ig}var Fw;function zI(){return Fw||(Fw=1,Rg.exports=BI()),Rg.exports}/**
26
+ * @license React
27
+ * react-dom.production.min.js
28
+ *
29
+ * Copyright (c) Facebook, Inc. and its affiliates.
30
+ *
31
+ * This source code is licensed under the MIT license found in the
32
+ * LICENSE file in the root directory of this source tree.
33
+ */var Uw;function $I(){if(Uw)return Vr;Uw=1;var t=oy(),e=zI();function n(l){for(var u="https://reactjs.org/docs/error-decoder.html?invariant="+l,m=1;m<arguments.length;m++)u+="&args[]="+encodeURIComponent(arguments[m]);return"Minified React error #"+l+"; visit "+u+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var r=new Set,i={};function s(l,u){a(l,u),a(l+"Capture",u)}function a(l,u){for(i[l]=u,l=0;l<u.length;l++)r.add(u[l])}var c=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),h=Object.prototype.hasOwnProperty,d=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,f={},p={};function g(l){return h.call(p,l)?!0:h.call(f,l)?!1:d.test(l)?p[l]=!0:(f[l]=!0,!1)}function v(l,u,m,y){if(m!==null&&m.type===0)return!1;switch(typeof u){case"function":case"symbol":return!0;case"boolean":return y?!1:m!==null?!m.acceptsBooleans:(l=l.toLowerCase().slice(0,5),l!=="data-"&&l!=="aria-");default:return!1}}function k(l,u,m,y){if(u===null||typeof u>"u"||v(l,u,m,y))return!0;if(y)return!1;if(m!==null)switch(m.type){case 3:return!u;case 4:return u===!1;case 5:return isNaN(u);case 6:return isNaN(u)||1>u}return!1}function w(l,u,m,y,b,N,O){this.acceptsBooleans=u===2||u===3||u===4,this.attributeName=y,this.attributeNamespace=b,this.mustUseProperty=m,this.propertyName=l,this.type=u,this.sanitizeURL=N,this.removeEmptyString=O}var S={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(l){S[l]=new w(l,0,!1,l,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(l){var u=l[0];S[u]=new w(u,1,!1,l[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(l){S[l]=new w(l,2,!1,l.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(l){S[l]=new w(l,2,!1,l,null,!1,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(l){S[l]=new w(l,3,!1,l.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(l){S[l]=new w(l,3,!0,l,null,!1,!1)}),["capture","download"].forEach(function(l){S[l]=new w(l,4,!1,l,null,!1,!1)}),["cols","rows","size","span"].forEach(function(l){S[l]=new w(l,6,!1,l,null,!1,!1)}),["rowSpan","start"].forEach(function(l){S[l]=new w(l,5,!1,l.toLowerCase(),null,!1,!1)});var T=/[\-:]([a-z])/g;function C(l){return l[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(l){var u=l.replace(T,C);S[u]=new w(u,1,!1,l,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(l){var u=l.replace(T,C);S[u]=new w(u,1,!1,l,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(l){var u=l.replace(T,C);S[u]=new w(u,1,!1,l,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(l){S[l]=new w(l,1,!1,l.toLowerCase(),null,!1,!1)}),S.xlinkHref=new w("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(l){S[l]=new w(l,1,!1,l.toLowerCase(),null,!0,!0)});function j(l,u,m,y){var b=S.hasOwnProperty(u)?S[u]:null;(b!==null?b.type!==0:y||!(2<u.length)||u[0]!=="o"&&u[0]!=="O"||u[1]!=="n"&&u[1]!=="N")&&(k(u,m,b,y)&&(m=null),y||b===null?g(u)&&(m===null?l.removeAttribute(u):l.setAttribute(u,""+m)):b.mustUseProperty?l[b.propertyName]=m===null?b.type===3?!1:"":m:(u=b.attributeName,y=b.attributeNamespace,m===null?l.removeAttribute(u):(b=b.type,m=b===3||b===4&&m===!0?"":""+m,y?l.setAttributeNS(y,u,m):l.setAttribute(u,m))))}var R=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,_=Symbol.for("react.element"),I=Symbol.for("react.portal"),M=Symbol.for("react.fragment"),L=Symbol.for("react.strict_mode"),$=Symbol.for("react.profiler"),E=Symbol.for("react.provider"),P=Symbol.for("react.context"),V=Symbol.for("react.forward_ref"),F=Symbol.for("react.suspense"),K=Symbol.for("react.suspense_list"),J=Symbol.for("react.memo"),Q=Symbol.for("react.lazy"),Z=Symbol.for("react.offscreen"),D=Symbol.iterator;function ne(l){return l===null||typeof l!="object"?null:(l=D&&l[D]||l["@@iterator"],typeof l=="function"?l:null)}var A=Object.assign,z;function ee(l){if(z===void 0)try{throw Error()}catch(m){var u=m.stack.trim().match(/\n( *(at )?)/);z=u&&u[1]||""}return`
34
+ `+z+l}var B=!1;function X(l,u){if(!l||B)return"";B=!0;var m=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(u)if(u=function(){throw Error()},Object.defineProperty(u.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(u,[])}catch(ge){var y=ge}Reflect.construct(l,[],u)}else{try{u.call()}catch(ge){y=ge}l.call(u.prototype)}else{try{throw Error()}catch(ge){y=ge}l()}}catch(ge){if(ge&&y&&typeof ge.stack=="string"){for(var b=ge.stack.split(`
35
+ `),N=y.stack.split(`
36
+ `),O=b.length-1,G=N.length-1;1<=O&&0<=G&&b[O]!==N[G];)G--;for(;1<=O&&0<=G;O--,G--)if(b[O]!==N[G]){if(O!==1||G!==1)do if(O--,G--,0>G||b[O]!==N[G]){var te=`
37
+ `+b[O].replace(" at new "," at ");return l.displayName&&te.includes("<anonymous>")&&(te=te.replace("<anonymous>",l.displayName)),te}while(1<=O&&0<=G);break}}}finally{B=!1,Error.prepareStackTrace=m}return(l=l?l.displayName||l.name:"")?ee(l):""}function ye(l){switch(l.tag){case 5:return ee(l.type);case 16:return ee("Lazy");case 13:return ee("Suspense");case 19:return ee("SuspenseList");case 0:case 2:case 15:return l=X(l.type,!1),l;case 11:return l=X(l.type.render,!1),l;case 1:return l=X(l.type,!0),l;default:return""}}function se(l){if(l==null)return null;if(typeof l=="function")return l.displayName||l.name||null;if(typeof l=="string")return l;switch(l){case M:return"Fragment";case I:return"Portal";case $:return"Profiler";case L:return"StrictMode";case F:return"Suspense";case K:return"SuspenseList"}if(typeof l=="object")switch(l.$$typeof){case P:return(l.displayName||"Context")+".Consumer";case E:return(l._context.displayName||"Context")+".Provider";case V:var u=l.render;return l=l.displayName,l||(l=u.displayName||u.name||"",l=l!==""?"ForwardRef("+l+")":"ForwardRef"),l;case J:return u=l.displayName||null,u!==null?u:se(l.type)||"Memo";case Q:u=l._payload,l=l._init;try{return se(l(u))}catch{}}return null}function oe(l){var u=l.type;switch(l.tag){case 24:return"Cache";case 9:return(u.displayName||"Context")+".Consumer";case 10:return(u._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return l=u.render,l=l.displayName||l.name||"",u.displayName||(l!==""?"ForwardRef("+l+")":"ForwardRef");case 7:return"Fragment";case 5:return u;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return se(u);case 8:return u===L?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof u=="function")return u.displayName||u.name||null;if(typeof u=="string")return u}return null}function U(l){switch(typeof l){case"boolean":case"number":case"string":case"undefined":return l;case"object":return l;default:return""}}function ue(l){var u=l.type;return(l=l.nodeName)&&l.toLowerCase()==="input"&&(u==="checkbox"||u==="radio")}function ke(l){var u=ue(l)?"checked":"value",m=Object.getOwnPropertyDescriptor(l.constructor.prototype,u),y=""+l[u];if(!l.hasOwnProperty(u)&&typeof m<"u"&&typeof m.get=="function"&&typeof m.set=="function"){var b=m.get,N=m.set;return Object.defineProperty(l,u,{configurable:!0,get:function(){return b.call(this)},set:function(O){y=""+O,N.call(this,O)}}),Object.defineProperty(l,u,{enumerable:m.enumerable}),{getValue:function(){return y},setValue:function(O){y=""+O},stopTracking:function(){l._valueTracker=null,delete l[u]}}}}function W(l){l._valueTracker||(l._valueTracker=ke(l))}function q(l){if(!l)return!1;var u=l._valueTracker;if(!u)return!0;var m=u.getValue(),y="";return l&&(y=ue(l)?l.checked?"true":"false":l.value),l=y,l!==m?(u.setValue(l),!0):!1}function fe(l){if(l=l||(typeof document<"u"?document:void 0),typeof l>"u")return null;try{return l.activeElement||l.body}catch{return l.body}}function ve(l,u){var m=u.checked;return A({},u,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:m??l._wrapperState.initialChecked})}function Se(l,u){var m=u.defaultValue==null?"":u.defaultValue,y=u.checked!=null?u.checked:u.defaultChecked;m=U(u.value!=null?u.value:m),l._wrapperState={initialChecked:y,initialValue:m,controlled:u.type==="checkbox"||u.type==="radio"?u.checked!=null:u.value!=null}}function Ke(l,u){u=u.checked,u!=null&&j(l,"checked",u,!1)}function dt(l,u){Ke(l,u);var m=U(u.value),y=u.type;if(m!=null)y==="number"?(m===0&&l.value===""||l.value!=m)&&(l.value=""+m):l.value!==""+m&&(l.value=""+m);else if(y==="submit"||y==="reset"){l.removeAttribute("value");return}u.hasOwnProperty("value")?_e(l,u.type,m):u.hasOwnProperty("defaultValue")&&_e(l,u.type,U(u.defaultValue)),u.checked==null&&u.defaultChecked!=null&&(l.defaultChecked=!!u.defaultChecked)}function Ge(l,u,m){if(u.hasOwnProperty("value")||u.hasOwnProperty("defaultValue")){var y=u.type;if(!(y!=="submit"&&y!=="reset"||u.value!==void 0&&u.value!==null))return;u=""+l._wrapperState.initialValue,m||u===l.value||(l.value=u),l.defaultValue=u}m=l.name,m!==""&&(l.name=""),l.defaultChecked=!!l._wrapperState.initialChecked,m!==""&&(l.name=m)}function _e(l,u,m){(u!=="number"||fe(l.ownerDocument)!==l)&&(m==null?l.defaultValue=""+l._wrapperState.initialValue:l.defaultValue!==""+m&&(l.defaultValue=""+m))}var Ve=Array.isArray;function xt(l,u,m,y){if(l=l.options,u){u={};for(var b=0;b<m.length;b++)u["$"+m[b]]=!0;for(m=0;m<l.length;m++)b=u.hasOwnProperty("$"+l[m].value),l[m].selected!==b&&(l[m].selected=b),b&&y&&(l[m].defaultSelected=!0)}else{for(m=""+U(m),u=null,b=0;b<l.length;b++){if(l[b].value===m){l[b].selected=!0,y&&(l[b].defaultSelected=!0);return}u!==null||l[b].disabled||(u=l[b])}u!==null&&(u.selected=!0)}}function Pt(l,u){if(u.dangerouslySetInnerHTML!=null)throw Error(n(91));return A({},u,{value:void 0,defaultValue:void 0,children:""+l._wrapperState.initialValue})}function mn(l,u){var m=u.value;if(m==null){if(m=u.children,u=u.defaultValue,m!=null){if(u!=null)throw Error(n(92));if(Ve(m)){if(1<m.length)throw Error(n(93));m=m[0]}u=m}u==null&&(u=""),m=u}l._wrapperState={initialValue:U(m)}}function gn(l,u){var m=U(u.value),y=U(u.defaultValue);m!=null&&(m=""+m,m!==l.value&&(l.value=m),u.defaultValue==null&&l.defaultValue!==m&&(l.defaultValue=m)),y!=null&&(l.defaultValue=""+y)}function jn(l){var u=l.textContent;u===l._wrapperState.initialValue&&u!==""&&u!==null&&(l.value=u)}function xe(l){switch(l){case"svg":return"http://www.w3.org/2000/svg";case"math":return"http://www.w3.org/1998/Math/MathML";default:return"http://www.w3.org/1999/xhtml"}}function Re(l,u){return l==null||l==="http://www.w3.org/1999/xhtml"?xe(u):l==="http://www.w3.org/2000/svg"&&u==="foreignObject"?"http://www.w3.org/1999/xhtml":l}var Qe,He=(function(l){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(u,m,y,b){MSApp.execUnsafeLocalFunction(function(){return l(u,m,y,b)})}:l})(function(l,u){if(l.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in l)l.innerHTML=u;else{for(Qe=Qe||document.createElement("div"),Qe.innerHTML="<svg>"+u.valueOf().toString()+"</svg>",u=Qe.firstChild;l.firstChild;)l.removeChild(l.firstChild);for(;u.firstChild;)l.appendChild(u.firstChild)}});function gt(l,u){if(u){var m=l.firstChild;if(m&&m===l.lastChild&&m.nodeType===3){m.nodeValue=u;return}}l.textContent=u}var hn={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},vn=["Webkit","ms","Moz","O"];Object.keys(hn).forEach(function(l){vn.forEach(function(u){u=u+l.charAt(0).toUpperCase()+l.substring(1),hn[u]=hn[l]})});function Fn(l,u,m){return u==null||typeof u=="boolean"||u===""?"":m||typeof u!="number"||u===0||hn.hasOwnProperty(l)&&hn[l]?(""+u).trim():u+"px"}function pe(l,u){l=l.style;for(var m in u)if(u.hasOwnProperty(m)){var y=m.indexOf("--")===0,b=Fn(m,u[m],y);m==="float"&&(m="cssFloat"),y?l.setProperty(m,b):l[m]=b}}var Ue=A({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function ze(l,u){if(u){if(Ue[l]&&(u.children!=null||u.dangerouslySetInnerHTML!=null))throw Error(n(137,l));if(u.dangerouslySetInnerHTML!=null){if(u.children!=null)throw Error(n(60));if(typeof u.dangerouslySetInnerHTML!="object"||!("__html"in u.dangerouslySetInnerHTML))throw Error(n(61))}if(u.style!=null&&typeof u.style!="object")throw Error(n(62))}}function Wt(l,u){if(l.indexOf("-")===-1)return typeof u.is=="string";switch(l){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var bt=null;function Tn(l){return l=l.target||l.srcElement||window,l.correspondingUseElement&&(l=l.correspondingUseElement),l.nodeType===3?l.parentNode:l}var nn=null,Kn=null,Mn=null;function ce(l){if(l=eu(l)){if(typeof nn!="function")throw Error(n(280));var u=l.stateNode;u&&(u=Jd(u),nn(l.stateNode,l.type,u))}}function be(l){Kn?Mn?Mn.push(l):Mn=[l]:Kn=l}function We(){if(Kn){var l=Kn,u=Mn;if(Mn=Kn=null,ce(l),u)for(l=0;l<u.length;l++)ce(u[l])}}function Ct(l,u){return l(u)}function ut(){}var Yt=!1;function kt(l,u,m){if(Yt)return l(u,m);Yt=!0;try{return Ct(l,u,m)}finally{Yt=!1,(Kn!==null||Mn!==null)&&(ut(),We())}}function Bt(l,u){var m=l.stateNode;if(m===null)return null;var y=Jd(m);if(y===null)return null;m=y[u];e:switch(u){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(y=!y.disabled)||(l=l.type,y=!(l==="button"||l==="input"||l==="select"||l==="textarea")),l=!y;break e;default:l=!1}if(l)return null;if(m&&typeof m!="function")throw Error(n(231,u,typeof m));return m}var ln=!1;if(c)try{var Y={};Object.defineProperty(Y,"passive",{get:function(){ln=!0}}),window.addEventListener("test",Y,Y),window.removeEventListener("test",Y,Y)}catch{ln=!1}function re(l,u,m,y,b,N,O,G,te){var ge=Array.prototype.slice.call(arguments,3);try{u.apply(m,ge)}catch(Pe){this.onError(Pe)}}var de=!1,Ce=null,Ae=!1,Je=null,lt={onError:function(l){de=!0,Ce=l}};function Ye(l,u,m,y,b,N,O,G,te){de=!1,Ce=null,re.apply(lt,arguments)}function Ze(l,u,m,y,b,N,O,G,te){if(Ye.apply(this,arguments),de){if(de){var ge=Ce;de=!1,Ce=null}else throw Error(n(198));Ae||(Ae=!0,Je=ge)}}function rt(l){var u=l,m=l;if(l.alternate)for(;u.return;)u=u.return;else{l=u;do u=l,(u.flags&4098)!==0&&(m=u.return),l=u.return;while(l)}return u.tag===3?m:null}function wt(l){if(l.tag===13){var u=l.memoizedState;if(u===null&&(l=l.alternate,l!==null&&(u=l.memoizedState)),u!==null)return u.dehydrated}return null}function ct(l){if(rt(l)!==l)throw Error(n(188))}function Nt(l){var u=l.alternate;if(!u){if(u=rt(l),u===null)throw Error(n(188));return u!==l?null:l}for(var m=l,y=u;;){var b=m.return;if(b===null)break;var N=b.alternate;if(N===null){if(y=b.return,y!==null){m=y;continue}break}if(b.child===N.child){for(N=b.child;N;){if(N===m)return ct(b),l;if(N===y)return ct(b),u;N=N.sibling}throw Error(n(188))}if(m.return!==y.return)m=b,y=N;else{for(var O=!1,G=b.child;G;){if(G===m){O=!0,m=b,y=N;break}if(G===y){O=!0,y=b,m=N;break}G=G.sibling}if(!O){for(G=N.child;G;){if(G===m){O=!0,m=N,y=b;break}if(G===y){O=!0,y=N,m=b;break}G=G.sibling}if(!O)throw Error(n(189))}}if(m.alternate!==y)throw Error(n(190))}if(m.tag!==3)throw Error(n(188));return m.stateNode.current===m?l:u}function Ot(l){return l=Nt(l),l!==null?Gn(l):null}function Gn(l){if(l.tag===5||l.tag===6)return l;for(l=l.child;l!==null;){var u=Gn(l);if(u!==null)return u;l=l.sibling}return null}var Vn=e.unstable_scheduleCallback,ir=e.unstable_cancelCallback,an=e.unstable_shouldYield,Lr=e.unstable_requestPaint,cn=e.unstable_now,bo=e.unstable_getCurrentPriorityLevel,yi=e.unstable_ImmediatePriority,ni=e.unstable_UserBlockingPriority,ba=e.unstable_NormalPriority,ko=e.unstable_LowPriority,us=e.unstable_IdlePriority,Vs=null,jr=null;function zt(l){if(jr&&typeof jr.onCommitFiberRoot=="function")try{jr.onCommitFiberRoot(Vs,l,void 0,(l.current.flags&128)===128)}catch{}}var fn=Math.clz32?Math.clz32:Pn,ka=Math.log,Ws=Math.LN2;function Pn(l){return l>>>=0,l===0?32:31-(ka(l)/Ws|0)|0}var Hs=64,wo=4194304;function So(l){switch(l&-l){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return l&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return l&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return l}}function Dd(l,u){var m=l.pendingLanes;if(m===0)return 0;var y=0,b=l.suspendedLanes,N=l.pingedLanes,O=m&268435455;if(O!==0){var G=O&~b;G!==0?y=So(G):(N&=O,N!==0&&(y=So(N)))}else O=m&~b,O!==0?y=So(O):N!==0&&(y=So(N));if(y===0)return 0;if(u!==0&&u!==y&&(u&b)===0&&(b=y&-y,N=u&-u,b>=N||b===16&&(N&4194240)!==0))return u;if((y&4)!==0&&(y|=m&16),u=l.entangledLanes,u!==0)for(l=l.entanglements,u&=y;0<u;)m=31-fn(u),b=1<<m,y|=l[m],u&=~b;return y}function t4(l,u){switch(l){case 1:case 2:case 4:return u+250;case 8:case 16:case 32:case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return u+5e3;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return-1;case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function n4(l,u){for(var m=l.suspendedLanes,y=l.pingedLanes,b=l.expirationTimes,N=l.pendingLanes;0<N;){var O=31-fn(N),G=1<<O,te=b[O];te===-1?((G&m)===0||(G&y)!==0)&&(b[O]=t4(G,u)):te<=u&&(l.expiredLanes|=G),N&=~G}}function Yp(l){return l=l.pendingLanes&-1073741825,l!==0?l:l&1073741824?1073741824:0}function ub(){var l=Hs;return Hs<<=1,(Hs&4194240)===0&&(Hs=64),l}function Jp(l){for(var u=[],m=0;31>m;m++)u.push(l);return u}function Lc(l,u,m){l.pendingLanes|=u,u!==536870912&&(l.suspendedLanes=0,l.pingedLanes=0),l=l.eventTimes,u=31-fn(u),l[u]=m}function r4(l,u){var m=l.pendingLanes&~u;l.pendingLanes=u,l.suspendedLanes=0,l.pingedLanes=0,l.expiredLanes&=u,l.mutableReadLanes&=u,l.entangledLanes&=u,u=l.entanglements;var y=l.eventTimes;for(l=l.expirationTimes;0<m;){var b=31-fn(m),N=1<<b;u[b]=0,y[b]=-1,l[b]=-1,m&=~N}}function Xp(l,u){var m=l.entangledLanes|=u;for(l=l.entanglements;m;){var y=31-fn(m),b=1<<y;b&u|l[y]&u&&(l[y]|=u),m&=~b}}var un=0;function db(l){return l&=-l,1<l?4<l?(l&268435455)!==0?16:536870912:4:1}var hb,Qp,fb,pb,mb,Zp=!1,Ad=[],wa=null,Sa=null,Ca=null,Fc=new Map,Uc=new Map,Ta=[],i4="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset submit".split(" ");function gb(l,u){switch(l){case"focusin":case"focusout":wa=null;break;case"dragenter":case"dragleave":Sa=null;break;case"mouseover":case"mouseout":Ca=null;break;case"pointerover":case"pointerout":Fc.delete(u.pointerId);break;case"gotpointercapture":case"lostpointercapture":Uc.delete(u.pointerId)}}function Bc(l,u,m,y,b,N){return l===null||l.nativeEvent!==N?(l={blockedOn:u,domEventName:m,eventSystemFlags:y,nativeEvent:N,targetContainers:[b]},u!==null&&(u=eu(u),u!==null&&Qp(u)),l):(l.eventSystemFlags|=y,u=l.targetContainers,b!==null&&u.indexOf(b)===-1&&u.push(b),l)}function s4(l,u,m,y,b){switch(u){case"focusin":return wa=Bc(wa,l,u,m,y,b),!0;case"dragenter":return Sa=Bc(Sa,l,u,m,y,b),!0;case"mouseover":return Ca=Bc(Ca,l,u,m,y,b),!0;case"pointerover":var N=b.pointerId;return Fc.set(N,Bc(Fc.get(N)||null,l,u,m,y,b)),!0;case"gotpointercapture":return N=b.pointerId,Uc.set(N,Bc(Uc.get(N)||null,l,u,m,y,b)),!0}return!1}function vb(l){var u=Co(l.target);if(u!==null){var m=rt(u);if(m!==null){if(u=m.tag,u===13){if(u=wt(m),u!==null){l.blockedOn=u,mb(l.priority,function(){fb(m)});return}}else if(u===3&&m.stateNode.current.memoizedState.isDehydrated){l.blockedOn=m.tag===3?m.stateNode.containerInfo:null;return}}}l.blockedOn=null}function Od(l){if(l.blockedOn!==null)return!1;for(var u=l.targetContainers;0<u.length;){var m=tm(l.domEventName,l.eventSystemFlags,u[0],l.nativeEvent);if(m===null){m=l.nativeEvent;var y=new m.constructor(m.type,m);bt=y,m.target.dispatchEvent(y),bt=null}else return u=eu(m),u!==null&&Qp(u),l.blockedOn=m,!1;u.shift()}return!0}function yb(l,u,m){Od(l)&&m.delete(u)}function a4(){Zp=!1,wa!==null&&Od(wa)&&(wa=null),Sa!==null&&Od(Sa)&&(Sa=null),Ca!==null&&Od(Ca)&&(Ca=null),Fc.forEach(yb),Uc.forEach(yb)}function zc(l,u){l.blockedOn===u&&(l.blockedOn=null,Zp||(Zp=!0,e.unstable_scheduleCallback(e.unstable_NormalPriority,a4)))}function $c(l){function u(b){return zc(b,l)}if(0<Ad.length){zc(Ad[0],l);for(var m=1;m<Ad.length;m++){var y=Ad[m];y.blockedOn===l&&(y.blockedOn=null)}}for(wa!==null&&zc(wa,l),Sa!==null&&zc(Sa,l),Ca!==null&&zc(Ca,l),Fc.forEach(u),Uc.forEach(u),m=0;m<Ta.length;m++)y=Ta[m],y.blockedOn===l&&(y.blockedOn=null);for(;0<Ta.length&&(m=Ta[0],m.blockedOn===null);)vb(m),m.blockedOn===null&&Ta.shift()}var kl=R.ReactCurrentBatchConfig,Ld=!0;function o4(l,u,m,y){var b=un,N=kl.transition;kl.transition=null;try{un=1,em(l,u,m,y)}finally{un=b,kl.transition=N}}function l4(l,u,m,y){var b=un,N=kl.transition;kl.transition=null;try{un=4,em(l,u,m,y)}finally{un=b,kl.transition=N}}function em(l,u,m,y){if(Ld){var b=tm(l,u,m,y);if(b===null)ym(l,u,y,Fd,m),gb(l,y);else if(s4(b,l,u,m,y))y.stopPropagation();else if(gb(l,y),u&4&&-1<i4.indexOf(l)){for(;b!==null;){var N=eu(b);if(N!==null&&hb(N),N=tm(l,u,m,y),N===null&&ym(l,u,y,Fd,m),N===b)break;b=N}b!==null&&y.stopPropagation()}else ym(l,u,y,null,m)}}var Fd=null;function tm(l,u,m,y){if(Fd=null,l=Tn(y),l=Co(l),l!==null)if(u=rt(l),u===null)l=null;else if(m=u.tag,m===13){if(l=wt(u),l!==null)return l;l=null}else if(m===3){if(u.stateNode.current.memoizedState.isDehydrated)return u.tag===3?u.stateNode.containerInfo:null;l=null}else u!==l&&(l=null);return Fd=l,null}function xb(l){switch(l){case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 1;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"toggle":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 4;case"message":switch(bo()){case yi:return 1;case ni:return 4;case ba:case ko:return 16;case us:return 536870912;default:return 16}default:return 16}}var Na=null,nm=null,Ud=null;function bb(){if(Ud)return Ud;var l,u=nm,m=u.length,y,b="value"in Na?Na.value:Na.textContent,N=b.length;for(l=0;l<m&&u[l]===b[l];l++);var O=m-l;for(y=1;y<=O&&u[m-y]===b[N-y];y++);return Ud=b.slice(l,1<y?1-y:void 0)}function Bd(l){var u=l.keyCode;return"charCode"in l?(l=l.charCode,l===0&&u===13&&(l=13)):l=u,l===10&&(l=13),32<=l||l===13?l:0}function zd(){return!0}function kb(){return!1}function ri(l){function u(m,y,b,N,O){this._reactName=m,this._targetInst=b,this.type=y,this.nativeEvent=N,this.target=O,this.currentTarget=null;for(var G in l)l.hasOwnProperty(G)&&(m=l[G],this[G]=m?m(N):N[G]);return this.isDefaultPrevented=(N.defaultPrevented!=null?N.defaultPrevented:N.returnValue===!1)?zd:kb,this.isPropagationStopped=kb,this}return A(u.prototype,{preventDefault:function(){this.defaultPrevented=!0;var m=this.nativeEvent;m&&(m.preventDefault?m.preventDefault():typeof m.returnValue!="unknown"&&(m.returnValue=!1),this.isDefaultPrevented=zd)},stopPropagation:function(){var m=this.nativeEvent;m&&(m.stopPropagation?m.stopPropagation():typeof m.cancelBubble!="unknown"&&(m.cancelBubble=!0),this.isPropagationStopped=zd)},persist:function(){},isPersistent:zd}),u}var wl={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(l){return l.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},rm=ri(wl),Vc=A({},wl,{view:0,detail:0}),c4=ri(Vc),im,sm,Wc,$d=A({},Vc,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:om,button:0,buttons:0,relatedTarget:function(l){return l.relatedTarget===void 0?l.fromElement===l.srcElement?l.toElement:l.fromElement:l.relatedTarget},movementX:function(l){return"movementX"in l?l.movementX:(l!==Wc&&(Wc&&l.type==="mousemove"?(im=l.screenX-Wc.screenX,sm=l.screenY-Wc.screenY):sm=im=0,Wc=l),im)},movementY:function(l){return"movementY"in l?l.movementY:sm}}),wb=ri($d),u4=A({},$d,{dataTransfer:0}),d4=ri(u4),h4=A({},Vc,{relatedTarget:0}),am=ri(h4),f4=A({},wl,{animationName:0,elapsedTime:0,pseudoElement:0}),p4=ri(f4),m4=A({},wl,{clipboardData:function(l){return"clipboardData"in l?l.clipboardData:window.clipboardData}}),g4=ri(m4),v4=A({},wl,{data:0}),Sb=ri(v4),y4={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},x4={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},b4={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function k4(l){var u=this.nativeEvent;return u.getModifierState?u.getModifierState(l):(l=b4[l])?!!u[l]:!1}function om(){return k4}var w4=A({},Vc,{key:function(l){if(l.key){var u=y4[l.key]||l.key;if(u!=="Unidentified")return u}return l.type==="keypress"?(l=Bd(l),l===13?"Enter":String.fromCharCode(l)):l.type==="keydown"||l.type==="keyup"?x4[l.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:om,charCode:function(l){return l.type==="keypress"?Bd(l):0},keyCode:function(l){return l.type==="keydown"||l.type==="keyup"?l.keyCode:0},which:function(l){return l.type==="keypress"?Bd(l):l.type==="keydown"||l.type==="keyup"?l.keyCode:0}}),S4=ri(w4),C4=A({},$d,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Cb=ri(C4),T4=A({},Vc,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:om}),N4=ri(T4),E4=A({},wl,{propertyName:0,elapsedTime:0,pseudoElement:0}),j4=ri(E4),P4=A({},$d,{deltaX:function(l){return"deltaX"in l?l.deltaX:"wheelDeltaX"in l?-l.wheelDeltaX:0},deltaY:function(l){return"deltaY"in l?l.deltaY:"wheelDeltaY"in l?-l.wheelDeltaY:"wheelDelta"in l?-l.wheelDelta:0},deltaZ:0,deltaMode:0}),_4=ri(P4),R4=[9,13,27,32],lm=c&&"CompositionEvent"in window,Hc=null;c&&"documentMode"in document&&(Hc=document.documentMode);var I4=c&&"TextEvent"in window&&!Hc,Tb=c&&(!lm||Hc&&8<Hc&&11>=Hc),Nb=" ",Eb=!1;function jb(l,u){switch(l){case"keyup":return R4.indexOf(u.keyCode)!==-1;case"keydown":return u.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Pb(l){return l=l.detail,typeof l=="object"&&"data"in l?l.data:null}var Sl=!1;function M4(l,u){switch(l){case"compositionend":return Pb(u);case"keypress":return u.which!==32?null:(Eb=!0,Nb);case"textInput":return l=u.data,l===Nb&&Eb?null:l;default:return null}}function D4(l,u){if(Sl)return l==="compositionend"||!lm&&jb(l,u)?(l=bb(),Ud=nm=Na=null,Sl=!1,l):null;switch(l){case"paste":return null;case"keypress":if(!(u.ctrlKey||u.altKey||u.metaKey)||u.ctrlKey&&u.altKey){if(u.char&&1<u.char.length)return u.char;if(u.which)return String.fromCharCode(u.which)}return null;case"compositionend":return Tb&&u.locale!=="ko"?null:u.data;default:return null}}var A4={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function _b(l){var u=l&&l.nodeName&&l.nodeName.toLowerCase();return u==="input"?!!A4[l.type]:u==="textarea"}function Rb(l,u,m,y){be(y),u=Kd(u,"onChange"),0<u.length&&(m=new rm("onChange","change",null,m,y),l.push({event:m,listeners:u}))}var qc=null,Kc=null;function O4(l){Yb(l,0)}function Vd(l){var u=jl(l);if(q(u))return l}function L4(l,u){if(l==="change")return u}var Ib=!1;if(c){var cm;if(c){var um="oninput"in document;if(!um){var Mb=document.createElement("div");Mb.setAttribute("oninput","return;"),um=typeof Mb.oninput=="function"}cm=um}else cm=!1;Ib=cm&&(!document.documentMode||9<document.documentMode)}function Db(){qc&&(qc.detachEvent("onpropertychange",Ab),Kc=qc=null)}function Ab(l){if(l.propertyName==="value"&&Vd(Kc)){var u=[];Rb(u,Kc,l,Tn(l)),kt(O4,u)}}function F4(l,u,m){l==="focusin"?(Db(),qc=u,Kc=m,qc.attachEvent("onpropertychange",Ab)):l==="focusout"&&Db()}function U4(l){if(l==="selectionchange"||l==="keyup"||l==="keydown")return Vd(Kc)}function B4(l,u){if(l==="click")return Vd(u)}function z4(l,u){if(l==="input"||l==="change")return Vd(u)}function $4(l,u){return l===u&&(l!==0||1/l===1/u)||l!==l&&u!==u}var Oi=typeof Object.is=="function"?Object.is:$4;function Gc(l,u){if(Oi(l,u))return!0;if(typeof l!="object"||l===null||typeof u!="object"||u===null)return!1;var m=Object.keys(l),y=Object.keys(u);if(m.length!==y.length)return!1;for(y=0;y<m.length;y++){var b=m[y];if(!h.call(u,b)||!Oi(l[b],u[b]))return!1}return!0}function Ob(l){for(;l&&l.firstChild;)l=l.firstChild;return l}function Lb(l,u){var m=Ob(l);l=0;for(var y;m;){if(m.nodeType===3){if(y=l+m.textContent.length,l<=u&&y>=u)return{node:m,offset:u-l};l=y}e:{for(;m;){if(m.nextSibling){m=m.nextSibling;break e}m=m.parentNode}m=void 0}m=Ob(m)}}function Fb(l,u){return l&&u?l===u?!0:l&&l.nodeType===3?!1:u&&u.nodeType===3?Fb(l,u.parentNode):"contains"in l?l.contains(u):l.compareDocumentPosition?!!(l.compareDocumentPosition(u)&16):!1:!1}function Ub(){for(var l=window,u=fe();u instanceof l.HTMLIFrameElement;){try{var m=typeof u.contentWindow.location.href=="string"}catch{m=!1}if(m)l=u.contentWindow;else break;u=fe(l.document)}return u}function dm(l){var u=l&&l.nodeName&&l.nodeName.toLowerCase();return u&&(u==="input"&&(l.type==="text"||l.type==="search"||l.type==="tel"||l.type==="url"||l.type==="password")||u==="textarea"||l.contentEditable==="true")}function V4(l){var u=Ub(),m=l.focusedElem,y=l.selectionRange;if(u!==m&&m&&m.ownerDocument&&Fb(m.ownerDocument.documentElement,m)){if(y!==null&&dm(m)){if(u=y.start,l=y.end,l===void 0&&(l=u),"selectionStart"in m)m.selectionStart=u,m.selectionEnd=Math.min(l,m.value.length);else if(l=(u=m.ownerDocument||document)&&u.defaultView||window,l.getSelection){l=l.getSelection();var b=m.textContent.length,N=Math.min(y.start,b);y=y.end===void 0?N:Math.min(y.end,b),!l.extend&&N>y&&(b=y,y=N,N=b),b=Lb(m,N);var O=Lb(m,y);b&&O&&(l.rangeCount!==1||l.anchorNode!==b.node||l.anchorOffset!==b.offset||l.focusNode!==O.node||l.focusOffset!==O.offset)&&(u=u.createRange(),u.setStart(b.node,b.offset),l.removeAllRanges(),N>y?(l.addRange(u),l.extend(O.node,O.offset)):(u.setEnd(O.node,O.offset),l.addRange(u)))}}for(u=[],l=m;l=l.parentNode;)l.nodeType===1&&u.push({element:l,left:l.scrollLeft,top:l.scrollTop});for(typeof m.focus=="function"&&m.focus(),m=0;m<u.length;m++)l=u[m],l.element.scrollLeft=l.left,l.element.scrollTop=l.top}}var W4=c&&"documentMode"in document&&11>=document.documentMode,Cl=null,hm=null,Yc=null,fm=!1;function Bb(l,u,m){var y=m.window===m?m.document:m.nodeType===9?m:m.ownerDocument;fm||Cl==null||Cl!==fe(y)||(y=Cl,"selectionStart"in y&&dm(y)?y={start:y.selectionStart,end:y.selectionEnd}:(y=(y.ownerDocument&&y.ownerDocument.defaultView||window).getSelection(),y={anchorNode:y.anchorNode,anchorOffset:y.anchorOffset,focusNode:y.focusNode,focusOffset:y.focusOffset}),Yc&&Gc(Yc,y)||(Yc=y,y=Kd(hm,"onSelect"),0<y.length&&(u=new rm("onSelect","select",null,u,m),l.push({event:u,listeners:y}),u.target=Cl)))}function Wd(l,u){var m={};return m[l.toLowerCase()]=u.toLowerCase(),m["Webkit"+l]="webkit"+u,m["Moz"+l]="moz"+u,m}var Tl={animationend:Wd("Animation","AnimationEnd"),animationiteration:Wd("Animation","AnimationIteration"),animationstart:Wd("Animation","AnimationStart"),transitionend:Wd("Transition","TransitionEnd")},pm={},zb={};c&&(zb=document.createElement("div").style,"AnimationEvent"in window||(delete Tl.animationend.animation,delete Tl.animationiteration.animation,delete Tl.animationstart.animation),"TransitionEvent"in window||delete Tl.transitionend.transition);function Hd(l){if(pm[l])return pm[l];if(!Tl[l])return l;var u=Tl[l],m;for(m in u)if(u.hasOwnProperty(m)&&m in zb)return pm[l]=u[m];return l}var $b=Hd("animationend"),Vb=Hd("animationiteration"),Wb=Hd("animationstart"),Hb=Hd("transitionend"),qb=new Map,Kb="abort auxClick cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");function Ea(l,u){qb.set(l,u),s(u,[l])}for(var mm=0;mm<Kb.length;mm++){var gm=Kb[mm],H4=gm.toLowerCase(),q4=gm[0].toUpperCase()+gm.slice(1);Ea(H4,"on"+q4)}Ea($b,"onAnimationEnd"),Ea(Vb,"onAnimationIteration"),Ea(Wb,"onAnimationStart"),Ea("dblclick","onDoubleClick"),Ea("focusin","onFocus"),Ea("focusout","onBlur"),Ea(Hb,"onTransitionEnd"),a("onMouseEnter",["mouseout","mouseover"]),a("onMouseLeave",["mouseout","mouseover"]),a("onPointerEnter",["pointerout","pointerover"]),a("onPointerLeave",["pointerout","pointerover"]),s("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),s("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),s("onBeforeInput",["compositionend","keypress","textInput","paste"]),s("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),s("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),s("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Jc="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),K4=new Set("cancel close invalid load scroll toggle".split(" ").concat(Jc));function Gb(l,u,m){var y=l.type||"unknown-event";l.currentTarget=m,Ze(y,u,void 0,l),l.currentTarget=null}function Yb(l,u){u=(u&4)!==0;for(var m=0;m<l.length;m++){var y=l[m],b=y.event;y=y.listeners;e:{var N=void 0;if(u)for(var O=y.length-1;0<=O;O--){var G=y[O],te=G.instance,ge=G.currentTarget;if(G=G.listener,te!==N&&b.isPropagationStopped())break e;Gb(b,G,ge),N=te}else for(O=0;O<y.length;O++){if(G=y[O],te=G.instance,ge=G.currentTarget,G=G.listener,te!==N&&b.isPropagationStopped())break e;Gb(b,G,ge),N=te}}}if(Ae)throw l=Je,Ae=!1,Je=null,l}function Nn(l,u){var m=u[Cm];m===void 0&&(m=u[Cm]=new Set);var y=l+"__bubble";m.has(y)||(Jb(u,l,2,!1),m.add(y))}function vm(l,u,m){var y=0;u&&(y|=4),Jb(m,l,y,u)}var qd="_reactListening"+Math.random().toString(36).slice(2);function Xc(l){if(!l[qd]){l[qd]=!0,r.forEach(function(m){m!=="selectionchange"&&(K4.has(m)||vm(m,!1,l),vm(m,!0,l))});var u=l.nodeType===9?l:l.ownerDocument;u===null||u[qd]||(u[qd]=!0,vm("selectionchange",!1,u))}}function Jb(l,u,m,y){switch(xb(u)){case 1:var b=o4;break;case 4:b=l4;break;default:b=em}m=b.bind(null,u,m,l),b=void 0,!ln||u!=="touchstart"&&u!=="touchmove"&&u!=="wheel"||(b=!0),y?b!==void 0?l.addEventListener(u,m,{capture:!0,passive:b}):l.addEventListener(u,m,!0):b!==void 0?l.addEventListener(u,m,{passive:b}):l.addEventListener(u,m,!1)}function ym(l,u,m,y,b){var N=y;if((u&1)===0&&(u&2)===0&&y!==null)e:for(;;){if(y===null)return;var O=y.tag;if(O===3||O===4){var G=y.stateNode.containerInfo;if(G===b||G.nodeType===8&&G.parentNode===b)break;if(O===4)for(O=y.return;O!==null;){var te=O.tag;if((te===3||te===4)&&(te=O.stateNode.containerInfo,te===b||te.nodeType===8&&te.parentNode===b))return;O=O.return}for(;G!==null;){if(O=Co(G),O===null)return;if(te=O.tag,te===5||te===6){y=N=O;continue e}G=G.parentNode}}y=y.return}kt(function(){var ge=N,Pe=Tn(m),Ie=[];e:{var Ee=qb.get(l);if(Ee!==void 0){var qe=rm,et=l;switch(l){case"keypress":if(Bd(m)===0)break e;case"keydown":case"keyup":qe=S4;break;case"focusin":et="focus",qe=am;break;case"focusout":et="blur",qe=am;break;case"beforeblur":case"afterblur":qe=am;break;case"click":if(m.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":qe=wb;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":qe=d4;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":qe=N4;break;case $b:case Vb:case Wb:qe=p4;break;case Hb:qe=j4;break;case"scroll":qe=c4;break;case"wheel":qe=_4;break;case"copy":case"cut":case"paste":qe=g4;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":qe=Cb}var it=(u&4)!==0,Wn=!it&&l==="scroll",le=it?Ee!==null?Ee+"Capture":null:Ee;it=[];for(var ie=ge,he;ie!==null;){he=ie;var Le=he.stateNode;if(he.tag===5&&Le!==null&&(he=Le,le!==null&&(Le=Bt(ie,le),Le!=null&&it.push(Qc(ie,Le,he)))),Wn)break;ie=ie.return}0<it.length&&(Ee=new qe(Ee,et,null,m,Pe),Ie.push({event:Ee,listeners:it}))}}if((u&7)===0){e:{if(Ee=l==="mouseover"||l==="pointerover",qe=l==="mouseout"||l==="pointerout",Ee&&m!==bt&&(et=m.relatedTarget||m.fromElement)&&(Co(et)||et[qs]))break e;if((qe||Ee)&&(Ee=Pe.window===Pe?Pe:(Ee=Pe.ownerDocument)?Ee.defaultView||Ee.parentWindow:window,qe?(et=m.relatedTarget||m.toElement,qe=ge,et=et?Co(et):null,et!==null&&(Wn=rt(et),et!==Wn||et.tag!==5&&et.tag!==6)&&(et=null)):(qe=null,et=ge),qe!==et)){if(it=wb,Le="onMouseLeave",le="onMouseEnter",ie="mouse",(l==="pointerout"||l==="pointerover")&&(it=Cb,Le="onPointerLeave",le="onPointerEnter",ie="pointer"),Wn=qe==null?Ee:jl(qe),he=et==null?Ee:jl(et),Ee=new it(Le,ie+"leave",qe,m,Pe),Ee.target=Wn,Ee.relatedTarget=he,Le=null,Co(Pe)===ge&&(it=new it(le,ie+"enter",et,m,Pe),it.target=he,it.relatedTarget=Wn,Le=it),Wn=Le,qe&&et)t:{for(it=qe,le=et,ie=0,he=it;he;he=Nl(he))ie++;for(he=0,Le=le;Le;Le=Nl(Le))he++;for(;0<ie-he;)it=Nl(it),ie--;for(;0<he-ie;)le=Nl(le),he--;for(;ie--;){if(it===le||le!==null&&it===le.alternate)break t;it=Nl(it),le=Nl(le)}it=null}else it=null;qe!==null&&Xb(Ie,Ee,qe,it,!1),et!==null&&Wn!==null&&Xb(Ie,Wn,et,it,!0)}}e:{if(Ee=ge?jl(ge):window,qe=Ee.nodeName&&Ee.nodeName.toLowerCase(),qe==="select"||qe==="input"&&Ee.type==="file")var ot=L4;else if(_b(Ee))if(Ib)ot=z4;else{ot=U4;var ft=F4}else(qe=Ee.nodeName)&&qe.toLowerCase()==="input"&&(Ee.type==="checkbox"||Ee.type==="radio")&&(ot=B4);if(ot&&(ot=ot(l,ge))){Rb(Ie,ot,m,Pe);break e}ft&&ft(l,Ee,ge),l==="focusout"&&(ft=Ee._wrapperState)&&ft.controlled&&Ee.type==="number"&&_e(Ee,"number",Ee.value)}switch(ft=ge?jl(ge):window,l){case"focusin":(_b(ft)||ft.contentEditable==="true")&&(Cl=ft,hm=ge,Yc=null);break;case"focusout":Yc=hm=Cl=null;break;case"mousedown":fm=!0;break;case"contextmenu":case"mouseup":case"dragend":fm=!1,Bb(Ie,m,Pe);break;case"selectionchange":if(W4)break;case"keydown":case"keyup":Bb(Ie,m,Pe)}var pt;if(lm)e:{switch(l){case"compositionstart":var yt="onCompositionStart";break e;case"compositionend":yt="onCompositionEnd";break e;case"compositionupdate":yt="onCompositionUpdate";break e}yt=void 0}else Sl?jb(l,m)&&(yt="onCompositionEnd"):l==="keydown"&&m.keyCode===229&&(yt="onCompositionStart");yt&&(Tb&&m.locale!=="ko"&&(Sl||yt!=="onCompositionStart"?yt==="onCompositionEnd"&&Sl&&(pt=bb()):(Na=Pe,nm="value"in Na?Na.value:Na.textContent,Sl=!0)),ft=Kd(ge,yt),0<ft.length&&(yt=new Sb(yt,l,null,m,Pe),Ie.push({event:yt,listeners:ft}),pt?yt.data=pt:(pt=Pb(m),pt!==null&&(yt.data=pt)))),(pt=I4?M4(l,m):D4(l,m))&&(ge=Kd(ge,"onBeforeInput"),0<ge.length&&(Pe=new Sb("onBeforeInput","beforeinput",null,m,Pe),Ie.push({event:Pe,listeners:ge}),Pe.data=pt))}Yb(Ie,u)})}function Qc(l,u,m){return{instance:l,listener:u,currentTarget:m}}function Kd(l,u){for(var m=u+"Capture",y=[];l!==null;){var b=l,N=b.stateNode;b.tag===5&&N!==null&&(b=N,N=Bt(l,m),N!=null&&y.unshift(Qc(l,N,b)),N=Bt(l,u),N!=null&&y.push(Qc(l,N,b))),l=l.return}return y}function Nl(l){if(l===null)return null;do l=l.return;while(l&&l.tag!==5);return l||null}function Xb(l,u,m,y,b){for(var N=u._reactName,O=[];m!==null&&m!==y;){var G=m,te=G.alternate,ge=G.stateNode;if(te!==null&&te===y)break;G.tag===5&&ge!==null&&(G=ge,b?(te=Bt(m,N),te!=null&&O.unshift(Qc(m,te,G))):b||(te=Bt(m,N),te!=null&&O.push(Qc(m,te,G)))),m=m.return}O.length!==0&&l.push({event:u,listeners:O})}var G4=/\r\n?/g,Y4=/\u0000|\uFFFD/g;function Qb(l){return(typeof l=="string"?l:""+l).replace(G4,`
38
+ `).replace(Y4,"")}function Gd(l,u,m){if(u=Qb(u),Qb(l)!==u&&m)throw Error(n(425))}function Yd(){}var xm=null,bm=null;function km(l,u){return l==="textarea"||l==="noscript"||typeof u.children=="string"||typeof u.children=="number"||typeof u.dangerouslySetInnerHTML=="object"&&u.dangerouslySetInnerHTML!==null&&u.dangerouslySetInnerHTML.__html!=null}var wm=typeof setTimeout=="function"?setTimeout:void 0,J4=typeof clearTimeout=="function"?clearTimeout:void 0,Zb=typeof Promise=="function"?Promise:void 0,X4=typeof queueMicrotask=="function"?queueMicrotask:typeof Zb<"u"?function(l){return Zb.resolve(null).then(l).catch(Q4)}:wm;function Q4(l){setTimeout(function(){throw l})}function Sm(l,u){var m=u,y=0;do{var b=m.nextSibling;if(l.removeChild(m),b&&b.nodeType===8)if(m=b.data,m==="/$"){if(y===0){l.removeChild(b),$c(u);return}y--}else m!=="$"&&m!=="$?"&&m!=="$!"||y++;m=b}while(m);$c(u)}function ja(l){for(;l!=null;l=l.nextSibling){var u=l.nodeType;if(u===1||u===3)break;if(u===8){if(u=l.data,u==="$"||u==="$!"||u==="$?")break;if(u==="/$")return null}}return l}function ek(l){l=l.previousSibling;for(var u=0;l;){if(l.nodeType===8){var m=l.data;if(m==="$"||m==="$!"||m==="$?"){if(u===0)return l;u--}else m==="/$"&&u++}l=l.previousSibling}return null}var El=Math.random().toString(36).slice(2),ds="__reactFiber$"+El,Zc="__reactProps$"+El,qs="__reactContainer$"+El,Cm="__reactEvents$"+El,Z4="__reactListeners$"+El,eI="__reactHandles$"+El;function Co(l){var u=l[ds];if(u)return u;for(var m=l.parentNode;m;){if(u=m[qs]||m[ds]){if(m=u.alternate,u.child!==null||m!==null&&m.child!==null)for(l=ek(l);l!==null;){if(m=l[ds])return m;l=ek(l)}return u}l=m,m=l.parentNode}return null}function eu(l){return l=l[ds]||l[qs],!l||l.tag!==5&&l.tag!==6&&l.tag!==13&&l.tag!==3?null:l}function jl(l){if(l.tag===5||l.tag===6)return l.stateNode;throw Error(n(33))}function Jd(l){return l[Zc]||null}var Tm=[],Pl=-1;function Pa(l){return{current:l}}function En(l){0>Pl||(l.current=Tm[Pl],Tm[Pl]=null,Pl--)}function wn(l,u){Pl++,Tm[Pl]=l.current,l.current=u}var _a={},pr=Pa(_a),Fr=Pa(!1),To=_a;function _l(l,u){var m=l.type.contextTypes;if(!m)return _a;var y=l.stateNode;if(y&&y.__reactInternalMemoizedUnmaskedChildContext===u)return y.__reactInternalMemoizedMaskedChildContext;var b={},N;for(N in m)b[N]=u[N];return y&&(l=l.stateNode,l.__reactInternalMemoizedUnmaskedChildContext=u,l.__reactInternalMemoizedMaskedChildContext=b),b}function Ur(l){return l=l.childContextTypes,l!=null}function Xd(){En(Fr),En(pr)}function tk(l,u,m){if(pr.current!==_a)throw Error(n(168));wn(pr,u),wn(Fr,m)}function nk(l,u,m){var y=l.stateNode;if(u=u.childContextTypes,typeof y.getChildContext!="function")return m;y=y.getChildContext();for(var b in y)if(!(b in u))throw Error(n(108,oe(l)||"Unknown",b));return A({},m,y)}function Qd(l){return l=(l=l.stateNode)&&l.__reactInternalMemoizedMergedChildContext||_a,To=pr.current,wn(pr,l),wn(Fr,Fr.current),!0}function rk(l,u,m){var y=l.stateNode;if(!y)throw Error(n(169));m?(l=nk(l,u,To),y.__reactInternalMemoizedMergedChildContext=l,En(Fr),En(pr),wn(pr,l)):En(Fr),wn(Fr,m)}var Ks=null,Zd=!1,Nm=!1;function ik(l){Ks===null?Ks=[l]:Ks.push(l)}function tI(l){Zd=!0,ik(l)}function Ra(){if(!Nm&&Ks!==null){Nm=!0;var l=0,u=un;try{var m=Ks;for(un=1;l<m.length;l++){var y=m[l];do y=y(!0);while(y!==null)}Ks=null,Zd=!1}catch(b){throw Ks!==null&&(Ks=Ks.slice(l+1)),Vn(yi,Ra),b}finally{un=u,Nm=!1}}return null}var Rl=[],Il=0,eh=null,th=0,xi=[],bi=0,No=null,Gs=1,Ys="";function Eo(l,u){Rl[Il++]=th,Rl[Il++]=eh,eh=l,th=u}function sk(l,u,m){xi[bi++]=Gs,xi[bi++]=Ys,xi[bi++]=No,No=l;var y=Gs;l=Ys;var b=32-fn(y)-1;y&=~(1<<b),m+=1;var N=32-fn(u)+b;if(30<N){var O=b-b%5;N=(y&(1<<O)-1).toString(32),y>>=O,b-=O,Gs=1<<32-fn(u)+b|m<<b|y,Ys=N+l}else Gs=1<<N|m<<b|y,Ys=l}function Em(l){l.return!==null&&(Eo(l,1),sk(l,1,0))}function jm(l){for(;l===eh;)eh=Rl[--Il],Rl[Il]=null,th=Rl[--Il],Rl[Il]=null;for(;l===No;)No=xi[--bi],xi[bi]=null,Ys=xi[--bi],xi[bi]=null,Gs=xi[--bi],xi[bi]=null}var ii=null,si=null,_n=!1,Li=null;function ak(l,u){var m=Ci(5,null,null,0);m.elementType="DELETED",m.stateNode=u,m.return=l,u=l.deletions,u===null?(l.deletions=[m],l.flags|=16):u.push(m)}function ok(l,u){switch(l.tag){case 5:var m=l.type;return u=u.nodeType!==1||m.toLowerCase()!==u.nodeName.toLowerCase()?null:u,u!==null?(l.stateNode=u,ii=l,si=ja(u.firstChild),!0):!1;case 6:return u=l.pendingProps===""||u.nodeType!==3?null:u,u!==null?(l.stateNode=u,ii=l,si=null,!0):!1;case 13:return u=u.nodeType!==8?null:u,u!==null?(m=No!==null?{id:Gs,overflow:Ys}:null,l.memoizedState={dehydrated:u,treeContext:m,retryLane:1073741824},m=Ci(18,null,null,0),m.stateNode=u,m.return=l,l.child=m,ii=l,si=null,!0):!1;default:return!1}}function Pm(l){return(l.mode&1)!==0&&(l.flags&128)===0}function _m(l){if(_n){var u=si;if(u){var m=u;if(!ok(l,u)){if(Pm(l))throw Error(n(418));u=ja(m.nextSibling);var y=ii;u&&ok(l,u)?ak(y,m):(l.flags=l.flags&-4097|2,_n=!1,ii=l)}}else{if(Pm(l))throw Error(n(418));l.flags=l.flags&-4097|2,_n=!1,ii=l}}}function lk(l){for(l=l.return;l!==null&&l.tag!==5&&l.tag!==3&&l.tag!==13;)l=l.return;ii=l}function nh(l){if(l!==ii)return!1;if(!_n)return lk(l),_n=!0,!1;var u;if((u=l.tag!==3)&&!(u=l.tag!==5)&&(u=l.type,u=u!=="head"&&u!=="body"&&!km(l.type,l.memoizedProps)),u&&(u=si)){if(Pm(l))throw ck(),Error(n(418));for(;u;)ak(l,u),u=ja(u.nextSibling)}if(lk(l),l.tag===13){if(l=l.memoizedState,l=l!==null?l.dehydrated:null,!l)throw Error(n(317));e:{for(l=l.nextSibling,u=0;l;){if(l.nodeType===8){var m=l.data;if(m==="/$"){if(u===0){si=ja(l.nextSibling);break e}u--}else m!=="$"&&m!=="$!"&&m!=="$?"||u++}l=l.nextSibling}si=null}}else si=ii?ja(l.stateNode.nextSibling):null;return!0}function ck(){for(var l=si;l;)l=ja(l.nextSibling)}function Ml(){si=ii=null,_n=!1}function Rm(l){Li===null?Li=[l]:Li.push(l)}var nI=R.ReactCurrentBatchConfig;function tu(l,u,m){if(l=m.ref,l!==null&&typeof l!="function"&&typeof l!="object"){if(m._owner){if(m=m._owner,m){if(m.tag!==1)throw Error(n(309));var y=m.stateNode}if(!y)throw Error(n(147,l));var b=y,N=""+l;return u!==null&&u.ref!==null&&typeof u.ref=="function"&&u.ref._stringRef===N?u.ref:(u=function(O){var G=b.refs;O===null?delete G[N]:G[N]=O},u._stringRef=N,u)}if(typeof l!="string")throw Error(n(284));if(!m._owner)throw Error(n(290,l))}return l}function rh(l,u){throw l=Object.prototype.toString.call(u),Error(n(31,l==="[object Object]"?"object with keys {"+Object.keys(u).join(", ")+"}":l))}function uk(l){var u=l._init;return u(l._payload)}function dk(l){function u(le,ie){if(l){var he=le.deletions;he===null?(le.deletions=[ie],le.flags|=16):he.push(ie)}}function m(le,ie){if(!l)return null;for(;ie!==null;)u(le,ie),ie=ie.sibling;return null}function y(le,ie){for(le=new Map;ie!==null;)ie.key!==null?le.set(ie.key,ie):le.set(ie.index,ie),ie=ie.sibling;return le}function b(le,ie){return le=Ua(le,ie),le.index=0,le.sibling=null,le}function N(le,ie,he){return le.index=he,l?(he=le.alternate,he!==null?(he=he.index,he<ie?(le.flags|=2,ie):he):(le.flags|=2,ie)):(le.flags|=1048576,ie)}function O(le){return l&&le.alternate===null&&(le.flags|=2),le}function G(le,ie,he,Le){return ie===null||ie.tag!==6?(ie=wg(he,le.mode,Le),ie.return=le,ie):(ie=b(ie,he),ie.return=le,ie)}function te(le,ie,he,Le){var ot=he.type;return ot===M?Pe(le,ie,he.props.children,Le,he.key):ie!==null&&(ie.elementType===ot||typeof ot=="object"&&ot!==null&&ot.$$typeof===Q&&uk(ot)===ie.type)?(Le=b(ie,he.props),Le.ref=tu(le,ie,he),Le.return=le,Le):(Le=Eh(he.type,he.key,he.props,null,le.mode,Le),Le.ref=tu(le,ie,he),Le.return=le,Le)}function ge(le,ie,he,Le){return ie===null||ie.tag!==4||ie.stateNode.containerInfo!==he.containerInfo||ie.stateNode.implementation!==he.implementation?(ie=Sg(he,le.mode,Le),ie.return=le,ie):(ie=b(ie,he.children||[]),ie.return=le,ie)}function Pe(le,ie,he,Le,ot){return ie===null||ie.tag!==7?(ie=Ao(he,le.mode,Le,ot),ie.return=le,ie):(ie=b(ie,he),ie.return=le,ie)}function Ie(le,ie,he){if(typeof ie=="string"&&ie!==""||typeof ie=="number")return ie=wg(""+ie,le.mode,he),ie.return=le,ie;if(typeof ie=="object"&&ie!==null){switch(ie.$$typeof){case _:return he=Eh(ie.type,ie.key,ie.props,null,le.mode,he),he.ref=tu(le,null,ie),he.return=le,he;case I:return ie=Sg(ie,le.mode,he),ie.return=le,ie;case Q:var Le=ie._init;return Ie(le,Le(ie._payload),he)}if(Ve(ie)||ne(ie))return ie=Ao(ie,le.mode,he,null),ie.return=le,ie;rh(le,ie)}return null}function Ee(le,ie,he,Le){var ot=ie!==null?ie.key:null;if(typeof he=="string"&&he!==""||typeof he=="number")return ot!==null?null:G(le,ie,""+he,Le);if(typeof he=="object"&&he!==null){switch(he.$$typeof){case _:return he.key===ot?te(le,ie,he,Le):null;case I:return he.key===ot?ge(le,ie,he,Le):null;case Q:return ot=he._init,Ee(le,ie,ot(he._payload),Le)}if(Ve(he)||ne(he))return ot!==null?null:Pe(le,ie,he,Le,null);rh(le,he)}return null}function qe(le,ie,he,Le,ot){if(typeof Le=="string"&&Le!==""||typeof Le=="number")return le=le.get(he)||null,G(ie,le,""+Le,ot);if(typeof Le=="object"&&Le!==null){switch(Le.$$typeof){case _:return le=le.get(Le.key===null?he:Le.key)||null,te(ie,le,Le,ot);case I:return le=le.get(Le.key===null?he:Le.key)||null,ge(ie,le,Le,ot);case Q:var ft=Le._init;return qe(le,ie,he,ft(Le._payload),ot)}if(Ve(Le)||ne(Le))return le=le.get(he)||null,Pe(ie,le,Le,ot,null);rh(ie,Le)}return null}function et(le,ie,he,Le){for(var ot=null,ft=null,pt=ie,yt=ie=0,or=null;pt!==null&&yt<he.length;yt++){pt.index>yt?(or=pt,pt=null):or=pt.sibling;var Jt=Ee(le,pt,he[yt],Le);if(Jt===null){pt===null&&(pt=or);break}l&&pt&&Jt.alternate===null&&u(le,pt),ie=N(Jt,ie,yt),ft===null?ot=Jt:ft.sibling=Jt,ft=Jt,pt=or}if(yt===he.length)return m(le,pt),_n&&Eo(le,yt),ot;if(pt===null){for(;yt<he.length;yt++)pt=Ie(le,he[yt],Le),pt!==null&&(ie=N(pt,ie,yt),ft===null?ot=pt:ft.sibling=pt,ft=pt);return _n&&Eo(le,yt),ot}for(pt=y(le,pt);yt<he.length;yt++)or=qe(pt,le,yt,he[yt],Le),or!==null&&(l&&or.alternate!==null&&pt.delete(or.key===null?yt:or.key),ie=N(or,ie,yt),ft===null?ot=or:ft.sibling=or,ft=or);return l&&pt.forEach(function(Ba){return u(le,Ba)}),_n&&Eo(le,yt),ot}function it(le,ie,he,Le){var ot=ne(he);if(typeof ot!="function")throw Error(n(150));if(he=ot.call(he),he==null)throw Error(n(151));for(var ft=ot=null,pt=ie,yt=ie=0,or=null,Jt=he.next();pt!==null&&!Jt.done;yt++,Jt=he.next()){pt.index>yt?(or=pt,pt=null):or=pt.sibling;var Ba=Ee(le,pt,Jt.value,Le);if(Ba===null){pt===null&&(pt=or);break}l&&pt&&Ba.alternate===null&&u(le,pt),ie=N(Ba,ie,yt),ft===null?ot=Ba:ft.sibling=Ba,ft=Ba,pt=or}if(Jt.done)return m(le,pt),_n&&Eo(le,yt),ot;if(pt===null){for(;!Jt.done;yt++,Jt=he.next())Jt=Ie(le,Jt.value,Le),Jt!==null&&(ie=N(Jt,ie,yt),ft===null?ot=Jt:ft.sibling=Jt,ft=Jt);return _n&&Eo(le,yt),ot}for(pt=y(le,pt);!Jt.done;yt++,Jt=he.next())Jt=qe(pt,le,yt,Jt.value,Le),Jt!==null&&(l&&Jt.alternate!==null&&pt.delete(Jt.key===null?yt:Jt.key),ie=N(Jt,ie,yt),ft===null?ot=Jt:ft.sibling=Jt,ft=Jt);return l&&pt.forEach(function(AI){return u(le,AI)}),_n&&Eo(le,yt),ot}function Wn(le,ie,he,Le){if(typeof he=="object"&&he!==null&&he.type===M&&he.key===null&&(he=he.props.children),typeof he=="object"&&he!==null){switch(he.$$typeof){case _:e:{for(var ot=he.key,ft=ie;ft!==null;){if(ft.key===ot){if(ot=he.type,ot===M){if(ft.tag===7){m(le,ft.sibling),ie=b(ft,he.props.children),ie.return=le,le=ie;break e}}else if(ft.elementType===ot||typeof ot=="object"&&ot!==null&&ot.$$typeof===Q&&uk(ot)===ft.type){m(le,ft.sibling),ie=b(ft,he.props),ie.ref=tu(le,ft,he),ie.return=le,le=ie;break e}m(le,ft);break}else u(le,ft);ft=ft.sibling}he.type===M?(ie=Ao(he.props.children,le.mode,Le,he.key),ie.return=le,le=ie):(Le=Eh(he.type,he.key,he.props,null,le.mode,Le),Le.ref=tu(le,ie,he),Le.return=le,le=Le)}return O(le);case I:e:{for(ft=he.key;ie!==null;){if(ie.key===ft)if(ie.tag===4&&ie.stateNode.containerInfo===he.containerInfo&&ie.stateNode.implementation===he.implementation){m(le,ie.sibling),ie=b(ie,he.children||[]),ie.return=le,le=ie;break e}else{m(le,ie);break}else u(le,ie);ie=ie.sibling}ie=Sg(he,le.mode,Le),ie.return=le,le=ie}return O(le);case Q:return ft=he._init,Wn(le,ie,ft(he._payload),Le)}if(Ve(he))return et(le,ie,he,Le);if(ne(he))return it(le,ie,he,Le);rh(le,he)}return typeof he=="string"&&he!==""||typeof he=="number"?(he=""+he,ie!==null&&ie.tag===6?(m(le,ie.sibling),ie=b(ie,he),ie.return=le,le=ie):(m(le,ie),ie=wg(he,le.mode,Le),ie.return=le,le=ie),O(le)):m(le,ie)}return Wn}var Dl=dk(!0),hk=dk(!1),ih=Pa(null),sh=null,Al=null,Im=null;function Mm(){Im=Al=sh=null}function Dm(l){var u=ih.current;En(ih),l._currentValue=u}function Am(l,u,m){for(;l!==null;){var y=l.alternate;if((l.childLanes&u)!==u?(l.childLanes|=u,y!==null&&(y.childLanes|=u)):y!==null&&(y.childLanes&u)!==u&&(y.childLanes|=u),l===m)break;l=l.return}}function Ol(l,u){sh=l,Im=Al=null,l=l.dependencies,l!==null&&l.firstContext!==null&&((l.lanes&u)!==0&&(Br=!0),l.firstContext=null)}function ki(l){var u=l._currentValue;if(Im!==l)if(l={context:l,memoizedValue:u,next:null},Al===null){if(sh===null)throw Error(n(308));Al=l,sh.dependencies={lanes:0,firstContext:l}}else Al=Al.next=l;return u}var jo=null;function Om(l){jo===null?jo=[l]:jo.push(l)}function fk(l,u,m,y){var b=u.interleaved;return b===null?(m.next=m,Om(u)):(m.next=b.next,b.next=m),u.interleaved=m,Js(l,y)}function Js(l,u){l.lanes|=u;var m=l.alternate;for(m!==null&&(m.lanes|=u),m=l,l=l.return;l!==null;)l.childLanes|=u,m=l.alternate,m!==null&&(m.childLanes|=u),m=l,l=l.return;return m.tag===3?m.stateNode:null}var Ia=!1;function Lm(l){l.updateQueue={baseState:l.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function pk(l,u){l=l.updateQueue,u.updateQueue===l&&(u.updateQueue={baseState:l.baseState,firstBaseUpdate:l.firstBaseUpdate,lastBaseUpdate:l.lastBaseUpdate,shared:l.shared,effects:l.effects})}function Xs(l,u){return{eventTime:l,lane:u,tag:0,payload:null,callback:null,next:null}}function Ma(l,u,m){var y=l.updateQueue;if(y===null)return null;if(y=y.shared,(Ht&2)!==0){var b=y.pending;return b===null?u.next=u:(u.next=b.next,b.next=u),y.pending=u,Js(l,m)}return b=y.interleaved,b===null?(u.next=u,Om(y)):(u.next=b.next,b.next=u),y.interleaved=u,Js(l,m)}function ah(l,u,m){if(u=u.updateQueue,u!==null&&(u=u.shared,(m&4194240)!==0)){var y=u.lanes;y&=l.pendingLanes,m|=y,u.lanes=m,Xp(l,m)}}function mk(l,u){var m=l.updateQueue,y=l.alternate;if(y!==null&&(y=y.updateQueue,m===y)){var b=null,N=null;if(m=m.firstBaseUpdate,m!==null){do{var O={eventTime:m.eventTime,lane:m.lane,tag:m.tag,payload:m.payload,callback:m.callback,next:null};N===null?b=N=O:N=N.next=O,m=m.next}while(m!==null);N===null?b=N=u:N=N.next=u}else b=N=u;m={baseState:y.baseState,firstBaseUpdate:b,lastBaseUpdate:N,shared:y.shared,effects:y.effects},l.updateQueue=m;return}l=m.lastBaseUpdate,l===null?m.firstBaseUpdate=u:l.next=u,m.lastBaseUpdate=u}function oh(l,u,m,y){var b=l.updateQueue;Ia=!1;var N=b.firstBaseUpdate,O=b.lastBaseUpdate,G=b.shared.pending;if(G!==null){b.shared.pending=null;var te=G,ge=te.next;te.next=null,O===null?N=ge:O.next=ge,O=te;var Pe=l.alternate;Pe!==null&&(Pe=Pe.updateQueue,G=Pe.lastBaseUpdate,G!==O&&(G===null?Pe.firstBaseUpdate=ge:G.next=ge,Pe.lastBaseUpdate=te))}if(N!==null){var Ie=b.baseState;O=0,Pe=ge=te=null,G=N;do{var Ee=G.lane,qe=G.eventTime;if((y&Ee)===Ee){Pe!==null&&(Pe=Pe.next={eventTime:qe,lane:0,tag:G.tag,payload:G.payload,callback:G.callback,next:null});e:{var et=l,it=G;switch(Ee=u,qe=m,it.tag){case 1:if(et=it.payload,typeof et=="function"){Ie=et.call(qe,Ie,Ee);break e}Ie=et;break e;case 3:et.flags=et.flags&-65537|128;case 0:if(et=it.payload,Ee=typeof et=="function"?et.call(qe,Ie,Ee):et,Ee==null)break e;Ie=A({},Ie,Ee);break e;case 2:Ia=!0}}G.callback!==null&&G.lane!==0&&(l.flags|=64,Ee=b.effects,Ee===null?b.effects=[G]:Ee.push(G))}else qe={eventTime:qe,lane:Ee,tag:G.tag,payload:G.payload,callback:G.callback,next:null},Pe===null?(ge=Pe=qe,te=Ie):Pe=Pe.next=qe,O|=Ee;if(G=G.next,G===null){if(G=b.shared.pending,G===null)break;Ee=G,G=Ee.next,Ee.next=null,b.lastBaseUpdate=Ee,b.shared.pending=null}}while(!0);if(Pe===null&&(te=Ie),b.baseState=te,b.firstBaseUpdate=ge,b.lastBaseUpdate=Pe,u=b.shared.interleaved,u!==null){b=u;do O|=b.lane,b=b.next;while(b!==u)}else N===null&&(b.shared.lanes=0);Ro|=O,l.lanes=O,l.memoizedState=Ie}}function gk(l,u,m){if(l=u.effects,u.effects=null,l!==null)for(u=0;u<l.length;u++){var y=l[u],b=y.callback;if(b!==null){if(y.callback=null,y=m,typeof b!="function")throw Error(n(191,b));b.call(y)}}}var nu={},hs=Pa(nu),ru=Pa(nu),iu=Pa(nu);function Po(l){if(l===nu)throw Error(n(174));return l}function Fm(l,u){switch(wn(iu,u),wn(ru,l),wn(hs,nu),l=u.nodeType,l){case 9:case 11:u=(u=u.documentElement)?u.namespaceURI:Re(null,"");break;default:l=l===8?u.parentNode:u,u=l.namespaceURI||null,l=l.tagName,u=Re(u,l)}En(hs),wn(hs,u)}function Ll(){En(hs),En(ru),En(iu)}function vk(l){Po(iu.current);var u=Po(hs.current),m=Re(u,l.type);u!==m&&(wn(ru,l),wn(hs,m))}function Um(l){ru.current===l&&(En(hs),En(ru))}var Dn=Pa(0);function lh(l){for(var u=l;u!==null;){if(u.tag===13){var m=u.memoizedState;if(m!==null&&(m=m.dehydrated,m===null||m.data==="$?"||m.data==="$!"))return u}else if(u.tag===19&&u.memoizedProps.revealOrder!==void 0){if((u.flags&128)!==0)return u}else if(u.child!==null){u.child.return=u,u=u.child;continue}if(u===l)break;for(;u.sibling===null;){if(u.return===null||u.return===l)return null;u=u.return}u.sibling.return=u.return,u=u.sibling}return null}var Bm=[];function zm(){for(var l=0;l<Bm.length;l++)Bm[l]._workInProgressVersionPrimary=null;Bm.length=0}var ch=R.ReactCurrentDispatcher,$m=R.ReactCurrentBatchConfig,_o=0,An=null,er=null,sr=null,uh=!1,su=!1,au=0,rI=0;function mr(){throw Error(n(321))}function Vm(l,u){if(u===null)return!1;for(var m=0;m<u.length&&m<l.length;m++)if(!Oi(l[m],u[m]))return!1;return!0}function Wm(l,u,m,y,b,N){if(_o=N,An=u,u.memoizedState=null,u.updateQueue=null,u.lanes=0,ch.current=l===null||l.memoizedState===null?oI:lI,l=m(y,b),su){N=0;do{if(su=!1,au=0,25<=N)throw Error(n(301));N+=1,sr=er=null,u.updateQueue=null,ch.current=cI,l=m(y,b)}while(su)}if(ch.current=fh,u=er!==null&&er.next!==null,_o=0,sr=er=An=null,uh=!1,u)throw Error(n(300));return l}function Hm(){var l=au!==0;return au=0,l}function fs(){var l={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return sr===null?An.memoizedState=sr=l:sr=sr.next=l,sr}function wi(){if(er===null){var l=An.alternate;l=l!==null?l.memoizedState:null}else l=er.next;var u=sr===null?An.memoizedState:sr.next;if(u!==null)sr=u,er=l;else{if(l===null)throw Error(n(310));er=l,l={memoizedState:er.memoizedState,baseState:er.baseState,baseQueue:er.baseQueue,queue:er.queue,next:null},sr===null?An.memoizedState=sr=l:sr=sr.next=l}return sr}function ou(l,u){return typeof u=="function"?u(l):u}function qm(l){var u=wi(),m=u.queue;if(m===null)throw Error(n(311));m.lastRenderedReducer=l;var y=er,b=y.baseQueue,N=m.pending;if(N!==null){if(b!==null){var O=b.next;b.next=N.next,N.next=O}y.baseQueue=b=N,m.pending=null}if(b!==null){N=b.next,y=y.baseState;var G=O=null,te=null,ge=N;do{var Pe=ge.lane;if((_o&Pe)===Pe)te!==null&&(te=te.next={lane:0,action:ge.action,hasEagerState:ge.hasEagerState,eagerState:ge.eagerState,next:null}),y=ge.hasEagerState?ge.eagerState:l(y,ge.action);else{var Ie={lane:Pe,action:ge.action,hasEagerState:ge.hasEagerState,eagerState:ge.eagerState,next:null};te===null?(G=te=Ie,O=y):te=te.next=Ie,An.lanes|=Pe,Ro|=Pe}ge=ge.next}while(ge!==null&&ge!==N);te===null?O=y:te.next=G,Oi(y,u.memoizedState)||(Br=!0),u.memoizedState=y,u.baseState=O,u.baseQueue=te,m.lastRenderedState=y}if(l=m.interleaved,l!==null){b=l;do N=b.lane,An.lanes|=N,Ro|=N,b=b.next;while(b!==l)}else b===null&&(m.lanes=0);return[u.memoizedState,m.dispatch]}function Km(l){var u=wi(),m=u.queue;if(m===null)throw Error(n(311));m.lastRenderedReducer=l;var y=m.dispatch,b=m.pending,N=u.memoizedState;if(b!==null){m.pending=null;var O=b=b.next;do N=l(N,O.action),O=O.next;while(O!==b);Oi(N,u.memoizedState)||(Br=!0),u.memoizedState=N,u.baseQueue===null&&(u.baseState=N),m.lastRenderedState=N}return[N,y]}function yk(){}function xk(l,u){var m=An,y=wi(),b=u(),N=!Oi(y.memoizedState,b);if(N&&(y.memoizedState=b,Br=!0),y=y.queue,Gm(wk.bind(null,m,y,l),[l]),y.getSnapshot!==u||N||sr!==null&&sr.memoizedState.tag&1){if(m.flags|=2048,lu(9,kk.bind(null,m,y,b,u),void 0,null),ar===null)throw Error(n(349));(_o&30)!==0||bk(m,u,b)}return b}function bk(l,u,m){l.flags|=16384,l={getSnapshot:u,value:m},u=An.updateQueue,u===null?(u={lastEffect:null,stores:null},An.updateQueue=u,u.stores=[l]):(m=u.stores,m===null?u.stores=[l]:m.push(l))}function kk(l,u,m,y){u.value=m,u.getSnapshot=y,Sk(u)&&Ck(l)}function wk(l,u,m){return m(function(){Sk(u)&&Ck(l)})}function Sk(l){var u=l.getSnapshot;l=l.value;try{var m=u();return!Oi(l,m)}catch{return!0}}function Ck(l){var u=Js(l,1);u!==null&&zi(u,l,1,-1)}function Tk(l){var u=fs();return typeof l=="function"&&(l=l()),u.memoizedState=u.baseState=l,l={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:ou,lastRenderedState:l},u.queue=l,l=l.dispatch=aI.bind(null,An,l),[u.memoizedState,l]}function lu(l,u,m,y){return l={tag:l,create:u,destroy:m,deps:y,next:null},u=An.updateQueue,u===null?(u={lastEffect:null,stores:null},An.updateQueue=u,u.lastEffect=l.next=l):(m=u.lastEffect,m===null?u.lastEffect=l.next=l:(y=m.next,m.next=l,l.next=y,u.lastEffect=l)),l}function Nk(){return wi().memoizedState}function dh(l,u,m,y){var b=fs();An.flags|=l,b.memoizedState=lu(1|u,m,void 0,y===void 0?null:y)}function hh(l,u,m,y){var b=wi();y=y===void 0?null:y;var N=void 0;if(er!==null){var O=er.memoizedState;if(N=O.destroy,y!==null&&Vm(y,O.deps)){b.memoizedState=lu(u,m,N,y);return}}An.flags|=l,b.memoizedState=lu(1|u,m,N,y)}function Ek(l,u){return dh(8390656,8,l,u)}function Gm(l,u){return hh(2048,8,l,u)}function jk(l,u){return hh(4,2,l,u)}function Pk(l,u){return hh(4,4,l,u)}function _k(l,u){if(typeof u=="function")return l=l(),u(l),function(){u(null)};if(u!=null)return l=l(),u.current=l,function(){u.current=null}}function Rk(l,u,m){return m=m!=null?m.concat([l]):null,hh(4,4,_k.bind(null,u,l),m)}function Ym(){}function Ik(l,u){var m=wi();u=u===void 0?null:u;var y=m.memoizedState;return y!==null&&u!==null&&Vm(u,y[1])?y[0]:(m.memoizedState=[l,u],l)}function Mk(l,u){var m=wi();u=u===void 0?null:u;var y=m.memoizedState;return y!==null&&u!==null&&Vm(u,y[1])?y[0]:(l=l(),m.memoizedState=[l,u],l)}function Dk(l,u,m){return(_o&21)===0?(l.baseState&&(l.baseState=!1,Br=!0),l.memoizedState=m):(Oi(m,u)||(m=ub(),An.lanes|=m,Ro|=m,l.baseState=!0),u)}function iI(l,u){var m=un;un=m!==0&&4>m?m:4,l(!0);var y=$m.transition;$m.transition={};try{l(!1),u()}finally{un=m,$m.transition=y}}function Ak(){return wi().memoizedState}function sI(l,u,m){var y=La(l);if(m={lane:y,action:m,hasEagerState:!1,eagerState:null,next:null},Ok(l))Lk(u,m);else if(m=fk(l,u,m,y),m!==null){var b=_r();zi(m,l,y,b),Fk(m,u,y)}}function aI(l,u,m){var y=La(l),b={lane:y,action:m,hasEagerState:!1,eagerState:null,next:null};if(Ok(l))Lk(u,b);else{var N=l.alternate;if(l.lanes===0&&(N===null||N.lanes===0)&&(N=u.lastRenderedReducer,N!==null))try{var O=u.lastRenderedState,G=N(O,m);if(b.hasEagerState=!0,b.eagerState=G,Oi(G,O)){var te=u.interleaved;te===null?(b.next=b,Om(u)):(b.next=te.next,te.next=b),u.interleaved=b;return}}catch{}finally{}m=fk(l,u,b,y),m!==null&&(b=_r(),zi(m,l,y,b),Fk(m,u,y))}}function Ok(l){var u=l.alternate;return l===An||u!==null&&u===An}function Lk(l,u){su=uh=!0;var m=l.pending;m===null?u.next=u:(u.next=m.next,m.next=u),l.pending=u}function Fk(l,u,m){if((m&4194240)!==0){var y=u.lanes;y&=l.pendingLanes,m|=y,u.lanes=m,Xp(l,m)}}var fh={readContext:ki,useCallback:mr,useContext:mr,useEffect:mr,useImperativeHandle:mr,useInsertionEffect:mr,useLayoutEffect:mr,useMemo:mr,useReducer:mr,useRef:mr,useState:mr,useDebugValue:mr,useDeferredValue:mr,useTransition:mr,useMutableSource:mr,useSyncExternalStore:mr,useId:mr,unstable_isNewReconciler:!1},oI={readContext:ki,useCallback:function(l,u){return fs().memoizedState=[l,u===void 0?null:u],l},useContext:ki,useEffect:Ek,useImperativeHandle:function(l,u,m){return m=m!=null?m.concat([l]):null,dh(4194308,4,_k.bind(null,u,l),m)},useLayoutEffect:function(l,u){return dh(4194308,4,l,u)},useInsertionEffect:function(l,u){return dh(4,2,l,u)},useMemo:function(l,u){var m=fs();return u=u===void 0?null:u,l=l(),m.memoizedState=[l,u],l},useReducer:function(l,u,m){var y=fs();return u=m!==void 0?m(u):u,y.memoizedState=y.baseState=u,l={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:l,lastRenderedState:u},y.queue=l,l=l.dispatch=sI.bind(null,An,l),[y.memoizedState,l]},useRef:function(l){var u=fs();return l={current:l},u.memoizedState=l},useState:Tk,useDebugValue:Ym,useDeferredValue:function(l){return fs().memoizedState=l},useTransition:function(){var l=Tk(!1),u=l[0];return l=iI.bind(null,l[1]),fs().memoizedState=l,[u,l]},useMutableSource:function(){},useSyncExternalStore:function(l,u,m){var y=An,b=fs();if(_n){if(m===void 0)throw Error(n(407));m=m()}else{if(m=u(),ar===null)throw Error(n(349));(_o&30)!==0||bk(y,u,m)}b.memoizedState=m;var N={value:m,getSnapshot:u};return b.queue=N,Ek(wk.bind(null,y,N,l),[l]),y.flags|=2048,lu(9,kk.bind(null,y,N,m,u),void 0,null),m},useId:function(){var l=fs(),u=ar.identifierPrefix;if(_n){var m=Ys,y=Gs;m=(y&~(1<<32-fn(y)-1)).toString(32)+m,u=":"+u+"R"+m,m=au++,0<m&&(u+="H"+m.toString(32)),u+=":"}else m=rI++,u=":"+u+"r"+m.toString(32)+":";return l.memoizedState=u},unstable_isNewReconciler:!1},lI={readContext:ki,useCallback:Ik,useContext:ki,useEffect:Gm,useImperativeHandle:Rk,useInsertionEffect:jk,useLayoutEffect:Pk,useMemo:Mk,useReducer:qm,useRef:Nk,useState:function(){return qm(ou)},useDebugValue:Ym,useDeferredValue:function(l){var u=wi();return Dk(u,er.memoizedState,l)},useTransition:function(){var l=qm(ou)[0],u=wi().memoizedState;return[l,u]},useMutableSource:yk,useSyncExternalStore:xk,useId:Ak,unstable_isNewReconciler:!1},cI={readContext:ki,useCallback:Ik,useContext:ki,useEffect:Gm,useImperativeHandle:Rk,useInsertionEffect:jk,useLayoutEffect:Pk,useMemo:Mk,useReducer:Km,useRef:Nk,useState:function(){return Km(ou)},useDebugValue:Ym,useDeferredValue:function(l){var u=wi();return er===null?u.memoizedState=l:Dk(u,er.memoizedState,l)},useTransition:function(){var l=Km(ou)[0],u=wi().memoizedState;return[l,u]},useMutableSource:yk,useSyncExternalStore:xk,useId:Ak,unstable_isNewReconciler:!1};function Fi(l,u){if(l&&l.defaultProps){u=A({},u),l=l.defaultProps;for(var m in l)u[m]===void 0&&(u[m]=l[m]);return u}return u}function Jm(l,u,m,y){u=l.memoizedState,m=m(y,u),m=m==null?u:A({},u,m),l.memoizedState=m,l.lanes===0&&(l.updateQueue.baseState=m)}var ph={isMounted:function(l){return(l=l._reactInternals)?rt(l)===l:!1},enqueueSetState:function(l,u,m){l=l._reactInternals;var y=_r(),b=La(l),N=Xs(y,b);N.payload=u,m!=null&&(N.callback=m),u=Ma(l,N,b),u!==null&&(zi(u,l,b,y),ah(u,l,b))},enqueueReplaceState:function(l,u,m){l=l._reactInternals;var y=_r(),b=La(l),N=Xs(y,b);N.tag=1,N.payload=u,m!=null&&(N.callback=m),u=Ma(l,N,b),u!==null&&(zi(u,l,b,y),ah(u,l,b))},enqueueForceUpdate:function(l,u){l=l._reactInternals;var m=_r(),y=La(l),b=Xs(m,y);b.tag=2,u!=null&&(b.callback=u),u=Ma(l,b,y),u!==null&&(zi(u,l,y,m),ah(u,l,y))}};function Uk(l,u,m,y,b,N,O){return l=l.stateNode,typeof l.shouldComponentUpdate=="function"?l.shouldComponentUpdate(y,N,O):u.prototype&&u.prototype.isPureReactComponent?!Gc(m,y)||!Gc(b,N):!0}function Bk(l,u,m){var y=!1,b=_a,N=u.contextType;return typeof N=="object"&&N!==null?N=ki(N):(b=Ur(u)?To:pr.current,y=u.contextTypes,N=(y=y!=null)?_l(l,b):_a),u=new u(m,N),l.memoizedState=u.state!==null&&u.state!==void 0?u.state:null,u.updater=ph,l.stateNode=u,u._reactInternals=l,y&&(l=l.stateNode,l.__reactInternalMemoizedUnmaskedChildContext=b,l.__reactInternalMemoizedMaskedChildContext=N),u}function zk(l,u,m,y){l=u.state,typeof u.componentWillReceiveProps=="function"&&u.componentWillReceiveProps(m,y),typeof u.UNSAFE_componentWillReceiveProps=="function"&&u.UNSAFE_componentWillReceiveProps(m,y),u.state!==l&&ph.enqueueReplaceState(u,u.state,null)}function Xm(l,u,m,y){var b=l.stateNode;b.props=m,b.state=l.memoizedState,b.refs={},Lm(l);var N=u.contextType;typeof N=="object"&&N!==null?b.context=ki(N):(N=Ur(u)?To:pr.current,b.context=_l(l,N)),b.state=l.memoizedState,N=u.getDerivedStateFromProps,typeof N=="function"&&(Jm(l,u,N,m),b.state=l.memoizedState),typeof u.getDerivedStateFromProps=="function"||typeof b.getSnapshotBeforeUpdate=="function"||typeof b.UNSAFE_componentWillMount!="function"&&typeof b.componentWillMount!="function"||(u=b.state,typeof b.componentWillMount=="function"&&b.componentWillMount(),typeof b.UNSAFE_componentWillMount=="function"&&b.UNSAFE_componentWillMount(),u!==b.state&&ph.enqueueReplaceState(b,b.state,null),oh(l,m,b,y),b.state=l.memoizedState),typeof b.componentDidMount=="function"&&(l.flags|=4194308)}function Fl(l,u){try{var m="",y=u;do m+=ye(y),y=y.return;while(y);var b=m}catch(N){b=`
39
+ Error generating stack: `+N.message+`
40
+ `+N.stack}return{value:l,source:u,stack:b,digest:null}}function Qm(l,u,m){return{value:l,source:null,stack:m??null,digest:u??null}}function Zm(l,u){try{console.error(u.value)}catch(m){setTimeout(function(){throw m})}}var uI=typeof WeakMap=="function"?WeakMap:Map;function $k(l,u,m){m=Xs(-1,m),m.tag=3,m.payload={element:null};var y=u.value;return m.callback=function(){kh||(kh=!0,pg=y),Zm(l,u)},m}function Vk(l,u,m){m=Xs(-1,m),m.tag=3;var y=l.type.getDerivedStateFromError;if(typeof y=="function"){var b=u.value;m.payload=function(){return y(b)},m.callback=function(){Zm(l,u)}}var N=l.stateNode;return N!==null&&typeof N.componentDidCatch=="function"&&(m.callback=function(){Zm(l,u),typeof y!="function"&&(Aa===null?Aa=new Set([this]):Aa.add(this));var O=u.stack;this.componentDidCatch(u.value,{componentStack:O!==null?O:""})}),m}function Wk(l,u,m){var y=l.pingCache;if(y===null){y=l.pingCache=new uI;var b=new Set;y.set(u,b)}else b=y.get(u),b===void 0&&(b=new Set,y.set(u,b));b.has(m)||(b.add(m),l=CI.bind(null,l,u,m),u.then(l,l))}function Hk(l){do{var u;if((u=l.tag===13)&&(u=l.memoizedState,u=u!==null?u.dehydrated!==null:!0),u)return l;l=l.return}while(l!==null);return null}function qk(l,u,m,y,b){return(l.mode&1)===0?(l===u?l.flags|=65536:(l.flags|=128,m.flags|=131072,m.flags&=-52805,m.tag===1&&(m.alternate===null?m.tag=17:(u=Xs(-1,1),u.tag=2,Ma(m,u,1))),m.lanes|=1),l):(l.flags|=65536,l.lanes=b,l)}var dI=R.ReactCurrentOwner,Br=!1;function Pr(l,u,m,y){u.child=l===null?hk(u,null,m,y):Dl(u,l.child,m,y)}function Kk(l,u,m,y,b){m=m.render;var N=u.ref;return Ol(u,b),y=Wm(l,u,m,y,N,b),m=Hm(),l!==null&&!Br?(u.updateQueue=l.updateQueue,u.flags&=-2053,l.lanes&=~b,Qs(l,u,b)):(_n&&m&&Em(u),u.flags|=1,Pr(l,u,y,b),u.child)}function Gk(l,u,m,y,b){if(l===null){var N=m.type;return typeof N=="function"&&!kg(N)&&N.defaultProps===void 0&&m.compare===null&&m.defaultProps===void 0?(u.tag=15,u.type=N,Yk(l,u,N,y,b)):(l=Eh(m.type,null,y,u,u.mode,b),l.ref=u.ref,l.return=u,u.child=l)}if(N=l.child,(l.lanes&b)===0){var O=N.memoizedProps;if(m=m.compare,m=m!==null?m:Gc,m(O,y)&&l.ref===u.ref)return Qs(l,u,b)}return u.flags|=1,l=Ua(N,y),l.ref=u.ref,l.return=u,u.child=l}function Yk(l,u,m,y,b){if(l!==null){var N=l.memoizedProps;if(Gc(N,y)&&l.ref===u.ref)if(Br=!1,u.pendingProps=y=N,(l.lanes&b)!==0)(l.flags&131072)!==0&&(Br=!0);else return u.lanes=l.lanes,Qs(l,u,b)}return eg(l,u,m,y,b)}function Jk(l,u,m){var y=u.pendingProps,b=y.children,N=l!==null?l.memoizedState:null;if(y.mode==="hidden")if((u.mode&1)===0)u.memoizedState={baseLanes:0,cachePool:null,transitions:null},wn(Bl,ai),ai|=m;else{if((m&1073741824)===0)return l=N!==null?N.baseLanes|m:m,u.lanes=u.childLanes=1073741824,u.memoizedState={baseLanes:l,cachePool:null,transitions:null},u.updateQueue=null,wn(Bl,ai),ai|=l,null;u.memoizedState={baseLanes:0,cachePool:null,transitions:null},y=N!==null?N.baseLanes:m,wn(Bl,ai),ai|=y}else N!==null?(y=N.baseLanes|m,u.memoizedState=null):y=m,wn(Bl,ai),ai|=y;return Pr(l,u,b,m),u.child}function Xk(l,u){var m=u.ref;(l===null&&m!==null||l!==null&&l.ref!==m)&&(u.flags|=512,u.flags|=2097152)}function eg(l,u,m,y,b){var N=Ur(m)?To:pr.current;return N=_l(u,N),Ol(u,b),m=Wm(l,u,m,y,N,b),y=Hm(),l!==null&&!Br?(u.updateQueue=l.updateQueue,u.flags&=-2053,l.lanes&=~b,Qs(l,u,b)):(_n&&y&&Em(u),u.flags|=1,Pr(l,u,m,b),u.child)}function Qk(l,u,m,y,b){if(Ur(m)){var N=!0;Qd(u)}else N=!1;if(Ol(u,b),u.stateNode===null)gh(l,u),Bk(u,m,y),Xm(u,m,y,b),y=!0;else if(l===null){var O=u.stateNode,G=u.memoizedProps;O.props=G;var te=O.context,ge=m.contextType;typeof ge=="object"&&ge!==null?ge=ki(ge):(ge=Ur(m)?To:pr.current,ge=_l(u,ge));var Pe=m.getDerivedStateFromProps,Ie=typeof Pe=="function"||typeof O.getSnapshotBeforeUpdate=="function";Ie||typeof O.UNSAFE_componentWillReceiveProps!="function"&&typeof O.componentWillReceiveProps!="function"||(G!==y||te!==ge)&&zk(u,O,y,ge),Ia=!1;var Ee=u.memoizedState;O.state=Ee,oh(u,y,O,b),te=u.memoizedState,G!==y||Ee!==te||Fr.current||Ia?(typeof Pe=="function"&&(Jm(u,m,Pe,y),te=u.memoizedState),(G=Ia||Uk(u,m,G,y,Ee,te,ge))?(Ie||typeof O.UNSAFE_componentWillMount!="function"&&typeof O.componentWillMount!="function"||(typeof O.componentWillMount=="function"&&O.componentWillMount(),typeof O.UNSAFE_componentWillMount=="function"&&O.UNSAFE_componentWillMount()),typeof O.componentDidMount=="function"&&(u.flags|=4194308)):(typeof O.componentDidMount=="function"&&(u.flags|=4194308),u.memoizedProps=y,u.memoizedState=te),O.props=y,O.state=te,O.context=ge,y=G):(typeof O.componentDidMount=="function"&&(u.flags|=4194308),y=!1)}else{O=u.stateNode,pk(l,u),G=u.memoizedProps,ge=u.type===u.elementType?G:Fi(u.type,G),O.props=ge,Ie=u.pendingProps,Ee=O.context,te=m.contextType,typeof te=="object"&&te!==null?te=ki(te):(te=Ur(m)?To:pr.current,te=_l(u,te));var qe=m.getDerivedStateFromProps;(Pe=typeof qe=="function"||typeof O.getSnapshotBeforeUpdate=="function")||typeof O.UNSAFE_componentWillReceiveProps!="function"&&typeof O.componentWillReceiveProps!="function"||(G!==Ie||Ee!==te)&&zk(u,O,y,te),Ia=!1,Ee=u.memoizedState,O.state=Ee,oh(u,y,O,b);var et=u.memoizedState;G!==Ie||Ee!==et||Fr.current||Ia?(typeof qe=="function"&&(Jm(u,m,qe,y),et=u.memoizedState),(ge=Ia||Uk(u,m,ge,y,Ee,et,te)||!1)?(Pe||typeof O.UNSAFE_componentWillUpdate!="function"&&typeof O.componentWillUpdate!="function"||(typeof O.componentWillUpdate=="function"&&O.componentWillUpdate(y,et,te),typeof O.UNSAFE_componentWillUpdate=="function"&&O.UNSAFE_componentWillUpdate(y,et,te)),typeof O.componentDidUpdate=="function"&&(u.flags|=4),typeof O.getSnapshotBeforeUpdate=="function"&&(u.flags|=1024)):(typeof O.componentDidUpdate!="function"||G===l.memoizedProps&&Ee===l.memoizedState||(u.flags|=4),typeof O.getSnapshotBeforeUpdate!="function"||G===l.memoizedProps&&Ee===l.memoizedState||(u.flags|=1024),u.memoizedProps=y,u.memoizedState=et),O.props=y,O.state=et,O.context=te,y=ge):(typeof O.componentDidUpdate!="function"||G===l.memoizedProps&&Ee===l.memoizedState||(u.flags|=4),typeof O.getSnapshotBeforeUpdate!="function"||G===l.memoizedProps&&Ee===l.memoizedState||(u.flags|=1024),y=!1)}return tg(l,u,m,y,N,b)}function tg(l,u,m,y,b,N){Xk(l,u);var O=(u.flags&128)!==0;if(!y&&!O)return b&&rk(u,m,!1),Qs(l,u,N);y=u.stateNode,dI.current=u;var G=O&&typeof m.getDerivedStateFromError!="function"?null:y.render();return u.flags|=1,l!==null&&O?(u.child=Dl(u,l.child,null,N),u.child=Dl(u,null,G,N)):Pr(l,u,G,N),u.memoizedState=y.state,b&&rk(u,m,!0),u.child}function Zk(l){var u=l.stateNode;u.pendingContext?tk(l,u.pendingContext,u.pendingContext!==u.context):u.context&&tk(l,u.context,!1),Fm(l,u.containerInfo)}function ew(l,u,m,y,b){return Ml(),Rm(b),u.flags|=256,Pr(l,u,m,y),u.child}var ng={dehydrated:null,treeContext:null,retryLane:0};function rg(l){return{baseLanes:l,cachePool:null,transitions:null}}function tw(l,u,m){var y=u.pendingProps,b=Dn.current,N=!1,O=(u.flags&128)!==0,G;if((G=O)||(G=l!==null&&l.memoizedState===null?!1:(b&2)!==0),G?(N=!0,u.flags&=-129):(l===null||l.memoizedState!==null)&&(b|=1),wn(Dn,b&1),l===null)return _m(u),l=u.memoizedState,l!==null&&(l=l.dehydrated,l!==null)?((u.mode&1)===0?u.lanes=1:l.data==="$!"?u.lanes=8:u.lanes=1073741824,null):(O=y.children,l=y.fallback,N?(y=u.mode,N=u.child,O={mode:"hidden",children:O},(y&1)===0&&N!==null?(N.childLanes=0,N.pendingProps=O):N=jh(O,y,0,null),l=Ao(l,y,m,null),N.return=u,l.return=u,N.sibling=l,u.child=N,u.child.memoizedState=rg(m),u.memoizedState=ng,l):ig(u,O));if(b=l.memoizedState,b!==null&&(G=b.dehydrated,G!==null))return hI(l,u,O,y,G,b,m);if(N){N=y.fallback,O=u.mode,b=l.child,G=b.sibling;var te={mode:"hidden",children:y.children};return(O&1)===0&&u.child!==b?(y=u.child,y.childLanes=0,y.pendingProps=te,u.deletions=null):(y=Ua(b,te),y.subtreeFlags=b.subtreeFlags&14680064),G!==null?N=Ua(G,N):(N=Ao(N,O,m,null),N.flags|=2),N.return=u,y.return=u,y.sibling=N,u.child=y,y=N,N=u.child,O=l.child.memoizedState,O=O===null?rg(m):{baseLanes:O.baseLanes|m,cachePool:null,transitions:O.transitions},N.memoizedState=O,N.childLanes=l.childLanes&~m,u.memoizedState=ng,y}return N=l.child,l=N.sibling,y=Ua(N,{mode:"visible",children:y.children}),(u.mode&1)===0&&(y.lanes=m),y.return=u,y.sibling=null,l!==null&&(m=u.deletions,m===null?(u.deletions=[l],u.flags|=16):m.push(l)),u.child=y,u.memoizedState=null,y}function ig(l,u){return u=jh({mode:"visible",children:u},l.mode,0,null),u.return=l,l.child=u}function mh(l,u,m,y){return y!==null&&Rm(y),Dl(u,l.child,null,m),l=ig(u,u.pendingProps.children),l.flags|=2,u.memoizedState=null,l}function hI(l,u,m,y,b,N,O){if(m)return u.flags&256?(u.flags&=-257,y=Qm(Error(n(422))),mh(l,u,O,y)):u.memoizedState!==null?(u.child=l.child,u.flags|=128,null):(N=y.fallback,b=u.mode,y=jh({mode:"visible",children:y.children},b,0,null),N=Ao(N,b,O,null),N.flags|=2,y.return=u,N.return=u,y.sibling=N,u.child=y,(u.mode&1)!==0&&Dl(u,l.child,null,O),u.child.memoizedState=rg(O),u.memoizedState=ng,N);if((u.mode&1)===0)return mh(l,u,O,null);if(b.data==="$!"){if(y=b.nextSibling&&b.nextSibling.dataset,y)var G=y.dgst;return y=G,N=Error(n(419)),y=Qm(N,y,void 0),mh(l,u,O,y)}if(G=(O&l.childLanes)!==0,Br||G){if(y=ar,y!==null){switch(O&-O){case 4:b=2;break;case 16:b=8;break;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:b=32;break;case 536870912:b=268435456;break;default:b=0}b=(b&(y.suspendedLanes|O))!==0?0:b,b!==0&&b!==N.retryLane&&(N.retryLane=b,Js(l,b),zi(y,l,b,-1))}return bg(),y=Qm(Error(n(421))),mh(l,u,O,y)}return b.data==="$?"?(u.flags|=128,u.child=l.child,u=TI.bind(null,l),b._reactRetry=u,null):(l=N.treeContext,si=ja(b.nextSibling),ii=u,_n=!0,Li=null,l!==null&&(xi[bi++]=Gs,xi[bi++]=Ys,xi[bi++]=No,Gs=l.id,Ys=l.overflow,No=u),u=ig(u,y.children),u.flags|=4096,u)}function nw(l,u,m){l.lanes|=u;var y=l.alternate;y!==null&&(y.lanes|=u),Am(l.return,u,m)}function sg(l,u,m,y,b){var N=l.memoizedState;N===null?l.memoizedState={isBackwards:u,rendering:null,renderingStartTime:0,last:y,tail:m,tailMode:b}:(N.isBackwards=u,N.rendering=null,N.renderingStartTime=0,N.last=y,N.tail=m,N.tailMode=b)}function rw(l,u,m){var y=u.pendingProps,b=y.revealOrder,N=y.tail;if(Pr(l,u,y.children,m),y=Dn.current,(y&2)!==0)y=y&1|2,u.flags|=128;else{if(l!==null&&(l.flags&128)!==0)e:for(l=u.child;l!==null;){if(l.tag===13)l.memoizedState!==null&&nw(l,m,u);else if(l.tag===19)nw(l,m,u);else if(l.child!==null){l.child.return=l,l=l.child;continue}if(l===u)break e;for(;l.sibling===null;){if(l.return===null||l.return===u)break e;l=l.return}l.sibling.return=l.return,l=l.sibling}y&=1}if(wn(Dn,y),(u.mode&1)===0)u.memoizedState=null;else switch(b){case"forwards":for(m=u.child,b=null;m!==null;)l=m.alternate,l!==null&&lh(l)===null&&(b=m),m=m.sibling;m=b,m===null?(b=u.child,u.child=null):(b=m.sibling,m.sibling=null),sg(u,!1,b,m,N);break;case"backwards":for(m=null,b=u.child,u.child=null;b!==null;){if(l=b.alternate,l!==null&&lh(l)===null){u.child=b;break}l=b.sibling,b.sibling=m,m=b,b=l}sg(u,!0,m,null,N);break;case"together":sg(u,!1,null,null,void 0);break;default:u.memoizedState=null}return u.child}function gh(l,u){(u.mode&1)===0&&l!==null&&(l.alternate=null,u.alternate=null,u.flags|=2)}function Qs(l,u,m){if(l!==null&&(u.dependencies=l.dependencies),Ro|=u.lanes,(m&u.childLanes)===0)return null;if(l!==null&&u.child!==l.child)throw Error(n(153));if(u.child!==null){for(l=u.child,m=Ua(l,l.pendingProps),u.child=m,m.return=u;l.sibling!==null;)l=l.sibling,m=m.sibling=Ua(l,l.pendingProps),m.return=u;m.sibling=null}return u.child}function fI(l,u,m){switch(u.tag){case 3:Zk(u),Ml();break;case 5:vk(u);break;case 1:Ur(u.type)&&Qd(u);break;case 4:Fm(u,u.stateNode.containerInfo);break;case 10:var y=u.type._context,b=u.memoizedProps.value;wn(ih,y._currentValue),y._currentValue=b;break;case 13:if(y=u.memoizedState,y!==null)return y.dehydrated!==null?(wn(Dn,Dn.current&1),u.flags|=128,null):(m&u.child.childLanes)!==0?tw(l,u,m):(wn(Dn,Dn.current&1),l=Qs(l,u,m),l!==null?l.sibling:null);wn(Dn,Dn.current&1);break;case 19:if(y=(m&u.childLanes)!==0,(l.flags&128)!==0){if(y)return rw(l,u,m);u.flags|=128}if(b=u.memoizedState,b!==null&&(b.rendering=null,b.tail=null,b.lastEffect=null),wn(Dn,Dn.current),y)break;return null;case 22:case 23:return u.lanes=0,Jk(l,u,m)}return Qs(l,u,m)}var iw,ag,sw,aw;iw=function(l,u){for(var m=u.child;m!==null;){if(m.tag===5||m.tag===6)l.appendChild(m.stateNode);else if(m.tag!==4&&m.child!==null){m.child.return=m,m=m.child;continue}if(m===u)break;for(;m.sibling===null;){if(m.return===null||m.return===u)return;m=m.return}m.sibling.return=m.return,m=m.sibling}},ag=function(){},sw=function(l,u,m,y){var b=l.memoizedProps;if(b!==y){l=u.stateNode,Po(hs.current);var N=null;switch(m){case"input":b=ve(l,b),y=ve(l,y),N=[];break;case"select":b=A({},b,{value:void 0}),y=A({},y,{value:void 0}),N=[];break;case"textarea":b=Pt(l,b),y=Pt(l,y),N=[];break;default:typeof b.onClick!="function"&&typeof y.onClick=="function"&&(l.onclick=Yd)}ze(m,y);var O;m=null;for(ge in b)if(!y.hasOwnProperty(ge)&&b.hasOwnProperty(ge)&&b[ge]!=null)if(ge==="style"){var G=b[ge];for(O in G)G.hasOwnProperty(O)&&(m||(m={}),m[O]="")}else ge!=="dangerouslySetInnerHTML"&&ge!=="children"&&ge!=="suppressContentEditableWarning"&&ge!=="suppressHydrationWarning"&&ge!=="autoFocus"&&(i.hasOwnProperty(ge)?N||(N=[]):(N=N||[]).push(ge,null));for(ge in y){var te=y[ge];if(G=b!=null?b[ge]:void 0,y.hasOwnProperty(ge)&&te!==G&&(te!=null||G!=null))if(ge==="style")if(G){for(O in G)!G.hasOwnProperty(O)||te&&te.hasOwnProperty(O)||(m||(m={}),m[O]="");for(O in te)te.hasOwnProperty(O)&&G[O]!==te[O]&&(m||(m={}),m[O]=te[O])}else m||(N||(N=[]),N.push(ge,m)),m=te;else ge==="dangerouslySetInnerHTML"?(te=te?te.__html:void 0,G=G?G.__html:void 0,te!=null&&G!==te&&(N=N||[]).push(ge,te)):ge==="children"?typeof te!="string"&&typeof te!="number"||(N=N||[]).push(ge,""+te):ge!=="suppressContentEditableWarning"&&ge!=="suppressHydrationWarning"&&(i.hasOwnProperty(ge)?(te!=null&&ge==="onScroll"&&Nn("scroll",l),N||G===te||(N=[])):(N=N||[]).push(ge,te))}m&&(N=N||[]).push("style",m);var ge=N;(u.updateQueue=ge)&&(u.flags|=4)}},aw=function(l,u,m,y){m!==y&&(u.flags|=4)};function cu(l,u){if(!_n)switch(l.tailMode){case"hidden":u=l.tail;for(var m=null;u!==null;)u.alternate!==null&&(m=u),u=u.sibling;m===null?l.tail=null:m.sibling=null;break;case"collapsed":m=l.tail;for(var y=null;m!==null;)m.alternate!==null&&(y=m),m=m.sibling;y===null?u||l.tail===null?l.tail=null:l.tail.sibling=null:y.sibling=null}}function gr(l){var u=l.alternate!==null&&l.alternate.child===l.child,m=0,y=0;if(u)for(var b=l.child;b!==null;)m|=b.lanes|b.childLanes,y|=b.subtreeFlags&14680064,y|=b.flags&14680064,b.return=l,b=b.sibling;else for(b=l.child;b!==null;)m|=b.lanes|b.childLanes,y|=b.subtreeFlags,y|=b.flags,b.return=l,b=b.sibling;return l.subtreeFlags|=y,l.childLanes=m,u}function pI(l,u,m){var y=u.pendingProps;switch(jm(u),u.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return gr(u),null;case 1:return Ur(u.type)&&Xd(),gr(u),null;case 3:return y=u.stateNode,Ll(),En(Fr),En(pr),zm(),y.pendingContext&&(y.context=y.pendingContext,y.pendingContext=null),(l===null||l.child===null)&&(nh(u)?u.flags|=4:l===null||l.memoizedState.isDehydrated&&(u.flags&256)===0||(u.flags|=1024,Li!==null&&(vg(Li),Li=null))),ag(l,u),gr(u),null;case 5:Um(u);var b=Po(iu.current);if(m=u.type,l!==null&&u.stateNode!=null)sw(l,u,m,y,b),l.ref!==u.ref&&(u.flags|=512,u.flags|=2097152);else{if(!y){if(u.stateNode===null)throw Error(n(166));return gr(u),null}if(l=Po(hs.current),nh(u)){y=u.stateNode,m=u.type;var N=u.memoizedProps;switch(y[ds]=u,y[Zc]=N,l=(u.mode&1)!==0,m){case"dialog":Nn("cancel",y),Nn("close",y);break;case"iframe":case"object":case"embed":Nn("load",y);break;case"video":case"audio":for(b=0;b<Jc.length;b++)Nn(Jc[b],y);break;case"source":Nn("error",y);break;case"img":case"image":case"link":Nn("error",y),Nn("load",y);break;case"details":Nn("toggle",y);break;case"input":Se(y,N),Nn("invalid",y);break;case"select":y._wrapperState={wasMultiple:!!N.multiple},Nn("invalid",y);break;case"textarea":mn(y,N),Nn("invalid",y)}ze(m,N),b=null;for(var O in N)if(N.hasOwnProperty(O)){var G=N[O];O==="children"?typeof G=="string"?y.textContent!==G&&(N.suppressHydrationWarning!==!0&&Gd(y.textContent,G,l),b=["children",G]):typeof G=="number"&&y.textContent!==""+G&&(N.suppressHydrationWarning!==!0&&Gd(y.textContent,G,l),b=["children",""+G]):i.hasOwnProperty(O)&&G!=null&&O==="onScroll"&&Nn("scroll",y)}switch(m){case"input":W(y),Ge(y,N,!0);break;case"textarea":W(y),jn(y);break;case"select":case"option":break;default:typeof N.onClick=="function"&&(y.onclick=Yd)}y=b,u.updateQueue=y,y!==null&&(u.flags|=4)}else{O=b.nodeType===9?b:b.ownerDocument,l==="http://www.w3.org/1999/xhtml"&&(l=xe(m)),l==="http://www.w3.org/1999/xhtml"?m==="script"?(l=O.createElement("div"),l.innerHTML="<script><\/script>",l=l.removeChild(l.firstChild)):typeof y.is=="string"?l=O.createElement(m,{is:y.is}):(l=O.createElement(m),m==="select"&&(O=l,y.multiple?O.multiple=!0:y.size&&(O.size=y.size))):l=O.createElementNS(l,m),l[ds]=u,l[Zc]=y,iw(l,u,!1,!1),u.stateNode=l;e:{switch(O=Wt(m,y),m){case"dialog":Nn("cancel",l),Nn("close",l),b=y;break;case"iframe":case"object":case"embed":Nn("load",l),b=y;break;case"video":case"audio":for(b=0;b<Jc.length;b++)Nn(Jc[b],l);b=y;break;case"source":Nn("error",l),b=y;break;case"img":case"image":case"link":Nn("error",l),Nn("load",l),b=y;break;case"details":Nn("toggle",l),b=y;break;case"input":Se(l,y),b=ve(l,y),Nn("invalid",l);break;case"option":b=y;break;case"select":l._wrapperState={wasMultiple:!!y.multiple},b=A({},y,{value:void 0}),Nn("invalid",l);break;case"textarea":mn(l,y),b=Pt(l,y),Nn("invalid",l);break;default:b=y}ze(m,b),G=b;for(N in G)if(G.hasOwnProperty(N)){var te=G[N];N==="style"?pe(l,te):N==="dangerouslySetInnerHTML"?(te=te?te.__html:void 0,te!=null&&He(l,te)):N==="children"?typeof te=="string"?(m!=="textarea"||te!=="")&&gt(l,te):typeof te=="number"&&gt(l,""+te):N!=="suppressContentEditableWarning"&&N!=="suppressHydrationWarning"&&N!=="autoFocus"&&(i.hasOwnProperty(N)?te!=null&&N==="onScroll"&&Nn("scroll",l):te!=null&&j(l,N,te,O))}switch(m){case"input":W(l),Ge(l,y,!1);break;case"textarea":W(l),jn(l);break;case"option":y.value!=null&&l.setAttribute("value",""+U(y.value));break;case"select":l.multiple=!!y.multiple,N=y.value,N!=null?xt(l,!!y.multiple,N,!1):y.defaultValue!=null&&xt(l,!!y.multiple,y.defaultValue,!0);break;default:typeof b.onClick=="function"&&(l.onclick=Yd)}switch(m){case"button":case"input":case"select":case"textarea":y=!!y.autoFocus;break e;case"img":y=!0;break e;default:y=!1}}y&&(u.flags|=4)}u.ref!==null&&(u.flags|=512,u.flags|=2097152)}return gr(u),null;case 6:if(l&&u.stateNode!=null)aw(l,u,l.memoizedProps,y);else{if(typeof y!="string"&&u.stateNode===null)throw Error(n(166));if(m=Po(iu.current),Po(hs.current),nh(u)){if(y=u.stateNode,m=u.memoizedProps,y[ds]=u,(N=y.nodeValue!==m)&&(l=ii,l!==null))switch(l.tag){case 3:Gd(y.nodeValue,m,(l.mode&1)!==0);break;case 5:l.memoizedProps.suppressHydrationWarning!==!0&&Gd(y.nodeValue,m,(l.mode&1)!==0)}N&&(u.flags|=4)}else y=(m.nodeType===9?m:m.ownerDocument).createTextNode(y),y[ds]=u,u.stateNode=y}return gr(u),null;case 13:if(En(Dn),y=u.memoizedState,l===null||l.memoizedState!==null&&l.memoizedState.dehydrated!==null){if(_n&&si!==null&&(u.mode&1)!==0&&(u.flags&128)===0)ck(),Ml(),u.flags|=98560,N=!1;else if(N=nh(u),y!==null&&y.dehydrated!==null){if(l===null){if(!N)throw Error(n(318));if(N=u.memoizedState,N=N!==null?N.dehydrated:null,!N)throw Error(n(317));N[ds]=u}else Ml(),(u.flags&128)===0&&(u.memoizedState=null),u.flags|=4;gr(u),N=!1}else Li!==null&&(vg(Li),Li=null),N=!0;if(!N)return u.flags&65536?u:null}return(u.flags&128)!==0?(u.lanes=m,u):(y=y!==null,y!==(l!==null&&l.memoizedState!==null)&&y&&(u.child.flags|=8192,(u.mode&1)!==0&&(l===null||(Dn.current&1)!==0?tr===0&&(tr=3):bg())),u.updateQueue!==null&&(u.flags|=4),gr(u),null);case 4:return Ll(),ag(l,u),l===null&&Xc(u.stateNode.containerInfo),gr(u),null;case 10:return Dm(u.type._context),gr(u),null;case 17:return Ur(u.type)&&Xd(),gr(u),null;case 19:if(En(Dn),N=u.memoizedState,N===null)return gr(u),null;if(y=(u.flags&128)!==0,O=N.rendering,O===null)if(y)cu(N,!1);else{if(tr!==0||l!==null&&(l.flags&128)!==0)for(l=u.child;l!==null;){if(O=lh(l),O!==null){for(u.flags|=128,cu(N,!1),y=O.updateQueue,y!==null&&(u.updateQueue=y,u.flags|=4),u.subtreeFlags=0,y=m,m=u.child;m!==null;)N=m,l=y,N.flags&=14680066,O=N.alternate,O===null?(N.childLanes=0,N.lanes=l,N.child=null,N.subtreeFlags=0,N.memoizedProps=null,N.memoizedState=null,N.updateQueue=null,N.dependencies=null,N.stateNode=null):(N.childLanes=O.childLanes,N.lanes=O.lanes,N.child=O.child,N.subtreeFlags=0,N.deletions=null,N.memoizedProps=O.memoizedProps,N.memoizedState=O.memoizedState,N.updateQueue=O.updateQueue,N.type=O.type,l=O.dependencies,N.dependencies=l===null?null:{lanes:l.lanes,firstContext:l.firstContext}),m=m.sibling;return wn(Dn,Dn.current&1|2),u.child}l=l.sibling}N.tail!==null&&cn()>zl&&(u.flags|=128,y=!0,cu(N,!1),u.lanes=4194304)}else{if(!y)if(l=lh(O),l!==null){if(u.flags|=128,y=!0,m=l.updateQueue,m!==null&&(u.updateQueue=m,u.flags|=4),cu(N,!0),N.tail===null&&N.tailMode==="hidden"&&!O.alternate&&!_n)return gr(u),null}else 2*cn()-N.renderingStartTime>zl&&m!==1073741824&&(u.flags|=128,y=!0,cu(N,!1),u.lanes=4194304);N.isBackwards?(O.sibling=u.child,u.child=O):(m=N.last,m!==null?m.sibling=O:u.child=O,N.last=O)}return N.tail!==null?(u=N.tail,N.rendering=u,N.tail=u.sibling,N.renderingStartTime=cn(),u.sibling=null,m=Dn.current,wn(Dn,y?m&1|2:m&1),u):(gr(u),null);case 22:case 23:return xg(),y=u.memoizedState!==null,l!==null&&l.memoizedState!==null!==y&&(u.flags|=8192),y&&(u.mode&1)!==0?(ai&1073741824)!==0&&(gr(u),u.subtreeFlags&6&&(u.flags|=8192)):gr(u),null;case 24:return null;case 25:return null}throw Error(n(156,u.tag))}function mI(l,u){switch(jm(u),u.tag){case 1:return Ur(u.type)&&Xd(),l=u.flags,l&65536?(u.flags=l&-65537|128,u):null;case 3:return Ll(),En(Fr),En(pr),zm(),l=u.flags,(l&65536)!==0&&(l&128)===0?(u.flags=l&-65537|128,u):null;case 5:return Um(u),null;case 13:if(En(Dn),l=u.memoizedState,l!==null&&l.dehydrated!==null){if(u.alternate===null)throw Error(n(340));Ml()}return l=u.flags,l&65536?(u.flags=l&-65537|128,u):null;case 19:return En(Dn),null;case 4:return Ll(),null;case 10:return Dm(u.type._context),null;case 22:case 23:return xg(),null;case 24:return null;default:return null}}var vh=!1,vr=!1,gI=typeof WeakSet=="function"?WeakSet:Set,Xe=null;function Ul(l,u){var m=l.ref;if(m!==null)if(typeof m=="function")try{m(null)}catch(y){Un(l,u,y)}else m.current=null}function og(l,u,m){try{m()}catch(y){Un(l,u,y)}}var ow=!1;function vI(l,u){if(xm=Ld,l=Ub(),dm(l)){if("selectionStart"in l)var m={start:l.selectionStart,end:l.selectionEnd};else e:{m=(m=l.ownerDocument)&&m.defaultView||window;var y=m.getSelection&&m.getSelection();if(y&&y.rangeCount!==0){m=y.anchorNode;var b=y.anchorOffset,N=y.focusNode;y=y.focusOffset;try{m.nodeType,N.nodeType}catch{m=null;break e}var O=0,G=-1,te=-1,ge=0,Pe=0,Ie=l,Ee=null;t:for(;;){for(var qe;Ie!==m||b!==0&&Ie.nodeType!==3||(G=O+b),Ie!==N||y!==0&&Ie.nodeType!==3||(te=O+y),Ie.nodeType===3&&(O+=Ie.nodeValue.length),(qe=Ie.firstChild)!==null;)Ee=Ie,Ie=qe;for(;;){if(Ie===l)break t;if(Ee===m&&++ge===b&&(G=O),Ee===N&&++Pe===y&&(te=O),(qe=Ie.nextSibling)!==null)break;Ie=Ee,Ee=Ie.parentNode}Ie=qe}m=G===-1||te===-1?null:{start:G,end:te}}else m=null}m=m||{start:0,end:0}}else m=null;for(bm={focusedElem:l,selectionRange:m},Ld=!1,Xe=u;Xe!==null;)if(u=Xe,l=u.child,(u.subtreeFlags&1028)!==0&&l!==null)l.return=u,Xe=l;else for(;Xe!==null;){u=Xe;try{var et=u.alternate;if((u.flags&1024)!==0)switch(u.tag){case 0:case 11:case 15:break;case 1:if(et!==null){var it=et.memoizedProps,Wn=et.memoizedState,le=u.stateNode,ie=le.getSnapshotBeforeUpdate(u.elementType===u.type?it:Fi(u.type,it),Wn);le.__reactInternalSnapshotBeforeUpdate=ie}break;case 3:var he=u.stateNode.containerInfo;he.nodeType===1?he.textContent="":he.nodeType===9&&he.documentElement&&he.removeChild(he.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(n(163))}}catch(Le){Un(u,u.return,Le)}if(l=u.sibling,l!==null){l.return=u.return,Xe=l;break}Xe=u.return}return et=ow,ow=!1,et}function uu(l,u,m){var y=u.updateQueue;if(y=y!==null?y.lastEffect:null,y!==null){var b=y=y.next;do{if((b.tag&l)===l){var N=b.destroy;b.destroy=void 0,N!==void 0&&og(u,m,N)}b=b.next}while(b!==y)}}function yh(l,u){if(u=u.updateQueue,u=u!==null?u.lastEffect:null,u!==null){var m=u=u.next;do{if((m.tag&l)===l){var y=m.create;m.destroy=y()}m=m.next}while(m!==u)}}function lg(l){var u=l.ref;if(u!==null){var m=l.stateNode;switch(l.tag){case 5:l=m;break;default:l=m}typeof u=="function"?u(l):u.current=l}}function lw(l){var u=l.alternate;u!==null&&(l.alternate=null,lw(u)),l.child=null,l.deletions=null,l.sibling=null,l.tag===5&&(u=l.stateNode,u!==null&&(delete u[ds],delete u[Zc],delete u[Cm],delete u[Z4],delete u[eI])),l.stateNode=null,l.return=null,l.dependencies=null,l.memoizedProps=null,l.memoizedState=null,l.pendingProps=null,l.stateNode=null,l.updateQueue=null}function cw(l){return l.tag===5||l.tag===3||l.tag===4}function uw(l){e:for(;;){for(;l.sibling===null;){if(l.return===null||cw(l.return))return null;l=l.return}for(l.sibling.return=l.return,l=l.sibling;l.tag!==5&&l.tag!==6&&l.tag!==18;){if(l.flags&2||l.child===null||l.tag===4)continue e;l.child.return=l,l=l.child}if(!(l.flags&2))return l.stateNode}}function cg(l,u,m){var y=l.tag;if(y===5||y===6)l=l.stateNode,u?m.nodeType===8?m.parentNode.insertBefore(l,u):m.insertBefore(l,u):(m.nodeType===8?(u=m.parentNode,u.insertBefore(l,m)):(u=m,u.appendChild(l)),m=m._reactRootContainer,m!=null||u.onclick!==null||(u.onclick=Yd));else if(y!==4&&(l=l.child,l!==null))for(cg(l,u,m),l=l.sibling;l!==null;)cg(l,u,m),l=l.sibling}function ug(l,u,m){var y=l.tag;if(y===5||y===6)l=l.stateNode,u?m.insertBefore(l,u):m.appendChild(l);else if(y!==4&&(l=l.child,l!==null))for(ug(l,u,m),l=l.sibling;l!==null;)ug(l,u,m),l=l.sibling}var ur=null,Ui=!1;function Da(l,u,m){for(m=m.child;m!==null;)dw(l,u,m),m=m.sibling}function dw(l,u,m){if(jr&&typeof jr.onCommitFiberUnmount=="function")try{jr.onCommitFiberUnmount(Vs,m)}catch{}switch(m.tag){case 5:vr||Ul(m,u);case 6:var y=ur,b=Ui;ur=null,Da(l,u,m),ur=y,Ui=b,ur!==null&&(Ui?(l=ur,m=m.stateNode,l.nodeType===8?l.parentNode.removeChild(m):l.removeChild(m)):ur.removeChild(m.stateNode));break;case 18:ur!==null&&(Ui?(l=ur,m=m.stateNode,l.nodeType===8?Sm(l.parentNode,m):l.nodeType===1&&Sm(l,m),$c(l)):Sm(ur,m.stateNode));break;case 4:y=ur,b=Ui,ur=m.stateNode.containerInfo,Ui=!0,Da(l,u,m),ur=y,Ui=b;break;case 0:case 11:case 14:case 15:if(!vr&&(y=m.updateQueue,y!==null&&(y=y.lastEffect,y!==null))){b=y=y.next;do{var N=b,O=N.destroy;N=N.tag,O!==void 0&&((N&2)!==0||(N&4)!==0)&&og(m,u,O),b=b.next}while(b!==y)}Da(l,u,m);break;case 1:if(!vr&&(Ul(m,u),y=m.stateNode,typeof y.componentWillUnmount=="function"))try{y.props=m.memoizedProps,y.state=m.memoizedState,y.componentWillUnmount()}catch(G){Un(m,u,G)}Da(l,u,m);break;case 21:Da(l,u,m);break;case 22:m.mode&1?(vr=(y=vr)||m.memoizedState!==null,Da(l,u,m),vr=y):Da(l,u,m);break;default:Da(l,u,m)}}function hw(l){var u=l.updateQueue;if(u!==null){l.updateQueue=null;var m=l.stateNode;m===null&&(m=l.stateNode=new gI),u.forEach(function(y){var b=NI.bind(null,l,y);m.has(y)||(m.add(y),y.then(b,b))})}}function Bi(l,u){var m=u.deletions;if(m!==null)for(var y=0;y<m.length;y++){var b=m[y];try{var N=l,O=u,G=O;e:for(;G!==null;){switch(G.tag){case 5:ur=G.stateNode,Ui=!1;break e;case 3:ur=G.stateNode.containerInfo,Ui=!0;break e;case 4:ur=G.stateNode.containerInfo,Ui=!0;break e}G=G.return}if(ur===null)throw Error(n(160));dw(N,O,b),ur=null,Ui=!1;var te=b.alternate;te!==null&&(te.return=null),b.return=null}catch(ge){Un(b,u,ge)}}if(u.subtreeFlags&12854)for(u=u.child;u!==null;)fw(u,l),u=u.sibling}function fw(l,u){var m=l.alternate,y=l.flags;switch(l.tag){case 0:case 11:case 14:case 15:if(Bi(u,l),ps(l),y&4){try{uu(3,l,l.return),yh(3,l)}catch(it){Un(l,l.return,it)}try{uu(5,l,l.return)}catch(it){Un(l,l.return,it)}}break;case 1:Bi(u,l),ps(l),y&512&&m!==null&&Ul(m,m.return);break;case 5:if(Bi(u,l),ps(l),y&512&&m!==null&&Ul(m,m.return),l.flags&32){var b=l.stateNode;try{gt(b,"")}catch(it){Un(l,l.return,it)}}if(y&4&&(b=l.stateNode,b!=null)){var N=l.memoizedProps,O=m!==null?m.memoizedProps:N,G=l.type,te=l.updateQueue;if(l.updateQueue=null,te!==null)try{G==="input"&&N.type==="radio"&&N.name!=null&&Ke(b,N),Wt(G,O);var ge=Wt(G,N);for(O=0;O<te.length;O+=2){var Pe=te[O],Ie=te[O+1];Pe==="style"?pe(b,Ie):Pe==="dangerouslySetInnerHTML"?He(b,Ie):Pe==="children"?gt(b,Ie):j(b,Pe,Ie,ge)}switch(G){case"input":dt(b,N);break;case"textarea":gn(b,N);break;case"select":var Ee=b._wrapperState.wasMultiple;b._wrapperState.wasMultiple=!!N.multiple;var qe=N.value;qe!=null?xt(b,!!N.multiple,qe,!1):Ee!==!!N.multiple&&(N.defaultValue!=null?xt(b,!!N.multiple,N.defaultValue,!0):xt(b,!!N.multiple,N.multiple?[]:"",!1))}b[Zc]=N}catch(it){Un(l,l.return,it)}}break;case 6:if(Bi(u,l),ps(l),y&4){if(l.stateNode===null)throw Error(n(162));b=l.stateNode,N=l.memoizedProps;try{b.nodeValue=N}catch(it){Un(l,l.return,it)}}break;case 3:if(Bi(u,l),ps(l),y&4&&m!==null&&m.memoizedState.isDehydrated)try{$c(u.containerInfo)}catch(it){Un(l,l.return,it)}break;case 4:Bi(u,l),ps(l);break;case 13:Bi(u,l),ps(l),b=l.child,b.flags&8192&&(N=b.memoizedState!==null,b.stateNode.isHidden=N,!N||b.alternate!==null&&b.alternate.memoizedState!==null||(fg=cn())),y&4&&hw(l);break;case 22:if(Pe=m!==null&&m.memoizedState!==null,l.mode&1?(vr=(ge=vr)||Pe,Bi(u,l),vr=ge):Bi(u,l),ps(l),y&8192){if(ge=l.memoizedState!==null,(l.stateNode.isHidden=ge)&&!Pe&&(l.mode&1)!==0)for(Xe=l,Pe=l.child;Pe!==null;){for(Ie=Xe=Pe;Xe!==null;){switch(Ee=Xe,qe=Ee.child,Ee.tag){case 0:case 11:case 14:case 15:uu(4,Ee,Ee.return);break;case 1:Ul(Ee,Ee.return);var et=Ee.stateNode;if(typeof et.componentWillUnmount=="function"){y=Ee,m=Ee.return;try{u=y,et.props=u.memoizedProps,et.state=u.memoizedState,et.componentWillUnmount()}catch(it){Un(y,m,it)}}break;case 5:Ul(Ee,Ee.return);break;case 22:if(Ee.memoizedState!==null){gw(Ie);continue}}qe!==null?(qe.return=Ee,Xe=qe):gw(Ie)}Pe=Pe.sibling}e:for(Pe=null,Ie=l;;){if(Ie.tag===5){if(Pe===null){Pe=Ie;try{b=Ie.stateNode,ge?(N=b.style,typeof N.setProperty=="function"?N.setProperty("display","none","important"):N.display="none"):(G=Ie.stateNode,te=Ie.memoizedProps.style,O=te!=null&&te.hasOwnProperty("display")?te.display:null,G.style.display=Fn("display",O))}catch(it){Un(l,l.return,it)}}}else if(Ie.tag===6){if(Pe===null)try{Ie.stateNode.nodeValue=ge?"":Ie.memoizedProps}catch(it){Un(l,l.return,it)}}else if((Ie.tag!==22&&Ie.tag!==23||Ie.memoizedState===null||Ie===l)&&Ie.child!==null){Ie.child.return=Ie,Ie=Ie.child;continue}if(Ie===l)break e;for(;Ie.sibling===null;){if(Ie.return===null||Ie.return===l)break e;Pe===Ie&&(Pe=null),Ie=Ie.return}Pe===Ie&&(Pe=null),Ie.sibling.return=Ie.return,Ie=Ie.sibling}}break;case 19:Bi(u,l),ps(l),y&4&&hw(l);break;case 21:break;default:Bi(u,l),ps(l)}}function ps(l){var u=l.flags;if(u&2){try{e:{for(var m=l.return;m!==null;){if(cw(m)){var y=m;break e}m=m.return}throw Error(n(160))}switch(y.tag){case 5:var b=y.stateNode;y.flags&32&&(gt(b,""),y.flags&=-33);var N=uw(l);ug(l,N,b);break;case 3:case 4:var O=y.stateNode.containerInfo,G=uw(l);cg(l,G,O);break;default:throw Error(n(161))}}catch(te){Un(l,l.return,te)}l.flags&=-3}u&4096&&(l.flags&=-4097)}function yI(l,u,m){Xe=l,pw(l)}function pw(l,u,m){for(var y=(l.mode&1)!==0;Xe!==null;){var b=Xe,N=b.child;if(b.tag===22&&y){var O=b.memoizedState!==null||vh;if(!O){var G=b.alternate,te=G!==null&&G.memoizedState!==null||vr;G=vh;var ge=vr;if(vh=O,(vr=te)&&!ge)for(Xe=b;Xe!==null;)O=Xe,te=O.child,O.tag===22&&O.memoizedState!==null?vw(b):te!==null?(te.return=O,Xe=te):vw(b);for(;N!==null;)Xe=N,pw(N),N=N.sibling;Xe=b,vh=G,vr=ge}mw(l)}else(b.subtreeFlags&8772)!==0&&N!==null?(N.return=b,Xe=N):mw(l)}}function mw(l){for(;Xe!==null;){var u=Xe;if((u.flags&8772)!==0){var m=u.alternate;try{if((u.flags&8772)!==0)switch(u.tag){case 0:case 11:case 15:vr||yh(5,u);break;case 1:var y=u.stateNode;if(u.flags&4&&!vr)if(m===null)y.componentDidMount();else{var b=u.elementType===u.type?m.memoizedProps:Fi(u.type,m.memoizedProps);y.componentDidUpdate(b,m.memoizedState,y.__reactInternalSnapshotBeforeUpdate)}var N=u.updateQueue;N!==null&&gk(u,N,y);break;case 3:var O=u.updateQueue;if(O!==null){if(m=null,u.child!==null)switch(u.child.tag){case 5:m=u.child.stateNode;break;case 1:m=u.child.stateNode}gk(u,O,m)}break;case 5:var G=u.stateNode;if(m===null&&u.flags&4){m=G;var te=u.memoizedProps;switch(u.type){case"button":case"input":case"select":case"textarea":te.autoFocus&&m.focus();break;case"img":te.src&&(m.src=te.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(u.memoizedState===null){var ge=u.alternate;if(ge!==null){var Pe=ge.memoizedState;if(Pe!==null){var Ie=Pe.dehydrated;Ie!==null&&$c(Ie)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(n(163))}vr||u.flags&512&&lg(u)}catch(Ee){Un(u,u.return,Ee)}}if(u===l){Xe=null;break}if(m=u.sibling,m!==null){m.return=u.return,Xe=m;break}Xe=u.return}}function gw(l){for(;Xe!==null;){var u=Xe;if(u===l){Xe=null;break}var m=u.sibling;if(m!==null){m.return=u.return,Xe=m;break}Xe=u.return}}function vw(l){for(;Xe!==null;){var u=Xe;try{switch(u.tag){case 0:case 11:case 15:var m=u.return;try{yh(4,u)}catch(te){Un(u,m,te)}break;case 1:var y=u.stateNode;if(typeof y.componentDidMount=="function"){var b=u.return;try{y.componentDidMount()}catch(te){Un(u,b,te)}}var N=u.return;try{lg(u)}catch(te){Un(u,N,te)}break;case 5:var O=u.return;try{lg(u)}catch(te){Un(u,O,te)}}}catch(te){Un(u,u.return,te)}if(u===l){Xe=null;break}var G=u.sibling;if(G!==null){G.return=u.return,Xe=G;break}Xe=u.return}}var xI=Math.ceil,xh=R.ReactCurrentDispatcher,dg=R.ReactCurrentOwner,Si=R.ReactCurrentBatchConfig,Ht=0,ar=null,Yn=null,dr=0,ai=0,Bl=Pa(0),tr=0,du=null,Ro=0,bh=0,hg=0,hu=null,zr=null,fg=0,zl=1/0,Zs=null,kh=!1,pg=null,Aa=null,wh=!1,Oa=null,Sh=0,fu=0,mg=null,Ch=-1,Th=0;function _r(){return(Ht&6)!==0?cn():Ch!==-1?Ch:Ch=cn()}function La(l){return(l.mode&1)===0?1:(Ht&2)!==0&&dr!==0?dr&-dr:nI.transition!==null?(Th===0&&(Th=ub()),Th):(l=un,l!==0||(l=window.event,l=l===void 0?16:xb(l.type)),l)}function zi(l,u,m,y){if(50<fu)throw fu=0,mg=null,Error(n(185));Lc(l,m,y),((Ht&2)===0||l!==ar)&&(l===ar&&((Ht&2)===0&&(bh|=m),tr===4&&Fa(l,dr)),$r(l,y),m===1&&Ht===0&&(u.mode&1)===0&&(zl=cn()+500,Zd&&Ra()))}function $r(l,u){var m=l.callbackNode;n4(l,u);var y=Dd(l,l===ar?dr:0);if(y===0)m!==null&&ir(m),l.callbackNode=null,l.callbackPriority=0;else if(u=y&-y,l.callbackPriority!==u){if(m!=null&&ir(m),u===1)l.tag===0?tI(xw.bind(null,l)):ik(xw.bind(null,l)),X4(function(){(Ht&6)===0&&Ra()}),m=null;else{switch(db(y)){case 1:m=yi;break;case 4:m=ni;break;case 16:m=ba;break;case 536870912:m=us;break;default:m=ba}m=Ew(m,yw.bind(null,l))}l.callbackPriority=u,l.callbackNode=m}}function yw(l,u){if(Ch=-1,Th=0,(Ht&6)!==0)throw Error(n(327));var m=l.callbackNode;if($l()&&l.callbackNode!==m)return null;var y=Dd(l,l===ar?dr:0);if(y===0)return null;if((y&30)!==0||(y&l.expiredLanes)!==0||u)u=Nh(l,y);else{u=y;var b=Ht;Ht|=2;var N=kw();(ar!==l||dr!==u)&&(Zs=null,zl=cn()+500,Mo(l,u));do try{wI();break}catch(G){bw(l,G)}while(!0);Mm(),xh.current=N,Ht=b,Yn!==null?u=0:(ar=null,dr=0,u=tr)}if(u!==0){if(u===2&&(b=Yp(l),b!==0&&(y=b,u=gg(l,b))),u===1)throw m=du,Mo(l,0),Fa(l,y),$r(l,cn()),m;if(u===6)Fa(l,y);else{if(b=l.current.alternate,(y&30)===0&&!bI(b)&&(u=Nh(l,y),u===2&&(N=Yp(l),N!==0&&(y=N,u=gg(l,N))),u===1))throw m=du,Mo(l,0),Fa(l,y),$r(l,cn()),m;switch(l.finishedWork=b,l.finishedLanes=y,u){case 0:case 1:throw Error(n(345));case 2:Do(l,zr,Zs);break;case 3:if(Fa(l,y),(y&130023424)===y&&(u=fg+500-cn(),10<u)){if(Dd(l,0)!==0)break;if(b=l.suspendedLanes,(b&y)!==y){_r(),l.pingedLanes|=l.suspendedLanes&b;break}l.timeoutHandle=wm(Do.bind(null,l,zr,Zs),u);break}Do(l,zr,Zs);break;case 4:if(Fa(l,y),(y&4194240)===y)break;for(u=l.eventTimes,b=-1;0<y;){var O=31-fn(y);N=1<<O,O=u[O],O>b&&(b=O),y&=~N}if(y=b,y=cn()-y,y=(120>y?120:480>y?480:1080>y?1080:1920>y?1920:3e3>y?3e3:4320>y?4320:1960*xI(y/1960))-y,10<y){l.timeoutHandle=wm(Do.bind(null,l,zr,Zs),y);break}Do(l,zr,Zs);break;case 5:Do(l,zr,Zs);break;default:throw Error(n(329))}}}return $r(l,cn()),l.callbackNode===m?yw.bind(null,l):null}function gg(l,u){var m=hu;return l.current.memoizedState.isDehydrated&&(Mo(l,u).flags|=256),l=Nh(l,u),l!==2&&(u=zr,zr=m,u!==null&&vg(u)),l}function vg(l){zr===null?zr=l:zr.push.apply(zr,l)}function bI(l){for(var u=l;;){if(u.flags&16384){var m=u.updateQueue;if(m!==null&&(m=m.stores,m!==null))for(var y=0;y<m.length;y++){var b=m[y],N=b.getSnapshot;b=b.value;try{if(!Oi(N(),b))return!1}catch{return!1}}}if(m=u.child,u.subtreeFlags&16384&&m!==null)m.return=u,u=m;else{if(u===l)break;for(;u.sibling===null;){if(u.return===null||u.return===l)return!0;u=u.return}u.sibling.return=u.return,u=u.sibling}}return!0}function Fa(l,u){for(u&=~hg,u&=~bh,l.suspendedLanes|=u,l.pingedLanes&=~u,l=l.expirationTimes;0<u;){var m=31-fn(u),y=1<<m;l[m]=-1,u&=~y}}function xw(l){if((Ht&6)!==0)throw Error(n(327));$l();var u=Dd(l,0);if((u&1)===0)return $r(l,cn()),null;var m=Nh(l,u);if(l.tag!==0&&m===2){var y=Yp(l);y!==0&&(u=y,m=gg(l,y))}if(m===1)throw m=du,Mo(l,0),Fa(l,u),$r(l,cn()),m;if(m===6)throw Error(n(345));return l.finishedWork=l.current.alternate,l.finishedLanes=u,Do(l,zr,Zs),$r(l,cn()),null}function yg(l,u){var m=Ht;Ht|=1;try{return l(u)}finally{Ht=m,Ht===0&&(zl=cn()+500,Zd&&Ra())}}function Io(l){Oa!==null&&Oa.tag===0&&(Ht&6)===0&&$l();var u=Ht;Ht|=1;var m=Si.transition,y=un;try{if(Si.transition=null,un=1,l)return l()}finally{un=y,Si.transition=m,Ht=u,(Ht&6)===0&&Ra()}}function xg(){ai=Bl.current,En(Bl)}function Mo(l,u){l.finishedWork=null,l.finishedLanes=0;var m=l.timeoutHandle;if(m!==-1&&(l.timeoutHandle=-1,J4(m)),Yn!==null)for(m=Yn.return;m!==null;){var y=m;switch(jm(y),y.tag){case 1:y=y.type.childContextTypes,y!=null&&Xd();break;case 3:Ll(),En(Fr),En(pr),zm();break;case 5:Um(y);break;case 4:Ll();break;case 13:En(Dn);break;case 19:En(Dn);break;case 10:Dm(y.type._context);break;case 22:case 23:xg()}m=m.return}if(ar=l,Yn=l=Ua(l.current,null),dr=ai=u,tr=0,du=null,hg=bh=Ro=0,zr=hu=null,jo!==null){for(u=0;u<jo.length;u++)if(m=jo[u],y=m.interleaved,y!==null){m.interleaved=null;var b=y.next,N=m.pending;if(N!==null){var O=N.next;N.next=b,y.next=O}m.pending=y}jo=null}return l}function bw(l,u){do{var m=Yn;try{if(Mm(),ch.current=fh,uh){for(var y=An.memoizedState;y!==null;){var b=y.queue;b!==null&&(b.pending=null),y=y.next}uh=!1}if(_o=0,sr=er=An=null,su=!1,au=0,dg.current=null,m===null||m.return===null){tr=1,du=u,Yn=null;break}e:{var N=l,O=m.return,G=m,te=u;if(u=dr,G.flags|=32768,te!==null&&typeof te=="object"&&typeof te.then=="function"){var ge=te,Pe=G,Ie=Pe.tag;if((Pe.mode&1)===0&&(Ie===0||Ie===11||Ie===15)){var Ee=Pe.alternate;Ee?(Pe.updateQueue=Ee.updateQueue,Pe.memoizedState=Ee.memoizedState,Pe.lanes=Ee.lanes):(Pe.updateQueue=null,Pe.memoizedState=null)}var qe=Hk(O);if(qe!==null){qe.flags&=-257,qk(qe,O,G,N,u),qe.mode&1&&Wk(N,ge,u),u=qe,te=ge;var et=u.updateQueue;if(et===null){var it=new Set;it.add(te),u.updateQueue=it}else et.add(te);break e}else{if((u&1)===0){Wk(N,ge,u),bg();break e}te=Error(n(426))}}else if(_n&&G.mode&1){var Wn=Hk(O);if(Wn!==null){(Wn.flags&65536)===0&&(Wn.flags|=256),qk(Wn,O,G,N,u),Rm(Fl(te,G));break e}}N=te=Fl(te,G),tr!==4&&(tr=2),hu===null?hu=[N]:hu.push(N),N=O;do{switch(N.tag){case 3:N.flags|=65536,u&=-u,N.lanes|=u;var le=$k(N,te,u);mk(N,le);break e;case 1:G=te;var ie=N.type,he=N.stateNode;if((N.flags&128)===0&&(typeof ie.getDerivedStateFromError=="function"||he!==null&&typeof he.componentDidCatch=="function"&&(Aa===null||!Aa.has(he)))){N.flags|=65536,u&=-u,N.lanes|=u;var Le=Vk(N,G,u);mk(N,Le);break e}}N=N.return}while(N!==null)}Sw(m)}catch(ot){u=ot,Yn===m&&m!==null&&(Yn=m=m.return);continue}break}while(!0)}function kw(){var l=xh.current;return xh.current=fh,l===null?fh:l}function bg(){(tr===0||tr===3||tr===2)&&(tr=4),ar===null||(Ro&268435455)===0&&(bh&268435455)===0||Fa(ar,dr)}function Nh(l,u){var m=Ht;Ht|=2;var y=kw();(ar!==l||dr!==u)&&(Zs=null,Mo(l,u));do try{kI();break}catch(b){bw(l,b)}while(!0);if(Mm(),Ht=m,xh.current=y,Yn!==null)throw Error(n(261));return ar=null,dr=0,tr}function kI(){for(;Yn!==null;)ww(Yn)}function wI(){for(;Yn!==null&&!an();)ww(Yn)}function ww(l){var u=Nw(l.alternate,l,ai);l.memoizedProps=l.pendingProps,u===null?Sw(l):Yn=u,dg.current=null}function Sw(l){var u=l;do{var m=u.alternate;if(l=u.return,(u.flags&32768)===0){if(m=pI(m,u,ai),m!==null){Yn=m;return}}else{if(m=mI(m,u),m!==null){m.flags&=32767,Yn=m;return}if(l!==null)l.flags|=32768,l.subtreeFlags=0,l.deletions=null;else{tr=6,Yn=null;return}}if(u=u.sibling,u!==null){Yn=u;return}Yn=u=l}while(u!==null);tr===0&&(tr=5)}function Do(l,u,m){var y=un,b=Si.transition;try{Si.transition=null,un=1,SI(l,u,m,y)}finally{Si.transition=b,un=y}return null}function SI(l,u,m,y){do $l();while(Oa!==null);if((Ht&6)!==0)throw Error(n(327));m=l.finishedWork;var b=l.finishedLanes;if(m===null)return null;if(l.finishedWork=null,l.finishedLanes=0,m===l.current)throw Error(n(177));l.callbackNode=null,l.callbackPriority=0;var N=m.lanes|m.childLanes;if(r4(l,N),l===ar&&(Yn=ar=null,dr=0),(m.subtreeFlags&2064)===0&&(m.flags&2064)===0||wh||(wh=!0,Ew(ba,function(){return $l(),null})),N=(m.flags&15990)!==0,(m.subtreeFlags&15990)!==0||N){N=Si.transition,Si.transition=null;var O=un;un=1;var G=Ht;Ht|=4,dg.current=null,vI(l,m),fw(m,l),V4(bm),Ld=!!xm,bm=xm=null,l.current=m,yI(m),Lr(),Ht=G,un=O,Si.transition=N}else l.current=m;if(wh&&(wh=!1,Oa=l,Sh=b),N=l.pendingLanes,N===0&&(Aa=null),zt(m.stateNode),$r(l,cn()),u!==null)for(y=l.onRecoverableError,m=0;m<u.length;m++)b=u[m],y(b.value,{componentStack:b.stack,digest:b.digest});if(kh)throw kh=!1,l=pg,pg=null,l;return(Sh&1)!==0&&l.tag!==0&&$l(),N=l.pendingLanes,(N&1)!==0?l===mg?fu++:(fu=0,mg=l):fu=0,Ra(),null}function $l(){if(Oa!==null){var l=db(Sh),u=Si.transition,m=un;try{if(Si.transition=null,un=16>l?16:l,Oa===null)var y=!1;else{if(l=Oa,Oa=null,Sh=0,(Ht&6)!==0)throw Error(n(331));var b=Ht;for(Ht|=4,Xe=l.current;Xe!==null;){var N=Xe,O=N.child;if((Xe.flags&16)!==0){var G=N.deletions;if(G!==null){for(var te=0;te<G.length;te++){var ge=G[te];for(Xe=ge;Xe!==null;){var Pe=Xe;switch(Pe.tag){case 0:case 11:case 15:uu(8,Pe,N)}var Ie=Pe.child;if(Ie!==null)Ie.return=Pe,Xe=Ie;else for(;Xe!==null;){Pe=Xe;var Ee=Pe.sibling,qe=Pe.return;if(lw(Pe),Pe===ge){Xe=null;break}if(Ee!==null){Ee.return=qe,Xe=Ee;break}Xe=qe}}}var et=N.alternate;if(et!==null){var it=et.child;if(it!==null){et.child=null;do{var Wn=it.sibling;it.sibling=null,it=Wn}while(it!==null)}}Xe=N}}if((N.subtreeFlags&2064)!==0&&O!==null)O.return=N,Xe=O;else e:for(;Xe!==null;){if(N=Xe,(N.flags&2048)!==0)switch(N.tag){case 0:case 11:case 15:uu(9,N,N.return)}var le=N.sibling;if(le!==null){le.return=N.return,Xe=le;break e}Xe=N.return}}var ie=l.current;for(Xe=ie;Xe!==null;){O=Xe;var he=O.child;if((O.subtreeFlags&2064)!==0&&he!==null)he.return=O,Xe=he;else e:for(O=ie;Xe!==null;){if(G=Xe,(G.flags&2048)!==0)try{switch(G.tag){case 0:case 11:case 15:yh(9,G)}}catch(ot){Un(G,G.return,ot)}if(G===O){Xe=null;break e}var Le=G.sibling;if(Le!==null){Le.return=G.return,Xe=Le;break e}Xe=G.return}}if(Ht=b,Ra(),jr&&typeof jr.onPostCommitFiberRoot=="function")try{jr.onPostCommitFiberRoot(Vs,l)}catch{}y=!0}return y}finally{un=m,Si.transition=u}}return!1}function Cw(l,u,m){u=Fl(m,u),u=$k(l,u,1),l=Ma(l,u,1),u=_r(),l!==null&&(Lc(l,1,u),$r(l,u))}function Un(l,u,m){if(l.tag===3)Cw(l,l,m);else for(;u!==null;){if(u.tag===3){Cw(u,l,m);break}else if(u.tag===1){var y=u.stateNode;if(typeof u.type.getDerivedStateFromError=="function"||typeof y.componentDidCatch=="function"&&(Aa===null||!Aa.has(y))){l=Fl(m,l),l=Vk(u,l,1),u=Ma(u,l,1),l=_r(),u!==null&&(Lc(u,1,l),$r(u,l));break}}u=u.return}}function CI(l,u,m){var y=l.pingCache;y!==null&&y.delete(u),u=_r(),l.pingedLanes|=l.suspendedLanes&m,ar===l&&(dr&m)===m&&(tr===4||tr===3&&(dr&130023424)===dr&&500>cn()-fg?Mo(l,0):hg|=m),$r(l,u)}function Tw(l,u){u===0&&((l.mode&1)===0?u=1:(u=wo,wo<<=1,(wo&130023424)===0&&(wo=4194304)));var m=_r();l=Js(l,u),l!==null&&(Lc(l,u,m),$r(l,m))}function TI(l){var u=l.memoizedState,m=0;u!==null&&(m=u.retryLane),Tw(l,m)}function NI(l,u){var m=0;switch(l.tag){case 13:var y=l.stateNode,b=l.memoizedState;b!==null&&(m=b.retryLane);break;case 19:y=l.stateNode;break;default:throw Error(n(314))}y!==null&&y.delete(u),Tw(l,m)}var Nw;Nw=function(l,u,m){if(l!==null)if(l.memoizedProps!==u.pendingProps||Fr.current)Br=!0;else{if((l.lanes&m)===0&&(u.flags&128)===0)return Br=!1,fI(l,u,m);Br=(l.flags&131072)!==0}else Br=!1,_n&&(u.flags&1048576)!==0&&sk(u,th,u.index);switch(u.lanes=0,u.tag){case 2:var y=u.type;gh(l,u),l=u.pendingProps;var b=_l(u,pr.current);Ol(u,m),b=Wm(null,u,y,l,b,m);var N=Hm();return u.flags|=1,typeof b=="object"&&b!==null&&typeof b.render=="function"&&b.$$typeof===void 0?(u.tag=1,u.memoizedState=null,u.updateQueue=null,Ur(y)?(N=!0,Qd(u)):N=!1,u.memoizedState=b.state!==null&&b.state!==void 0?b.state:null,Lm(u),b.updater=ph,u.stateNode=b,b._reactInternals=u,Xm(u,y,l,m),u=tg(null,u,y,!0,N,m)):(u.tag=0,_n&&N&&Em(u),Pr(null,u,b,m),u=u.child),u;case 16:y=u.elementType;e:{switch(gh(l,u),l=u.pendingProps,b=y._init,y=b(y._payload),u.type=y,b=u.tag=jI(y),l=Fi(y,l),b){case 0:u=eg(null,u,y,l,m);break e;case 1:u=Qk(null,u,y,l,m);break e;case 11:u=Kk(null,u,y,l,m);break e;case 14:u=Gk(null,u,y,Fi(y.type,l),m);break e}throw Error(n(306,y,""))}return u;case 0:return y=u.type,b=u.pendingProps,b=u.elementType===y?b:Fi(y,b),eg(l,u,y,b,m);case 1:return y=u.type,b=u.pendingProps,b=u.elementType===y?b:Fi(y,b),Qk(l,u,y,b,m);case 3:e:{if(Zk(u),l===null)throw Error(n(387));y=u.pendingProps,N=u.memoizedState,b=N.element,pk(l,u),oh(u,y,null,m);var O=u.memoizedState;if(y=O.element,N.isDehydrated)if(N={element:y,isDehydrated:!1,cache:O.cache,pendingSuspenseBoundaries:O.pendingSuspenseBoundaries,transitions:O.transitions},u.updateQueue.baseState=N,u.memoizedState=N,u.flags&256){b=Fl(Error(n(423)),u),u=ew(l,u,y,m,b);break e}else if(y!==b){b=Fl(Error(n(424)),u),u=ew(l,u,y,m,b);break e}else for(si=ja(u.stateNode.containerInfo.firstChild),ii=u,_n=!0,Li=null,m=hk(u,null,y,m),u.child=m;m;)m.flags=m.flags&-3|4096,m=m.sibling;else{if(Ml(),y===b){u=Qs(l,u,m);break e}Pr(l,u,y,m)}u=u.child}return u;case 5:return vk(u),l===null&&_m(u),y=u.type,b=u.pendingProps,N=l!==null?l.memoizedProps:null,O=b.children,km(y,b)?O=null:N!==null&&km(y,N)&&(u.flags|=32),Xk(l,u),Pr(l,u,O,m),u.child;case 6:return l===null&&_m(u),null;case 13:return tw(l,u,m);case 4:return Fm(u,u.stateNode.containerInfo),y=u.pendingProps,l===null?u.child=Dl(u,null,y,m):Pr(l,u,y,m),u.child;case 11:return y=u.type,b=u.pendingProps,b=u.elementType===y?b:Fi(y,b),Kk(l,u,y,b,m);case 7:return Pr(l,u,u.pendingProps,m),u.child;case 8:return Pr(l,u,u.pendingProps.children,m),u.child;case 12:return Pr(l,u,u.pendingProps.children,m),u.child;case 10:e:{if(y=u.type._context,b=u.pendingProps,N=u.memoizedProps,O=b.value,wn(ih,y._currentValue),y._currentValue=O,N!==null)if(Oi(N.value,O)){if(N.children===b.children&&!Fr.current){u=Qs(l,u,m);break e}}else for(N=u.child,N!==null&&(N.return=u);N!==null;){var G=N.dependencies;if(G!==null){O=N.child;for(var te=G.firstContext;te!==null;){if(te.context===y){if(N.tag===1){te=Xs(-1,m&-m),te.tag=2;var ge=N.updateQueue;if(ge!==null){ge=ge.shared;var Pe=ge.pending;Pe===null?te.next=te:(te.next=Pe.next,Pe.next=te),ge.pending=te}}N.lanes|=m,te=N.alternate,te!==null&&(te.lanes|=m),Am(N.return,m,u),G.lanes|=m;break}te=te.next}}else if(N.tag===10)O=N.type===u.type?null:N.child;else if(N.tag===18){if(O=N.return,O===null)throw Error(n(341));O.lanes|=m,G=O.alternate,G!==null&&(G.lanes|=m),Am(O,m,u),O=N.sibling}else O=N.child;if(O!==null)O.return=N;else for(O=N;O!==null;){if(O===u){O=null;break}if(N=O.sibling,N!==null){N.return=O.return,O=N;break}O=O.return}N=O}Pr(l,u,b.children,m),u=u.child}return u;case 9:return b=u.type,y=u.pendingProps.children,Ol(u,m),b=ki(b),y=y(b),u.flags|=1,Pr(l,u,y,m),u.child;case 14:return y=u.type,b=Fi(y,u.pendingProps),b=Fi(y.type,b),Gk(l,u,y,b,m);case 15:return Yk(l,u,u.type,u.pendingProps,m);case 17:return y=u.type,b=u.pendingProps,b=u.elementType===y?b:Fi(y,b),gh(l,u),u.tag=1,Ur(y)?(l=!0,Qd(u)):l=!1,Ol(u,m),Bk(u,y,b),Xm(u,y,b,m),tg(null,u,y,!0,l,m);case 19:return rw(l,u,m);case 22:return Jk(l,u,m)}throw Error(n(156,u.tag))};function Ew(l,u){return Vn(l,u)}function EI(l,u,m,y){this.tag=l,this.key=m,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=u,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=y,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Ci(l,u,m,y){return new EI(l,u,m,y)}function kg(l){return l=l.prototype,!(!l||!l.isReactComponent)}function jI(l){if(typeof l=="function")return kg(l)?1:0;if(l!=null){if(l=l.$$typeof,l===V)return 11;if(l===J)return 14}return 2}function Ua(l,u){var m=l.alternate;return m===null?(m=Ci(l.tag,u,l.key,l.mode),m.elementType=l.elementType,m.type=l.type,m.stateNode=l.stateNode,m.alternate=l,l.alternate=m):(m.pendingProps=u,m.type=l.type,m.flags=0,m.subtreeFlags=0,m.deletions=null),m.flags=l.flags&14680064,m.childLanes=l.childLanes,m.lanes=l.lanes,m.child=l.child,m.memoizedProps=l.memoizedProps,m.memoizedState=l.memoizedState,m.updateQueue=l.updateQueue,u=l.dependencies,m.dependencies=u===null?null:{lanes:u.lanes,firstContext:u.firstContext},m.sibling=l.sibling,m.index=l.index,m.ref=l.ref,m}function Eh(l,u,m,y,b,N){var O=2;if(y=l,typeof l=="function")kg(l)&&(O=1);else if(typeof l=="string")O=5;else e:switch(l){case M:return Ao(m.children,b,N,u);case L:O=8,b|=8;break;case $:return l=Ci(12,m,u,b|2),l.elementType=$,l.lanes=N,l;case F:return l=Ci(13,m,u,b),l.elementType=F,l.lanes=N,l;case K:return l=Ci(19,m,u,b),l.elementType=K,l.lanes=N,l;case Z:return jh(m,b,N,u);default:if(typeof l=="object"&&l!==null)switch(l.$$typeof){case E:O=10;break e;case P:O=9;break e;case V:O=11;break e;case J:O=14;break e;case Q:O=16,y=null;break e}throw Error(n(130,l==null?l:typeof l,""))}return u=Ci(O,m,u,b),u.elementType=l,u.type=y,u.lanes=N,u}function Ao(l,u,m,y){return l=Ci(7,l,y,u),l.lanes=m,l}function jh(l,u,m,y){return l=Ci(22,l,y,u),l.elementType=Z,l.lanes=m,l.stateNode={isHidden:!1},l}function wg(l,u,m){return l=Ci(6,l,null,u),l.lanes=m,l}function Sg(l,u,m){return u=Ci(4,l.children!==null?l.children:[],l.key,u),u.lanes=m,u.stateNode={containerInfo:l.containerInfo,pendingChildren:null,implementation:l.implementation},u}function PI(l,u,m,y,b){this.tag=u,this.containerInfo=l,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Jp(0),this.expirationTimes=Jp(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Jp(0),this.identifierPrefix=y,this.onRecoverableError=b,this.mutableSourceEagerHydrationData=null}function Cg(l,u,m,y,b,N,O,G,te){return l=new PI(l,u,m,G,te),u===1?(u=1,N===!0&&(u|=8)):u=0,N=Ci(3,null,null,u),l.current=N,N.stateNode=l,N.memoizedState={element:y,isDehydrated:m,cache:null,transitions:null,pendingSuspenseBoundaries:null},Lm(N),l}function _I(l,u,m){var y=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:I,key:y==null?null:""+y,children:l,containerInfo:u,implementation:m}}function jw(l){if(!l)return _a;l=l._reactInternals;e:{if(rt(l)!==l||l.tag!==1)throw Error(n(170));var u=l;do{switch(u.tag){case 3:u=u.stateNode.context;break e;case 1:if(Ur(u.type)){u=u.stateNode.__reactInternalMemoizedMergedChildContext;break e}}u=u.return}while(u!==null);throw Error(n(171))}if(l.tag===1){var m=l.type;if(Ur(m))return nk(l,m,u)}return u}function Pw(l,u,m,y,b,N,O,G,te){return l=Cg(m,y,!0,l,b,N,O,G,te),l.context=jw(null),m=l.current,y=_r(),b=La(m),N=Xs(y,b),N.callback=u??null,Ma(m,N,b),l.current.lanes=b,Lc(l,b,y),$r(l,y),l}function Ph(l,u,m,y){var b=u.current,N=_r(),O=La(b);return m=jw(m),u.context===null?u.context=m:u.pendingContext=m,u=Xs(N,O),u.payload={element:l},y=y===void 0?null:y,y!==null&&(u.callback=y),l=Ma(b,u,O),l!==null&&(zi(l,b,O,N),ah(l,b,O)),O}function _h(l){if(l=l.current,!l.child)return null;switch(l.child.tag){case 5:return l.child.stateNode;default:return l.child.stateNode}}function _w(l,u){if(l=l.memoizedState,l!==null&&l.dehydrated!==null){var m=l.retryLane;l.retryLane=m!==0&&m<u?m:u}}function Tg(l,u){_w(l,u),(l=l.alternate)&&_w(l,u)}function RI(){return null}var Rw=typeof reportError=="function"?reportError:function(l){console.error(l)};function Ng(l){this._internalRoot=l}Rh.prototype.render=Ng.prototype.render=function(l){var u=this._internalRoot;if(u===null)throw Error(n(409));Ph(l,u,null,null)},Rh.prototype.unmount=Ng.prototype.unmount=function(){var l=this._internalRoot;if(l!==null){this._internalRoot=null;var u=l.containerInfo;Io(function(){Ph(null,l,null,null)}),u[qs]=null}};function Rh(l){this._internalRoot=l}Rh.prototype.unstable_scheduleHydration=function(l){if(l){var u=pb();l={blockedOn:null,target:l,priority:u};for(var m=0;m<Ta.length&&u!==0&&u<Ta[m].priority;m++);Ta.splice(m,0,l),m===0&&vb(l)}};function Eg(l){return!(!l||l.nodeType!==1&&l.nodeType!==9&&l.nodeType!==11)}function Ih(l){return!(!l||l.nodeType!==1&&l.nodeType!==9&&l.nodeType!==11&&(l.nodeType!==8||l.nodeValue!==" react-mount-point-unstable "))}function Iw(){}function II(l,u,m,y,b){if(b){if(typeof y=="function"){var N=y;y=function(){var ge=_h(O);N.call(ge)}}var O=Pw(u,y,l,0,null,!1,!1,"",Iw);return l._reactRootContainer=O,l[qs]=O.current,Xc(l.nodeType===8?l.parentNode:l),Io(),O}for(;b=l.lastChild;)l.removeChild(b);if(typeof y=="function"){var G=y;y=function(){var ge=_h(te);G.call(ge)}}var te=Cg(l,0,!1,null,null,!1,!1,"",Iw);return l._reactRootContainer=te,l[qs]=te.current,Xc(l.nodeType===8?l.parentNode:l),Io(function(){Ph(u,te,m,y)}),te}function Mh(l,u,m,y,b){var N=m._reactRootContainer;if(N){var O=N;if(typeof b=="function"){var G=b;b=function(){var te=_h(O);G.call(te)}}Ph(u,O,l,b)}else O=II(m,u,l,b,y);return _h(O)}hb=function(l){switch(l.tag){case 3:var u=l.stateNode;if(u.current.memoizedState.isDehydrated){var m=So(u.pendingLanes);m!==0&&(Xp(u,m|1),$r(u,cn()),(Ht&6)===0&&(zl=cn()+500,Ra()))}break;case 13:Io(function(){var y=Js(l,1);if(y!==null){var b=_r();zi(y,l,1,b)}}),Tg(l,1)}},Qp=function(l){if(l.tag===13){var u=Js(l,134217728);if(u!==null){var m=_r();zi(u,l,134217728,m)}Tg(l,134217728)}},fb=function(l){if(l.tag===13){var u=La(l),m=Js(l,u);if(m!==null){var y=_r();zi(m,l,u,y)}Tg(l,u)}},pb=function(){return un},mb=function(l,u){var m=un;try{return un=l,u()}finally{un=m}},nn=function(l,u,m){switch(u){case"input":if(dt(l,m),u=m.name,m.type==="radio"&&u!=null){for(m=l;m.parentNode;)m=m.parentNode;for(m=m.querySelectorAll("input[name="+JSON.stringify(""+u)+'][type="radio"]'),u=0;u<m.length;u++){var y=m[u];if(y!==l&&y.form===l.form){var b=Jd(y);if(!b)throw Error(n(90));q(y),dt(y,b)}}}break;case"textarea":gn(l,m);break;case"select":u=m.value,u!=null&&xt(l,!!m.multiple,u,!1)}},Ct=yg,ut=Io;var MI={usingClientEntryPoint:!1,Events:[eu,jl,Jd,be,We,yg]},pu={findFiberByHostInstance:Co,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},DI={bundleType:pu.bundleType,version:pu.version,rendererPackageName:pu.rendererPackageName,rendererConfig:pu.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:R.ReactCurrentDispatcher,findHostInstanceByFiber:function(l){return l=Ot(l),l===null?null:l.stateNode},findFiberByHostInstance:pu.findFiberByHostInstance||RI,findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null,reconcilerVersion:"18.3.1-next-f1338f8080-20240426"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var Dh=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Dh.isDisabled&&Dh.supportsFiber)try{Vs=Dh.inject(DI),jr=Dh}catch{}}return Vr.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=MI,Vr.createPortal=function(l,u){var m=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!Eg(u))throw Error(n(200));return _I(l,u,null,m)},Vr.createRoot=function(l,u){if(!Eg(l))throw Error(n(299));var m=!1,y="",b=Rw;return u!=null&&(u.unstable_strictMode===!0&&(m=!0),u.identifierPrefix!==void 0&&(y=u.identifierPrefix),u.onRecoverableError!==void 0&&(b=u.onRecoverableError)),u=Cg(l,1,!1,null,null,m,!1,y,b),l[qs]=u.current,Xc(l.nodeType===8?l.parentNode:l),new Ng(u)},Vr.findDOMNode=function(l){if(l==null)return null;if(l.nodeType===1)return l;var u=l._reactInternals;if(u===void 0)throw typeof l.render=="function"?Error(n(188)):(l=Object.keys(l).join(","),Error(n(268,l)));return l=Ot(u),l=l===null?null:l.stateNode,l},Vr.flushSync=function(l){return Io(l)},Vr.hydrate=function(l,u,m){if(!Ih(u))throw Error(n(200));return Mh(null,l,u,!0,m)},Vr.hydrateRoot=function(l,u,m){if(!Eg(l))throw Error(n(405));var y=m!=null&&m.hydratedSources||null,b=!1,N="",O=Rw;if(m!=null&&(m.unstable_strictMode===!0&&(b=!0),m.identifierPrefix!==void 0&&(N=m.identifierPrefix),m.onRecoverableError!==void 0&&(O=m.onRecoverableError)),u=Pw(u,null,l,1,m??null,b,!1,N,O),l[qs]=u.current,Xc(l),y)for(l=0;l<y.length;l++)m=y[l],b=m._getVersion,b=b(m._source),u.mutableSourceEagerHydrationData==null?u.mutableSourceEagerHydrationData=[m,b]:u.mutableSourceEagerHydrationData.push(m,b);return new Rh(u)},Vr.render=function(l,u,m){if(!Ih(u))throw Error(n(200));return Mh(null,l,u,!1,m)},Vr.unmountComponentAtNode=function(l){if(!Ih(l))throw Error(n(40));return l._reactRootContainer?(Io(function(){Mh(null,null,l,!1,function(){l._reactRootContainer=null,l[qs]=null})}),!0):!1},Vr.unstable_batchedUpdates=yg,Vr.unstable_renderSubtreeIntoContainer=function(l,u,m,y){if(!Ih(m))throw Error(n(200));if(l==null||l._reactInternals===void 0)throw Error(n(38));return Mh(l,u,m,!1,y)},Vr.version="18.3.1-next-f1338f8080-20240426",Vr}var Bw;function LT(){if(Bw)return _g.exports;Bw=1;function t(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(e){console.error(e)}}return t(),_g.exports=$I(),_g.exports}var zw;function VI(){if(zw)return Ah;zw=1;var t=LT();return Ah.createRoot=t.createRoot,Ah.hydrateRoot=t.hydrateRoot,Ah}var WI=VI(),x=oy();const Me=up(x),FT=OI({__proto__:null,default:Me},[x]);/**
41
+ * react-router v7.13.0
42
+ *
43
+ * Copyright (c) Remix Software Inc.
44
+ *
45
+ * This source code is licensed under the MIT license found in the
46
+ * LICENSE.md file in the root directory of this source tree.
47
+ *
48
+ * @license MIT
49
+ */var UT=t=>{throw TypeError(t)},HI=(t,e,n)=>e.has(t)||UT("Cannot "+n),Mg=(t,e,n)=>(HI(t,e,"read from private field"),n?n.call(t):e.get(t)),qI=(t,e,n)=>e.has(t)?UT("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,n),$w="popstate";function KI(t={}){function e(r,i){let{pathname:s,search:a,hash:c}=r.location;return Qu("",{pathname:s,search:a,hash:c},i.state&&i.state.usr||null,i.state&&i.state.key||"default")}function n(r,i){return typeof i=="string"?i:Es(i)}return YI(e,n,null,t)}function At(t,e){if(t===!1||t===null||typeof t>"u")throw new Error(e)}function Zn(t,e){if(!t){typeof console<"u"&&console.warn(e);try{throw new Error(e)}catch{}}}function GI(){return Math.random().toString(36).substring(2,10)}function Vw(t,e){return{usr:t.state,key:t.key,idx:e}}function Qu(t,e,n=null,r){return{pathname:typeof t=="string"?t:t.pathname,search:"",hash:"",...typeof e=="string"?ho(e):e,state:n,key:e&&e.key||r||GI()}}function Es({pathname:t="/",search:e="",hash:n=""}){return e&&e!=="?"&&(t+=e.charAt(0)==="?"?e:"?"+e),n&&n!=="#"&&(t+=n.charAt(0)==="#"?n:"#"+n),t}function ho(t){let e={};if(t){let n=t.indexOf("#");n>=0&&(e.hash=t.substring(n),t=t.substring(0,n));let r=t.indexOf("?");r>=0&&(e.search=t.substring(r),t=t.substring(0,r)),t&&(e.pathname=t)}return e}function YI(t,e,n,r={}){let{window:i=document.defaultView,v5Compat:s=!1}=r,a=i.history,c="POP",h=null,d=f();d==null&&(d=0,a.replaceState({...a.state,idx:d},""));function f(){return(a.state||{idx:null}).idx}function p(){c="POP";let S=f(),T=S==null?null:S-d;d=S,h&&h({action:c,location:w.location,delta:T})}function g(S,T){c="PUSH";let C=Qu(w.location,S,T);d=f()+1;let j=Vw(C,d),R=w.createHref(C);try{a.pushState(j,"",R)}catch(_){if(_ instanceof DOMException&&_.name==="DataCloneError")throw _;i.location.assign(R)}s&&h&&h({action:c,location:w.location,delta:1})}function v(S,T){c="REPLACE";let C=Qu(w.location,S,T);d=f();let j=Vw(C,d),R=w.createHref(C);a.replaceState(j,"",R),s&&h&&h({action:c,location:w.location,delta:0})}function k(S){return BT(S)}let w={get action(){return c},get location(){return t(i,a)},listen(S){if(h)throw new Error("A history only accepts one active listener");return i.addEventListener($w,p),h=S,()=>{i.removeEventListener($w,p),h=null}},createHref(S){return e(i,S)},createURL:k,encodeLocation(S){let T=k(S);return{pathname:T.pathname,search:T.search,hash:T.hash}},push:g,replace:v,go(S){return a.go(S)}};return w}function BT(t,e=!1){let n="http://localhost";typeof window<"u"&&(n=window.location.origin!=="null"?window.location.origin:window.location.href),At(n,"No window.location.(origin|href) available to create URL");let r=typeof t=="string"?t:Es(t);return r=r.replace(/ $/,"%20"),!e&&r.startsWith("//")&&(r=n+r),new URL(r,n)}var Au,Ww=class{constructor(t){if(qI(this,Au,new Map),t)for(let[e,n]of t)this.set(e,n)}get(t){if(Mg(this,Au).has(t))return Mg(this,Au).get(t);if(t.defaultValue!==void 0)return t.defaultValue;throw new Error("No value found for context")}set(t,e){Mg(this,Au).set(t,e)}};Au=new WeakMap;var JI=new Set(["lazy","caseSensitive","path","id","index","children"]);function XI(t){return JI.has(t)}var QI=new Set(["lazy","caseSensitive","path","id","index","middleware","children"]);function ZI(t){return QI.has(t)}function e5(t){return t.index===!0}function Zu(t,e,n=[],r={},i=!1){return t.map((s,a)=>{let c=[...n,String(a)],h=typeof s.id=="string"?s.id:c.join("-");if(At(s.index!==!0||!s.children,"Cannot specify children on an index route"),At(i||!r[h],`Found a route id collision on id "${h}". Route id's must be globally unique within Data Router usages`),e5(s)){let d={...s,id:h};return r[h]=Hw(d,e(d)),d}else{let d={...s,id:h,children:void 0};return r[h]=Hw(d,e(d)),s.children&&(d.children=Zu(s.children,e,c,r,i)),d}})}function Hw(t,e){return Object.assign(t,{...e,...typeof e.lazy=="object"&&e.lazy!=null?{lazy:{...t.lazy,...e.lazy}}:{}})}function Ga(t,e,n="/"){return Ou(t,e,n,!1)}function Ou(t,e,n,r){let i=typeof e=="string"?ho(e):e,s=Ri(i.pathname||"/",n);if(s==null)return null;let a=zT(t);n5(a);let c=null;for(let h=0;c==null&&h<a.length;++h){let d=f5(s);c=d5(a[h],d,r)}return c}function t5(t,e){let{route:n,pathname:r,params:i}=t;return{id:n.id,pathname:r,params:i,data:e[n.id],loaderData:e[n.id],handle:n.handle}}function zT(t,e=[],n=[],r="",i=!1){let s=(a,c,h=i,d)=>{let f={relativePath:d===void 0?a.path||"":d,caseSensitive:a.caseSensitive===!0,childrenIndex:c,route:a};if(f.relativePath.startsWith("/")){if(!f.relativePath.startsWith(r)&&h)return;At(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 p=ws([r,f.relativePath]),g=n.concat(f);a.children&&a.children.length>0&&(At(a.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${p}".`),zT(a.children,e,g,p,h)),!(a.path==null&&!a.index)&&e.push({path:p,score:c5(p,a.index),routesMeta:g})};return t.forEach((a,c)=>{var h;if(a.path===""||!((h=a.path)!=null&&h.includes("?")))s(a,c);else for(let d of $T(a.path))s(a,c,!0,d)}),e}function $T(t){let e=t.split("/");if(e.length===0)return[];let[n,...r]=e,i=n.endsWith("?"),s=n.replace(/\?$/,"");if(r.length===0)return i?[s,""]:[s];let a=$T(r.join("/")),c=[];return c.push(...a.map(h=>h===""?s:[s,h].join("/"))),i&&c.push(...a),c.map(h=>t.startsWith("/")&&h===""?"/":h)}function n5(t){t.sort((e,n)=>e.score!==n.score?n.score-e.score:u5(e.routesMeta.map(r=>r.childrenIndex),n.routesMeta.map(r=>r.childrenIndex)))}var r5=/^:[\w-]+$/,i5=3,s5=2,a5=1,o5=10,l5=-2,qw=t=>t==="*";function c5(t,e){let n=t.split("/"),r=n.length;return n.some(qw)&&(r+=l5),e&&(r+=s5),n.filter(i=>!qw(i)).reduce((i,s)=>i+(r5.test(s)?i5:s===""?a5:o5),r)}function u5(t,e){return t.length===e.length&&t.slice(0,-1).every((r,i)=>r===e[i])?t[t.length-1]-e[e.length-1]:0}function d5(t,e,n=!1){let{routesMeta:r}=t,i={},s="/",a=[];for(let c=0;c<r.length;++c){let h=r[c],d=c===r.length-1,f=s==="/"?e:e.slice(s.length)||"/",p=_f({path:h.relativePath,caseSensitive:h.caseSensitive,end:d},f),g=h.route;if(!p&&d&&n&&!r[r.length-1].route.index&&(p=_f({path:h.relativePath,caseSensitive:h.caseSensitive,end:!1},f)),!p)return null;Object.assign(i,p.params),a.push({params:i,pathname:ws([s,p.pathname]),pathnameBase:g5(ws([s,p.pathnameBase])),route:g}),p.pathnameBase!=="/"&&(s=ws([s,p.pathnameBase]))}return a}function _f(t,e){typeof t=="string"&&(t={path:t,caseSensitive:!1,end:!0});let[n,r]=h5(t.path,t.caseSensitive,t.end),i=e.match(n);if(!i)return null;let s=i[0],a=s.replace(/(.)\/+$/,"$1"),c=i.slice(1);return{params:r.reduce((d,{paramName:f,isOptional:p},g)=>{if(f==="*"){let k=c[g]||"";a=s.slice(0,s.length-k.length).replace(/(.)\/+$/,"$1")}const v=c[g];return p&&!v?d[f]=void 0:d[f]=(v||"").replace(/%2F/g,"/"),d},{}),pathname:s,pathnameBase:a,pattern:t}}function h5(t,e=!1,n=!0){Zn(t==="*"||!t.endsWith("*")||t.endsWith("/*"),`Route path "${t}" will be treated as if it were "${t.replace(/\*$/,"/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${t.replace(/\*$/,"/*")}".`);let r=[],i="^"+t.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(a,c,h)=>(r.push({paramName:c,isOptional:h!=null}),h?"/?([^\\/]+)?":"/([^\\/]+)")).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return t.endsWith("*")?(r.push({paramName:"*"}),i+=t==="*"||t==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?i+="\\/*$":t!==""&&t!=="/"&&(i+="(?:(?=\\/|$))"),[new RegExp(i,e?void 0:"i"),r]}function f5(t){try{return t.split("/").map(e=>decodeURIComponent(e).replace(/\//g,"%2F")).join("/")}catch(e){return Zn(!1,`The URL path "${t}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${e}).`),t}}function Ri(t,e){if(e==="/")return t;if(!t.toLowerCase().startsWith(e.toLowerCase()))return null;let n=e.endsWith("/")?e.length-1:e.length,r=t.charAt(n);return r&&r!=="/"?null:t.slice(n)||"/"}function p5({basename:t,pathname:e}){return e==="/"?t:ws([t,e])}var VT=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,ly=t=>VT.test(t);function m5(t,e="/"){let{pathname:n,search:r="",hash:i=""}=typeof t=="string"?ho(t):t,s;return n?(n=n.replace(/\/\/+/g,"/"),n.startsWith("/")?s=Kw(n.substring(1),"/"):s=Kw(n,e)):s=e,{pathname:s,search:v5(r),hash:y5(i)}}function Kw(t,e){let n=e.replace(/\/+$/,"").split("/");return t.split("/").forEach(i=>{i===".."?n.length>1&&n.pop():i!=="."&&n.push(i)}),n.length>1?n.join("/"):"/"}function Dg(t,e,n,r){return`Cannot include a '${t}' character in a manually specified \`to.${e}\` 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 WT(t){return t.filter((e,n)=>n===0||e.route.path&&e.route.path.length>0)}function cy(t){let e=WT(t);return e.map((n,r)=>r===e.length-1?n.pathname:n.pathnameBase)}function uy(t,e,n,r=!1){let i;typeof t=="string"?i=ho(t):(i={...t},At(!i.pathname||!i.pathname.includes("?"),Dg("?","pathname","search",i)),At(!i.pathname||!i.pathname.includes("#"),Dg("#","pathname","hash",i)),At(!i.search||!i.search.includes("#"),Dg("#","search","hash",i)));let s=t===""||i.pathname==="",a=s?"/":i.pathname,c;if(a==null)c=n;else{let p=e.length-1;if(!r&&a.startsWith("..")){let g=a.split("/");for(;g[0]==="..";)g.shift(),p-=1;i.pathname=g.join("/")}c=p>=0?e[p]:"/"}let h=m5(i,c),d=a&&a!=="/"&&a.endsWith("/"),f=(s||a===".")&&n.endsWith("/");return!h.pathname.endsWith("/")&&(d||f)&&(h.pathname+="/"),h}var ws=t=>t.join("/").replace(/\/\/+/g,"/"),g5=t=>t.replace(/\/+$/,"").replace(/^\/*/,"/"),v5=t=>!t||t==="?"?"":t.startsWith("?")?t:"?"+t,y5=t=>!t||t==="#"?"":t.startsWith("#")?t:"#"+t,yd=class{constructor(t,e,n,r=!1){this.status=t,this.statusText=e||"",this.internal=r,n instanceof Error?(this.data=n.toString(),this.error=n):this.data=n}};function ed(t){return t!=null&&typeof t.status=="number"&&typeof t.statusText=="string"&&typeof t.internal=="boolean"&&"data"in t}function xd(t){return t.map(e=>e.route.path).filter(Boolean).join("/").replace(/\/\/*/g,"/")||"/"}var HT=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function qT(t,e){let n=t;if(typeof n!="string"||!VT.test(n))return{absoluteURL:void 0,isExternal:!1,to:n};let r=n,i=!1;if(HT)try{let s=new URL(window.location.href),a=n.startsWith("//")?new URL(s.protocol+n):new URL(n),c=Ri(a.pathname,e);a.origin===s.origin&&c!=null?n=c+a.search+a.hash:i=!0}catch{Zn(!1,`<Link to="${n}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:r,isExternal:i,to:n}}var Qa=Symbol("Uninstrumented");function x5(t,e){let n={lazy:[],"lazy.loader":[],"lazy.action":[],"lazy.middleware":[],middleware:[],loader:[],action:[]};t.forEach(i=>i({id:e.id,index:e.index,path:e.path,instrument(s){let a=Object.keys(n);for(let c of a)s[c]&&n[c].push(s[c])}}));let r={};if(typeof e.lazy=="function"&&n.lazy.length>0){let i=tc(n.lazy,e.lazy,()=>{});i&&(r.lazy=i)}if(typeof e.lazy=="object"){let i=e.lazy;["middleware","loader","action"].forEach(s=>{let a=i[s],c=n[`lazy.${s}`];if(typeof a=="function"&&c.length>0){let h=tc(c,a,()=>{});h&&(r.lazy=Object.assign(r.lazy||{},{[s]:h}))}})}return["loader","action"].forEach(i=>{let s=e[i];if(typeof s=="function"&&n[i].length>0){let a=s[Qa]??s,c=tc(n[i],a,(...h)=>Gw(h[0]));c&&(i==="loader"&&a.hydrate===!0&&(c.hydrate=!0),c[Qa]=a,r[i]=c)}}),e.middleware&&e.middleware.length>0&&n.middleware.length>0&&(r.middleware=e.middleware.map(i=>{let s=i[Qa]??i,a=tc(n.middleware,s,(...c)=>Gw(c[0]));return a?(a[Qa]=s,a):i})),r}function b5(t,e){let n={navigate:[],fetch:[]};if(e.forEach(r=>r({instrument(i){let s=Object.keys(i);for(let a of s)i[a]&&n[a].push(i[a])}})),n.navigate.length>0){let r=t.navigate[Qa]??t.navigate,i=tc(n.navigate,r,(...s)=>{let[a,c]=s;return{to:typeof a=="number"||typeof a=="string"?a:a?Es(a):".",...Yw(t,c??{})}});i&&(i[Qa]=r,t.navigate=i)}if(n.fetch.length>0){let r=t.fetch[Qa]??t.fetch,i=tc(n.fetch,r,(...s)=>{let[a,,c,h]=s;return{href:c??".",fetcherKey:a,...Yw(t,h??{})}});i&&(i[Qa]=r,t.fetch=i)}return t}function tc(t,e,n){return t.length===0?null:async(...r)=>{let i=await KT(t,n(...r),()=>e(...r),t.length-1);if(i.type==="error")throw i.value;return i.value}}async function KT(t,e,n,r){let i=t[r],s;if(i){let a,c=async()=>(a?console.error("You cannot call instrumented handlers more than once"):a=KT(t,e,n,r-1),s=await a,At(s,"Expected a result"),s.type==="error"&&s.value instanceof Error?{status:"error",error:s.value}:{status:"success",error:void 0});try{await i(c,e)}catch(h){console.error("An instrumentation function threw an error:",h)}a||await c(),await a}else try{s={type:"success",value:await n()}}catch(a){s={type:"error",value:a}}return s||{type:"error",value:new Error("No result assigned in instrumentation chain.")}}function Gw(t){let{request:e,context:n,params:r,unstable_pattern:i}=t;return{request:k5(e),params:{...r},unstable_pattern:i,context:w5(n)}}function Yw(t,e){return{currentUrl:Es(t.state.location),..."formMethod"in e?{formMethod:e.formMethod}:{},..."formEncType"in e?{formEncType:e.formEncType}:{},..."formData"in e?{formData:e.formData}:{},..."body"in e?{body:e.body}:{}}}function k5(t){return{method:t.method,url:t.url,headers:{get:(...e)=>t.headers.get(...e)}}}function w5(t){if(C5(t)){let e={...t};return Object.freeze(e),e}else return{get:e=>t.get(e)}}var S5=Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function C5(t){if(t===null||typeof t!="object")return!1;const e=Object.getPrototypeOf(t);return e===Object.prototype||e===null||Object.getOwnPropertyNames(e).sort().join("\0")===S5}var GT=["POST","PUT","PATCH","DELETE"],T5=new Set(GT),N5=["GET",...GT],E5=new Set(N5),YT=new Set([301,302,303,307,308]),j5=new Set([307,308]),Ag={state:"idle",location:void 0,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0},P5={state:"idle",data:void 0,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0},gu={state:"unblocked",proceed:void 0,reset:void 0,location:void 0},_5=t=>({hasErrorBoundary:!!t.hasErrorBoundary}),JT="remix-router-transitions",XT=Symbol("ResetLoaderData");function R5(t){const e=t.window?t.window:typeof window<"u"?window:void 0,n=typeof e<"u"&&typeof e.document<"u"&&typeof e.document.createElement<"u";At(t.routes.length>0,"You must provide a non-empty routes array to createRouter");let r=t.hydrationRouteProperties||[],i=t.mapRouteProperties||_5,s=i;if(t.unstable_instrumentations){let Y=t.unstable_instrumentations;s=re=>({...i(re),...x5(Y.map(de=>de.route).filter(Boolean),re)})}let a={},c=Zu(t.routes,s,void 0,a),h,d=t.basename||"/";d.startsWith("/")||(d=`/${d}`);let f=t.dataStrategy||O5,p={...t.future},g=null,v=new Set,k=null,w=null,S=null,T=t.hydrationData!=null,C=Ga(c,t.history.location,d),j=!1,R=null,_;if(C==null&&!t.patchRoutesOnNavigation){let Y=ji(404,{pathname:t.history.location.pathname}),{matches:re,route:de}=Oh(c);_=!0,C=re,R={[de.id]:Y}}else if(C&&!t.hydrationData&&ut(C,c,t.history.location.pathname).active&&(C=null),C)if(C.some(Y=>Y.route.lazy))_=!1;else if(!C.some(Y=>dy(Y.route)))_=!0;else{let Y=t.hydrationData?t.hydrationData.loaderData:null,re=t.hydrationData?t.hydrationData.errors:null;if(re){let de=C.findIndex(Ce=>re[Ce.route.id]!==void 0);_=C.slice(0,de+1).every(Ce=>!G0(Ce.route,Y,re))}else _=C.every(de=>!G0(de.route,Y,re))}else{_=!1,C=[];let Y=ut(null,c,t.history.location.pathname);Y.active&&Y.matches&&(j=!0,C=Y.matches)}let I,M={historyAction:t.history.action,location:t.history.location,matches:C,initialized:_,navigation:Ag,restoreScrollPosition:t.hydrationData!=null?!1:null,preventScrollReset:!1,revalidation:"idle",loaderData:t.hydrationData&&t.hydrationData.loaderData||{},actionData:t.hydrationData&&t.hydrationData.actionData||null,errors:t.hydrationData&&t.hydrationData.errors||R,fetchers:new Map,blockers:new Map},L="POP",$=null,E=!1,P,V=!1,F=new Map,K=null,J=!1,Q=!1,Z=new Set,D=new Map,ne=0,A=-1,z=new Map,ee=new Set,B=new Map,X=new Map,ye=new Set,se=new Map,oe,U=null;function ue(){if(g=t.history.listen(({action:Y,location:re,delta:de})=>{if(oe){oe(),oe=void 0;return}Zn(se.size===0||de!=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 Ce=Kn({currentLocation:M.location,nextLocation:re,historyAction:Y});if(Ce&&de!=null){let Ae=new Promise(Je=>{oe=Je});t.history.go(de*-1),nn(Ce,{state:"blocked",location:re,proceed(){nn(Ce,{state:"proceeding",proceed:void 0,reset:void 0,location:re}),Ae.then(()=>t.history.go(de))},reset(){let Je=new Map(M.blockers);Je.set(Ce,gu),q({blockers:Je})}}),$==null||$.resolve(),$=null;return}return Ke(Y,re)}),n){eM(e,F);let Y=()=>tM(e,F);e.addEventListener("pagehide",Y),K=()=>e.removeEventListener("pagehide",Y)}return M.initialized||Ke("POP",M.location,{initialHydration:!0}),I}function ke(){g&&g(),K&&K(),v.clear(),P&&P.abort(),M.fetchers.forEach((Y,re)=>vn(re)),M.blockers.forEach((Y,re)=>Tn(re))}function W(Y){return v.add(Y),()=>v.delete(Y)}function q(Y,re={}){Y.matches&&(Y.matches=Y.matches.map(Ae=>{let Je=a[Ae.route.id],lt=Ae.route;return lt.element!==Je.element||lt.errorElement!==Je.errorElement||lt.hydrateFallbackElement!==Je.hydrateFallbackElement?{...Ae,route:Je}:Ae})),M={...M,...Y};let de=[],Ce=[];M.fetchers.forEach((Ae,Je)=>{Ae.state==="idle"&&(ye.has(Je)?de.push(Je):Ce.push(Je))}),ye.forEach(Ae=>{!M.fetchers.has(Ae)&&!D.has(Ae)&&de.push(Ae)}),[...v].forEach(Ae=>Ae(M,{deletedFetchers:de,newErrors:Y.errors??null,viewTransitionOpts:re.viewTransitionOpts,flushSync:re.flushSync===!0})),de.forEach(Ae=>vn(Ae)),Ce.forEach(Ae=>M.fetchers.delete(Ae))}function fe(Y,re,{flushSync:de}={}){var wt,ct;let Ce=M.actionData!=null&&M.navigation.formMethod!=null&&xr(M.navigation.formMethod)&&M.navigation.state==="loading"&&((wt=Y.state)==null?void 0:wt._isRedirect)!==!0,Ae;re.actionData?Object.keys(re.actionData).length>0?Ae=re.actionData:Ae=null:Ce?Ae=M.actionData:Ae=null;let Je=re.loaderData?s1(M.loaderData,re.loaderData,re.matches||[],re.errors):M.loaderData,lt=M.blockers;lt.size>0&&(lt=new Map(lt),lt.forEach((Nt,Ot)=>lt.set(Ot,gu)));let Ye=J?!1:Ct(Y,re.matches||M.matches),Ze=E===!0||M.navigation.formMethod!=null&&xr(M.navigation.formMethod)&&((ct=Y.state)==null?void 0:ct._isRedirect)!==!0;h&&(c=h,h=void 0),J||L==="POP"||(L==="PUSH"?t.history.push(Y,Y.state):L==="REPLACE"&&t.history.replace(Y,Y.state));let rt;if(L==="POP"){let Nt=F.get(M.location.pathname);Nt&&Nt.has(Y.pathname)?rt={currentLocation:M.location,nextLocation:Y}:F.has(Y.pathname)&&(rt={currentLocation:Y,nextLocation:M.location})}else if(V){let Nt=F.get(M.location.pathname);Nt?Nt.add(Y.pathname):(Nt=new Set([Y.pathname]),F.set(M.location.pathname,Nt)),rt={currentLocation:M.location,nextLocation:Y}}q({...re,actionData:Ae,loaderData:Je,historyAction:L,location:Y,initialized:!0,navigation:Ag,revalidation:"idle",restoreScrollPosition:Ye,preventScrollReset:Ze,blockers:lt},{viewTransitionOpts:rt,flushSync:de===!0}),L="POP",E=!1,V=!1,J=!1,Q=!1,$==null||$.resolve(),$=null,U==null||U.resolve(),U=null}async function ve(Y,re){if($==null||$.resolve(),$=null,typeof Y=="number"){$||($=c1());let Ot=$.promise;return t.history.go(Y),Ot}let de=K0(M.location,M.matches,d,Y,re==null?void 0:re.fromRouteId,re==null?void 0:re.relative),{path:Ce,submission:Ae,error:Je}=Jw(!1,de,re),lt=M.location,Ye=Qu(M.location,Ce,re&&re.state);Ye={...Ye,...t.history.encodeLocation(Ye)};let Ze=re&&re.replace!=null?re.replace:void 0,rt="PUSH";Ze===!0?rt="REPLACE":Ze===!1||Ae!=null&&xr(Ae.formMethod)&&Ae.formAction===M.location.pathname+M.location.search&&(rt="REPLACE");let wt=re&&"preventScrollReset"in re?re.preventScrollReset===!0:void 0,ct=(re&&re.flushSync)===!0,Nt=Kn({currentLocation:lt,nextLocation:Ye,historyAction:rt});if(Nt){nn(Nt,{state:"blocked",location:Ye,proceed(){nn(Nt,{state:"proceeding",proceed:void 0,reset:void 0,location:Ye}),ve(Y,re)},reset(){let Ot=new Map(M.blockers);Ot.set(Nt,gu),q({blockers:Ot})}});return}await Ke(rt,Ye,{submission:Ae,pendingError:Je,preventScrollReset:wt,replace:re&&re.replace,enableViewTransition:re&&re.viewTransition,flushSync:ct,callSiteDefaultShouldRevalidate:re&&re.unstable_defaultShouldRevalidate})}function Se(){U||(U=c1()),Re(),q({revalidation:"loading"});let Y=U.promise;return M.navigation.state==="submitting"?Y:M.navigation.state==="idle"?(Ke(M.historyAction,M.location,{startUninterruptedRevalidation:!0}),Y):(Ke(L||M.historyAction,M.navigation.location,{overrideNavigation:M.navigation,enableViewTransition:V===!0}),Y)}async function Ke(Y,re,de){P&&P.abort(),P=null,L=Y,J=(de&&de.startUninterruptedRevalidation)===!0,We(M.location,M.matches),E=(de&&de.preventScrollReset)===!0,V=(de&&de.enableViewTransition)===!0;let Ce=h||c,Ae=de&&de.overrideNavigation,Je=de!=null&&de.initialHydration&&M.matches&&M.matches.length>0&&!j?M.matches:Ga(Ce,re,d),lt=(de&&de.flushSync)===!0;if(Je&&M.initialized&&!Q&&W5(M.location,re)&&!(de&&de.submission&&xr(de.submission.formMethod))){fe(re,{matches:Je},{flushSync:lt});return}let Ye=ut(Je,Ce,re.pathname);if(Ye.active&&Ye.matches&&(Je=Ye.matches),!Je){let{error:Vn,notFoundMatches:ir,route:an}=Mn(re.pathname);fe(re,{matches:ir,loaderData:{},errors:{[an.id]:Vn}},{flushSync:lt});return}P=new AbortController;let Ze=Zl(t.history,re,P.signal,de&&de.submission),rt=t.getContext?await t.getContext():new Ww,wt;if(de&&de.pendingError)wt=[Ya(Je).route.id,{type:"error",error:de.pendingError}];else if(de&&de.submission&&xr(de.submission.formMethod)){let Vn=await dt(Ze,re,de.submission,Je,rt,Ye.active,de&&de.initialHydration===!0,{replace:de.replace,flushSync:lt});if(Vn.shortCircuited)return;if(Vn.pendingActionResult){let[ir,an]=Vn.pendingActionResult;if(li(an)&&ed(an.error)&&an.error.status===404){P=null,fe(re,{matches:Vn.matches,loaderData:{},errors:{[ir]:an.error}});return}}Je=Vn.matches||Je,wt=Vn.pendingActionResult,Ae=Og(re,de.submission),lt=!1,Ye.active=!1,Ze=Zl(t.history,Ze.url,Ze.signal)}let{shortCircuited:ct,matches:Nt,loaderData:Ot,errors:Gn}=await Ge(Ze,re,Je,rt,Ye.active,Ae,de&&de.submission,de&&de.fetcherSubmission,de&&de.replace,de&&de.initialHydration===!0,lt,wt,de&&de.callSiteDefaultShouldRevalidate);ct||(P=null,fe(re,{matches:Nt||Je,...a1(wt),loaderData:Ot,errors:Gn}))}async function dt(Y,re,de,Ce,Ae,Je,lt,Ye={}){Re();let Ze=Q5(re,de);if(q({navigation:Ze},{flushSync:Ye.flushSync===!0}),Je){let ct=await Yt(Ce,re.pathname,Y.signal);if(ct.type==="aborted")return{shortCircuited:!0};if(ct.type==="error"){if(ct.partialMatches.length===0){let{matches:Ot,route:Gn}=Oh(c);return{matches:Ot,pendingActionResult:[Gn.id,{type:"error",error:ct.error}]}}let Nt=Ya(ct.partialMatches).route.id;return{matches:ct.partialMatches,pendingActionResult:[Nt,{type:"error",error:ct.error}]}}else if(ct.matches)Ce=ct.matches;else{let{notFoundMatches:Nt,error:Ot,route:Gn}=Mn(re.pathname);return{matches:Nt,pendingActionResult:[Gn.id,{type:"error",error:Ot}]}}}let rt,wt=of(Ce,re);if(!wt.route.action&&!wt.route.lazy)rt={type:"error",error:ji(405,{method:Y.method,pathname:re.pathname,routeId:wt.route.id})};else{let ct=ic(s,a,Y,Ce,wt,lt?[]:r,Ae),Nt=await jn(Y,ct,Ae,null);if(rt=Nt[wt.route.id],!rt){for(let Ot of Ce)if(Nt[Ot.route.id]){rt=Nt[Ot.route.id];break}}if(Y.signal.aborted)return{shortCircuited:!0}}if(Jo(rt)){let ct;return Ye&&Ye.replace!=null?ct=Ye.replace:ct=n1(rt.response.headers.get("Location"),new URL(Y.url),d,t.history)===M.location.pathname+M.location.search,await gn(Y,rt,!0,{submission:de,replace:ct}),{shortCircuited:!0}}if(li(rt)){let ct=Ya(Ce,wt.route.id);return(Ye&&Ye.replace)!==!0&&(L="PUSH"),{matches:Ce,pendingActionResult:[ct.route.id,rt,wt.route.id]}}return{matches:Ce,pendingActionResult:[wt.route.id,rt]}}async function Ge(Y,re,de,Ce,Ae,Je,lt,Ye,Ze,rt,wt,ct,Nt){let Ot=Je||Og(re,lt),Gn=lt||Ye||l1(Ot),Vn=!J&&!rt;if(Ae){if(Vn){let fn=_e(ct);q({navigation:Ot,...fn!==void 0?{actionData:fn}:{}},{flushSync:wt})}let zt=await Yt(de,re.pathname,Y.signal);if(zt.type==="aborted")return{shortCircuited:!0};if(zt.type==="error"){if(zt.partialMatches.length===0){let{matches:ka,route:Ws}=Oh(c);return{matches:ka,loaderData:{},errors:{[Ws.id]:zt.error}}}let fn=Ya(zt.partialMatches).route.id;return{matches:zt.partialMatches,loaderData:{},errors:{[fn]:zt.error}}}else if(zt.matches)de=zt.matches;else{let{error:fn,notFoundMatches:ka,route:Ws}=Mn(re.pathname);return{matches:ka,loaderData:{},errors:{[Ws.id]:fn}}}}let ir=h||c,{dsMatches:an,revalidatingFetchers:Lr}=Xw(Y,Ce,s,a,t.history,M,de,Gn,re,rt?[]:r,rt===!0,Q,Z,ye,B,ee,ir,d,t.patchRoutesOnNavigation!=null,ct,Nt);if(A=++ne,!t.dataStrategy&&!an.some(zt=>zt.shouldLoad)&&!an.some(zt=>zt.route.middleware&&zt.route.middleware.length>0)&&Lr.length===0){let zt=ze();return fe(re,{matches:de,loaderData:{},errors:ct&&li(ct[1])?{[ct[0]]:ct[1].error}:null,...a1(ct),...zt?{fetchers:new Map(M.fetchers)}:{}},{flushSync:wt}),{shortCircuited:!0}}if(Vn){let zt={};if(!Ae){zt.navigation=Ot;let fn=_e(ct);fn!==void 0&&(zt.actionData=fn)}Lr.length>0&&(zt.fetchers=Ve(Lr)),q(zt,{flushSync:wt})}Lr.forEach(zt=>{pe(zt.key),zt.controller&&D.set(zt.key,zt.controller)});let cn=()=>Lr.forEach(zt=>pe(zt.key));P&&P.signal.addEventListener("abort",cn);let{loaderResults:bo,fetcherResults:yi}=await xe(an,Lr,Y,Ce);if(Y.signal.aborted)return{shortCircuited:!0};P&&P.signal.removeEventListener("abort",cn),Lr.forEach(zt=>D.delete(zt.key));let ni=Lh(bo);if(ni)return await gn(Y,ni.result,!0,{replace:Ze}),{shortCircuited:!0};if(ni=Lh(yi),ni)return ee.add(ni.key),await gn(Y,ni.result,!0,{replace:Ze}),{shortCircuited:!0};let{loaderData:ba,errors:ko}=i1(M,de,bo,ct,Lr,yi);rt&&M.errors&&(ko={...M.errors,...ko});let us=ze(),Vs=Wt(A),jr=us||Vs||Lr.length>0;return{matches:de,loaderData:ba,errors:ko,...jr?{fetchers:new Map(M.fetchers)}:{}}}function _e(Y){if(Y&&!li(Y[1]))return{[Y[0]]:Y[1].data};if(M.actionData)return Object.keys(M.actionData).length===0?null:M.actionData}function Ve(Y){return Y.forEach(re=>{let de=M.fetchers.get(re.key),Ce=vu(void 0,de?de.data:void 0);M.fetchers.set(re.key,Ce)}),new Map(M.fetchers)}async function xt(Y,re,de,Ce){pe(Y);let Ae=(Ce&&Ce.flushSync)===!0,Je=h||c,lt=K0(M.location,M.matches,d,de,re,Ce==null?void 0:Ce.relative),Ye=Ga(Je,lt,d),Ze=ut(Ye,Je,lt);if(Ze.active&&Ze.matches&&(Ye=Ze.matches),!Ye){He(Y,re,ji(404,{pathname:lt}),{flushSync:Ae});return}let{path:rt,submission:wt,error:ct}=Jw(!0,lt,Ce);if(ct){He(Y,re,ct,{flushSync:Ae});return}let Nt=t.getContext?await t.getContext():new Ww,Ot=(Ce&&Ce.preventScrollReset)===!0;if(wt&&xr(wt.formMethod)){await Pt(Y,re,rt,Ye,Nt,Ze.active,Ae,Ot,wt,Ce&&Ce.unstable_defaultShouldRevalidate);return}B.set(Y,{routeId:re,path:rt}),await mn(Y,re,rt,Ye,Nt,Ze.active,Ae,Ot,wt)}async function Pt(Y,re,de,Ce,Ae,Je,lt,Ye,Ze,rt){Re(),B.delete(Y);let wt=M.fetchers.get(Y);Qe(Y,Z5(Ze,wt),{flushSync:lt});let ct=new AbortController,Nt=Zl(t.history,de,ct.signal,Ze);if(Je){let Pn=await Yt(Ce,new URL(Nt.url).pathname,Nt.signal,Y);if(Pn.type==="aborted")return;if(Pn.type==="error"){He(Y,re,Pn.error,{flushSync:lt});return}else if(Pn.matches)Ce=Pn.matches;else{He(Y,re,ji(404,{pathname:de}),{flushSync:lt});return}}let Ot=of(Ce,de);if(!Ot.route.action&&!Ot.route.lazy){let Pn=ji(405,{method:Ze.formMethod,pathname:de,routeId:re});He(Y,re,Pn,{flushSync:lt});return}D.set(Y,ct);let Gn=ne,Vn=ic(s,a,Nt,Ce,Ot,r,Ae),ir=await jn(Nt,Vn,Ae,Y),an=ir[Ot.route.id];if(!an){for(let Pn of Vn)if(ir[Pn.route.id]){an=ir[Pn.route.id];break}}if(Nt.signal.aborted){D.get(Y)===ct&&D.delete(Y);return}if(ye.has(Y)){if(Jo(an)||li(an)){Qe(Y,sa(void 0));return}}else{if(Jo(an))if(D.delete(Y),A>Gn){Qe(Y,sa(void 0));return}else return ee.add(Y),Qe(Y,vu(Ze)),gn(Nt,an,!1,{fetcherSubmission:Ze,preventScrollReset:Ye});if(li(an)){He(Y,re,an.error);return}}let Lr=M.navigation.location||M.location,cn=Zl(t.history,Lr,ct.signal),bo=h||c,yi=M.navigation.state!=="idle"?Ga(bo,M.navigation.location,d):M.matches;At(yi,"Didn't find any matches after fetcher action");let ni=++ne;z.set(Y,ni);let ba=vu(Ze,an.data);M.fetchers.set(Y,ba);let{dsMatches:ko,revalidatingFetchers:us}=Xw(cn,Ae,s,a,t.history,M,yi,Ze,Lr,r,!1,Q,Z,ye,B,ee,bo,d,t.patchRoutesOnNavigation!=null,[Ot.route.id,an],rt);us.filter(Pn=>Pn.key!==Y).forEach(Pn=>{let Hs=Pn.key,wo=M.fetchers.get(Hs),So=vu(void 0,wo?wo.data:void 0);M.fetchers.set(Hs,So),pe(Hs),Pn.controller&&D.set(Hs,Pn.controller)}),q({fetchers:new Map(M.fetchers)});let Vs=()=>us.forEach(Pn=>pe(Pn.key));ct.signal.addEventListener("abort",Vs);let{loaderResults:jr,fetcherResults:zt}=await xe(ko,us,cn,Ae);if(ct.signal.aborted)return;if(ct.signal.removeEventListener("abort",Vs),z.delete(Y),D.delete(Y),us.forEach(Pn=>D.delete(Pn.key)),M.fetchers.has(Y)){let Pn=sa(an.data);M.fetchers.set(Y,Pn)}let fn=Lh(jr);if(fn)return gn(cn,fn.result,!1,{preventScrollReset:Ye});if(fn=Lh(zt),fn)return ee.add(fn.key),gn(cn,fn.result,!1,{preventScrollReset:Ye});let{loaderData:ka,errors:Ws}=i1(M,yi,jr,void 0,us,zt);Wt(ni),M.navigation.state==="loading"&&ni>A?(At(L,"Expected pending action"),P&&P.abort(),fe(M.navigation.location,{matches:yi,loaderData:ka,errors:Ws,fetchers:new Map(M.fetchers)})):(q({errors:Ws,loaderData:s1(M.loaderData,ka,yi,Ws),fetchers:new Map(M.fetchers)}),Q=!1)}async function mn(Y,re,de,Ce,Ae,Je,lt,Ye,Ze){let rt=M.fetchers.get(Y);Qe(Y,vu(Ze,rt?rt.data:void 0),{flushSync:lt});let wt=new AbortController,ct=Zl(t.history,de,wt.signal);if(Je){let an=await Yt(Ce,new URL(ct.url).pathname,ct.signal,Y);if(an.type==="aborted")return;if(an.type==="error"){He(Y,re,an.error,{flushSync:lt});return}else if(an.matches)Ce=an.matches;else{He(Y,re,ji(404,{pathname:de}),{flushSync:lt});return}}let Nt=of(Ce,de);D.set(Y,wt);let Ot=ne,Gn=ic(s,a,ct,Ce,Nt,r,Ae),ir=(await jn(ct,Gn,Ae,Y))[Nt.route.id];if(D.get(Y)===wt&&D.delete(Y),!ct.signal.aborted){if(ye.has(Y)){Qe(Y,sa(void 0));return}if(Jo(ir))if(A>Ot){Qe(Y,sa(void 0));return}else{ee.add(Y),await gn(ct,ir,!1,{preventScrollReset:Ye});return}if(li(ir)){He(Y,re,ir.error);return}Qe(Y,sa(ir.data))}}async function gn(Y,re,de,{submission:Ce,fetcherSubmission:Ae,preventScrollReset:Je,replace:lt}={}){de||($==null||$.resolve(),$=null),re.response.headers.has("X-Remix-Revalidate")&&(Q=!0);let Ye=re.response.headers.get("Location");At(Ye,"Expected a Location header on the redirect Response"),Ye=n1(Ye,new URL(Y.url),d,t.history);let Ze=Qu(M.location,Ye,{_isRedirect:!0});if(n){let Gn=!1;if(re.response.headers.has("X-Remix-Reload-Document"))Gn=!0;else if(ly(Ye)){const Vn=BT(Ye,!0);Gn=Vn.origin!==e.location.origin||Ri(Vn.pathname,d)==null}if(Gn){lt?e.location.replace(Ye):e.location.assign(Ye);return}}P=null;let rt=lt===!0||re.response.headers.has("X-Remix-Replace")?"REPLACE":"PUSH",{formMethod:wt,formAction:ct,formEncType:Nt}=M.navigation;!Ce&&!Ae&&wt&&ct&&Nt&&(Ce=l1(M.navigation));let Ot=Ce||Ae;if(j5.has(re.response.status)&&Ot&&xr(Ot.formMethod))await Ke(rt,Ze,{submission:{...Ot,formAction:Ye},preventScrollReset:Je||E,enableViewTransition:de?V:void 0});else{let Gn=Og(Ze,Ce);await Ke(rt,Ze,{overrideNavigation:Gn,fetcherSubmission:Ae,preventScrollReset:Je||E,enableViewTransition:de?V:void 0})}}async function jn(Y,re,de,Ce){var lt;let Ae,Je={};try{Ae=await F5(f,Y,re,Ce,de,!1)}catch(Ye){return re.filter(Ze=>Ze.shouldLoad).forEach(Ze=>{Je[Ze.route.id]={type:"error",error:Ye}}),Je}if(Y.signal.aborted)return Je;if(!xr(Y.method))for(let Ye of re){if(((lt=Ae[Ye.route.id])==null?void 0:lt.type)==="error")break;!Ae.hasOwnProperty(Ye.route.id)&&!M.loaderData.hasOwnProperty(Ye.route.id)&&(!M.errors||!M.errors.hasOwnProperty(Ye.route.id))&&Ye.shouldCallHandler()&&(Ae[Ye.route.id]={type:"error",result:new Error(`No result returned from dataStrategy for route ${Ye.route.id}`)})}for(let[Ye,Ze]of Object.entries(Ae))if(G5(Ze)){let rt=Ze.result;Je[Ye]={type:"redirect",response:$5(rt,Y,Ye,re,d)}}else Je[Ye]=await z5(Ze);return Je}async function xe(Y,re,de,Ce){let Ae=jn(de,Y,Ce,null),Je=Promise.all(re.map(async Ze=>{if(Ze.matches&&Ze.match&&Ze.request&&Ze.controller){let wt=(await jn(Ze.request,Ze.matches,Ce,Ze.key))[Ze.match.route.id];return{[Ze.key]:wt}}else return Promise.resolve({[Ze.key]:{type:"error",error:ji(404,{pathname:Ze.path})}})})),lt=await Ae,Ye=(await Je).reduce((Ze,rt)=>Object.assign(Ze,rt),{});return{loaderResults:lt,fetcherResults:Ye}}function Re(){Q=!0,B.forEach((Y,re)=>{D.has(re)&&Z.add(re),pe(re)})}function Qe(Y,re,de={}){M.fetchers.set(Y,re),q({fetchers:new Map(M.fetchers)},{flushSync:(de&&de.flushSync)===!0})}function He(Y,re,de,Ce={}){let Ae=Ya(M.matches,re);vn(Y),q({errors:{[Ae.route.id]:de},fetchers:new Map(M.fetchers)},{flushSync:(Ce&&Ce.flushSync)===!0})}function gt(Y){return X.set(Y,(X.get(Y)||0)+1),ye.has(Y)&&ye.delete(Y),M.fetchers.get(Y)||P5}function hn(Y,re){pe(Y,re==null?void 0:re.reason),Qe(Y,sa(null))}function vn(Y){let re=M.fetchers.get(Y);D.has(Y)&&!(re&&re.state==="loading"&&z.has(Y))&&pe(Y),B.delete(Y),z.delete(Y),ee.delete(Y),ye.delete(Y),Z.delete(Y),M.fetchers.delete(Y)}function Fn(Y){let re=(X.get(Y)||0)-1;re<=0?(X.delete(Y),ye.add(Y)):X.set(Y,re),q({fetchers:new Map(M.fetchers)})}function pe(Y,re){let de=D.get(Y);de&&(de.abort(re),D.delete(Y))}function Ue(Y){for(let re of Y){let de=gt(re),Ce=sa(de.data);M.fetchers.set(re,Ce)}}function ze(){let Y=[],re=!1;for(let de of ee){let Ce=M.fetchers.get(de);At(Ce,`Expected fetcher: ${de}`),Ce.state==="loading"&&(ee.delete(de),Y.push(de),re=!0)}return Ue(Y),re}function Wt(Y){let re=[];for(let[de,Ce]of z)if(Ce<Y){let Ae=M.fetchers.get(de);At(Ae,`Expected fetcher: ${de}`),Ae.state==="loading"&&(pe(de),z.delete(de),re.push(de))}return Ue(re),re.length>0}function bt(Y,re){let de=M.blockers.get(Y)||gu;return se.get(Y)!==re&&se.set(Y,re),de}function Tn(Y){M.blockers.delete(Y),se.delete(Y)}function nn(Y,re){let de=M.blockers.get(Y)||gu;At(de.state==="unblocked"&&re.state==="blocked"||de.state==="blocked"&&re.state==="blocked"||de.state==="blocked"&&re.state==="proceeding"||de.state==="blocked"&&re.state==="unblocked"||de.state==="proceeding"&&re.state==="unblocked",`Invalid blocker state transition: ${de.state} -> ${re.state}`);let Ce=new Map(M.blockers);Ce.set(Y,re),q({blockers:Ce})}function Kn({currentLocation:Y,nextLocation:re,historyAction:de}){if(se.size===0)return;se.size>1&&Zn(!1,"A router only supports one blocker at a time");let Ce=Array.from(se.entries()),[Ae,Je]=Ce[Ce.length-1],lt=M.blockers.get(Ae);if(!(lt&&lt.state==="proceeding")&&Je({currentLocation:Y,nextLocation:re,historyAction:de}))return Ae}function Mn(Y){let re=ji(404,{pathname:Y}),de=h||c,{matches:Ce,route:Ae}=Oh(de);return{notFoundMatches:Ce,route:Ae,error:re}}function ce(Y,re,de){if(k=Y,S=re,w=de||null,!T&&M.navigation===Ag){T=!0;let Ce=Ct(M.location,M.matches);Ce!=null&&q({restoreScrollPosition:Ce})}return()=>{k=null,S=null,w=null}}function be(Y,re){return w&&w(Y,re.map(Ce=>t5(Ce,M.loaderData)))||Y.key}function We(Y,re){if(k&&S){let de=be(Y,re);k[de]=S()}}function Ct(Y,re){if(k){let de=be(Y,re),Ce=k[de];if(typeof Ce=="number")return Ce}return null}function ut(Y,re,de){if(t.patchRoutesOnNavigation)if(Y){if(Object.keys(Y[0].params).length>0)return{active:!0,matches:Ou(re,de,d,!0)}}else return{active:!0,matches:Ou(re,de,d,!0)||[]};return{active:!1,matches:null}}async function Yt(Y,re,de,Ce){if(!t.patchRoutesOnNavigation)return{type:"success",matches:Y};let Ae=Y;for(;;){let Je=h==null,lt=h||c,Ye=a;try{await t.patchRoutesOnNavigation({signal:de,path:re,matches:Ae,fetcherKey:Ce,patch:(wt,ct)=>{de.aborted||Qw(wt,ct,lt,Ye,s,!1)}})}catch(wt){return{type:"error",error:wt,partialMatches:Ae}}finally{Je&&!de.aborted&&(c=[...c])}if(de.aborted)return{type:"aborted"};let Ze=Ga(lt,re,d),rt=null;if(Ze){if(Object.keys(Ze[0].params).length===0)return{type:"success",matches:Ze};if(rt=Ou(lt,re,d,!0),!(rt&&Ae.length<rt.length&&kt(Ae,rt.slice(0,Ae.length))))return{type:"success",matches:Ze}}if(rt||(rt=Ou(lt,re,d,!0)),!rt||kt(Ae,rt))return{type:"success",matches:null};Ae=rt}}function kt(Y,re){return Y.length===re.length&&Y.every((de,Ce)=>de.route.id===re[Ce].route.id)}function Bt(Y){a={},h=Zu(Y,s,void 0,a)}function ln(Y,re,de=!1){let Ce=h==null;Qw(Y,re,h||c,a,s,de),Ce&&(c=[...c],q({}))}return I={get basename(){return d},get future(){return p},get state(){return M},get routes(){return c},get window(){return e},initialize:ue,subscribe:W,enableScrollRestoration:ce,navigate:ve,fetch:xt,revalidate:Se,createHref:Y=>t.history.createHref(Y),encodeLocation:Y=>t.history.encodeLocation(Y),getFetcher:gt,resetFetcher:hn,deleteFetcher:Fn,dispose:ke,getBlocker:bt,deleteBlocker:Tn,patchRoutes:ln,_internalFetchControllers:D,_internalSetRoutes:Bt,_internalSetStateDoNotUseOrYouWillBreakYourApp(Y){q(Y)}},t.unstable_instrumentations&&(I=b5(I,t.unstable_instrumentations.map(Y=>Y.router).filter(Boolean))),I}function I5(t){return t!=null&&("formData"in t&&t.formData!=null||"body"in t&&t.body!==void 0)}function K0(t,e,n,r,i,s){let a,c;if(i){a=[];for(let d of e)if(a.push(d),d.route.id===i){c=d;break}}else a=e,c=e[e.length-1];let h=uy(r||".",cy(a),Ri(t.pathname,n)||t.pathname,s==="path");if(r==null&&(h.search=t.search,h.hash=t.hash),(r==null||r===""||r===".")&&c){let d=fy(h.search);if(c.route.index&&!d)h.search=h.search?h.search.replace(/^\?/,"?index&"):"?index";else if(!c.route.index&&d){let f=new URLSearchParams(h.search),p=f.getAll("index");f.delete("index"),p.filter(v=>v).forEach(v=>f.append("index",v));let g=f.toString();h.search=g?`?${g}`:""}}return n!=="/"&&(h.pathname=p5({basename:n,pathname:h.pathname})),Es(h)}function Jw(t,e,n){if(!n||!I5(n))return{path:e};if(n.formMethod&&!X5(n.formMethod))return{path:e,error:ji(405,{method:n.formMethod})};let r=()=>({path:e,error:ji(400,{type:"invalid-body"})}),s=(n.formMethod||"get").toUpperCase(),a=rN(e);if(n.body!==void 0){if(n.formEncType==="text/plain"){if(!xr(s))return r();let p=typeof n.body=="string"?n.body:n.body instanceof FormData||n.body instanceof URLSearchParams?Array.from(n.body.entries()).reduce((g,[v,k])=>`${g}${v}=${k}
50
+ `,""):String(n.body);return{path:e,submission:{formMethod:s,formAction:a,formEncType:n.formEncType,formData:void 0,json:void 0,text:p}}}else if(n.formEncType==="application/json"){if(!xr(s))return r();try{let p=typeof n.body=="string"?JSON.parse(n.body):n.body;return{path:e,submission:{formMethod:s,formAction:a,formEncType:n.formEncType,formData:void 0,json:p,text:void 0}}}catch{return r()}}}At(typeof FormData=="function","FormData is not available in this environment");let c,h;if(n.formData)c=J0(n.formData),h=n.formData;else if(n.body instanceof FormData)c=J0(n.body),h=n.body;else if(n.body instanceof URLSearchParams)c=n.body,h=r1(c);else if(n.body==null)c=new URLSearchParams,h=new FormData;else try{c=new URLSearchParams(n.body),h=r1(c)}catch{return r()}let d={formMethod:s,formAction:a,formEncType:n&&n.formEncType||"application/x-www-form-urlencoded",formData:h,json:void 0,text:void 0};if(xr(d.formMethod))return{path:e,submission:d};let f=ho(e);return t&&f.search&&fy(f.search)&&c.append("index",""),f.search=`?${c}`,{path:Es(f),submission:d}}function Xw(t,e,n,r,i,s,a,c,h,d,f,p,g,v,k,w,S,T,C,j,R){var J;let _=j?li(j[1])?j[1].error:j[1].data:void 0,I=i.createURL(s.location),M=i.createURL(h),L;if(f&&s.errors){let Q=Object.keys(s.errors)[0];L=a.findIndex(Z=>Z.route.id===Q)}else if(j&&li(j[1])){let Q=j[0];L=a.findIndex(Z=>Z.route.id===Q)-1}let $=j?j[1].statusCode:void 0,E=$&&$>=400,P={currentUrl:I,currentParams:((J=s.matches[0])==null?void 0:J.params)||{},nextUrl:M,nextParams:a[0].params,...c,actionResult:_,actionStatus:$},V=xd(a),F=a.map((Q,Z)=>{let{route:D}=Q,ne=null;if(L!=null&&Z>L?ne=!1:D.lazy?ne=!0:dy(D)?f?ne=G0(D,s.loaderData,s.errors):M5(s.loaderData,s.matches[Z],Q)&&(ne=!0):ne=!1,ne!==null)return Y0(n,r,t,V,Q,d,e,ne);let A=!1;typeof R=="boolean"?A=R:E?A=!1:(p||I.pathname+I.search===M.pathname+M.search||I.search!==M.search||D5(s.matches[Z],Q))&&(A=!0);let z={...P,defaultShouldRevalidate:A},ee=Bu(Q,z);return Y0(n,r,t,V,Q,d,e,ee,z,R)}),K=[];return k.forEach((Q,Z)=>{if(f||!a.some(ye=>ye.route.id===Q.routeId)||v.has(Z))return;let D=s.fetchers.get(Z),ne=D&&D.state!=="idle"&&D.data===void 0,A=Ga(S,Q.path,T);if(!A){if(C&&ne)return;K.push({key:Z,routeId:Q.routeId,path:Q.path,matches:null,match:null,request:null,controller:null});return}if(w.has(Z))return;let z=of(A,Q.path),ee=new AbortController,B=Zl(i,Q.path,ee.signal),X=null;if(g.has(Z))g.delete(Z),X=ic(n,r,B,A,z,d,e);else if(ne)p&&(X=ic(n,r,B,A,z,d,e));else{let ye;typeof R=="boolean"?ye=R:E?ye=!1:ye=p;let se={...P,defaultShouldRevalidate:ye};Bu(z,se)&&(X=ic(n,r,B,A,z,d,e,se))}X&&K.push({key:Z,routeId:Q.routeId,path:Q.path,matches:X,match:z,request:B,controller:ee})}),{dsMatches:F,revalidatingFetchers:K}}function dy(t){return t.loader!=null||t.middleware!=null&&t.middleware.length>0}function G0(t,e,n){if(t.lazy)return!0;if(!dy(t))return!1;let r=e!=null&&t.id in e,i=n!=null&&n[t.id]!==void 0;return!r&&i?!1:typeof t.loader=="function"&&t.loader.hydrate===!0?!0:!r&&!i}function M5(t,e,n){let r=!e||n.route.id!==e.route.id,i=!t.hasOwnProperty(n.route.id);return r||i}function D5(t,e){let n=t.route.path;return t.pathname!==e.pathname||n!=null&&n.endsWith("*")&&t.params["*"]!==e.params["*"]}function Bu(t,e){if(t.route.shouldRevalidate){let n=t.route.shouldRevalidate(e);if(typeof n=="boolean")return n}return e.defaultShouldRevalidate}function Qw(t,e,n,r,i,s){let a;if(t){let d=r[t];At(d,`No route found to patch children into: routeId = ${t}`),d.children||(d.children=[]),a=d.children}else a=n;let c=[],h=[];if(e.forEach(d=>{let f=a.find(p=>QT(d,p));f?h.push({existingRoute:f,newRoute:d}):c.push(d)}),c.length>0){let d=Zu(c,i,[t||"_","patch",String((a==null?void 0:a.length)||"0")],r);a.push(...d)}if(s&&h.length>0)for(let d=0;d<h.length;d++){let{existingRoute:f,newRoute:p}=h[d],g=f,[v]=Zu([p],i,[],{},!0);Object.assign(g,{element:v.element?v.element:g.element,errorElement:v.errorElement?v.errorElement:g.errorElement,hydrateFallbackElement:v.hydrateFallbackElement?v.hydrateFallbackElement:g.hydrateFallbackElement})}}function QT(t,e){return"id"in t&&"id"in e&&t.id===e.id?!0:t.index===e.index&&t.path===e.path&&t.caseSensitive===e.caseSensitive?(!t.children||t.children.length===0)&&(!e.children||e.children.length===0)?!0:t.children.every((n,r)=>{var i;return(i=e.children)==null?void 0:i.some(s=>QT(n,s))}):!1}var Zw=new WeakMap,ZT=({key:t,route:e,manifest:n,mapRouteProperties:r})=>{let i=n[e.id];if(At(i,"No route found in manifest"),!i.lazy||typeof i.lazy!="object")return;let s=i.lazy[t];if(!s)return;let a=Zw.get(i);a||(a={},Zw.set(i,a));let c=a[t];if(c)return c;let h=(async()=>{let d=XI(t),p=i[t]!==void 0&&t!=="hasErrorBoundary";if(d)Zn(!d,"Route property "+t+" is not a supported lazy route property. This property will be ignored."),a[t]=Promise.resolve();else if(p)Zn(!1,`Route "${i.id}" has a static property "${t}" defined. The lazy property will be ignored.`);else{let g=await s();g!=null&&(Object.assign(i,{[t]:g}),Object.assign(i,r(i)))}typeof i.lazy=="object"&&(i.lazy[t]=void 0,Object.values(i.lazy).every(g=>g===void 0)&&(i.lazy=void 0))})();return a[t]=h,h},e1=new WeakMap;function A5(t,e,n,r,i){let s=n[t.id];if(At(s,"No route found in manifest"),!t.lazy)return{lazyRoutePromise:void 0,lazyHandlerPromise:void 0};if(typeof t.lazy=="function"){let f=e1.get(s);if(f)return{lazyRoutePromise:f,lazyHandlerPromise:f};let p=(async()=>{At(typeof t.lazy=="function","No lazy route function found");let g=await t.lazy(),v={};for(let k in g){let w=g[k];if(w===void 0)continue;let S=ZI(k),C=s[k]!==void 0&&k!=="hasErrorBoundary";S?Zn(!S,"Route property "+k+" is not a supported property to be returned from a lazy route function. This property will be ignored."):C?Zn(!C,`Route "${s.id}" has a static property "${k}" defined but its lazy function is also returning a value for this property. The lazy route property "${k}" will be ignored.`):v[k]=w}Object.assign(s,v),Object.assign(s,{...r(s),lazy:void 0})})();return e1.set(s,p),p.catch(()=>{}),{lazyRoutePromise:p,lazyHandlerPromise:p}}let a=Object.keys(t.lazy),c=[],h;for(let f of a){if(i&&i.includes(f))continue;let p=ZT({key:f,route:t,manifest:n,mapRouteProperties:r});p&&(c.push(p),f===e&&(h=p))}let d=c.length>0?Promise.all(c).then(()=>{}):void 0;return d==null||d.catch(()=>{}),h==null||h.catch(()=>{}),{lazyRoutePromise:d,lazyHandlerPromise:h}}async function t1(t){let e=t.matches.filter(i=>i.shouldLoad),n={};return(await Promise.all(e.map(i=>i.resolve()))).forEach((i,s)=>{n[e[s].route.id]=i}),n}async function O5(t){return t.matches.some(e=>e.route.middleware)?eN(t,()=>t1(t)):t1(t)}function eN(t,e){return L5(t,e,r=>{if(J5(r))throw r;return r},q5,n);function n(r,i,s){if(s)return Promise.resolve(Object.assign(s.value,{[i]:{type:"error",result:r}}));{let{matches:a}=t,c=Math.min(Math.max(a.findIndex(d=>d.route.id===i),0),Math.max(a.findIndex(d=>d.shouldCallHandler()),0)),h=Ya(a,a[c].route.id).route.id;return Promise.resolve({[h]:{type:"error",result:r}})}}}async function L5(t,e,n,r,i){let{matches:s,request:a,params:c,context:h,unstable_pattern:d}=t,f=s.flatMap(g=>g.route.middleware?g.route.middleware.map(v=>[g.route.id,v]):[]);return await tN({request:a,params:c,context:h,unstable_pattern:d},f,e,n,r,i)}async function tN(t,e,n,r,i,s,a=0){let{request:c}=t;if(c.signal.aborted)throw c.signal.reason??new Error(`Request aborted: ${c.method} ${c.url}`);let h=e[a];if(!h)return await n();let[d,f]=h,p,g=async()=>{if(p)throw new Error("You may only call `next()` once per middleware");try{return p={value:await tN(t,e,n,r,i,s,a+1)},p.value}catch(v){return p={value:await s(v,d,p)},p.value}};try{let v=await f(t,g),k=v!=null?r(v):void 0;return i(k)?k:p?k??p.value:(p={value:await g()},p.value)}catch(v){return await s(v,d,p)}}function nN(t,e,n,r,i){let s=ZT({key:"middleware",route:r.route,manifest:e,mapRouteProperties:t}),a=A5(r.route,xr(n.method)?"action":"loader",e,t,i);return{middleware:s,route:a.lazyRoutePromise,handler:a.lazyHandlerPromise}}function Y0(t,e,n,r,i,s,a,c,h=null,d){let f=!1,p=nN(t,e,n,i,s);return{...i,_lazyPromises:p,shouldLoad:c,shouldRevalidateArgs:h,shouldCallHandler(g){return f=!0,h?typeof d=="boolean"?Bu(i,{...h,defaultShouldRevalidate:d}):typeof g=="boolean"?Bu(i,{...h,defaultShouldRevalidate:g}):Bu(i,h):c},resolve(g){let{lazy:v,loader:k,middleware:w}=i.route,S=f||c||g&&!xr(n.method)&&(v||k),T=w&&w.length>0&&!k&&!v;return S&&(xr(n.method)||!T)?U5({request:n,unstable_pattern:r,match:i,lazyHandlerPromise:p==null?void 0:p.handler,lazyRoutePromise:p==null?void 0:p.route,handlerOverride:g,scopedContext:a}):Promise.resolve({type:"data",result:void 0})}}}function ic(t,e,n,r,i,s,a,c=null){return r.map(h=>h.route.id!==i.route.id?{...h,shouldLoad:!1,shouldRevalidateArgs:c,shouldCallHandler:()=>!1,_lazyPromises:nN(t,e,n,h,s),resolve:()=>Promise.resolve({type:"data",result:void 0})}:Y0(t,e,n,xd(r),h,s,a,!0,c))}async function F5(t,e,n,r,i,s){n.some(d=>{var f;return(f=d._lazyPromises)==null?void 0:f.middleware})&&await Promise.all(n.map(d=>{var f;return(f=d._lazyPromises)==null?void 0:f.middleware}));let a={request:e,unstable_pattern:xd(n),params:n[0].params,context:i,matches:n},h=await t({...a,fetcherKey:r,runClientMiddleware:d=>{let f=a;return eN(f,()=>d({...f,fetcherKey:r,runClientMiddleware:()=>{throw new Error("Cannot call `runClientMiddleware()` from within an `runClientMiddleware` handler")}}))}});try{await Promise.all(n.flatMap(d=>{var f,p;return[(f=d._lazyPromises)==null?void 0:f.handler,(p=d._lazyPromises)==null?void 0:p.route]}))}catch{}return h}async function U5({request:t,unstable_pattern:e,match:n,lazyHandlerPromise:r,lazyRoutePromise:i,handlerOverride:s,scopedContext:a}){let c,h,d=xr(t.method),f=d?"action":"loader",p=g=>{let v,k=new Promise((T,C)=>v=C);h=()=>v(),t.signal.addEventListener("abort",h);let w=T=>typeof g!="function"?Promise.reject(new Error(`You cannot call the handler for a route which defines a boolean "${f}" [routeId: ${n.route.id}]`)):g({request:t,unstable_pattern:e,params:n.params,context:a},...T!==void 0?[T]:[]),S=(async()=>{try{return{type:"data",result:await(s?s(C=>w(C)):w())}}catch(T){return{type:"error",result:T}}})();return Promise.race([S,k])};try{let g=d?n.route.action:n.route.loader;if(r||i)if(g){let v,[k]=await Promise.all([p(g).catch(w=>{v=w}),r,i]);if(v!==void 0)throw v;c=k}else{await r;let v=d?n.route.action:n.route.loader;if(v)[c]=await Promise.all([p(v),i]);else if(f==="action"){let k=new URL(t.url),w=k.pathname+k.search;throw ji(405,{method:t.method,pathname:w,routeId:n.route.id})}else return{type:"data",result:void 0}}else if(g)c=await p(g);else{let v=new URL(t.url),k=v.pathname+v.search;throw ji(404,{pathname:k})}}catch(g){return{type:"error",result:g}}finally{h&&t.signal.removeEventListener("abort",h)}return c}async function B5(t){let e=t.headers.get("Content-Type");return e&&/\bapplication\/json\b/.test(e)?t.body==null?null:t.json():t.text()}async function z5(t){var r,i,s,a,c;let{result:e,type:n}=t;if(hy(e)){let h;try{h=await B5(e)}catch(d){return{type:"error",error:d}}return n==="error"?{type:"error",error:new yd(e.status,e.statusText,h),statusCode:e.status,headers:e.headers}:{type:"data",data:h,statusCode:e.status,headers:e.headers}}return n==="error"?o1(e)?e.data instanceof Error?{type:"error",error:e.data,statusCode:(r=e.init)==null?void 0:r.status,headers:(i=e.init)!=null&&i.headers?new Headers(e.init.headers):void 0}:{type:"error",error:H5(e),statusCode:ed(e)?e.status:void 0,headers:(s=e.init)!=null&&s.headers?new Headers(e.init.headers):void 0}:{type:"error",error:e,statusCode:ed(e)?e.status:void 0}:o1(e)?{type:"data",data:e.data,statusCode:(a=e.init)==null?void 0:a.status,headers:(c=e.init)!=null&&c.headers?new Headers(e.init.headers):void 0}:{type:"data",data:e}}function $5(t,e,n,r,i){let s=t.headers.get("Location");if(At(s,"Redirects returned/thrown from loaders/actions must have a Location header"),!ly(s)){let a=r.slice(0,r.findIndex(c=>c.route.id===n)+1);s=K0(new URL(e.url),a,i,s),t.headers.set("Location",s)}return t}function n1(t,e,n,r){let i=["about:","blob:","chrome:","chrome-untrusted:","content:","data:","devtools:","file:","filesystem:","javascript:"];if(ly(t)){let s=t,a=s.startsWith("//")?new URL(e.protocol+s):new URL(s);if(i.includes(a.protocol))throw new Error("Invalid redirect location");let c=Ri(a.pathname,n)!=null;if(a.origin===e.origin&&c)return a.pathname+a.search+a.hash}try{let s=r.createURL(t);if(i.includes(s.protocol))throw new Error("Invalid redirect location")}catch{}return t}function Zl(t,e,n,r){let i=t.createURL(rN(e)).toString(),s={signal:n};if(r&&xr(r.formMethod)){let{formMethod:a,formEncType:c}=r;s.method=a.toUpperCase(),c==="application/json"?(s.headers=new Headers({"Content-Type":c}),s.body=JSON.stringify(r.json)):c==="text/plain"?s.body=r.text:c==="application/x-www-form-urlencoded"&&r.formData?s.body=J0(r.formData):s.body=r.formData}return new Request(i,s)}function J0(t){let e=new URLSearchParams;for(let[n,r]of t.entries())e.append(n,typeof r=="string"?r:r.name);return e}function r1(t){let e=new FormData;for(let[n,r]of t.entries())e.append(n,r);return e}function V5(t,e,n,r=!1,i=!1){let s={},a=null,c,h=!1,d={},f=n&&li(n[1])?n[1].error:void 0;return t.forEach(p=>{if(!(p.route.id in e))return;let g=p.route.id,v=e[g];if(At(!Jo(v),"Cannot handle redirect results in processLoaderData"),li(v)){let k=v.error;if(f!==void 0&&(k=f,f=void 0),a=a||{},i)a[g]=k;else{let w=Ya(t,g);a[w.route.id]==null&&(a[w.route.id]=k)}r||(s[g]=XT),h||(h=!0,c=ed(v.error)?v.error.status:500),v.headers&&(d[g]=v.headers)}else s[g]=v.data,v.statusCode&&v.statusCode!==200&&!h&&(c=v.statusCode),v.headers&&(d[g]=v.headers)}),f!==void 0&&n&&(a={[n[0]]:f},n[2]&&(s[n[2]]=void 0)),{loaderData:s,errors:a,statusCode:c||200,loaderHeaders:d}}function i1(t,e,n,r,i,s){let{loaderData:a,errors:c}=V5(e,n,r);return i.filter(h=>!h.matches||h.matches.some(d=>d.shouldLoad)).forEach(h=>{let{key:d,match:f,controller:p}=h;if(p&&p.signal.aborted)return;let g=s[d];if(At(g,"Did not find corresponding fetcher result"),li(g)){let v=Ya(t.matches,f==null?void 0:f.route.id);c&&c[v.route.id]||(c={...c,[v.route.id]:g.error}),t.fetchers.delete(d)}else if(Jo(g))At(!1,"Unhandled fetcher revalidation redirect");else{let v=sa(g.data);t.fetchers.set(d,v)}}),{loaderData:a,errors:c}}function s1(t,e,n,r){let i=Object.entries(e).filter(([,s])=>s!==XT).reduce((s,[a,c])=>(s[a]=c,s),{});for(let s of n){let a=s.route.id;if(!e.hasOwnProperty(a)&&t.hasOwnProperty(a)&&s.route.loader&&(i[a]=t[a]),r&&r.hasOwnProperty(a))break}return i}function a1(t){return t?li(t[1])?{actionData:{}}:{actionData:{[t[0]]:t[1].data}}:{}}function Ya(t,e){return(e?t.slice(0,t.findIndex(r=>r.route.id===e)+1):[...t]).reverse().find(r=>r.route.hasErrorBoundary===!0)||t[0]}function Oh(t){let e=t.length===1?t[0]:t.find(n=>n.index||!n.path||n.path==="/")||{id:"__shim-error-route__"};return{matches:[{params:{},pathname:"",pathnameBase:"",route:e}],route:e}}function ji(t,{pathname:e,routeId:n,method:r,type:i,message:s}={}){let a="Unknown Server Error",c="Unknown @remix-run/router error";return t===400?(a="Bad Request",r&&e&&n?c=`You made a ${r} request to "${e}" but did not provide a \`loader\` for route "${n}", so there is no way to handle the request.`:i==="invalid-body"&&(c="Unable to encode submission body")):t===403?(a="Forbidden",c=`Route "${n}" does not match URL "${e}"`):t===404?(a="Not Found",c=`No route matches URL "${e}"`):t===405&&(a="Method Not Allowed",r&&e&&n?c=`You made a ${r.toUpperCase()} request to "${e}" but did not provide an \`action\` for route "${n}", so there is no way to handle the request.`:r&&(c=`Invalid request method "${r.toUpperCase()}"`)),new yd(t||500,a,new Error(c),!0)}function Lh(t){let e=Object.entries(t);for(let n=e.length-1;n>=0;n--){let[r,i]=e[n];if(Jo(i))return{key:r,result:i}}}function rN(t){let e=typeof t=="string"?ho(t):t;return Es({...e,hash:""})}function W5(t,e){return t.pathname!==e.pathname||t.search!==e.search?!1:t.hash===""?e.hash!=="":t.hash===e.hash?!0:e.hash!==""}function H5(t){var e,n;return new yd(((e=t.init)==null?void 0:e.status)??500,((n=t.init)==null?void 0:n.statusText)??"Internal Server Error",t.data)}function q5(t){return t!=null&&typeof t=="object"&&Object.entries(t).every(([e,n])=>typeof e=="string"&&K5(n))}function K5(t){return t!=null&&typeof t=="object"&&"type"in t&&"result"in t&&(t.type==="data"||t.type==="error")}function G5(t){return hy(t.result)&&YT.has(t.result.status)}function li(t){return t.type==="error"}function Jo(t){return(t&&t.type)==="redirect"}function o1(t){return typeof t=="object"&&t!=null&&"type"in t&&"data"in t&&"init"in t&&t.type==="DataWithResponseInit"}function hy(t){return t!=null&&typeof t.status=="number"&&typeof t.statusText=="string"&&typeof t.headers=="object"&&typeof t.body<"u"}function Y5(t){return YT.has(t)}function J5(t){return hy(t)&&Y5(t.status)&&t.headers.has("Location")}function X5(t){return E5.has(t.toUpperCase())}function xr(t){return T5.has(t.toUpperCase())}function fy(t){return new URLSearchParams(t).getAll("index").some(e=>e==="")}function of(t,e){let n=typeof e=="string"?ho(e).search:e.search;if(t[t.length-1].route.index&&fy(n||""))return t[t.length-1];let r=WT(t);return r[r.length-1]}function l1(t){let{formMethod:e,formAction:n,formEncType:r,text:i,formData:s,json:a}=t;if(!(!e||!n||!r)){if(i!=null)return{formMethod:e,formAction:n,formEncType:r,formData:void 0,json:void 0,text:i};if(s!=null)return{formMethod:e,formAction:n,formEncType:r,formData:s,json:void 0,text:void 0};if(a!==void 0)return{formMethod:e,formAction:n,formEncType:r,formData:void 0,json:a,text:void 0}}}function Og(t,e){return e?{state:"loading",location:t,formMethod:e.formMethod,formAction:e.formAction,formEncType:e.formEncType,formData:e.formData,json:e.json,text:e.text}:{state:"loading",location:t,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0}}function Q5(t,e){return{state:"submitting",location:t,formMethod:e.formMethod,formAction:e.formAction,formEncType:e.formEncType,formData:e.formData,json:e.json,text:e.text}}function vu(t,e){return t?{state:"loading",formMethod:t.formMethod,formAction:t.formAction,formEncType:t.formEncType,formData:t.formData,json:t.json,text:t.text,data:e}:{state:"loading",formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0,data:e}}function Z5(t,e){return{state:"submitting",formMethod:t.formMethod,formAction:t.formAction,formEncType:t.formEncType,formData:t.formData,json:t.json,text:t.text,data:e?e.data:void 0}}function sa(t){return{state:"idle",formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0,data:t}}function eM(t,e){try{let n=t.sessionStorage.getItem(JT);if(n){let r=JSON.parse(n);for(let[i,s]of Object.entries(r||{}))s&&Array.isArray(s)&&e.set(i,new Set(s||[]))}}catch{}}function tM(t,e){if(e.size>0){let n={};for(let[r,i]of e)n[r]=[...i];try{t.sessionStorage.setItem(JT,JSON.stringify(n))}catch(r){Zn(!1,`Failed to save applied view transitions in sessionStorage (${r}).`)}}}function c1(){let t,e,n=new Promise((r,i)=>{t=async s=>{r(s);try{await n}catch{}},e=async s=>{i(s);try{await n}catch{}}});return{promise:n,resolve:t,reject:e}}var vl=x.createContext(null);vl.displayName="DataRouter";var bd=x.createContext(null);bd.displayName="DataRouterState";var iN=x.createContext(!1);function nM(){return x.useContext(iN)}var py=x.createContext({isTransitioning:!1});py.displayName="ViewTransition";var sN=x.createContext(new Map);sN.displayName="Fetchers";var rM=x.createContext(null);rM.displayName="Await";var Ii=x.createContext(null);Ii.displayName="Navigation";var dp=x.createContext(null);dp.displayName="Location";var ls=x.createContext({outlet:null,matches:[],isDataRoute:!1});ls.displayName="Route";var my=x.createContext(null);my.displayName="RouteError";var aN="REACT_ROUTER_ERROR",iM="REDIRECT",sM="ROUTE_ERROR_RESPONSE";function aM(t){if(t.startsWith(`${aN}:${iM}:{`))try{let e=JSON.parse(t.slice(28));if(typeof e=="object"&&e&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.location=="string"&&typeof e.reloadDocument=="boolean"&&typeof e.replace=="boolean")return e}catch{}}function oM(t){if(t.startsWith(`${aN}:${sM}:{`))try{let e=JSON.parse(t.slice(40));if(typeof e=="object"&&e&&typeof e.status=="number"&&typeof e.statusText=="string")return new yd(e.status,e.statusText,e.data)}catch{}}function lM(t,{relative:e}={}){At(kd(),"useHref() may be used only in the context of a <Router> component.");let{basename:n,navigator:r}=x.useContext(Ii),{hash:i,pathname:s,search:a}=wd(t,{relative:e}),c=s;return n!=="/"&&(c=s==="/"?n:ws([n,s])),r.createHref({pathname:c,search:a,hash:i})}function kd(){return x.useContext(dp)!=null}function ma(){return At(kd(),"useLocation() may be used only in the context of a <Router> component."),x.useContext(dp).location}var oN="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function lN(t){x.useContext(Ii).static||x.useLayoutEffect(t)}function Pc(){let{isDataRoute:t}=x.useContext(ls);return t?CM():cM()}function cM(){At(kd(),"useNavigate() may be used only in the context of a <Router> component.");let t=x.useContext(vl),{basename:e,navigator:n}=x.useContext(Ii),{matches:r}=x.useContext(ls),{pathname:i}=ma(),s=JSON.stringify(cy(r)),a=x.useRef(!1);return lN(()=>{a.current=!0}),x.useCallback((h,d={})=>{if(Zn(a.current,oN),!a.current)return;if(typeof h=="number"){n.go(h);return}let f=uy(h,JSON.parse(s),i,d.relative==="path");t==null&&e!=="/"&&(f.pathname=f.pathname==="/"?e:ws([e,f.pathname])),(d.replace?n.replace:n.push)(f,d.state,d)},[e,n,s,i,t])}var uM=x.createContext(null);function dM(t){let e=x.useContext(ls).outlet;return x.useMemo(()=>e&&x.createElement(uM.Provider,{value:t},e),[e,t])}function hM(){let{matches:t}=x.useContext(ls),e=t[t.length-1];return e?e.params:{}}function wd(t,{relative:e}={}){let{matches:n}=x.useContext(ls),{pathname:r}=ma(),i=JSON.stringify(cy(n));return x.useMemo(()=>uy(t,JSON.parse(i),r,e==="path"),[t,i,r,e])}function fM(t,e,n,r,i){At(kd(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:s}=x.useContext(Ii),{matches:a}=x.useContext(ls),c=a[a.length-1],h=c?c.params:{},d=c?c.pathname:"/",f=c?c.pathnameBase:"/",p=c&&c.route;{let C=p&&p.path||"";uN(d,!p||C.endsWith("*")||C.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${d}" (under <Route path="${C}">) 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.
51
+
52
+ Please change the parent <Route path="${C}"> to <Route path="${C==="/"?"*":`${C}/*`}">.`)}let g=ma(),v;v=g;let k=v.pathname||"/",w=k;if(f!=="/"){let C=f.replace(/^\//,"").split("/");w="/"+k.replace(/^\//,"").split("/").slice(C.length).join("/")}let S=Ga(t,{pathname:w});return Zn(p||S!=null,`No routes matched location "${v.pathname}${v.search}${v.hash}" `),Zn(S==null||S[S.length-1].route.element!==void 0||S[S.length-1].route.Component!==void 0||S[S.length-1].route.lazy!==void 0,`Matched leaf route at location "${v.pathname}${v.search}${v.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.`),yM(S&&S.map(C=>Object.assign({},C,{params:Object.assign({},h,C.params),pathname:ws([f,s.encodeLocation?s.encodeLocation(C.pathname.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:C.pathname]),pathnameBase:C.pathnameBase==="/"?f:ws([f,s.encodeLocation?s.encodeLocation(C.pathnameBase.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:C.pathnameBase])})),a,n,r,i)}function pM(){let t=SM(),e=ed(t)?`${t.status} ${t.statusText}`:t instanceof Error?t.message:JSON.stringify(t),n=t instanceof Error?t.stack:null,r="rgba(200,200,200, 0.5)",i={padding:"0.5rem",backgroundColor:r},s={padding:"2px 4px",backgroundColor:r},a=null;return console.error("Error handled by React Router default ErrorBoundary:",t),a=x.createElement(x.Fragment,null,x.createElement("p",null,"💿 Hey developer 👋"),x.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",x.createElement("code",{style:s},"ErrorBoundary")," or"," ",x.createElement("code",{style:s},"errorElement")," prop on your route.")),x.createElement(x.Fragment,null,x.createElement("h2",null,"Unexpected Application Error!"),x.createElement("h3",{style:{fontStyle:"italic"}},e),n?x.createElement("pre",{style:i},n):null,a)}var mM=x.createElement(pM,null),cN=class extends x.Component{constructor(t){super(t),this.state={location:t.location,revalidation:t.revalidation,error:t.error}}static getDerivedStateFromError(t){return{error:t}}static getDerivedStateFromProps(t,e){return e.location!==t.location||e.revalidation!=="idle"&&t.revalidation==="idle"?{error:t.error,location:t.location,revalidation:t.revalidation}:{error:t.error!==void 0?t.error:e.error,location:e.location,revalidation:t.revalidation||e.revalidation}}componentDidCatch(t,e){this.props.onError?this.props.onError(t,e):console.error("React Router caught the following error during render",t)}render(){let t=this.state.error;if(this.context&&typeof t=="object"&&t&&"digest"in t&&typeof t.digest=="string"){const n=oM(t.digest);n&&(t=n)}let e=t!==void 0?x.createElement(ls.Provider,{value:this.props.routeContext},x.createElement(my.Provider,{value:t,children:this.props.component})):this.props.children;return this.context?x.createElement(gM,{error:t},e):e}};cN.contextType=iN;var Lg=new WeakMap;function gM({children:t,error:e}){let{basename:n}=x.useContext(Ii);if(typeof e=="object"&&e&&"digest"in e&&typeof e.digest=="string"){let r=aM(e.digest);if(r){let i=Lg.get(e);if(i)throw i;let s=qT(r.location,n);if(HT&&!Lg.get(e))if(s.isExternal||r.reloadDocument)window.location.href=s.absoluteURL||s.to;else{const a=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(s.to,{replace:r.replace}));throw Lg.set(e,a),a}return x.createElement("meta",{httpEquiv:"refresh",content:`0;url=${s.absoluteURL||s.to}`})}}return t}function vM({routeContext:t,match:e,children:n}){let r=x.useContext(vl);return r&&r.static&&r.staticContext&&(e.route.errorElement||e.route.ErrorBoundary)&&(r.staticContext._deepestRenderedBoundaryId=e.route.id),x.createElement(ls.Provider,{value:t},n)}function yM(t,e=[],n=null,r=null,i=null){if(t==null){if(!n)return null;if(n.errors)t=n.matches;else if(e.length===0&&!n.initialized&&n.matches.length>0)t=n.matches;else return null}let s=t,a=n==null?void 0:n.errors;if(a!=null){let f=s.findIndex(p=>p.route.id&&(a==null?void 0:a[p.route.id])!==void 0);At(f>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(a).join(",")}`),s=s.slice(0,Math.min(s.length,f+1))}let c=!1,h=-1;if(n)for(let f=0;f<s.length;f++){let p=s[f];if((p.route.HydrateFallback||p.route.hydrateFallbackElement)&&(h=f),p.route.id){let{loaderData:g,errors:v}=n,k=p.route.loader&&!g.hasOwnProperty(p.route.id)&&(!v||v[p.route.id]===void 0);if(p.route.lazy||k){c=!0,h>=0?s=s.slice(0,h+1):s=[s[0]];break}}}let d=n&&r?(f,p)=>{var g,v;r(f,{location:n.location,params:((v=(g=n.matches)==null?void 0:g[0])==null?void 0:v.params)??{},unstable_pattern:xd(n.matches),errorInfo:p})}:void 0;return s.reduceRight((f,p,g)=>{let v,k=!1,w=null,S=null;n&&(v=a&&p.route.id?a[p.route.id]:void 0,w=p.route.errorElement||mM,c&&(h<0&&g===0?(uN("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),k=!0,S=null):h===g&&(k=!0,S=p.route.hydrateFallbackElement||null)));let T=e.concat(s.slice(0,g+1)),C=()=>{let j;return v?j=w:k?j=S:p.route.Component?j=x.createElement(p.route.Component,null):p.route.element?j=p.route.element:j=f,x.createElement(vM,{match:p,routeContext:{outlet:f,matches:T,isDataRoute:n!=null},children:j})};return n&&(p.route.ErrorBoundary||p.route.errorElement||g===0)?x.createElement(cN,{location:n.location,revalidation:n.revalidation,component:w,error:v,children:C(),routeContext:{outlet:null,matches:T,isDataRoute:!0},onError:d}):C()},null)}function gy(t){return`${t} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function xM(t){let e=x.useContext(vl);return At(e,gy(t)),e}function bM(t){let e=x.useContext(bd);return At(e,gy(t)),e}function kM(t){let e=x.useContext(ls);return At(e,gy(t)),e}function vy(t){let e=kM(t),n=e.matches[e.matches.length-1];return At(n.route.id,`${t} can only be used on routes that contain a unique "id"`),n.route.id}function wM(){return vy("useRouteId")}function SM(){var r;let t=x.useContext(my),e=bM("useRouteError"),n=vy("useRouteError");return t!==void 0?t:(r=e.errors)==null?void 0:r[n]}function CM(){let{router:t}=xM("useNavigate"),e=vy("useNavigate"),n=x.useRef(!1);return lN(()=>{n.current=!0}),x.useCallback(async(i,s={})=>{Zn(n.current,oN),n.current&&(typeof i=="number"?await t.navigate(i):await t.navigate(i,{fromRouteId:e,...s}))},[t,e])}var u1={};function uN(t,e,n){!e&&!u1[t]&&(u1[t]=!0,Zn(!1,n))}var d1={};function h1(t,e){!t&&!d1[e]&&(d1[e]=!0,console.warn(e))}var TM="useOptimistic",f1=FT[TM],NM=()=>{};function EM(t){return f1?f1(t):[t,NM]}function jM(t){let e={hasErrorBoundary:t.hasErrorBoundary||t.ErrorBoundary!=null||t.errorElement!=null};return t.Component&&(t.element&&Zn(!1,"You should not include both `Component` and `element` on your route - `Component` will be used."),Object.assign(e,{element:x.createElement(t.Component),Component:void 0})),t.HydrateFallback&&(t.hydrateFallbackElement&&Zn(!1,"You should not include both `HydrateFallback` and `hydrateFallbackElement` on your route - `HydrateFallback` will be used."),Object.assign(e,{hydrateFallbackElement:x.createElement(t.HydrateFallback),HydrateFallback:void 0})),t.ErrorBoundary&&(t.errorElement&&Zn(!1,"You should not include both `ErrorBoundary` and `errorElement` on your route - `ErrorBoundary` will be used."),Object.assign(e,{errorElement:x.createElement(t.ErrorBoundary),ErrorBoundary:void 0})),e}var PM=["HydrateFallback","hydrateFallbackElement"],_M=class{constructor(){this.status="pending",this.promise=new Promise((t,e)=>{this.resolve=n=>{this.status==="pending"&&(this.status="resolved",t(n))},this.reject=n=>{this.status==="pending"&&(this.status="rejected",e(n))}})}};function RM({router:t,flushSync:e,onError:n,unstable_useTransitions:r}){r=nM()||r;let[s,a]=x.useState(t.state),[c,h]=EM(s),[d,f]=x.useState(),[p,g]=x.useState({isTransitioning:!1}),[v,k]=x.useState(),[w,S]=x.useState(),[T,C]=x.useState(),j=x.useRef(new Map),R=x.useCallback((L,{deletedFetchers:$,newErrors:E,flushSync:P,viewTransitionOpts:V})=>{E&&n&&Object.values(E).forEach(K=>{var J;return n(K,{location:L.location,params:((J=L.matches[0])==null?void 0:J.params)??{},unstable_pattern:xd(L.matches)})}),L.fetchers.forEach((K,J)=>{K.data!==void 0&&j.current.set(J,K.data)}),$.forEach(K=>j.current.delete(K)),h1(P===!1||e!=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 F=t.window!=null&&t.window.document!=null&&typeof t.window.document.startViewTransition=="function";if(h1(V==null||F,"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."),!V||!F){e&&P?e(()=>a(L)):r===!1?a(L):x.startTransition(()=>{r===!0&&h(K=>p1(K,L)),a(L)});return}if(e&&P){e(()=>{w&&(v==null||v.resolve(),w.skipTransition()),g({isTransitioning:!0,flushSync:!0,currentLocation:V.currentLocation,nextLocation:V.nextLocation})});let K=t.window.document.startViewTransition(()=>{e(()=>a(L))});K.finished.finally(()=>{e(()=>{k(void 0),S(void 0),f(void 0),g({isTransitioning:!1})})}),e(()=>S(K));return}w?(v==null||v.resolve(),w.skipTransition(),C({state:L,currentLocation:V.currentLocation,nextLocation:V.nextLocation})):(f(L),g({isTransitioning:!0,flushSync:!1,currentLocation:V.currentLocation,nextLocation:V.nextLocation}))},[t.window,e,w,v,r,h,n]);x.useLayoutEffect(()=>t.subscribe(R),[t,R]),x.useEffect(()=>{p.isTransitioning&&!p.flushSync&&k(new _M)},[p]),x.useEffect(()=>{if(v&&d&&t.window){let L=d,$=v.promise,E=t.window.document.startViewTransition(async()=>{r===!1?a(L):x.startTransition(()=>{r===!0&&h(P=>p1(P,L)),a(L)}),await $});E.finished.finally(()=>{k(void 0),S(void 0),f(void 0),g({isTransitioning:!1})}),S(E)}},[d,v,t.window,r,h]),x.useEffect(()=>{v&&d&&c.location.key===d.location.key&&v.resolve()},[v,w,c.location,d]),x.useEffect(()=>{!p.isTransitioning&&T&&(f(T.state),g({isTransitioning:!0,flushSync:!1,currentLocation:T.currentLocation,nextLocation:T.nextLocation}),C(void 0))},[p.isTransitioning,T]);let _=x.useMemo(()=>({createHref:t.createHref,encodeLocation:t.encodeLocation,go:L=>t.navigate(L),push:(L,$,E)=>t.navigate(L,{state:$,preventScrollReset:E==null?void 0:E.preventScrollReset}),replace:(L,$,E)=>t.navigate(L,{replace:!0,state:$,preventScrollReset:E==null?void 0:E.preventScrollReset})}),[t]),I=t.basename||"/",M=x.useMemo(()=>({router:t,navigator:_,static:!1,basename:I,onError:n}),[t,_,I,n]);return x.createElement(x.Fragment,null,x.createElement(vl.Provider,{value:M},x.createElement(bd.Provider,{value:c},x.createElement(sN.Provider,{value:j.current},x.createElement(py.Provider,{value:p},x.createElement(AM,{basename:I,location:c.location,navigationType:c.historyAction,navigator:_,unstable_useTransitions:r},x.createElement(IM,{routes:t.routes,future:t.future,state:c,onError:n})))))),null)}function p1(t,e){return{...t,navigation:e.navigation.state!=="idle"?e.navigation:t.navigation,revalidation:e.revalidation!=="idle"?e.revalidation:t.revalidation,actionData:e.navigation.state!=="submitting"?e.actionData:t.actionData,fetchers:e.fetchers}}var IM=x.memo(MM);function MM({routes:t,future:e,state:n,onError:r}){return fM(t,void 0,n,r,e)}function DM(t){return dM(t.context)}function AM({basename:t="/",children:e=null,location:n,navigationType:r="POP",navigator:i,static:s=!1,unstable_useTransitions:a}){At(!kd(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let c=t.replace(/^\/*/,"/"),h=x.useMemo(()=>({basename:c,navigator:i,static:s,unstable_useTransitions:a,future:{}}),[c,i,s,a]);typeof n=="string"&&(n=ho(n));let{pathname:d="/",search:f="",hash:p="",state:g=null,key:v="default"}=n,k=x.useMemo(()=>{let w=Ri(d,c);return w==null?null:{location:{pathname:w,search:f,hash:p,state:g,key:v},navigationType:r}},[c,d,f,p,g,v,r]);return Zn(k!=null,`<Router basename="${c}"> is not able to match the URL "${d}${f}${p}" because it does not start with the basename, so the <Router> won't render anything.`),k==null?null:x.createElement(Ii.Provider,{value:h},x.createElement(dp.Provider,{children:e,value:k}))}var lf="get",cf="application/x-www-form-urlencoded";function hp(t){return typeof HTMLElement<"u"&&t instanceof HTMLElement}function OM(t){return hp(t)&&t.tagName.toLowerCase()==="button"}function LM(t){return hp(t)&&t.tagName.toLowerCase()==="form"}function FM(t){return hp(t)&&t.tagName.toLowerCase()==="input"}function UM(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}function BM(t,e){return t.button===0&&(!e||e==="_self")&&!UM(t)}var Fh=null;function zM(){if(Fh===null)try{new FormData(document.createElement("form"),0),Fh=!1}catch{Fh=!0}return Fh}var $M=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function Fg(t){return t!=null&&!$M.has(t)?(Zn(!1,`"${t}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${cf}"`),null):t}function VM(t,e){let n,r,i,s,a;if(LM(t)){let c=t.getAttribute("action");r=c?Ri(c,e):null,n=t.getAttribute("method")||lf,i=Fg(t.getAttribute("enctype"))||cf,s=new FormData(t)}else if(OM(t)||FM(t)&&(t.type==="submit"||t.type==="image")){let c=t.form;if(c==null)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let h=t.getAttribute("formaction")||c.getAttribute("action");if(r=h?Ri(h,e):null,n=t.getAttribute("formmethod")||c.getAttribute("method")||lf,i=Fg(t.getAttribute("formenctype"))||Fg(c.getAttribute("enctype"))||cf,s=new FormData(c,t),!zM()){let{name:d,type:f,value:p}=t;if(f==="image"){let g=d?`${d}.`:"";s.append(`${g}x`,"0"),s.append(`${g}y`,"0")}else d&&s.append(d,p)}}else{if(hp(t))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');n=lf,r=null,i=cf,a=t}return s&&i==="text/plain"&&(a=s,s=void 0),{action:r,method:n.toLowerCase(),encType:i,formData:s,body:a}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function yy(t,e){if(t===!1||t===null||typeof t>"u")throw new Error(e)}function WM(t,e,n,r){let i=typeof t=="string"?new URL(t,typeof window>"u"?"server://singlefetch/":window.location.origin):t;return n?i.pathname.endsWith("/")?i.pathname=`${i.pathname}_.${r}`:i.pathname=`${i.pathname}.${r}`:i.pathname==="/"?i.pathname=`_root.${r}`:e&&Ri(i.pathname,e)==="/"?i.pathname=`${e.replace(/\/$/,"")}/_root.${r}`:i.pathname=`${i.pathname.replace(/\/$/,"")}.${r}`,i}async function HM(t,e){if(t.id in e)return e[t.id];try{let n=await import(t.module);return e[t.id]=n,n}catch(n){return console.error(`Error loading route module \`${t.module}\`, reloading page...`),console.error(n),window.__reactRouterContext&&window.__reactRouterContext.isSpaMode,window.location.reload(),new Promise(()=>{})}}function qM(t){return t==null?!1:t.href==null?t.rel==="preload"&&typeof t.imageSrcSet=="string"&&typeof t.imageSizes=="string":typeof t.rel=="string"&&typeof t.href=="string"}async function KM(t,e,n){let r=await Promise.all(t.map(async i=>{let s=e.routes[i.route.id];if(s){let a=await HM(s,n);return a.links?a.links():[]}return[]}));return XM(r.flat(1).filter(qM).filter(i=>i.rel==="stylesheet"||i.rel==="preload").map(i=>i.rel==="stylesheet"?{...i,rel:"prefetch",as:"style"}:{...i,rel:"prefetch"}))}function m1(t,e,n,r,i,s){let a=(h,d)=>n[d]?h.route.id!==n[d].route.id:!0,c=(h,d)=>{var f;return n[d].pathname!==h.pathname||((f=n[d].route.path)==null?void 0:f.endsWith("*"))&&n[d].params["*"]!==h.params["*"]};return s==="assets"?e.filter((h,d)=>a(h,d)||c(h,d)):s==="data"?e.filter((h,d)=>{var p;let f=r.routes[h.route.id];if(!f||!f.hasLoader)return!1;if(a(h,d)||c(h,d))return!0;if(h.route.shouldRevalidate){let g=h.route.shouldRevalidate({currentUrl:new URL(i.pathname+i.search+i.hash,window.origin),currentParams:((p=n[0])==null?void 0:p.params)||{},nextUrl:new URL(t,window.origin),nextParams:h.params,defaultShouldRevalidate:!0});if(typeof g=="boolean")return g}return!0}):[]}function GM(t,e,{includeHydrateFallback:n}={}){return YM(t.map(r=>{let i=e.routes[r.route.id];if(!i)return[];let s=[i.module];return i.clientActionModule&&(s=s.concat(i.clientActionModule)),i.clientLoaderModule&&(s=s.concat(i.clientLoaderModule)),n&&i.hydrateFallbackModule&&(s=s.concat(i.hydrateFallbackModule)),i.imports&&(s=s.concat(i.imports)),s}).flat(1))}function YM(t){return[...new Set(t)]}function JM(t){let e={},n=Object.keys(t).sort();for(let r of n)e[r]=t[r];return e}function XM(t,e){let n=new Set;return new Set(e),t.reduce((r,i)=>{let s=JSON.stringify(JM(i));return n.has(s)||(n.add(s),r.push({key:s,link:i})),r},[])}function dN(){let t=x.useContext(vl);return yy(t,"You must render this element inside a <DataRouterContext.Provider> element"),t}function QM(){let t=x.useContext(bd);return yy(t,"You must render this element inside a <DataRouterStateContext.Provider> element"),t}var xy=x.createContext(void 0);xy.displayName="FrameworkContext";function hN(){let t=x.useContext(xy);return yy(t,"You must render this element inside a <HydratedRouter> element"),t}function ZM(t,e){let n=x.useContext(xy),[r,i]=x.useState(!1),[s,a]=x.useState(!1),{onFocus:c,onBlur:h,onMouseEnter:d,onMouseLeave:f,onTouchStart:p}=e,g=x.useRef(null);x.useEffect(()=>{if(t==="render"&&a(!0),t==="viewport"){let w=T=>{T.forEach(C=>{a(C.isIntersecting)})},S=new IntersectionObserver(w,{threshold:.5});return g.current&&S.observe(g.current),()=>{S.disconnect()}}},[t]),x.useEffect(()=>{if(r){let w=setTimeout(()=>{a(!0)},100);return()=>{clearTimeout(w)}}},[r]);let v=()=>{i(!0)},k=()=>{i(!1),a(!1)};return n?t!=="intent"?[s,g,{}]:[s,g,{onFocus:yu(c,v),onBlur:yu(h,k),onMouseEnter:yu(d,v),onMouseLeave:yu(f,k),onTouchStart:yu(p,v)}]:[!1,g,{}]}function yu(t,e){return n=>{t&&t(n),n.defaultPrevented||e(n)}}function e3({page:t,...e}){let{router:n}=dN(),r=x.useMemo(()=>Ga(n.routes,t,n.basename),[n.routes,t,n.basename]);return r?x.createElement(n3,{page:t,matches:r,...e}):null}function t3(t){let{manifest:e,routeModules:n}=hN(),[r,i]=x.useState([]);return x.useEffect(()=>{let s=!1;return KM(t,e,n).then(a=>{s||i(a)}),()=>{s=!0}},[t,e,n]),r}function n3({page:t,matches:e,...n}){let r=ma(),{future:i,manifest:s,routeModules:a}=hN(),{basename:c}=dN(),{loaderData:h,matches:d}=QM(),f=x.useMemo(()=>m1(t,e,d,s,r,"data"),[t,e,d,s,r]),p=x.useMemo(()=>m1(t,e,d,s,r,"assets"),[t,e,d,s,r]),g=x.useMemo(()=>{if(t===r.pathname+r.search+r.hash)return[];let w=new Set,S=!1;if(e.forEach(C=>{var R;let j=s.routes[C.route.id];!j||!j.hasLoader||(!f.some(_=>_.route.id===C.route.id)&&C.route.id in h&&((R=a[C.route.id])!=null&&R.shouldRevalidate)||j.hasClientLoader?S=!0:w.add(C.route.id))}),w.size===0)return[];let T=WM(t,c,i.unstable_trailingSlashAwareDataRequests,"data");return S&&w.size>0&&T.searchParams.set("_routes",e.filter(C=>w.has(C.route.id)).map(C=>C.route.id).join(",")),[T.pathname+T.search]},[c,i.unstable_trailingSlashAwareDataRequests,h,r,s,f,e,t,a]),v=x.useMemo(()=>GM(p,s),[p,s]),k=t3(p);return x.createElement(x.Fragment,null,g.map(w=>x.createElement("link",{key:w,rel:"prefetch",as:"fetch",href:w,...n})),v.map(w=>x.createElement("link",{key:w,rel:"modulepreload",href:w,...n})),k.map(({key:w,link:S})=>x.createElement("link",{key:w,nonce:n.nonce,...S,crossOrigin:S.crossOrigin??n.crossOrigin})))}function r3(...t){return e=>{t.forEach(n=>{typeof n=="function"?n(e):n!=null&&(n.current=e)})}}var i3=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{i3&&(window.__reactRouterVersion="7.13.0")}catch{}function s3(t,e){return R5({basename:e==null?void 0:e.basename,getContext:e==null?void 0:e.getContext,future:e==null?void 0:e.future,history:KI({window:e==null?void 0:e.window}),hydrationData:a3(),routes:t,mapRouteProperties:jM,hydrationRouteProperties:PM,dataStrategy:e==null?void 0:e.dataStrategy,patchRoutesOnNavigation:e==null?void 0:e.patchRoutesOnNavigation,window:e==null?void 0:e.window,unstable_instrumentations:e==null?void 0:e.unstable_instrumentations}).initialize()}function a3(){let t=window==null?void 0:window.__staticRouterHydrationData;return t&&t.errors&&(t={...t,errors:o3(t.errors)}),t}function o3(t){if(!t)return null;let e=Object.entries(t),n={};for(let[r,i]of e)if(i&&i.__type==="RouteErrorResponse")n[r]=new yd(i.status,i.statusText,i.data,i.internal===!0);else if(i&&i.__type==="Error"){if(i.__subType){let s=window[i.__subType];if(typeof s=="function")try{let a=new s(i.message);a.stack="",n[r]=a}catch{}}if(n[r]==null){let s=new Error(i.message);s.stack="",n[r]=s}}else n[r]=i;return n}var fN=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,al=x.forwardRef(function({onClick:e,discover:n="render",prefetch:r="none",relative:i,reloadDocument:s,replace:a,state:c,target:h,to:d,preventScrollReset:f,viewTransition:p,unstable_defaultShouldRevalidate:g,...v},k){let{basename:w,unstable_useTransitions:S}=x.useContext(Ii),T=typeof d=="string"&&fN.test(d),C=qT(d,w);d=C.to;let j=lM(d,{relative:i}),[R,_,I]=ZM(r,v),M=d3(d,{replace:a,state:c,target:h,preventScrollReset:f,relative:i,viewTransition:p,unstable_defaultShouldRevalidate:g,unstable_useTransitions:S});function L(E){e&&e(E),E.defaultPrevented||M(E)}let $=x.createElement("a",{...v,...I,href:C.absoluteURL||j,onClick:C.isExternal||s?e:L,ref:r3(k,_),target:h,"data-discover":!T&&n==="render"?"true":void 0});return R&&!T?x.createElement(x.Fragment,null,$,x.createElement(e3,{page:j})):$});al.displayName="Link";var l3=x.forwardRef(function({"aria-current":e="page",caseSensitive:n=!1,className:r="",end:i=!1,style:s,to:a,viewTransition:c,children:h,...d},f){let p=wd(a,{relative:d.relative}),g=ma(),v=x.useContext(bd),{navigator:k,basename:w}=x.useContext(Ii),S=v!=null&&g3(p)&&c===!0,T=k.encodeLocation?k.encodeLocation(p).pathname:p.pathname,C=g.pathname,j=v&&v.navigation&&v.navigation.location?v.navigation.location.pathname:null;n||(C=C.toLowerCase(),j=j?j.toLowerCase():null,T=T.toLowerCase()),j&&w&&(j=Ri(j,w)||j);const R=T!=="/"&&T.endsWith("/")?T.length-1:T.length;let _=C===T||!i&&C.startsWith(T)&&C.charAt(R)==="/",I=j!=null&&(j===T||!i&&j.startsWith(T)&&j.charAt(T.length)==="/"),M={isActive:_,isPending:I,isTransitioning:S},L=_?e:void 0,$;typeof r=="function"?$=r(M):$=[r,_?"active":null,I?"pending":null,S?"transitioning":null].filter(Boolean).join(" ");let E=typeof s=="function"?s(M):s;return x.createElement(al,{...d,"aria-current":L,className:$,ref:f,style:E,to:a,viewTransition:c},typeof h=="function"?h(M):h)});l3.displayName="NavLink";var c3=x.forwardRef(({discover:t="render",fetcherKey:e,navigate:n,reloadDocument:r,replace:i,state:s,method:a=lf,action:c,onSubmit:h,relative:d,preventScrollReset:f,viewTransition:p,unstable_defaultShouldRevalidate:g,...v},k)=>{let{unstable_useTransitions:w}=x.useContext(Ii),S=p3(),T=m3(c,{relative:d}),C=a.toLowerCase()==="get"?"get":"post",j=typeof c=="string"&&fN.test(c),R=_=>{if(h&&h(_),_.defaultPrevented)return;_.preventDefault();let I=_.nativeEvent.submitter,M=(I==null?void 0:I.getAttribute("formmethod"))||a,L=()=>S(I||_.currentTarget,{fetcherKey:e,method:M,navigate:n,replace:i,state:s,relative:d,preventScrollReset:f,viewTransition:p,unstable_defaultShouldRevalidate:g});w&&n!==!1?x.startTransition(()=>L()):L()};return x.createElement("form",{ref:k,method:C,action:T,onSubmit:r?h:R,...v,"data-discover":!j&&t==="render"?"true":void 0})});c3.displayName="Form";function u3(t){return`${t} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function pN(t){let e=x.useContext(vl);return At(e,u3(t)),e}function d3(t,{target:e,replace:n,state:r,preventScrollReset:i,relative:s,viewTransition:a,unstable_defaultShouldRevalidate:c,unstable_useTransitions:h}={}){let d=Pc(),f=ma(),p=wd(t,{relative:s});return x.useCallback(g=>{if(BM(g,e)){g.preventDefault();let v=n!==void 0?n:Es(f)===Es(p),k=()=>d(t,{replace:v,state:r,preventScrollReset:i,relative:s,viewTransition:a,unstable_defaultShouldRevalidate:c});h?x.startTransition(()=>k()):k()}},[f,d,p,n,r,e,t,i,s,a,c,h])}var h3=0,f3=()=>`__${String(++h3)}__`;function p3(){let{router:t}=pN("useSubmit"),{basename:e}=x.useContext(Ii),n=wM(),r=t.fetch,i=t.navigate;return x.useCallback(async(s,a={})=>{let{action:c,method:h,encType:d,formData:f,body:p}=VM(s,e);if(a.navigate===!1){let g=a.fetcherKey||f3();await r(g,n,a.action||c,{unstable_defaultShouldRevalidate:a.unstable_defaultShouldRevalidate,preventScrollReset:a.preventScrollReset,formData:f,body:p,formMethod:a.method||h,formEncType:a.encType||d,flushSync:a.flushSync})}else await i(a.action||c,{unstable_defaultShouldRevalidate:a.unstable_defaultShouldRevalidate,preventScrollReset:a.preventScrollReset,formData:f,body:p,formMethod:a.method||h,formEncType:a.encType||d,replace:a.replace,state:a.state,fromRouteId:n,flushSync:a.flushSync,viewTransition:a.viewTransition})},[r,i,e,n])}function m3(t,{relative:e}={}){let{basename:n}=x.useContext(Ii),r=x.useContext(ls);At(r,"useFormAction must be used inside a RouteContext");let[i]=r.matches.slice(-1),s={...wd(t||".",{relative:e})},a=ma();if(t==null){s.search=a.search;let c=new URLSearchParams(s.search),h=c.getAll("index");if(h.some(f=>f==="")){c.delete("index"),h.filter(p=>p).forEach(p=>c.append("index",p));let f=c.toString();s.search=f?`?${f}`:""}}return(!t||t===".")&&i.route.index&&(s.search=s.search?s.search.replace(/^\?/,"?index&"):"?index"),n!=="/"&&(s.pathname=s.pathname==="/"?n:ws([n,s.pathname])),Es(s)}function g3(t,{relative:e}={}){let n=x.useContext(py);At(n!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:r}=pN("useViewTransitionState"),i=wd(t,{relative:e});if(!n.isTransitioning)return!1;let s=Ri(n.currentLocation.pathname,r)||n.currentLocation.pathname,a=Ri(n.nextLocation.pathname,r)||n.nextLocation.pathname;return _f(i.pathname,a)!=null||_f(i.pathname,s)!=null}function mN(){return window.__DAEMORA_API_BASE??""}function v3(){const t=document.querySelector('meta[name="api-token"]');return(t==null?void 0:t.getAttribute("content"))??null}function gN(t){const e=new Headers(t==null?void 0:t.headers),n=v3();return n&&!e.has("X-Auth-Token")&&e.set("X-Auth-Token",n),t!=null&&t.body&&typeof t.body=="string"&&!e.has("Content-Type")&&e.set("Content-Type","application/json"),e}async function g1(t){const e=await fetch(`${mN()}/auth/login`,{method:"POST",credentials:"include",headers:gN({body:"{}"}),body:JSON.stringify({passphrase:t})});if(!e.ok){const n=await x3(e);throw new y3((n==null?void 0:n.code)??"login_failed",(n==null?void 0:n.error)??`HTTP ${e.status}`)}try{sessionStorage.setItem("daemora_vault_pass",t)}catch{}return vN()}async function vN(){const t=await fetch(`${mN()}/auth/session`,{credentials:"include",headers:gN()});return t.ok?t.json():null}class y3 extends Error{constructor(e,n){super(n),this.code=e,this.name="LoginError"}}async function x3(t){try{return await t.json()}catch{return null}}function b3({children:t}){const e=Pc(),[n,r]=x.useState("loading"),[i,s]=x.useState(""),[a,c]=x.useState(null),[h,d]=x.useState(!1),f=async()=>{const g=await vN().catch(()=>null);if(!g){r("error");return}if(!g.exists){e("/setup",{replace:!0});return}if(g.unlocked){r("ok");return}const v=(()=>{try{return sessionStorage.getItem("daemora_vault_pass")}catch{return null}})();if(v)try{const k=await g1(v);if(k!=null&&k.unlocked){r("ok");return}}catch{}r("locked")};x.useEffect(()=>{f()},[]);const p=async g=>{if(g.preventDefault(),!!i){d(!0),c(null);try{(await g1(i)).unlocked?(s(""),r("ok")):c("Vault did not unlock.")}catch(v){c(v.message||"Unlock failed")}finally{d(!1)}}};return n==="loading"?o.jsx("div",{className:"min-h-screen flex items-center justify-center text-[10px] text-gray-600 font-mono uppercase tracking-widest",children:"Loading…"}):n==="locked"?o.jsx("div",{className:"min-h-screen flex items-center justify-center bg-slate-950 px-4",children:o.jsxs("div",{className:"w-full max-w-sm rounded-xl border border-slate-800/70 bg-slate-900/60 p-6 font-mono",children:[o.jsx("h2",{className:"text-sm font-semibold text-white mb-1",children:"Vault locked"}),o.jsx("p",{className:"text-[11px] text-gray-500 mb-4 leading-relaxed",children:"Enter your vault passphrase. It stays unlocked in memory until the Daemora server stops."}),o.jsxs("form",{onSubmit:p,className:"space-y-3",children:[o.jsx("input",{type:"password",autoFocus:!0,value:i,onChange:g=>s(g.target.value),placeholder:"passphrase",className:"w-full px-3 py-2 text-[13px] rounded bg-slate-950/60 border border-slate-800/80 text-white focus:outline-none focus:border-[#00d9ff]/50"}),a&&o.jsx("div",{className:"text-[11px] text-red-400",children:a}),o.jsx("button",{type:"submit",disabled:h||!i,className:"w-full px-3 py-2 text-[11px] uppercase tracking-widest rounded bg-[#00d9ff]/10 border border-[#00d9ff]/40 text-[#00d9ff] hover:bg-[#00d9ff]/20 disabled:opacity-40",children:h?"Unlocking…":"Unlock"})]})]})}):n==="error"?o.jsx("div",{className:"min-h-screen flex items-center justify-center text-[10px] text-red-400 font-mono uppercase tracking-widest",children:"Server unreachable. Check the Daemora process."}):o.jsx(o.Fragment,{children:t})}window.__TAURI_INTERNALS__&&(window.__TAURI__=!0),window.__TAURI__?{}:null;function k3(){return window.__DAEMORA_API_BASE||""}function uf(t){const e=k3();return!e||t.startsWith("http://")||t.startsWith("https://")?t:`${e}${t}`}function yN(){const t=document.querySelector('meta[name="api-token"]');return(t==null?void 0:t.getAttribute("content"))||""}async function we(t,e){const n=yN(),r=new Headers(e==null?void 0:e.headers);n&&!r.has("Authorization")&&!r.has("X-Auth-Token")&&r.set("X-Auth-Token",n),e!=null&&e.body&&typeof e.body=="string"&&!r.has("Content-Type")&&r.set("Content-Type","application/json");const i=await fetch(uf(t),{...e,headers:r,credentials:"include"});if(!i.ok){const s=sessionStorage.getItem("daemora_vault_pass");if(s){const a=await i.clone().text();if(/vault\s*is\s*locked/i.test(a)&&(await fetch(uf("/auth/login"),{method:"POST",headers:{"Content-Type":"application/json",...n?{"X-Auth-Token":n}:{}},credentials:"include",body:JSON.stringify({passphrase:s})})).ok)return fetch(uf(t),{...e,headers:r,credentials:"include"})}}return i}async function w3(t){const e=await we(t);if(!e.ok)throw new Error(`API error ${e.status}: ${await e.text()}`);return e.json()}async function S3(t,e,n){const r=await we(t,{method:e,body:n!==void 0?JSON.stringify(n):void 0});if(!r.ok)throw new Error(`API error ${r.status}: ${await r.text()}`);return r.json()}function X0(t){const e=uf(t),n=yN(),r=e.includes("?")?"&":"?";return n?`${e}${r}token=${n}`:e}function C3(){const t=x.useRef(null);return x.useEffect(()=>{const e=t.current;if(!e)return;const n=e.getContext("2d");if(!n)return;const r=()=>{e.width=window.innerWidth,e.height=window.innerHeight};r(),window.addEventListener("resize",r);const i=[],s=200;for(let h=0;h<s;h++)i.push({x:Math.random()*e.width,y:Math.random()*e.height,radius:Math.random()*1.5,opacity:Math.random()*.5+.3});let a;const c=()=>{n.clearRect(0,0,e.width,e.height),i.forEach(h=>{n.beginPath(),n.arc(h.x,h.y,h.radius,0,Math.PI*2),n.fillStyle=`rgba(255, 255, 255, ${h.opacity})`,n.fill(),h.opacity+=(Math.random()-.5)*.02,h.opacity=Math.max(.2,Math.min(.8,h.opacity))}),a=requestAnimationFrame(c)};return c(),()=>{window.removeEventListener("resize",r),cancelAnimationFrame(a)}},[]),o.jsx("canvas",{ref:t,className:"fixed inset-0 pointer-events-none z-0",style:{opacity:.4}})}function Xo({className:t="",size:e=40}){return o.jsxs("svg",{width:e,height:e,viewBox:"0 0 100 100",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:t,children:[o.jsxs("defs",{children:[o.jsxs("radialGradient",{id:"d-eye",cx:"50%",cy:"50%",r:"50%",children:[o.jsx("stop",{offset:"0%",stopColor:"#ff6a00"}),o.jsx("stop",{offset:"40%",stopColor:"#ff4458"}),o.jsx("stop",{offset:"100%",stopColor:"#aa1122",stopOpacity:"0.6"})]}),o.jsxs("radialGradient",{id:"d-eyeglow",cx:"50%",cy:"50%",r:"50%",children:[o.jsx("stop",{offset:"0%",stopColor:"#ff4458",stopOpacity:"0.6"}),o.jsx("stop",{offset:"100%",stopColor:"#ff4458",stopOpacity:"0"})]}),o.jsxs("linearGradient",{id:"d-body",x1:"50",y1:"2",x2:"50",y2:"98",gradientUnits:"userSpaceOnUse",children:[o.jsx("stop",{offset:"0%",stopColor:"#1a0812"}),o.jsx("stop",{offset:"100%",stopColor:"#060308"})]}),o.jsxs("linearGradient",{id:"d-stroke",x1:"0",y1:"0",x2:"100",y2:"100",gradientUnits:"userSpaceOnUse",children:[o.jsx("stop",{offset:"0%",stopColor:"#ff4458"}),o.jsx("stop",{offset:"55%",stopColor:"#00d9ff"}),o.jsx("stop",{offset:"100%",stopColor:"#ff4458"})]}),o.jsxs("filter",{id:"d-bloom",x:"-60%",y:"-60%",width:"220%",height:"220%",children:[o.jsx("feGaussianBlur",{stdDeviation:"4",result:"blur"}),o.jsxs("feMerge",{children:[o.jsx("feMergeNode",{in:"blur"}),o.jsx("feMergeNode",{in:"SourceGraphic"})]})]}),o.jsxs("filter",{id:"d-edge",x:"-20%",y:"-20%",width:"140%",height:"140%",children:[o.jsx("feGaussianBlur",{stdDeviation:"1.5",result:"blur"}),o.jsxs("feMerge",{children:[o.jsx("feMergeNode",{in:"blur"}),o.jsx("feMergeNode",{in:"SourceGraphic"})]})]})]}),o.jsx("polygon",{points:"30,28 22,6 38,22",fill:"#ff4458",opacity:"0.85",filter:"url(#d-edge)"}),o.jsx("polygon",{points:"30,28 22,6 38,22",fill:"none",stroke:"#ff4458",strokeWidth:"0.5",strokeOpacity:"0.5"}),o.jsx("polygon",{points:"70,28 78,6 62,22",fill:"#ff4458",opacity:"0.85",filter:"url(#d-edge)"}),o.jsx("polygon",{points:"70,28 78,6 62,22",fill:"none",stroke:"#ff4458",strokeWidth:"0.5",strokeOpacity:"0.5"}),o.jsx("polygon",{points:"30,28 70,28 84,40 88,60 76,80 62,92 50,96 38,92 24,80 12,60 16,40",fill:"url(#d-body)",stroke:"url(#d-stroke)",strokeWidth:"1.8",filter:"url(#d-edge)"}),o.jsx("polygon",{points:"33,33 67,33 79,43 82,61 72,78 61,88 50,91 39,88 28,78 18,61 21,43",fill:"none",stroke:"#ff4458",strokeWidth:"0.5",strokeOpacity:"0.18"}),o.jsx("line",{x1:"22",y1:"46",x2:"44",y2:"53",stroke:"#ff4458",strokeWidth:"2.5",strokeLinecap:"round"}),o.jsx("line",{x1:"78",y1:"46",x2:"56",y2:"53",stroke:"#ff4458",strokeWidth:"2.5",strokeLinecap:"round"}),o.jsx("line",{x1:"36",y1:"50",x2:"44",y2:"53",stroke:"#ff4458",strokeWidth:"1",strokeLinecap:"round",strokeOpacity:"0.5"}),o.jsx("line",{x1:"64",y1:"50",x2:"56",y2:"53",stroke:"#ff4458",strokeWidth:"1",strokeLinecap:"round",strokeOpacity:"0.5"}),o.jsx("ellipse",{cx:"50",cy:"62",rx:"26",ry:"12",fill:"url(#d-eyeglow)"}),o.jsx("ellipse",{cx:"50",cy:"62",rx:"22",ry:"11",fill:"#050208"}),o.jsx("ellipse",{cx:"50",cy:"62",rx:"22",ry:"11",fill:"none",stroke:"#ff4458",strokeWidth:"0.8",strokeOpacity:"0.4"}),o.jsx("ellipse",{cx:"50",cy:"62",rx:"14",ry:"8",fill:"url(#d-eye)",filter:"url(#d-bloom)"}),o.jsx("ellipse",{cx:"50",cy:"62",rx:"3.5",ry:"7.5",fill:"#000"}),o.jsx("ellipse",{cx:"46",cy:"58",rx:"2",ry:"1.2",fill:"white",fillOpacity:"0.35"}),o.jsxs("line",{x1:"28",y1:"62",x2:"72",y2:"62",stroke:"#ff6a00",strokeWidth:"0.7",strokeOpacity:"0.5",children:[o.jsx("animate",{attributeName:"y1",values:"54;70;54",dur:"2.2s",repeatCount:"indefinite"}),o.jsx("animate",{attributeName:"y2",values:"54;70;54",dur:"2.2s",repeatCount:"indefinite"}),o.jsx("animate",{attributeName:"stroke-opacity",values:"0.5;0;0.5",dur:"2.2s",repeatCount:"indefinite"})]}),o.jsx("line",{x1:"44",y1:"81",x2:"50",y2:"86",stroke:"#ff4458",strokeWidth:"1.2",strokeLinecap:"round",strokeOpacity:"0.55"}),o.jsx("line",{x1:"56",y1:"81",x2:"50",y2:"86",stroke:"#ff4458",strokeWidth:"1.2",strokeLinecap:"round",strokeOpacity:"0.55"}),o.jsx("circle",{cx:"20",cy:"60",r:"1.5",fill:"#00d9ff",opacity:"0.6"}),o.jsx("circle",{cx:"80",cy:"60",r:"1.5",fill:"#00d9ff",opacity:"0.6"}),o.jsx("line",{x1:"22",y1:"60",x2:"28",y2:"62",stroke:"#00d9ff",strokeWidth:"0.6",strokeOpacity:"0.35"}),o.jsx("line",{x1:"78",y1:"60",x2:"72",y2:"62",stroke:"#00d9ff",strokeWidth:"0.6",strokeOpacity:"0.35"}),o.jsx("circle",{cx:"22",cy:"6",r:"2",fill:"#ff4458",children:o.jsx("animate",{attributeName:"opacity",values:"0.5;1;0.5",dur:"1.8s",repeatCount:"indefinite"})}),o.jsx("circle",{cx:"78",cy:"6",r:"2",fill:"#ff4458",children:o.jsx("animate",{attributeName:"opacity",values:"0.5;1;0.5",dur:"1.8s",begin:"0.9s",repeatCount:"indefinite"})}),o.jsxs("ellipse",{cx:"50",cy:"62",rx:"14",ry:"8",fill:"none",stroke:"#ff4458",strokeWidth:"1.2",strokeOpacity:"0",children:[o.jsx("animate",{attributeName:"rx",values:"14;24;14",dur:"2.8s",repeatCount:"indefinite"}),o.jsx("animate",{attributeName:"ry",values:"8;14;8",dur:"2.8s",repeatCount:"indefinite"}),o.jsx("animate",{attributeName:"stroke-opacity",values:"0.5;0;0.5",dur:"2.8s",repeatCount:"indefinite"})]})]})}/**
53
+ * @license lucide-react v0.487.0 - ISC
54
+ *
55
+ * This source code is licensed under the ISC license.
56
+ * See the LICENSE file in the root directory of this source tree.
57
+ */const T3=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),N3=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,n,r)=>r?r.toUpperCase():n.toLowerCase()),v1=t=>{const e=N3(t);return e.charAt(0).toUpperCase()+e.slice(1)},xN=(...t)=>t.filter((e,n,r)=>!!e&&e.trim()!==""&&r.indexOf(e)===n).join(" ").trim();/**
58
+ * @license lucide-react v0.487.0 - ISC
59
+ *
60
+ * This source code is licensed under the ISC license.
61
+ * See the LICENSE file in the root directory of this source tree.
62
+ */var E3={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/**
63
+ * @license lucide-react v0.487.0 - ISC
64
+ *
65
+ * This source code is licensed under the ISC license.
66
+ * See the LICENSE file in the root directory of this source tree.
67
+ */const j3=x.forwardRef(({color:t="currentColor",size:e=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:i="",children:s,iconNode:a,...c},h)=>x.createElement("svg",{ref:h,...E3,width:e,height:e,stroke:t,strokeWidth:r?Number(n)*24/Number(e):n,className:xN("lucide",i),...c},[...a.map(([d,f])=>x.createElement(d,f)),...Array.isArray(s)?s:[s]]));/**
68
+ * @license lucide-react v0.487.0 - ISC
69
+ *
70
+ * This source code is licensed under the ISC license.
71
+ * See the LICENSE file in the root directory of this source tree.
72
+ */const $e=(t,e)=>{const n=x.forwardRef(({className:r,...i},s)=>x.createElement(j3,{ref:s,iconNode:e,className:xN(`lucide-${T3(v1(t))}`,`lucide-${t}`,r),...i}));return n.displayName=v1(t),n};/**
73
+ * @license lucide-react v0.487.0 - ISC
74
+ *
75
+ * This source code is licensed under the ISC license.
76
+ * See the LICENSE file in the root directory of this source tree.
77
+ */const P3=[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]],y1=$e("activity",P3);/**
78
+ * @license lucide-react v0.487.0 - ISC
79
+ *
80
+ * This source code is licensed under the ISC license.
81
+ * See the LICENSE file in the root directory of this source tree.
82
+ */const _3=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],R3=$e("arrow-left",_3);/**
83
+ * @license lucide-react v0.487.0 - ISC
84
+ *
85
+ * This source code is licensed under the ISC license.
86
+ * See the LICENSE file in the root directory of this source tree.
87
+ */const I3=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],M3=$e("arrow-up",I3);/**
88
+ * @license lucide-react v0.487.0 - ISC
89
+ *
90
+ * This source code is licensed under the ISC license.
91
+ * See the LICENSE file in the root directory of this source tree.
92
+ */const D3=[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]],td=$e("bot",D3);/**
93
+ * @license lucide-react v0.487.0 - ISC
94
+ *
95
+ * This source code is licensed under the ISC license.
96
+ * See the LICENSE file in the root directory of this source tree.
97
+ */const A3=[["path",{d:"M2.97 12.92A2 2 0 0 0 2 14.63v3.24a2 2 0 0 0 .97 1.71l3 1.8a2 2 0 0 0 2.06 0L12 19v-5.5l-5-3-4.03 2.42Z",key:"lc1i9w"}],["path",{d:"m7 16.5-4.74-2.85",key:"1o9zyk"}],["path",{d:"m7 16.5 5-3",key:"va8pkn"}],["path",{d:"M7 16.5v5.17",key:"jnp8gn"}],["path",{d:"M12 13.5V19l3.97 2.38a2 2 0 0 0 2.06 0l3-1.8a2 2 0 0 0 .97-1.71v-3.24a2 2 0 0 0-.97-1.71L17 10.5l-5 3Z",key:"8zsnat"}],["path",{d:"m17 16.5-5-3",key:"8arw3v"}],["path",{d:"m17 16.5 4.74-2.85",key:"8rfmw"}],["path",{d:"M17 16.5v5.17",key:"k6z78m"}],["path",{d:"M7.97 4.42A2 2 0 0 0 7 6.13v4.37l5 3 5-3V6.13a2 2 0 0 0-.97-1.71l-3-1.8a2 2 0 0 0-2.06 0l-3 1.8Z",key:"1xygjf"}],["path",{d:"M12 8 7.26 5.15",key:"1vbdud"}],["path",{d:"m12 8 4.74-2.85",key:"3rx089"}],["path",{d:"M12 13.5V8",key:"1io7kd"}]],O3=$e("boxes",A3);/**
98
+ * @license lucide-react v0.487.0 - ISC
99
+ *
100
+ * This source code is licensed under the ISC license.
101
+ * See the LICENSE file in the root directory of this source tree.
102
+ */const L3=[["path",{d:"M12 5a3 3 0 1 0-5.997.125 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18Z",key:"l5xja"}],["path",{d:"M12 5a3 3 0 1 1 5.997.125 4 4 0 0 1 2.526 5.77 4 4 0 0 1-.556 6.588A4 4 0 1 1 12 18Z",key:"ep3f8r"}],["path",{d:"M15 13a4.5 4.5 0 0 1-3-4 4.5 4.5 0 0 1-3 4",key:"1p4c4q"}],["path",{d:"M17.599 6.5a3 3 0 0 0 .399-1.375",key:"tmeiqw"}],["path",{d:"M6.003 5.125A3 3 0 0 0 6.401 6.5",key:"105sqy"}],["path",{d:"M3.477 10.896a4 4 0 0 1 .585-.396",key:"ql3yin"}],["path",{d:"M19.938 10.5a4 4 0 0 1 .585.396",key:"1qfode"}],["path",{d:"M6 18a4 4 0 0 1-1.967-.516",key:"2e4loj"}],["path",{d:"M19.967 17.484A4 4 0 0 1 18 18",key:"159ez6"}]],Q0=$e("brain",L3);/**
103
+ * @license lucide-react v0.487.0 - ISC
104
+ *
105
+ * This source code is licensed under the ISC license.
106
+ * See the LICENSE file in the root directory of this source tree.
107
+ */const F3=[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}]],x1=$e("calendar",F3);/**
108
+ * @license lucide-react v0.487.0 - ISC
109
+ *
110
+ * This source code is licensed under the ISC license.
111
+ * See the LICENSE file in the root directory of this source tree.
112
+ */const U3=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],nd=$e("check",U3);/**
113
+ * @license lucide-react v0.487.0 - ISC
114
+ *
115
+ * This source code is licensed under the ISC license.
116
+ * See the LICENSE file in the root directory of this source tree.
117
+ */const B3=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],fo=$e("chevron-down",B3);/**
118
+ * @license lucide-react v0.487.0 - ISC
119
+ *
120
+ * This source code is licensed under the ISC license.
121
+ * See the LICENSE file in the root directory of this source tree.
122
+ */const z3=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],bN=$e("chevron-left",z3);/**
123
+ * @license lucide-react v0.487.0 - ISC
124
+ *
125
+ * This source code is licensed under the ISC license.
126
+ * See the LICENSE file in the root directory of this source tree.
127
+ */const $3=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],fp=$e("chevron-right",$3);/**
128
+ * @license lucide-react v0.487.0 - ISC
129
+ *
130
+ * This source code is licensed under the ISC license.
131
+ * See the LICENSE file in the root directory of this source tree.
132
+ */const V3=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],by=$e("chevron-up",V3);/**
133
+ * @license lucide-react v0.487.0 - ISC
134
+ *
135
+ * This source code is licensed under the ISC license.
136
+ * See the LICENSE file in the root directory of this source tree.
137
+ */const W3=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]],Zi=$e("circle-alert",W3);/**
138
+ * @license lucide-react v0.487.0 - ISC
139
+ *
140
+ * This source code is licensed under the ISC license.
141
+ * See the LICENSE file in the root directory of this source tree.
142
+ */const H3=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],ky=$e("circle-check-big",H3);/**
143
+ * @license lucide-react v0.487.0 - ISC
144
+ *
145
+ * This source code is licensed under the ISC license.
146
+ * See the LICENSE file in the root directory of this source tree.
147
+ */const q3=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],_i=$e("circle-check",q3);/**
148
+ * @license lucide-react v0.487.0 - ISC
149
+ *
150
+ * This source code is licensed under the ISC license.
151
+ * See the LICENSE file in the root directory of this source tree.
152
+ */const K3=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]],wy=$e("circle-x",K3);/**
153
+ * @license lucide-react v0.487.0 - ISC
154
+ *
155
+ * This source code is licensed under the ISC license.
156
+ * See the LICENSE file in the root directory of this source tree.
157
+ */const G3=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M11 9h4a2 2 0 0 0 2-2V3",key:"1ve2rv"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"M7 21v-4a2 2 0 0 1 2-2h4",key:"1fwkro"}],["circle",{cx:"15",cy:"15",r:"2",key:"3i40o0"}]],Y3=$e("circuit-board",G3);/**
158
+ * @license lucide-react v0.487.0 - ISC
159
+ *
160
+ * This source code is licensed under the ISC license.
161
+ * See the LICENSE file in the root directory of this source tree.
162
+ */const J3=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]],es=$e("clock",J3);/**
163
+ * @license lucide-react v0.487.0 - ISC
164
+ *
165
+ * This source code is licensed under the ISC license.
166
+ * See the LICENSE file in the root directory of this source tree.
167
+ */const X3=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],df=$e("copy",X3);/**
168
+ * @license lucide-react v0.487.0 - ISC
169
+ *
170
+ * This source code is licensed under the ISC license.
171
+ * See the LICENSE file in the root directory of this source tree.
172
+ */const Q3=[["rect",{width:"16",height:"16",x:"4",y:"4",rx:"2",key:"14l7u7"}],["rect",{width:"6",height:"6",x:"9",y:"9",rx:"1",key:"5aljv4"}],["path",{d:"M15 2v2",key:"13l42r"}],["path",{d:"M15 20v2",key:"15mkzm"}],["path",{d:"M2 15h2",key:"1gxd5l"}],["path",{d:"M2 9h2",key:"1bbxkp"}],["path",{d:"M20 15h2",key:"19e6y8"}],["path",{d:"M20 9h2",key:"19tzq7"}],["path",{d:"M9 2v2",key:"165o2o"}],["path",{d:"M9 20v2",key:"i2bqo8"}]],Ja=$e("cpu",Q3);/**
173
+ * @license lucide-react v0.487.0 - ISC
174
+ *
175
+ * This source code is licensed under the ISC license.
176
+ * See the LICENSE file in the root directory of this source tree.
177
+ */const Z3=[["line",{x1:"12",x2:"12",y1:"2",y2:"22",key:"7eqyqh"}],["path",{d:"M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6",key:"1b0p4s"}]],Rf=$e("dollar-sign",Z3);/**
178
+ * @license lucide-react v0.487.0 - ISC
179
+ *
180
+ * This source code is licensed under the ISC license.
181
+ * See the LICENSE file in the root directory of this source tree.
182
+ */const eD=[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]],kN=$e("download",eD);/**
183
+ * @license lucide-react v0.487.0 - ISC
184
+ *
185
+ * This source code is licensed under the ISC license.
186
+ * See the LICENSE file in the root directory of this source tree.
187
+ */const tD=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]],nD=$e("external-link",tD);/**
188
+ * @license lucide-react v0.487.0 - ISC
189
+ *
190
+ * This source code is licensed under the ISC license.
191
+ * See the LICENSE file in the root directory of this source tree.
192
+ */const rD=[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],sc=$e("eye-off",rD);/**
193
+ * @license lucide-react v0.487.0 - ISC
194
+ *
195
+ * This source code is licensed under the ISC license.
196
+ * See the LICENSE file in the root directory of this source tree.
197
+ */const iD=[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],Ss=$e("eye",iD);/**
198
+ * @license lucide-react v0.487.0 - ISC
199
+ *
200
+ * This source code is licensed under the ISC license.
201
+ * See the LICENSE file in the root directory of this source tree.
202
+ */const sD=[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}]],b1=$e("file",sD);/**
203
+ * @license lucide-react v0.487.0 - ISC
204
+ *
205
+ * This source code is licensed under the ISC license.
206
+ * See the LICENSE file in the root directory of this source tree.
207
+ */const aD=[["path",{d:"M12 10a2 2 0 0 0-2 2c0 1.02-.1 2.51-.26 4",key:"1nerag"}],["path",{d:"M14 13.12c0 2.38 0 6.38-1 8.88",key:"o46ks0"}],["path",{d:"M17.29 21.02c.12-.6.43-2.3.5-3.02",key:"ptglia"}],["path",{d:"M2 12a10 10 0 0 1 18-6",key:"ydlgp0"}],["path",{d:"M2 16h.01",key:"1gqxmh"}],["path",{d:"M21.8 16c.2-2 .131-5.354 0-6",key:"drycrb"}],["path",{d:"M5 19.5C5.5 18 6 15 6 12a6 6 0 0 1 .34-2",key:"1tidbn"}],["path",{d:"M8.65 22c.21-.66.45-1.32.57-2",key:"13wd9y"}],["path",{d:"M9 6.8a6 6 0 0 1 9 5.2v2",key:"1fr1j5"}]],oD=$e("fingerprint",aD);/**
208
+ * @license lucide-react v0.487.0 - ISC
209
+ *
210
+ * This source code is licensed under the ISC license.
211
+ * See the LICENSE file in the root directory of this source tree.
212
+ */const lD=[["path",{d:"M8.5 14.5A2.5 2.5 0 0 0 11 12c0-1.38-.5-2-1-3-1.072-2.143-.224-4.054 2-6 .5 2.5 2 4.9 4 6.5 2 1.6 3 3.5 3 5.5a7 7 0 1 1-14 0c0-1.153.433-2.294 1-3a2.5 2.5 0 0 0 2.5 2.5z",key:"96xj49"}]],cD=$e("flame",lD);/**
213
+ * @license lucide-react v0.487.0 - ISC
214
+ *
215
+ * This source code is licensed under the ISC license.
216
+ * See the LICENSE file in the root directory of this source tree.
217
+ */const uD=[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]],dD=$e("folder-open",uD);/**
218
+ * @license lucide-react v0.487.0 - ISC
219
+ *
220
+ * This source code is licensed under the ISC license.
221
+ * See the LICENSE file in the root directory of this source tree.
222
+ */const hD=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]],wN=$e("globe",hD);/**
223
+ * @license lucide-react v0.487.0 - ISC
224
+ *
225
+ * This source code is licensed under the ISC license.
226
+ * See the LICENSE file in the root directory of this source tree.
227
+ */const fD=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]],Ug=$e("history",fD);/**
228
+ * @license lucide-react v0.487.0 - ISC
229
+ *
230
+ * This source code is licensed under the ISC license.
231
+ * See the LICENSE file in the root directory of this source tree.
232
+ */const pD=[["path",{d:"M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z",key:"1s6t7t"}],["circle",{cx:"16.5",cy:"7.5",r:".5",fill:"currentColor",key:"w0ekpg"}]],mD=$e("key-round",pD);/**
233
+ * @license lucide-react v0.487.0 - ISC
234
+ *
235
+ * This source code is licensed under the ISC license.
236
+ * See the LICENSE file in the root directory of this source tree.
237
+ */const gD=[["path",{d:"m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4",key:"g0fldk"}],["path",{d:"m21 2-9.6 9.6",key:"1j0ho8"}],["circle",{cx:"7.5",cy:"15.5",r:"5.5",key:"yqb3hr"}]],xu=$e("key",gD);/**
238
+ * @license lucide-react v0.487.0 - ISC
239
+ *
240
+ * This source code is licensed under the ISC license.
241
+ * See the LICENSE file in the root directory of this source tree.
242
+ */const vD=[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]],yD=$e("link-2",vD);/**
243
+ * @license lucide-react v0.487.0 - ISC
244
+ *
245
+ * This source code is licensed under the ISC license.
246
+ * See the LICENSE file in the root directory of this source tree.
247
+ */const xD=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],$t=$e("loader-circle",xD);/**
248
+ * @license lucide-react v0.487.0 - ISC
249
+ *
250
+ * This source code is licensed under the ISC license.
251
+ * See the LICENSE file in the root directory of this source tree.
252
+ */const bD=[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 9.9-1",key:"1mm8w8"}]],Z0=$e("lock-open",bD);/**
253
+ * @license lucide-react v0.487.0 - ISC
254
+ *
255
+ * This source code is licensed under the ISC license.
256
+ * See the LICENSE file in the root directory of this source tree.
257
+ */const kD=[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]],If=$e("lock",kD);/**
258
+ * @license lucide-react v0.487.0 - ISC
259
+ *
260
+ * This source code is licensed under the ISC license.
261
+ * See the LICENSE file in the root directory of this source tree.
262
+ */const wD=[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}]],SN=$e("message-square",wD);/**
263
+ * @license lucide-react v0.487.0 - ISC
264
+ *
265
+ * This source code is licensed under the ISC license.
266
+ * See the LICENSE file in the root directory of this source tree.
267
+ */const SD=[["path",{d:"M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3Z",key:"131961"}],["path",{d:"M19 10v2a7 7 0 0 1-14 0v-2",key:"1vc78b"}],["line",{x1:"12",x2:"12",y1:"19",y2:"22",key:"x3vr5v"}]],ev=$e("mic",SD);/**
268
+ * @license lucide-react v0.487.0 - ISC
269
+ *
270
+ * This source code is licensed under the ISC license.
271
+ * See the LICENSE file in the root directory of this source tree.
272
+ */const CD=[["rect",{x:"16",y:"16",width:"6",height:"6",rx:"1",key:"4q2zg0"}],["rect",{x:"2",y:"16",width:"6",height:"6",rx:"1",key:"8cvhb9"}],["rect",{x:"9",y:"2",width:"6",height:"6",rx:"1",key:"1egb70"}],["path",{d:"M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3",key:"1jsf9p"}],["path",{d:"M12 12V8",key:"2874zd"}]],TD=$e("network",CD);/**
273
+ * @license lucide-react v0.487.0 - ISC
274
+ *
275
+ * This source code is licensed under the ISC license.
276
+ * See the LICENSE file in the root directory of this source tree.
277
+ */const ND=[["path",{d:"M13.234 20.252 21 12.3",key:"1cbrk9"}],["path",{d:"m16 6-8.414 8.586a2 2 0 0 0 0 2.828 2 2 0 0 0 2.828 0l8.414-8.586a4 4 0 0 0 0-5.656 4 4 0 0 0-5.656 0l-8.415 8.585a6 6 0 1 0 8.486 8.486",key:"1pkts6"}]],ED=$e("paperclip",ND);/**
278
+ * @license lucide-react v0.487.0 - ISC
279
+ *
280
+ * This source code is licensed under the ISC license.
281
+ * See the LICENSE file in the root directory of this source tree.
282
+ */const jD=[["rect",{x:"14",y:"4",width:"4",height:"16",rx:"1",key:"zuxfzm"}],["rect",{x:"6",y:"4",width:"4",height:"16",rx:"1",key:"1okwgv"}]],CN=$e("pause",jD);/**
283
+ * @license lucide-react v0.487.0 - ISC
284
+ *
285
+ * This source code is licensed under the ISC license.
286
+ * See the LICENSE file in the root directory of this source tree.
287
+ */const PD=[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]],Sy=$e("pencil",PD);/**
288
+ * @license lucide-react v0.487.0 - ISC
289
+ *
290
+ * This source code is licensed under the ISC license.
291
+ * See the LICENSE file in the root directory of this source tree.
292
+ */const _D=[["path",{d:"M10.68 13.31a16 16 0 0 0 3.41 2.6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7 2 2 0 0 1 1.72 2v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.42 19.42 0 0 1-3.33-2.67m-2.67-3.34a19.79 19.79 0 0 1-3.07-8.63A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91",key:"z86iuo"}],["line",{x1:"22",x2:"2",y1:"2",y2:"22",key:"11kh81"}]],RD=$e("phone-off",_D);/**
293
+ * @license lucide-react v0.487.0 - ISC
294
+ *
295
+ * This source code is licensed under the ISC license.
296
+ * See the LICENSE file in the root directory of this source tree.
297
+ */const ID=[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]],Cy=$e("play",ID);/**
298
+ * @license lucide-react v0.487.0 - ISC
299
+ *
300
+ * This source code is licensed under the ISC license.
301
+ * See the LICENSE file in the root directory of this source tree.
302
+ */const MD=[["path",{d:"M12 22v-5",key:"1ega77"}],["path",{d:"M9 8V2",key:"14iosj"}],["path",{d:"M15 8V2",key:"18g5xt"}],["path",{d:"M18 8v5a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V8Z",key:"osxo6l"}]],DD=$e("plug",MD);/**
303
+ * @license lucide-react v0.487.0 - ISC
304
+ *
305
+ * This source code is licensed under the ISC license.
306
+ * See the LICENSE file in the root directory of this source tree.
307
+ */const AD=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],Cs=$e("plus",AD);/**
308
+ * @license lucide-react v0.487.0 - ISC
309
+ *
310
+ * This source code is licensed under the ISC license.
311
+ * See the LICENSE file in the root directory of this source tree.
312
+ */const OD=[["path",{d:"M18.36 6.64A9 9 0 0 1 20.77 15",key:"dxknvb"}],["path",{d:"M6.16 6.16a9 9 0 1 0 12.68 12.68",key:"1x7qb5"}],["path",{d:"M12 2v4",key:"3427ic"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],LD=$e("power-off",OD);/**
313
+ * @license lucide-react v0.487.0 - ISC
314
+ *
315
+ * This source code is licensed under the ISC license.
316
+ * See the LICENSE file in the root directory of this source tree.
317
+ */const FD=[["path",{d:"M15.39 4.39a1 1 0 0 0 1.68-.474 2.5 2.5 0 1 1 3.014 3.015 1 1 0 0 0-.474 1.68l1.683 1.682a2.414 2.414 0 0 1 0 3.414L19.61 15.39a1 1 0 0 1-1.68-.474 2.5 2.5 0 1 0-3.014 3.015 1 1 0 0 1 .474 1.68l-1.683 1.682a2.414 2.414 0 0 1-3.414 0L8.61 19.61a1 1 0 0 0-1.68.474 2.5 2.5 0 1 1-3.014-3.015 1 1 0 0 0 .474-1.68l-1.683-1.682a2.414 2.414 0 0 1 0-3.414L4.39 8.61a1 1 0 0 1 1.68.474 2.5 2.5 0 1 0 3.014-3.015 1 1 0 0 1-.474-1.68l1.683-1.682a2.414 2.414 0 0 1 3.414 0z",key:"w46dr5"}]],TN=$e("puzzle",FD);/**
318
+ * @license lucide-react v0.487.0 - ISC
319
+ *
320
+ * This source code is licensed under the ISC license.
321
+ * See the LICENSE file in the root directory of this source tree.
322
+ */const UD=[["path",{d:"M4.9 19.1C1 15.2 1 8.8 4.9 4.9",key:"1vaf9d"}],["path",{d:"M7.8 16.2c-2.3-2.3-2.3-6.1 0-8.5",key:"u1ii0m"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}],["path",{d:"M16.2 7.8c2.3 2.3 2.3 6.1 0 8.5",key:"1j5fej"}],["path",{d:"M19.1 4.9C23 8.8 23 15.1 19.1 19",key:"10b0cb"}]],Ty=$e("radio",UD);/**
323
+ * @license lucide-react v0.487.0 - ISC
324
+ *
325
+ * This source code is licensed under the ISC license.
326
+ * See the LICENSE file in the root directory of this source tree.
327
+ */const BD=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],so=$e("refresh-cw",BD);/**
328
+ * @license lucide-react v0.487.0 - ISC
329
+ *
330
+ * This source code is licensed under the ISC license.
331
+ * See the LICENSE file in the root directory of this source tree.
332
+ */const zD=[["path",{d:"m17 2 4 4-4 4",key:"nntrym"}],["path",{d:"M3 11v-1a4 4 0 0 1 4-4h14",key:"84bu3i"}],["path",{d:"m7 22-4-4 4-4",key:"1wqhfi"}],["path",{d:"M21 13v1a4 4 0 0 1-4 4H3",key:"1rx37r"}]],NN=$e("repeat",zD);/**
333
+ * @license lucide-react v0.487.0 - ISC
334
+ *
335
+ * This source code is licensed under the ISC license.
336
+ * See the LICENSE file in the root directory of this source tree.
337
+ */const $D=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]],VD=$e("rotate-ccw",$D);/**
338
+ * @license lucide-react v0.487.0 - ISC
339
+ *
340
+ * This source code is licensed under the ISC license.
341
+ * See the LICENSE file in the root directory of this source tree.
342
+ */const WD=[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]],rd=$e("save",WD);/**
343
+ * @license lucide-react v0.487.0 - ISC
344
+ *
345
+ * This source code is licensed under the ISC license.
346
+ * See the LICENSE file in the root directory of this source tree.
347
+ */const HD=[["path",{d:"M15 12h-5",key:"r7krc0"}],["path",{d:"M15 8h-5",key:"1khuty"}],["path",{d:"M19 17V5a2 2 0 0 0-2-2H4",key:"zz82l3"}],["path",{d:"M8 21h12a2 2 0 0 0 2-2v-1a1 1 0 0 0-1-1H11a1 1 0 0 0-1 1v1a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v2a1 1 0 0 0 1 1h3",key:"1ph1d7"}]],qD=$e("scroll-text",HD);/**
348
+ * @license lucide-react v0.487.0 - ISC
349
+ *
350
+ * This source code is licensed under the ISC license.
351
+ * See the LICENSE file in the root directory of this source tree.
352
+ */const KD=[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]],Wo=$e("search",KD);/**
353
+ * @license lucide-react v0.487.0 - ISC
354
+ *
355
+ * This source code is licensed under the ISC license.
356
+ * See the LICENSE file in the root directory of this source tree.
357
+ */const GD=[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]],k1=$e("send",GD);/**
358
+ * @license lucide-react v0.487.0 - ISC
359
+ *
360
+ * This source code is licensed under the ISC license.
361
+ * See the LICENSE file in the root directory of this source tree.
362
+ */const YD=[["path",{d:"M20 7h-9",key:"3s1dr2"}],["path",{d:"M14 17H5",key:"gfn3mx"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}],["circle",{cx:"7",cy:"7",r:"3",key:"dfmy0x"}]],JD=$e("settings-2",YD);/**
363
+ * @license lucide-react v0.487.0 - ISC
364
+ *
365
+ * This source code is licensed under the ISC license.
366
+ * See the LICENSE file in the root directory of this source tree.
367
+ */const XD=[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],pp=$e("settings",XD);/**
368
+ * @license lucide-react v0.487.0 - ISC
369
+ *
370
+ * This source code is licensed under the ISC license.
371
+ * See the LICENSE file in the root directory of this source tree.
372
+ */const QD=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M12 16h.01",key:"1drbdi"}]],ZD=$e("shield-alert",QD);/**
373
+ * @license lucide-react v0.487.0 - ISC
374
+ *
375
+ * This source code is licensed under the ISC license.
376
+ * See the LICENSE file in the root directory of this source tree.
377
+ */const eA=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],w1=$e("shield-check",eA);/**
378
+ * @license lucide-react v0.487.0 - ISC
379
+ *
380
+ * This source code is licensed under the ISC license.
381
+ * See the LICENSE file in the root directory of this source tree.
382
+ */const tA=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]],zu=$e("shield",tA);/**
383
+ * @license lucide-react v0.487.0 - ISC
384
+ *
385
+ * This source code is licensed under the ISC license.
386
+ * See the LICENSE file in the root directory of this source tree.
387
+ */const nA=[["path",{d:"M9.937 15.5A2 2 0 0 0 8.5 14.063l-6.135-1.582a.5.5 0 0 1 0-.962L8.5 9.936A2 2 0 0 0 9.937 8.5l1.582-6.135a.5.5 0 0 1 .963 0L14.063 8.5A2 2 0 0 0 15.5 9.937l6.135 1.581a.5.5 0 0 1 0 .964L15.5 14.063a2 2 0 0 0-1.437 1.437l-1.582 6.135a.5.5 0 0 1-.963 0z",key:"4pj2yx"}],["path",{d:"M20 3v4",key:"1olli1"}],["path",{d:"M22 5h-4",key:"1gvqau"}],["path",{d:"M4 17v2",key:"vumght"}],["path",{d:"M5 18H3",key:"zchphs"}]],EN=$e("sparkles",nA);/**
388
+ * @license lucide-react v0.487.0 - ISC
389
+ *
390
+ * This source code is licensed under the ISC license.
391
+ * See the LICENSE file in the root directory of this source tree.
392
+ */const rA=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"6",key:"1vlfrh"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]],Mf=$e("target",rA);/**
393
+ * @license lucide-react v0.487.0 - ISC
394
+ *
395
+ * This source code is licensed under the ISC license.
396
+ * See the LICENSE file in the root directory of this source tree.
397
+ */const iA=[["polyline",{points:"4 17 10 11 4 5",key:"akl6gq"}],["line",{x1:"12",x2:"20",y1:"19",y2:"19",key:"q2wloq"}]],Ny=$e("terminal",iA);/**
398
+ * @license lucide-react v0.487.0 - ISC
399
+ *
400
+ * This source code is licensed under the ISC license.
401
+ * See the LICENSE file in the root directory of this source tree.
402
+ */const sA=[["line",{x1:"10",x2:"14",y1:"2",y2:"2",key:"14vaq8"}],["line",{x1:"12",x2:"15",y1:"14",y2:"11",key:"17fdiu"}],["circle",{cx:"12",cy:"14",r:"8",key:"1e1u0o"}]],jN=$e("timer",sA);/**
403
+ * @license lucide-react v0.487.0 - ISC
404
+ *
405
+ * This source code is licensed under the ISC license.
406
+ * See the LICENSE file in the root directory of this source tree.
407
+ */const aA=[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]],qn=$e("trash-2",aA);/**
408
+ * @license lucide-react v0.487.0 - ISC
409
+ *
410
+ * This source code is licensed under the ISC license.
411
+ * See the LICENSE file in the root directory of this source tree.
412
+ */const oA=[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],Gr=$e("triangle-alert",oA);/**
413
+ * @license lucide-react v0.487.0 - ISC
414
+ *
415
+ * This source code is licensed under the ISC license.
416
+ * See the LICENSE file in the root directory of this source tree.
417
+ */const lA=[["path",{d:"m19 5 3-3",key:"yk6iyv"}],["path",{d:"m2 22 3-3",key:"19mgm9"}],["path",{d:"M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z",key:"goz73y"}],["path",{d:"M7.5 13.5 10 11",key:"7xgeeb"}],["path",{d:"M10.5 16.5 13 14",key:"10btkg"}],["path",{d:"m12 6 6 6 2.3-2.3a2.4 2.4 0 0 0 0-3.4l-2.6-2.6a2.4 2.4 0 0 0-3.4 0Z",key:"1snsnr"}]],S1=$e("unplug",lA);/**
418
+ * @license lucide-react v0.487.0 - ISC
419
+ *
420
+ * This source code is licensed under the ISC license.
421
+ * See the LICENSE file in the root directory of this source tree.
422
+ */const cA=[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]],tv=$e("user",cA);/**
423
+ * @license lucide-react v0.487.0 - ISC
424
+ *
425
+ * This source code is licensed under the ISC license.
426
+ * See the LICENSE file in the root directory of this source tree.
427
+ */const uA=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["path",{d:"M16 3.13a4 4 0 0 1 0 7.75",key:"1da9ce"}]],Qo=$e("users",uA);/**
428
+ * @license lucide-react v0.487.0 - ISC
429
+ *
430
+ * This source code is licensed under the ISC license.
431
+ * See the LICENSE file in the root directory of this source tree.
432
+ */const dA=[["path",{d:"M18 16.98h-5.99c-1.1 0-1.95.94-2.48 1.9A4 4 0 0 1 2 17c.01-.7.2-1.4.57-2",key:"q3hayz"}],["path",{d:"m6 17 3.13-5.78c.53-.97.1-2.18-.5-3.1a4 4 0 1 1 6.89-4.06",key:"1go1hn"}],["path",{d:"m12 6 3.13 5.73C15.66 12.7 16.9 13 18 13a4 4 0 0 1 0 8",key:"qlwsc0"}]],hA=$e("webhook",dA);/**
433
+ * @license lucide-react v0.487.0 - ISC
434
+ *
435
+ * This source code is licensed under the ISC license.
436
+ * See the LICENSE file in the root directory of this source tree.
437
+ */const fA=[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z",key:"cbrjhi"}]],PN=$e("wrench",fA);/**
438
+ * @license lucide-react v0.487.0 - ISC
439
+ *
440
+ * This source code is licensed under the ISC license.
441
+ * See the LICENSE file in the root directory of this source tree.
442
+ */const pA=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],ol=$e("x",pA);/**
443
+ * @license lucide-react v0.487.0 - ISC
444
+ *
445
+ * This source code is licensed under the ISC license.
446
+ * See the LICENSE file in the root directory of this source tree.
447
+ */const mA=[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]],ha=$e("zap",mA),C1="daemora_sidebar_collapsed",gA=[{path:"/",label:"Dashboard",icon:Y3},{path:"/chat",label:"Chat",icon:Ny},{path:"/logs",label:"Logs",icon:qD},{path:"/channels",label:"Channels",icon:Ty},{path:"/integrations",label:"Integrations",icon:DD},{path:"/mcp",label:"MCP",icon:TD},{path:"/skills",label:"Skills",icon:cD},{path:"/cron",label:"Scheduler",icon:jN},{path:"/goals",label:"Goals",icon:Mf},{path:"/watchers",label:"Watchers",icon:Ss},{path:"/security",label:"Security",icon:ZD},{path:"/costs",label:"Costs",icon:oD},{path:"/crew",label:"Crew",icon:TN},{path:"/teams",label:"Teams",icon:O3},{path:"/settings",label:"Settings",icon:pp}];function vA(){const t=ma(),e=Pc(),[n,r]=x.useState(!1),[i,s]=x.useState(!1),[a,c]=x.useState(""),[h,d]=x.useState(""),[f,p]=x.useState(!1),[g,v]=x.useState(()=>{try{return localStorage.getItem(C1)==="1"}catch{return!1}}),k=()=>{v(S=>{const T=!S;try{localStorage.setItem(C1,T?"1":"0")}catch{}return T})};x.useEffect(()=>{(async()=>{try{const S=await we("/api/setup/status"),T=S.ok?await S.json():null;if(T&&!T.completed){e("/setup",{replace:!0}),r(!0);return}if(T!=null&&T.vaultExists&&!(T!=null&&T.vaultUnlocked)){const C=sessionStorage.getItem("daemora_vault_pass");if(C)try{(await we("/auth/login",{method:"POST",body:JSON.stringify({passphrase:C})})).ok||s(!0)}catch{s(!0)}else s(!0)}r(!0)}catch{r(!0)}})()},[]);const w=async()=>{if(a){p(!0),d("");try{const S=await we("/auth/login",{method:"POST",body:JSON.stringify({passphrase:a})});if(!S.ok){const T=await S.json().catch(()=>({}));throw new Error(T.error||"Wrong passphrase")}sessionStorage.setItem("daemora_vault_pass",a),s(!1),c("")}catch(S){d(S.message||"Failed")}p(!1)}};return n?i?o.jsx("div",{className:"min-h-screen bg-[#0a0f1a] flex items-center justify-center",children:o.jsxs("div",{className:"w-full max-w-sm px-6 flex flex-col items-center gap-5",children:[o.jsx(Xo,{size:48}),o.jsx("h1",{className:"text-xl font-bold tracking-[2px] bg-gradient-to-r from-[#00d9ff] to-[#4ECDC4] bg-clip-text text-transparent",children:"DAEMORA"}),o.jsx("div",{className:"text-center",children:o.jsx("p",{className:"text-sm text-[#6b7a8d]",children:"Enter vault passphrase to unlock API keys"})}),o.jsxs("div",{className:"w-full flex flex-col gap-3",children:[o.jsx("input",{type:"password",value:a,onChange:S=>c(S.target.value),onKeyDown:S=>S.key==="Enter"&&w(),placeholder:"Vault passphrase",className:"w-full px-4 py-3 bg-[#131b2e] border border-[#1e2d45] rounded-lg text-white font-mono text-sm outline-none focus:border-[#00d9ff] transition-colors",autoFocus:!0}),h&&o.jsx("p",{className:"text-xs text-red-400 text-center",children:h}),o.jsx("button",{onClick:w,disabled:f||!a,className:"w-full py-3 bg-gradient-to-r from-[#00d9ff] to-[#4ECDC4] text-[#0a0f1a] font-bold rounded-lg text-sm hover:opacity-90 active:scale-[0.98] transition-all disabled:opacity-40",children:f?"Unlocking...":"Unlock"}),o.jsx("button",{onClick:()=>s(!1),className:"text-xs text-[#4a5568] hover:text-[#6b7a8d] underline",children:"Skip — continue without API keys"})]})]})}):o.jsxs("div",{className:"min-h-screen bg-[#030213] text-[#f0f0f3] relative overflow-hidden flex",children:[o.jsx(C3,{}),o.jsx("div",{className:"fixed top-0 left-1/4 w-96 h-96 bg-[#00d9ff] opacity-10 blur-[128px] rounded-full pointer-events-none"}),o.jsx("div",{className:"fixed bottom-0 right-1/4 w-96 h-96 bg-[#4ECDC4] opacity-10 blur-[128px] rounded-full pointer-events-none"}),o.jsxs("aside",{className:`relative border-r border-slate-800/50 bg-slate-900/20 backdrop-blur-xl z-20 flex flex-col h-screen sticky top-0 transition-[width] duration-200 ease-out ${g?"w-16":"w-64"}`,children:[o.jsx("button",{type:"button",onClick:k,className:"absolute -right-3 top-7 z-30 w-6 h-6 rounded-full bg-slate-900 border border-slate-700 hover:border-[#00d9ff]/60 hover:bg-slate-800 flex items-center justify-center text-gray-400 hover:text-[#00d9ff] transition-colors shadow-lg","aria-label":g?"Expand sidebar":"Collapse sidebar",title:g?"Expand sidebar":"Collapse sidebar",children:g?o.jsx(fp,{className:"w-3.5 h-3.5"}):o.jsx(bN,{className:"w-3.5 h-3.5"})}),o.jsx("div",{className:`border-b border-slate-800/50 ${g?"py-5 px-3 flex justify-center":"p-6"}`,children:o.jsxs("div",{className:`flex items-center ${g?"justify-center":"gap-3"}`,children:[o.jsx(Xo,{size:g?32:40}),!g&&o.jsx("h1",{className:"text-xl font-bold bg-gradient-to-r from-white via-[#00d9ff] to-[#4ECDC4] bg-clip-text text-transparent tracking-tight",children:"Daemora"})]})}),o.jsx("nav",{className:`space-y-1 flex-1 overflow-y-auto ${g?"p-2":"p-4"}`,children:gA.map(S=>{const T=S.icon,C=t.pathname===S.path||S.path!=="/"&&t.pathname.startsWith(S.path);return o.jsxs(al,{to:S.path,title:g?S.label:void 0,className:`flex items-center rounded-lg transition-all ${g?"justify-center px-0 py-2.5":"gap-3 px-4 py-3"} ${C?"bg-[#00d9ff]/10 text-[#00d9ff] border border-[#00d9ff]/30 shadow-[0_0_15px_rgba(0,217,255,0.2)]":"text-gray-400 hover:bg-slate-800/50 hover:text-[#00d9ff]"}`,children:[o.jsx(T,{className:"w-5 h-5 shrink-0"}),!g&&o.jsx("span",{className:"font-medium text-sm",children:S.label})]},S.path)})}),o.jsx("div",{className:`border-t border-slate-800/50 ${g?"py-3 flex justify-center":"p-4"}`,children:o.jsxs("div",{className:`flex items-center ${g?"justify-center":"gap-2 px-4 py-2"}`,children:[o.jsx("div",{className:"w-2 h-2 bg-[#00ff88] rounded-full animate-pulse",title:"System Active"}),!g&&o.jsx("span",{className:"text-[10px] text-gray-500 font-mono uppercase tracking-widest",children:"System Active"})]})})]}),o.jsxs("div",{className:"flex-1 flex flex-col relative z-10 h-screen overflow-hidden",children:[o.jsxs("header",{className:"h-16 border-b border-slate-800/50 bg-slate-900/10 backdrop-blur-md flex items-center justify-between px-8 shrink-0",children:[o.jsx("div",{className:"text-[10px] text-gray-500 font-mono uppercase tracking-[0.3em]",children:"Authorized Access Only // Layer 7 Encryption"}),o.jsx("div",{className:"flex items-center gap-4",children:o.jsx(yA,{variant:"outline",className:"border-[#00ff88]/20 text-[#00ff88] font-mono text-[9px] h-5 uppercase",children:"Live"})})]}),o.jsx("main",{className:`flex-1 overflow-y-auto ${t.pathname==="/chat"?"":"p-6"}`,children:o.jsx("div",{className:`h-full ${t.pathname==="/chat"?"":"max-w-[1600px] mx-auto"}`,children:o.jsx(DM,{})})})]})]}):null}function yA({children:t,variant:e,className:n}){return o.jsx("span",{className:`inline-flex items-center px-2 rounded-full border text-xs font-semibold ${n}`,children:t})}function _N(t){var e,n,r="";if(typeof t=="string"||typeof t=="number")r+=t;else if(typeof t=="object")if(Array.isArray(t)){var i=t.length;for(e=0;e<i;e++)t[e]&&(n=_N(t[e]))&&(r&&(r+=" "),r+=n)}else for(n in t)t[n]&&(r&&(r+=" "),r+=n);return r}function RN(){for(var t,e,n=0,r="",i=arguments.length;n<i;n++)(t=arguments[n])&&(e=_N(t))&&(r&&(r+=" "),r+=e);return r}const Ey="-",xA=t=>{const e=kA(t),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=t;return{getClassGroupId:a=>{const c=a.split(Ey);return c[0]===""&&c.length!==1&&c.shift(),IN(c,e)||bA(a)},getConflictingClassGroupIds:(a,c)=>{const h=n[a]||[];return c&&r[a]?[...h,...r[a]]:h}}},IN=(t,e)=>{var a;if(t.length===0)return e.classGroupId;const n=t[0],r=e.nextPart.get(n),i=r?IN(t.slice(1),r):void 0;if(i)return i;if(e.validators.length===0)return;const s=t.join(Ey);return(a=e.validators.find(({validator:c})=>c(s)))==null?void 0:a.classGroupId},T1=/^\[(.+)\]$/,bA=t=>{if(T1.test(t)){const e=T1.exec(t)[1],n=e==null?void 0:e.substring(0,e.indexOf(":"));if(n)return"arbitrary.."+n}},kA=t=>{const{theme:e,classGroups:n}=t,r={nextPart:new Map,validators:[]};for(const i in n)nv(n[i],r,i,e);return r},nv=(t,e,n,r)=>{t.forEach(i=>{if(typeof i=="string"){const s=i===""?e:N1(e,i);s.classGroupId=n;return}if(typeof i=="function"){if(wA(i)){nv(i(r),e,n,r);return}e.validators.push({validator:i,classGroupId:n});return}Object.entries(i).forEach(([s,a])=>{nv(a,N1(e,s),n,r)})})},N1=(t,e)=>{let n=t;return e.split(Ey).forEach(r=>{n.nextPart.has(r)||n.nextPart.set(r,{nextPart:new Map,validators:[]}),n=n.nextPart.get(r)}),n},wA=t=>t.isThemeGetter,SA=t=>{if(t<1)return{get:()=>{},set:()=>{}};let e=0,n=new Map,r=new Map;const i=(s,a)=>{n.set(s,a),e++,e>t&&(e=0,r=n,n=new Map)};return{get(s){let a=n.get(s);if(a!==void 0)return a;if((a=r.get(s))!==void 0)return i(s,a),a},set(s,a){n.has(s)?n.set(s,a):i(s,a)}}},rv="!",iv=":",CA=iv.length,TA=t=>{const{prefix:e,experimentalParseClassName:n}=t;let r=i=>{const s=[];let a=0,c=0,h=0,d;for(let k=0;k<i.length;k++){let w=i[k];if(a===0&&c===0){if(w===iv){s.push(i.slice(h,k)),h=k+CA;continue}if(w==="/"){d=k;continue}}w==="["?a++:w==="]"?a--:w==="("?c++:w===")"&&c--}const f=s.length===0?i:i.substring(h),p=NA(f),g=p!==f,v=d&&d>h?d-h:void 0;return{modifiers:s,hasImportantModifier:g,baseClassName:p,maybePostfixModifierPosition:v}};if(e){const i=e+iv,s=r;r=a=>a.startsWith(i)?s(a.substring(i.length)):{isExternal:!0,modifiers:[],hasImportantModifier:!1,baseClassName:a,maybePostfixModifierPosition:void 0}}if(n){const i=r;r=s=>n({className:s,parseClassName:i})}return r},NA=t=>t.endsWith(rv)?t.substring(0,t.length-1):t.startsWith(rv)?t.substring(1):t,EA=t=>{const e=Object.fromEntries(t.orderSensitiveModifiers.map(r=>[r,!0]));return r=>{if(r.length<=1)return r;const i=[];let s=[];return r.forEach(a=>{a[0]==="["||e[a]?(i.push(...s.sort(),a),s=[]):s.push(a)}),i.push(...s.sort()),i}},jA=t=>({cache:SA(t.cacheSize),parseClassName:TA(t),sortModifiers:EA(t),...xA(t)}),PA=/\s+/,_A=(t,e)=>{const{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:i,sortModifiers:s}=e,a=[],c=t.trim().split(PA);let h="";for(let d=c.length-1;d>=0;d-=1){const f=c[d],{isExternal:p,modifiers:g,hasImportantModifier:v,baseClassName:k,maybePostfixModifierPosition:w}=n(f);if(p){h=f+(h.length>0?" "+h:h);continue}let S=!!w,T=r(S?k.substring(0,w):k);if(!T){if(!S){h=f+(h.length>0?" "+h:h);continue}if(T=r(k),!T){h=f+(h.length>0?" "+h:h);continue}S=!1}const C=s(g).join(":"),j=v?C+rv:C,R=j+T;if(a.includes(R))continue;a.push(R);const _=i(T,S);for(let I=0;I<_.length;++I){const M=_[I];a.push(j+M)}h=f+(h.length>0?" "+h:h)}return h};function RA(){let t=0,e,n,r="";for(;t<arguments.length;)(e=arguments[t++])&&(n=MN(e))&&(r&&(r+=" "),r+=n);return r}const MN=t=>{if(typeof t=="string")return t;let e,n="";for(let r=0;r<t.length;r++)t[r]&&(e=MN(t[r]))&&(n&&(n+=" "),n+=e);return n};function IA(t,...e){let n,r,i,s=a;function a(h){const d=e.reduce((f,p)=>p(f),t());return n=jA(d),r=n.cache.get,i=n.cache.set,s=c,c(h)}function c(h){const d=r(h);if(d)return d;const f=_A(h,n);return i(h,f),f}return function(){return s(RA.apply(null,arguments))}}const nr=t=>{const e=n=>n[t]||[];return e.isThemeGetter=!0,e},DN=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,AN=/^\((?:(\w[\w-]*):)?(.+)\)$/i,MA=/^\d+\/\d+$/,DA=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,AA=/\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$/,OA=/^(rgba?|hsla?|hwb|(ok)?(lab|lch))\(.+\)$/,LA=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,FA=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Vl=t=>MA.test(t),Rt=t=>!!t&&!Number.isNaN(Number(t)),za=t=>!!t&&Number.isInteger(Number(t)),Bg=t=>t.endsWith("%")&&Rt(t.slice(0,-1)),ea=t=>DA.test(t),UA=()=>!0,BA=t=>AA.test(t)&&!OA.test(t),ON=()=>!1,zA=t=>LA.test(t),$A=t=>FA.test(t),VA=t=>!tt(t)&&!nt(t),WA=t=>_c(t,UN,ON),tt=t=>DN.test(t),Oo=t=>_c(t,BN,BA),zg=t=>_c(t,YA,Rt),E1=t=>_c(t,LN,ON),HA=t=>_c(t,FN,$A),Uh=t=>_c(t,zN,zA),nt=t=>AN.test(t),bu=t=>Rc(t,BN),qA=t=>Rc(t,JA),j1=t=>Rc(t,LN),KA=t=>Rc(t,UN),GA=t=>Rc(t,FN),Bh=t=>Rc(t,zN,!0),_c=(t,e,n)=>{const r=DN.exec(t);return r?r[1]?e(r[1]):n(r[2]):!1},Rc=(t,e,n=!1)=>{const r=AN.exec(t);return r?r[1]?e(r[1]):n:!1},LN=t=>t==="position"||t==="percentage",FN=t=>t==="image"||t==="url",UN=t=>t==="length"||t==="size"||t==="bg-size",BN=t=>t==="length",YA=t=>t==="number",JA=t=>t==="family-name",zN=t=>t==="shadow",XA=()=>{const t=nr("color"),e=nr("font"),n=nr("text"),r=nr("font-weight"),i=nr("tracking"),s=nr("leading"),a=nr("breakpoint"),c=nr("container"),h=nr("spacing"),d=nr("radius"),f=nr("shadow"),p=nr("inset-shadow"),g=nr("text-shadow"),v=nr("drop-shadow"),k=nr("blur"),w=nr("perspective"),S=nr("aspect"),T=nr("ease"),C=nr("animate"),j=()=>["auto","avoid","all","avoid-page","page","left","right","column"],R=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],_=()=>[...R(),nt,tt],I=()=>["auto","hidden","clip","visible","scroll"],M=()=>["auto","contain","none"],L=()=>[nt,tt,h],$=()=>[Vl,"full","auto",...L()],E=()=>[za,"none","subgrid",nt,tt],P=()=>["auto",{span:["full",za,nt,tt]},za,nt,tt],V=()=>[za,"auto",nt,tt],F=()=>["auto","min","max","fr",nt,tt],K=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],J=()=>["start","end","center","stretch","center-safe","end-safe"],Q=()=>["auto",...L()],Z=()=>[Vl,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...L()],D=()=>[t,nt,tt],ne=()=>[...R(),j1,E1,{position:[nt,tt]}],A=()=>["no-repeat",{repeat:["","x","y","space","round"]}],z=()=>["auto","cover","contain",KA,WA,{size:[nt,tt]}],ee=()=>[Bg,bu,Oo],B=()=>["","none","full",d,nt,tt],X=()=>["",Rt,bu,Oo],ye=()=>["solid","dashed","dotted","double"],se=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],oe=()=>[Rt,Bg,j1,E1],U=()=>["","none",k,nt,tt],ue=()=>["none",Rt,nt,tt],ke=()=>["none",Rt,nt,tt],W=()=>[Rt,nt,tt],q=()=>[Vl,"full",...L()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[ea],breakpoint:[ea],color:[UA],container:[ea],"drop-shadow":[ea],ease:["in","out","in-out"],font:[VA],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[ea],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[ea],shadow:[ea],spacing:["px",Rt],text:[ea],"text-shadow":[ea],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",Vl,tt,nt,S]}],container:["container"],columns:[{columns:[Rt,tt,nt,c]}],"break-after":[{"break-after":j()}],"break-before":[{"break-before":j()}],"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:_()}],overflow:[{overflow:I()}],"overflow-x":[{"overflow-x":I()}],"overflow-y":[{"overflow-y":I()}],overscroll:[{overscroll:M()}],"overscroll-x":[{"overscroll-x":M()}],"overscroll-y":[{"overscroll-y":M()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:$()}],"inset-x":[{"inset-x":$()}],"inset-y":[{"inset-y":$()}],start:[{start:$()}],end:[{end:$()}],top:[{top:$()}],right:[{right:$()}],bottom:[{bottom:$()}],left:[{left:$()}],visibility:["visible","invisible","collapse"],z:[{z:[za,"auto",nt,tt]}],basis:[{basis:[Vl,"full","auto",c,...L()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[Rt,Vl,"auto","initial","none",tt]}],grow:[{grow:["",Rt,nt,tt]}],shrink:[{shrink:["",Rt,nt,tt]}],order:[{order:[za,"first","last","none",nt,tt]}],"grid-cols":[{"grid-cols":E()}],"col-start-end":[{col:P()}],"col-start":[{"col-start":V()}],"col-end":[{"col-end":V()}],"grid-rows":[{"grid-rows":E()}],"row-start-end":[{row:P()}],"row-start":[{"row-start":V()}],"row-end":[{"row-end":V()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":F()}],"auto-rows":[{"auto-rows":F()}],gap:[{gap:L()}],"gap-x":[{"gap-x":L()}],"gap-y":[{"gap-y":L()}],"justify-content":[{justify:[...K(),"normal"]}],"justify-items":[{"justify-items":[...J(),"normal"]}],"justify-self":[{"justify-self":["auto",...J()]}],"align-content":[{content:["normal",...K()]}],"align-items":[{items:[...J(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...J(),{baseline:["","last"]}]}],"place-content":[{"place-content":K()}],"place-items":[{"place-items":[...J(),"baseline"]}],"place-self":[{"place-self":["auto",...J()]}],p:[{p:L()}],px:[{px:L()}],py:[{py:L()}],ps:[{ps:L()}],pe:[{pe:L()}],pt:[{pt:L()}],pr:[{pr:L()}],pb:[{pb:L()}],pl:[{pl:L()}],m:[{m:Q()}],mx:[{mx:Q()}],my:[{my:Q()}],ms:[{ms:Q()}],me:[{me:Q()}],mt:[{mt:Q()}],mr:[{mr:Q()}],mb:[{mb:Q()}],ml:[{ml:Q()}],"space-x":[{"space-x":L()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":L()}],"space-y-reverse":["space-y-reverse"],size:[{size:Z()}],w:[{w:[c,"screen",...Z()]}],"min-w":[{"min-w":[c,"screen","none",...Z()]}],"max-w":[{"max-w":[c,"screen","none","prose",{screen:[a]},...Z()]}],h:[{h:["screen",...Z()]}],"min-h":[{"min-h":["screen","none",...Z()]}],"max-h":[{"max-h":["screen",...Z()]}],"font-size":[{text:["base",n,bu,Oo]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[r,nt,zg]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",Bg,tt]}],"font-family":[{font:[qA,tt,e]}],"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:[i,nt,tt]}],"line-clamp":[{"line-clamp":[Rt,"none",nt,zg]}],leading:[{leading:[s,...L()]}],"list-image":[{"list-image":["none",nt,tt]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",nt,tt]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:D()}],"text-color":[{text:D()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...ye(),"wavy"]}],"text-decoration-thickness":[{decoration:[Rt,"from-font","auto",nt,Oo]}],"text-decoration-color":[{decoration:D()}],"underline-offset":[{"underline-offset":[Rt,"auto",nt,tt]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:L()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",nt,tt]}],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",nt,tt]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:ne()}],"bg-repeat":[{bg:A()}],"bg-size":[{bg:z()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},za,nt,tt],radial:["",nt,tt],conic:[za,nt,tt]},GA,HA]}],"bg-color":[{bg:D()}],"gradient-from-pos":[{from:ee()}],"gradient-via-pos":[{via:ee()}],"gradient-to-pos":[{to:ee()}],"gradient-from":[{from:D()}],"gradient-via":[{via:D()}],"gradient-to":[{to:D()}],rounded:[{rounded:B()}],"rounded-s":[{"rounded-s":B()}],"rounded-e":[{"rounded-e":B()}],"rounded-t":[{"rounded-t":B()}],"rounded-r":[{"rounded-r":B()}],"rounded-b":[{"rounded-b":B()}],"rounded-l":[{"rounded-l":B()}],"rounded-ss":[{"rounded-ss":B()}],"rounded-se":[{"rounded-se":B()}],"rounded-ee":[{"rounded-ee":B()}],"rounded-es":[{"rounded-es":B()}],"rounded-tl":[{"rounded-tl":B()}],"rounded-tr":[{"rounded-tr":B()}],"rounded-br":[{"rounded-br":B()}],"rounded-bl":[{"rounded-bl":B()}],"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:[...ye(),"hidden","none"]}],"divide-style":[{divide:[...ye(),"hidden","none"]}],"border-color":[{border:D()}],"border-color-x":[{"border-x":D()}],"border-color-y":[{"border-y":D()}],"border-color-s":[{"border-s":D()}],"border-color-e":[{"border-e":D()}],"border-color-t":[{"border-t":D()}],"border-color-r":[{"border-r":D()}],"border-color-b":[{"border-b":D()}],"border-color-l":[{"border-l":D()}],"divide-color":[{divide:D()}],"outline-style":[{outline:[...ye(),"none","hidden"]}],"outline-offset":[{"outline-offset":[Rt,nt,tt]}],"outline-w":[{outline:["",Rt,bu,Oo]}],"outline-color":[{outline:D()}],shadow:[{shadow:["","none",f,Bh,Uh]}],"shadow-color":[{shadow:D()}],"inset-shadow":[{"inset-shadow":["none",p,Bh,Uh]}],"inset-shadow-color":[{"inset-shadow":D()}],"ring-w":[{ring:X()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:D()}],"ring-offset-w":[{"ring-offset":[Rt,Oo]}],"ring-offset-color":[{"ring-offset":D()}],"inset-ring-w":[{"inset-ring":X()}],"inset-ring-color":[{"inset-ring":D()}],"text-shadow":[{"text-shadow":["none",g,Bh,Uh]}],"text-shadow-color":[{"text-shadow":D()}],opacity:[{opacity:[Rt,nt,tt]}],"mix-blend":[{"mix-blend":[...se(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":se()}],"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":[Rt]}],"mask-image-linear-from-pos":[{"mask-linear-from":oe()}],"mask-image-linear-to-pos":[{"mask-linear-to":oe()}],"mask-image-linear-from-color":[{"mask-linear-from":D()}],"mask-image-linear-to-color":[{"mask-linear-to":D()}],"mask-image-t-from-pos":[{"mask-t-from":oe()}],"mask-image-t-to-pos":[{"mask-t-to":oe()}],"mask-image-t-from-color":[{"mask-t-from":D()}],"mask-image-t-to-color":[{"mask-t-to":D()}],"mask-image-r-from-pos":[{"mask-r-from":oe()}],"mask-image-r-to-pos":[{"mask-r-to":oe()}],"mask-image-r-from-color":[{"mask-r-from":D()}],"mask-image-r-to-color":[{"mask-r-to":D()}],"mask-image-b-from-pos":[{"mask-b-from":oe()}],"mask-image-b-to-pos":[{"mask-b-to":oe()}],"mask-image-b-from-color":[{"mask-b-from":D()}],"mask-image-b-to-color":[{"mask-b-to":D()}],"mask-image-l-from-pos":[{"mask-l-from":oe()}],"mask-image-l-to-pos":[{"mask-l-to":oe()}],"mask-image-l-from-color":[{"mask-l-from":D()}],"mask-image-l-to-color":[{"mask-l-to":D()}],"mask-image-x-from-pos":[{"mask-x-from":oe()}],"mask-image-x-to-pos":[{"mask-x-to":oe()}],"mask-image-x-from-color":[{"mask-x-from":D()}],"mask-image-x-to-color":[{"mask-x-to":D()}],"mask-image-y-from-pos":[{"mask-y-from":oe()}],"mask-image-y-to-pos":[{"mask-y-to":oe()}],"mask-image-y-from-color":[{"mask-y-from":D()}],"mask-image-y-to-color":[{"mask-y-to":D()}],"mask-image-radial":[{"mask-radial":[nt,tt]}],"mask-image-radial-from-pos":[{"mask-radial-from":oe()}],"mask-image-radial-to-pos":[{"mask-radial-to":oe()}],"mask-image-radial-from-color":[{"mask-radial-from":D()}],"mask-image-radial-to-color":[{"mask-radial-to":D()}],"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":R()}],"mask-image-conic-pos":[{"mask-conic":[Rt]}],"mask-image-conic-from-pos":[{"mask-conic-from":oe()}],"mask-image-conic-to-pos":[{"mask-conic-to":oe()}],"mask-image-conic-from-color":[{"mask-conic-from":D()}],"mask-image-conic-to-color":[{"mask-conic-to":D()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:ne()}],"mask-repeat":[{mask:A()}],"mask-size":[{mask:z()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",nt,tt]}],filter:[{filter:["","none",nt,tt]}],blur:[{blur:U()}],brightness:[{brightness:[Rt,nt,tt]}],contrast:[{contrast:[Rt,nt,tt]}],"drop-shadow":[{"drop-shadow":["","none",v,Bh,Uh]}],"drop-shadow-color":[{"drop-shadow":D()}],grayscale:[{grayscale:["",Rt,nt,tt]}],"hue-rotate":[{"hue-rotate":[Rt,nt,tt]}],invert:[{invert:["",Rt,nt,tt]}],saturate:[{saturate:[Rt,nt,tt]}],sepia:[{sepia:["",Rt,nt,tt]}],"backdrop-filter":[{"backdrop-filter":["","none",nt,tt]}],"backdrop-blur":[{"backdrop-blur":U()}],"backdrop-brightness":[{"backdrop-brightness":[Rt,nt,tt]}],"backdrop-contrast":[{"backdrop-contrast":[Rt,nt,tt]}],"backdrop-grayscale":[{"backdrop-grayscale":["",Rt,nt,tt]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[Rt,nt,tt]}],"backdrop-invert":[{"backdrop-invert":["",Rt,nt,tt]}],"backdrop-opacity":[{"backdrop-opacity":[Rt,nt,tt]}],"backdrop-saturate":[{"backdrop-saturate":[Rt,nt,tt]}],"backdrop-sepia":[{"backdrop-sepia":["",Rt,nt,tt]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":L()}],"border-spacing-x":[{"border-spacing-x":L()}],"border-spacing-y":[{"border-spacing-y":L()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",nt,tt]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[Rt,"initial",nt,tt]}],ease:[{ease:["linear","initial",T,nt,tt]}],delay:[{delay:[Rt,nt,tt]}],animate:[{animate:["none",C,nt,tt]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[w,nt,tt]}],"perspective-origin":[{"perspective-origin":_()}],rotate:[{rotate:ue()}],"rotate-x":[{"rotate-x":ue()}],"rotate-y":[{"rotate-y":ue()}],"rotate-z":[{"rotate-z":ue()}],scale:[{scale:ke()}],"scale-x":[{"scale-x":ke()}],"scale-y":[{"scale-y":ke()}],"scale-z":[{"scale-z":ke()}],"scale-3d":["scale-3d"],skew:[{skew:W()}],"skew-x":[{"skew-x":W()}],"skew-y":[{"skew-y":W()}],transform:[{transform:[nt,tt,"","none","gpu","cpu"]}],"transform-origin":[{origin:_()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:q()}],"translate-x":[{"translate-x":q()}],"translate-y":[{"translate-y":q()}],"translate-z":[{"translate-z":q()}],"translate-none":["translate-none"],accent:[{accent:D()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:D()}],"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",nt,tt]}],"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":L()}],"scroll-mx":[{"scroll-mx":L()}],"scroll-my":[{"scroll-my":L()}],"scroll-ms":[{"scroll-ms":L()}],"scroll-me":[{"scroll-me":L()}],"scroll-mt":[{"scroll-mt":L()}],"scroll-mr":[{"scroll-mr":L()}],"scroll-mb":[{"scroll-mb":L()}],"scroll-ml":[{"scroll-ml":L()}],"scroll-p":[{"scroll-p":L()}],"scroll-px":[{"scroll-px":L()}],"scroll-py":[{"scroll-py":L()}],"scroll-ps":[{"scroll-ps":L()}],"scroll-pe":[{"scroll-pe":L()}],"scroll-pt":[{"scroll-pt":L()}],"scroll-pr":[{"scroll-pr":L()}],"scroll-pb":[{"scroll-pb":L()}],"scroll-pl":[{"scroll-pl":L()}],"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",nt,tt]}],fill:[{fill:["none",...D()]}],"stroke-w":[{stroke:[Rt,bu,Oo,zg]}],stroke:[{stroke:["none",...D()]}],"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"]}},QA=IA(XA);function St(...t){return QA(RN(t))}function rn({className:t,...e}){return o.jsx("div",{"data-slot":"card",className:St("bg-card text-card-foreground flex flex-col gap-6 rounded-xl border",t),...e})}function br({className:t,...e}){return o.jsx("div",{"data-slot":"card-header",className:St("@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-1.5 px-6 pt-6 has-data-[slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-6",t),...e})}function kr({className:t,...e}){return o.jsx("h4",{"data-slot":"card-title",className:St("leading-none",t),...e})}function to({className:t,...e}){return o.jsx("p",{"data-slot":"card-description",className:St("text-muted-foreground",t),...e})}function on({className:t,...e}){return o.jsx("div",{"data-slot":"card-content",className:St("px-6 [&:last-child]:pb-6",t),...e})}function ZA({title:t,subtitle:e,icon:n,actions:r}){return o.jsxs("div",{className:"flex items-center justify-between mb-6",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[n&&o.jsx("span",{className:"text-primary",children:n}),o.jsxs("div",{children:[o.jsx("h1",{className:"text-2xl font-semibold text-foreground",children:t}),e&&o.jsx("p",{className:"text-sm text-muted-foreground mt-0.5",children:e})]})]}),r&&o.jsx("div",{className:"flex items-center gap-2",children:r})]})}function P1(t,e){if(typeof t=="function")return t(e);t!=null&&(t.current=e)}function $N(...t){return e=>{let n=!1;const r=t.map(i=>{const s=P1(i,e);return!n&&typeof s=="function"&&(n=!0),s});if(n)return()=>{for(let i=0;i<r.length;i++){const s=r[i];typeof s=="function"?s():P1(t[i],null)}}}}function sn(...t){return x.useCallback($N(...t),t)}var ao=x.forwardRef((t,e)=>{const{children:n,...r}=t,i=x.Children.toArray(n),s=i.find(eO);if(s){const a=s.props.children,c=i.map(h=>h===s?x.Children.count(a)>1?x.Children.only(null):x.isValidElement(a)?a.props.children:null:h);return o.jsx(sv,{...r,ref:e,children:x.isValidElement(a)?x.cloneElement(a,void 0,c):null})}return o.jsx(sv,{...r,ref:e,children:n})});ao.displayName="Slot";var sv=x.forwardRef((t,e)=>{const{children:n,...r}=t;if(x.isValidElement(n)){const i=nO(n),s=tO(r,n.props);return n.type!==x.Fragment&&(s.ref=e?$N(e,i):i),x.cloneElement(n,s)}return x.Children.count(n)>1?x.Children.only(null):null});sv.displayName="SlotClone";var VN=({children:t})=>o.jsx(o.Fragment,{children:t});function eO(t){return x.isValidElement(t)&&t.type===VN}function tO(t,e){const n={...e};for(const r in e){const i=t[r],s=e[r];/^on[A-Z]/.test(r)?i&&s?n[r]=(...c)=>{s(...c),i(...c)}:i&&(n[r]=i):r==="style"?n[r]={...i,...s}:r==="className"&&(n[r]=[i,s].filter(Boolean).join(" "))}return{...t,...n}}function nO(t){var r,i;let e=(r=Object.getOwnPropertyDescriptor(t.props,"ref"))==null?void 0:r.get,n=e&&"isReactWarning"in e&&e.isReactWarning;return n?t.ref:(e=(i=Object.getOwnPropertyDescriptor(t,"ref"))==null?void 0:i.get,n=e&&"isReactWarning"in e&&e.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}const _1=t=>typeof t=="boolean"?`${t}`:t===0?"0":t,R1=RN,WN=(t,e)=>n=>{var r;if((e==null?void 0:e.variants)==null)return R1(t,n==null?void 0:n.class,n==null?void 0:n.className);const{variants:i,defaultVariants:s}=e,a=Object.keys(i).map(d=>{const f=n==null?void 0:n[d],p=s==null?void 0:s[d];if(f===null)return null;const g=_1(f)||_1(p);return i[d][g]}),c=n&&Object.entries(n).reduce((d,f)=>{let[p,g]=f;return g===void 0||(d[p]=g),d},{}),h=e==null||(r=e.compoundVariants)===null||r===void 0?void 0:r.reduce((d,f)=>{let{class:p,className:g,...v}=f;return Object.entries(v).every(k=>{let[w,S]=k;return Array.isArray(S)?S.includes({...s,...c}[w]):{...s,...c}[w]===S})?[...d,p,g]:d},[]);return R1(t,a,h,n==null?void 0:n.class,n==null?void 0:n.className)},rO=WN("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 focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive transition-[color,box-shadow] overflow-hidden",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground [a&]:hover:bg-primary/90",secondary:"border-transparent bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90",destructive:"border-transparent bg-destructive text-white [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"}},defaultVariants:{variant:"default"}});function Kt({className:t,variant:e,asChild:n=!1,...r}){const i=n?ao:"span";return o.jsx(i,{"data-slot":"badge",className:St(rO({variant:e}),t),...r})}const I1={active:"bg-success/15 text-success border-success/30",completed:"bg-primary/15 text-primary border-primary/30",connected:"bg-success/15 text-success border-success/30",running:"bg-success/15 text-success border-success/30",enabled:"bg-success/15 text-success border-success/30",done:"bg-primary/15 text-primary border-primary/30",healthy:"bg-success/15 text-success border-success/30",paused:"bg-warning/15 text-warning border-warning/30",pending:"bg-warning/15 text-warning border-warning/30",assigned:"bg-warning/15 text-warning border-warning/30",working:"bg-warning/15 text-warning border-warning/30",starting:"bg-warning/15 text-warning border-warning/30",loading:"bg-warning/15 text-warning border-warning/30",failed:"bg-destructive/15 text-destructive border-destructive/30",error:"bg-destructive/15 text-destructive border-destructive/30",blocked:"bg-destructive/15 text-destructive border-destructive/30",disbanded:"bg-destructive/15 text-destructive border-destructive/30",stopped:"bg-destructive/15 text-destructive border-destructive/30",disabled:"bg-destructive/15 text-destructive border-destructive/30",idle:"bg-muted text-muted-foreground border-border",inactive:"bg-muted text-muted-foreground border-border",unknown:"bg-muted text-muted-foreground border-border",coding:"bg-info/15 text-info border-info/30",research:"bg-info/15 text-info border-info/30"};function iO({status:t,className:e}){const n=I1[t.toLowerCase()]||I1.unknown;return o.jsx(Kt,{variant:"outline",className:St("text-xs font-medium border",n,e),children:t})}const sO={primary:"text-primary",success:"text-success",warning:"text-warning",destructive:"text-destructive",info:"text-info"};function zh({icon:t,label:e,value:n,sub:r,color:i="primary"}){return o.jsx(rn,{className:"bg-card/50 border-border p-4",children:o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("div",{className:`${sO[i]} opacity-80`,children:t}),o.jsxs("div",{children:[o.jsx("p",{className:"text-xs text-muted-foreground",children:e}),o.jsx("p",{className:"text-xl font-semibold text-foreground",children:n}),r&&o.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:r})]})]})})}const aO={sm:"h-4 w-4",md:"h-6 w-6",lg:"h-8 w-8"};function oO({text:t,size:e="md"}){return o.jsxs("div",{className:"flex flex-col items-center justify-center py-12 gap-3",children:[o.jsx($t,{className:`${aO[e]} animate-spin text-primary`}),t&&o.jsx("p",{className:"text-sm text-muted-foreground",children:t})]})}function lO({icon:t,title:e,description:n,action:r}){return o.jsxs("div",{className:"flex flex-col items-center justify-center py-16 gap-3 text-center",children:[o.jsx("div",{className:"text-muted-foreground opacity-50",children:t}),o.jsx("h3",{className:"text-base font-medium text-foreground",children:e}),n&&o.jsx("p",{className:"text-sm text-muted-foreground max-w-md",children:n}),r&&o.jsx("div",{className:"mt-2",children:r})]})}var Sd=LT();const HN=up(Sd);function cO(t){if(typeof document>"u")return;let e=document.head||document.getElementsByTagName("head")[0],n=document.createElement("style");n.type="text/css",e.appendChild(n),n.styleSheet?n.styleSheet.cssText=t:n.appendChild(document.createTextNode(t))}const uO=t=>{switch(t){case"success":return fO;case"info":return mO;case"warning":return pO;case"error":return gO;default:return null}},dO=Array(12).fill(0),hO=({visible:t,className:e})=>Me.createElement("div",{className:["sonner-loading-wrapper",e].filter(Boolean).join(" "),"data-visible":t},Me.createElement("div",{className:"sonner-spinner"},dO.map((n,r)=>Me.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${r}`})))),fO=Me.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},Me.createElement("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z",clipRule:"evenodd"})),pO=Me.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},Me.createElement("path",{fillRule:"evenodd",d:"M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z",clipRule:"evenodd"})),mO=Me.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},Me.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z",clipRule:"evenodd"})),gO=Me.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},Me.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z",clipRule:"evenodd"})),vO=Me.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},Me.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),Me.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),yO=()=>{const[t,e]=Me.useState(document.hidden);return Me.useEffect(()=>{const n=()=>{e(document.hidden)};return document.addEventListener("visibilitychange",n),()=>window.removeEventListener("visibilitychange",n)},[]),t};let av=1;class xO{constructor(){this.subscribe=e=>(this.subscribers.push(e),()=>{const n=this.subscribers.indexOf(e);this.subscribers.splice(n,1)}),this.publish=e=>{this.subscribers.forEach(n=>n(e))},this.addToast=e=>{this.publish(e),this.toasts=[...this.toasts,e]},this.create=e=>{var n;const{message:r,...i}=e,s=typeof(e==null?void 0:e.id)=="number"||((n=e.id)==null?void 0:n.length)>0?e.id:av++,a=this.toasts.find(h=>h.id===s),c=e.dismissible===void 0?!0:e.dismissible;return this.dismissedToasts.has(s)&&this.dismissedToasts.delete(s),a?this.toasts=this.toasts.map(h=>h.id===s?(this.publish({...h,...e,id:s,title:r}),{...h,...e,id:s,dismissible:c,title:r}):h):this.addToast({title:r,...i,dismissible:c,id:s}),s},this.dismiss=e=>(e?(this.dismissedToasts.add(e),requestAnimationFrame(()=>this.subscribers.forEach(n=>n({id:e,dismiss:!0})))):this.toasts.forEach(n=>{this.subscribers.forEach(r=>r({id:n.id,dismiss:!0}))}),e),this.message=(e,n)=>this.create({...n,message:e}),this.error=(e,n)=>this.create({...n,message:e,type:"error"}),this.success=(e,n)=>this.create({...n,type:"success",message:e}),this.info=(e,n)=>this.create({...n,type:"info",message:e}),this.warning=(e,n)=>this.create({...n,type:"warning",message:e}),this.loading=(e,n)=>this.create({...n,type:"loading",message:e}),this.promise=(e,n)=>{if(!n)return;let r;n.loading!==void 0&&(r=this.create({...n,promise:e,type:"loading",message:n.loading,description:typeof n.description!="function"?n.description:void 0}));const i=Promise.resolve(e instanceof Function?e():e);let s=r!==void 0,a;const c=i.then(async d=>{if(a=["resolve",d],Me.isValidElement(d))s=!1,this.create({id:r,type:"default",message:d});else if(kO(d)&&!d.ok){s=!1;const p=typeof n.error=="function"?await n.error(`HTTP error! status: ${d.status}`):n.error,g=typeof n.description=="function"?await n.description(`HTTP error! status: ${d.status}`):n.description,k=typeof p=="object"&&!Me.isValidElement(p)?p:{message:p};this.create({id:r,type:"error",description:g,...k})}else if(d instanceof Error){s=!1;const p=typeof n.error=="function"?await n.error(d):n.error,g=typeof n.description=="function"?await n.description(d):n.description,k=typeof p=="object"&&!Me.isValidElement(p)?p:{message:p};this.create({id:r,type:"error",description:g,...k})}else if(n.success!==void 0){s=!1;const p=typeof n.success=="function"?await n.success(d):n.success,g=typeof n.description=="function"?await n.description(d):n.description,k=typeof p=="object"&&!Me.isValidElement(p)?p:{message:p};this.create({id:r,type:"success",description:g,...k})}}).catch(async d=>{if(a=["reject",d],n.error!==void 0){s=!1;const f=typeof n.error=="function"?await n.error(d):n.error,p=typeof n.description=="function"?await n.description(d):n.description,v=typeof f=="object"&&!Me.isValidElement(f)?f:{message:f};this.create({id:r,type:"error",description:p,...v})}}).finally(()=>{s&&(this.dismiss(r),r=void 0),n.finally==null||n.finally.call(n)}),h=()=>new Promise((d,f)=>c.then(()=>a[0]==="reject"?f(a[1]):d(a[1])).catch(f));return typeof r!="string"&&typeof r!="number"?{unwrap:h}:Object.assign(r,{unwrap:h})},this.custom=(e,n)=>{const r=(n==null?void 0:n.id)||av++;return this.create({jsx:e(r),id:r,...n}),r},this.getActiveToasts=()=>this.toasts.filter(e=>!this.dismissedToasts.has(e.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}}const Hr=new xO,bO=(t,e)=>{const n=(e==null?void 0:e.id)||av++;return Hr.addToast({title:t,...e,id:n}),n},kO=t=>t&&typeof t=="object"&&"ok"in t&&typeof t.ok=="boolean"&&"status"in t&&typeof t.status=="number",wO=bO,SO=()=>Hr.toasts,CO=()=>Hr.getActiveToasts(),me=Object.assign(wO,{success:Hr.success,info:Hr.info,warning:Hr.warning,error:Hr.error,custom:Hr.custom,message:Hr.message,promise:Hr.promise,dismiss:Hr.dismiss,loading:Hr.loading},{getHistory:SO,getToasts:CO});cO("[data-sonner-toaster][dir=ltr],html[dir=ltr]{--toast-icon-margin-start:-3px;--toast-icon-margin-end:4px;--toast-svg-margin-start:-1px;--toast-svg-margin-end:0px;--toast-button-margin-start:auto;--toast-button-margin-end:0;--toast-close-button-start:0;--toast-close-button-end:unset;--toast-close-button-transform:translate(-35%, -35%)}[data-sonner-toaster][dir=rtl],html[dir=rtl]{--toast-icon-margin-start:4px;--toast-icon-margin-end:-3px;--toast-svg-margin-start:0px;--toast-svg-margin-end:-1px;--toast-button-margin-start:0;--toast-button-margin-end:auto;--toast-close-button-start:unset;--toast-close-button-end:0;--toast-close-button-transform:translate(35%, -35%)}[data-sonner-toaster]{position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1:hsl(0, 0%, 99%);--gray2:hsl(0, 0%, 97.3%);--gray3:hsl(0, 0%, 95.1%);--gray4:hsl(0, 0%, 93%);--gray5:hsl(0, 0%, 90.9%);--gray6:hsl(0, 0%, 88.7%);--gray7:hsl(0, 0%, 85.8%);--gray8:hsl(0, 0%, 78%);--gray9:hsl(0, 0%, 56.1%);--gray10:hsl(0, 0%, 52.3%);--gray11:hsl(0, 0%, 43.5%);--gray12:hsl(0, 0%, 9%);--border-radius:8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:0;z-index:999999999;transition:transform .4s ease}[data-sonner-toaster][data-lifted=true]{transform:translateY(-8px)}@media (hover:none) and (pointer:coarse){[data-sonner-toaster][data-lifted=true]{transform:none}}[data-sonner-toaster][data-x-position=right]{right:var(--offset-right)}[data-sonner-toaster][data-x-position=left]{left:var(--offset-left)}[data-sonner-toaster][data-x-position=center]{left:50%;transform:translateX(-50%)}[data-sonner-toaster][data-y-position=top]{top:var(--offset-top)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--offset-bottom)}[data-sonner-toast]{--y:translateY(100%);--lift-amount:calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:0;overflow-wrap:anywhere}[data-sonner-toast][data-styled=true]{padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px rgba(0,0,0,.1);width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}[data-sonner-toast]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-y-position=top]{top:0;--y:translateY(-100%);--lift:1;--lift-amount:calc(1 * var(--gap))}[data-sonner-toast][data-y-position=bottom]{bottom:0;--y:translateY(100%);--lift:-1;--lift-amount:calc(var(--lift) * var(--gap))}[data-sonner-toast][data-styled=true] [data-description]{font-weight:400;line-height:1.4;color:#3f3f3f}[data-rich-colors=true][data-sonner-toast][data-styled=true] [data-description]{color:inherit}[data-sonner-toaster][data-sonner-theme=dark] [data-description]{color:#e8e8e8}[data-sonner-toast][data-styled=true] [data-title]{font-weight:500;line-height:1.5;color:inherit}[data-sonner-toast][data-styled=true] [data-icon]{display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}[data-sonner-toast][data-promise=true] [data-icon]>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}[data-sonner-toast][data-styled=true] [data-icon]>*{flex-shrink:0}[data-sonner-toast][data-styled=true] [data-icon] svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}[data-sonner-toast][data-styled=true] [data-content]{display:flex;flex-direction:column;gap:2px}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;font-weight:500;cursor:pointer;outline:0;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}[data-sonner-toast][data-styled=true] [data-button]:focus-visible{box-shadow:0 0 0 2px rgba(0,0,0,.4)}[data-sonner-toast][data-styled=true] [data-button]:first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}[data-sonner-toast][data-styled=true] [data-cancel]{color:var(--normal-text);background:rgba(0,0,0,.08)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-styled=true] [data-cancel]{background:rgba(255,255,255,.3)}[data-sonner-toast][data-styled=true] [data-close-button]{position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--gray12);background:var(--normal-bg);border:1px solid var(--gray4);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast][data-styled=true] [data-close-button]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-styled=true] [data-disabled=true]{cursor:not-allowed}[data-sonner-toast][data-styled=true]:hover [data-close-button]:hover{background:var(--gray2);border-color:var(--gray5)}[data-sonner-toast][data-swiping=true]::before{content:'';position:absolute;left:-100%;right:-100%;height:100%;z-index:-1}[data-sonner-toast][data-y-position=top][data-swiping=true]::before{bottom:50%;transform:scaleY(3) translateY(50%)}[data-sonner-toast][data-y-position=bottom][data-swiping=true]::before{top:50%;transform:scaleY(3) translateY(-50%)}[data-sonner-toast][data-swiping=false][data-removed=true]::before{content:'';position:absolute;inset:0;transform:scaleY(2)}[data-sonner-toast][data-expanded=true]::after{content:'';position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}[data-sonner-toast][data-mounted=true]{--y:translateY(0);opacity:1}[data-sonner-toast][data-expanded=false][data-front=false]{--scale:var(--toasts-before) * 0.05 + 1;--y:translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}[data-sonner-toast]>*{transition:opacity .4s}[data-sonner-toast][data-x-position=right]{right:0}[data-sonner-toast][data-x-position=left]{left:0}[data-sonner-toast][data-expanded=false][data-front=false][data-styled=true]>*{opacity:0}[data-sonner-toast][data-visible=false]{opacity:0;pointer-events:none}[data-sonner-toast][data-mounted=true][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}[data-sonner-toast][data-removed=true][data-front=true][data-swipe-out=false]{--y:translateY(calc(var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=false]{--y:translateY(40%);opacity:0;transition:transform .5s,opacity .2s}[data-sonner-toast][data-removed=true][data-front=false]::before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y,0)) translateX(var(--swipe-amount-x,0));transition:none}[data-sonner-toast][data-swiped=true]{user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width:600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-sonner-theme=light]{--normal-bg:#fff;--normal-border:var(--gray4);--normal-text:var(--gray12);--success-bg:hsl(143, 85%, 96%);--success-border:hsl(145, 92%, 87%);--success-text:hsl(140, 100%, 27%);--info-bg:hsl(208, 100%, 97%);--info-border:hsl(221, 91%, 93%);--info-text:hsl(210, 92%, 45%);--warning-bg:hsl(49, 100%, 97%);--warning-border:hsl(49, 91%, 84%);--warning-text:hsl(31, 92%, 45%);--error-bg:hsl(359, 100%, 97%);--error-border:hsl(359, 100%, 94%);--error-text:hsl(360, 100%, 45%)}[data-sonner-toaster][data-sonner-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg:#000;--normal-border:hsl(0, 0%, 20%);--normal-text:var(--gray1)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg:#fff;--normal-border:var(--gray3);--normal-text:var(--gray12)}[data-sonner-toaster][data-sonner-theme=dark]{--normal-bg:#000;--normal-bg-hover:hsl(0, 0%, 12%);--normal-border:hsl(0, 0%, 20%);--normal-border-hover:hsl(0, 0%, 25%);--normal-text:var(--gray1);--success-bg:hsl(150, 100%, 6%);--success-border:hsl(147, 100%, 12%);--success-text:hsl(150, 86%, 65%);--info-bg:hsl(215, 100%, 6%);--info-border:hsl(223, 43%, 17%);--info-text:hsl(216, 87%, 65%);--warning-bg:hsl(64, 100%, 6%);--warning-border:hsl(60, 100%, 9%);--warning-text:hsl(46, 87%, 65%);--error-bg:hsl(358, 76%, 10%);--error-border:hsl(357, 89%, 16%);--error-text:hsl(358, 100%, 81%)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size:16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:first-child{animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}100%{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}100%{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}100%{opacity:.15}}@media (prefers-reduced-motion){.sonner-loading-bar,[data-sonner-toast],[data-sonner-toast]>*{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)}");function $h(t){return t.label!==void 0}const TO=3,NO="24px",EO="16px",M1=4e3,jO=356,PO=14,_O=45,RO=200;function ms(...t){return t.filter(Boolean).join(" ")}function IO(t){const[e,n]=t.split("-"),r=[];return e&&r.push(e),n&&r.push(n),r}const MO=t=>{var e,n,r,i,s,a,c,h,d;const{invert:f,toast:p,unstyled:g,interacting:v,setHeights:k,visibleToasts:w,heights:S,index:T,toasts:C,expanded:j,removeToast:R,defaultRichColors:_,closeButton:I,style:M,cancelButtonStyle:L,actionButtonStyle:$,className:E="",descriptionClassName:P="",duration:V,position:F,gap:K,expandByDefault:J,classNames:Q,icons:Z,closeButtonAriaLabel:D="Close toast"}=t,[ne,A]=Me.useState(null),[z,ee]=Me.useState(null),[B,X]=Me.useState(!1),[ye,se]=Me.useState(!1),[oe,U]=Me.useState(!1),[ue,ke]=Me.useState(!1),[W,q]=Me.useState(!1),[fe,ve]=Me.useState(0),[Se,Ke]=Me.useState(0),dt=Me.useRef(p.duration||V||M1),Ge=Me.useRef(null),_e=Me.useRef(null),Ve=T===0,xt=T+1<=w,Pt=p.type,mn=p.dismissible!==!1,gn=p.className||"",jn=p.descriptionClassName||"",xe=Me.useMemo(()=>S.findIndex(be=>be.toastId===p.id)||0,[S,p.id]),Re=Me.useMemo(()=>{var be;return(be=p.closeButton)!=null?be:I},[p.closeButton,I]),Qe=Me.useMemo(()=>p.duration||V||M1,[p.duration,V]),He=Me.useRef(0),gt=Me.useRef(0),hn=Me.useRef(0),vn=Me.useRef(null),[Fn,pe]=F.split("-"),Ue=Me.useMemo(()=>S.reduce((be,We,Ct)=>Ct>=xe?be:be+We.height,0),[S,xe]),ze=yO(),Wt=p.invert||f,bt=Pt==="loading";gt.current=Me.useMemo(()=>xe*K+Ue,[xe,Ue]),Me.useEffect(()=>{dt.current=Qe},[Qe]),Me.useEffect(()=>{X(!0)},[]),Me.useEffect(()=>{const be=_e.current;if(be){const We=be.getBoundingClientRect().height;return Ke(We),k(Ct=>[{toastId:p.id,height:We,position:p.position},...Ct]),()=>k(Ct=>Ct.filter(ut=>ut.toastId!==p.id))}},[k,p.id]),Me.useLayoutEffect(()=>{if(!B)return;const be=_e.current,We=be.style.height;be.style.height="auto";const Ct=be.getBoundingClientRect().height;be.style.height=We,Ke(Ct),k(ut=>ut.find(kt=>kt.toastId===p.id)?ut.map(kt=>kt.toastId===p.id?{...kt,height:Ct}:kt):[{toastId:p.id,height:Ct,position:p.position},...ut])},[B,p.title,p.description,k,p.id]);const Tn=Me.useCallback(()=>{se(!0),ve(gt.current),k(be=>be.filter(We=>We.toastId!==p.id)),setTimeout(()=>{R(p)},RO)},[p,R,k,gt]);Me.useEffect(()=>{if(p.promise&&Pt==="loading"||p.duration===1/0||p.type==="loading")return;let be;return j||v||ze?(()=>{if(hn.current<He.current){const ut=new Date().getTime()-He.current;dt.current=dt.current-ut}hn.current=new Date().getTime()})():(()=>{dt.current!==1/0&&(He.current=new Date().getTime(),be=setTimeout(()=>{p.onAutoClose==null||p.onAutoClose.call(p,p),Tn()},dt.current))})(),()=>clearTimeout(be)},[j,v,p,Pt,ze,Tn]),Me.useEffect(()=>{p.delete&&Tn()},[Tn,p.delete]);function nn(){var be;if(Z!=null&&Z.loading){var We;return Me.createElement("div",{className:ms(Q==null?void 0:Q.loader,p==null||(We=p.classNames)==null?void 0:We.loader,"sonner-loader"),"data-visible":Pt==="loading"},Z.loading)}return Me.createElement(hO,{className:ms(Q==null?void 0:Q.loader,p==null||(be=p.classNames)==null?void 0:be.loader),visible:Pt==="loading"})}const Kn=p.icon||(Z==null?void 0:Z[Pt])||uO(Pt);var Mn,ce;return Me.createElement("li",{tabIndex:0,ref:_e,className:ms(E,gn,Q==null?void 0:Q.toast,p==null||(e=p.classNames)==null?void 0:e.toast,Q==null?void 0:Q.default,Q==null?void 0:Q[Pt],p==null||(n=p.classNames)==null?void 0:n[Pt]),"data-sonner-toast":"","data-rich-colors":(Mn=p.richColors)!=null?Mn:_,"data-styled":!(p.jsx||p.unstyled||g),"data-mounted":B,"data-promise":!!p.promise,"data-swiped":W,"data-removed":ye,"data-visible":xt,"data-y-position":Fn,"data-x-position":pe,"data-index":T,"data-front":Ve,"data-swiping":oe,"data-dismissible":mn,"data-type":Pt,"data-invert":Wt,"data-swipe-out":ue,"data-swipe-direction":z,"data-expanded":!!(j||J&&B),style:{"--index":T,"--toasts-before":T,"--z-index":C.length-T,"--offset":`${ye?fe:gt.current}px`,"--initial-height":J?"auto":`${Se}px`,...M,...p.style},onDragEnd:()=>{U(!1),A(null),vn.current=null},onPointerDown:be=>{bt||!mn||(Ge.current=new Date,ve(gt.current),be.target.setPointerCapture(be.pointerId),be.target.tagName!=="BUTTON"&&(U(!0),vn.current={x:be.clientX,y:be.clientY}))},onPointerUp:()=>{var be,We,Ct;if(ue||!mn)return;vn.current=null;const ut=Number(((be=_e.current)==null?void 0:be.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),Yt=Number(((We=_e.current)==null?void 0:We.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),kt=new Date().getTime()-((Ct=Ge.current)==null?void 0:Ct.getTime()),Bt=ne==="x"?ut:Yt,ln=Math.abs(Bt)/kt;if(Math.abs(Bt)>=_O||ln>.11){ve(gt.current),p.onDismiss==null||p.onDismiss.call(p,p),ee(ne==="x"?ut>0?"right":"left":Yt>0?"down":"up"),Tn(),ke(!0);return}else{var Y,re;(Y=_e.current)==null||Y.style.setProperty("--swipe-amount-x","0px"),(re=_e.current)==null||re.style.setProperty("--swipe-amount-y","0px")}q(!1),U(!1),A(null)},onPointerMove:be=>{var We,Ct,ut;if(!vn.current||!mn||((We=window.getSelection())==null?void 0:We.toString().length)>0)return;const kt=be.clientY-vn.current.y,Bt=be.clientX-vn.current.x;var ln;const Y=(ln=t.swipeDirections)!=null?ln:IO(F);!ne&&(Math.abs(Bt)>1||Math.abs(kt)>1)&&A(Math.abs(Bt)>Math.abs(kt)?"x":"y");let re={x:0,y:0};const de=Ce=>1/(1.5+Math.abs(Ce)/20);if(ne==="y"){if(Y.includes("top")||Y.includes("bottom"))if(Y.includes("top")&&kt<0||Y.includes("bottom")&&kt>0)re.y=kt;else{const Ce=kt*de(kt);re.y=Math.abs(Ce)<Math.abs(kt)?Ce:kt}}else if(ne==="x"&&(Y.includes("left")||Y.includes("right")))if(Y.includes("left")&&Bt<0||Y.includes("right")&&Bt>0)re.x=Bt;else{const Ce=Bt*de(Bt);re.x=Math.abs(Ce)<Math.abs(Bt)?Ce:Bt}(Math.abs(re.x)>0||Math.abs(re.y)>0)&&q(!0),(Ct=_e.current)==null||Ct.style.setProperty("--swipe-amount-x",`${re.x}px`),(ut=_e.current)==null||ut.style.setProperty("--swipe-amount-y",`${re.y}px`)}},Re&&!p.jsx&&Pt!=="loading"?Me.createElement("button",{"aria-label":D,"data-disabled":bt,"data-close-button":!0,onClick:bt||!mn?()=>{}:()=>{Tn(),p.onDismiss==null||p.onDismiss.call(p,p)},className:ms(Q==null?void 0:Q.closeButton,p==null||(r=p.classNames)==null?void 0:r.closeButton)},(ce=Z==null?void 0:Z.close)!=null?ce:vO):null,(Pt||p.icon||p.promise)&&p.icon!==null&&((Z==null?void 0:Z[Pt])!==null||p.icon)?Me.createElement("div",{"data-icon":"",className:ms(Q==null?void 0:Q.icon,p==null||(i=p.classNames)==null?void 0:i.icon)},p.promise||p.type==="loading"&&!p.icon?p.icon||nn():null,p.type!=="loading"?Kn:null):null,Me.createElement("div",{"data-content":"",className:ms(Q==null?void 0:Q.content,p==null||(s=p.classNames)==null?void 0:s.content)},Me.createElement("div",{"data-title":"",className:ms(Q==null?void 0:Q.title,p==null||(a=p.classNames)==null?void 0:a.title)},p.jsx?p.jsx:typeof p.title=="function"?p.title():p.title),p.description?Me.createElement("div",{"data-description":"",className:ms(P,jn,Q==null?void 0:Q.description,p==null||(c=p.classNames)==null?void 0:c.description)},typeof p.description=="function"?p.description():p.description):null),Me.isValidElement(p.cancel)?p.cancel:p.cancel&&$h(p.cancel)?Me.createElement("button",{"data-button":!0,"data-cancel":!0,style:p.cancelButtonStyle||L,onClick:be=>{$h(p.cancel)&&mn&&(p.cancel.onClick==null||p.cancel.onClick.call(p.cancel,be),Tn())},className:ms(Q==null?void 0:Q.cancelButton,p==null||(h=p.classNames)==null?void 0:h.cancelButton)},p.cancel.label):null,Me.isValidElement(p.action)?p.action:p.action&&$h(p.action)?Me.createElement("button",{"data-button":!0,"data-action":!0,style:p.actionButtonStyle||$,onClick:be=>{$h(p.action)&&(p.action.onClick==null||p.action.onClick.call(p.action,be),!be.defaultPrevented&&Tn())},className:ms(Q==null?void 0:Q.actionButton,p==null||(d=p.classNames)==null?void 0:d.actionButton)},p.action.label):null)};function D1(){if(typeof window>"u"||typeof document>"u")return"ltr";const t=document.documentElement.getAttribute("dir");return t==="auto"||!t?window.getComputedStyle(document.documentElement).direction:t}function DO(t,e){const n={};return[t,e].forEach((r,i)=>{const s=i===1,a=s?"--mobile-offset":"--offset",c=s?EO:NO;function h(d){["top","right","bottom","left"].forEach(f=>{n[`${a}-${f}`]=typeof d=="number"?`${d}px`:d})}typeof r=="number"||typeof r=="string"?h(r):typeof r=="object"?["top","right","bottom","left"].forEach(d=>{r[d]===void 0?n[`${a}-${d}`]=c:n[`${a}-${d}`]=typeof r[d]=="number"?`${r[d]}px`:r[d]}):h(c)}),n}const AO=Me.forwardRef(function(e,n){const{invert:r,position:i="bottom-right",hotkey:s=["altKey","KeyT"],expand:a,closeButton:c,className:h,offset:d,mobileOffset:f,theme:p="light",richColors:g,duration:v,style:k,visibleToasts:w=TO,toastOptions:S,dir:T=D1(),gap:C=PO,icons:j,containerAriaLabel:R="Notifications"}=e,[_,I]=Me.useState([]),M=Me.useMemo(()=>Array.from(new Set([i].concat(_.filter(z=>z.position).map(z=>z.position)))),[_,i]),[L,$]=Me.useState([]),[E,P]=Me.useState(!1),[V,F]=Me.useState(!1),[K,J]=Me.useState(p!=="system"?p:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),Q=Me.useRef(null),Z=s.join("+").replace(/Key/g,"").replace(/Digit/g,""),D=Me.useRef(null),ne=Me.useRef(!1),A=Me.useCallback(z=>{I(ee=>{var B;return(B=ee.find(X=>X.id===z.id))!=null&&B.delete||Hr.dismiss(z.id),ee.filter(({id:X})=>X!==z.id)})},[]);return Me.useEffect(()=>Hr.subscribe(z=>{if(z.dismiss){requestAnimationFrame(()=>{I(ee=>ee.map(B=>B.id===z.id?{...B,delete:!0}:B))});return}setTimeout(()=>{HN.flushSync(()=>{I(ee=>{const B=ee.findIndex(X=>X.id===z.id);return B!==-1?[...ee.slice(0,B),{...ee[B],...z},...ee.slice(B+1)]:[z,...ee]})})})}),[_]),Me.useEffect(()=>{if(p!=="system"){J(p);return}if(p==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?J("dark"):J("light")),typeof window>"u")return;const z=window.matchMedia("(prefers-color-scheme: dark)");try{z.addEventListener("change",({matches:ee})=>{J(ee?"dark":"light")})}catch{z.addListener(({matches:B})=>{try{J(B?"dark":"light")}catch(X){console.error(X)}})}},[p]),Me.useEffect(()=>{_.length<=1&&P(!1)},[_]),Me.useEffect(()=>{const z=ee=>{var B;if(s.every(se=>ee[se]||ee.code===se)){var ye;P(!0),(ye=Q.current)==null||ye.focus()}ee.code==="Escape"&&(document.activeElement===Q.current||(B=Q.current)!=null&&B.contains(document.activeElement))&&P(!1)};return document.addEventListener("keydown",z),()=>document.removeEventListener("keydown",z)},[s]),Me.useEffect(()=>{if(Q.current)return()=>{D.current&&(D.current.focus({preventScroll:!0}),D.current=null,ne.current=!1)}},[Q.current]),Me.createElement("section",{ref:n,"aria-label":`${R} ${Z}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},M.map((z,ee)=>{var B;const[X,ye]=z.split("-");return _.length?Me.createElement("ol",{key:z,dir:T==="auto"?D1():T,tabIndex:-1,ref:Q,className:h,"data-sonner-toaster":!0,"data-sonner-theme":K,"data-y-position":X,"data-lifted":E&&_.length>1&&!a,"data-x-position":ye,style:{"--front-toast-height":`${((B=L[0])==null?void 0:B.height)||0}px`,"--width":`${jO}px`,"--gap":`${C}px`,...k,...DO(d,f)},onBlur:se=>{ne.current&&!se.currentTarget.contains(se.relatedTarget)&&(ne.current=!1,D.current&&(D.current.focus({preventScroll:!0}),D.current=null))},onFocus:se=>{se.target instanceof HTMLElement&&se.target.dataset.dismissible==="false"||ne.current||(ne.current=!0,D.current=se.relatedTarget)},onMouseEnter:()=>P(!0),onMouseMove:()=>P(!0),onMouseLeave:()=>{V||P(!1)},onDragEnd:()=>P(!1),onPointerDown:se=>{se.target instanceof HTMLElement&&se.target.dataset.dismissible==="false"||F(!0)},onPointerUp:()=>F(!1)},_.filter(se=>!se.position&&ee===0||se.position===z).map((se,oe)=>{var U,ue;return Me.createElement(MO,{key:se.id,icons:j,index:oe,toast:se,defaultRichColors:g,duration:(U=S==null?void 0:S.duration)!=null?U:v,className:S==null?void 0:S.className,descriptionClassName:S==null?void 0:S.descriptionClassName,invert:r,visibleToasts:w,closeButton:(ue=S==null?void 0:S.closeButton)!=null?ue:c,interacting:V,position:z,style:S==null?void 0:S.style,unstyled:S==null?void 0:S.unstyled,classNames:S==null?void 0:S.classNames,cancelButtonStyle:S==null?void 0:S.cancelButtonStyle,actionButtonStyle:S==null?void 0:S.actionButtonStyle,closeButtonAriaLabel:S==null?void 0:S.closeButtonAriaLabel,removeToast:A,toasts:_.filter(ke=>ke.position==se.position),heights:L.filter(ke=>ke.position==se.position),setHeights:$,expandByDefault:a,gap:C,expanded:E,swipeDirections:e.swipeDirections})})):null}))});function OO(){var h,d,f;const[t,e]=x.useState(null),[n,r]=x.useState([]),[i,s]=x.useState(!0),a=async()=>{try{const[p,g]=await Promise.all([we("/api/health"),we("/api/tasks?limit=5&type=task")]);if(p.ok&&e(await p.json()),g.ok){const v=await g.json();r(v.tasks||[])}}catch{me.error("Failed to fetch dashboard data")}finally{s(!1)}};x.useEffect(()=>{a();const p=setInterval(a,1e4);return()=>clearInterval(p)},[]);const c=p=>{const g=Math.floor(p/3600),v=Math.floor(p%3600/60);return`${g}h ${v}m`};return i&&!t?o.jsx(oO,{text:"Loading dashboard..."}):o.jsxs("div",{className:"space-y-8",children:[o.jsx(ZA,{title:"Dashboard",subtitle:"System Overview"}),o.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4",children:[o.jsx(zh,{icon:(t==null?void 0:t.status)==="ok"?o.jsx(_i,{className:"w-7 h-7"}):o.jsx(Zi,{className:"w-7 h-7"}),label:"System Status",value:(t==null?void 0:t.status)==="ok"?"Healthy":"Offline",sub:`Uptime: ${t?c(t.uptime):"0h 0m"}`,color:(t==null?void 0:t.status)==="ok"?"success":"destructive"}),o.jsx(zh,{icon:o.jsx(y1,{className:"w-7 h-7"}),label:"Active Tasks",value:((h=t==null?void 0:t.queue)==null?void 0:h.running)||0,sub:`of ${((d=t==null?void 0:t.queue)==null?void 0:d.total)||0} total`,color:"primary"}),o.jsx(zh,{icon:o.jsx(ha,{className:"w-7 h-7"}),label:"Tools Loaded",value:(t==null?void 0:t.tools)||0,sub:"available",color:"info"}),o.jsx(zh,{icon:o.jsx(_i,{className:"w-7 h-7"}),label:"Daily Spend",value:`$${((f=t==null?void 0:t.todayCost)==null?void 0:f.toFixed(2))||"0.00"}`,sub:"USD today",color:"primary"})]}),o.jsxs(rn,{className:"bg-card/50 border-border",children:[o.jsx(br,{children:o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{children:[o.jsx(kr,{className:"text-foreground",children:"Recent Activity"}),o.jsx(to,{className:"text-muted-foreground text-xs",children:"Latest tasks"})]}),o.jsx(al,{to:"/tasks",className:"text-sm text-primary hover:text-secondary transition-colors font-medium",children:"View all →"})]})}),o.jsx(on,{children:o.jsx("div",{className:"space-y-3",children:n.length===0?o.jsx(lO,{icon:o.jsx(y1,{className:"w-10 h-10"}),title:"No tasks yet",description:"Tasks will appear here as they're processed."}):n.map(p=>o.jsxs("div",{className:"flex items-center justify-between p-3 bg-muted/30 rounded-lg border border-border hover:border-primary/30 transition-all group",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[p.status==="running"?o.jsx(es,{className:"w-4 h-4 text-warning animate-pulse"}):p.status==="completed"?o.jsx(_i,{className:"w-4 h-4 text-success"}):o.jsx(Zi,{className:"w-4 h-4 text-destructive"}),o.jsxs("div",{children:[o.jsx("div",{className:"text-sm font-medium text-foreground truncate max-w-[300px] group-hover:text-primary transition-colors",children:p.title||p.input}),o.jsxs("div",{className:"text-xs text-muted-foreground",children:[p.agentCreated?"agent":p.channel," · ",new Date(p.createdAt).toLocaleString()]})]})]}),o.jsx(iO,{status:p.status})]},p.id))})})]})]})}function LO({className:t,...e}){return o.jsx("textarea",{"data-slot":"textarea",className:St("resize-none border-input placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 flex field-sizing-content min-h-16 w-full rounded-md border bg-input-background px-3 py-2 text-base transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",t),...e})}var FO=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","span","svg","ul"],_t=FO.reduce((t,e)=>{const n=x.forwardRef((r,i)=>{const{asChild:s,...a}=r,c=s?ao:e;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),o.jsx(c,{...a,ref:i})});return n.displayName=`Primitive.${e}`,{...t,[e]:n}},{});function UO(t,e){t&&Sd.flushSync(()=>t.dispatchEvent(e))}var Tr=globalThis!=null&&globalThis.document?x.useLayoutEffect:()=>{};function BO(t,e){return x.useReducer((n,r)=>e[n][r]??n,t)}var ga=t=>{const{present:e,children:n}=t,r=zO(e),i=typeof n=="function"?n({present:r.isPresent}):x.Children.only(n),s=sn(r.ref,$O(i));return typeof n=="function"||r.isPresent?x.cloneElement(i,{ref:s}):null};ga.displayName="Presence";function zO(t){const[e,n]=x.useState(),r=x.useRef({}),i=x.useRef(t),s=x.useRef("none"),a=t?"mounted":"unmounted",[c,h]=BO(a,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return x.useEffect(()=>{const d=Vh(r.current);s.current=c==="mounted"?d:"none"},[c]),Tr(()=>{const d=r.current,f=i.current;if(f!==t){const g=s.current,v=Vh(d);t?h("MOUNT"):v==="none"||(d==null?void 0:d.display)==="none"?h("UNMOUNT"):h(f&&g!==v?"ANIMATION_OUT":"UNMOUNT"),i.current=t}},[t,h]),Tr(()=>{if(e){let d;const f=e.ownerDocument.defaultView??window,p=v=>{const w=Vh(r.current).includes(v.animationName);if(v.target===e&&w&&(h("ANIMATION_END"),!i.current)){const S=e.style.animationFillMode;e.style.animationFillMode="forwards",d=f.setTimeout(()=>{e.style.animationFillMode==="forwards"&&(e.style.animationFillMode=S)})}},g=v=>{v.target===e&&(s.current=Vh(r.current))};return e.addEventListener("animationstart",g),e.addEventListener("animationcancel",p),e.addEventListener("animationend",p),()=>{f.clearTimeout(d),e.removeEventListener("animationstart",g),e.removeEventListener("animationcancel",p),e.removeEventListener("animationend",p)}}else h("ANIMATION_END")},[e,h]),{isPresent:["mounted","unmountSuspended"].includes(c),ref:x.useCallback(d=>{d&&(r.current=getComputedStyle(d)),n(d)},[])}}function Vh(t){return(t==null?void 0:t.animationName)||"none"}function $O(t){var r,i;let e=(r=Object.getOwnPropertyDescriptor(t.props,"ref"))==null?void 0:r.get,n=e&&"isReactWarning"in e&&e.isReactWarning;return n?t.ref:(e=(i=Object.getOwnPropertyDescriptor(t,"ref"))==null?void 0:i.get,n=e&&"isReactWarning"in e&&e.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}function VO(t,e){const n=x.createContext(e),r=s=>{const{children:a,...c}=s,h=x.useMemo(()=>c,Object.values(c));return o.jsx(n.Provider,{value:h,children:a})};r.displayName=t+"Provider";function i(s){const a=x.useContext(n);if(a)return a;if(e!==void 0)return e;throw new Error(`\`${s}\` must be used within \`${t}\``)}return[r,i]}function Us(t,e=[]){let n=[];function r(s,a){const c=x.createContext(a),h=n.length;n=[...n,a];const d=p=>{var T;const{scope:g,children:v,...k}=p,w=((T=g==null?void 0:g[t])==null?void 0:T[h])||c,S=x.useMemo(()=>k,Object.values(k));return o.jsx(w.Provider,{value:S,children:v})};d.displayName=s+"Provider";function f(p,g){var w;const v=((w=g==null?void 0:g[t])==null?void 0:w[h])||c,k=x.useContext(v);if(k)return k;if(a!==void 0)return a;throw new Error(`\`${p}\` must be used within \`${s}\``)}return[d,f]}const i=()=>{const s=n.map(a=>x.createContext(a));return function(c){const h=(c==null?void 0:c[t])||s;return x.useMemo(()=>({[`__scope${t}`]:{...c,[t]:h}}),[c,h])}};return i.scopeName=t,[r,WO(i,...e)]}function WO(...t){const e=t[0];if(t.length===1)return e;const n=()=>{const r=t.map(i=>({useScope:i(),scopeName:i.scopeName}));return function(s){const a=r.reduce((c,{useScope:h,scopeName:d})=>{const p=h(s)[`__scope${d}`];return{...c,...p}},{});return x.useMemo(()=>({[`__scope${e.scopeName}`]:a}),[a])}};return n.scopeName=e.scopeName,n}function hr(t){const e=x.useRef(t);return x.useEffect(()=>{e.current=t}),x.useMemo(()=>(...n)=>{var r;return(r=e.current)==null?void 0:r.call(e,...n)},[])}var HO=x.createContext(void 0);function mp(t){const e=x.useContext(HO);return t||e||"ltr"}function ov(t,[e,n]){return Math.min(n,Math.max(e,t))}function Et(t,e,{checkForDefaultPrevented:n=!0}={}){return function(i){if(t==null||t(i),n===!1||!i.defaultPrevented)return e==null?void 0:e(i)}}function qO(t,e){return x.useReducer((n,r)=>e[n][r]??n,t)}var jy="ScrollArea",[qN]=Us(jy),[KO,Mi]=qN(jy),KN=x.forwardRef((t,e)=>{const{__scopeScrollArea:n,type:r="hover",dir:i,scrollHideDelay:s=600,...a}=t,[c,h]=x.useState(null),[d,f]=x.useState(null),[p,g]=x.useState(null),[v,k]=x.useState(null),[w,S]=x.useState(null),[T,C]=x.useState(0),[j,R]=x.useState(0),[_,I]=x.useState(!1),[M,L]=x.useState(!1),$=sn(e,P=>h(P)),E=mp(i);return o.jsx(KO,{scope:n,type:r,dir:E,scrollHideDelay:s,scrollArea:c,viewport:d,onViewportChange:f,content:p,onContentChange:g,scrollbarX:v,onScrollbarXChange:k,scrollbarXEnabled:_,onScrollbarXEnabledChange:I,scrollbarY:w,onScrollbarYChange:S,scrollbarYEnabled:M,onScrollbarYEnabledChange:L,onCornerWidthChange:C,onCornerHeightChange:R,children:o.jsx(_t.div,{dir:E,...a,ref:$,style:{position:"relative","--radix-scroll-area-corner-width":T+"px","--radix-scroll-area-corner-height":j+"px",...t.style}})})});KN.displayName=jy;var GN="ScrollAreaViewport",YN=x.forwardRef((t,e)=>{const{__scopeScrollArea:n,children:r,nonce:i,...s}=t,a=Mi(GN,n),c=x.useRef(null),h=sn(e,c,a.onViewportChange);return o.jsxs(o.Fragment,{children:[o.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}"},nonce:i}),o.jsx(_t.div,{"data-radix-scroll-area-viewport":"",...s,ref:h,style:{overflowX:a.scrollbarXEnabled?"scroll":"hidden",overflowY:a.scrollbarYEnabled?"scroll":"hidden",...t.style},children:o.jsx("div",{ref:a.onContentChange,style:{minWidth:"100%",display:"table"},children:r})})]})});YN.displayName=GN;var Bs="ScrollAreaScrollbar",JN=x.forwardRef((t,e)=>{const{forceMount:n,...r}=t,i=Mi(Bs,t.__scopeScrollArea),{onScrollbarXEnabledChange:s,onScrollbarYEnabledChange:a}=i,c=t.orientation==="horizontal";return x.useEffect(()=>(c?s(!0):a(!0),()=>{c?s(!1):a(!1)}),[c,s,a]),i.type==="hover"?o.jsx(GO,{...r,ref:e,forceMount:n}):i.type==="scroll"?o.jsx(YO,{...r,ref:e,forceMount:n}):i.type==="auto"?o.jsx(XN,{...r,ref:e,forceMount:n}):i.type==="always"?o.jsx(Py,{...r,ref:e}):null});JN.displayName=Bs;var GO=x.forwardRef((t,e)=>{const{forceMount:n,...r}=t,i=Mi(Bs,t.__scopeScrollArea),[s,a]=x.useState(!1);return x.useEffect(()=>{const c=i.scrollArea;let h=0;if(c){const d=()=>{window.clearTimeout(h),a(!0)},f=()=>{h=window.setTimeout(()=>a(!1),i.scrollHideDelay)};return c.addEventListener("pointerenter",d),c.addEventListener("pointerleave",f),()=>{window.clearTimeout(h),c.removeEventListener("pointerenter",d),c.removeEventListener("pointerleave",f)}}},[i.scrollArea,i.scrollHideDelay]),o.jsx(ga,{present:n||s,children:o.jsx(XN,{"data-state":s?"visible":"hidden",...r,ref:e})})}),YO=x.forwardRef((t,e)=>{const{forceMount:n,...r}=t,i=Mi(Bs,t.__scopeScrollArea),s=t.orientation==="horizontal",a=vp(()=>h("SCROLL_END"),100),[c,h]=qO("hidden",{hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}});return x.useEffect(()=>{if(c==="idle"){const d=window.setTimeout(()=>h("HIDE"),i.scrollHideDelay);return()=>window.clearTimeout(d)}},[c,i.scrollHideDelay,h]),x.useEffect(()=>{const d=i.viewport,f=s?"scrollLeft":"scrollTop";if(d){let p=d[f];const g=()=>{const v=d[f];p!==v&&(h("SCROLL"),a()),p=v};return d.addEventListener("scroll",g),()=>d.removeEventListener("scroll",g)}},[i.viewport,s,h,a]),o.jsx(ga,{present:n||c!=="hidden",children:o.jsx(Py,{"data-state":c==="hidden"?"hidden":"visible",...r,ref:e,onPointerEnter:Et(t.onPointerEnter,()=>h("POINTER_ENTER")),onPointerLeave:Et(t.onPointerLeave,()=>h("POINTER_LEAVE"))})})}),XN=x.forwardRef((t,e)=>{const n=Mi(Bs,t.__scopeScrollArea),{forceMount:r,...i}=t,[s,a]=x.useState(!1),c=t.orientation==="horizontal",h=vp(()=>{if(n.viewport){const d=n.viewport.offsetWidth<n.viewport.scrollWidth,f=n.viewport.offsetHeight<n.viewport.scrollHeight;a(c?d:f)}},10);return yc(n.viewport,h),yc(n.content,h),o.jsx(ga,{present:r||s,children:o.jsx(Py,{"data-state":s?"visible":"hidden",...i,ref:e})})}),Py=x.forwardRef((t,e)=>{const{orientation:n="vertical",...r}=t,i=Mi(Bs,t.__scopeScrollArea),s=x.useRef(null),a=x.useRef(0),[c,h]=x.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),d=nE(c.viewport,c.content),f={...r,sizes:c,onSizesChange:h,hasThumb:d>0&&d<1,onThumbChange:g=>s.current=g,onThumbPointerUp:()=>a.current=0,onThumbPointerDown:g=>a.current=g};function p(g,v){return tL(g,a.current,c,v)}return n==="horizontal"?o.jsx(JO,{...f,ref:e,onThumbPositionChange:()=>{if(i.viewport&&s.current){const g=i.viewport.scrollLeft,v=A1(g,c,i.dir);s.current.style.transform=`translate3d(${v}px, 0, 0)`}},onWheelScroll:g=>{i.viewport&&(i.viewport.scrollLeft=g)},onDragScroll:g=>{i.viewport&&(i.viewport.scrollLeft=p(g,i.dir))}}):n==="vertical"?o.jsx(XO,{...f,ref:e,onThumbPositionChange:()=>{if(i.viewport&&s.current){const g=i.viewport.scrollTop,v=A1(g,c);s.current.style.transform=`translate3d(0, ${v}px, 0)`}},onWheelScroll:g=>{i.viewport&&(i.viewport.scrollTop=g)},onDragScroll:g=>{i.viewport&&(i.viewport.scrollTop=p(g))}}):null}),JO=x.forwardRef((t,e)=>{const{sizes:n,onSizesChange:r,...i}=t,s=Mi(Bs,t.__scopeScrollArea),[a,c]=x.useState(),h=x.useRef(null),d=sn(e,h,s.onScrollbarXChange);return x.useEffect(()=>{h.current&&c(getComputedStyle(h.current))},[h]),o.jsx(ZN,{"data-orientation":"horizontal",...i,ref:d,sizes:n,style:{bottom:0,left:s.dir==="rtl"?"var(--radix-scroll-area-corner-width)":0,right:s.dir==="ltr"?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":gp(n)+"px",...t.style},onThumbPointerDown:f=>t.onThumbPointerDown(f.x),onDragScroll:f=>t.onDragScroll(f.x),onWheelScroll:(f,p)=>{if(s.viewport){const g=s.viewport.scrollLeft+f.deltaX;t.onWheelScroll(g),iE(g,p)&&f.preventDefault()}},onResize:()=>{h.current&&s.viewport&&a&&r({content:s.viewport.scrollWidth,viewport:s.viewport.offsetWidth,scrollbar:{size:h.current.clientWidth,paddingStart:Af(a.paddingLeft),paddingEnd:Af(a.paddingRight)}})}})}),XO=x.forwardRef((t,e)=>{const{sizes:n,onSizesChange:r,...i}=t,s=Mi(Bs,t.__scopeScrollArea),[a,c]=x.useState(),h=x.useRef(null),d=sn(e,h,s.onScrollbarYChange);return x.useEffect(()=>{h.current&&c(getComputedStyle(h.current))},[h]),o.jsx(ZN,{"data-orientation":"vertical",...i,ref:d,sizes:n,style:{top:0,right:s.dir==="ltr"?0:void 0,left:s.dir==="rtl"?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":gp(n)+"px",...t.style},onThumbPointerDown:f=>t.onThumbPointerDown(f.y),onDragScroll:f=>t.onDragScroll(f.y),onWheelScroll:(f,p)=>{if(s.viewport){const g=s.viewport.scrollTop+f.deltaY;t.onWheelScroll(g),iE(g,p)&&f.preventDefault()}},onResize:()=>{h.current&&s.viewport&&a&&r({content:s.viewport.scrollHeight,viewport:s.viewport.offsetHeight,scrollbar:{size:h.current.clientHeight,paddingStart:Af(a.paddingTop),paddingEnd:Af(a.paddingBottom)}})}})}),[QO,QN]=qN(Bs),ZN=x.forwardRef((t,e)=>{const{__scopeScrollArea:n,sizes:r,hasThumb:i,onThumbChange:s,onThumbPointerUp:a,onThumbPointerDown:c,onThumbPositionChange:h,onDragScroll:d,onWheelScroll:f,onResize:p,...g}=t,v=Mi(Bs,n),[k,w]=x.useState(null),S=sn(e,$=>w($)),T=x.useRef(null),C=x.useRef(""),j=v.viewport,R=r.content-r.viewport,_=hr(f),I=hr(h),M=vp(p,10);function L($){if(T.current){const E=$.clientX-T.current.left,P=$.clientY-T.current.top;d({x:E,y:P})}}return x.useEffect(()=>{const $=E=>{const P=E.target;(k==null?void 0:k.contains(P))&&_(E,R)};return document.addEventListener("wheel",$,{passive:!1}),()=>document.removeEventListener("wheel",$,{passive:!1})},[j,k,R,_]),x.useEffect(I,[r,I]),yc(k,M),yc(v.content,M),o.jsx(QO,{scope:n,scrollbar:k,hasThumb:i,onThumbChange:hr(s),onThumbPointerUp:hr(a),onThumbPositionChange:I,onThumbPointerDown:hr(c),children:o.jsx(_t.div,{...g,ref:S,style:{position:"absolute",...g.style},onPointerDown:Et(t.onPointerDown,$=>{$.button===0&&($.target.setPointerCapture($.pointerId),T.current=k.getBoundingClientRect(),C.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",v.viewport&&(v.viewport.style.scrollBehavior="auto"),L($))}),onPointerMove:Et(t.onPointerMove,L),onPointerUp:Et(t.onPointerUp,$=>{const E=$.target;E.hasPointerCapture($.pointerId)&&E.releasePointerCapture($.pointerId),document.body.style.webkitUserSelect=C.current,v.viewport&&(v.viewport.style.scrollBehavior=""),T.current=null})})})}),Df="ScrollAreaThumb",eE=x.forwardRef((t,e)=>{const{forceMount:n,...r}=t,i=QN(Df,t.__scopeScrollArea);return o.jsx(ga,{present:n||i.hasThumb,children:o.jsx(ZO,{ref:e,...r})})}),ZO=x.forwardRef((t,e)=>{const{__scopeScrollArea:n,style:r,...i}=t,s=Mi(Df,n),a=QN(Df,n),{onThumbPositionChange:c}=a,h=sn(e,p=>a.onThumbChange(p)),d=x.useRef(void 0),f=vp(()=>{d.current&&(d.current(),d.current=void 0)},100);return x.useEffect(()=>{const p=s.viewport;if(p){const g=()=>{if(f(),!d.current){const v=nL(p,c);d.current=v,c()}};return c(),p.addEventListener("scroll",g),()=>p.removeEventListener("scroll",g)}},[s.viewport,f,c]),o.jsx(_t.div,{"data-state":a.hasThumb?"visible":"hidden",...i,ref:h,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...r},onPointerDownCapture:Et(t.onPointerDownCapture,p=>{const v=p.target.getBoundingClientRect(),k=p.clientX-v.left,w=p.clientY-v.top;a.onThumbPointerDown({x:k,y:w})}),onPointerUp:Et(t.onPointerUp,a.onThumbPointerUp)})});eE.displayName=Df;var _y="ScrollAreaCorner",tE=x.forwardRef((t,e)=>{const n=Mi(_y,t.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&r?o.jsx(eL,{...t,ref:e}):null});tE.displayName=_y;var eL=x.forwardRef((t,e)=>{const{__scopeScrollArea:n,...r}=t,i=Mi(_y,n),[s,a]=x.useState(0),[c,h]=x.useState(0),d=!!(s&&c);return yc(i.scrollbarX,()=>{var p;const f=((p=i.scrollbarX)==null?void 0:p.offsetHeight)||0;i.onCornerHeightChange(f),h(f)}),yc(i.scrollbarY,()=>{var p;const f=((p=i.scrollbarY)==null?void 0:p.offsetWidth)||0;i.onCornerWidthChange(f),a(f)}),d?o.jsx(_t.div,{...r,ref:e,style:{width:s,height:c,position:"absolute",right:i.dir==="ltr"?0:void 0,left:i.dir==="rtl"?0:void 0,bottom:0,...t.style}}):null});function Af(t){return t?parseInt(t,10):0}function nE(t,e){const n=t/e;return isNaN(n)?0:n}function gp(t){const e=nE(t.viewport,t.content),n=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,r=(t.scrollbar.size-n)*e;return Math.max(r,18)}function tL(t,e,n,r="ltr"){const i=gp(n),s=i/2,a=e||s,c=i-a,h=n.scrollbar.paddingStart+a,d=n.scrollbar.size-n.scrollbar.paddingEnd-c,f=n.content-n.viewport,p=r==="ltr"?[0,f]:[f*-1,0];return rE([h,d],p)(t)}function A1(t,e,n="ltr"){const r=gp(e),i=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,s=e.scrollbar.size-i,a=e.content-e.viewport,c=s-r,h=n==="ltr"?[0,a]:[a*-1,0],d=ov(t,h);return rE([0,a],[0,c])(d)}function rE(t,e){return n=>{if(t[0]===t[1]||e[0]===e[1])return e[0];const r=(e[1]-e[0])/(t[1]-t[0]);return e[0]+r*(n-t[0])}}function iE(t,e){return t>0&&t<e}var nL=(t,e=()=>{})=>{let n={left:t.scrollLeft,top:t.scrollTop},r=0;return(function i(){const s={left:t.scrollLeft,top:t.scrollTop},a=n.left!==s.left,c=n.top!==s.top;(a||c)&&e(),n=s,r=window.requestAnimationFrame(i)})(),()=>window.cancelAnimationFrame(r)};function vp(t,e){const n=hr(t),r=x.useRef(0);return x.useEffect(()=>()=>window.clearTimeout(r.current),[]),x.useCallback(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(n,e)},[n,e])}function yc(t,e){const n=hr(e);Tr(()=>{let r=0;if(t){const i=new ResizeObserver(()=>{cancelAnimationFrame(r),r=window.requestAnimationFrame(n)});return i.observe(t),()=>{window.cancelAnimationFrame(r),i.unobserve(t)}}},[t,n])}var rL=KN,iL=YN,sL=tE;function sE({className:t,children:e,...n}){return o.jsxs(rL,{"data-slot":"scroll-area",className:St("relative overflow-hidden",t),...n,children:[o.jsx(iL,{"data-slot":"scroll-area-viewport",className:"focus-visible:ring-ring/50 size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:outline-1",children:e}),o.jsx(aL,{}),o.jsx(sL,{})]})}function aL({className:t,orientation:e="vertical",...n}){return o.jsx(JN,{"data-slot":"scroll-area-scrollbar",orientation:e,className:St("flex touch-none p-px transition-colors select-none",e==="vertical"&&"h-full w-2.5 border-l border-l-transparent",e==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent",t),...n,children:o.jsx(eE,{"data-slot":"scroll-area-thumb",className:"bg-border relative flex-1 rounded-full"})})}var oL=FT.useId||(()=>{}),lL=0;function no(t){const[e,n]=x.useState(oL());return Tr(()=>{n(r=>r??String(lL++))},[t]),t||(e?`radix-${e}`:"")}function xc({prop:t,defaultProp:e,onChange:n=()=>{}}){const[r,i]=cL({defaultProp:e,onChange:n}),s=t!==void 0,a=s?t:r,c=hr(n),h=x.useCallback(d=>{if(s){const p=typeof d=="function"?d(t):d;p!==t&&c(p)}else i(d)},[s,t,i,c]);return[a,h]}function cL({defaultProp:t,onChange:e}){const n=x.useState(t),[r]=n,i=x.useRef(r),s=hr(e);return x.useEffect(()=>{i.current!==r&&(s(r),i.current=r)},[r,i,s]),n}function uL(t,e=globalThis==null?void 0:globalThis.document){const n=hr(t);x.useEffect(()=>{const r=i=>{i.key==="Escape"&&n(i)};return e.addEventListener("keydown",r,{capture:!0}),()=>e.removeEventListener("keydown",r,{capture:!0})},[n,e])}var dL="DismissableLayer",lv="dismissableLayer.update",hL="dismissableLayer.pointerDownOutside",fL="dismissableLayer.focusOutside",O1,aE=x.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Ry=x.forwardRef((t,e)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:i,onFocusOutside:s,onInteractOutside:a,onDismiss:c,...h}=t,d=x.useContext(aE),[f,p]=x.useState(null),g=(f==null?void 0:f.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,v]=x.useState({}),k=sn(e,M=>p(M)),w=Array.from(d.layers),[S]=[...d.layersWithOutsidePointerEventsDisabled].slice(-1),T=w.indexOf(S),C=f?w.indexOf(f):-1,j=d.layersWithOutsidePointerEventsDisabled.size>0,R=C>=T,_=gL(M=>{const L=M.target,$=[...d.branches].some(E=>E.contains(L));!R||$||(i==null||i(M),a==null||a(M),M.defaultPrevented||c==null||c())},g),I=vL(M=>{const L=M.target;[...d.branches].some(E=>E.contains(L))||(s==null||s(M),a==null||a(M),M.defaultPrevented||c==null||c())},g);return uL(M=>{C===d.layers.size-1&&(r==null||r(M),!M.defaultPrevented&&c&&(M.preventDefault(),c()))},g),x.useEffect(()=>{if(f)return n&&(d.layersWithOutsidePointerEventsDisabled.size===0&&(O1=g.body.style.pointerEvents,g.body.style.pointerEvents="none"),d.layersWithOutsidePointerEventsDisabled.add(f)),d.layers.add(f),L1(),()=>{n&&d.layersWithOutsidePointerEventsDisabled.size===1&&(g.body.style.pointerEvents=O1)}},[f,g,n,d]),x.useEffect(()=>()=>{f&&(d.layers.delete(f),d.layersWithOutsidePointerEventsDisabled.delete(f),L1())},[f,d]),x.useEffect(()=>{const M=()=>v({});return document.addEventListener(lv,M),()=>document.removeEventListener(lv,M)},[]),o.jsx(_t.div,{...h,ref:k,style:{pointerEvents:j?R?"auto":"none":void 0,...t.style},onFocusCapture:Et(t.onFocusCapture,I.onFocusCapture),onBlurCapture:Et(t.onBlurCapture,I.onBlurCapture),onPointerDownCapture:Et(t.onPointerDownCapture,_.onPointerDownCapture)})});Ry.displayName=dL;var pL="DismissableLayerBranch",mL=x.forwardRef((t,e)=>{const n=x.useContext(aE),r=x.useRef(null),i=sn(e,r);return x.useEffect(()=>{const s=r.current;if(s)return n.branches.add(s),()=>{n.branches.delete(s)}},[n.branches]),o.jsx(_t.div,{...t,ref:i})});mL.displayName=pL;function gL(t,e=globalThis==null?void 0:globalThis.document){const n=hr(t),r=x.useRef(!1),i=x.useRef(()=>{});return x.useEffect(()=>{const s=c=>{if(c.target&&!r.current){let h=function(){oE(hL,n,d,{discrete:!0})};const d={originalEvent:c};c.pointerType==="touch"?(e.removeEventListener("click",i.current),i.current=h,e.addEventListener("click",i.current,{once:!0})):h()}else e.removeEventListener("click",i.current);r.current=!1},a=window.setTimeout(()=>{e.addEventListener("pointerdown",s)},0);return()=>{window.clearTimeout(a),e.removeEventListener("pointerdown",s),e.removeEventListener("click",i.current)}},[e,n]),{onPointerDownCapture:()=>r.current=!0}}function vL(t,e=globalThis==null?void 0:globalThis.document){const n=hr(t),r=x.useRef(!1);return x.useEffect(()=>{const i=s=>{s.target&&!r.current&&oE(fL,n,{originalEvent:s},{discrete:!1})};return e.addEventListener("focusin",i),()=>e.removeEventListener("focusin",i)},[e,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function L1(){const t=new CustomEvent(lv);document.dispatchEvent(t)}function oE(t,e,n,{discrete:r}){const i=n.originalEvent.target,s=new CustomEvent(t,{bubbles:!1,cancelable:!0,detail:n});e&&i.addEventListener(t,e,{once:!0}),r?UO(i,s):i.dispatchEvent(s)}var $g="focusScope.autoFocusOnMount",Vg="focusScope.autoFocusOnUnmount",F1={bubbles:!1,cancelable:!0},yL="FocusScope",Iy=x.forwardRef((t,e)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:i,onUnmountAutoFocus:s,...a}=t,[c,h]=x.useState(null),d=hr(i),f=hr(s),p=x.useRef(null),g=sn(e,w=>h(w)),v=x.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;x.useEffect(()=>{if(r){let w=function(j){if(v.paused||!c)return;const R=j.target;c.contains(R)?p.current=R:Ka(p.current,{select:!0})},S=function(j){if(v.paused||!c)return;const R=j.relatedTarget;R!==null&&(c.contains(R)||Ka(p.current,{select:!0}))},T=function(j){if(document.activeElement===document.body)for(const _ of j)_.removedNodes.length>0&&Ka(c)};document.addEventListener("focusin",w),document.addEventListener("focusout",S);const C=new MutationObserver(T);return c&&C.observe(c,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",w),document.removeEventListener("focusout",S),C.disconnect()}}},[r,c,v.paused]),x.useEffect(()=>{if(c){B1.add(v);const w=document.activeElement;if(!c.contains(w)){const T=new CustomEvent($g,F1);c.addEventListener($g,d),c.dispatchEvent(T),T.defaultPrevented||(xL(CL(lE(c)),{select:!0}),document.activeElement===w&&Ka(c))}return()=>{c.removeEventListener($g,d),setTimeout(()=>{const T=new CustomEvent(Vg,F1);c.addEventListener(Vg,f),c.dispatchEvent(T),T.defaultPrevented||Ka(w??document.body,{select:!0}),c.removeEventListener(Vg,f),B1.remove(v)},0)}}},[c,d,f,v]);const k=x.useCallback(w=>{if(!n&&!r||v.paused)return;const S=w.key==="Tab"&&!w.altKey&&!w.ctrlKey&&!w.metaKey,T=document.activeElement;if(S&&T){const C=w.currentTarget,[j,R]=bL(C);j&&R?!w.shiftKey&&T===R?(w.preventDefault(),n&&Ka(j,{select:!0})):w.shiftKey&&T===j&&(w.preventDefault(),n&&Ka(R,{select:!0})):T===C&&w.preventDefault()}},[n,r,v.paused]);return o.jsx(_t.div,{tabIndex:-1,...a,ref:g,onKeyDown:k})});Iy.displayName=yL;function xL(t,{select:e=!1}={}){const n=document.activeElement;for(const r of t)if(Ka(r,{select:e}),document.activeElement!==n)return}function bL(t){const e=lE(t),n=U1(e,t),r=U1(e.reverse(),t);return[n,r]}function lE(t){const e=[],n=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const i=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||i?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)e.push(n.currentNode);return e}function U1(t,e){for(const n of t)if(!kL(n,{upTo:e}))return n}function kL(t,{upTo:e}){if(getComputedStyle(t).visibility==="hidden")return!0;for(;t;){if(e!==void 0&&t===e)return!1;if(getComputedStyle(t).display==="none")return!0;t=t.parentElement}return!1}function wL(t){return t instanceof HTMLInputElement&&"select"in t}function Ka(t,{select:e=!1}={}){if(t&&t.focus){const n=document.activeElement;t.focus({preventScroll:!0}),t!==n&&wL(t)&&e&&t.select()}}var B1=SL();function SL(){let t=[];return{add(e){const n=t[0];e!==n&&(n==null||n.pause()),t=z1(t,e),t.unshift(e)},remove(e){var n;t=z1(t,e),(n=t[0])==null||n.resume()}}}function z1(t,e){const n=[...t],r=n.indexOf(e);return r!==-1&&n.splice(r,1),n}function CL(t){return t.filter(e=>e.tagName!=="A")}var TL="Portal",My=x.forwardRef((t,e)=>{var c;const{container:n,...r}=t,[i,s]=x.useState(!1);Tr(()=>s(!0),[]);const a=n||i&&((c=globalThis==null?void 0:globalThis.document)==null?void 0:c.body);return a?HN.createPortal(o.jsx(_t.div,{...r,ref:e}),a):null});My.displayName=TL;var Wg=0;function cE(){x.useEffect(()=>{const t=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",t[0]??$1()),document.body.insertAdjacentElement("beforeend",t[1]??$1()),Wg++,()=>{Wg===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(e=>e.remove()),Wg--}},[])}function $1(){const t=document.createElement("span");return t.setAttribute("data-radix-focus-guard",""),t.tabIndex=0,t.style.outline="none",t.style.opacity="0",t.style.position="fixed",t.style.pointerEvents="none",t}var xs=function(){return xs=Object.assign||function(e){for(var n,r=1,i=arguments.length;r<i;r++){n=arguments[r];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(e[s]=n[s])}return e},xs.apply(this,arguments)};function uE(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,r=Object.getOwnPropertySymbols(t);i<r.length;i++)e.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(t,r[i])&&(n[r[i]]=t[r[i]]);return n}function NL(t,e,n){if(n||arguments.length===2)for(var r=0,i=e.length,s;r<i;r++)(s||!(r in e))&&(s||(s=Array.prototype.slice.call(e,0,r)),s[r]=e[r]);return t.concat(s||Array.prototype.slice.call(e))}var hf="right-scroll-bar-position",ff="width-before-scroll-bar",EL="with-scroll-bars-hidden",jL="--removed-body-scroll-bar-size";function Hg(t,e){return typeof t=="function"?t(e):t&&(t.current=e),t}function PL(t,e){var n=x.useState(function(){return{value:t,callback:e,facade:{get current(){return n.value},set current(r){var i=n.value;i!==r&&(n.value=r,n.callback(r,i))}}}})[0];return n.callback=e,n.facade}var _L=typeof window<"u"?x.useLayoutEffect:x.useEffect,V1=new WeakMap;function RL(t,e){var n=PL(null,function(r){return t.forEach(function(i){return Hg(i,r)})});return _L(function(){var r=V1.get(n);if(r){var i=new Set(r),s=new Set(t),a=n.current;i.forEach(function(c){s.has(c)||Hg(c,null)}),s.forEach(function(c){i.has(c)||Hg(c,a)})}V1.set(n,t)},[t]),n}function IL(t){return t}function ML(t,e){e===void 0&&(e=IL);var n=[],r=!1,i={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]:t},useMedium:function(s){var a=e(s,r);return n.push(a),function(){n=n.filter(function(c){return c!==a})}},assignSyncMedium:function(s){for(r=!0;n.length;){var a=n;n=[],a.forEach(s)}n={push:function(c){return s(c)},filter:function(){return n}}},assignMedium:function(s){r=!0;var a=[];if(n.length){var c=n;n=[],c.forEach(s),a=n}var h=function(){var f=a;a=[],f.forEach(s)},d=function(){return Promise.resolve().then(h)};d(),n={push:function(f){a.push(f),d()},filter:function(f){return a=a.filter(f),n}}}};return i}function DL(t){t===void 0&&(t={});var e=ML(null);return e.options=xs({async:!0,ssr:!1},t),e}var dE=function(t){var e=t.sideCar,n=uE(t,["sideCar"]);if(!e)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=e.read();if(!r)throw new Error("Sidecar medium not found");return x.createElement(r,xs({},n))};dE.isSideCarExport=!0;function AL(t,e){return t.useMedium(e),dE}var hE=DL(),qg=function(){},yp=x.forwardRef(function(t,e){var n=x.useRef(null),r=x.useState({onScrollCapture:qg,onWheelCapture:qg,onTouchMoveCapture:qg}),i=r[0],s=r[1],a=t.forwardProps,c=t.children,h=t.className,d=t.removeScrollBar,f=t.enabled,p=t.shards,g=t.sideCar,v=t.noRelative,k=t.noIsolation,w=t.inert,S=t.allowPinchZoom,T=t.as,C=T===void 0?"div":T,j=t.gapMode,R=uE(t,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),_=g,I=RL([n,e]),M=xs(xs({},R),i);return x.createElement(x.Fragment,null,f&&x.createElement(_,{sideCar:hE,removeScrollBar:d,shards:p,noRelative:v,noIsolation:k,inert:w,setCallbacks:s,allowPinchZoom:!!S,lockRef:n,gapMode:j}),a?x.cloneElement(x.Children.only(c),xs(xs({},M),{ref:I})):x.createElement(C,xs({},M,{className:h,ref:I}),c))});yp.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};yp.classNames={fullWidth:ff,zeroRight:hf};var OL=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function LL(){if(!document)return null;var t=document.createElement("style");t.type="text/css";var e=OL();return e&&t.setAttribute("nonce",e),t}function FL(t,e){t.styleSheet?t.styleSheet.cssText=e:t.appendChild(document.createTextNode(e))}function UL(t){var e=document.head||document.getElementsByTagName("head")[0];e.appendChild(t)}var BL=function(){var t=0,e=null;return{add:function(n){t==0&&(e=LL())&&(FL(e,n),UL(e)),t++},remove:function(){t--,!t&&e&&(e.parentNode&&e.parentNode.removeChild(e),e=null)}}},zL=function(){var t=BL();return function(e,n){x.useEffect(function(){return t.add(e),function(){t.remove()}},[e&&n])}},fE=function(){var t=zL(),e=function(n){var r=n.styles,i=n.dynamic;return t(r,i),null};return e},$L={left:0,top:0,right:0,gap:0},Kg=function(t){return parseInt(t||"",10)||0},VL=function(t){var e=window.getComputedStyle(document.body),n=e[t==="padding"?"paddingLeft":"marginLeft"],r=e[t==="padding"?"paddingTop":"marginTop"],i=e[t==="padding"?"paddingRight":"marginRight"];return[Kg(n),Kg(r),Kg(i)]},WL=function(t){if(t===void 0&&(t="margin"),typeof window>"u")return $L;var e=VL(t),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:e[0],top:e[1],right:e[2],gap:Math.max(0,r-n+e[2]-e[0])}},HL=fE(),ac="data-scroll-locked",qL=function(t,e,n,r){var i=t.left,s=t.top,a=t.right,c=t.gap;return n===void 0&&(n="margin"),`
448
+ .`.concat(EL,` {
449
+ overflow: hidden `).concat(r,`;
450
+ padding-right: `).concat(c,"px ").concat(r,`;
451
+ }
452
+ body[`).concat(ac,`] {
453
+ overflow: hidden `).concat(r,`;
454
+ overscroll-behavior: contain;
455
+ `).concat([e&&"position: relative ".concat(r,";"),n==="margin"&&`
456
+ padding-left: `.concat(i,`px;
457
+ padding-top: `).concat(s,`px;
458
+ padding-right: `).concat(a,`px;
459
+ margin-left:0;
460
+ margin-top:0;
461
+ margin-right: `).concat(c,"px ").concat(r,`;
462
+ `),n==="padding"&&"padding-right: ".concat(c,"px ").concat(r,";")].filter(Boolean).join(""),`
463
+ }
464
+
465
+ .`).concat(hf,` {
466
+ right: `).concat(c,"px ").concat(r,`;
467
+ }
468
+
469
+ .`).concat(ff,` {
470
+ margin-right: `).concat(c,"px ").concat(r,`;
471
+ }
472
+
473
+ .`).concat(hf," .").concat(hf,` {
474
+ right: 0 `).concat(r,`;
475
+ }
476
+
477
+ .`).concat(ff," .").concat(ff,` {
478
+ margin-right: 0 `).concat(r,`;
479
+ }
480
+
481
+ body[`).concat(ac,`] {
482
+ `).concat(jL,": ").concat(c,`px;
483
+ }
484
+ `)},W1=function(){var t=parseInt(document.body.getAttribute(ac)||"0",10);return isFinite(t)?t:0},KL=function(){x.useEffect(function(){return document.body.setAttribute(ac,(W1()+1).toString()),function(){var t=W1()-1;t<=0?document.body.removeAttribute(ac):document.body.setAttribute(ac,t.toString())}},[])},GL=function(t){var e=t.noRelative,n=t.noImportant,r=t.gapMode,i=r===void 0?"margin":r;KL();var s=x.useMemo(function(){return WL(i)},[i]);return x.createElement(HL,{styles:qL(s,!e,i,n?"":"!important")})},cv=!1;if(typeof window<"u")try{var Wh=Object.defineProperty({},"passive",{get:function(){return cv=!0,!0}});window.addEventListener("test",Wh,Wh),window.removeEventListener("test",Wh,Wh)}catch{cv=!1}var Wl=cv?{passive:!1}:!1,YL=function(t){return t.tagName==="TEXTAREA"},pE=function(t,e){if(!(t instanceof Element))return!1;var n=window.getComputedStyle(t);return n[e]!=="hidden"&&!(n.overflowY===n.overflowX&&!YL(t)&&n[e]==="visible")},JL=function(t){return pE(t,"overflowY")},XL=function(t){return pE(t,"overflowX")},H1=function(t,e){var n=e.ownerDocument,r=e;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var i=mE(t,r);if(i){var s=gE(t,r),a=s[1],c=s[2];if(a>c)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},QL=function(t){var e=t.scrollTop,n=t.scrollHeight,r=t.clientHeight;return[e,n,r]},ZL=function(t){var e=t.scrollLeft,n=t.scrollWidth,r=t.clientWidth;return[e,n,r]},mE=function(t,e){return t==="v"?JL(e):XL(e)},gE=function(t,e){return t==="v"?QL(e):ZL(e)},e8=function(t,e){return t==="h"&&e==="rtl"?-1:1},t8=function(t,e,n,r,i){var s=e8(t,window.getComputedStyle(e).direction),a=s*r,c=n.target,h=e.contains(c),d=!1,f=a>0,p=0,g=0;do{if(!c)break;var v=gE(t,c),k=v[0],w=v[1],S=v[2],T=w-S-s*k;(k||T)&&mE(t,c)&&(p+=T,g+=k);var C=c.parentNode;c=C&&C.nodeType===Node.DOCUMENT_FRAGMENT_NODE?C.host:C}while(!h&&c!==document.body||h&&(e.contains(c)||e===c));return(f&&Math.abs(p)<1||!f&&Math.abs(g)<1)&&(d=!0),d},Hh=function(t){return"changedTouches"in t?[t.changedTouches[0].clientX,t.changedTouches[0].clientY]:[0,0]},q1=function(t){return[t.deltaX,t.deltaY]},K1=function(t){return t&&"current"in t?t.current:t},n8=function(t,e){return t[0]===e[0]&&t[1]===e[1]},r8=function(t){return`
485
+ .block-interactivity-`.concat(t,` {pointer-events: none;}
486
+ .allow-interactivity-`).concat(t,` {pointer-events: all;}
487
+ `)},i8=0,Hl=[];function s8(t){var e=x.useRef([]),n=x.useRef([0,0]),r=x.useRef(),i=x.useState(i8++)[0],s=x.useState(fE)[0],a=x.useRef(t);x.useEffect(function(){a.current=t},[t]),x.useEffect(function(){if(t.inert){document.body.classList.add("block-interactivity-".concat(i));var w=NL([t.lockRef.current],(t.shards||[]).map(K1),!0).filter(Boolean);return w.forEach(function(S){return S.classList.add("allow-interactivity-".concat(i))}),function(){document.body.classList.remove("block-interactivity-".concat(i)),w.forEach(function(S){return S.classList.remove("allow-interactivity-".concat(i))})}}},[t.inert,t.lockRef.current,t.shards]);var c=x.useCallback(function(w,S){if("touches"in w&&w.touches.length===2||w.type==="wheel"&&w.ctrlKey)return!a.current.allowPinchZoom;var T=Hh(w),C=n.current,j="deltaX"in w?w.deltaX:C[0]-T[0],R="deltaY"in w?w.deltaY:C[1]-T[1],_,I=w.target,M=Math.abs(j)>Math.abs(R)?"h":"v";if("touches"in w&&M==="h"&&I.type==="range")return!1;var L=window.getSelection(),$=L&&L.anchorNode,E=$?$===I||$.contains(I):!1;if(E)return!1;var P=H1(M,I);if(!P)return!0;if(P?_=M:(_=M==="v"?"h":"v",P=H1(M,I)),!P)return!1;if(!r.current&&"changedTouches"in w&&(j||R)&&(r.current=_),!_)return!0;var V=r.current||_;return t8(V,S,w,V==="h"?j:R)},[]),h=x.useCallback(function(w){var S=w;if(!(!Hl.length||Hl[Hl.length-1]!==s)){var T="deltaY"in S?q1(S):Hh(S),C=e.current.filter(function(_){return _.name===S.type&&(_.target===S.target||S.target===_.shadowParent)&&n8(_.delta,T)})[0];if(C&&C.should){S.cancelable&&S.preventDefault();return}if(!C){var j=(a.current.shards||[]).map(K1).filter(Boolean).filter(function(_){return _.contains(S.target)}),R=j.length>0?c(S,j[0]):!a.current.noIsolation;R&&S.cancelable&&S.preventDefault()}}},[]),d=x.useCallback(function(w,S,T,C){var j={name:w,delta:S,target:T,should:C,shadowParent:a8(T)};e.current.push(j),setTimeout(function(){e.current=e.current.filter(function(R){return R!==j})},1)},[]),f=x.useCallback(function(w){n.current=Hh(w),r.current=void 0},[]),p=x.useCallback(function(w){d(w.type,q1(w),w.target,c(w,t.lockRef.current))},[]),g=x.useCallback(function(w){d(w.type,Hh(w),w.target,c(w,t.lockRef.current))},[]);x.useEffect(function(){return Hl.push(s),t.setCallbacks({onScrollCapture:p,onWheelCapture:p,onTouchMoveCapture:g}),document.addEventListener("wheel",h,Wl),document.addEventListener("touchmove",h,Wl),document.addEventListener("touchstart",f,Wl),function(){Hl=Hl.filter(function(w){return w!==s}),document.removeEventListener("wheel",h,Wl),document.removeEventListener("touchmove",h,Wl),document.removeEventListener("touchstart",f,Wl)}},[]);var v=t.removeScrollBar,k=t.inert;return x.createElement(x.Fragment,null,k?x.createElement(s,{styles:r8(i)}):null,v?x.createElement(GL,{noRelative:t.noRelative,gapMode:t.gapMode}):null)}function a8(t){for(var e=null;t!==null;)t instanceof ShadowRoot&&(e=t.host,t=t.host),t=t.parentNode;return e}const o8=AL(hE,s8);var Dy=x.forwardRef(function(t,e){return x.createElement(yp,xs({},t,{ref:e,sideCar:o8}))});Dy.classNames=yp.classNames;var l8=function(t){if(typeof document>"u")return null;var e=Array.isArray(t)?t[0]:t;return e.ownerDocument.body},ql=new WeakMap,qh=new WeakMap,Kh={},Gg=0,vE=function(t){return t&&(t.host||vE(t.parentNode))},c8=function(t,e){return e.map(function(n){if(t.contains(n))return n;var r=vE(n);return r&&t.contains(r)?r:(console.error("aria-hidden",n,"in not contained inside",t,". Doing nothing"),null)}).filter(function(n){return!!n})},u8=function(t,e,n,r){var i=c8(e,Array.isArray(t)?t:[t]);Kh[n]||(Kh[n]=new WeakMap);var s=Kh[n],a=[],c=new Set,h=new Set(i),d=function(p){!p||c.has(p)||(c.add(p),d(p.parentNode))};i.forEach(d);var f=function(p){!p||h.has(p)||Array.prototype.forEach.call(p.children,function(g){if(c.has(g))f(g);else try{var v=g.getAttribute(r),k=v!==null&&v!=="false",w=(ql.get(g)||0)+1,S=(s.get(g)||0)+1;ql.set(g,w),s.set(g,S),a.push(g),w===1&&k&&qh.set(g,!0),S===1&&g.setAttribute(n,"true"),k||g.setAttribute(r,"true")}catch(T){console.error("aria-hidden: cannot operate on ",g,T)}})};return f(e),c.clear(),Gg++,function(){a.forEach(function(p){var g=ql.get(p)-1,v=s.get(p)-1;ql.set(p,g),s.set(p,v),g||(qh.has(p)||p.removeAttribute(r),qh.delete(p)),v||p.removeAttribute(n)}),Gg--,Gg||(ql=new WeakMap,ql=new WeakMap,qh=new WeakMap,Kh={})}},yE=function(t,e,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(t)?t:[t]),i=l8(t);return i?(r.push.apply(r,Array.from(i.querySelectorAll("[aria-live], script"))),u8(r,i,n,"aria-hidden")):function(){return null}},Ay="Dialog",[xE,bE]=Us(Ay),[d8,cs]=xE(Ay),kE=t=>{const{__scopeDialog:e,children:n,open:r,defaultOpen:i,onOpenChange:s,modal:a=!0}=t,c=x.useRef(null),h=x.useRef(null),[d=!1,f]=xc({prop:r,defaultProp:i,onChange:s});return o.jsx(d8,{scope:e,triggerRef:c,contentRef:h,contentId:no(),titleId:no(),descriptionId:no(),open:d,onOpenChange:f,onOpenToggle:x.useCallback(()=>f(p=>!p),[f]),modal:a,children:n})};kE.displayName=Ay;var wE="DialogTrigger",SE=x.forwardRef((t,e)=>{const{__scopeDialog:n,...r}=t,i=cs(wE,n),s=sn(e,i.triggerRef);return o.jsx(_t.button,{type:"button","aria-haspopup":"dialog","aria-expanded":i.open,"aria-controls":i.contentId,"data-state":Fy(i.open),...r,ref:s,onClick:Et(t.onClick,i.onOpenToggle)})});SE.displayName=wE;var Oy="DialogPortal",[h8,CE]=xE(Oy,{forceMount:void 0}),TE=t=>{const{__scopeDialog:e,forceMount:n,children:r,container:i}=t,s=cs(Oy,e);return o.jsx(h8,{scope:e,forceMount:n,children:x.Children.map(r,a=>o.jsx(ga,{present:n||s.open,children:o.jsx(My,{asChild:!0,container:i,children:a})}))})};TE.displayName=Oy;var Of="DialogOverlay",NE=x.forwardRef((t,e)=>{const n=CE(Of,t.__scopeDialog),{forceMount:r=n.forceMount,...i}=t,s=cs(Of,t.__scopeDialog);return s.modal?o.jsx(ga,{present:r||s.open,children:o.jsx(f8,{...i,ref:e})}):null});NE.displayName=Of;var f8=x.forwardRef((t,e)=>{const{__scopeDialog:n,...r}=t,i=cs(Of,n);return o.jsx(Dy,{as:ao,allowPinchZoom:!0,shards:[i.contentRef],children:o.jsx(_t.div,{"data-state":Fy(i.open),...r,ref:e,style:{pointerEvents:"auto",...r.style}})})}),ll="DialogContent",EE=x.forwardRef((t,e)=>{const n=CE(ll,t.__scopeDialog),{forceMount:r=n.forceMount,...i}=t,s=cs(ll,t.__scopeDialog);return o.jsx(ga,{present:r||s.open,children:s.modal?o.jsx(p8,{...i,ref:e}):o.jsx(m8,{...i,ref:e})})});EE.displayName=ll;var p8=x.forwardRef((t,e)=>{const n=cs(ll,t.__scopeDialog),r=x.useRef(null),i=sn(e,n.contentRef,r);return x.useEffect(()=>{const s=r.current;if(s)return yE(s)},[]),o.jsx(jE,{...t,ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Et(t.onCloseAutoFocus,s=>{var a;s.preventDefault(),(a=n.triggerRef.current)==null||a.focus()}),onPointerDownOutside:Et(t.onPointerDownOutside,s=>{const a=s.detail.originalEvent,c=a.button===0&&a.ctrlKey===!0;(a.button===2||c)&&s.preventDefault()}),onFocusOutside:Et(t.onFocusOutside,s=>s.preventDefault())})}),m8=x.forwardRef((t,e)=>{const n=cs(ll,t.__scopeDialog),r=x.useRef(!1),i=x.useRef(!1);return o.jsx(jE,{...t,ref:e,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:s=>{var a,c;(a=t.onCloseAutoFocus)==null||a.call(t,s),s.defaultPrevented||(r.current||(c=n.triggerRef.current)==null||c.focus(),s.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:s=>{var h,d;(h=t.onInteractOutside)==null||h.call(t,s),s.defaultPrevented||(r.current=!0,s.detail.originalEvent.type==="pointerdown"&&(i.current=!0));const a=s.target;((d=n.triggerRef.current)==null?void 0:d.contains(a))&&s.preventDefault(),s.detail.originalEvent.type==="focusin"&&i.current&&s.preventDefault()}})}),jE=x.forwardRef((t,e)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:s,...a}=t,c=cs(ll,n),h=x.useRef(null),d=sn(e,h);return cE(),o.jsxs(o.Fragment,{children:[o.jsx(Iy,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:s,children:o.jsx(Ry,{role:"dialog",id:c.contentId,"aria-describedby":c.descriptionId,"aria-labelledby":c.titleId,"data-state":Fy(c.open),...a,ref:d,onDismiss:()=>c.onOpenChange(!1)})}),o.jsxs(o.Fragment,{children:[o.jsx(v8,{titleId:c.titleId}),o.jsx(x8,{contentRef:h,descriptionId:c.descriptionId})]})]})}),Ly="DialogTitle",PE=x.forwardRef((t,e)=>{const{__scopeDialog:n,...r}=t,i=cs(Ly,n);return o.jsx(_t.h2,{id:i.titleId,...r,ref:e})});PE.displayName=Ly;var _E="DialogDescription",RE=x.forwardRef((t,e)=>{const{__scopeDialog:n,...r}=t,i=cs(_E,n);return o.jsx(_t.p,{id:i.descriptionId,...r,ref:e})});RE.displayName=_E;var IE="DialogClose",ME=x.forwardRef((t,e)=>{const{__scopeDialog:n,...r}=t,i=cs(IE,n);return o.jsx(_t.button,{type:"button",...r,ref:e,onClick:Et(t.onClick,()=>i.onOpenChange(!1))})});ME.displayName=IE;function Fy(t){return t?"open":"closed"}var DE="DialogTitleWarning",[g8,AE]=VO(DE,{contentName:ll,titleName:Ly,docsSlug:"dialog"}),v8=({titleId:t})=>{const e=AE(DE),n=`\`${e.contentName}\` requires a \`${e.titleName}\` for the component to be accessible for screen reader users.
488
+
489
+ If you want to hide the \`${e.titleName}\`, you can wrap it with our VisuallyHidden component.
490
+
491
+ For more information, see https://radix-ui.com/primitives/docs/components/${e.docsSlug}`;return x.useEffect(()=>{t&&(document.getElementById(t)||console.error(n))},[n,t]),null},y8="DialogDescriptionWarning",x8=({contentRef:t,descriptionId:e})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${AE(y8).contentName}}.`;return x.useEffect(()=>{var s;const i=(s=t.current)==null?void 0:s.getAttribute("aria-describedby");e&&i&&(document.getElementById(e)||console.warn(r))},[r,t,e]),null},OE=kE,LE=SE,FE=TE,UE=NE,BE=EE,zE=PE,$E=RE,Uy=ME,VE="AlertDialog",[b8]=Us(VE,[bE]),va=bE(),WE=t=>{const{__scopeAlertDialog:e,...n}=t,r=va(e);return o.jsx(OE,{...r,...n,modal:!0})};WE.displayName=VE;var k8="AlertDialogTrigger",w8=x.forwardRef((t,e)=>{const{__scopeAlertDialog:n,...r}=t,i=va(n);return o.jsx(LE,{...i,...r,ref:e})});w8.displayName=k8;var S8="AlertDialogPortal",HE=t=>{const{__scopeAlertDialog:e,...n}=t,r=va(e);return o.jsx(FE,{...r,...n})};HE.displayName=S8;var C8="AlertDialogOverlay",qE=x.forwardRef((t,e)=>{const{__scopeAlertDialog:n,...r}=t,i=va(n);return o.jsx(UE,{...i,...r,ref:e})});qE.displayName=C8;var oc="AlertDialogContent",[T8,N8]=b8(oc),KE=x.forwardRef((t,e)=>{const{__scopeAlertDialog:n,children:r,...i}=t,s=va(n),a=x.useRef(null),c=sn(e,a),h=x.useRef(null);return o.jsx(g8,{contentName:oc,titleName:GE,docsSlug:"alert-dialog",children:o.jsx(T8,{scope:n,cancelRef:h,children:o.jsxs(BE,{role:"alertdialog",...s,...i,ref:c,onOpenAutoFocus:Et(i.onOpenAutoFocus,d=>{var f;d.preventDefault(),(f=h.current)==null||f.focus({preventScroll:!0})}),onPointerDownOutside:d=>d.preventDefault(),onInteractOutside:d=>d.preventDefault(),children:[o.jsx(VN,{children:r}),o.jsx(j8,{contentRef:a})]})})})});KE.displayName=oc;var GE="AlertDialogTitle",YE=x.forwardRef((t,e)=>{const{__scopeAlertDialog:n,...r}=t,i=va(n);return o.jsx(zE,{...i,...r,ref:e})});YE.displayName=GE;var JE="AlertDialogDescription",XE=x.forwardRef((t,e)=>{const{__scopeAlertDialog:n,...r}=t,i=va(n);return o.jsx($E,{...i,...r,ref:e})});XE.displayName=JE;var E8="AlertDialogAction",QE=x.forwardRef((t,e)=>{const{__scopeAlertDialog:n,...r}=t,i=va(n);return o.jsx(Uy,{...i,...r,ref:e})});QE.displayName=E8;var ZE="AlertDialogCancel",ej=x.forwardRef((t,e)=>{const{__scopeAlertDialog:n,...r}=t,{cancelRef:i}=N8(ZE,n),s=va(n),a=sn(e,i);return o.jsx(Uy,{...s,...r,ref:a})});ej.displayName=ZE;var j8=({contentRef:t})=>{const e=`\`${oc}\` requires a description for the component to be accessible for screen reader users.
492
+
493
+ You can add a description to the \`${oc}\` by passing a \`${JE}\` component as a child, which also benefits sighted users by adding visible context to the dialog.
494
+
495
+ Alternatively, you can use your own component as a description by assigning it an \`id\` and passing the same value to the \`aria-describedby\` prop in \`${oc}\`. If the description is confusing or duplicative for sighted users, you can use the \`@radix-ui/react-visually-hidden\` primitive as a wrapper around your description component.
496
+
497
+ For more information, see https://radix-ui.com/primitives/docs/components/alert-dialog`;return x.useEffect(()=>{var r;document.getElementById((r=t.current)==null?void 0:r.getAttribute("aria-describedby"))||console.warn(e)},[e,t]),null},P8=WE,_8=HE,R8=qE,I8=KE,M8=QE,D8=ej,A8=YE,O8=XE;const id=WN("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"border bg-background text-foreground hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 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 rounded-md"}},defaultVariants:{variant:"default",size:"default"}});function at({className:t,variant:e,size:n,asChild:r=!1,...i}){const s=r?ao:"button";return o.jsx(s,{"data-slot":"button",className:St(id({variant:e,size:n,className:t})),...i})}function js({...t}){return o.jsx(P8,{"data-slot":"alert-dialog",...t})}function L8({...t}){return o.jsx(_8,{"data-slot":"alert-dialog-portal",...t})}function F8({className:t,...e}){return o.jsx(R8,{"data-slot":"alert-dialog-overlay",className:St("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",t),...e})}function Ps({className:t,...e}){return o.jsxs(L8,{children:[o.jsx(F8,{}),o.jsx(I8,{"data-slot":"alert-dialog-content",className:St("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%] gap-4 rounded-lg border p-6 shadow-lg duration-200 sm:max-w-lg",t),...e})]})}function _s({className:t,...e}){return o.jsx("div",{"data-slot":"alert-dialog-header",className:St("flex flex-col gap-2 text-center sm:text-left",t),...e})}function Rs({className:t,...e}){return o.jsx("div",{"data-slot":"alert-dialog-footer",className:St("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",t),...e})}function Is({className:t,...e}){return o.jsx(A8,{"data-slot":"alert-dialog-title",className:St("text-lg font-semibold",t),...e})}function Ms({className:t,...e}){return o.jsx(O8,{"data-slot":"alert-dialog-description",className:St("text-muted-foreground text-sm",t),...e})}function Ds({className:t,...e}){return o.jsx(M8,{className:St(id(),t),...e})}function As({className:t,...e}){return o.jsx(D8,{className:St(id({variant:"outline"}),t),...e})}function U8(t,e){const n={};return(t[t.length-1]===""?[...t,""]:t).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const B8=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,z8=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,$8={};function G1(t,e){return($8.jsx?z8:B8).test(t)}const V8=/[ \t\n\f\r]/g;function W8(t){return typeof t=="object"?t.type==="text"?Y1(t.value):!1:Y1(t)}function Y1(t){return t.replace(V8,"")===""}class Cd{constructor(e,n,r){this.normal=n,this.property=e,r&&(this.space=r)}}Cd.prototype.normal={};Cd.prototype.property={};Cd.prototype.space=void 0;function tj(t,e){const n={},r={};for(const i of t)Object.assign(n,i.property),Object.assign(r,i.normal);return new Cd(n,r,e)}function uv(t){return t.toLowerCase()}class ti{constructor(e,n){this.attribute=n,this.property=e}}ti.prototype.attribute="";ti.prototype.booleanish=!1;ti.prototype.boolean=!1;ti.prototype.commaOrSpaceSeparated=!1;ti.prototype.commaSeparated=!1;ti.prototype.defined=!1;ti.prototype.mustUseProperty=!1;ti.prototype.number=!1;ti.prototype.overloadedBoolean=!1;ti.prototype.property="";ti.prototype.spaceSeparated=!1;ti.prototype.space=void 0;let H8=0;const jt=yl(),Jn=yl(),dv=yl(),Oe=yl(),Sn=yl(),lc=yl(),oi=yl();function yl(){return 2**++H8}const hv=Object.freeze(Object.defineProperty({__proto__:null,boolean:jt,booleanish:Jn,commaOrSpaceSeparated:oi,commaSeparated:lc,number:Oe,overloadedBoolean:dv,spaceSeparated:Sn},Symbol.toStringTag,{value:"Module"})),Yg=Object.keys(hv);class By extends ti{constructor(e,n,r,i){let s=-1;if(super(e,n),J1(this,"space",i),typeof r=="number")for(;++s<Yg.length;){const a=Yg[s];J1(this,Yg[s],(r&hv[a])===hv[a])}}}By.prototype.defined=!0;function J1(t,e,n){n&&(t[e]=n)}function Ic(t){const e={},n={};for(const[r,i]of Object.entries(t.properties)){const s=new By(r,t.transform(t.attributes||{},r),i,t.space);t.mustUseProperty&&t.mustUseProperty.includes(r)&&(s.mustUseProperty=!0),e[r]=s,n[uv(r)]=r,n[uv(s.attribute)]=r}return new Cd(e,n,t.space)}const nj=Ic({properties:{ariaActiveDescendant:null,ariaAtomic:Jn,ariaAutoComplete:null,ariaBusy:Jn,ariaChecked:Jn,ariaColCount:Oe,ariaColIndex:Oe,ariaColSpan:Oe,ariaControls:Sn,ariaCurrent:null,ariaDescribedBy:Sn,ariaDetails:null,ariaDisabled:Jn,ariaDropEffect:Sn,ariaErrorMessage:null,ariaExpanded:Jn,ariaFlowTo:Sn,ariaGrabbed:Jn,ariaHasPopup:null,ariaHidden:Jn,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:Sn,ariaLevel:Oe,ariaLive:null,ariaModal:Jn,ariaMultiLine:Jn,ariaMultiSelectable:Jn,ariaOrientation:null,ariaOwns:Sn,ariaPlaceholder:null,ariaPosInSet:Oe,ariaPressed:Jn,ariaReadOnly:Jn,ariaRelevant:null,ariaRequired:Jn,ariaRoleDescription:Sn,ariaRowCount:Oe,ariaRowIndex:Oe,ariaRowSpan:Oe,ariaSelected:Jn,ariaSetSize:Oe,ariaSort:null,ariaValueMax:Oe,ariaValueMin:Oe,ariaValueNow:Oe,ariaValueText:null,role:null},transform(t,e){return e==="role"?e:"aria-"+e.slice(4).toLowerCase()}});function rj(t,e){return e in t?t[e]:e}function ij(t,e){return rj(t,e.toLowerCase())}const q8=Ic({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:lc,acceptCharset:Sn,accessKey:Sn,action:null,allow:null,allowFullScreen:jt,allowPaymentRequest:jt,allowUserMedia:jt,alt:null,as:null,async:jt,autoCapitalize:null,autoComplete:Sn,autoFocus:jt,autoPlay:jt,blocking:Sn,capture:null,charSet:null,checked:jt,cite:null,className:Sn,cols:Oe,colSpan:null,content:null,contentEditable:Jn,controls:jt,controlsList:Sn,coords:Oe|lc,crossOrigin:null,data:null,dateTime:null,decoding:null,default:jt,defer:jt,dir:null,dirName:null,disabled:jt,download:dv,draggable:Jn,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:jt,formTarget:null,headers:Sn,height:Oe,hidden:dv,high:Oe,href:null,hrefLang:null,htmlFor:Sn,httpEquiv:Sn,id:null,imageSizes:null,imageSrcSet:null,inert:jt,inputMode:null,integrity:null,is:null,isMap:jt,itemId:null,itemProp:Sn,itemRef:Sn,itemScope:jt,itemType:Sn,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:jt,low:Oe,manifest:null,max:null,maxLength:Oe,media:null,method:null,min:null,minLength:Oe,multiple:jt,muted:jt,name:null,nonce:null,noModule:jt,noValidate:jt,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:jt,optimum:Oe,pattern:null,ping:Sn,placeholder:null,playsInline:jt,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:jt,referrerPolicy:null,rel:Sn,required:jt,reversed:jt,rows:Oe,rowSpan:Oe,sandbox:Sn,scope:null,scoped:jt,seamless:jt,selected:jt,shadowRootClonable:jt,shadowRootDelegatesFocus:jt,shadowRootMode:null,shape:null,size:Oe,sizes:null,slot:null,span:Oe,spellCheck:Jn,src:null,srcDoc:null,srcLang:null,srcSet:null,start:Oe,step:null,style:null,tabIndex:Oe,target:null,title:null,translate:null,type:null,typeMustMatch:jt,useMap:null,value:Jn,width:Oe,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:Sn,axis:null,background:null,bgColor:null,border:Oe,borderColor:null,bottomMargin:Oe,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:jt,declare:jt,event:null,face:null,frame:null,frameBorder:null,hSpace:Oe,leftMargin:Oe,link:null,longDesc:null,lowSrc:null,marginHeight:Oe,marginWidth:Oe,noResize:jt,noHref:jt,noShade:jt,noWrap:jt,object:null,profile:null,prompt:null,rev:null,rightMargin:Oe,rules:null,scheme:null,scrolling:Jn,standby:null,summary:null,text:null,topMargin:Oe,valueType:null,version:null,vAlign:null,vLink:null,vSpace:Oe,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:jt,disableRemotePlayback:jt,prefix:null,property:null,results:Oe,security:null,unselectable:null},space:"html",transform:ij}),K8=Ic({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:oi,accentHeight:Oe,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:Oe,amplitude:Oe,arabicForm:null,ascent:Oe,attributeName:null,attributeType:null,azimuth:Oe,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:Oe,by:null,calcMode:null,capHeight:Oe,className:Sn,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:Oe,diffuseConstant:Oe,direction:null,display:null,dur:null,divisor:Oe,dominantBaseline:null,download:jt,dx:null,dy:null,edgeMode:null,editable:null,elevation:Oe,enableBackground:null,end:null,event:null,exponent:Oe,externalResourcesRequired:null,fill:null,fillOpacity:Oe,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:lc,g2:lc,glyphName:lc,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:Oe,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:Oe,horizOriginX:Oe,horizOriginY:Oe,id:null,ideographic:Oe,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:Oe,k:Oe,k1:Oe,k2:Oe,k3:Oe,k4:Oe,kernelMatrix:oi,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:Oe,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:Oe,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:Oe,overlineThickness:Oe,paintOrder:null,panose1:null,path:null,pathLength:Oe,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:Sn,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:Oe,pointsAtY:Oe,pointsAtZ:Oe,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:oi,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:oi,rev:oi,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:oi,requiredFeatures:oi,requiredFonts:oi,requiredFormats:oi,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:Oe,specularExponent:Oe,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:Oe,strikethroughThickness:Oe,string:null,stroke:null,strokeDashArray:oi,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:Oe,strokeOpacity:Oe,strokeWidth:null,style:null,surfaceScale:Oe,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:oi,tabIndex:Oe,tableValues:null,target:null,targetX:Oe,targetY:Oe,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:oi,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:Oe,underlineThickness:Oe,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:Oe,values:null,vAlphabetic:Oe,vMathematical:Oe,vectorEffect:null,vHanging:Oe,vIdeographic:Oe,version:null,vertAdvY:Oe,vertOriginX:Oe,vertOriginY:Oe,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:Oe,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:rj}),sj=Ic({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(t,e){return"xlink:"+e.slice(5).toLowerCase()}}),aj=Ic({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:ij}),oj=Ic({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(t,e){return"xml:"+e.slice(3).toLowerCase()}}),G8={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"},Y8=/[A-Z]/g,X1=/-[a-z]/g,J8=/^data[-\w.:]+$/i;function X8(t,e){const n=uv(e);let r=e,i=ti;if(n in t.normal)return t.property[t.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&J8.test(e)){if(e.charAt(4)==="-"){const s=e.slice(5).replace(X1,Z8);r="data"+s.charAt(0).toUpperCase()+s.slice(1)}else{const s=e.slice(4);if(!X1.test(s)){let a=s.replace(Y8,Q8);a.charAt(0)!=="-"&&(a="-"+a),e="data"+a}}i=By}return new i(r,e)}function Q8(t){return"-"+t.toLowerCase()}function Z8(t){return t.charAt(1).toUpperCase()}const e6=tj([nj,q8,sj,aj,oj],"html"),zy=tj([nj,K8,sj,aj,oj],"svg");function t6(t){return t.join(" ").trim()}var Kl={},Jg,Q1;function n6(){if(Q1)return Jg;Q1=1;var t=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,e=/\n/g,n=/^\s*/,r=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,i=/^:\s*/,s=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,a=/^[;\s]*/,c=/^\s+|\s+$/g,h=`
498
+ `,d="/",f="*",p="",g="comment",v="declaration";function k(S,T){if(typeof S!="string")throw new TypeError("First argument must be a string");if(!S)return[];T=T||{};var C=1,j=1;function R(K){var J=K.match(e);J&&(C+=J.length);var Q=K.lastIndexOf(h);j=~Q?K.length-Q:j+K.length}function _(){var K={line:C,column:j};return function(J){return J.position=new I(K),$(),J}}function I(K){this.start=K,this.end={line:C,column:j},this.source=T.source}I.prototype.content=S;function M(K){var J=new Error(T.source+":"+C+":"+j+": "+K);if(J.reason=K,J.filename=T.source,J.line=C,J.column=j,J.source=S,!T.silent)throw J}function L(K){var J=K.exec(S);if(J){var Q=J[0];return R(Q),S=S.slice(Q.length),J}}function $(){L(n)}function E(K){var J;for(K=K||[];J=P();)J!==!1&&K.push(J);return K}function P(){var K=_();if(!(d!=S.charAt(0)||f!=S.charAt(1))){for(var J=2;p!=S.charAt(J)&&(f!=S.charAt(J)||d!=S.charAt(J+1));)++J;if(J+=2,p===S.charAt(J-1))return M("End of comment missing");var Q=S.slice(2,J-2);return j+=2,R(Q),S=S.slice(J),j+=2,K({type:g,comment:Q})}}function V(){var K=_(),J=L(r);if(J){if(P(),!L(i))return M("property missing ':'");var Q=L(s),Z=K({type:v,property:w(J[0].replace(t,p)),value:Q?w(Q[0].replace(t,p)):p});return L(a),Z}}function F(){var K=[];E(K);for(var J;J=V();)J!==!1&&(K.push(J),E(K));return K}return $(),F()}function w(S){return S?S.replace(c,p):p}return Jg=k,Jg}var Z1;function r6(){if(Z1)return Kl;Z1=1;var t=Kl&&Kl.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(Kl,"__esModule",{value:!0}),Kl.default=n;const e=t(n6());function n(r,i){let s=null;if(!r||typeof r!="string")return s;const a=(0,e.default)(r),c=typeof i=="function";return a.forEach(h=>{if(h.type!=="declaration")return;const{property:d,value:f}=h;c?i(d,f,h):f&&(s=s||{},s[d]=f)}),s}return Kl}var ku={},eS;function i6(){if(eS)return ku;eS=1,Object.defineProperty(ku,"__esModule",{value:!0}),ku.camelCase=void 0;var t=/^--[a-zA-Z0-9_-]+$/,e=/-([a-z])/g,n=/^[^-]+$/,r=/^-(webkit|moz|ms|o|khtml)-/,i=/^-(ms)-/,s=function(d){return!d||n.test(d)||t.test(d)},a=function(d,f){return f.toUpperCase()},c=function(d,f){return"".concat(f,"-")},h=function(d,f){return f===void 0&&(f={}),s(d)?d:(d=d.toLowerCase(),f.reactCompat?d=d.replace(i,c):d=d.replace(r,c),d.replace(e,a))};return ku.camelCase=h,ku}var wu,tS;function s6(){if(tS)return wu;tS=1;var t=wu&&wu.__importDefault||function(i){return i&&i.__esModule?i:{default:i}},e=t(r6()),n=i6();function r(i,s){var a={};return!i||typeof i!="string"||(0,e.default)(i,function(c,h){c&&h&&(a[(0,n.camelCase)(c,s)]=h)}),a}return r.default=r,wu=r,wu}var a6=s6();const o6=up(a6),lj=cj("end"),$y=cj("start");function cj(t){return e;function e(n){const r=n&&n.position&&n.position[t]||{};if(typeof r.line=="number"&&r.line>0&&typeof r.column=="number"&&r.column>0)return{line:r.line,column:r.column,offset:typeof r.offset=="number"&&r.offset>-1?r.offset:void 0}}}function l6(t){const e=$y(t),n=lj(t);if(e&&n)return{start:e,end:n}}function $u(t){return!t||typeof t!="object"?"":"position"in t||"type"in t?nS(t.position):"start"in t||"end"in t?nS(t):"line"in t||"column"in t?fv(t):""}function fv(t){return rS(t&&t.line)+":"+rS(t&&t.column)}function nS(t){return fv(t&&t.start)+"-"+fv(t&&t.end)}function rS(t){return t&&typeof t=="number"?t:1}class Er extends Error{constructor(e,n,r){super(),typeof n=="string"&&(r=n,n=void 0);let i="",s={},a=!1;if(n&&("line"in n&&"column"in n?s={place:n}:"start"in n&&"end"in n?s={place:n}:"type"in n?s={ancestors:[n],place:n.position}:s={...n}),typeof e=="string"?i=e:!s.cause&&e&&(a=!0,i=e.message,s.cause=e),!s.ruleId&&!s.source&&typeof r=="string"){const h=r.indexOf(":");h===-1?s.ruleId=r:(s.source=r.slice(0,h),s.ruleId=r.slice(h+1))}if(!s.place&&s.ancestors&&s.ancestors){const h=s.ancestors[s.ancestors.length-1];h&&(s.place=h.position)}const c=s.place&&"start"in s.place?s.place.start:s.place;this.ancestors=s.ancestors||void 0,this.cause=s.cause||void 0,this.column=c?c.column:void 0,this.fatal=void 0,this.file="",this.message=i,this.line=c?c.line:void 0,this.name=$u(s.place)||"1:1",this.place=s.place||void 0,this.reason=this.message,this.ruleId=s.ruleId||void 0,this.source=s.source||void 0,this.stack=a&&s.cause&&typeof s.cause.stack=="string"?s.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}Er.prototype.file="";Er.prototype.name="";Er.prototype.reason="";Er.prototype.message="";Er.prototype.stack="";Er.prototype.column=void 0;Er.prototype.line=void 0;Er.prototype.ancestors=void 0;Er.prototype.cause=void 0;Er.prototype.fatal=void 0;Er.prototype.place=void 0;Er.prototype.ruleId=void 0;Er.prototype.source=void 0;const Vy={}.hasOwnProperty,c6=new Map,u6=/[A-Z]/g,d6=new Set(["table","tbody","thead","tfoot","tr"]),h6=new Set(["td","th"]),uj="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function f6(t,e){if(!e||e.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const n=e.filePath||void 0;let r;if(e.development){if(typeof e.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");r=k6(n,e.jsxDEV)}else{if(typeof e.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof e.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");r=b6(n,e.jsx,e.jsxs)}const i={Fragment:e.Fragment,ancestors:[],components:e.components||{},create:r,elementAttributeNameCase:e.elementAttributeNameCase||"react",evaluater:e.createEvaluater?e.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:e.ignoreInvalidStyle||!1,passKeys:e.passKeys!==!1,passNode:e.passNode||!1,schema:e.space==="svg"?zy:e6,stylePropertyNameCase:e.stylePropertyNameCase||"dom",tableCellAlignToStyle:e.tableCellAlignToStyle!==!1},s=dj(i,t,void 0);return s&&typeof s!="string"?s:i.create(t,i.Fragment,{children:s||void 0},void 0)}function dj(t,e,n){if(e.type==="element")return p6(t,e,n);if(e.type==="mdxFlowExpression"||e.type==="mdxTextExpression")return m6(t,e);if(e.type==="mdxJsxFlowElement"||e.type==="mdxJsxTextElement")return v6(t,e,n);if(e.type==="mdxjsEsm")return g6(t,e);if(e.type==="root")return y6(t,e,n);if(e.type==="text")return x6(t,e)}function p6(t,e,n){const r=t.schema;let i=r;e.tagName.toLowerCase()==="svg"&&r.space==="html"&&(i=zy,t.schema=i),t.ancestors.push(e);const s=fj(t,e.tagName,!1),a=w6(t,e);let c=Hy(t,e);return d6.has(e.tagName)&&(c=c.filter(function(h){return typeof h=="string"?!W8(h):!0})),hj(t,a,s,e),Wy(a,c),t.ancestors.pop(),t.schema=r,t.create(e,s,a,n)}function m6(t,e){if(e.data&&e.data.estree&&t.evaluater){const r=e.data.estree.body[0];return r.type,t.evaluater.evaluateExpression(r.expression)}sd(t,e.position)}function g6(t,e){if(e.data&&e.data.estree&&t.evaluater)return t.evaluater.evaluateProgram(e.data.estree);sd(t,e.position)}function v6(t,e,n){const r=t.schema;let i=r;e.name==="svg"&&r.space==="html"&&(i=zy,t.schema=i),t.ancestors.push(e);const s=e.name===null?t.Fragment:fj(t,e.name,!0),a=S6(t,e),c=Hy(t,e);return hj(t,a,s,e),Wy(a,c),t.ancestors.pop(),t.schema=r,t.create(e,s,a,n)}function y6(t,e,n){const r={};return Wy(r,Hy(t,e)),t.create(e,t.Fragment,r,n)}function x6(t,e){return e.value}function hj(t,e,n,r){typeof n!="string"&&n!==t.Fragment&&t.passNode&&(e.node=r)}function Wy(t,e){if(e.length>0){const n=e.length>1?e:e[0];n&&(t.children=n)}}function b6(t,e,n){return r;function r(i,s,a,c){const d=Array.isArray(a.children)?n:e;return c?d(s,a,c):d(s,a)}}function k6(t,e){return n;function n(r,i,s,a){const c=Array.isArray(s.children),h=$y(r);return e(i,s,a,c,{columnNumber:h?h.column-1:void 0,fileName:t,lineNumber:h?h.line:void 0},void 0)}}function w6(t,e){const n={};let r,i;for(i in e.properties)if(i!=="children"&&Vy.call(e.properties,i)){const s=C6(t,i,e.properties[i]);if(s){const[a,c]=s;t.tableCellAlignToStyle&&a==="align"&&typeof c=="string"&&h6.has(e.tagName)?r=c:n[a]=c}}if(r){const s=n.style||(n.style={});s[t.stylePropertyNameCase==="css"?"text-align":"textAlign"]=r}return n}function S6(t,e){const n={};for(const r of e.attributes)if(r.type==="mdxJsxExpressionAttribute")if(r.data&&r.data.estree&&t.evaluater){const s=r.data.estree.body[0];s.type;const a=s.expression;a.type;const c=a.properties[0];c.type,Object.assign(n,t.evaluater.evaluateExpression(c.argument))}else sd(t,e.position);else{const i=r.name;let s;if(r.value&&typeof r.value=="object")if(r.value.data&&r.value.data.estree&&t.evaluater){const c=r.value.data.estree.body[0];c.type,s=t.evaluater.evaluateExpression(c.expression)}else sd(t,e.position);else s=r.value===null?!0:r.value;n[i]=s}return n}function Hy(t,e){const n=[];let r=-1;const i=t.passKeys?new Map:c6;for(;++r<e.children.length;){const s=e.children[r];let a;if(t.passKeys){const h=s.type==="element"?s.tagName:s.type==="mdxJsxFlowElement"||s.type==="mdxJsxTextElement"?s.name:void 0;if(h){const d=i.get(h)||0;a=h+"-"+d,i.set(h,d+1)}}const c=dj(t,s,a);c!==void 0&&n.push(c)}return n}function C6(t,e,n){const r=X8(t.schema,e);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?U8(n):t6(n)),r.property==="style"){let i=typeof n=="object"?n:T6(t,String(n));return t.stylePropertyNameCase==="css"&&(i=N6(i)),["style",i]}return[t.elementAttributeNameCase==="react"&&r.space?G8[r.property]||r.property:r.attribute,n]}}function T6(t,e){try{return o6(e,{reactCompat:!0})}catch(n){if(t.ignoreInvalidStyle)return{};const r=n,i=new Er("Cannot parse `style` attribute",{ancestors:t.ancestors,cause:r,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw i.file=t.filePath||void 0,i.url=uj+"#cannot-parse-style-attribute",i}}function fj(t,e,n){let r;if(!n)r={type:"Literal",value:e};else if(e.includes(".")){const i=e.split(".");let s=-1,a;for(;++s<i.length;){const c=G1(i[s])?{type:"Identifier",name:i[s]}:{type:"Literal",value:i[s]};a=a?{type:"MemberExpression",object:a,property:c,computed:!!(s&&c.type==="Literal"),optional:!1}:c}r=a}else r=G1(e)&&!/^[a-z]/.test(e)?{type:"Identifier",name:e}:{type:"Literal",value:e};if(r.type==="Literal"){const i=r.value;return Vy.call(t.components,i)?t.components[i]:i}if(t.evaluater)return t.evaluater.evaluateExpression(r);sd(t)}function sd(t,e){const n=new Er("Cannot handle MDX estrees without `createEvaluater`",{ancestors:t.ancestors,place:e,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw n.file=t.filePath||void 0,n.url=uj+"#cannot-handle-mdx-estrees-without-createevaluater",n}function N6(t){const e={};let n;for(n in t)Vy.call(t,n)&&(e[E6(n)]=t[n]);return e}function E6(t){let e=t.replace(u6,j6);return e.slice(0,3)==="ms-"&&(e="-"+e),e}function j6(t){return"-"+t.toLowerCase()}const Xg={action:["form"],cite:["blockquote","del","ins","q"],data:["object"],formAction:["button","input"],href:["a","area","base","link"],icon:["menuitem"],itemId:null,manifest:["html"],ping:["a","area"],poster:["video"],src:["audio","embed","iframe","img","input","script","source","track","video"]},P6={};function qy(t,e){const n=P6,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,i=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return pj(t,r,i)}function pj(t,e,n){if(_6(t)){if("value"in t)return t.type==="html"&&!n?"":t.value;if(e&&"alt"in t&&t.alt)return t.alt;if("children"in t)return iS(t.children,e,n)}return Array.isArray(t)?iS(t,e,n):""}function iS(t,e,n){const r=[];let i=-1;for(;++i<t.length;)r[i]=pj(t[i],e,n);return r.join("")}function _6(t){return!!(t&&typeof t=="object")}const sS=document.createElement("i");function Ky(t){const e="&"+t+";";sS.innerHTML=e;const n=sS.textContent;return n.charCodeAt(n.length-1)===59&&t!=="semi"||n===e?!1:n}function di(t,e,n,r){const i=t.length;let s=0,a;if(e<0?e=-e>i?0:i+e:e=e>i?i:e,n=n>0?n:0,r.length<1e4)a=Array.from(r),a.unshift(e,n),t.splice(...a);else for(n&&t.splice(e,n);s<r.length;)a=r.slice(s,s+1e4),a.unshift(e,0),t.splice(...a),s+=1e4,e+=1e4}function Pi(t,e){return t.length>0?(di(t,t.length,0,e),t):e}const aS={}.hasOwnProperty;function mj(t){const e={};let n=-1;for(;++n<t.length;)R6(e,t[n]);return e}function R6(t,e){let n;for(n in e){const i=(aS.call(t,n)?t[n]:void 0)||(t[n]={}),s=e[n];let a;if(s)for(a in s){aS.call(i,a)||(i[a]=[]);const c=s[a];I6(i[a],Array.isArray(c)?c:c?[c]:[])}}}function I6(t,e){let n=-1;const r=[];for(;++n<e.length;)(e[n].add==="after"?t:r).push(e[n]);di(t,0,0,r)}function gj(t,e){const n=Number.parseInt(t,e);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)===65535||(n&65535)===65534||n>1114111?"�":String.fromCodePoint(n)}function rs(t){return t.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const Ar=po(/[A-Za-z]/),wr=po(/[\dA-Za-z]/),M6=po(/[#-'*+\--9=?A-Z^-~]/);function Lf(t){return t!==null&&(t<32||t===127)}const pv=po(/\d/),D6=po(/[\dA-Fa-f]/),A6=po(/[!-/:-@[-`{-~]/);function mt(t){return t!==null&&t<-2}function kn(t){return t!==null&&(t<0||t===32)}function Ft(t){return t===-2||t===-1||t===32}const xp=po(new RegExp("\\p{P}|\\p{S}","u")),cl=po(/\s/);function po(t){return e;function e(n){return n!==null&&n>-1&&t.test(String.fromCharCode(n))}}function Mc(t){const e=[];let n=-1,r=0,i=0;for(;++n<t.length;){const s=t.charCodeAt(n);let a="";if(s===37&&wr(t.charCodeAt(n+1))&&wr(t.charCodeAt(n+2)))i=2;else if(s<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(s))||(a=String.fromCharCode(s));else if(s>55295&&s<57344){const c=t.charCodeAt(n+1);s<56320&&c>56319&&c<57344?(a=String.fromCharCode(s,c),i=1):a="�"}else a=String.fromCharCode(s);a&&(e.push(t.slice(r,n),encodeURIComponent(a)),r=n+i+1,a=""),i&&(n+=i,i=0)}return e.join("")+t.slice(r)}function Vt(t,e,n,r){const i=r?r-1:Number.POSITIVE_INFINITY;let s=0;return a;function a(h){return Ft(h)?(t.enter(n),c(h)):e(h)}function c(h){return Ft(h)&&s++<i?(t.consume(h),c):(t.exit(n),e(h))}}const O6={tokenize:L6};function L6(t){const e=t.attempt(this.parser.constructs.contentInitial,r,i);let n;return e;function r(c){if(c===null){t.consume(c);return}return t.enter("lineEnding"),t.consume(c),t.exit("lineEnding"),Vt(t,e,"linePrefix")}function i(c){return t.enter("paragraph"),s(c)}function s(c){const h=t.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=h),n=h,a(c)}function a(c){if(c===null){t.exit("chunkText"),t.exit("paragraph"),t.consume(c);return}return mt(c)?(t.consume(c),t.exit("chunkText"),s):(t.consume(c),a)}}const F6={tokenize:U6},oS={tokenize:B6};function U6(t){const e=this,n=[];let r=0,i,s,a;return c;function c(j){if(r<n.length){const R=n[r];return e.containerState=R[1],t.attempt(R[0].continuation,h,d)(j)}return d(j)}function h(j){if(r++,e.containerState._closeFlow){e.containerState._closeFlow=void 0,i&&C();const R=e.events.length;let _=R,I;for(;_--;)if(e.events[_][0]==="exit"&&e.events[_][1].type==="chunkFlow"){I=e.events[_][1].end;break}T(r);let M=R;for(;M<e.events.length;)e.events[M][1].end={...I},M++;return di(e.events,_+1,0,e.events.slice(R)),e.events.length=M,d(j)}return c(j)}function d(j){if(r===n.length){if(!i)return g(j);if(i.currentConstruct&&i.currentConstruct.concrete)return k(j);e.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return e.containerState={},t.check(oS,f,p)(j)}function f(j){return i&&C(),T(r),g(j)}function p(j){return e.parser.lazy[e.now().line]=r!==n.length,a=e.now().offset,k(j)}function g(j){return e.containerState={},t.attempt(oS,v,k)(j)}function v(j){return r++,n.push([e.currentConstruct,e.containerState]),g(j)}function k(j){if(j===null){i&&C(),T(0),t.consume(j);return}return i=i||e.parser.flow(e.now()),t.enter("chunkFlow",{_tokenizer:i,contentType:"flow",previous:s}),w(j)}function w(j){if(j===null){S(t.exit("chunkFlow"),!0),T(0),t.consume(j);return}return mt(j)?(t.consume(j),S(t.exit("chunkFlow")),r=0,e.interrupt=void 0,c):(t.consume(j),w)}function S(j,R){const _=e.sliceStream(j);if(R&&_.push(null),j.previous=s,s&&(s.next=j),s=j,i.defineSkip(j.start),i.write(_),e.parser.lazy[j.start.line]){let I=i.events.length;for(;I--;)if(i.events[I][1].start.offset<a&&(!i.events[I][1].end||i.events[I][1].end.offset>a))return;const M=e.events.length;let L=M,$,E;for(;L--;)if(e.events[L][0]==="exit"&&e.events[L][1].type==="chunkFlow"){if($){E=e.events[L][1].end;break}$=!0}for(T(r),I=M;I<e.events.length;)e.events[I][1].end={...E},I++;di(e.events,L+1,0,e.events.slice(M)),e.events.length=I}}function T(j){let R=n.length;for(;R-- >j;){const _=n[R];e.containerState=_[1],_[0].exit.call(e,t)}n.length=j}function C(){i.write([null]),s=void 0,i=void 0,e.containerState._closeFlow=void 0}}function B6(t,e,n){return Vt(t,t.attempt(this.parser.constructs.document,e,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function bc(t){if(t===null||kn(t)||cl(t))return 1;if(xp(t))return 2}function bp(t,e,n){const r=[];let i=-1;for(;++i<t.length;){const s=t[i].resolveAll;s&&!r.includes(s)&&(e=s(e,n),r.push(s))}return e}const mv={name:"attention",resolveAll:z6,tokenize:$6};function z6(t,e){let n=-1,r,i,s,a,c,h,d,f;for(;++n<t.length;)if(t[n][0]==="enter"&&t[n][1].type==="attentionSequence"&&t[n][1]._close){for(r=n;r--;)if(t[r][0]==="exit"&&t[r][1].type==="attentionSequence"&&t[r][1]._open&&e.sliceSerialize(t[r][1]).charCodeAt(0)===e.sliceSerialize(t[n][1]).charCodeAt(0)){if((t[r][1]._close||t[n][1]._open)&&(t[n][1].end.offset-t[n][1].start.offset)%3&&!((t[r][1].end.offset-t[r][1].start.offset+t[n][1].end.offset-t[n][1].start.offset)%3))continue;h=t[r][1].end.offset-t[r][1].start.offset>1&&t[n][1].end.offset-t[n][1].start.offset>1?2:1;const p={...t[r][1].end},g={...t[n][1].start};lS(p,-h),lS(g,h),a={type:h>1?"strongSequence":"emphasisSequence",start:p,end:{...t[r][1].end}},c={type:h>1?"strongSequence":"emphasisSequence",start:{...t[n][1].start},end:g},s={type:h>1?"strongText":"emphasisText",start:{...t[r][1].end},end:{...t[n][1].start}},i={type:h>1?"strong":"emphasis",start:{...a.start},end:{...c.end}},t[r][1].end={...a.start},t[n][1].start={...c.end},d=[],t[r][1].end.offset-t[r][1].start.offset&&(d=Pi(d,[["enter",t[r][1],e],["exit",t[r][1],e]])),d=Pi(d,[["enter",i,e],["enter",a,e],["exit",a,e],["enter",s,e]]),d=Pi(d,bp(e.parser.constructs.insideSpan.null,t.slice(r+1,n),e)),d=Pi(d,[["exit",s,e],["enter",c,e],["exit",c,e],["exit",i,e]]),t[n][1].end.offset-t[n][1].start.offset?(f=2,d=Pi(d,[["enter",t[n][1],e],["exit",t[n][1],e]])):f=0,di(t,r-1,n-r+3,d),n=r+d.length-f-2;break}}for(n=-1;++n<t.length;)t[n][1].type==="attentionSequence"&&(t[n][1].type="data");return t}function $6(t,e){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=bc(r);let s;return a;function a(h){return s=h,t.enter("attentionSequence"),c(h)}function c(h){if(h===s)return t.consume(h),c;const d=t.exit("attentionSequence"),f=bc(h),p=!f||f===2&&i||n.includes(h),g=!i||i===2&&f||n.includes(r);return d._open=!!(s===42?p:p&&(i||!g)),d._close=!!(s===42?g:g&&(f||!p)),e(h)}}function lS(t,e){t.column+=e,t.offset+=e,t._bufferIndex+=e}const V6={name:"autolink",tokenize:W6};function W6(t,e,n){let r=0;return i;function i(v){return t.enter("autolink"),t.enter("autolinkMarker"),t.consume(v),t.exit("autolinkMarker"),t.enter("autolinkProtocol"),s}function s(v){return Ar(v)?(t.consume(v),a):v===64?n(v):d(v)}function a(v){return v===43||v===45||v===46||wr(v)?(r=1,c(v)):d(v)}function c(v){return v===58?(t.consume(v),r=0,h):(v===43||v===45||v===46||wr(v))&&r++<32?(t.consume(v),c):(r=0,d(v))}function h(v){return v===62?(t.exit("autolinkProtocol"),t.enter("autolinkMarker"),t.consume(v),t.exit("autolinkMarker"),t.exit("autolink"),e):v===null||v===32||v===60||Lf(v)?n(v):(t.consume(v),h)}function d(v){return v===64?(t.consume(v),f):M6(v)?(t.consume(v),d):n(v)}function f(v){return wr(v)?p(v):n(v)}function p(v){return v===46?(t.consume(v),r=0,f):v===62?(t.exit("autolinkProtocol").type="autolinkEmail",t.enter("autolinkMarker"),t.consume(v),t.exit("autolinkMarker"),t.exit("autolink"),e):g(v)}function g(v){if((v===45||wr(v))&&r++<63){const k=v===45?g:p;return t.consume(v),k}return n(v)}}const Td={partial:!0,tokenize:H6};function H6(t,e,n){return r;function r(s){return Ft(s)?Vt(t,i,"linePrefix")(s):i(s)}function i(s){return s===null||mt(s)?e(s):n(s)}}const vj={continuation:{tokenize:K6},exit:G6,name:"blockQuote",tokenize:q6};function q6(t,e,n){const r=this;return i;function i(a){if(a===62){const c=r.containerState;return c.open||(t.enter("blockQuote",{_container:!0}),c.open=!0),t.enter("blockQuotePrefix"),t.enter("blockQuoteMarker"),t.consume(a),t.exit("blockQuoteMarker"),s}return n(a)}function s(a){return Ft(a)?(t.enter("blockQuotePrefixWhitespace"),t.consume(a),t.exit("blockQuotePrefixWhitespace"),t.exit("blockQuotePrefix"),e):(t.exit("blockQuotePrefix"),e(a))}}function K6(t,e,n){const r=this;return i;function i(a){return Ft(a)?Vt(t,s,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(a):s(a)}function s(a){return t.attempt(vj,e,n)(a)}}function G6(t){t.exit("blockQuote")}const yj={name:"characterEscape",tokenize:Y6};function Y6(t,e,n){return r;function r(s){return t.enter("characterEscape"),t.enter("escapeMarker"),t.consume(s),t.exit("escapeMarker"),i}function i(s){return A6(s)?(t.enter("characterEscapeValue"),t.consume(s),t.exit("characterEscapeValue"),t.exit("characterEscape"),e):n(s)}}const xj={name:"characterReference",tokenize:J6};function J6(t,e,n){const r=this;let i=0,s,a;return c;function c(p){return t.enter("characterReference"),t.enter("characterReferenceMarker"),t.consume(p),t.exit("characterReferenceMarker"),h}function h(p){return p===35?(t.enter("characterReferenceMarkerNumeric"),t.consume(p),t.exit("characterReferenceMarkerNumeric"),d):(t.enter("characterReferenceValue"),s=31,a=wr,f(p))}function d(p){return p===88||p===120?(t.enter("characterReferenceMarkerHexadecimal"),t.consume(p),t.exit("characterReferenceMarkerHexadecimal"),t.enter("characterReferenceValue"),s=6,a=D6,f):(t.enter("characterReferenceValue"),s=7,a=pv,f(p))}function f(p){if(p===59&&i){const g=t.exit("characterReferenceValue");return a===wr&&!Ky(r.sliceSerialize(g))?n(p):(t.enter("characterReferenceMarker"),t.consume(p),t.exit("characterReferenceMarker"),t.exit("characterReference"),e)}return a(p)&&i++<s?(t.consume(p),f):n(p)}}const cS={partial:!0,tokenize:Q6},uS={concrete:!0,name:"codeFenced",tokenize:X6};function X6(t,e,n){const r=this,i={partial:!0,tokenize:_};let s=0,a=0,c;return h;function h(I){return d(I)}function d(I){const M=r.events[r.events.length-1];return s=M&&M[1].type==="linePrefix"?M[2].sliceSerialize(M[1],!0).length:0,c=I,t.enter("codeFenced"),t.enter("codeFencedFence"),t.enter("codeFencedFenceSequence"),f(I)}function f(I){return I===c?(a++,t.consume(I),f):a<3?n(I):(t.exit("codeFencedFenceSequence"),Ft(I)?Vt(t,p,"whitespace")(I):p(I))}function p(I){return I===null||mt(I)?(t.exit("codeFencedFence"),r.interrupt?e(I):t.check(cS,w,R)(I)):(t.enter("codeFencedFenceInfo"),t.enter("chunkString",{contentType:"string"}),g(I))}function g(I){return I===null||mt(I)?(t.exit("chunkString"),t.exit("codeFencedFenceInfo"),p(I)):Ft(I)?(t.exit("chunkString"),t.exit("codeFencedFenceInfo"),Vt(t,v,"whitespace")(I)):I===96&&I===c?n(I):(t.consume(I),g)}function v(I){return I===null||mt(I)?p(I):(t.enter("codeFencedFenceMeta"),t.enter("chunkString",{contentType:"string"}),k(I))}function k(I){return I===null||mt(I)?(t.exit("chunkString"),t.exit("codeFencedFenceMeta"),p(I)):I===96&&I===c?n(I):(t.consume(I),k)}function w(I){return t.attempt(i,R,S)(I)}function S(I){return t.enter("lineEnding"),t.consume(I),t.exit("lineEnding"),T}function T(I){return s>0&&Ft(I)?Vt(t,C,"linePrefix",s+1)(I):C(I)}function C(I){return I===null||mt(I)?t.check(cS,w,R)(I):(t.enter("codeFlowValue"),j(I))}function j(I){return I===null||mt(I)?(t.exit("codeFlowValue"),C(I)):(t.consume(I),j)}function R(I){return t.exit("codeFenced"),e(I)}function _(I,M,L){let $=0;return E;function E(J){return I.enter("lineEnding"),I.consume(J),I.exit("lineEnding"),P}function P(J){return I.enter("codeFencedFence"),Ft(J)?Vt(I,V,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(J):V(J)}function V(J){return J===c?(I.enter("codeFencedFenceSequence"),F(J)):L(J)}function F(J){return J===c?($++,I.consume(J),F):$>=a?(I.exit("codeFencedFenceSequence"),Ft(J)?Vt(I,K,"whitespace")(J):K(J)):L(J)}function K(J){return J===null||mt(J)?(I.exit("codeFencedFence"),M(J)):L(J)}}}function Q6(t,e,n){const r=this;return i;function i(a){return a===null?n(a):(t.enter("lineEnding"),t.consume(a),t.exit("lineEnding"),s)}function s(a){return r.parser.lazy[r.now().line]?n(a):e(a)}}const Qg={name:"codeIndented",tokenize:e9},Z6={partial:!0,tokenize:t9};function e9(t,e,n){const r=this;return i;function i(d){return t.enter("codeIndented"),Vt(t,s,"linePrefix",5)(d)}function s(d){const f=r.events[r.events.length-1];return f&&f[1].type==="linePrefix"&&f[2].sliceSerialize(f[1],!0).length>=4?a(d):n(d)}function a(d){return d===null?h(d):mt(d)?t.attempt(Z6,a,h)(d):(t.enter("codeFlowValue"),c(d))}function c(d){return d===null||mt(d)?(t.exit("codeFlowValue"),a(d)):(t.consume(d),c)}function h(d){return t.exit("codeIndented"),e(d)}}function t9(t,e,n){const r=this;return i;function i(a){return r.parser.lazy[r.now().line]?n(a):mt(a)?(t.enter("lineEnding"),t.consume(a),t.exit("lineEnding"),i):Vt(t,s,"linePrefix",5)(a)}function s(a){const c=r.events[r.events.length-1];return c&&c[1].type==="linePrefix"&&c[2].sliceSerialize(c[1],!0).length>=4?e(a):mt(a)?i(a):n(a)}}const n9={name:"codeText",previous:i9,resolve:r9,tokenize:s9};function r9(t){let e=t.length-4,n=3,r,i;if((t[n][1].type==="lineEnding"||t[n][1].type==="space")&&(t[e][1].type==="lineEnding"||t[e][1].type==="space")){for(r=n;++r<e;)if(t[r][1].type==="codeTextData"){t[n][1].type="codeTextPadding",t[e][1].type="codeTextPadding",n+=2,e-=2;break}}for(r=n-1,e++;++r<=e;)i===void 0?r!==e&&t[r][1].type!=="lineEnding"&&(i=r):(r===e||t[r][1].type==="lineEnding")&&(t[i][1].type="codeTextData",r!==i+2&&(t[i][1].end=t[r-1][1].end,t.splice(i+2,r-i-2),e-=r-i-2,r=i+2),i=void 0);return t}function i9(t){return t!==96||this.events[this.events.length-1][1].type==="characterEscape"}function s9(t,e,n){let r=0,i,s;return a;function a(p){return t.enter("codeText"),t.enter("codeTextSequence"),c(p)}function c(p){return p===96?(t.consume(p),r++,c):(t.exit("codeTextSequence"),h(p))}function h(p){return p===null?n(p):p===32?(t.enter("space"),t.consume(p),t.exit("space"),h):p===96?(s=t.enter("codeTextSequence"),i=0,f(p)):mt(p)?(t.enter("lineEnding"),t.consume(p),t.exit("lineEnding"),h):(t.enter("codeTextData"),d(p))}function d(p){return p===null||p===32||p===96||mt(p)?(t.exit("codeTextData"),h(p)):(t.consume(p),d)}function f(p){return p===96?(t.consume(p),i++,f):i===r?(t.exit("codeTextSequence"),t.exit("codeText"),e(p)):(s.type="codeTextData",d(p))}}class a9{constructor(e){this.left=e?[...e]:[],this.right=[]}get(e){if(e<0||e>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+e+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return e<this.left.length?this.left[e]:this.right[this.right.length-e+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(e,n){const r=n??Number.POSITIVE_INFINITY;return r<this.left.length?this.left.slice(e,r):e>this.left.length?this.right.slice(this.right.length-r+this.left.length,this.right.length-e+this.left.length).reverse():this.left.slice(e).concat(this.right.slice(this.right.length-r+this.left.length).reverse())}splice(e,n,r){const i=n||0;this.setCursor(Math.trunc(e));const s=this.right.splice(this.right.length-i,Number.POSITIVE_INFINITY);return r&&Su(this.left,r),s.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(e){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(e)}pushMany(e){this.setCursor(Number.POSITIVE_INFINITY),Su(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),Su(this.right,e.reverse())}setCursor(e){if(!(e===this.left.length||e>this.left.length&&this.right.length===0||e<0&&this.left.length===0))if(e<this.left.length){const n=this.left.splice(e,Number.POSITIVE_INFINITY);Su(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-e,Number.POSITIVE_INFINITY);Su(this.left,n.reverse())}}}function Su(t,e){let n=0;if(e.length<1e4)t.push(...e);else for(;n<e.length;)t.push(...e.slice(n,n+1e4)),n+=1e4}function bj(t){const e={};let n=-1,r,i,s,a,c,h,d;const f=new a9(t);for(;++n<f.length;){for(;n in e;)n=e[n];if(r=f.get(n),n&&r[1].type==="chunkFlow"&&f.get(n-1)[1].type==="listItemPrefix"&&(h=r[1]._tokenizer.events,s=0,s<h.length&&h[s][1].type==="lineEndingBlank"&&(s+=2),s<h.length&&h[s][1].type==="content"))for(;++s<h.length&&h[s][1].type!=="content";)h[s][1].type==="chunkText"&&(h[s][1]._isInFirstContentOfListItem=!0,s++);if(r[0]==="enter")r[1].contentType&&(Object.assign(e,o9(f,n)),n=e[n],d=!0);else if(r[1]._container){for(s=n,i=void 0;s--;)if(a=f.get(s),a[1].type==="lineEnding"||a[1].type==="lineEndingBlank")a[0]==="enter"&&(i&&(f.get(i)[1].type="lineEndingBlank"),a[1].type="lineEnding",i=s);else if(!(a[1].type==="linePrefix"||a[1].type==="listItemIndent"))break;i&&(r[1].end={...f.get(i)[1].start},c=f.slice(i,n),c.unshift(r),f.splice(i,n-i+1,c))}}return di(t,0,Number.POSITIVE_INFINITY,f.slice(0)),!d}function o9(t,e){const n=t.get(e)[1],r=t.get(e)[2];let i=e-1;const s=[];let a=n._tokenizer;a||(a=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(a._contentTypeTextTrailing=!0));const c=a.events,h=[],d={};let f,p,g=-1,v=n,k=0,w=0;const S=[w];for(;v;){for(;t.get(++i)[1]!==v;);s.push(i),v._tokenizer||(f=r.sliceStream(v),v.next||f.push(null),p&&a.defineSkip(v.start),v._isInFirstContentOfListItem&&(a._gfmTasklistFirstContentOfListItem=!0),a.write(f),v._isInFirstContentOfListItem&&(a._gfmTasklistFirstContentOfListItem=void 0)),p=v,v=v.next}for(v=n;++g<c.length;)c[g][0]==="exit"&&c[g-1][0]==="enter"&&c[g][1].type===c[g-1][1].type&&c[g][1].start.line!==c[g][1].end.line&&(w=g+1,S.push(w),v._tokenizer=void 0,v.previous=void 0,v=v.next);for(a.events=[],v?(v._tokenizer=void 0,v.previous=void 0):S.pop(),g=S.length;g--;){const T=c.slice(S[g],S[g+1]),C=s.pop();h.push([C,C+T.length-1]),t.splice(C,2,T)}for(h.reverse(),g=-1;++g<h.length;)d[k+h[g][0]]=k+h[g][1],k+=h[g][1]-h[g][0]-1;return d}const l9={resolve:u9,tokenize:d9},c9={partial:!0,tokenize:h9};function u9(t){return bj(t),t}function d9(t,e){let n;return r;function r(c){return t.enter("content"),n=t.enter("chunkContent",{contentType:"content"}),i(c)}function i(c){return c===null?s(c):mt(c)?t.check(c9,a,s)(c):(t.consume(c),i)}function s(c){return t.exit("chunkContent"),t.exit("content"),e(c)}function a(c){return t.consume(c),t.exit("chunkContent"),n.next=t.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,i}}function h9(t,e,n){const r=this;return i;function i(a){return t.exit("chunkContent"),t.enter("lineEnding"),t.consume(a),t.exit("lineEnding"),Vt(t,s,"linePrefix")}function s(a){if(a===null||mt(a))return n(a);const c=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes("codeIndented")&&c&&c[1].type==="linePrefix"&&c[2].sliceSerialize(c[1],!0).length>=4?e(a):t.interrupt(r.parser.constructs.flow,n,e)(a)}}function kj(t,e,n,r,i,s,a,c,h){const d=h||Number.POSITIVE_INFINITY;let f=0;return p;function p(T){return T===60?(t.enter(r),t.enter(i),t.enter(s),t.consume(T),t.exit(s),g):T===null||T===32||T===41||Lf(T)?n(T):(t.enter(r),t.enter(a),t.enter(c),t.enter("chunkString",{contentType:"string"}),w(T))}function g(T){return T===62?(t.enter(s),t.consume(T),t.exit(s),t.exit(i),t.exit(r),e):(t.enter(c),t.enter("chunkString",{contentType:"string"}),v(T))}function v(T){return T===62?(t.exit("chunkString"),t.exit(c),g(T)):T===null||T===60||mt(T)?n(T):(t.consume(T),T===92?k:v)}function k(T){return T===60||T===62||T===92?(t.consume(T),v):v(T)}function w(T){return!f&&(T===null||T===41||kn(T))?(t.exit("chunkString"),t.exit(c),t.exit(a),t.exit(r),e(T)):f<d&&T===40?(t.consume(T),f++,w):T===41?(t.consume(T),f--,w):T===null||T===32||T===40||Lf(T)?n(T):(t.consume(T),T===92?S:w)}function S(T){return T===40||T===41||T===92?(t.consume(T),w):w(T)}}function wj(t,e,n,r,i,s){const a=this;let c=0,h;return d;function d(v){return t.enter(r),t.enter(i),t.consume(v),t.exit(i),t.enter(s),f}function f(v){return c>999||v===null||v===91||v===93&&!h||v===94&&!c&&"_hiddenFootnoteSupport"in a.parser.constructs?n(v):v===93?(t.exit(s),t.enter(i),t.consume(v),t.exit(i),t.exit(r),e):mt(v)?(t.enter("lineEnding"),t.consume(v),t.exit("lineEnding"),f):(t.enter("chunkString",{contentType:"string"}),p(v))}function p(v){return v===null||v===91||v===93||mt(v)||c++>999?(t.exit("chunkString"),f(v)):(t.consume(v),h||(h=!Ft(v)),v===92?g:p)}function g(v){return v===91||v===92||v===93?(t.consume(v),c++,p):p(v)}}function Sj(t,e,n,r,i,s){let a;return c;function c(g){return g===34||g===39||g===40?(t.enter(r),t.enter(i),t.consume(g),t.exit(i),a=g===40?41:g,h):n(g)}function h(g){return g===a?(t.enter(i),t.consume(g),t.exit(i),t.exit(r),e):(t.enter(s),d(g))}function d(g){return g===a?(t.exit(s),h(a)):g===null?n(g):mt(g)?(t.enter("lineEnding"),t.consume(g),t.exit("lineEnding"),Vt(t,d,"linePrefix")):(t.enter("chunkString",{contentType:"string"}),f(g))}function f(g){return g===a||g===null||mt(g)?(t.exit("chunkString"),d(g)):(t.consume(g),g===92?p:f)}function p(g){return g===a||g===92?(t.consume(g),f):f(g)}}function Vu(t,e){let n;return r;function r(i){return mt(i)?(t.enter("lineEnding"),t.consume(i),t.exit("lineEnding"),n=!0,r):Ft(i)?Vt(t,r,n?"linePrefix":"lineSuffix")(i):e(i)}}const f9={name:"definition",tokenize:m9},p9={partial:!0,tokenize:g9};function m9(t,e,n){const r=this;let i;return s;function s(v){return t.enter("definition"),a(v)}function a(v){return wj.call(r,t,c,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(v)}function c(v){return i=rs(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),v===58?(t.enter("definitionMarker"),t.consume(v),t.exit("definitionMarker"),h):n(v)}function h(v){return kn(v)?Vu(t,d)(v):d(v)}function d(v){return kj(t,f,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(v)}function f(v){return t.attempt(p9,p,p)(v)}function p(v){return Ft(v)?Vt(t,g,"whitespace")(v):g(v)}function g(v){return v===null||mt(v)?(t.exit("definition"),r.parser.defined.push(i),e(v)):n(v)}}function g9(t,e,n){return r;function r(c){return kn(c)?Vu(t,i)(c):n(c)}function i(c){return Sj(t,s,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(c)}function s(c){return Ft(c)?Vt(t,a,"whitespace")(c):a(c)}function a(c){return c===null||mt(c)?e(c):n(c)}}const v9={name:"hardBreakEscape",tokenize:y9};function y9(t,e,n){return r;function r(s){return t.enter("hardBreakEscape"),t.consume(s),i}function i(s){return mt(s)?(t.exit("hardBreakEscape"),e(s)):n(s)}}const x9={name:"headingAtx",resolve:b9,tokenize:k9};function b9(t,e){let n=t.length-2,r=3,i,s;return t[r][1].type==="whitespace"&&(r+=2),n-2>r&&t[n][1].type==="whitespace"&&(n-=2),t[n][1].type==="atxHeadingSequence"&&(r===n-1||n-4>r&&t[n-2][1].type==="whitespace")&&(n-=r+1===n?2:4),n>r&&(i={type:"atxHeadingText",start:t[r][1].start,end:t[n][1].end},s={type:"chunkText",start:t[r][1].start,end:t[n][1].end,contentType:"text"},di(t,r,n-r+1,[["enter",i,e],["enter",s,e],["exit",s,e],["exit",i,e]])),t}function k9(t,e,n){let r=0;return i;function i(f){return t.enter("atxHeading"),s(f)}function s(f){return t.enter("atxHeadingSequence"),a(f)}function a(f){return f===35&&r++<6?(t.consume(f),a):f===null||kn(f)?(t.exit("atxHeadingSequence"),c(f)):n(f)}function c(f){return f===35?(t.enter("atxHeadingSequence"),h(f)):f===null||mt(f)?(t.exit("atxHeading"),e(f)):Ft(f)?Vt(t,c,"whitespace")(f):(t.enter("atxHeadingText"),d(f))}function h(f){return f===35?(t.consume(f),h):(t.exit("atxHeadingSequence"),c(f))}function d(f){return f===null||f===35||kn(f)?(t.exit("atxHeadingText"),c(f)):(t.consume(f),d)}}const w9=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],dS=["pre","script","style","textarea"],S9={concrete:!0,name:"htmlFlow",resolveTo:N9,tokenize:E9},C9={partial:!0,tokenize:P9},T9={partial:!0,tokenize:j9};function N9(t){let e=t.length;for(;e--&&!(t[e][0]==="enter"&&t[e][1].type==="htmlFlow"););return e>1&&t[e-2][1].type==="linePrefix"&&(t[e][1].start=t[e-2][1].start,t[e+1][1].start=t[e-2][1].start,t.splice(e-2,2)),t}function E9(t,e,n){const r=this;let i,s,a,c,h;return d;function d(B){return f(B)}function f(B){return t.enter("htmlFlow"),t.enter("htmlFlowData"),t.consume(B),p}function p(B){return B===33?(t.consume(B),g):B===47?(t.consume(B),s=!0,w):B===63?(t.consume(B),i=3,r.interrupt?e:A):Ar(B)?(t.consume(B),a=String.fromCharCode(B),S):n(B)}function g(B){return B===45?(t.consume(B),i=2,v):B===91?(t.consume(B),i=5,c=0,k):Ar(B)?(t.consume(B),i=4,r.interrupt?e:A):n(B)}function v(B){return B===45?(t.consume(B),r.interrupt?e:A):n(B)}function k(B){const X="CDATA[";return B===X.charCodeAt(c++)?(t.consume(B),c===X.length?r.interrupt?e:V:k):n(B)}function w(B){return Ar(B)?(t.consume(B),a=String.fromCharCode(B),S):n(B)}function S(B){if(B===null||B===47||B===62||kn(B)){const X=B===47,ye=a.toLowerCase();return!X&&!s&&dS.includes(ye)?(i=1,r.interrupt?e(B):V(B)):w9.includes(a.toLowerCase())?(i=6,X?(t.consume(B),T):r.interrupt?e(B):V(B)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(B):s?C(B):j(B))}return B===45||wr(B)?(t.consume(B),a+=String.fromCharCode(B),S):n(B)}function T(B){return B===62?(t.consume(B),r.interrupt?e:V):n(B)}function C(B){return Ft(B)?(t.consume(B),C):E(B)}function j(B){return B===47?(t.consume(B),E):B===58||B===95||Ar(B)?(t.consume(B),R):Ft(B)?(t.consume(B),j):E(B)}function R(B){return B===45||B===46||B===58||B===95||wr(B)?(t.consume(B),R):_(B)}function _(B){return B===61?(t.consume(B),I):Ft(B)?(t.consume(B),_):j(B)}function I(B){return B===null||B===60||B===61||B===62||B===96?n(B):B===34||B===39?(t.consume(B),h=B,M):Ft(B)?(t.consume(B),I):L(B)}function M(B){return B===h?(t.consume(B),h=null,$):B===null||mt(B)?n(B):(t.consume(B),M)}function L(B){return B===null||B===34||B===39||B===47||B===60||B===61||B===62||B===96||kn(B)?_(B):(t.consume(B),L)}function $(B){return B===47||B===62||Ft(B)?j(B):n(B)}function E(B){return B===62?(t.consume(B),P):n(B)}function P(B){return B===null||mt(B)?V(B):Ft(B)?(t.consume(B),P):n(B)}function V(B){return B===45&&i===2?(t.consume(B),Q):B===60&&i===1?(t.consume(B),Z):B===62&&i===4?(t.consume(B),z):B===63&&i===3?(t.consume(B),A):B===93&&i===5?(t.consume(B),ne):mt(B)&&(i===6||i===7)?(t.exit("htmlFlowData"),t.check(C9,ee,F)(B)):B===null||mt(B)?(t.exit("htmlFlowData"),F(B)):(t.consume(B),V)}function F(B){return t.check(T9,K,ee)(B)}function K(B){return t.enter("lineEnding"),t.consume(B),t.exit("lineEnding"),J}function J(B){return B===null||mt(B)?F(B):(t.enter("htmlFlowData"),V(B))}function Q(B){return B===45?(t.consume(B),A):V(B)}function Z(B){return B===47?(t.consume(B),a="",D):V(B)}function D(B){if(B===62){const X=a.toLowerCase();return dS.includes(X)?(t.consume(B),z):V(B)}return Ar(B)&&a.length<8?(t.consume(B),a+=String.fromCharCode(B),D):V(B)}function ne(B){return B===93?(t.consume(B),A):V(B)}function A(B){return B===62?(t.consume(B),z):B===45&&i===2?(t.consume(B),A):V(B)}function z(B){return B===null||mt(B)?(t.exit("htmlFlowData"),ee(B)):(t.consume(B),z)}function ee(B){return t.exit("htmlFlow"),e(B)}}function j9(t,e,n){const r=this;return i;function i(a){return mt(a)?(t.enter("lineEnding"),t.consume(a),t.exit("lineEnding"),s):n(a)}function s(a){return r.parser.lazy[r.now().line]?n(a):e(a)}}function P9(t,e,n){return r;function r(i){return t.enter("lineEnding"),t.consume(i),t.exit("lineEnding"),t.attempt(Td,e,n)}}const _9={name:"htmlText",tokenize:R9};function R9(t,e,n){const r=this;let i,s,a;return c;function c(A){return t.enter("htmlText"),t.enter("htmlTextData"),t.consume(A),h}function h(A){return A===33?(t.consume(A),d):A===47?(t.consume(A),_):A===63?(t.consume(A),j):Ar(A)?(t.consume(A),L):n(A)}function d(A){return A===45?(t.consume(A),f):A===91?(t.consume(A),s=0,k):Ar(A)?(t.consume(A),C):n(A)}function f(A){return A===45?(t.consume(A),v):n(A)}function p(A){return A===null?n(A):A===45?(t.consume(A),g):mt(A)?(a=p,Z(A)):(t.consume(A),p)}function g(A){return A===45?(t.consume(A),v):p(A)}function v(A){return A===62?Q(A):A===45?g(A):p(A)}function k(A){const z="CDATA[";return A===z.charCodeAt(s++)?(t.consume(A),s===z.length?w:k):n(A)}function w(A){return A===null?n(A):A===93?(t.consume(A),S):mt(A)?(a=w,Z(A)):(t.consume(A),w)}function S(A){return A===93?(t.consume(A),T):w(A)}function T(A){return A===62?Q(A):A===93?(t.consume(A),T):w(A)}function C(A){return A===null||A===62?Q(A):mt(A)?(a=C,Z(A)):(t.consume(A),C)}function j(A){return A===null?n(A):A===63?(t.consume(A),R):mt(A)?(a=j,Z(A)):(t.consume(A),j)}function R(A){return A===62?Q(A):j(A)}function _(A){return Ar(A)?(t.consume(A),I):n(A)}function I(A){return A===45||wr(A)?(t.consume(A),I):M(A)}function M(A){return mt(A)?(a=M,Z(A)):Ft(A)?(t.consume(A),M):Q(A)}function L(A){return A===45||wr(A)?(t.consume(A),L):A===47||A===62||kn(A)?$(A):n(A)}function $(A){return A===47?(t.consume(A),Q):A===58||A===95||Ar(A)?(t.consume(A),E):mt(A)?(a=$,Z(A)):Ft(A)?(t.consume(A),$):Q(A)}function E(A){return A===45||A===46||A===58||A===95||wr(A)?(t.consume(A),E):P(A)}function P(A){return A===61?(t.consume(A),V):mt(A)?(a=P,Z(A)):Ft(A)?(t.consume(A),P):$(A)}function V(A){return A===null||A===60||A===61||A===62||A===96?n(A):A===34||A===39?(t.consume(A),i=A,F):mt(A)?(a=V,Z(A)):Ft(A)?(t.consume(A),V):(t.consume(A),K)}function F(A){return A===i?(t.consume(A),i=void 0,J):A===null?n(A):mt(A)?(a=F,Z(A)):(t.consume(A),F)}function K(A){return A===null||A===34||A===39||A===60||A===61||A===96?n(A):A===47||A===62||kn(A)?$(A):(t.consume(A),K)}function J(A){return A===47||A===62||kn(A)?$(A):n(A)}function Q(A){return A===62?(t.consume(A),t.exit("htmlTextData"),t.exit("htmlText"),e):n(A)}function Z(A){return t.exit("htmlTextData"),t.enter("lineEnding"),t.consume(A),t.exit("lineEnding"),D}function D(A){return Ft(A)?Vt(t,ne,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(A):ne(A)}function ne(A){return t.enter("htmlTextData"),a(A)}}const Gy={name:"labelEnd",resolveAll:A9,resolveTo:O9,tokenize:L9},I9={tokenize:F9},M9={tokenize:U9},D9={tokenize:B9};function A9(t){let e=-1;const n=[];for(;++e<t.length;){const r=t[e][1];if(n.push(t[e]),r.type==="labelImage"||r.type==="labelLink"||r.type==="labelEnd"){const i=r.type==="labelImage"?4:2;r.type="data",e+=i}}return t.length!==n.length&&di(t,0,t.length,n),t}function O9(t,e){let n=t.length,r=0,i,s,a,c;for(;n--;)if(i=t[n][1],s){if(i.type==="link"||i.type==="labelLink"&&i._inactive)break;t[n][0]==="enter"&&i.type==="labelLink"&&(i._inactive=!0)}else if(a){if(t[n][0]==="enter"&&(i.type==="labelImage"||i.type==="labelLink")&&!i._balanced&&(s=n,i.type!=="labelLink")){r=2;break}}else i.type==="labelEnd"&&(a=n);const h={type:t[s][1].type==="labelLink"?"link":"image",start:{...t[s][1].start},end:{...t[t.length-1][1].end}},d={type:"label",start:{...t[s][1].start},end:{...t[a][1].end}},f={type:"labelText",start:{...t[s+r+2][1].end},end:{...t[a-2][1].start}};return c=[["enter",h,e],["enter",d,e]],c=Pi(c,t.slice(s+1,s+r+3)),c=Pi(c,[["enter",f,e]]),c=Pi(c,bp(e.parser.constructs.insideSpan.null,t.slice(s+r+4,a-3),e)),c=Pi(c,[["exit",f,e],t[a-2],t[a-1],["exit",d,e]]),c=Pi(c,t.slice(a+1)),c=Pi(c,[["exit",h,e]]),di(t,s,t.length,c),t}function L9(t,e,n){const r=this;let i=r.events.length,s,a;for(;i--;)if((r.events[i][1].type==="labelImage"||r.events[i][1].type==="labelLink")&&!r.events[i][1]._balanced){s=r.events[i][1];break}return c;function c(g){return s?s._inactive?p(g):(a=r.parser.defined.includes(rs(r.sliceSerialize({start:s.end,end:r.now()}))),t.enter("labelEnd"),t.enter("labelMarker"),t.consume(g),t.exit("labelMarker"),t.exit("labelEnd"),h):n(g)}function h(g){return g===40?t.attempt(I9,f,a?f:p)(g):g===91?t.attempt(M9,f,a?d:p)(g):a?f(g):p(g)}function d(g){return t.attempt(D9,f,p)(g)}function f(g){return e(g)}function p(g){return s._balanced=!0,n(g)}}function F9(t,e,n){return r;function r(p){return t.enter("resource"),t.enter("resourceMarker"),t.consume(p),t.exit("resourceMarker"),i}function i(p){return kn(p)?Vu(t,s)(p):s(p)}function s(p){return p===41?f(p):kj(t,a,c,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(p)}function a(p){return kn(p)?Vu(t,h)(p):f(p)}function c(p){return n(p)}function h(p){return p===34||p===39||p===40?Sj(t,d,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(p):f(p)}function d(p){return kn(p)?Vu(t,f)(p):f(p)}function f(p){return p===41?(t.enter("resourceMarker"),t.consume(p),t.exit("resourceMarker"),t.exit("resource"),e):n(p)}}function U9(t,e,n){const r=this;return i;function i(c){return wj.call(r,t,s,a,"reference","referenceMarker","referenceString")(c)}function s(c){return r.parser.defined.includes(rs(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?e(c):n(c)}function a(c){return n(c)}}function B9(t,e,n){return r;function r(s){return t.enter("reference"),t.enter("referenceMarker"),t.consume(s),t.exit("referenceMarker"),i}function i(s){return s===93?(t.enter("referenceMarker"),t.consume(s),t.exit("referenceMarker"),t.exit("reference"),e):n(s)}}const z9={name:"labelStartImage",resolveAll:Gy.resolveAll,tokenize:$9};function $9(t,e,n){const r=this;return i;function i(c){return t.enter("labelImage"),t.enter("labelImageMarker"),t.consume(c),t.exit("labelImageMarker"),s}function s(c){return c===91?(t.enter("labelMarker"),t.consume(c),t.exit("labelMarker"),t.exit("labelImage"),a):n(c)}function a(c){return c===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(c):e(c)}}const V9={name:"labelStartLink",resolveAll:Gy.resolveAll,tokenize:W9};function W9(t,e,n){const r=this;return i;function i(a){return t.enter("labelLink"),t.enter("labelMarker"),t.consume(a),t.exit("labelMarker"),t.exit("labelLink"),s}function s(a){return a===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(a):e(a)}}const Zg={name:"lineEnding",tokenize:H9};function H9(t,e){return n;function n(r){return t.enter("lineEnding"),t.consume(r),t.exit("lineEnding"),Vt(t,e,"linePrefix")}}const pf={name:"thematicBreak",tokenize:q9};function q9(t,e,n){let r=0,i;return s;function s(d){return t.enter("thematicBreak"),a(d)}function a(d){return i=d,c(d)}function c(d){return d===i?(t.enter("thematicBreakSequence"),h(d)):r>=3&&(d===null||mt(d))?(t.exit("thematicBreak"),e(d)):n(d)}function h(d){return d===i?(t.consume(d),r++,h):(t.exit("thematicBreakSequence"),Ft(d)?Vt(t,c,"whitespace")(d):c(d))}}const Wr={continuation:{tokenize:J9},exit:Q9,name:"list",tokenize:Y9},K9={partial:!0,tokenize:Z9},G9={partial:!0,tokenize:X9};function Y9(t,e,n){const r=this,i=r.events[r.events.length-1];let s=i&&i[1].type==="linePrefix"?i[2].sliceSerialize(i[1],!0).length:0,a=0;return c;function c(v){const k=r.containerState.type||(v===42||v===43||v===45?"listUnordered":"listOrdered");if(k==="listUnordered"?!r.containerState.marker||v===r.containerState.marker:pv(v)){if(r.containerState.type||(r.containerState.type=k,t.enter(k,{_container:!0})),k==="listUnordered")return t.enter("listItemPrefix"),v===42||v===45?t.check(pf,n,d)(v):d(v);if(!r.interrupt||v===49)return t.enter("listItemPrefix"),t.enter("listItemValue"),h(v)}return n(v)}function h(v){return pv(v)&&++a<10?(t.consume(v),h):(!r.interrupt||a<2)&&(r.containerState.marker?v===r.containerState.marker:v===41||v===46)?(t.exit("listItemValue"),d(v)):n(v)}function d(v){return t.enter("listItemMarker"),t.consume(v),t.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||v,t.check(Td,r.interrupt?n:f,t.attempt(K9,g,p))}function f(v){return r.containerState.initialBlankLine=!0,s++,g(v)}function p(v){return Ft(v)?(t.enter("listItemPrefixWhitespace"),t.consume(v),t.exit("listItemPrefixWhitespace"),g):n(v)}function g(v){return r.containerState.size=s+r.sliceSerialize(t.exit("listItemPrefix"),!0).length,e(v)}}function J9(t,e,n){const r=this;return r.containerState._closeFlow=void 0,t.check(Td,i,s);function i(c){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,Vt(t,e,"listItemIndent",r.containerState.size+1)(c)}function s(c){return r.containerState.furtherBlankLines||!Ft(c)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,a(c)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,t.attempt(G9,e,a)(c))}function a(c){return r.containerState._closeFlow=!0,r.interrupt=void 0,Vt(t,t.attempt(Wr,e,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(c)}}function X9(t,e,n){const r=this;return Vt(t,i,"listItemIndent",r.containerState.size+1);function i(s){const a=r.events[r.events.length-1];return a&&a[1].type==="listItemIndent"&&a[2].sliceSerialize(a[1],!0).length===r.containerState.size?e(s):n(s)}}function Q9(t){t.exit(this.containerState.type)}function Z9(t,e,n){const r=this;return Vt(t,i,"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function i(s){const a=r.events[r.events.length-1];return!Ft(s)&&a&&a[1].type==="listItemPrefixWhitespace"?e(s):n(s)}}const hS={name:"setextUnderline",resolveTo:eF,tokenize:tF};function eF(t,e){let n=t.length,r,i,s;for(;n--;)if(t[n][0]==="enter"){if(t[n][1].type==="content"){r=n;break}t[n][1].type==="paragraph"&&(i=n)}else t[n][1].type==="content"&&t.splice(n,1),!s&&t[n][1].type==="definition"&&(s=n);const a={type:"setextHeading",start:{...t[r][1].start},end:{...t[t.length-1][1].end}};return t[i][1].type="setextHeadingText",s?(t.splice(i,0,["enter",a,e]),t.splice(s+1,0,["exit",t[r][1],e]),t[r][1].end={...t[s][1].end}):t[r][1]=a,t.push(["exit",a,e]),t}function tF(t,e,n){const r=this;let i;return s;function s(d){let f=r.events.length,p;for(;f--;)if(r.events[f][1].type!=="lineEnding"&&r.events[f][1].type!=="linePrefix"&&r.events[f][1].type!=="content"){p=r.events[f][1].type==="paragraph";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||p)?(t.enter("setextHeadingLine"),i=d,a(d)):n(d)}function a(d){return t.enter("setextHeadingLineSequence"),c(d)}function c(d){return d===i?(t.consume(d),c):(t.exit("setextHeadingLineSequence"),Ft(d)?Vt(t,h,"lineSuffix")(d):h(d))}function h(d){return d===null||mt(d)?(t.exit("setextHeadingLine"),e(d)):n(d)}}const nF={tokenize:rF};function rF(t){const e=this,n=t.attempt(Td,r,t.attempt(this.parser.constructs.flowInitial,i,Vt(t,t.attempt(this.parser.constructs.flow,i,t.attempt(l9,i)),"linePrefix")));return n;function r(s){if(s===null){t.consume(s);return}return t.enter("lineEndingBlank"),t.consume(s),t.exit("lineEndingBlank"),e.currentConstruct=void 0,n}function i(s){if(s===null){t.consume(s);return}return t.enter("lineEnding"),t.consume(s),t.exit("lineEnding"),e.currentConstruct=void 0,n}}const iF={resolveAll:Tj()},sF=Cj("string"),aF=Cj("text");function Cj(t){return{resolveAll:Tj(t==="text"?oF:void 0),tokenize:e};function e(n){const r=this,i=this.parser.constructs[t],s=n.attempt(i,a,c);return a;function a(f){return d(f)?s(f):c(f)}function c(f){if(f===null){n.consume(f);return}return n.enter("data"),n.consume(f),h}function h(f){return d(f)?(n.exit("data"),s(f)):(n.consume(f),h)}function d(f){if(f===null)return!0;const p=i[f];let g=-1;if(p)for(;++g<p.length;){const v=p[g];if(!v.previous||v.previous.call(r,r.previous))return!0}return!1}}}function Tj(t){return e;function e(n,r){let i=-1,s;for(;++i<=n.length;)s===void 0?n[i]&&n[i][1].type==="data"&&(s=i,i++):(!n[i]||n[i][1].type!=="data")&&(i!==s+2&&(n[s][1].end=n[i-1][1].end,n.splice(s+2,i-s-2),i=s+2),s=void 0);return t?t(n,r):n}}function oF(t,e){let n=0;for(;++n<=t.length;)if((n===t.length||t[n][1].type==="lineEnding")&&t[n-1][1].type==="data"){const r=t[n-1][1],i=e.sliceStream(r);let s=i.length,a=-1,c=0,h;for(;s--;){const d=i[s];if(typeof d=="string"){for(a=d.length;d.charCodeAt(a-1)===32;)c++,a--;if(a)break;a=-1}else if(d===-2)h=!0,c++;else if(d!==-1){s++;break}}if(e._contentTypeTextTrailing&&n===t.length&&(c=0),c){const d={type:n===t.length||h||c<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:s?a:r.start._bufferIndex+a,_index:r.start._index+s,line:r.end.line,column:r.end.column-c,offset:r.end.offset-c},end:{...r.end}};r.end={...d.start},r.start.offset===r.end.offset?Object.assign(r,d):(t.splice(n,0,["enter",d,e],["exit",d,e]),n+=2)}n++}return t}const lF={42:Wr,43:Wr,45:Wr,48:Wr,49:Wr,50:Wr,51:Wr,52:Wr,53:Wr,54:Wr,55:Wr,56:Wr,57:Wr,62:vj},cF={91:f9},uF={[-2]:Qg,[-1]:Qg,32:Qg},dF={35:x9,42:pf,45:[hS,pf],60:S9,61:hS,95:pf,96:uS,126:uS},hF={38:xj,92:yj},fF={[-5]:Zg,[-4]:Zg,[-3]:Zg,33:z9,38:xj,42:mv,60:[V6,_9],91:V9,92:[v9,yj],93:Gy,95:mv,96:n9},pF={null:[mv,iF]},mF={null:[42,95]},gF={null:[]},vF=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:mF,contentInitial:cF,disable:gF,document:lF,flow:dF,flowInitial:uF,insideSpan:pF,string:hF,text:fF},Symbol.toStringTag,{value:"Module"}));function yF(t,e,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0};const i={},s=[];let a=[],c=[];const h={attempt:M(_),check:M(I),consume:C,enter:j,exit:R,interrupt:M(I,{interrupt:!0})},d={code:null,containerState:{},defineSkip:w,events:[],now:k,parser:t,previous:null,sliceSerialize:g,sliceStream:v,write:p};let f=e.tokenize.call(d,h);return e.resolveAll&&s.push(e),d;function p(P){return a=Pi(a,P),S(),a[a.length-1]!==null?[]:(L(e,0),d.events=bp(s,d.events,d),d.events)}function g(P,V){return bF(v(P),V)}function v(P){return xF(a,P)}function k(){const{_bufferIndex:P,_index:V,line:F,column:K,offset:J}=r;return{_bufferIndex:P,_index:V,line:F,column:K,offset:J}}function w(P){i[P.line]=P.column,E()}function S(){let P;for(;r._index<a.length;){const V=a[r._index];if(typeof V=="string")for(P=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===P&&r._bufferIndex<V.length;)T(V.charCodeAt(r._bufferIndex));else T(V)}}function T(P){f=f(P)}function C(P){mt(P)?(r.line++,r.column=1,r.offset+=P===-3?2:1,E()):P!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===a[r._index].length&&(r._bufferIndex=-1,r._index++)),d.previous=P}function j(P,V){const F=V||{};return F.type=P,F.start=k(),d.events.push(["enter",F,d]),c.push(F),F}function R(P){const V=c.pop();return V.end=k(),d.events.push(["exit",V,d]),V}function _(P,V){L(P,V.from)}function I(P,V){V.restore()}function M(P,V){return F;function F(K,J,Q){let Z,D,ne,A;return Array.isArray(K)?ee(K):"tokenize"in K?ee([K]):z(K);function z(se){return oe;function oe(U){const ue=U!==null&&se[U],ke=U!==null&&se.null,W=[...Array.isArray(ue)?ue:ue?[ue]:[],...Array.isArray(ke)?ke:ke?[ke]:[]];return ee(W)(U)}}function ee(se){return Z=se,D=0,se.length===0?Q:B(se[D])}function B(se){return oe;function oe(U){return A=$(),ne=se,se.partial||(d.currentConstruct=se),se.name&&d.parser.constructs.disable.null.includes(se.name)?ye():se.tokenize.call(V?Object.assign(Object.create(d),V):d,h,X,ye)(U)}}function X(se){return P(ne,A),J}function ye(se){return A.restore(),++D<Z.length?B(Z[D]):Q}}}function L(P,V){P.resolveAll&&!s.includes(P)&&s.push(P),P.resolve&&di(d.events,V,d.events.length-V,P.resolve(d.events.slice(V),d)),P.resolveTo&&(d.events=P.resolveTo(d.events,d))}function $(){const P=k(),V=d.previous,F=d.currentConstruct,K=d.events.length,J=Array.from(c);return{from:K,restore:Q};function Q(){r=P,d.previous=V,d.currentConstruct=F,d.events.length=K,c=J,E()}}function E(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function xF(t,e){const n=e.start._index,r=e.start._bufferIndex,i=e.end._index,s=e.end._bufferIndex;let a;if(n===i)a=[t[n].slice(r,s)];else{if(a=t.slice(n,i),r>-1){const c=a[0];typeof c=="string"?a[0]=c.slice(r):a.shift()}s>0&&a.push(t[i].slice(0,s))}return a}function bF(t,e){let n=-1;const r=[];let i;for(;++n<t.length;){const s=t[n];let a;if(typeof s=="string")a=s;else switch(s){case-5:{a="\r";break}case-4:{a=`
499
+ `;break}case-3:{a=`\r
500
+ `;break}case-2:{a=e?" ":" ";break}case-1:{if(!e&&i)continue;a=" ";break}default:a=String.fromCharCode(s)}i=s===-2,r.push(a)}return r.join("")}function kF(t){const r={constructs:mj([vF,...(t||{}).extensions||[]]),content:i(O6),defined:[],document:i(F6),flow:i(nF),lazy:{},string:i(sF),text:i(aF)};return r;function i(s){return a;function a(c){return yF(r,s,c)}}}function wF(t){for(;!bj(t););return t}const fS=/[\0\t\n\r]/g;function SF(){let t=1,e="",n=!0,r;return i;function i(s,a,c){const h=[];let d,f,p,g,v;for(s=e+(typeof s=="string"?s.toString():new TextDecoder(a||void 0).decode(s)),p=0,e="",n&&(s.charCodeAt(0)===65279&&p++,n=void 0);p<s.length;){if(fS.lastIndex=p,d=fS.exec(s),g=d&&d.index!==void 0?d.index:s.length,v=s.charCodeAt(g),!d){e=s.slice(p);break}if(v===10&&p===g&&r)h.push(-3),r=void 0;else switch(r&&(h.push(-5),r=void 0),p<g&&(h.push(s.slice(p,g)),t+=g-p),v){case 0:{h.push(65533),t++;break}case 9:{for(f=Math.ceil(t/4)*4,h.push(-2);t++<f;)h.push(-1);break}case 10:{h.push(-4),t=1;break}default:r=!0,t=1}p=g+1}return c&&(r&&h.push(-5),e&&h.push(e),h.push(null)),h}}const CF=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function TF(t){return t.replace(CF,NF)}function NF(t,e,n){if(e)return e;if(n.charCodeAt(0)===35){const i=n.charCodeAt(1),s=i===120||i===88;return gj(n.slice(s?2:1),s?16:10)}return Ky(n)||t}const Nj={}.hasOwnProperty;function EF(t,e,n){return e&&typeof e=="object"&&(n=e,e=void 0),jF(n)(wF(kF(n).document().write(SF()(t,e,!0))))}function jF(t){const e={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:s(_e),autolinkProtocol:$,autolinkEmail:$,atxHeading:s(Se),blockQuote:s(ke),characterEscape:$,characterReference:$,codeFenced:s(W),codeFencedFenceInfo:a,codeFencedFenceMeta:a,codeIndented:s(W,a),codeText:s(q,a),codeTextData:$,data:$,codeFlowValue:$,definition:s(fe),definitionDestinationString:a,definitionLabelString:a,definitionTitleString:a,emphasis:s(ve),hardBreakEscape:s(Ke),hardBreakTrailing:s(Ke),htmlFlow:s(dt,a),htmlFlowData:$,htmlText:s(dt,a),htmlTextData:$,image:s(Ge),label:a,link:s(_e),listItem:s(xt),listItemValue:g,listOrdered:s(Ve,p),listUnordered:s(Ve),paragraph:s(Pt),reference:B,referenceString:a,resourceDestinationString:a,resourceTitleString:a,setextHeading:s(Se),strong:s(mn),thematicBreak:s(jn)},exit:{atxHeading:h(),atxHeadingSequence:_,autolink:h(),autolinkEmail:ue,autolinkProtocol:U,blockQuote:h(),characterEscapeValue:E,characterReferenceMarkerHexadecimal:ye,characterReferenceMarkerNumeric:ye,characterReferenceValue:se,characterReference:oe,codeFenced:h(S),codeFencedFence:w,codeFencedFenceInfo:v,codeFencedFenceMeta:k,codeFlowValue:E,codeIndented:h(T),codeText:h(J),codeTextData:E,data:E,definition:h(),definitionDestinationString:R,definitionLabelString:C,definitionTitleString:j,emphasis:h(),hardBreakEscape:h(V),hardBreakTrailing:h(V),htmlFlow:h(F),htmlFlowData:E,htmlText:h(K),htmlTextData:E,image:h(Z),label:ne,labelText:D,lineEnding:P,link:h(Q),listItem:h(),listOrdered:h(),listUnordered:h(),paragraph:h(),referenceString:X,resourceDestinationString:A,resourceTitleString:z,resource:ee,setextHeading:h(L),setextHeadingLineSequence:M,setextHeadingText:I,strong:h(),thematicBreak:h()}};Ej(e,(t||{}).mdastExtensions||[]);const n={};return r;function r(xe){let Re={type:"root",children:[]};const Qe={stack:[Re],tokenStack:[],config:e,enter:c,exit:d,buffer:a,resume:f,data:n},He=[];let gt=-1;for(;++gt<xe.length;)if(xe[gt][1].type==="listOrdered"||xe[gt][1].type==="listUnordered")if(xe[gt][0]==="enter")He.push(gt);else{const hn=He.pop();gt=i(xe,hn,gt)}for(gt=-1;++gt<xe.length;){const hn=e[xe[gt][0]];Nj.call(hn,xe[gt][1].type)&&hn[xe[gt][1].type].call(Object.assign({sliceSerialize:xe[gt][2].sliceSerialize},Qe),xe[gt][1])}if(Qe.tokenStack.length>0){const hn=Qe.tokenStack[Qe.tokenStack.length-1];(hn[1]||pS).call(Qe,void 0,hn[0])}for(Re.position={start:$a(xe.length>0?xe[0][1].start:{line:1,column:1,offset:0}),end:$a(xe.length>0?xe[xe.length-2][1].end:{line:1,column:1,offset:0})},gt=-1;++gt<e.transforms.length;)Re=e.transforms[gt](Re)||Re;return Re}function i(xe,Re,Qe){let He=Re-1,gt=-1,hn=!1,vn,Fn,pe,Ue;for(;++He<=Qe;){const ze=xe[He];switch(ze[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{ze[0]==="enter"?gt++:gt--,Ue=void 0;break}case"lineEndingBlank":{ze[0]==="enter"&&(vn&&!Ue&&!gt&&!pe&&(pe=He),Ue=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:Ue=void 0}if(!gt&&ze[0]==="enter"&&ze[1].type==="listItemPrefix"||gt===-1&&ze[0]==="exit"&&(ze[1].type==="listUnordered"||ze[1].type==="listOrdered")){if(vn){let Wt=He;for(Fn=void 0;Wt--;){const bt=xe[Wt];if(bt[1].type==="lineEnding"||bt[1].type==="lineEndingBlank"){if(bt[0]==="exit")continue;Fn&&(xe[Fn][1].type="lineEndingBlank",hn=!0),bt[1].type="lineEnding",Fn=Wt}else if(!(bt[1].type==="linePrefix"||bt[1].type==="blockQuotePrefix"||bt[1].type==="blockQuotePrefixWhitespace"||bt[1].type==="blockQuoteMarker"||bt[1].type==="listItemIndent"))break}pe&&(!Fn||pe<Fn)&&(vn._spread=!0),vn.end=Object.assign({},Fn?xe[Fn][1].start:ze[1].end),xe.splice(Fn||He,0,["exit",vn,ze[2]]),He++,Qe++}if(ze[1].type==="listItemPrefix"){const Wt={type:"listItem",_spread:!1,start:Object.assign({},ze[1].start),end:void 0};vn=Wt,xe.splice(He,0,["enter",Wt,ze[2]]),He++,Qe++,pe=void 0,Ue=!0}}}return xe[Re][1]._spread=hn,Qe}function s(xe,Re){return Qe;function Qe(He){c.call(this,xe(He),He),Re&&Re.call(this,He)}}function a(){this.stack.push({type:"fragment",children:[]})}function c(xe,Re,Qe){this.stack[this.stack.length-1].children.push(xe),this.stack.push(xe),this.tokenStack.push([Re,Qe||void 0]),xe.position={start:$a(Re.start),end:void 0}}function h(xe){return Re;function Re(Qe){xe&&xe.call(this,Qe),d.call(this,Qe)}}function d(xe,Re){const Qe=this.stack.pop(),He=this.tokenStack.pop();if(He)He[0].type!==xe.type&&(Re?Re.call(this,xe,He[0]):(He[1]||pS).call(this,xe,He[0]));else throw new Error("Cannot close `"+xe.type+"` ("+$u({start:xe.start,end:xe.end})+"): it’s not open");Qe.position.end=$a(xe.end)}function f(){return qy(this.stack.pop())}function p(){this.data.expectingFirstListItemValue=!0}function g(xe){if(this.data.expectingFirstListItemValue){const Re=this.stack[this.stack.length-2];Re.start=Number.parseInt(this.sliceSerialize(xe),10),this.data.expectingFirstListItemValue=void 0}}function v(){const xe=this.resume(),Re=this.stack[this.stack.length-1];Re.lang=xe}function k(){const xe=this.resume(),Re=this.stack[this.stack.length-1];Re.meta=xe}function w(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function S(){const xe=this.resume(),Re=this.stack[this.stack.length-1];Re.value=xe.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function T(){const xe=this.resume(),Re=this.stack[this.stack.length-1];Re.value=xe.replace(/(\r?\n|\r)$/g,"")}function C(xe){const Re=this.resume(),Qe=this.stack[this.stack.length-1];Qe.label=Re,Qe.identifier=rs(this.sliceSerialize(xe)).toLowerCase()}function j(){const xe=this.resume(),Re=this.stack[this.stack.length-1];Re.title=xe}function R(){const xe=this.resume(),Re=this.stack[this.stack.length-1];Re.url=xe}function _(xe){const Re=this.stack[this.stack.length-1];if(!Re.depth){const Qe=this.sliceSerialize(xe).length;Re.depth=Qe}}function I(){this.data.setextHeadingSlurpLineEnding=!0}function M(xe){const Re=this.stack[this.stack.length-1];Re.depth=this.sliceSerialize(xe).codePointAt(0)===61?1:2}function L(){this.data.setextHeadingSlurpLineEnding=void 0}function $(xe){const Qe=this.stack[this.stack.length-1].children;let He=Qe[Qe.length-1];(!He||He.type!=="text")&&(He=gn(),He.position={start:$a(xe.start),end:void 0},Qe.push(He)),this.stack.push(He)}function E(xe){const Re=this.stack.pop();Re.value+=this.sliceSerialize(xe),Re.position.end=$a(xe.end)}function P(xe){const Re=this.stack[this.stack.length-1];if(this.data.atHardBreak){const Qe=Re.children[Re.children.length-1];Qe.position.end=$a(xe.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&e.canContainEols.includes(Re.type)&&($.call(this,xe),E.call(this,xe))}function V(){this.data.atHardBreak=!0}function F(){const xe=this.resume(),Re=this.stack[this.stack.length-1];Re.value=xe}function K(){const xe=this.resume(),Re=this.stack[this.stack.length-1];Re.value=xe}function J(){const xe=this.resume(),Re=this.stack[this.stack.length-1];Re.value=xe}function Q(){const xe=this.stack[this.stack.length-1];if(this.data.inReference){const Re=this.data.referenceType||"shortcut";xe.type+="Reference",xe.referenceType=Re,delete xe.url,delete xe.title}else delete xe.identifier,delete xe.label;this.data.referenceType=void 0}function Z(){const xe=this.stack[this.stack.length-1];if(this.data.inReference){const Re=this.data.referenceType||"shortcut";xe.type+="Reference",xe.referenceType=Re,delete xe.url,delete xe.title}else delete xe.identifier,delete xe.label;this.data.referenceType=void 0}function D(xe){const Re=this.sliceSerialize(xe),Qe=this.stack[this.stack.length-2];Qe.label=TF(Re),Qe.identifier=rs(Re).toLowerCase()}function ne(){const xe=this.stack[this.stack.length-1],Re=this.resume(),Qe=this.stack[this.stack.length-1];if(this.data.inReference=!0,Qe.type==="link"){const He=xe.children;Qe.children=He}else Qe.alt=Re}function A(){const xe=this.resume(),Re=this.stack[this.stack.length-1];Re.url=xe}function z(){const xe=this.resume(),Re=this.stack[this.stack.length-1];Re.title=xe}function ee(){this.data.inReference=void 0}function B(){this.data.referenceType="collapsed"}function X(xe){const Re=this.resume(),Qe=this.stack[this.stack.length-1];Qe.label=Re,Qe.identifier=rs(this.sliceSerialize(xe)).toLowerCase(),this.data.referenceType="full"}function ye(xe){this.data.characterReferenceType=xe.type}function se(xe){const Re=this.sliceSerialize(xe),Qe=this.data.characterReferenceType;let He;Qe?(He=gj(Re,Qe==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):He=Ky(Re);const gt=this.stack[this.stack.length-1];gt.value+=He}function oe(xe){const Re=this.stack.pop();Re.position.end=$a(xe.end)}function U(xe){E.call(this,xe);const Re=this.stack[this.stack.length-1];Re.url=this.sliceSerialize(xe)}function ue(xe){E.call(this,xe);const Re=this.stack[this.stack.length-1];Re.url="mailto:"+this.sliceSerialize(xe)}function ke(){return{type:"blockquote",children:[]}}function W(){return{type:"code",lang:null,meta:null,value:""}}function q(){return{type:"inlineCode",value:""}}function fe(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function ve(){return{type:"emphasis",children:[]}}function Se(){return{type:"heading",depth:0,children:[]}}function Ke(){return{type:"break"}}function dt(){return{type:"html",value:""}}function Ge(){return{type:"image",title:null,url:"",alt:null}}function _e(){return{type:"link",title:null,url:"",children:[]}}function Ve(xe){return{type:"list",ordered:xe.type==="listOrdered",start:null,spread:xe._spread,children:[]}}function xt(xe){return{type:"listItem",spread:xe._spread,checked:null,children:[]}}function Pt(){return{type:"paragraph",children:[]}}function mn(){return{type:"strong",children:[]}}function gn(){return{type:"text",value:""}}function jn(){return{type:"thematicBreak"}}}function $a(t){return{line:t.line,column:t.column,offset:t.offset}}function Ej(t,e){let n=-1;for(;++n<e.length;){const r=e[n];Array.isArray(r)?Ej(t,r):PF(t,r)}}function PF(t,e){let n;for(n in e)if(Nj.call(e,n))switch(n){case"canContainEols":{const r=e[n];r&&t[n].push(...r);break}case"transforms":{const r=e[n];r&&t[n].push(...r);break}case"enter":case"exit":{const r=e[n];r&&Object.assign(t[n],r);break}}}function pS(t,e){throw t?new Error("Cannot close `"+t.type+"` ("+$u({start:t.start,end:t.end})+"): a different token (`"+e.type+"`, "+$u({start:e.start,end:e.end})+") is open"):new Error("Cannot close document, a token (`"+e.type+"`, "+$u({start:e.start,end:e.end})+") is still open")}function _F(t){const e=this;e.parser=n;function n(r){return EF(r,{...e.data("settings"),...t,extensions:e.data("micromarkExtensions")||[],mdastExtensions:e.data("fromMarkdownExtensions")||[]})}}function RF(t,e){const n={type:"element",tagName:"blockquote",properties:{},children:t.wrap(t.all(e),!0)};return t.patch(e,n),t.applyData(e,n)}function IF(t,e){const n={type:"element",tagName:"br",properties:{},children:[]};return t.patch(e,n),[t.applyData(e,n),{type:"text",value:`
501
+ `}]}function MF(t,e){const n=e.value?e.value+`
502
+ `:"",r={},i=e.lang?e.lang.split(/\s+/):[];i.length>0&&(r.className=["language-"+i[0]]);let s={type:"element",tagName:"code",properties:r,children:[{type:"text",value:n}]};return e.meta&&(s.data={meta:e.meta}),t.patch(e,s),s=t.applyData(e,s),s={type:"element",tagName:"pre",properties:{},children:[s]},t.patch(e,s),s}function DF(t,e){const n={type:"element",tagName:"del",properties:{},children:t.all(e)};return t.patch(e,n),t.applyData(e,n)}function AF(t,e){const n={type:"element",tagName:"em",properties:{},children:t.all(e)};return t.patch(e,n),t.applyData(e,n)}function OF(t,e){const n=typeof t.options.clobberPrefix=="string"?t.options.clobberPrefix:"user-content-",r=String(e.identifier).toUpperCase(),i=Mc(r.toLowerCase()),s=t.footnoteOrder.indexOf(r);let a,c=t.footnoteCounts.get(r);c===void 0?(c=0,t.footnoteOrder.push(r),a=t.footnoteOrder.length):a=s+1,c+=1,t.footnoteCounts.set(r,c);const h={type:"element",tagName:"a",properties:{href:"#"+n+"fn-"+i,id:n+"fnref-"+i+(c>1?"-"+c:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(a)}]};t.patch(e,h);const d={type:"element",tagName:"sup",properties:{},children:[h]};return t.patch(e,d),t.applyData(e,d)}function LF(t,e){const n={type:"element",tagName:"h"+e.depth,properties:{},children:t.all(e)};return t.patch(e,n),t.applyData(e,n)}function FF(t,e){if(t.options.allowDangerousHtml){const n={type:"raw",value:e.value};return t.patch(e,n),t.applyData(e,n)}}function jj(t,e){const n=e.referenceType;let r="]";if(n==="collapsed"?r+="[]":n==="full"&&(r+="["+(e.label||e.identifier)+"]"),e.type==="imageReference")return[{type:"text",value:"!["+e.alt+r}];const i=t.all(e),s=i[0];s&&s.type==="text"?s.value="["+s.value:i.unshift({type:"text",value:"["});const a=i[i.length-1];return a&&a.type==="text"?a.value+=r:i.push({type:"text",value:r}),i}function UF(t,e){const n=String(e.identifier).toUpperCase(),r=t.definitionById.get(n);if(!r)return jj(t,e);const i={src:Mc(r.url||""),alt:e.alt};r.title!==null&&r.title!==void 0&&(i.title=r.title);const s={type:"element",tagName:"img",properties:i,children:[]};return t.patch(e,s),t.applyData(e,s)}function BF(t,e){const n={src:Mc(e.url)};e.alt!==null&&e.alt!==void 0&&(n.alt=e.alt),e.title!==null&&e.title!==void 0&&(n.title=e.title);const r={type:"element",tagName:"img",properties:n,children:[]};return t.patch(e,r),t.applyData(e,r)}function zF(t,e){const n={type:"text",value:e.value.replace(/\r?\n|\r/g," ")};t.patch(e,n);const r={type:"element",tagName:"code",properties:{},children:[n]};return t.patch(e,r),t.applyData(e,r)}function $F(t,e){const n=String(e.identifier).toUpperCase(),r=t.definitionById.get(n);if(!r)return jj(t,e);const i={href:Mc(r.url||"")};r.title!==null&&r.title!==void 0&&(i.title=r.title);const s={type:"element",tagName:"a",properties:i,children:t.all(e)};return t.patch(e,s),t.applyData(e,s)}function VF(t,e){const n={href:Mc(e.url)};e.title!==null&&e.title!==void 0&&(n.title=e.title);const r={type:"element",tagName:"a",properties:n,children:t.all(e)};return t.patch(e,r),t.applyData(e,r)}function WF(t,e,n){const r=t.all(e),i=n?HF(n):Pj(e),s={},a=[];if(typeof e.checked=="boolean"){const f=r[0];let p;f&&f.type==="element"&&f.tagName==="p"?p=f:(p={type:"element",tagName:"p",properties:{},children:[]},r.unshift(p)),p.children.length>0&&p.children.unshift({type:"text",value:" "}),p.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:e.checked,disabled:!0},children:[]}),s.className=["task-list-item"]}let c=-1;for(;++c<r.length;){const f=r[c];(i||c!==0||f.type!=="element"||f.tagName!=="p")&&a.push({type:"text",value:`
503
+ `}),f.type==="element"&&f.tagName==="p"&&!i?a.push(...f.children):a.push(f)}const h=r[r.length-1];h&&(i||h.type!=="element"||h.tagName!=="p")&&a.push({type:"text",value:`
504
+ `});const d={type:"element",tagName:"li",properties:s,children:a};return t.patch(e,d),t.applyData(e,d)}function HF(t){let e=!1;if(t.type==="list"){e=t.spread||!1;const n=t.children;let r=-1;for(;!e&&++r<n.length;)e=Pj(n[r])}return e}function Pj(t){const e=t.spread;return e??t.children.length>1}function qF(t,e){const n={},r=t.all(e);let i=-1;for(typeof e.start=="number"&&e.start!==1&&(n.start=e.start);++i<r.length;){const a=r[i];if(a.type==="element"&&a.tagName==="li"&&a.properties&&Array.isArray(a.properties.className)&&a.properties.className.includes("task-list-item")){n.className=["contains-task-list"];break}}const s={type:"element",tagName:e.ordered?"ol":"ul",properties:n,children:t.wrap(r,!0)};return t.patch(e,s),t.applyData(e,s)}function KF(t,e){const n={type:"element",tagName:"p",properties:{},children:t.all(e)};return t.patch(e,n),t.applyData(e,n)}function GF(t,e){const n={type:"root",children:t.wrap(t.all(e))};return t.patch(e,n),t.applyData(e,n)}function YF(t,e){const n={type:"element",tagName:"strong",properties:{},children:t.all(e)};return t.patch(e,n),t.applyData(e,n)}function JF(t,e){const n=t.all(e),r=n.shift(),i=[];if(r){const a={type:"element",tagName:"thead",properties:{},children:t.wrap([r],!0)};t.patch(e.children[0],a),i.push(a)}if(n.length>0){const a={type:"element",tagName:"tbody",properties:{},children:t.wrap(n,!0)},c=$y(e.children[1]),h=lj(e.children[e.children.length-1]);c&&h&&(a.position={start:c,end:h}),i.push(a)}const s={type:"element",tagName:"table",properties:{},children:t.wrap(i,!0)};return t.patch(e,s),t.applyData(e,s)}function XF(t,e,n){const r=n?n.children:void 0,s=(r?r.indexOf(e):1)===0?"th":"td",a=n&&n.type==="table"?n.align:void 0,c=a?a.length:e.children.length;let h=-1;const d=[];for(;++h<c;){const p=e.children[h],g={},v=a?a[h]:void 0;v&&(g.align=v);let k={type:"element",tagName:s,properties:g,children:[]};p&&(k.children=t.all(p),t.patch(p,k),k=t.applyData(p,k)),d.push(k)}const f={type:"element",tagName:"tr",properties:{},children:t.wrap(d,!0)};return t.patch(e,f),t.applyData(e,f)}function QF(t,e){const n={type:"element",tagName:"td",properties:{},children:t.all(e)};return t.patch(e,n),t.applyData(e,n)}const mS=9,gS=32;function ZF(t){const e=String(t),n=/\r?\n|\r/g;let r=n.exec(e),i=0;const s=[];for(;r;)s.push(vS(e.slice(i,r.index),i>0,!0),r[0]),i=r.index+r[0].length,r=n.exec(e);return s.push(vS(e.slice(i),i>0,!1)),s.join("")}function vS(t,e,n){let r=0,i=t.length;if(e){let s=t.codePointAt(r);for(;s===mS||s===gS;)r++,s=t.codePointAt(r)}if(n){let s=t.codePointAt(i-1);for(;s===mS||s===gS;)i--,s=t.codePointAt(i-1)}return i>r?t.slice(r,i):""}function eU(t,e){const n={type:"text",value:ZF(String(e.value))};return t.patch(e,n),t.applyData(e,n)}function tU(t,e){const n={type:"element",tagName:"hr",properties:{},children:[]};return t.patch(e,n),t.applyData(e,n)}const nU={blockquote:RF,break:IF,code:MF,delete:DF,emphasis:AF,footnoteReference:OF,heading:LF,html:FF,imageReference:UF,image:BF,inlineCode:zF,linkReference:$F,link:VF,listItem:WF,list:qF,paragraph:KF,root:GF,strong:YF,table:JF,tableCell:QF,tableRow:XF,text:eU,thematicBreak:tU,toml:Gh,yaml:Gh,definition:Gh,footnoteDefinition:Gh};function Gh(){}const _j=-1,kp=0,Wu=1,Ff=2,Yy=3,Jy=4,Xy=5,Qy=6,Rj=7,Ij=8,yS=typeof self=="object"?self:globalThis,rU=(t,e)=>{const n=(i,s)=>(t.set(s,i),i),r=i=>{if(t.has(i))return t.get(i);const[s,a]=e[i];switch(s){case kp:case _j:return n(a,i);case Wu:{const c=n([],i);for(const h of a)c.push(r(h));return c}case Ff:{const c=n({},i);for(const[h,d]of a)c[r(h)]=r(d);return c}case Yy:return n(new Date(a),i);case Jy:{const{source:c,flags:h}=a;return n(new RegExp(c,h),i)}case Xy:{const c=n(new Map,i);for(const[h,d]of a)c.set(r(h),r(d));return c}case Qy:{const c=n(new Set,i);for(const h of a)c.add(r(h));return c}case Rj:{const{name:c,message:h}=a;return n(new yS[c](h),i)}case Ij:return n(BigInt(a),i);case"BigInt":return n(Object(BigInt(a)),i);case"ArrayBuffer":return n(new Uint8Array(a).buffer,a);case"DataView":{const{buffer:c}=new Uint8Array(a);return n(new DataView(c),a)}}return n(new yS[s](a),i)};return r},xS=t=>rU(new Map,t)(0),Gl="",{toString:iU}={},{keys:sU}=Object,Cu=t=>{const e=typeof t;if(e!=="object"||!t)return[kp,e];const n=iU.call(t).slice(8,-1);switch(n){case"Array":return[Wu,Gl];case"Object":return[Ff,Gl];case"Date":return[Yy,Gl];case"RegExp":return[Jy,Gl];case"Map":return[Xy,Gl];case"Set":return[Qy,Gl];case"DataView":return[Wu,n]}return n.includes("Array")?[Wu,n]:n.includes("Error")?[Rj,n]:[Ff,n]},Yh=([t,e])=>t===kp&&(e==="function"||e==="symbol"),aU=(t,e,n,r)=>{const i=(a,c)=>{const h=r.push(a)-1;return n.set(c,h),h},s=a=>{if(n.has(a))return n.get(a);let[c,h]=Cu(a);switch(c){case kp:{let f=a;switch(h){case"bigint":c=Ij,f=a.toString();break;case"function":case"symbol":if(t)throw new TypeError("unable to serialize "+h);f=null;break;case"undefined":return i([_j],a)}return i([c,f],a)}case Wu:{if(h){let g=a;return h==="DataView"?g=new Uint8Array(a.buffer):h==="ArrayBuffer"&&(g=new Uint8Array(a)),i([h,[...g]],a)}const f=[],p=i([c,f],a);for(const g of a)f.push(s(g));return p}case Ff:{if(h)switch(h){case"BigInt":return i([h,a.toString()],a);case"Boolean":case"Number":case"String":return i([h,a.valueOf()],a)}if(e&&"toJSON"in a)return s(a.toJSON());const f=[],p=i([c,f],a);for(const g of sU(a))(t||!Yh(Cu(a[g])))&&f.push([s(g),s(a[g])]);return p}case Yy:return i([c,a.toISOString()],a);case Jy:{const{source:f,flags:p}=a;return i([c,{source:f,flags:p}],a)}case Xy:{const f=[],p=i([c,f],a);for(const[g,v]of a)(t||!(Yh(Cu(g))||Yh(Cu(v))))&&f.push([s(g),s(v)]);return p}case Qy:{const f=[],p=i([c,f],a);for(const g of a)(t||!Yh(Cu(g)))&&f.push(s(g));return p}}const{message:d}=a;return i([c,{name:h,message:d}],a)};return s},bS=(t,{json:e,lossy:n}={})=>{const r=[];return aU(!(e||n),!!e,new Map,r)(t),r},Uf=typeof structuredClone=="function"?(t,e)=>e&&("json"in e||"lossy"in e)?xS(bS(t,e)):structuredClone(t):(t,e)=>xS(bS(t,e));function oU(t,e){const n=[{type:"text",value:"↩"}];return e>1&&n.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(e)}]}),n}function lU(t,e){return"Back to reference "+(t+1)+(e>1?"-"+e:"")}function cU(t){const e=typeof t.options.clobberPrefix=="string"?t.options.clobberPrefix:"user-content-",n=t.options.footnoteBackContent||oU,r=t.options.footnoteBackLabel||lU,i=t.options.footnoteLabel||"Footnotes",s=t.options.footnoteLabelTagName||"h2",a=t.options.footnoteLabelProperties||{className:["sr-only"]},c=[];let h=-1;for(;++h<t.footnoteOrder.length;){const d=t.footnoteById.get(t.footnoteOrder[h]);if(!d)continue;const f=t.all(d),p=String(d.identifier).toUpperCase(),g=Mc(p.toLowerCase());let v=0;const k=[],w=t.footnoteCounts.get(p);for(;w!==void 0&&++v<=w;){k.length>0&&k.push({type:"text",value:" "});let C=typeof n=="string"?n:n(h,v);typeof C=="string"&&(C={type:"text",value:C}),k.push({type:"element",tagName:"a",properties:{href:"#"+e+"fnref-"+g+(v>1?"-"+v:""),dataFootnoteBackref:"",ariaLabel:typeof r=="string"?r:r(h,v),className:["data-footnote-backref"]},children:Array.isArray(C)?C:[C]})}const S=f[f.length-1];if(S&&S.type==="element"&&S.tagName==="p"){const C=S.children[S.children.length-1];C&&C.type==="text"?C.value+=" ":S.children.push({type:"text",value:" "}),S.children.push(...k)}else f.push(...k);const T={type:"element",tagName:"li",properties:{id:e+"fn-"+g},children:t.wrap(f,!0)};t.patch(d,T),c.push(T)}if(c.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:s,properties:{...Uf(a),id:"footnote-label"},children:[{type:"text",value:i}]},{type:"text",value:`
505
+ `},{type:"element",tagName:"ol",properties:{},children:t.wrap(c,!0)},{type:"text",value:`
506
+ `}]}}const wp=(function(t){if(t==null)return fU;if(typeof t=="function")return Sp(t);if(typeof t=="object")return Array.isArray(t)?uU(t):dU(t);if(typeof t=="string")return hU(t);throw new Error("Expected function, string, or object as test")});function uU(t){const e=[];let n=-1;for(;++n<t.length;)e[n]=wp(t[n]);return Sp(r);function r(...i){let s=-1;for(;++s<e.length;)if(e[s].apply(this,i))return!0;return!1}}function dU(t){const e=t;return Sp(n);function n(r){const i=r;let s;for(s in t)if(i[s]!==e[s])return!1;return!0}}function hU(t){return Sp(e);function e(n){return n&&n.type===t}}function Sp(t){return e;function e(n,r,i){return!!(pU(n)&&t.call(this,n,typeof r=="number"?r:void 0,i||void 0))}}function fU(){return!0}function pU(t){return t!==null&&typeof t=="object"&&"type"in t}const Mj=[],mU=!0,gv=!1,gU="skip";function Dj(t,e,n,r){let i;typeof e=="function"&&typeof n!="function"?(r=n,n=e):i=e;const s=wp(i),a=r?-1:1;c(t,void 0,[])();function c(h,d,f){const p=h&&typeof h=="object"?h:{};if(typeof p.type=="string"){const v=typeof p.tagName=="string"?p.tagName:typeof p.name=="string"?p.name:void 0;Object.defineProperty(g,"name",{value:"node ("+(h.type+(v?"<"+v+">":""))+")"})}return g;function g(){let v=Mj,k,w,S;if((!e||s(h,d,f[f.length-1]||void 0))&&(v=vU(n(h,f)),v[0]===gv))return v;if("children"in h&&h.children){const T=h;if(T.children&&v[0]!==gU)for(w=(r?T.children.length:-1)+a,S=f.concat(T);w>-1&&w<T.children.length;){const C=T.children[w];if(k=c(C,w,S)(),k[0]===gv)return k;w=typeof k[1]=="number"?k[1]:w+a}}return v}}}function vU(t){return Array.isArray(t)?t:typeof t=="number"?[mU,t]:t==null?Mj:[t]}function Zy(t,e,n,r){let i,s,a;typeof e=="function"&&typeof n!="function"?(s=void 0,a=e,i=n):(s=e,a=n,i=r),Dj(t,s,c,i);function c(h,d){const f=d[d.length-1],p=f?f.children.indexOf(h):void 0;return a(h,p,f)}}const vv={}.hasOwnProperty,yU={};function xU(t,e){const n=e||yU,r=new Map,i=new Map,s=new Map,a={...nU,...n.handlers},c={all:d,applyData:kU,definitionById:r,footnoteById:i,footnoteCounts:s,footnoteOrder:[],handlers:a,one:h,options:n,patch:bU,wrap:SU};return Zy(t,function(f){if(f.type==="definition"||f.type==="footnoteDefinition"){const p=f.type==="definition"?r:i,g=String(f.identifier).toUpperCase();p.has(g)||p.set(g,f)}}),c;function h(f,p){const g=f.type,v=c.handlers[g];if(vv.call(c.handlers,g)&&v)return v(c,f,p);if(c.options.passThrough&&c.options.passThrough.includes(g)){if("children"in f){const{children:w,...S}=f,T=Uf(S);return T.children=c.all(f),T}return Uf(f)}return(c.options.unknownHandler||wU)(c,f,p)}function d(f){const p=[];if("children"in f){const g=f.children;let v=-1;for(;++v<g.length;){const k=c.one(g[v],f);if(k){if(v&&g[v-1].type==="break"&&(!Array.isArray(k)&&k.type==="text"&&(k.value=kS(k.value)),!Array.isArray(k)&&k.type==="element")){const w=k.children[0];w&&w.type==="text"&&(w.value=kS(w.value))}Array.isArray(k)?p.push(...k):p.push(k)}}}return p}}function bU(t,e){t.position&&(e.position=l6(t))}function kU(t,e){let n=e;if(t&&t.data){const r=t.data.hName,i=t.data.hChildren,s=t.data.hProperties;if(typeof r=="string")if(n.type==="element")n.tagName=r;else{const a="children"in n?n.children:[n];n={type:"element",tagName:r,properties:{},children:a}}n.type==="element"&&s&&Object.assign(n.properties,Uf(s)),"children"in n&&n.children&&i!==null&&i!==void 0&&(n.children=i)}return n}function wU(t,e){const n=e.data||{},r="value"in e&&!(vv.call(n,"hProperties")||vv.call(n,"hChildren"))?{type:"text",value:e.value}:{type:"element",tagName:"div",properties:{},children:t.all(e)};return t.patch(e,r),t.applyData(e,r)}function SU(t,e){const n=[];let r=-1;for(e&&n.push({type:"text",value:`
507
+ `});++r<t.length;)r&&n.push({type:"text",value:`
508
+ `}),n.push(t[r]);return e&&t.length>0&&n.push({type:"text",value:`
509
+ `}),n}function kS(t){let e=0,n=t.charCodeAt(e);for(;n===9||n===32;)e++,n=t.charCodeAt(e);return t.slice(e)}function wS(t,e){const n=xU(t,e),r=n.one(t,void 0),i=cU(n),s=Array.isArray(r)?{type:"root",children:r}:r||{type:"root",children:[]};return i&&s.children.push({type:"text",value:`
510
+ `},i),s}function CU(t,e){return t&&"run"in t?async function(n,r){const i=wS(n,{file:r,...e});await t.run(i,r)}:function(n,r){return wS(n,{file:r,...t||e})}}function SS(t){if(t)throw t}var e0,CS;function TU(){if(CS)return e0;CS=1;var t=Object.prototype.hasOwnProperty,e=Object.prototype.toString,n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=function(d){return typeof Array.isArray=="function"?Array.isArray(d):e.call(d)==="[object Array]"},s=function(d){if(!d||e.call(d)!=="[object Object]")return!1;var f=t.call(d,"constructor"),p=d.constructor&&d.constructor.prototype&&t.call(d.constructor.prototype,"isPrototypeOf");if(d.constructor&&!f&&!p)return!1;var g;for(g in d);return typeof g>"u"||t.call(d,g)},a=function(d,f){n&&f.name==="__proto__"?n(d,f.name,{enumerable:!0,configurable:!0,value:f.newValue,writable:!0}):d[f.name]=f.newValue},c=function(d,f){if(f==="__proto__")if(t.call(d,f)){if(r)return r(d,f).value}else return;return d[f]};return e0=function h(){var d,f,p,g,v,k,w=arguments[0],S=1,T=arguments.length,C=!1;for(typeof w=="boolean"&&(C=w,w=arguments[1]||{},S=2),(w==null||typeof w!="object"&&typeof w!="function")&&(w={});S<T;++S)if(d=arguments[S],d!=null)for(f in d)p=c(w,f),g=c(d,f),w!==g&&(C&&g&&(s(g)||(v=i(g)))?(v?(v=!1,k=p&&i(p)?p:[]):k=p&&s(p)?p:{},a(w,{name:f,newValue:h(C,k,g)})):typeof g<"u"&&a(w,{name:f,newValue:g}));return w},e0}var NU=TU();const t0=up(NU);function yv(t){if(typeof t!="object"||t===null)return!1;const e=Object.getPrototypeOf(t);return(e===null||e===Object.prototype||Object.getPrototypeOf(e)===null)&&!(Symbol.toStringTag in t)&&!(Symbol.iterator in t)}function EU(){const t=[],e={run:n,use:r};return e;function n(...i){let s=-1;const a=i.pop();if(typeof a!="function")throw new TypeError("Expected function as last argument, not "+a);c(null,...i);function c(h,...d){const f=t[++s];let p=-1;if(h){a(h);return}for(;++p<i.length;)(d[p]===null||d[p]===void 0)&&(d[p]=i[p]);i=d,f?jU(f,c)(...d):a(null,...d)}}function r(i){if(typeof i!="function")throw new TypeError("Expected `middelware` to be a function, not "+i);return t.push(i),e}}function jU(t,e){let n;return r;function r(...a){const c=t.length>a.length;let h;c&&a.push(i);try{h=t.apply(this,a)}catch(d){const f=d;if(c&&n)throw f;return i(f)}c||(h&&h.then&&typeof h.then=="function"?h.then(s,i):h instanceof Error?i(h):s(h))}function i(a,...c){n||(n=!0,e(a,...c))}function s(a){i(null,a)}}const vs={basename:PU,dirname:_U,extname:RU,join:IU,sep:"/"};function PU(t,e){if(e!==void 0&&typeof e!="string")throw new TypeError('"ext" argument must be a string');Nd(t);let n=0,r=-1,i=t.length,s;if(e===void 0||e.length===0||e.length>t.length){for(;i--;)if(t.codePointAt(i)===47){if(s){n=i+1;break}}else r<0&&(s=!0,r=i+1);return r<0?"":t.slice(n,r)}if(e===t)return"";let a=-1,c=e.length-1;for(;i--;)if(t.codePointAt(i)===47){if(s){n=i+1;break}}else a<0&&(s=!0,a=i+1),c>-1&&(t.codePointAt(i)===e.codePointAt(c--)?c<0&&(r=i):(c=-1,r=a));return n===r?r=a:r<0&&(r=t.length),t.slice(n,r)}function _U(t){if(Nd(t),t.length===0)return".";let e=-1,n=t.length,r;for(;--n;)if(t.codePointAt(n)===47){if(r){e=n;break}}else r||(r=!0);return e<0?t.codePointAt(0)===47?"/":".":e===1&&t.codePointAt(0)===47?"//":t.slice(0,e)}function RU(t){Nd(t);let e=t.length,n=-1,r=0,i=-1,s=0,a;for(;e--;){const c=t.codePointAt(e);if(c===47){if(a){r=e+1;break}continue}n<0&&(a=!0,n=e+1),c===46?i<0?i=e:s!==1&&(s=1):i>-1&&(s=-1)}return i<0||n<0||s===0||s===1&&i===n-1&&i===r+1?"":t.slice(i,n)}function IU(...t){let e=-1,n;for(;++e<t.length;)Nd(t[e]),t[e]&&(n=n===void 0?t[e]:n+"/"+t[e]);return n===void 0?".":MU(n)}function MU(t){Nd(t);const e=t.codePointAt(0)===47;let n=DU(t,!e);return n.length===0&&!e&&(n="."),n.length>0&&t.codePointAt(t.length-1)===47&&(n+="/"),e?"/"+n:n}function DU(t,e){let n="",r=0,i=-1,s=0,a=-1,c,h;for(;++a<=t.length;){if(a<t.length)c=t.codePointAt(a);else{if(c===47)break;c=47}if(c===47){if(!(i===a-1||s===1))if(i!==a-1&&s===2){if(n.length<2||r!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(h=n.lastIndexOf("/"),h!==n.length-1){h<0?(n="",r=0):(n=n.slice(0,h),r=n.length-1-n.lastIndexOf("/")),i=a,s=0;continue}}else if(n.length>0){n="",r=0,i=a,s=0;continue}}e&&(n=n.length>0?n+"/..":"..",r=2)}else n.length>0?n+="/"+t.slice(i+1,a):n=t.slice(i+1,a),r=a-i-1;i=a,s=0}else c===46&&s>-1?s++:s=-1}return n}function Nd(t){if(typeof t!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(t))}const AU={cwd:OU};function OU(){return"/"}function xv(t){return!!(t!==null&&typeof t=="object"&&"href"in t&&t.href&&"protocol"in t&&t.protocol&&t.auth===void 0)}function LU(t){if(typeof t=="string")t=new URL(t);else if(!xv(t)){const e=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+t+"`");throw e.code="ERR_INVALID_ARG_TYPE",e}if(t.protocol!=="file:"){const e=new TypeError("The URL must be of scheme file");throw e.code="ERR_INVALID_URL_SCHEME",e}return FU(t)}function FU(t){if(t.hostname!==""){const r=new TypeError('File URL host must be "localhost" or empty on darwin');throw r.code="ERR_INVALID_FILE_URL_HOST",r}const e=t.pathname;let n=-1;for(;++n<e.length;)if(e.codePointAt(n)===37&&e.codePointAt(n+1)===50){const r=e.codePointAt(n+2);if(r===70||r===102){const i=new TypeError("File URL path must not include encoded / characters");throw i.code="ERR_INVALID_FILE_URL_PATH",i}}return decodeURIComponent(e)}const n0=["history","path","basename","stem","extname","dirname"];class Aj{constructor(e){let n;e?xv(e)?n={path:e}:typeof e=="string"||UU(e)?n={value:e}:n=e:n={},this.cwd="cwd"in n?"":AU.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let r=-1;for(;++r<n0.length;){const s=n0[r];s in n&&n[s]!==void 0&&n[s]!==null&&(this[s]=s==="history"?[...n[s]]:n[s])}let i;for(i in n)n0.includes(i)||(this[i]=n[i])}get basename(){return typeof this.path=="string"?vs.basename(this.path):void 0}set basename(e){i0(e,"basename"),r0(e,"basename"),this.path=vs.join(this.dirname||"",e)}get dirname(){return typeof this.path=="string"?vs.dirname(this.path):void 0}set dirname(e){TS(this.basename,"dirname"),this.path=vs.join(e||"",this.basename)}get extname(){return typeof this.path=="string"?vs.extname(this.path):void 0}set extname(e){if(r0(e,"extname"),TS(this.dirname,"extname"),e){if(e.codePointAt(0)!==46)throw new Error("`extname` must start with `.`");if(e.includes(".",1))throw new Error("`extname` cannot contain multiple dots")}this.path=vs.join(this.dirname,this.stem+(e||""))}get path(){return this.history[this.history.length-1]}set path(e){xv(e)&&(e=LU(e)),i0(e,"path"),this.path!==e&&this.history.push(e)}get stem(){return typeof this.path=="string"?vs.basename(this.path,this.extname):void 0}set stem(e){i0(e,"stem"),r0(e,"stem"),this.path=vs.join(this.dirname||"",e+(this.extname||""))}fail(e,n,r){const i=this.message(e,n,r);throw i.fatal=!0,i}info(e,n,r){const i=this.message(e,n,r);return i.fatal=void 0,i}message(e,n,r){const i=new Er(e,n,r);return this.path&&(i.name=this.path+":"+i.name,i.file=this.path),i.fatal=!1,this.messages.push(i),i}toString(e){return this.value===void 0?"":typeof this.value=="string"?this.value:new TextDecoder(e||void 0).decode(this.value)}}function r0(t,e){if(t&&t.includes(vs.sep))throw new Error("`"+e+"` cannot be a path: did not expect `"+vs.sep+"`")}function i0(t,e){if(!t)throw new Error("`"+e+"` cannot be empty")}function TS(t,e){if(!t)throw new Error("Setting `"+e+"` requires `path` to be set too")}function UU(t){return!!(t&&typeof t=="object"&&"byteLength"in t&&"byteOffset"in t)}const BU=(function(t){const r=this.constructor.prototype,i=r[t],s=function(){return i.apply(s,arguments)};return Object.setPrototypeOf(s,r),s}),zU={}.hasOwnProperty;class ex extends BU{constructor(){super("copy"),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=EU()}copy(){const e=new ex;let n=-1;for(;++n<this.attachers.length;){const r=this.attachers[n];e.use(...r)}return e.data(t0(!0,{},this.namespace)),e}data(e,n){return typeof e=="string"?arguments.length===2?(o0("data",this.frozen),this.namespace[e]=n,this):zU.call(this.namespace,e)&&this.namespace[e]||void 0:e?(o0("data",this.frozen),this.namespace=e,this):this.namespace}freeze(){if(this.frozen)return this;const e=this;for(;++this.freezeIndex<this.attachers.length;){const[n,...r]=this.attachers[this.freezeIndex];if(r[0]===!1)continue;r[0]===!0&&(r[0]=void 0);const i=n.call(e,...r);typeof i=="function"&&this.transformers.use(i)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(e){this.freeze();const n=Jh(e),r=this.parser||this.Parser;return s0("parse",r),r(String(n),n)}process(e,n){const r=this;return this.freeze(),s0("process",this.parser||this.Parser),a0("process",this.compiler||this.Compiler),n?i(void 0,n):new Promise(i);function i(s,a){const c=Jh(e),h=r.parse(c);r.run(h,c,function(f,p,g){if(f||!p||!g)return d(f);const v=p,k=r.stringify(v,g);WU(k)?g.value=k:g.result=k,d(f,g)});function d(f,p){f||!p?a(f):s?s(p):n(void 0,p)}}}processSync(e){let n=!1,r;return this.freeze(),s0("processSync",this.parser||this.Parser),a0("processSync",this.compiler||this.Compiler),this.process(e,i),ES("processSync","process",n),r;function i(s,a){n=!0,SS(s),r=a}}run(e,n,r){NS(e),this.freeze();const i=this.transformers;return!r&&typeof n=="function"&&(r=n,n=void 0),r?s(void 0,r):new Promise(s);function s(a,c){const h=Jh(n);i.run(e,h,d);function d(f,p,g){const v=p||e;f?c(f):a?a(v):r(void 0,v,g)}}}runSync(e,n){let r=!1,i;return this.run(e,n,s),ES("runSync","run",r),i;function s(a,c){SS(a),i=c,r=!0}}stringify(e,n){this.freeze();const r=Jh(n),i=this.compiler||this.Compiler;return a0("stringify",i),NS(e),i(e,r)}use(e,...n){const r=this.attachers,i=this.namespace;if(o0("use",this.frozen),e!=null)if(typeof e=="function")h(e,n);else if(typeof e=="object")Array.isArray(e)?c(e):a(e);else throw new TypeError("Expected usable value, not `"+e+"`");return this;function s(d){if(typeof d=="function")h(d,[]);else if(typeof d=="object")if(Array.isArray(d)){const[f,...p]=d;h(f,p)}else a(d);else throw new TypeError("Expected usable value, not `"+d+"`")}function a(d){if(!("plugins"in d)&&!("settings"in d))throw new Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");c(d.plugins),d.settings&&(i.settings=t0(!0,i.settings,d.settings))}function c(d){let f=-1;if(d!=null)if(Array.isArray(d))for(;++f<d.length;){const p=d[f];s(p)}else throw new TypeError("Expected a list of plugins, not `"+d+"`")}function h(d,f){let p=-1,g=-1;for(;++p<r.length;)if(r[p][0]===d){g=p;break}if(g===-1)r.push([d,...f]);else if(f.length>0){let[v,...k]=f;const w=r[g][1];yv(w)&&yv(v)&&(v=t0(!0,w,v)),r[g]=[d,v,...k]}}}}const $U=new ex().freeze();function s0(t,e){if(typeof e!="function")throw new TypeError("Cannot `"+t+"` without `parser`")}function a0(t,e){if(typeof e!="function")throw new TypeError("Cannot `"+t+"` without `compiler`")}function o0(t,e){if(e)throw new Error("Cannot call `"+t+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function NS(t){if(!yv(t)||typeof t.type!="string")throw new TypeError("Expected node, got `"+t+"`")}function ES(t,e,n){if(!n)throw new Error("`"+t+"` finished async. Use `"+e+"` instead")}function Jh(t){return VU(t)?t:new Aj(t)}function VU(t){return!!(t&&typeof t=="object"&&"message"in t&&"messages"in t)}function WU(t){return typeof t=="string"||HU(t)}function HU(t){return!!(t&&typeof t=="object"&&"byteLength"in t&&"byteOffset"in t)}const qU="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",jS=[],PS={allowDangerousHtml:!0},KU=/^(https?|ircs?|mailto|xmpp)$/i,GU=[{from:"astPlugins",id:"remove-buggy-html-in-markdown-parser"},{from:"allowDangerousHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"allowNode",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowElement"},{from:"allowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowedElements"},{from:"disallowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"disallowedElements"},{from:"escapeHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"includeElementIndex",id:"#remove-includeelementindex"},{from:"includeNodeIndex",id:"change-includenodeindex-to-includeelementindex"},{from:"linkTarget",id:"remove-linktarget"},{from:"plugins",id:"change-plugins-to-remarkplugins",to:"remarkPlugins"},{from:"rawSourcePos",id:"#remove-rawsourcepos"},{from:"renderers",id:"change-renderers-to-components",to:"components"},{from:"source",id:"change-source-to-children",to:"children"},{from:"sourcePos",id:"#remove-sourcepos"},{from:"transformImageUri",id:"#add-urltransform",to:"urlTransform"},{from:"transformLinkUri",id:"#add-urltransform",to:"urlTransform"}];function Oj(t){const e=t.allowedElements,n=t.allowElement,r=t.children||"",i=t.className,s=t.components,a=t.disallowedElements,c=t.rehypePlugins||jS,h=t.remarkPlugins||jS,d=t.remarkRehypeOptions?{...t.remarkRehypeOptions,...PS}:PS,f=t.skipHtml,p=t.unwrapDisallowed,g=t.urlTransform||YU,v=$U().use(_F).use(h).use(CU,d).use(c),k=new Aj;typeof r=="string"&&(k.value=r);for(const C of GU)Object.hasOwn(t,C.from)&&(""+C.from+(C.to?"use `"+C.to+"` instead":"remove it")+qU+C.id,void 0);const w=v.parse(k);let S=v.runSync(w,k);return i&&(S={type:"element",tagName:"div",properties:{className:i},children:S.type==="root"?S.children:[S]}),Zy(S,T),f6(S,{Fragment:o.Fragment,components:s,ignoreInvalidStyle:!0,jsx:o.jsx,jsxs:o.jsxs,passKeys:!0,passNode:!0});function T(C,j,R){if(C.type==="raw"&&R&&typeof j=="number")return f?R.children.splice(j,1):R.children[j]={type:"text",value:C.value},j;if(C.type==="element"){let _;for(_ in Xg)if(Object.hasOwn(Xg,_)&&Object.hasOwn(C.properties,_)){const I=C.properties[_],M=Xg[_];(M===null||M.includes(C.tagName))&&(C.properties[_]=g(String(I||""),_,C))}}if(C.type==="element"){let _=e?!e.includes(C.tagName):a?a.includes(C.tagName):!1;if(!_&&n&&typeof j=="number"&&(_=!n(C,j,R)),_&&R&&typeof j=="number")return p&&C.children?R.children.splice(j,1,...C.children):R.children.splice(j,1),j}}}function YU(t){const e=t.indexOf(":"),n=t.indexOf("?"),r=t.indexOf("#"),i=t.indexOf("/");return e<0||i>-1&&e>i||n>-1&&e>n||r>-1&&e>r||KU.test(t.slice(0,e))?t:""}function _S(t,e){const n=String(t);if(typeof e!="string")throw new TypeError("Expected character");let r=0,i=n.indexOf(e);for(;i!==-1;)r++,i=n.indexOf(e,i+e.length);return r}function JU(t){if(typeof t!="string")throw new TypeError("Expected a string");return t.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function XU(t,e,n){const i=wp((n||{}).ignore||[]),s=QU(e);let a=-1;for(;++a<s.length;)Dj(t,"text",c);function c(d,f){let p=-1,g;for(;++p<f.length;){const v=f[p],k=g?g.children:void 0;if(i(v,k?k.indexOf(v):void 0,g))return;g=v}if(g)return h(d,f)}function h(d,f){const p=f[f.length-1],g=s[a][0],v=s[a][1];let k=0;const S=p.children.indexOf(d);let T=!1,C=[];g.lastIndex=0;let j=g.exec(d.value);for(;j;){const R=j.index,_={index:j.index,input:j.input,stack:[...f,d]};let I=v(...j,_);if(typeof I=="string"&&(I=I.length>0?{type:"text",value:I}:void 0),I===!1?g.lastIndex=R+1:(k!==R&&C.push({type:"text",value:d.value.slice(k,R)}),Array.isArray(I)?C.push(...I):I&&C.push(I),k=R+j[0].length,T=!0),!g.global)break;j=g.exec(d.value)}return T?(k<d.value.length&&C.push({type:"text",value:d.value.slice(k)}),p.children.splice(S,1,...C)):C=[d],S+C.length}}function QU(t){const e=[];if(!Array.isArray(t))throw new TypeError("Expected find and replace tuple or list of tuples");const n=!t[0]||Array.isArray(t[0])?t:[t];let r=-1;for(;++r<n.length;){const i=n[r];e.push([ZU(i[0]),e7(i[1])])}return e}function ZU(t){return typeof t=="string"?new RegExp(JU(t),"g"):t}function e7(t){return typeof t=="function"?t:function(){return t}}const l0="phrasing",c0=["autolink","link","image","label"];function t7(){return{transforms:[l7],enter:{literalAutolink:r7,literalAutolinkEmail:u0,literalAutolinkHttp:u0,literalAutolinkWww:u0},exit:{literalAutolink:o7,literalAutolinkEmail:a7,literalAutolinkHttp:i7,literalAutolinkWww:s7}}}function n7(){return{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:l0,notInConstruct:c0},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:l0,notInConstruct:c0},{character:":",before:"[ps]",after:"\\/",inConstruct:l0,notInConstruct:c0}]}}function r7(t){this.enter({type:"link",title:null,url:"",children:[]},t)}function u0(t){this.config.enter.autolinkProtocol.call(this,t)}function i7(t){this.config.exit.autolinkProtocol.call(this,t)}function s7(t){this.config.exit.data.call(this,t);const e=this.stack[this.stack.length-1];e.type,e.url="http://"+this.sliceSerialize(t)}function a7(t){this.config.exit.autolinkEmail.call(this,t)}function o7(t){this.exit(t)}function l7(t){XU(t,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,c7],[new RegExp("(?<=^|\\s|\\p{P}|\\p{S})([-.\\w+]+)@([-\\w]+(?:\\.[-\\w]+)+)","gu"),u7]],{ignore:["link","linkReference"]})}function c7(t,e,n,r,i){let s="";if(!Lj(i)||(/^w/i.test(e)&&(n=e+n,e="",s="http://"),!d7(n)))return!1;const a=h7(n+r);if(!a[0])return!1;const c={type:"link",title:null,url:s+e+a[0],children:[{type:"text",value:e+a[0]}]};return a[1]?[c,{type:"text",value:a[1]}]:c}function u7(t,e,n,r){return!Lj(r,!0)||/[-\d_]$/.test(n)?!1:{type:"link",title:null,url:"mailto:"+e+"@"+n,children:[{type:"text",value:e+"@"+n}]}}function d7(t){const e=t.split(".");return!(e.length<2||e[e.length-1]&&(/_/.test(e[e.length-1])||!/[a-zA-Z\d]/.test(e[e.length-1]))||e[e.length-2]&&(/_/.test(e[e.length-2])||!/[a-zA-Z\d]/.test(e[e.length-2])))}function h7(t){const e=/[!"&'),.:;<>?\]}]+$/.exec(t);if(!e)return[t,void 0];t=t.slice(0,e.index);let n=e[0],r=n.indexOf(")");const i=_S(t,"(");let s=_S(t,")");for(;r!==-1&&i>s;)t+=n.slice(0,r+1),n=n.slice(r+1),r=n.indexOf(")"),s++;return[t,n]}function Lj(t,e){const n=t.input.charCodeAt(t.index-1);return(t.index===0||cl(n)||xp(n))&&(!e||n!==47)}Fj.peek=k7;function f7(){this.buffer()}function p7(t){this.enter({type:"footnoteReference",identifier:"",label:""},t)}function m7(){this.buffer()}function g7(t){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},t)}function v7(t){const e=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=rs(this.sliceSerialize(t)).toLowerCase(),n.label=e}function y7(t){this.exit(t)}function x7(t){const e=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=rs(this.sliceSerialize(t)).toLowerCase(),n.label=e}function b7(t){this.exit(t)}function k7(){return"["}function Fj(t,e,n,r){const i=n.createTracker(r);let s=i.move("[^");const a=n.enter("footnoteReference"),c=n.enter("reference");return s+=i.move(n.safe(n.associationId(t),{after:"]",before:s})),c(),a(),s+=i.move("]"),s}function w7(){return{enter:{gfmFootnoteCallString:f7,gfmFootnoteCall:p7,gfmFootnoteDefinitionLabelString:m7,gfmFootnoteDefinition:g7},exit:{gfmFootnoteCallString:v7,gfmFootnoteCall:y7,gfmFootnoteDefinitionLabelString:x7,gfmFootnoteDefinition:b7}}}function S7(t){let e=!1;return t&&t.firstLineBlank&&(e=!0),{handlers:{footnoteDefinition:n,footnoteReference:Fj},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]};function n(r,i,s,a){const c=s.createTracker(a);let h=c.move("[^");const d=s.enter("footnoteDefinition"),f=s.enter("label");return h+=c.move(s.safe(s.associationId(r),{before:h,after:"]"})),f(),h+=c.move("]:"),r.children&&r.children.length>0&&(c.shift(4),h+=c.move((e?`
511
+ `:" ")+s.indentLines(s.containerFlow(r,c.current()),e?Uj:C7))),d(),h}}function C7(t,e,n){return e===0?t:Uj(t,e,n)}function Uj(t,e,n){return(n?"":" ")+t}const T7=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];Bj.peek=_7;function N7(){return{canContainEols:["delete"],enter:{strikethrough:j7},exit:{strikethrough:P7}}}function E7(){return{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:T7}],handlers:{delete:Bj}}}function j7(t){this.enter({type:"delete",children:[]},t)}function P7(t){this.exit(t)}function Bj(t,e,n,r){const i=n.createTracker(r),s=n.enter("strikethrough");let a=i.move("~~");return a+=n.containerPhrasing(t,{...i.current(),before:a,after:"~"}),a+=i.move("~~"),s(),a}function _7(){return"~"}function R7(t){return t.length}function I7(t,e){const n=e||{},r=(n.align||[]).concat(),i=n.stringLength||R7,s=[],a=[],c=[],h=[];let d=0,f=-1;for(;++f<t.length;){const w=[],S=[];let T=-1;for(t[f].length>d&&(d=t[f].length);++T<t[f].length;){const C=M7(t[f][T]);if(n.alignDelimiters!==!1){const j=i(C);S[T]=j,(h[T]===void 0||j>h[T])&&(h[T]=j)}w.push(C)}a[f]=w,c[f]=S}let p=-1;if(typeof r=="object"&&"length"in r)for(;++p<d;)s[p]=RS(r[p]);else{const w=RS(r);for(;++p<d;)s[p]=w}p=-1;const g=[],v=[];for(;++p<d;){const w=s[p];let S="",T="";w===99?(S=":",T=":"):w===108?S=":":w===114&&(T=":");let C=n.alignDelimiters===!1?1:Math.max(1,h[p]-S.length-T.length);const j=S+"-".repeat(C)+T;n.alignDelimiters!==!1&&(C=S.length+C+T.length,C>h[p]&&(h[p]=C),v[p]=C),g[p]=j}a.splice(1,0,g),c.splice(1,0,v),f=-1;const k=[];for(;++f<a.length;){const w=a[f],S=c[f];p=-1;const T=[];for(;++p<d;){const C=w[p]||"";let j="",R="";if(n.alignDelimiters!==!1){const _=h[p]-(S[p]||0),I=s[p];I===114?j=" ".repeat(_):I===99?_%2?(j=" ".repeat(_/2+.5),R=" ".repeat(_/2-.5)):(j=" ".repeat(_/2),R=j):R=" ".repeat(_)}n.delimiterStart!==!1&&!p&&T.push("|"),n.padding!==!1&&!(n.alignDelimiters===!1&&C==="")&&(n.delimiterStart!==!1||p)&&T.push(" "),n.alignDelimiters!==!1&&T.push(j),T.push(C),n.alignDelimiters!==!1&&T.push(R),n.padding!==!1&&T.push(" "),(n.delimiterEnd!==!1||p!==d-1)&&T.push("|")}k.push(n.delimiterEnd===!1?T.join("").replace(/ +$/,""):T.join(""))}return k.join(`
512
+ `)}function M7(t){return t==null?"":String(t)}function RS(t){const e=typeof t=="string"?t.codePointAt(0):0;return e===67||e===99?99:e===76||e===108?108:e===82||e===114?114:0}function D7(t,e,n,r){const i=n.enter("blockquote"),s=n.createTracker(r);s.move("> "),s.shift(2);const a=n.indentLines(n.containerFlow(t,s.current()),A7);return i(),a}function A7(t,e,n){return">"+(n?"":" ")+t}function O7(t,e){return IS(t,e.inConstruct,!0)&&!IS(t,e.notInConstruct,!1)}function IS(t,e,n){if(typeof e=="string"&&(e=[e]),!e||e.length===0)return n;let r=-1;for(;++r<e.length;)if(t.includes(e[r]))return!0;return!1}function MS(t,e,n,r){let i=-1;for(;++i<n.unsafe.length;)if(n.unsafe[i].character===`
513
+ `&&O7(n.stack,n.unsafe[i]))return/[ \t]/.test(r.before)?"":" ";return`\\
514
+ `}function L7(t,e){const n=String(t);let r=n.indexOf(e),i=r,s=0,a=0;if(typeof e!="string")throw new TypeError("Expected substring");for(;r!==-1;)r===i?++s>a&&(a=s):s=1,i=r+e.length,r=n.indexOf(e,i);return a}function F7(t,e){return!!(e.options.fences===!1&&t.value&&!t.lang&&/[^ \r\n]/.test(t.value)&&!/^[\t ]*(?:[\r\n]|$)|(?:^|[\r\n])[\t ]*$/.test(t.value))}function U7(t){const e=t.options.fence||"`";if(e!=="`"&&e!=="~")throw new Error("Cannot serialize code with `"+e+"` for `options.fence`, expected `` ` `` or `~`");return e}function B7(t,e,n,r){const i=U7(n),s=t.value||"",a=i==="`"?"GraveAccent":"Tilde";if(F7(t,n)){const p=n.enter("codeIndented"),g=n.indentLines(s,z7);return p(),g}const c=n.createTracker(r),h=i.repeat(Math.max(L7(s,i)+1,3)),d=n.enter("codeFenced");let f=c.move(h);if(t.lang){const p=n.enter(`codeFencedLang${a}`);f+=c.move(n.safe(t.lang,{before:f,after:" ",encode:["`"],...c.current()})),p()}if(t.lang&&t.meta){const p=n.enter(`codeFencedMeta${a}`);f+=c.move(" "),f+=c.move(n.safe(t.meta,{before:f,after:`
515
+ `,encode:["`"],...c.current()})),p()}return f+=c.move(`
516
+ `),s&&(f+=c.move(s+`
517
+ `)),f+=c.move(h),d(),f}function z7(t,e,n){return(n?"":" ")+t}function tx(t){const e=t.options.quote||'"';if(e!=='"'&&e!=="'")throw new Error("Cannot serialize title with `"+e+"` for `options.quote`, expected `\"`, or `'`");return e}function $7(t,e,n,r){const i=tx(n),s=i==='"'?"Quote":"Apostrophe",a=n.enter("definition");let c=n.enter("label");const h=n.createTracker(r);let d=h.move("[");return d+=h.move(n.safe(n.associationId(t),{before:d,after:"]",...h.current()})),d+=h.move("]: "),c(),!t.url||/[\0- \u007F]/.test(t.url)?(c=n.enter("destinationLiteral"),d+=h.move("<"),d+=h.move(n.safe(t.url,{before:d,after:">",...h.current()})),d+=h.move(">")):(c=n.enter("destinationRaw"),d+=h.move(n.safe(t.url,{before:d,after:t.title?" ":`
518
+ `,...h.current()}))),c(),t.title&&(c=n.enter(`title${s}`),d+=h.move(" "+i),d+=h.move(n.safe(t.title,{before:d,after:i,...h.current()})),d+=h.move(i),c()),a(),d}function V7(t){const e=t.options.emphasis||"*";if(e!=="*"&&e!=="_")throw new Error("Cannot serialize emphasis with `"+e+"` for `options.emphasis`, expected `*`, or `_`");return e}function ad(t){return"&#x"+t.toString(16).toUpperCase()+";"}function Bf(t,e,n){const r=bc(t),i=bc(e);return r===void 0?i===void 0?n==="_"?{inside:!0,outside:!0}:{inside:!1,outside:!1}:i===1?{inside:!0,outside:!0}:{inside:!1,outside:!0}:r===1?i===void 0?{inside:!1,outside:!1}:i===1?{inside:!0,outside:!0}:{inside:!1,outside:!1}:i===void 0?{inside:!1,outside:!1}:i===1?{inside:!0,outside:!1}:{inside:!1,outside:!1}}zj.peek=W7;function zj(t,e,n,r){const i=V7(n),s=n.enter("emphasis"),a=n.createTracker(r),c=a.move(i);let h=a.move(n.containerPhrasing(t,{after:i,before:c,...a.current()}));const d=h.charCodeAt(0),f=Bf(r.before.charCodeAt(r.before.length-1),d,i);f.inside&&(h=ad(d)+h.slice(1));const p=h.charCodeAt(h.length-1),g=Bf(r.after.charCodeAt(0),p,i);g.inside&&(h=h.slice(0,-1)+ad(p));const v=a.move(i);return s(),n.attentionEncodeSurroundingInfo={after:g.outside,before:f.outside},c+h+v}function W7(t,e,n){return n.options.emphasis||"*"}function H7(t,e){let n=!1;return Zy(t,function(r){if("value"in r&&/\r?\n|\r/.test(r.value)||r.type==="break")return n=!0,gv}),!!((!t.depth||t.depth<3)&&qy(t)&&(e.options.setext||n))}function q7(t,e,n,r){const i=Math.max(Math.min(6,t.depth||1),1),s=n.createTracker(r);if(H7(t,n)){const f=n.enter("headingSetext"),p=n.enter("phrasing"),g=n.containerPhrasing(t,{...s.current(),before:`
519
+ `,after:`
520
+ `});return p(),f(),g+`
521
+ `+(i===1?"=":"-").repeat(g.length-(Math.max(g.lastIndexOf("\r"),g.lastIndexOf(`
522
+ `))+1))}const a="#".repeat(i),c=n.enter("headingAtx"),h=n.enter("phrasing");s.move(a+" ");let d=n.containerPhrasing(t,{before:"# ",after:`
523
+ `,...s.current()});return/^[\t ]/.test(d)&&(d=ad(d.charCodeAt(0))+d.slice(1)),d=d?a+" "+d:a,n.options.closeAtx&&(d+=" "+a),h(),c(),d}$j.peek=K7;function $j(t){return t.value||""}function K7(){return"<"}Vj.peek=G7;function Vj(t,e,n,r){const i=tx(n),s=i==='"'?"Quote":"Apostrophe",a=n.enter("image");let c=n.enter("label");const h=n.createTracker(r);let d=h.move("![");return d+=h.move(n.safe(t.alt,{before:d,after:"]",...h.current()})),d+=h.move("]("),c(),!t.url&&t.title||/[\0- \u007F]/.test(t.url)?(c=n.enter("destinationLiteral"),d+=h.move("<"),d+=h.move(n.safe(t.url,{before:d,after:">",...h.current()})),d+=h.move(">")):(c=n.enter("destinationRaw"),d+=h.move(n.safe(t.url,{before:d,after:t.title?" ":")",...h.current()}))),c(),t.title&&(c=n.enter(`title${s}`),d+=h.move(" "+i),d+=h.move(n.safe(t.title,{before:d,after:i,...h.current()})),d+=h.move(i),c()),d+=h.move(")"),a(),d}function G7(){return"!"}Wj.peek=Y7;function Wj(t,e,n,r){const i=t.referenceType,s=n.enter("imageReference");let a=n.enter("label");const c=n.createTracker(r);let h=c.move("![");const d=n.safe(t.alt,{before:h,after:"]",...c.current()});h+=c.move(d+"]["),a();const f=n.stack;n.stack=[],a=n.enter("reference");const p=n.safe(n.associationId(t),{before:h,after:"]",...c.current()});return a(),n.stack=f,s(),i==="full"||!d||d!==p?h+=c.move(p+"]"):i==="shortcut"?h=h.slice(0,-1):h+=c.move("]"),h}function Y7(){return"!"}Hj.peek=J7;function Hj(t,e,n){let r=t.value||"",i="`",s=-1;for(;new RegExp("(^|[^`])"+i+"([^`]|$)").test(r);)i+="`";for(/[^ \r\n]/.test(r)&&(/^[ \r\n]/.test(r)&&/[ \r\n]$/.test(r)||/^`|`$/.test(r))&&(r=" "+r+" ");++s<n.unsafe.length;){const a=n.unsafe[s],c=n.compilePattern(a);let h;if(a.atBreak)for(;h=c.exec(r);){let d=h.index;r.charCodeAt(d)===10&&r.charCodeAt(d-1)===13&&d--,r=r.slice(0,d)+" "+r.slice(h.index+1)}}return i+r+i}function J7(){return"`"}function qj(t,e){const n=qy(t);return!!(!e.options.resourceLink&&t.url&&!t.title&&t.children&&t.children.length===1&&t.children[0].type==="text"&&(n===t.url||"mailto:"+n===t.url)&&/^[a-z][a-z+.-]+:/i.test(t.url)&&!/[\0- <>\u007F]/.test(t.url))}Kj.peek=X7;function Kj(t,e,n,r){const i=tx(n),s=i==='"'?"Quote":"Apostrophe",a=n.createTracker(r);let c,h;if(qj(t,n)){const f=n.stack;n.stack=[],c=n.enter("autolink");let p=a.move("<");return p+=a.move(n.containerPhrasing(t,{before:p,after:">",...a.current()})),p+=a.move(">"),c(),n.stack=f,p}c=n.enter("link"),h=n.enter("label");let d=a.move("[");return d+=a.move(n.containerPhrasing(t,{before:d,after:"](",...a.current()})),d+=a.move("]("),h(),!t.url&&t.title||/[\0- \u007F]/.test(t.url)?(h=n.enter("destinationLiteral"),d+=a.move("<"),d+=a.move(n.safe(t.url,{before:d,after:">",...a.current()})),d+=a.move(">")):(h=n.enter("destinationRaw"),d+=a.move(n.safe(t.url,{before:d,after:t.title?" ":")",...a.current()}))),h(),t.title&&(h=n.enter(`title${s}`),d+=a.move(" "+i),d+=a.move(n.safe(t.title,{before:d,after:i,...a.current()})),d+=a.move(i),h()),d+=a.move(")"),c(),d}function X7(t,e,n){return qj(t,n)?"<":"["}Gj.peek=Q7;function Gj(t,e,n,r){const i=t.referenceType,s=n.enter("linkReference");let a=n.enter("label");const c=n.createTracker(r);let h=c.move("[");const d=n.containerPhrasing(t,{before:h,after:"]",...c.current()});h+=c.move(d+"]["),a();const f=n.stack;n.stack=[],a=n.enter("reference");const p=n.safe(n.associationId(t),{before:h,after:"]",...c.current()});return a(),n.stack=f,s(),i==="full"||!d||d!==p?h+=c.move(p+"]"):i==="shortcut"?h=h.slice(0,-1):h+=c.move("]"),h}function Q7(){return"["}function nx(t){const e=t.options.bullet||"*";if(e!=="*"&&e!=="+"&&e!=="-")throw new Error("Cannot serialize items with `"+e+"` for `options.bullet`, expected `*`, `+`, or `-`");return e}function Z7(t){const e=nx(t),n=t.options.bulletOther;if(!n)return e==="*"?"-":"*";if(n!=="*"&&n!=="+"&&n!=="-")throw new Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===e)throw new Error("Expected `bullet` (`"+e+"`) and `bulletOther` (`"+n+"`) to be different");return n}function eB(t){const e=t.options.bulletOrdered||".";if(e!=="."&&e!==")")throw new Error("Cannot serialize items with `"+e+"` for `options.bulletOrdered`, expected `.` or `)`");return e}function Yj(t){const e=t.options.rule||"*";if(e!=="*"&&e!=="-"&&e!=="_")throw new Error("Cannot serialize rules with `"+e+"` for `options.rule`, expected `*`, `-`, or `_`");return e}function tB(t,e,n,r){const i=n.enter("list"),s=n.bulletCurrent;let a=t.ordered?eB(n):nx(n);const c=t.ordered?a==="."?")":".":Z7(n);let h=e&&n.bulletLastUsed?a===n.bulletLastUsed:!1;if(!t.ordered){const f=t.children?t.children[0]:void 0;if((a==="*"||a==="-")&&f&&(!f.children||!f.children[0])&&n.stack[n.stack.length-1]==="list"&&n.stack[n.stack.length-2]==="listItem"&&n.stack[n.stack.length-3]==="list"&&n.stack[n.stack.length-4]==="listItem"&&n.indexStack[n.indexStack.length-1]===0&&n.indexStack[n.indexStack.length-2]===0&&n.indexStack[n.indexStack.length-3]===0&&(h=!0),Yj(n)===a&&f){let p=-1;for(;++p<t.children.length;){const g=t.children[p];if(g&&g.type==="listItem"&&g.children&&g.children[0]&&g.children[0].type==="thematicBreak"){h=!0;break}}}}h&&(a=c),n.bulletCurrent=a;const d=n.containerFlow(t,r);return n.bulletLastUsed=a,n.bulletCurrent=s,i(),d}function nB(t){const e=t.options.listItemIndent||"one";if(e!=="tab"&&e!=="one"&&e!=="mixed")throw new Error("Cannot serialize items with `"+e+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return e}function rB(t,e,n,r){const i=nB(n);let s=n.bulletCurrent||nx(n);e&&e.type==="list"&&e.ordered&&(s=(typeof e.start=="number"&&e.start>-1?e.start:1)+(n.options.incrementListMarker===!1?0:e.children.indexOf(t))+s);let a=s.length+1;(i==="tab"||i==="mixed"&&(e&&e.type==="list"&&e.spread||t.spread))&&(a=Math.ceil(a/4)*4);const c=n.createTracker(r);c.move(s+" ".repeat(a-s.length)),c.shift(a);const h=n.enter("listItem"),d=n.indentLines(n.containerFlow(t,c.current()),f);return h(),d;function f(p,g,v){return g?(v?"":" ".repeat(a))+p:(v?s:s+" ".repeat(a-s.length))+p}}function iB(t,e,n,r){const i=n.enter("paragraph"),s=n.enter("phrasing"),a=n.containerPhrasing(t,r);return s(),i(),a}const sB=wp(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function aB(t,e,n,r){return(t.children.some(function(a){return sB(a)})?n.containerPhrasing:n.containerFlow).call(n,t,r)}function oB(t){const e=t.options.strong||"*";if(e!=="*"&&e!=="_")throw new Error("Cannot serialize strong with `"+e+"` for `options.strong`, expected `*`, or `_`");return e}Jj.peek=lB;function Jj(t,e,n,r){const i=oB(n),s=n.enter("strong"),a=n.createTracker(r),c=a.move(i+i);let h=a.move(n.containerPhrasing(t,{after:i,before:c,...a.current()}));const d=h.charCodeAt(0),f=Bf(r.before.charCodeAt(r.before.length-1),d,i);f.inside&&(h=ad(d)+h.slice(1));const p=h.charCodeAt(h.length-1),g=Bf(r.after.charCodeAt(0),p,i);g.inside&&(h=h.slice(0,-1)+ad(p));const v=a.move(i+i);return s(),n.attentionEncodeSurroundingInfo={after:g.outside,before:f.outside},c+h+v}function lB(t,e,n){return n.options.strong||"*"}function cB(t,e,n,r){return n.safe(t.value,r)}function uB(t){const e=t.options.ruleRepetition||3;if(e<3)throw new Error("Cannot serialize rules with repetition `"+e+"` for `options.ruleRepetition`, expected `3` or more");return e}function dB(t,e,n){const r=(Yj(n)+(n.options.ruleSpaces?" ":"")).repeat(uB(n));return n.options.ruleSpaces?r.slice(0,-1):r}const Xj={blockquote:D7,break:MS,code:B7,definition:$7,emphasis:zj,hardBreak:MS,heading:q7,html:$j,image:Vj,imageReference:Wj,inlineCode:Hj,link:Kj,linkReference:Gj,list:tB,listItem:rB,paragraph:iB,root:aB,strong:Jj,text:cB,thematicBreak:dB};function hB(){return{enter:{table:fB,tableData:DS,tableHeader:DS,tableRow:mB},exit:{codeText:gB,table:pB,tableData:d0,tableHeader:d0,tableRow:d0}}}function fB(t){const e=t._align;this.enter({type:"table",align:e.map(function(n){return n==="none"?null:n}),children:[]},t),this.data.inTable=!0}function pB(t){this.exit(t),this.data.inTable=void 0}function mB(t){this.enter({type:"tableRow",children:[]},t)}function d0(t){this.exit(t)}function DS(t){this.enter({type:"tableCell",children:[]},t)}function gB(t){let e=this.resume();this.data.inTable&&(e=e.replace(/\\([\\|])/g,vB));const n=this.stack[this.stack.length-1];n.type,n.value=e,this.exit(t)}function vB(t,e){return e==="|"?e:t}function yB(t){const e=t||{},n=e.tableCellPadding,r=e.tablePipeAlign,i=e.stringLength,s=n?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:`
524
+ `,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:g,table:a,tableCell:h,tableRow:c}};function a(v,k,w,S){return d(f(v,w,S),v.align)}function c(v,k,w,S){const T=p(v,w,S),C=d([T]);return C.slice(0,C.indexOf(`
525
+ `))}function h(v,k,w,S){const T=w.enter("tableCell"),C=w.enter("phrasing"),j=w.containerPhrasing(v,{...S,before:s,after:s});return C(),T(),j}function d(v,k){return I7(v,{align:k,alignDelimiters:r,padding:n,stringLength:i})}function f(v,k,w){const S=v.children;let T=-1;const C=[],j=k.enter("table");for(;++T<S.length;)C[T]=p(S[T],k,w);return j(),C}function p(v,k,w){const S=v.children;let T=-1;const C=[],j=k.enter("tableRow");for(;++T<S.length;)C[T]=h(S[T],v,k,w);return j(),C}function g(v,k,w){let S=Xj.inlineCode(v,k,w);return w.stack.includes("tableCell")&&(S=S.replace(/\|/g,"\\$&")),S}}function xB(){return{exit:{taskListCheckValueChecked:AS,taskListCheckValueUnchecked:AS,paragraph:kB}}}function bB(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:wB}}}function AS(t){const e=this.stack[this.stack.length-2];e.type,e.checked=t.type==="taskListCheckValueChecked"}function kB(t){const e=this.stack[this.stack.length-2];if(e&&e.type==="listItem"&&typeof e.checked=="boolean"){const n=this.stack[this.stack.length-1];n.type;const r=n.children[0];if(r&&r.type==="text"){const i=e.children;let s=-1,a;for(;++s<i.length;){const c=i[s];if(c.type==="paragraph"){a=c;break}}a===n&&(r.value=r.value.slice(1),r.value.length===0?n.children.shift():n.position&&r.position&&typeof r.position.start.offset=="number"&&(r.position.start.column++,r.position.start.offset++,n.position.start=Object.assign({},r.position.start)))}}this.exit(t)}function wB(t,e,n,r){const i=t.children[0],s=typeof t.checked=="boolean"&&i&&i.type==="paragraph",a="["+(t.checked?"x":" ")+"] ",c=n.createTracker(r);s&&c.move(a);let h=Xj.listItem(t,e,n,{...r,...c.current()});return s&&(h=h.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,d)),h;function d(f){return f+a}}function SB(){return[t7(),w7(),N7(),hB(),xB()]}function CB(t){return{extensions:[n7(),S7(t),E7(),yB(t),bB()]}}const TB={tokenize:RB,partial:!0},Qj={tokenize:IB,partial:!0},Zj={tokenize:MB,partial:!0},e2={tokenize:DB,partial:!0},NB={tokenize:AB,partial:!0},t2={name:"wwwAutolink",tokenize:PB,previous:r2},n2={name:"protocolAutolink",tokenize:_B,previous:i2},ya={name:"emailAutolink",tokenize:jB,previous:s2},zs={};function EB(){return{text:zs}}let Lo=48;for(;Lo<123;)zs[Lo]=ya,Lo++,Lo===58?Lo=65:Lo===91&&(Lo=97);zs[43]=ya;zs[45]=ya;zs[46]=ya;zs[95]=ya;zs[72]=[ya,n2];zs[104]=[ya,n2];zs[87]=[ya,t2];zs[119]=[ya,t2];function jB(t,e,n){const r=this;let i,s;return a;function a(p){return!bv(p)||!s2.call(r,r.previous)||rx(r.events)?n(p):(t.enter("literalAutolink"),t.enter("literalAutolinkEmail"),c(p))}function c(p){return bv(p)?(t.consume(p),c):p===64?(t.consume(p),h):n(p)}function h(p){return p===46?t.check(NB,f,d)(p):p===45||p===95||wr(p)?(s=!0,t.consume(p),h):f(p)}function d(p){return t.consume(p),i=!0,h}function f(p){return s&&i&&Ar(r.previous)?(t.exit("literalAutolinkEmail"),t.exit("literalAutolink"),e(p)):n(p)}}function PB(t,e,n){const r=this;return i;function i(a){return a!==87&&a!==119||!r2.call(r,r.previous)||rx(r.events)?n(a):(t.enter("literalAutolink"),t.enter("literalAutolinkWww"),t.check(TB,t.attempt(Qj,t.attempt(Zj,s),n),n)(a))}function s(a){return t.exit("literalAutolinkWww"),t.exit("literalAutolink"),e(a)}}function _B(t,e,n){const r=this;let i="",s=!1;return a;function a(p){return(p===72||p===104)&&i2.call(r,r.previous)&&!rx(r.events)?(t.enter("literalAutolink"),t.enter("literalAutolinkHttp"),i+=String.fromCodePoint(p),t.consume(p),c):n(p)}function c(p){if(Ar(p)&&i.length<5)return i+=String.fromCodePoint(p),t.consume(p),c;if(p===58){const g=i.toLowerCase();if(g==="http"||g==="https")return t.consume(p),h}return n(p)}function h(p){return p===47?(t.consume(p),s?d:(s=!0,h)):n(p)}function d(p){return p===null||Lf(p)||kn(p)||cl(p)||xp(p)?n(p):t.attempt(Qj,t.attempt(Zj,f),n)(p)}function f(p){return t.exit("literalAutolinkHttp"),t.exit("literalAutolink"),e(p)}}function RB(t,e,n){let r=0;return i;function i(a){return(a===87||a===119)&&r<3?(r++,t.consume(a),i):a===46&&r===3?(t.consume(a),s):n(a)}function s(a){return a===null?n(a):e(a)}}function IB(t,e,n){let r,i,s;return a;function a(d){return d===46||d===95?t.check(e2,h,c)(d):d===null||kn(d)||cl(d)||d!==45&&xp(d)?h(d):(s=!0,t.consume(d),a)}function c(d){return d===95?r=!0:(i=r,r=void 0),t.consume(d),a}function h(d){return i||r||!s?n(d):e(d)}}function MB(t,e){let n=0,r=0;return i;function i(a){return a===40?(n++,t.consume(a),i):a===41&&r<n?s(a):a===33||a===34||a===38||a===39||a===41||a===42||a===44||a===46||a===58||a===59||a===60||a===63||a===93||a===95||a===126?t.check(e2,e,s)(a):a===null||kn(a)||cl(a)?e(a):(t.consume(a),i)}function s(a){return a===41&&r++,t.consume(a),i}}function DB(t,e,n){return r;function r(c){return c===33||c===34||c===39||c===41||c===42||c===44||c===46||c===58||c===59||c===63||c===95||c===126?(t.consume(c),r):c===38?(t.consume(c),s):c===93?(t.consume(c),i):c===60||c===null||kn(c)||cl(c)?e(c):n(c)}function i(c){return c===null||c===40||c===91||kn(c)||cl(c)?e(c):r(c)}function s(c){return Ar(c)?a(c):n(c)}function a(c){return c===59?(t.consume(c),r):Ar(c)?(t.consume(c),a):n(c)}}function AB(t,e,n){return r;function r(s){return t.consume(s),i}function i(s){return wr(s)?n(s):e(s)}}function r2(t){return t===null||t===40||t===42||t===95||t===91||t===93||t===126||kn(t)}function i2(t){return!Ar(t)}function s2(t){return!(t===47||bv(t))}function bv(t){return t===43||t===45||t===46||t===95||wr(t)}function rx(t){let e=t.length,n=!1;for(;e--;){const r=t[e][1];if((r.type==="labelLink"||r.type==="labelImage")&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return t.length>0&&!n&&(t[t.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}const OB={tokenize:WB,partial:!0};function LB(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:zB,continuation:{tokenize:$B},exit:VB}},text:{91:{name:"gfmFootnoteCall",tokenize:BB},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:FB,resolveTo:UB}}}}function FB(t,e,n){const r=this;let i=r.events.length;const s=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let a;for(;i--;){const h=r.events[i][1];if(h.type==="labelImage"){a=h;break}if(h.type==="gfmFootnoteCall"||h.type==="labelLink"||h.type==="label"||h.type==="image"||h.type==="link")break}return c;function c(h){if(!a||!a._balanced)return n(h);const d=rs(r.sliceSerialize({start:a.end,end:r.now()}));return d.codePointAt(0)!==94||!s.includes(d.slice(1))?n(h):(t.enter("gfmFootnoteCallLabelMarker"),t.consume(h),t.exit("gfmFootnoteCallLabelMarker"),e(h))}}function UB(t,e){let n=t.length;for(;n--;)if(t[n][1].type==="labelImage"&&t[n][0]==="enter"){t[n][1];break}t[n+1][1].type="data",t[n+3][1].type="gfmFootnoteCallLabelMarker";const r={type:"gfmFootnoteCall",start:Object.assign({},t[n+3][1].start),end:Object.assign({},t[t.length-1][1].end)},i={type:"gfmFootnoteCallMarker",start:Object.assign({},t[n+3][1].end),end:Object.assign({},t[n+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;const s={type:"gfmFootnoteCallString",start:Object.assign({},i.end),end:Object.assign({},t[t.length-1][1].start)},a={type:"chunkString",contentType:"string",start:Object.assign({},s.start),end:Object.assign({},s.end)},c=[t[n+1],t[n+2],["enter",r,e],t[n+3],t[n+4],["enter",i,e],["exit",i,e],["enter",s,e],["enter",a,e],["exit",a,e],["exit",s,e],t[t.length-2],t[t.length-1],["exit",r,e]];return t.splice(n,t.length-n+1,...c),t}function BB(t,e,n){const r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let s=0,a;return c;function c(p){return t.enter("gfmFootnoteCall"),t.enter("gfmFootnoteCallLabelMarker"),t.consume(p),t.exit("gfmFootnoteCallLabelMarker"),h}function h(p){return p!==94?n(p):(t.enter("gfmFootnoteCallMarker"),t.consume(p),t.exit("gfmFootnoteCallMarker"),t.enter("gfmFootnoteCallString"),t.enter("chunkString").contentType="string",d)}function d(p){if(s>999||p===93&&!a||p===null||p===91||kn(p))return n(p);if(p===93){t.exit("chunkString");const g=t.exit("gfmFootnoteCallString");return i.includes(rs(r.sliceSerialize(g)))?(t.enter("gfmFootnoteCallLabelMarker"),t.consume(p),t.exit("gfmFootnoteCallLabelMarker"),t.exit("gfmFootnoteCall"),e):n(p)}return kn(p)||(a=!0),s++,t.consume(p),p===92?f:d}function f(p){return p===91||p===92||p===93?(t.consume(p),s++,d):d(p)}}function zB(t,e,n){const r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let s,a=0,c;return h;function h(k){return t.enter("gfmFootnoteDefinition")._container=!0,t.enter("gfmFootnoteDefinitionLabel"),t.enter("gfmFootnoteDefinitionLabelMarker"),t.consume(k),t.exit("gfmFootnoteDefinitionLabelMarker"),d}function d(k){return k===94?(t.enter("gfmFootnoteDefinitionMarker"),t.consume(k),t.exit("gfmFootnoteDefinitionMarker"),t.enter("gfmFootnoteDefinitionLabelString"),t.enter("chunkString").contentType="string",f):n(k)}function f(k){if(a>999||k===93&&!c||k===null||k===91||kn(k))return n(k);if(k===93){t.exit("chunkString");const w=t.exit("gfmFootnoteDefinitionLabelString");return s=rs(r.sliceSerialize(w)),t.enter("gfmFootnoteDefinitionLabelMarker"),t.consume(k),t.exit("gfmFootnoteDefinitionLabelMarker"),t.exit("gfmFootnoteDefinitionLabel"),g}return kn(k)||(c=!0),a++,t.consume(k),k===92?p:f}function p(k){return k===91||k===92||k===93?(t.consume(k),a++,f):f(k)}function g(k){return k===58?(t.enter("definitionMarker"),t.consume(k),t.exit("definitionMarker"),i.includes(s)||i.push(s),Vt(t,v,"gfmFootnoteDefinitionWhitespace")):n(k)}function v(k){return e(k)}}function $B(t,e,n){return t.check(Td,e,t.attempt(OB,e,n))}function VB(t){t.exit("gfmFootnoteDefinition")}function WB(t,e,n){const r=this;return Vt(t,i,"gfmFootnoteDefinitionIndent",5);function i(s){const a=r.events[r.events.length-1];return a&&a[1].type==="gfmFootnoteDefinitionIndent"&&a[2].sliceSerialize(a[1],!0).length===4?e(s):n(s)}}function HB(t){let n=(t||{}).singleTilde;const r={name:"strikethrough",tokenize:s,resolveAll:i};return n==null&&(n=!0),{text:{126:r},insideSpan:{null:[r]},attentionMarkers:{null:[126]}};function i(a,c){let h=-1;for(;++h<a.length;)if(a[h][0]==="enter"&&a[h][1].type==="strikethroughSequenceTemporary"&&a[h][1]._close){let d=h;for(;d--;)if(a[d][0]==="exit"&&a[d][1].type==="strikethroughSequenceTemporary"&&a[d][1]._open&&a[h][1].end.offset-a[h][1].start.offset===a[d][1].end.offset-a[d][1].start.offset){a[h][1].type="strikethroughSequence",a[d][1].type="strikethroughSequence";const f={type:"strikethrough",start:Object.assign({},a[d][1].start),end:Object.assign({},a[h][1].end)},p={type:"strikethroughText",start:Object.assign({},a[d][1].end),end:Object.assign({},a[h][1].start)},g=[["enter",f,c],["enter",a[d][1],c],["exit",a[d][1],c],["enter",p,c]],v=c.parser.constructs.insideSpan.null;v&&di(g,g.length,0,bp(v,a.slice(d+1,h),c)),di(g,g.length,0,[["exit",p,c],["enter",a[h][1],c],["exit",a[h][1],c],["exit",f,c]]),di(a,d-1,h-d+3,g),h=d+g.length-2;break}}for(h=-1;++h<a.length;)a[h][1].type==="strikethroughSequenceTemporary"&&(a[h][1].type="data");return a}function s(a,c,h){const d=this.previous,f=this.events;let p=0;return g;function g(k){return d===126&&f[f.length-1][1].type!=="characterEscape"?h(k):(a.enter("strikethroughSequenceTemporary"),v(k))}function v(k){const w=bc(d);if(k===126)return p>1?h(k):(a.consume(k),p++,v);if(p<2&&!n)return h(k);const S=a.exit("strikethroughSequenceTemporary"),T=bc(k);return S._open=!T||T===2&&!!w,S._close=!w||w===2&&!!T,c(k)}}}class qB{constructor(){this.map=[]}add(e,n,r){KB(this,e,n,r)}consume(e){if(this.map.sort(function(s,a){return s[0]-a[0]}),this.map.length===0)return;let n=this.map.length;const r=[];for(;n>0;)n-=1,r.push(e.slice(this.map[n][0]+this.map[n][1]),this.map[n][2]),e.length=this.map[n][0];r.push(e.slice()),e.length=0;let i=r.pop();for(;i;){for(const s of i)e.push(s);i=r.pop()}this.map.length=0}}function KB(t,e,n,r){let i=0;if(!(n===0&&r.length===0)){for(;i<t.map.length;){if(t.map[i][0]===e){t.map[i][1]+=n,t.map[i][2].push(...r);return}i+=1}t.map.push([e,n,r])}}function GB(t,e){let n=!1;const r=[];for(;e<t.length;){const i=t[e];if(n){if(i[0]==="enter")i[1].type==="tableContent"&&r.push(t[e+1][1].type==="tableDelimiterMarker"?"left":"none");else if(i[1].type==="tableContent"){if(t[e-1][1].type==="tableDelimiterMarker"){const s=r.length-1;r[s]=r[s]==="left"?"center":"right"}}else if(i[1].type==="tableDelimiterRow")break}else i[0]==="enter"&&i[1].type==="tableDelimiterRow"&&(n=!0);e+=1}return r}function YB(){return{flow:{null:{name:"table",tokenize:JB,resolveAll:XB}}}}function JB(t,e,n){const r=this;let i=0,s=0,a;return c;function c(E){let P=r.events.length-1;for(;P>-1;){const K=r.events[P][1].type;if(K==="lineEnding"||K==="linePrefix")P--;else break}const V=P>-1?r.events[P][1].type:null,F=V==="tableHead"||V==="tableRow"?I:h;return F===I&&r.parser.lazy[r.now().line]?n(E):F(E)}function h(E){return t.enter("tableHead"),t.enter("tableRow"),d(E)}function d(E){return E===124||(a=!0,s+=1),f(E)}function f(E){return E===null?n(E):mt(E)?s>1?(s=0,r.interrupt=!0,t.exit("tableRow"),t.enter("lineEnding"),t.consume(E),t.exit("lineEnding"),v):n(E):Ft(E)?Vt(t,f,"whitespace")(E):(s+=1,a&&(a=!1,i+=1),E===124?(t.enter("tableCellDivider"),t.consume(E),t.exit("tableCellDivider"),a=!0,f):(t.enter("data"),p(E)))}function p(E){return E===null||E===124||kn(E)?(t.exit("data"),f(E)):(t.consume(E),E===92?g:p)}function g(E){return E===92||E===124?(t.consume(E),p):p(E)}function v(E){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(E):(t.enter("tableDelimiterRow"),a=!1,Ft(E)?Vt(t,k,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(E):k(E))}function k(E){return E===45||E===58?S(E):E===124?(a=!0,t.enter("tableCellDivider"),t.consume(E),t.exit("tableCellDivider"),w):_(E)}function w(E){return Ft(E)?Vt(t,S,"whitespace")(E):S(E)}function S(E){return E===58?(s+=1,a=!0,t.enter("tableDelimiterMarker"),t.consume(E),t.exit("tableDelimiterMarker"),T):E===45?(s+=1,T(E)):E===null||mt(E)?R(E):_(E)}function T(E){return E===45?(t.enter("tableDelimiterFiller"),C(E)):_(E)}function C(E){return E===45?(t.consume(E),C):E===58?(a=!0,t.exit("tableDelimiterFiller"),t.enter("tableDelimiterMarker"),t.consume(E),t.exit("tableDelimiterMarker"),j):(t.exit("tableDelimiterFiller"),j(E))}function j(E){return Ft(E)?Vt(t,R,"whitespace")(E):R(E)}function R(E){return E===124?k(E):E===null||mt(E)?!a||i!==s?_(E):(t.exit("tableDelimiterRow"),t.exit("tableHead"),e(E)):_(E)}function _(E){return n(E)}function I(E){return t.enter("tableRow"),M(E)}function M(E){return E===124?(t.enter("tableCellDivider"),t.consume(E),t.exit("tableCellDivider"),M):E===null||mt(E)?(t.exit("tableRow"),e(E)):Ft(E)?Vt(t,M,"whitespace")(E):(t.enter("data"),L(E))}function L(E){return E===null||E===124||kn(E)?(t.exit("data"),M(E)):(t.consume(E),E===92?$:L)}function $(E){return E===92||E===124?(t.consume(E),L):L(E)}}function XB(t,e){let n=-1,r=!0,i=0,s=[0,0,0,0],a=[0,0,0,0],c=!1,h=0,d,f,p;const g=new qB;for(;++n<t.length;){const v=t[n],k=v[1];v[0]==="enter"?k.type==="tableHead"?(c=!1,h!==0&&(OS(g,e,h,d,f),f=void 0,h=0),d={type:"table",start:Object.assign({},k.start),end:Object.assign({},k.end)},g.add(n,0,[["enter",d,e]])):k.type==="tableRow"||k.type==="tableDelimiterRow"?(r=!0,p=void 0,s=[0,0,0,0],a=[0,n+1,0,0],c&&(c=!1,f={type:"tableBody",start:Object.assign({},k.start),end:Object.assign({},k.end)},g.add(n,0,[["enter",f,e]])),i=k.type==="tableDelimiterRow"?2:f?3:1):i&&(k.type==="data"||k.type==="tableDelimiterMarker"||k.type==="tableDelimiterFiller")?(r=!1,a[2]===0&&(s[1]!==0&&(a[0]=a[1],p=Xh(g,e,s,i,void 0,p),s=[0,0,0,0]),a[2]=n)):k.type==="tableCellDivider"&&(r?r=!1:(s[1]!==0&&(a[0]=a[1],p=Xh(g,e,s,i,void 0,p)),s=a,a=[s[1],n,0,0])):k.type==="tableHead"?(c=!0,h=n):k.type==="tableRow"||k.type==="tableDelimiterRow"?(h=n,s[1]!==0?(a[0]=a[1],p=Xh(g,e,s,i,n,p)):a[1]!==0&&(p=Xh(g,e,a,i,n,p)),i=0):i&&(k.type==="data"||k.type==="tableDelimiterMarker"||k.type==="tableDelimiterFiller")&&(a[3]=n)}for(h!==0&&OS(g,e,h,d,f),g.consume(e.events),n=-1;++n<e.events.length;){const v=e.events[n];v[0]==="enter"&&v[1].type==="table"&&(v[1]._align=GB(e.events,n))}return t}function Xh(t,e,n,r,i,s){const a=r===1?"tableHeader":r===2?"tableDelimiter":"tableData",c="tableContent";n[0]!==0&&(s.end=Object.assign({},ec(e.events,n[0])),t.add(n[0],0,[["exit",s,e]]));const h=ec(e.events,n[1]);if(s={type:a,start:Object.assign({},h),end:Object.assign({},h)},t.add(n[1],0,[["enter",s,e]]),n[2]!==0){const d=ec(e.events,n[2]),f=ec(e.events,n[3]),p={type:c,start:Object.assign({},d),end:Object.assign({},f)};if(t.add(n[2],0,[["enter",p,e]]),r!==2){const g=e.events[n[2]],v=e.events[n[3]];if(g[1].end=Object.assign({},v[1].end),g[1].type="chunkText",g[1].contentType="text",n[3]>n[2]+1){const k=n[2]+1,w=n[3]-n[2]-1;t.add(k,w,[])}}t.add(n[3]+1,0,[["exit",p,e]])}return i!==void 0&&(s.end=Object.assign({},ec(e.events,i)),t.add(i,0,[["exit",s,e]]),s=void 0),s}function OS(t,e,n,r,i){const s=[],a=ec(e.events,n);i&&(i.end=Object.assign({},a),s.push(["exit",i,e])),r.end=Object.assign({},a),s.push(["exit",r,e]),t.add(n+1,0,s)}function ec(t,e){const n=t[e],r=n[0]==="enter"?"start":"end";return n[1][r]}const QB={name:"tasklistCheck",tokenize:ez};function ZB(){return{text:{91:QB}}}function ez(t,e,n){const r=this;return i;function i(h){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(h):(t.enter("taskListCheck"),t.enter("taskListCheckMarker"),t.consume(h),t.exit("taskListCheckMarker"),s)}function s(h){return kn(h)?(t.enter("taskListCheckValueUnchecked"),t.consume(h),t.exit("taskListCheckValueUnchecked"),a):h===88||h===120?(t.enter("taskListCheckValueChecked"),t.consume(h),t.exit("taskListCheckValueChecked"),a):n(h)}function a(h){return h===93?(t.enter("taskListCheckMarker"),t.consume(h),t.exit("taskListCheckMarker"),t.exit("taskListCheck"),c):n(h)}function c(h){return mt(h)?e(h):Ft(h)?t.check({tokenize:tz},e,n)(h):n(h)}}function tz(t,e,n){return Vt(t,r,"whitespace");function r(i){return i===null?n(i):e(i)}}function nz(t){return mj([EB(),LB(),HB(t),YB(),ZB()])}const rz={};function a2(t){const e=this,n=t||rz,r=e.data(),i=r.micromarkExtensions||(r.micromarkExtensions=[]),s=r.fromMarkdownExtensions||(r.fromMarkdownExtensions=[]),a=r.toMarkdownExtensions||(r.toMarkdownExtensions=[]);i.push(nz(n)),s.push(SB()),a.push(CB(n))}var LS={};function iz(t,e){return e.forEach(function(n){n&&typeof n!="string"&&!Array.isArray(n)&&Object.keys(n).forEach(function(r){if(r!=="default"&&!(r in t)){var i=Object.getOwnPropertyDescriptor(n,r);Object.defineProperty(t,r,i.get?i:{enumerable:!0,get:function(){return n[r]}})}})}),Object.freeze(t)}var sz=Object.defineProperty,az=(t,e,n)=>e in t?sz(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,FS=(t,e,n)=>az(t,typeof e!="symbol"?e+"":e,n);class fr{constructor(){FS(this,"_locking"),FS(this,"_locks"),this._locking=Promise.resolve(),this._locks=0}isLocked(){return this._locks>0}lock(){this._locks+=1;let e;const n=new Promise(i=>e=()=>{this._locks-=1,i()}),r=this._locking.then(()=>e);return this._locking=this._locking.then(()=>n),r}}function Bn(t,e){if(!t)throw new Error(e)}const oz=34028234663852886e22,lz=-34028234663852886e22,cz=4294967295,uz=2147483647,dz=-2147483648;function mf(t){if(typeof t!="number")throw new Error("invalid int 32: "+typeof t);if(!Number.isInteger(t)||t>uz||t<dz)throw new Error("invalid int 32: "+t)}function kv(t){if(typeof t!="number")throw new Error("invalid uint 32: "+typeof t);if(!Number.isInteger(t)||t>cz||t<0)throw new Error("invalid uint 32: "+t)}function o2(t){if(typeof t!="number")throw new Error("invalid float 32: "+typeof t);if(Number.isFinite(t)&&(t>oz||t<lz))throw new Error("invalid float 32: "+t)}const l2=Symbol("@bufbuild/protobuf/enum-type");function hz(t){const e=t[l2];return Bn(e,"missing enum type on enum object"),e}function c2(t,e,n,r){t[l2]=u2(e,n.map(i=>({no:i.no,name:i.name,localName:t[i.no]})))}function u2(t,e,n){const r=Object.create(null),i=Object.create(null),s=[];for(const a of e){const c=d2(a);s.push(c),r[a.name]=c,i[a.no]=c}return{typeName:t,values:s,findName(a){return r[a]},findNumber(a){return i[a]}}}function fz(t,e,n){const r={};for(const i of e){const s=d2(i);r[s.localName]=s.no,r[s.no]=s.localName}return c2(r,t,e),r}function d2(t){return"localName"in t?t:Object.assign(Object.assign({},t),{localName:t.name})}class ix{equals(e){return this.getType().runtime.util.equals(this.getType(),this,e)}clone(){return this.getType().runtime.util.clone(this)}fromBinary(e,n){const r=this.getType(),i=r.runtime.bin,s=i.makeReadOptions(n);return i.readMessage(this,s.readerFactory(e),e.byteLength,s),this}fromJson(e,n){const r=this.getType(),i=r.runtime.json,s=i.makeReadOptions(n);return i.readMessage(r,e,s,this),this}fromJsonString(e,n){let r;try{r=JSON.parse(e)}catch(i){throw new Error("cannot decode ".concat(this.getType().typeName," from JSON: ").concat(i instanceof Error?i.message:String(i)))}return this.fromJson(r,n)}toBinary(e){const n=this.getType(),r=n.runtime.bin,i=r.makeWriteOptions(e),s=i.writerFactory();return r.writeMessage(this,s,i),s.finish()}toJson(e){const n=this.getType(),r=n.runtime.json,i=r.makeWriteOptions(e);return r.writeMessage(this,i)}toJsonString(e){var n;const r=this.toJson(e);return JSON.stringify(r,null,(n=e==null?void 0:e.prettySpaces)!==null&&n!==void 0?n:0)}toJSON(){return this.toJson({emitDefaultValues:!0})}getType(){return Object.getPrototypeOf(this).constructor}}function pz(t,e,n,r){var i;const s=(i=r==null?void 0:r.localName)!==null&&i!==void 0?i:e.substring(e.lastIndexOf(".")+1),a={[s]:function(c){t.util.initFields(this),t.util.initPartial(c,this)}}[s];return Object.setPrototypeOf(a.prototype,new ix),Object.assign(a,{runtime:t,typeName:e,fields:t.util.newFieldList(n),fromBinary(c,h){return new a().fromBinary(c,h)},fromJson(c,h){return new a().fromJson(c,h)},fromJsonString(c,h){return new a().fromJsonString(c,h)},equals(c,h){return t.util.equals(a,c,h)}}),a}function mz(){let t=0,e=0;for(let r=0;r<28;r+=7){let i=this.buf[this.pos++];if(t|=(i&127)<<r,(i&128)==0)return this.assertBounds(),[t,e]}let n=this.buf[this.pos++];if(t|=(n&15)<<28,e=(n&112)>>4,(n&128)==0)return this.assertBounds(),[t,e];for(let r=3;r<=31;r+=7){let i=this.buf[this.pos++];if(e|=(i&127)<<r,(i&128)==0)return this.assertBounds(),[t,e]}throw new Error("invalid varint")}function h0(t,e,n){for(let s=0;s<28;s=s+7){const a=t>>>s,c=!(!(a>>>7)&&e==0),h=(c?a|128:a)&255;if(n.push(h),!c)return}const r=t>>>28&15|(e&7)<<4,i=e>>3!=0;if(n.push((i?r|128:r)&255),!!i){for(let s=3;s<31;s=s+7){const a=e>>>s,c=!!(a>>>7),h=(c?a|128:a)&255;if(n.push(h),!c)return}n.push(e>>>31&1)}}const gf=4294967296;function US(t){const e=t[0]==="-";e&&(t=t.slice(1));const n=1e6;let r=0,i=0;function s(a,c){const h=Number(t.slice(a,c));i*=n,r=r*n+h,r>=gf&&(i=i+(r/gf|0),r=r%gf)}return s(-24,-18),s(-18,-12),s(-12,-6),s(-6),e?f2(r,i):sx(r,i)}function gz(t,e){let n=sx(t,e);const r=n.hi&2147483648;r&&(n=f2(n.lo,n.hi));const i=h2(n.lo,n.hi);return r?"-"+i:i}function h2(t,e){if({lo:t,hi:e}=vz(t,e),e<=2097151)return String(gf*e+t);const n=t&16777215,r=(t>>>24|e<<8)&16777215,i=e>>16&65535;let s=n+r*6777216+i*6710656,a=r+i*8147497,c=i*2;const h=1e7;return s>=h&&(a+=Math.floor(s/h),s%=h),a>=h&&(c+=Math.floor(a/h),a%=h),c.toString()+BS(a)+BS(s)}function vz(t,e){return{lo:t>>>0,hi:e>>>0}}function sx(t,e){return{lo:t|0,hi:e|0}}function f2(t,e){return e=~e,t?t=~t+1:e+=1,sx(t,e)}const BS=t=>{const e=String(t);return"0000000".slice(e.length)+e};function zS(t,e){if(t>=0){for(;t>127;)e.push(t&127|128),t=t>>>7;e.push(t)}else{for(let n=0;n<9;n++)e.push(t&127|128),t=t>>7;e.push(1)}}function yz(){let t=this.buf[this.pos++],e=t&127;if((t&128)==0)return this.assertBounds(),e;if(t=this.buf[this.pos++],e|=(t&127)<<7,(t&128)==0)return this.assertBounds(),e;if(t=this.buf[this.pos++],e|=(t&127)<<14,(t&128)==0)return this.assertBounds(),e;if(t=this.buf[this.pos++],e|=(t&127)<<21,(t&128)==0)return this.assertBounds(),e;t=this.buf[this.pos++],e|=(t&15)<<28;for(let n=5;(t&128)!==0&&n<10;n++)t=this.buf[this.pos++];if((t&128)!=0)throw new Error("invalid varint");return this.assertBounds(),e>>>0}function xz(){const t=new DataView(new ArrayBuffer(8));if(typeof BigInt=="function"&&typeof t.getBigInt64=="function"&&typeof t.getBigUint64=="function"&&typeof t.setBigInt64=="function"&&typeof t.setBigUint64=="function"&&(typeof process!="object"||typeof LS!="object"||LS.BUF_BIGINT_DISABLE!=="1")){const i=BigInt("-9223372036854775808"),s=BigInt("9223372036854775807"),a=BigInt("0"),c=BigInt("18446744073709551615");return{zero:BigInt(0),supported:!0,parse(h){const d=typeof h=="bigint"?h:BigInt(h);if(d>s||d<i)throw new Error("int64 invalid: ".concat(h));return d},uParse(h){const d=typeof h=="bigint"?h:BigInt(h);if(d>c||d<a)throw new Error("uint64 invalid: ".concat(h));return d},enc(h){return t.setBigInt64(0,this.parse(h),!0),{lo:t.getInt32(0,!0),hi:t.getInt32(4,!0)}},uEnc(h){return t.setBigInt64(0,this.uParse(h),!0),{lo:t.getInt32(0,!0),hi:t.getInt32(4,!0)}},dec(h,d){return t.setInt32(0,h,!0),t.setInt32(4,d,!0),t.getBigInt64(0,!0)},uDec(h,d){return t.setInt32(0,h,!0),t.setInt32(4,d,!0),t.getBigUint64(0,!0)}}}const n=i=>Bn(/^-?[0-9]+$/.test(i),"int64 invalid: ".concat(i)),r=i=>Bn(/^[0-9]+$/.test(i),"uint64 invalid: ".concat(i));return{zero:"0",supported:!1,parse(i){return typeof i!="string"&&(i=i.toString()),n(i),i},uParse(i){return typeof i!="string"&&(i=i.toString()),r(i),i},enc(i){return typeof i!="string"&&(i=i.toString()),n(i),US(i)},uEnc(i){return typeof i!="string"&&(i=i.toString()),r(i),US(i)},dec(i,s){return gz(i,s)},uDec(i,s){return h2(i,s)}}}const In=xz();var Ne;(function(t){t[t.DOUBLE=1]="DOUBLE",t[t.FLOAT=2]="FLOAT",t[t.INT64=3]="INT64",t[t.UINT64=4]="UINT64",t[t.INT32=5]="INT32",t[t.FIXED64=6]="FIXED64",t[t.FIXED32=7]="FIXED32",t[t.BOOL=8]="BOOL",t[t.STRING=9]="STRING",t[t.BYTES=12]="BYTES",t[t.UINT32=13]="UINT32",t[t.SFIXED32=15]="SFIXED32",t[t.SFIXED64=16]="SFIXED64",t[t.SINT32=17]="SINT32",t[t.SINT64=18]="SINT64"})(Ne||(Ne={}));var oo;(function(t){t[t.BIGINT=0]="BIGINT",t[t.STRING=1]="STRING"})(oo||(oo={}));function Va(t,e,n){if(e===n)return!0;if(t==Ne.BYTES){if(!(e instanceof Uint8Array)||!(n instanceof Uint8Array)||e.length!==n.length)return!1;for(let r=0;r<e.length;r++)if(e[r]!==n[r])return!1;return!0}switch(t){case Ne.UINT64:case Ne.FIXED64:case Ne.INT64:case Ne.SFIXED64:case Ne.SINT64:return e==n}return!1}function kc(t,e){switch(t){case Ne.BOOL:return!1;case Ne.UINT64:case Ne.FIXED64:case Ne.INT64:case Ne.SFIXED64:case Ne.SINT64:return e==0?In.zero:"0";case Ne.DOUBLE:case Ne.FLOAT:return 0;case Ne.BYTES:return new Uint8Array(0);case Ne.STRING:return"";default:return 0}}function p2(t,e){switch(t){case Ne.BOOL:return e===!1;case Ne.STRING:return e==="";case Ne.BYTES:return e instanceof Uint8Array&&!e.byteLength;default:return e==0}}var Hn;(function(t){t[t.Varint=0]="Varint",t[t.Bit64=1]="Bit64",t[t.LengthDelimited=2]="LengthDelimited",t[t.StartGroup=3]="StartGroup",t[t.EndGroup=4]="EndGroup",t[t.Bit32=5]="Bit32"})(Hn||(Hn={}));class bz{constructor(e){this.stack=[],this.textEncoder=e??new TextEncoder,this.chunks=[],this.buf=[]}finish(){this.chunks.push(new Uint8Array(this.buf));let e=0;for(let i=0;i<this.chunks.length;i++)e+=this.chunks[i].length;let n=new Uint8Array(e),r=0;for(let i=0;i<this.chunks.length;i++)n.set(this.chunks[i],r),r+=this.chunks[i].length;return this.chunks=[],n}fork(){return this.stack.push({chunks:this.chunks,buf:this.buf}),this.chunks=[],this.buf=[],this}join(){let e=this.finish(),n=this.stack.pop();if(!n)throw new Error("invalid state, fork stack empty");return this.chunks=n.chunks,this.buf=n.buf,this.uint32(e.byteLength),this.raw(e)}tag(e,n){return this.uint32((e<<3|n)>>>0)}raw(e){return this.buf.length&&(this.chunks.push(new Uint8Array(this.buf)),this.buf=[]),this.chunks.push(e),this}uint32(e){for(kv(e);e>127;)this.buf.push(e&127|128),e=e>>>7;return this.buf.push(e),this}int32(e){return mf(e),zS(e,this.buf),this}bool(e){return this.buf.push(e?1:0),this}bytes(e){return this.uint32(e.byteLength),this.raw(e)}string(e){let n=this.textEncoder.encode(e);return this.uint32(n.byteLength),this.raw(n)}float(e){o2(e);let n=new Uint8Array(4);return new DataView(n.buffer).setFloat32(0,e,!0),this.raw(n)}double(e){let n=new Uint8Array(8);return new DataView(n.buffer).setFloat64(0,e,!0),this.raw(n)}fixed32(e){kv(e);let n=new Uint8Array(4);return new DataView(n.buffer).setUint32(0,e,!0),this.raw(n)}sfixed32(e){mf(e);let n=new Uint8Array(4);return new DataView(n.buffer).setInt32(0,e,!0),this.raw(n)}sint32(e){return mf(e),e=(e<<1^e>>31)>>>0,zS(e,this.buf),this}sfixed64(e){let n=new Uint8Array(8),r=new DataView(n.buffer),i=In.enc(e);return r.setInt32(0,i.lo,!0),r.setInt32(4,i.hi,!0),this.raw(n)}fixed64(e){let n=new Uint8Array(8),r=new DataView(n.buffer),i=In.uEnc(e);return r.setInt32(0,i.lo,!0),r.setInt32(4,i.hi,!0),this.raw(n)}int64(e){let n=In.enc(e);return h0(n.lo,n.hi,this.buf),this}sint64(e){let n=In.enc(e),r=n.hi>>31,i=n.lo<<1^r,s=(n.hi<<1|n.lo>>>31)^r;return h0(i,s,this.buf),this}uint64(e){let n=In.uEnc(e);return h0(n.lo,n.hi,this.buf),this}}class kz{constructor(e,n){this.varint64=mz,this.uint32=yz,this.buf=e,this.len=e.length,this.pos=0,this.view=new DataView(e.buffer,e.byteOffset,e.byteLength),this.textDecoder=n??new TextDecoder}tag(){let e=this.uint32(),n=e>>>3,r=e&7;if(n<=0||r<0||r>5)throw new Error("illegal tag: field no "+n+" wire type "+r);return[n,r]}skip(e,n){let r=this.pos;switch(e){case Hn.Varint:for(;this.buf[this.pos++]&128;);break;case Hn.Bit64:this.pos+=4;case Hn.Bit32:this.pos+=4;break;case Hn.LengthDelimited:let i=this.uint32();this.pos+=i;break;case Hn.StartGroup:for(;;){const[s,a]=this.tag();if(a===Hn.EndGroup){if(n!==void 0&&s!==n)throw new Error("invalid end group tag");break}this.skip(a,s)}break;default:throw new Error("cant skip wire type "+e)}return this.assertBounds(),this.buf.subarray(r,this.pos)}assertBounds(){if(this.pos>this.len)throw new RangeError("premature EOF")}int32(){return this.uint32()|0}sint32(){let e=this.uint32();return e>>>1^-(e&1)}int64(){return In.dec(...this.varint64())}uint64(){return In.uDec(...this.varint64())}sint64(){let[e,n]=this.varint64(),r=-(e&1);return e=(e>>>1|(n&1)<<31)^r,n=n>>>1^r,In.dec(e,n)}bool(){let[e,n]=this.varint64();return e!==0||n!==0}fixed32(){return this.view.getUint32((this.pos+=4)-4,!0)}sfixed32(){return this.view.getInt32((this.pos+=4)-4,!0)}fixed64(){return In.uDec(this.sfixed32(),this.sfixed32())}sfixed64(){return In.dec(this.sfixed32(),this.sfixed32())}float(){return this.view.getFloat32((this.pos+=4)-4,!0)}double(){return this.view.getFloat64((this.pos+=8)-8,!0)}bytes(){let e=this.uint32(),n=this.pos;return this.pos+=e,this.assertBounds(),this.buf.subarray(n,n+e)}string(){return this.textDecoder.decode(this.bytes())}}function wz(t,e,n,r){let i;return{typeName:e,extendee:n,get field(){if(!i){const s=typeof r=="function"?r():r;s.name=e.split(".").pop(),s.jsonName="[".concat(e,"]"),i=t.util.newFieldList([s]).list()[0]}return i},runtime:t}}function m2(t){const e=t.field.localName,n=Object.create(null);return n[e]=Sz(t),[n,()=>n[e]]}function Sz(t){const e=t.field;if(e.repeated)return[];if(e.default!==void 0)return e.default;switch(e.kind){case"enum":return e.T.values[0].no;case"scalar":return kc(e.T,e.L);case"message":const n=e.T,r=new n;return n.fieldWrapper?n.fieldWrapper.unwrapField(r):r;case"map":throw"map fields are not allowed to be extensions"}}function Cz(t,e){if(!e.repeated&&(e.kind=="enum"||e.kind=="scalar")){for(let n=t.length-1;n>=0;--n)if(t[n].no==e.no)return[t[n]];return[]}return t.filter(n=>n.no===e.no)}let ca="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split(""),Cp=[];for(let t=0;t<ca.length;t++)Cp[ca[t].charCodeAt(0)]=t;Cp[45]=ca.indexOf("+");Cp[95]=ca.indexOf("/");const g2={dec(t){let e=t.length*3/4;t[t.length-2]=="="?e-=2:t[t.length-1]=="="&&(e-=1);let n=new Uint8Array(e),r=0,i=0,s,a=0;for(let c=0;c<t.length;c++){if(s=Cp[t.charCodeAt(c)],s===void 0)switch(t[c]){case"=":i=0;case`
526
+ `:case"\r":case" ":case" ":continue;default:throw Error("invalid base64 string.")}switch(i){case 0:a=s,i=1;break;case 1:n[r++]=a<<2|(s&48)>>4,a=s,i=2;break;case 2:n[r++]=(a&15)<<4|(s&60)>>2,a=s,i=3;break;case 3:n[r++]=(a&3)<<6|s,i=0;break}}if(i==1)throw Error("invalid base64 string.");return n.subarray(0,r)},enc(t){let e="",n=0,r,i=0;for(let s=0;s<t.length;s++)switch(r=t[s],n){case 0:e+=ca[r>>2],i=(r&3)<<4,n=1;break;case 1:e+=ca[i|r>>4],i=(r&15)<<2,n=2;break;case 2:e+=ca[i|r>>6],e+=ca[r&63],n=0;break}return n&&(e+=ca[i],e+="=",n==1&&(e+="=")),e}};function Tz(t,e,n){y2(e,t);const r=e.runtime.bin.makeReadOptions(n),i=Cz(t.getType().runtime.bin.listUnknownFields(t),e.field),[s,a]=m2(e);for(const c of i)e.runtime.bin.readField(s,r.readerFactory(c.data),e.field,c.wireType,r);return a()}function Nz(t,e,n,r){y2(e,t);const i=e.runtime.bin.makeReadOptions(r),s=e.runtime.bin.makeWriteOptions(r);if(v2(t,e)){const d=t.getType().runtime.bin.listUnknownFields(t).filter(f=>f.no!=e.field.no);t.getType().runtime.bin.discardUnknownFields(t);for(const f of d)t.getType().runtime.bin.onUnknownField(t,f.no,f.wireType,f.data)}const a=s.writerFactory();let c=e.field;!c.opt&&!c.repeated&&(c.kind=="enum"||c.kind=="scalar")&&(c=Object.assign(Object.assign({},e.field),{opt:!0})),e.runtime.bin.writeField(c,n,a,s);const h=i.readerFactory(a.finish());for(;h.pos<h.len;){const[d,f]=h.tag(),p=h.skip(f,d);t.getType().runtime.bin.onUnknownField(t,d,f,p)}}function v2(t,e){const n=t.getType();return e.extendee.typeName===n.typeName&&!!n.runtime.bin.listUnknownFields(t).find(r=>r.no==e.field.no)}function y2(t,e){Bn(t.extendee.typeName==e.getType().typeName,"extension ".concat(t.typeName," can only be applied to message ").concat(t.extendee.typeName))}function x2(t,e){const n=t.localName;if(t.repeated)return e[n].length>0;if(t.oneof)return e[t.oneof.localName].case===n;switch(t.kind){case"enum":case"scalar":return t.opt||t.req?e[n]!==void 0:t.kind=="enum"?e[n]!==t.T.values[0].no:!p2(t.T,e[n]);case"message":return e[n]!==void 0;case"map":return Object.keys(e[n]).length>0}}function $S(t,e){const n=t.localName,r=!t.opt&&!t.req;if(t.repeated)e[n]=[];else if(t.oneof)e[t.oneof.localName]={case:void 0};else switch(t.kind){case"map":e[n]={};break;case"enum":e[n]=r?t.T.values[0].no:void 0;break;case"scalar":e[n]=r?kc(t.T,t.L):void 0;break;case"message":e[n]=void 0;break}}function ua(t,e){if(t===null||typeof t!="object"||!Object.getOwnPropertyNames(ix.prototype).every(r=>r in t&&typeof t[r]=="function"))return!1;const n=t.getType();return n===null||typeof n!="function"||!("typeName"in n)||typeof n.typeName!="string"?!1:e===void 0?!0:n.typeName==e.typeName}function b2(t,e){return ua(e)||!t.fieldWrapper?e:t.fieldWrapper.wrapField(e)}Ne.DOUBLE,Ne.FLOAT,Ne.INT64,Ne.UINT64,Ne.INT32,Ne.UINT32,Ne.BOOL,Ne.STRING,Ne.BYTES;const VS={ignoreUnknownFields:!1},WS={emitDefaultValues:!1,enumAsInteger:!1,useProtoFieldName:!1,prettySpaces:0};function Ez(t){return t?Object.assign(Object.assign({},VS),t):VS}function jz(t){return t?Object.assign(Object.assign({},WS),t):WS}const zf=Symbol(),vf=Symbol();function Pz(){return{makeReadOptions:Ez,makeWriteOptions:jz,readMessage(t,e,n,r){if(e==null||Array.isArray(e)||typeof e!="object")throw new Error("cannot decode message ".concat(t.typeName," from JSON: ").concat(ys(e)));r=r??new t;const i=new Map,s=n.typeRegistry;for(const[a,c]of Object.entries(e)){const h=t.fields.findJsonName(a);if(h){if(h.oneof){if(c===null&&h.kind=="scalar")continue;const d=i.get(h.oneof);if(d!==void 0)throw new Error("cannot decode message ".concat(t.typeName,' from JSON: multiple keys for oneof "').concat(h.oneof.name,'" present: "').concat(d,'", "').concat(a,'"'));i.set(h.oneof,a)}HS(r,c,h,n,t)}else{let d=!1;if(s!=null&&s.findExtension&&a.startsWith("[")&&a.endsWith("]")){const f=s.findExtension(a.substring(1,a.length-1));if(f&&f.extendee.typeName==t.typeName){d=!0;const[p,g]=m2(f);HS(p,c,f.field,n,f),Nz(r,f,g(),n)}}if(!d&&!n.ignoreUnknownFields)throw new Error("cannot decode message ".concat(t.typeName,' from JSON: key "').concat(a,'" is unknown'))}}return r},writeMessage(t,e){const n=t.getType(),r={};let i;try{for(i of n.fields.byNumber()){if(!x2(i,t)){if(i.req)throw"required field not set";if(!e.emitDefaultValues||!Rz(i))continue}const a=i.oneof?t[i.oneof.localName].value:t[i.localName],c=qS(i,a,e);c!==void 0&&(r[e.useProtoFieldName?i.name:i.jsonName]=c)}const s=e.typeRegistry;if(s!=null&&s.findExtensionFor)for(const a of n.runtime.bin.listUnknownFields(t)){const c=s.findExtensionFor(n.typeName,a.no);if(c&&v2(t,c)){const h=Tz(t,c,e),d=qS(c.field,h,e);d!==void 0&&(r[c.field.jsonName]=d)}}}catch(s){const a=i?"cannot encode field ".concat(n.typeName,".").concat(i.name," to JSON"):"cannot encode message ".concat(n.typeName," to JSON"),c=s instanceof Error?s.message:String(s);throw new Error(a+(c.length>0?": ".concat(c):""))}return r},readScalar(t,e,n){return Hu(t,e,n??oo.BIGINT,!0)},writeScalar(t,e,n){if(e!==void 0&&(n||p2(t,e)))return yf(t,e)},debug:ys}}function ys(t){if(t===null)return"null";switch(typeof t){case"object":return Array.isArray(t)?"array":"object";case"string":return t.length>100?"string":'"'.concat(t.split('"').join('\\"'),'"');default:return String(t)}}function HS(t,e,n,r,i){let s=n.localName;if(n.repeated){if(Bn(n.kind!="map"),e===null)return;if(!Array.isArray(e))throw new Error("cannot decode field ".concat(i.typeName,".").concat(n.name," from JSON: ").concat(ys(e)));const a=t[s];for(const c of e){if(c===null)throw new Error("cannot decode field ".concat(i.typeName,".").concat(n.name," from JSON: ").concat(ys(c)));switch(n.kind){case"message":a.push(n.T.fromJson(c,r));break;case"enum":const h=f0(n.T,c,r.ignoreUnknownFields,!0);h!==vf&&a.push(h);break;case"scalar":try{a.push(Hu(n.T,c,n.L,!0))}catch(d){let f="cannot decode field ".concat(i.typeName,".").concat(n.name," from JSON: ").concat(ys(c));throw d instanceof Error&&d.message.length>0&&(f+=": ".concat(d.message)),new Error(f)}break}}}else if(n.kind=="map"){if(e===null)return;if(typeof e!="object"||Array.isArray(e))throw new Error("cannot decode field ".concat(i.typeName,".").concat(n.name," from JSON: ").concat(ys(e)));const a=t[s];for(const[c,h]of Object.entries(e)){if(h===null)throw new Error("cannot decode field ".concat(i.typeName,".").concat(n.name," from JSON: map value null"));let d;try{d=_z(n.K,c)}catch(f){let p="cannot decode map key for field ".concat(i.typeName,".").concat(n.name," from JSON: ").concat(ys(e));throw f instanceof Error&&f.message.length>0&&(p+=": ".concat(f.message)),new Error(p)}switch(n.V.kind){case"message":a[d]=n.V.T.fromJson(h,r);break;case"enum":const f=f0(n.V.T,h,r.ignoreUnknownFields,!0);f!==vf&&(a[d]=f);break;case"scalar":try{a[d]=Hu(n.V.T,h,oo.BIGINT,!0)}catch(p){let g="cannot decode map value for field ".concat(i.typeName,".").concat(n.name," from JSON: ").concat(ys(e));throw p instanceof Error&&p.message.length>0&&(g+=": ".concat(p.message)),new Error(g)}break}}}else switch(n.oneof&&(t=t[n.oneof.localName]={case:s},s="value"),n.kind){case"message":const a=n.T;if(e===null&&a.typeName!="google.protobuf.Value")return;let c=t[s];ua(c)?c.fromJson(e,r):(t[s]=c=a.fromJson(e,r),a.fieldWrapper&&!n.oneof&&(t[s]=a.fieldWrapper.unwrapField(c)));break;case"enum":const h=f0(n.T,e,r.ignoreUnknownFields,!1);switch(h){case zf:$S(n,t);break;case vf:break;default:t[s]=h;break}break;case"scalar":try{const d=Hu(n.T,e,n.L,!1);switch(d){case zf:$S(n,t);break;default:t[s]=d;break}}catch(d){let f="cannot decode field ".concat(i.typeName,".").concat(n.name," from JSON: ").concat(ys(e));throw d instanceof Error&&d.message.length>0&&(f+=": ".concat(d.message)),new Error(f)}break}}function _z(t,e){if(t===Ne.BOOL)switch(e){case"true":e=!0;break;case"false":e=!1;break}return Hu(t,e,oo.BIGINT,!0).toString()}function Hu(t,e,n,r){if(e===null)return r?kc(t,n):zf;switch(t){case Ne.DOUBLE:case Ne.FLOAT:if(e==="NaN")return Number.NaN;if(e==="Infinity")return Number.POSITIVE_INFINITY;if(e==="-Infinity")return Number.NEGATIVE_INFINITY;if(e===""||typeof e=="string"&&e.trim().length!==e.length||typeof e!="string"&&typeof e!="number")break;const i=Number(e);if(Number.isNaN(i)||!Number.isFinite(i))break;return t==Ne.FLOAT&&o2(i),i;case Ne.INT32:case Ne.FIXED32:case Ne.SFIXED32:case Ne.SINT32:case Ne.UINT32:let s;if(typeof e=="number"?s=e:typeof e=="string"&&e.length>0&&e.trim().length===e.length&&(s=Number(e)),s===void 0)break;return t==Ne.UINT32||t==Ne.FIXED32?kv(s):mf(s),s;case Ne.INT64:case Ne.SFIXED64:case Ne.SINT64:if(typeof e!="number"&&typeof e!="string")break;const a=In.parse(e);return n?a.toString():a;case Ne.FIXED64:case Ne.UINT64:if(typeof e!="number"&&typeof e!="string")break;const c=In.uParse(e);return n?c.toString():c;case Ne.BOOL:if(typeof e!="boolean")break;return e;case Ne.STRING:if(typeof e!="string")break;try{encodeURIComponent(e)}catch{throw new Error("invalid UTF8")}return e;case Ne.BYTES:if(e==="")return new Uint8Array(0);if(typeof e!="string")break;return g2.dec(e)}throw new Error}function f0(t,e,n,r){if(e===null)return t.typeName=="google.protobuf.NullValue"?0:r?t.values[0].no:zf;switch(typeof e){case"number":if(Number.isInteger(e))return e;break;case"string":const i=t.findName(e);if(i!==void 0)return i.no;if(n)return vf;break}throw new Error("cannot decode enum ".concat(t.typeName," from JSON: ").concat(ys(e)))}function Rz(t){return t.repeated||t.kind=="map"?!0:!(t.oneof||t.kind=="message"||t.opt||t.req)}function qS(t,e,n){if(t.kind=="map"){Bn(typeof e=="object"&&e!=null);const r={},i=Object.entries(e);switch(t.V.kind){case"scalar":for(const[a,c]of i)r[a.toString()]=yf(t.V.T,c);break;case"message":for(const[a,c]of i)r[a.toString()]=c.toJson(n);break;case"enum":const s=t.V.T;for(const[a,c]of i)r[a.toString()]=p0(s,c,n.enumAsInteger);break}return n.emitDefaultValues||i.length>0?r:void 0}if(t.repeated){Bn(Array.isArray(e));const r=[];switch(t.kind){case"scalar":for(let i=0;i<e.length;i++)r.push(yf(t.T,e[i]));break;case"enum":for(let i=0;i<e.length;i++)r.push(p0(t.T,e[i],n.enumAsInteger));break;case"message":for(let i=0;i<e.length;i++)r.push(e[i].toJson(n));break}return n.emitDefaultValues||r.length>0?r:void 0}switch(t.kind){case"scalar":return yf(t.T,e);case"enum":return p0(t.T,e,n.enumAsInteger);case"message":return b2(t.T,e).toJson(n)}}function p0(t,e,n){var r;if(Bn(typeof e=="number"),t.typeName=="google.protobuf.NullValue")return null;if(n)return e;const i=t.findNumber(e);return(r=i==null?void 0:i.name)!==null&&r!==void 0?r:e}function yf(t,e){switch(t){case Ne.INT32:case Ne.SFIXED32:case Ne.SINT32:case Ne.FIXED32:case Ne.UINT32:return Bn(typeof e=="number"),e;case Ne.FLOAT:case Ne.DOUBLE:return Bn(typeof e=="number"),Number.isNaN(e)?"NaN":e===Number.POSITIVE_INFINITY?"Infinity":e===Number.NEGATIVE_INFINITY?"-Infinity":e;case Ne.STRING:return Bn(typeof e=="string"),e;case Ne.BOOL:return Bn(typeof e=="boolean"),e;case Ne.UINT64:case Ne.FIXED64:case Ne.INT64:case Ne.SFIXED64:case Ne.SINT64:return Bn(typeof e=="bigint"||typeof e=="string"||typeof e=="number"),e.toString();case Ne.BYTES:return Bn(e instanceof Uint8Array),g2.enc(e)}}const Yl=Symbol("@bufbuild/protobuf/unknown-fields"),KS={readUnknownFields:!0,readerFactory:t=>new kz(t)},GS={writeUnknownFields:!0,writerFactory:()=>new bz};function Iz(t){return t?Object.assign(Object.assign({},KS),t):KS}function Mz(t){return t?Object.assign(Object.assign({},GS),t):GS}function Dz(){return{makeReadOptions:Iz,makeWriteOptions:Mz,listUnknownFields(t){var e;return(e=t[Yl])!==null&&e!==void 0?e:[]},discardUnknownFields(t){delete t[Yl]},writeUnknownFields(t,e){const r=t[Yl];if(r)for(const i of r)e.tag(i.no,i.wireType).raw(i.data)},onUnknownField(t,e,n,r){const i=t;Array.isArray(i[Yl])||(i[Yl]=[]),i[Yl].push({no:e,wireType:n,data:r})},readMessage(t,e,n,r,i){const s=t.getType(),a=i?e.len:e.pos+n;let c,h;for(;e.pos<a&&([c,h]=e.tag(),!(i===!0&&h==Hn.EndGroup));){const d=s.fields.find(c);if(!d){const f=e.skip(h,c);r.readUnknownFields&&this.onUnknownField(t,c,h,f);continue}YS(t,e,d,h,r)}if(i&&(h!=Hn.EndGroup||c!==n))throw new Error("invalid end group tag")},readField:YS,writeMessage(t,e,n){const r=t.getType();for(const i of r.fields.byNumber()){if(!x2(i,t)){if(i.req)throw new Error("cannot encode field ".concat(r.typeName,".").concat(i.name," to binary: required field not set"));continue}const s=i.oneof?t[i.oneof.localName].value:t[i.localName];JS(i,s,e,n)}return n.writeUnknownFields&&this.writeUnknownFields(t,e),e},writeField(t,e,n,r){e!==void 0&&JS(t,e,n,r)}}}function YS(t,e,n,r,i){let{repeated:s,localName:a}=n;switch(n.oneof&&(t=t[n.oneof.localName],t.case!=a&&delete t.value,t.case=a,a="value"),n.kind){case"scalar":case"enum":const c=n.kind=="enum"?Ne.INT32:n.T;let h=$f;if(n.kind=="scalar"&&n.L>0&&(h=Oz),s){let g=t[a];if(r==Hn.LengthDelimited&&c!=Ne.STRING&&c!=Ne.BYTES){let k=e.uint32()+e.pos;for(;e.pos<k;)g.push(h(e,c))}else g.push(h(e,c))}else t[a]=h(e,c);break;case"message":const d=n.T;s?t[a].push(xf(e,new d,i,n)):ua(t[a])?xf(e,t[a],i,n):(t[a]=xf(e,new d,i,n),d.fieldWrapper&&!n.oneof&&!n.repeated&&(t[a]=d.fieldWrapper.unwrapField(t[a])));break;case"map":let[f,p]=Az(n,e,i);t[a][f]=p;break}}function xf(t,e,n,r){const i=e.getType().runtime.bin,s=r==null?void 0:r.delimited;return i.readMessage(e,t,s?r.no:t.uint32(),n,s),e}function Az(t,e,n){const r=e.uint32(),i=e.pos+r;let s,a;for(;e.pos<i;){const[c]=e.tag();switch(c){case 1:s=$f(e,t.K);break;case 2:switch(t.V.kind){case"scalar":a=$f(e,t.V.T);break;case"enum":a=e.int32();break;case"message":a=xf(e,new t.V.T,n,void 0);break}break}}if(s===void 0&&(s=kc(t.K,oo.BIGINT)),typeof s!="string"&&typeof s!="number"&&(s=s.toString()),a===void 0)switch(t.V.kind){case"scalar":a=kc(t.V.T,oo.BIGINT);break;case"enum":a=t.V.T.values[0].no;break;case"message":a=new t.V.T;break}return[s,a]}function Oz(t,e){const n=$f(t,e);return typeof n=="bigint"?n.toString():n}function $f(t,e){switch(e){case Ne.STRING:return t.string();case Ne.BOOL:return t.bool();case Ne.DOUBLE:return t.double();case Ne.FLOAT:return t.float();case Ne.INT32:return t.int32();case Ne.INT64:return t.int64();case Ne.UINT64:return t.uint64();case Ne.FIXED64:return t.fixed64();case Ne.BYTES:return t.bytes();case Ne.FIXED32:return t.fixed32();case Ne.SFIXED32:return t.sfixed32();case Ne.SFIXED64:return t.sfixed64();case Ne.SINT64:return t.sint64();case Ne.UINT32:return t.uint32();case Ne.SINT32:return t.sint32()}}function JS(t,e,n,r){Bn(e!==void 0);const i=t.repeated;switch(t.kind){case"scalar":case"enum":let s=t.kind=="enum"?Ne.INT32:t.T;if(i)if(Bn(Array.isArray(e)),t.packed)Fz(n,s,t.no,e);else for(const a of e)qu(n,s,t.no,a);else qu(n,s,t.no,e);break;case"message":if(i){Bn(Array.isArray(e));for(const a of e)XS(n,r,t,a)}else XS(n,r,t,e);break;case"map":Bn(typeof e=="object"&&e!=null);for(const[a,c]of Object.entries(e))Lz(n,r,t,a,c);break}}function Lz(t,e,n,r,i){t.tag(n.no,Hn.LengthDelimited),t.fork();let s=r;switch(n.K){case Ne.INT32:case Ne.FIXED32:case Ne.UINT32:case Ne.SFIXED32:case Ne.SINT32:s=Number.parseInt(r);break;case Ne.BOOL:Bn(r=="true"||r=="false"),s=r=="true";break}switch(qu(t,n.K,1,s),n.V.kind){case"scalar":qu(t,n.V.T,2,i);break;case"enum":qu(t,Ne.INT32,2,i);break;case"message":Bn(i!==void 0),t.tag(2,Hn.LengthDelimited).bytes(i.toBinary(e));break}t.join()}function XS(t,e,n,r){const i=b2(n.T,r);n.delimited?t.tag(n.no,Hn.StartGroup).raw(i.toBinary(e)).tag(n.no,Hn.EndGroup):t.tag(n.no,Hn.LengthDelimited).bytes(i.toBinary(e))}function qu(t,e,n,r){Bn(r!==void 0);let[i,s]=k2(e);t.tag(n,i)[s](r)}function Fz(t,e,n,r){if(!r.length)return;t.tag(n,Hn.LengthDelimited).fork();let[,i]=k2(e);for(let s=0;s<r.length;s++)t[i](r[s]);t.join()}function k2(t){let e=Hn.Varint;switch(t){case Ne.BYTES:case Ne.STRING:e=Hn.LengthDelimited;break;case Ne.DOUBLE:case Ne.FIXED64:case Ne.SFIXED64:e=Hn.Bit64;break;case Ne.FIXED32:case Ne.SFIXED32:case Ne.FLOAT:e=Hn.Bit32;break}const n=Ne[t].toLowerCase();return[e,n]}function Uz(){return{setEnumType:c2,initPartial(t,e){if(t===void 0)return;const n=e.getType();for(const r of n.fields.byMember()){const i=r.localName,s=e,a=t;if(a[i]!=null)switch(r.kind){case"oneof":const c=a[i].case;if(c===void 0)continue;const h=r.findField(c);let d=a[i].value;h&&h.kind=="message"&&!ua(d,h.T)?d=new h.T(d):h&&h.kind==="scalar"&&h.T===Ne.BYTES&&(d=Tu(d)),s[i]={case:c,value:d};break;case"scalar":case"enum":let f=a[i];r.T===Ne.BYTES&&(f=r.repeated?f.map(Tu):Tu(f)),s[i]=f;break;case"map":switch(r.V.kind){case"scalar":case"enum":if(r.V.T===Ne.BYTES)for(const[v,k]of Object.entries(a[i]))s[i][v]=Tu(k);else Object.assign(s[i],a[i]);break;case"message":const g=r.V.T;for(const v of Object.keys(a[i])){let k=a[i][v];g.fieldWrapper||(k=new g(k)),s[i][v]=k}break}break;case"message":const p=r.T;if(r.repeated)s[i]=a[i].map(g=>ua(g,p)?g:new p(g));else{const g=a[i];p.fieldWrapper?p.typeName==="google.protobuf.BytesValue"?s[i]=Tu(g):s[i]=g:s[i]=ua(g,p)?g:new p(g)}break}}},equals(t,e,n){return e===n?!0:!e||!n?!1:t.fields.byMember().every(r=>{const i=e[r.localName],s=n[r.localName];if(r.repeated){if(i.length!==s.length)return!1;switch(r.kind){case"message":return i.every((a,c)=>r.T.equals(a,s[c]));case"scalar":return i.every((a,c)=>Va(r.T,a,s[c]));case"enum":return i.every((a,c)=>Va(Ne.INT32,a,s[c]))}throw new Error("repeated cannot contain ".concat(r.kind))}switch(r.kind){case"message":let a=i,c=s;return r.T.fieldWrapper&&(a!==void 0&&!ua(a)&&(a=r.T.fieldWrapper.wrapField(a)),c!==void 0&&!ua(c)&&(c=r.T.fieldWrapper.wrapField(c))),r.T.equals(a,c);case"enum":return Va(Ne.INT32,i,s);case"scalar":return Va(r.T,i,s);case"oneof":if(i.case!==s.case)return!1;const h=r.findField(i.case);if(h===void 0)return!0;switch(h.kind){case"message":return h.T.equals(i.value,s.value);case"enum":return Va(Ne.INT32,i.value,s.value);case"scalar":return Va(h.T,i.value,s.value)}throw new Error("oneof cannot contain ".concat(h.kind));case"map":const d=Object.keys(i).concat(Object.keys(s));switch(r.V.kind){case"message":const f=r.V.T;return d.every(g=>f.equals(i[g],s[g]));case"enum":return d.every(g=>Va(Ne.INT32,i[g],s[g]));case"scalar":const p=r.V.T;return d.every(g=>Va(p,i[g],s[g]))}break}})},clone(t){const e=t.getType(),n=new e,r=n;for(const i of e.fields.byMember()){const s=t[i.localName];let a;if(i.repeated)a=s.map(Qh);else if(i.kind=="map"){a=r[i.localName];for(const[c,h]of Object.entries(s))a[c]=Qh(h)}else i.kind=="oneof"?a=i.findField(s.case)?{case:s.case,value:Qh(s.value)}:{case:void 0}:a=Qh(s);r[i.localName]=a}for(const i of e.runtime.bin.listUnknownFields(t))e.runtime.bin.onUnknownField(r,i.no,i.wireType,i.data);return n}}}function Qh(t){if(t===void 0)return t;if(ua(t))return t.clone();if(t instanceof Uint8Array){const e=new Uint8Array(t.byteLength);return e.set(t),e}return t}function Tu(t){return t instanceof Uint8Array?t:new Uint8Array(t)}function Bz(t,e,n){return{syntax:t,json:Pz(),bin:Dz(),util:Object.assign(Object.assign({},Uz()),{newFieldList:e,initFields:n}),makeMessageType(r,i,s){return pz(this,r,i,s)},makeEnum:fz,makeEnumType:u2,getEnumType:hz,makeExtension(r,i,s){return wz(this,r,i,s)}}}class zz{constructor(e,n){this._fields=e,this._normalizer=n}findJsonName(e){if(!this.jsonNames){const n={};for(const r of this.list())n[r.jsonName]=n[r.name]=r;this.jsonNames=n}return this.jsonNames[e]}find(e){if(!this.numbers){const n={};for(const r of this.list())n[r.no]=r;this.numbers=n}return this.numbers[e]}list(){return this.all||(this.all=this._normalizer(this._fields)),this.all}byNumber(){return this.numbersAsc||(this.numbersAsc=this.list().concat().sort((e,n)=>e.no-n.no)),this.numbersAsc}byMember(){if(!this.members){this.members=[];const e=this.members;let n;for(const r of this.list())r.oneof?r.oneof!==n&&(n=r.oneof,e.push(n)):e.push(r)}return this.members}}function w2(t,e){const n=S2(t);return e?n:Kz(qz(n))}function $z(t){return w2(t,!1)}const Vz=S2;function S2(t){let e=!1;const n=[];for(let r=0;r<t.length;r++){let i=t.charAt(r);switch(i){case"_":e=!0;break;case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":n.push(i),e=!1;break;default:e&&(e=!1,i=i.toUpperCase()),n.push(i);break}}return n.join("")}const Wz=new Set(["constructor","toString","toJSON","valueOf"]),Hz=new Set(["getType","clone","equals","fromBinary","fromJson","fromJsonString","toBinary","toJson","toJsonString","toObject"]),C2=t=>"".concat(t,"$"),qz=t=>Hz.has(t)?C2(t):t,Kz=t=>Wz.has(t)?C2(t):t;class Gz{constructor(e){this.kind="oneof",this.repeated=!1,this.packed=!1,this.opt=!1,this.req=!1,this.default=void 0,this.fields=[],this.name=e,this.localName=$z(e)}addField(e){Bn(e.oneof===this,"field ".concat(e.name," not one of ").concat(this.name)),this.fields.push(e)}findField(e){if(!this._lookup){this._lookup=Object.create(null);for(let n=0;n<this.fields.length;n++)this._lookup[this.fields[n].localName]=this.fields[n]}return this._lookup[e]}}function Yz(t,e){var n,r,i,s,a,c;const h=[];let d;for(const f of typeof t=="function"?t():t){const p=f;if(p.localName=w2(f.name,f.oneof!==void 0),p.jsonName=(n=f.jsonName)!==null&&n!==void 0?n:Vz(f.name),p.repeated=(r=f.repeated)!==null&&r!==void 0?r:!1,f.kind=="scalar"&&(p.L=(i=f.L)!==null&&i!==void 0?i:oo.BIGINT),p.delimited=(s=f.delimited)!==null&&s!==void 0?s:!1,p.req=(a=f.req)!==null&&a!==void 0?a:!1,p.opt=(c=f.opt)!==null&&c!==void 0?c:!1,f.packed===void 0&&(p.packed=f.kind=="enum"||f.kind=="scalar"&&f.T!=Ne.BYTES&&f.T!=Ne.STRING),f.oneof!==void 0){const g=typeof f.oneof=="string"?f.oneof:f.oneof.name;(!d||d.name!=g)&&(d=new Gz(g)),p.oneof=d,d.addField(p)}h.push(p)}return h}const ae=Bz("proto3",t=>new zz(t,e=>Yz(e)),t=>{for(const e of t.getType().fields.byMember()){if(e.opt)continue;const n=e.localName,r=t;if(e.repeated){r[n]=[];continue}switch(e.kind){case"oneof":r[n]={case:void 0};break;case"enum":r[n]=0;break;case"map":r[n]={};break;case"scalar":r[n]=kc(e.T,e.L);break}}});class Kr extends ix{constructor(e){super(),this.seconds=In.zero,this.nanos=0,ae.util.initPartial(e,this)}fromJson(e,n){if(typeof e!="string")throw new Error("cannot decode google.protobuf.Timestamp from JSON: ".concat(ae.json.debug(e)));const r=e.match(/^([0-9]{4})-([0-9]{2})-([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})(?:Z|\.([0-9]{3,9})Z|([+-][0-9][0-9]:[0-9][0-9]))$/);if(!r)throw new Error("cannot decode google.protobuf.Timestamp from JSON: invalid RFC 3339 string");const i=Date.parse(r[1]+"-"+r[2]+"-"+r[3]+"T"+r[4]+":"+r[5]+":"+r[6]+(r[8]?r[8]:"Z"));if(Number.isNaN(i))throw new Error("cannot decode google.protobuf.Timestamp from JSON: invalid RFC 3339 string");if(i<Date.parse("0001-01-01T00:00:00Z")||i>Date.parse("9999-12-31T23:59:59Z"))throw new Error("cannot decode message google.protobuf.Timestamp from JSON: must be from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z inclusive");return this.seconds=In.parse(i/1e3),this.nanos=0,r[7]&&(this.nanos=parseInt("1"+r[7]+"0".repeat(9-r[7].length))-1e9),this}toJson(e){const n=Number(this.seconds)*1e3;if(n<Date.parse("0001-01-01T00:00:00Z")||n>Date.parse("9999-12-31T23:59:59Z"))throw new Error("cannot encode google.protobuf.Timestamp to JSON: must be from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z inclusive");if(this.nanos<0)throw new Error("cannot encode google.protobuf.Timestamp to JSON: nanos must not be negative");let r="Z";if(this.nanos>0){const i=(this.nanos+1e9).toString().substring(1);i.substring(3)==="000000"?r="."+i.substring(0,3)+"Z":i.substring(6)==="000"?r="."+i.substring(0,6)+"Z":r="."+i+"Z"}return new Date(n).toISOString().replace(".000Z",r)}toDate(){return new Date(Number(this.seconds)*1e3+Math.ceil(this.nanos/1e6))}static now(){return Kr.fromDate(new Date)}static fromDate(e){const n=e.getTime();return new Kr({seconds:In.parse(Math.floor(n/1e3)),nanos:n%1e3*1e6})}static fromBinary(e,n){return new Kr().fromBinary(e,n)}static fromJson(e,n){return new Kr().fromJson(e,n)}static fromJsonString(e,n){return new Kr().fromJsonString(e,n)}static equals(e,n){return ae.util.equals(Kr,e,n)}}Kr.runtime=ae;Kr.typeName="google.protobuf.Timestamp";Kr.fields=ae.util.newFieldList(()=>[{no:1,name:"seconds",kind:"scalar",T:3},{no:2,name:"nanos",kind:"scalar",T:5}]);const Jz=ae.makeMessageType("livekit.MetricsBatch",()=>[{no:1,name:"timestamp_ms",kind:"scalar",T:3},{no:2,name:"normalized_timestamp",kind:"message",T:Kr},{no:3,name:"str_data",kind:"scalar",T:9,repeated:!0},{no:4,name:"time_series",kind:"message",T:Xz,repeated:!0},{no:5,name:"events",kind:"message",T:Zz,repeated:!0}]),Xz=ae.makeMessageType("livekit.TimeSeriesMetric",()=>[{no:1,name:"label",kind:"scalar",T:13},{no:2,name:"participant_identity",kind:"scalar",T:13},{no:3,name:"track_sid",kind:"scalar",T:13},{no:4,name:"samples",kind:"message",T:Qz,repeated:!0},{no:5,name:"rid",kind:"scalar",T:13}]),Qz=ae.makeMessageType("livekit.MetricSample",()=>[{no:1,name:"timestamp_ms",kind:"scalar",T:3},{no:2,name:"normalized_timestamp",kind:"message",T:Kr},{no:3,name:"value",kind:"scalar",T:2}]),Zz=ae.makeMessageType("livekit.EventMetric",()=>[{no:1,name:"label",kind:"scalar",T:13},{no:2,name:"participant_identity",kind:"scalar",T:13},{no:3,name:"track_sid",kind:"scalar",T:13},{no:4,name:"start_timestamp_ms",kind:"scalar",T:3},{no:5,name:"end_timestamp_ms",kind:"scalar",T:3,opt:!0},{no:6,name:"normalized_start_timestamp",kind:"message",T:Kr},{no:7,name:"normalized_end_timestamp",kind:"message",T:Kr,opt:!0},{no:8,name:"metadata",kind:"scalar",T:9},{no:9,name:"rid",kind:"scalar",T:13}]),T2=ae.makeEnum("livekit.BackupCodecPolicy",[{no:0,name:"PREFER_REGRESSION"},{no:1,name:"SIMULCAST"},{no:2,name:"REGRESSION"}]),Ki=ae.makeEnum("livekit.TrackType",[{no:0,name:"AUDIO"},{no:1,name:"VIDEO"},{no:2,name:"DATA"}]),Xn=ae.makeEnum("livekit.TrackSource",[{no:0,name:"UNKNOWN"},{no:1,name:"CAMERA"},{no:2,name:"MICROPHONE"},{no:3,name:"SCREEN_SHARE"},{no:4,name:"SCREEN_SHARE_AUDIO"}]),ax=ae.makeEnum("livekit.VideoQuality",[{no:0,name:"LOW"},{no:1,name:"MEDIUM"},{no:2,name:"HIGH"},{no:3,name:"OFF"}]),Lu=ae.makeEnum("livekit.ConnectionQuality",[{no:0,name:"POOR"},{no:1,name:"GOOD"},{no:2,name:"EXCELLENT"},{no:3,name:"LOST"}]),od=ae.makeEnum("livekit.ClientConfigSetting",[{no:0,name:"UNSET"},{no:1,name:"DISABLED"},{no:2,name:"ENABLED"}]),ts=ae.makeEnum("livekit.DisconnectReason",[{no:0,name:"UNKNOWN_REASON"},{no:1,name:"CLIENT_INITIATED"},{no:2,name:"DUPLICATE_IDENTITY"},{no:3,name:"SERVER_SHUTDOWN"},{no:4,name:"PARTICIPANT_REMOVED"},{no:5,name:"ROOM_DELETED"},{no:6,name:"STATE_MISMATCH"},{no:7,name:"JOIN_FAILURE"},{no:8,name:"MIGRATION"},{no:9,name:"SIGNAL_CLOSE"},{no:10,name:"ROOM_CLOSED"},{no:11,name:"USER_UNAVAILABLE"},{no:12,name:"USER_REJECTED"},{no:13,name:"SIP_TRUNK_FAILURE"},{no:14,name:"CONNECTION_TIMEOUT"},{no:15,name:"MEDIA_FAILURE"},{no:16,name:"AGENT_ERROR"}]),zo=ae.makeEnum("livekit.ReconnectReason",[{no:0,name:"RR_UNKNOWN"},{no:1,name:"RR_SIGNAL_DISCONNECTED"},{no:2,name:"RR_PUBLISHER_FAILED"},{no:3,name:"RR_SUBSCRIBER_FAILED"},{no:4,name:"RR_SWITCH_CANDIDATE"}]),e$=ae.makeEnum("livekit.SubscriptionError",[{no:0,name:"SE_UNKNOWN"},{no:1,name:"SE_CODEC_UNSUPPORTED"},{no:2,name:"SE_TRACK_NOTFOUND"}]),lr=ae.makeEnum("livekit.AudioTrackFeature",[{no:0,name:"TF_STEREO"},{no:1,name:"TF_NO_DTX"},{no:2,name:"TF_AUTO_GAIN_CONTROL"},{no:3,name:"TF_ECHO_CANCELLATION"},{no:4,name:"TF_NOISE_SUPPRESSION"},{no:5,name:"TF_ENHANCED_NOISE_CANCELLATION"},{no:6,name:"TF_PRECONNECT_BUFFER"}]),N2=ae.makeEnum("livekit.PacketTrailerFeature",[{no:0,name:"PTF_USER_TIMESTAMP"},{no:1,name:"PTF_FRAME_ID"}]),Tp=ae.makeMessageType("livekit.Room",()=>[{no:1,name:"sid",kind:"scalar",T:9},{no:2,name:"name",kind:"scalar",T:9},{no:3,name:"empty_timeout",kind:"scalar",T:13},{no:14,name:"departure_timeout",kind:"scalar",T:13},{no:4,name:"max_participants",kind:"scalar",T:13},{no:5,name:"creation_time",kind:"scalar",T:3},{no:15,name:"creation_time_ms",kind:"scalar",T:3},{no:6,name:"turn_password",kind:"scalar",T:9},{no:7,name:"enabled_codecs",kind:"message",T:Vf,repeated:!0},{no:8,name:"metadata",kind:"scalar",T:9},{no:9,name:"num_participants",kind:"scalar",T:13},{no:11,name:"num_publishers",kind:"scalar",T:13},{no:10,name:"active_recording",kind:"scalar",T:8},{no:13,name:"version",kind:"message",T:U2}]),Vf=ae.makeMessageType("livekit.Codec",()=>[{no:1,name:"mime",kind:"scalar",T:9},{no:2,name:"fmtp_line",kind:"scalar",T:9}]),t$=ae.makeMessageType("livekit.ParticipantPermission",()=>[{no:1,name:"can_subscribe",kind:"scalar",T:8},{no:2,name:"can_publish",kind:"scalar",T:8},{no:3,name:"can_publish_data",kind:"scalar",T:8},{no:9,name:"can_publish_sources",kind:"enum",T:ae.getEnumType(Xn),repeated:!0},{no:7,name:"hidden",kind:"scalar",T:8},{no:8,name:"recorder",kind:"scalar",T:8},{no:10,name:"can_update_metadata",kind:"scalar",T:8},{no:11,name:"agent",kind:"scalar",T:8},{no:12,name:"can_subscribe_metrics",kind:"scalar",T:8},{no:13,name:"can_manage_agent_session",kind:"scalar",T:8}]),ul=ae.makeMessageType("livekit.ParticipantInfo",()=>[{no:1,name:"sid",kind:"scalar",T:9},{no:2,name:"identity",kind:"scalar",T:9},{no:3,name:"state",kind:"enum",T:ae.getEnumType(cc)},{no:4,name:"tracks",kind:"message",T:nc,repeated:!0},{no:5,name:"metadata",kind:"scalar",T:9},{no:6,name:"joined_at",kind:"scalar",T:3},{no:17,name:"joined_at_ms",kind:"scalar",T:3},{no:9,name:"name",kind:"scalar",T:9},{no:10,name:"version",kind:"scalar",T:13},{no:11,name:"permission",kind:"message",T:t$},{no:12,name:"region",kind:"scalar",T:9},{no:13,name:"is_publisher",kind:"scalar",T:8},{no:14,name:"kind",kind:"enum",T:ae.getEnumType(ld)},{no:15,name:"attributes",kind:"map",K:9,V:{kind:"scalar",T:9}},{no:16,name:"disconnect_reason",kind:"enum",T:ae.getEnumType(ts)},{no:18,name:"kind_details",kind:"enum",T:ae.getEnumType(n$),repeated:!0},{no:19,name:"data_tracks",kind:"message",T:Np,repeated:!0},{no:20,name:"client_protocol",kind:"scalar",T:5}]),cc=ae.makeEnum("livekit.ParticipantInfo.State",[{no:0,name:"JOINING"},{no:1,name:"JOINED"},{no:2,name:"ACTIVE"},{no:3,name:"DISCONNECTED"}]),ld=ae.makeEnum("livekit.ParticipantInfo.Kind",[{no:0,name:"STANDARD"},{no:1,name:"INGRESS"},{no:2,name:"EGRESS"},{no:3,name:"SIP"},{no:4,name:"AGENT"},{no:7,name:"CONNECTOR"},{no:8,name:"BRIDGE"}]),n$=ae.makeEnum("livekit.ParticipantInfo.KindDetail",[{no:0,name:"CLOUD_AGENT"},{no:1,name:"FORWARDED"},{no:2,name:"CONNECTOR_WHATSAPP"},{no:3,name:"CONNECTOR_TWILIO"},{no:4,name:"BRIDGE_RTSP"}]),bn=ae.makeEnum("livekit.Encryption.Type",[{no:0,name:"NONE"},{no:1,name:"GCM"},{no:2,name:"CUSTOM"}]),r$=ae.makeMessageType("livekit.SimulcastCodecInfo",()=>[{no:1,name:"mime_type",kind:"scalar",T:9},{no:2,name:"mid",kind:"scalar",T:9},{no:3,name:"cid",kind:"scalar",T:9},{no:4,name:"layers",kind:"message",T:ro,repeated:!0},{no:5,name:"video_layer_mode",kind:"enum",T:ae.getEnumType(E2)},{no:6,name:"sdp_cid",kind:"scalar",T:9}]),nc=ae.makeMessageType("livekit.TrackInfo",()=>[{no:1,name:"sid",kind:"scalar",T:9},{no:2,name:"type",kind:"enum",T:ae.getEnumType(Ki)},{no:3,name:"name",kind:"scalar",T:9},{no:4,name:"muted",kind:"scalar",T:8},{no:5,name:"width",kind:"scalar",T:13},{no:6,name:"height",kind:"scalar",T:13},{no:7,name:"simulcast",kind:"scalar",T:8},{no:8,name:"disable_dtx",kind:"scalar",T:8},{no:9,name:"source",kind:"enum",T:ae.getEnumType(Xn)},{no:10,name:"layers",kind:"message",T:ro,repeated:!0},{no:11,name:"mime_type",kind:"scalar",T:9},{no:12,name:"mid",kind:"scalar",T:9},{no:13,name:"codecs",kind:"message",T:r$,repeated:!0},{no:14,name:"stereo",kind:"scalar",T:8},{no:15,name:"disable_red",kind:"scalar",T:8},{no:16,name:"encryption",kind:"enum",T:ae.getEnumType(bn)},{no:17,name:"stream",kind:"scalar",T:9},{no:18,name:"version",kind:"message",T:U2},{no:19,name:"audio_features",kind:"enum",T:ae.getEnumType(lr),repeated:!0},{no:20,name:"backup_codec_policy",kind:"enum",T:ae.getEnumType(T2)},{no:21,name:"packet_trailer_features",kind:"enum",T:ae.getEnumType(N2),repeated:!0}]),Np=ae.makeMessageType("livekit.DataTrackInfo",()=>[{no:1,name:"pub_handle",kind:"scalar",T:13},{no:2,name:"sid",kind:"scalar",T:9},{no:3,name:"name",kind:"scalar",T:9},{no:4,name:"encryption",kind:"enum",T:ae.getEnumType(bn)}]),i$=ae.makeMessageType("livekit.DataTrackSubscriptionOptions",()=>[{no:1,name:"target_fps",kind:"scalar",T:13,opt:!0}]),ro=ae.makeMessageType("livekit.VideoLayer",()=>[{no:1,name:"quality",kind:"enum",T:ae.getEnumType(ax)},{no:2,name:"width",kind:"scalar",T:13},{no:3,name:"height",kind:"scalar",T:13},{no:4,name:"bitrate",kind:"scalar",T:13},{no:5,name:"ssrc",kind:"scalar",T:13},{no:6,name:"spatial_layer",kind:"scalar",T:5},{no:7,name:"rid",kind:"scalar",T:9},{no:8,name:"repair_ssrc",kind:"scalar",T:13}]),E2=ae.makeEnum("livekit.VideoLayer.Mode",[{no:0,name:"MODE_UNUSED"},{no:1,name:"ONE_SPATIAL_LAYER_PER_STREAM"},{no:2,name:"MULTIPLE_SPATIAL_LAYERS_PER_STREAM"},{no:3,name:"ONE_SPATIAL_LAYER_PER_STREAM_INCOMPLETE_RTCP_SR"}]),Mr=ae.makeMessageType("livekit.DataPacket",()=>[{no:1,name:"kind",kind:"enum",T:ae.getEnumType(Zo)},{no:4,name:"participant_identity",kind:"scalar",T:9},{no:5,name:"destination_identities",kind:"scalar",T:9,repeated:!0},{no:2,name:"user",kind:"message",T:ox,oneof:"value"},{no:3,name:"speaker",kind:"message",T:s$,oneof:"value"},{no:6,name:"sip_dtmf",kind:"message",T:R2,oneof:"value"},{no:7,name:"transcription",kind:"message",T:a$,oneof:"value"},{no:8,name:"metrics",kind:"message",T:Jz,oneof:"value"},{no:9,name:"chat_message",kind:"message",T:Wf,oneof:"value"},{no:10,name:"rpc_request",kind:"message",T:lx,oneof:"value"},{no:11,name:"rpc_ack",kind:"message",T:cx,oneof:"value"},{no:12,name:"rpc_response",kind:"message",T:ux,oneof:"value"},{no:13,name:"stream_header",kind:"message",T:Hf,oneof:"value"},{no:14,name:"stream_chunk",kind:"message",T:qf,oneof:"value"},{no:15,name:"stream_trailer",kind:"message",T:Kf,oneof:"value"},{no:18,name:"encrypted_packet",kind:"message",T:j2,oneof:"value"},{no:16,name:"sequence",kind:"scalar",T:13},{no:17,name:"participant_sid",kind:"scalar",T:9}]),Zo=ae.makeEnum("livekit.DataPacket.Kind",[{no:0,name:"RELIABLE"},{no:1,name:"LOSSY"}]),j2=ae.makeMessageType("livekit.EncryptedPacket",()=>[{no:1,name:"encryption_type",kind:"enum",T:ae.getEnumType(bn)},{no:2,name:"iv",kind:"scalar",T:12},{no:3,name:"key_index",kind:"scalar",T:13},{no:4,name:"encrypted_value",kind:"scalar",T:12}]),P2=ae.makeMessageType("livekit.EncryptedPacketPayload",()=>[{no:1,name:"user",kind:"message",T:ox,oneof:"value"},{no:3,name:"chat_message",kind:"message",T:Wf,oneof:"value"},{no:4,name:"rpc_request",kind:"message",T:lx,oneof:"value"},{no:5,name:"rpc_ack",kind:"message",T:cx,oneof:"value"},{no:6,name:"rpc_response",kind:"message",T:ux,oneof:"value"},{no:7,name:"stream_header",kind:"message",T:Hf,oneof:"value"},{no:8,name:"stream_chunk",kind:"message",T:qf,oneof:"value"},{no:9,name:"stream_trailer",kind:"message",T:Kf,oneof:"value"}]),s$=ae.makeMessageType("livekit.ActiveSpeakerUpdate",()=>[{no:1,name:"speakers",kind:"message",T:_2,repeated:!0}]),_2=ae.makeMessageType("livekit.SpeakerInfo",()=>[{no:1,name:"sid",kind:"scalar",T:9},{no:2,name:"level",kind:"scalar",T:2},{no:3,name:"active",kind:"scalar",T:8}]),ox=ae.makeMessageType("livekit.UserPacket",()=>[{no:1,name:"participant_sid",kind:"scalar",T:9},{no:5,name:"participant_identity",kind:"scalar",T:9},{no:2,name:"payload",kind:"scalar",T:12},{no:3,name:"destination_sids",kind:"scalar",T:9,repeated:!0},{no:6,name:"destination_identities",kind:"scalar",T:9,repeated:!0},{no:4,name:"topic",kind:"scalar",T:9,opt:!0},{no:8,name:"id",kind:"scalar",T:9,opt:!0},{no:9,name:"start_time",kind:"scalar",T:4,opt:!0},{no:10,name:"end_time",kind:"scalar",T:4,opt:!0},{no:11,name:"nonce",kind:"scalar",T:12}]),R2=ae.makeMessageType("livekit.SipDTMF",()=>[{no:3,name:"code",kind:"scalar",T:13},{no:4,name:"digit",kind:"scalar",T:9}]),a$=ae.makeMessageType("livekit.Transcription",()=>[{no:2,name:"transcribed_participant_identity",kind:"scalar",T:9},{no:3,name:"track_id",kind:"scalar",T:9},{no:4,name:"segments",kind:"message",T:o$,repeated:!0}]),o$=ae.makeMessageType("livekit.TranscriptionSegment",()=>[{no:1,name:"id",kind:"scalar",T:9},{no:2,name:"text",kind:"scalar",T:9},{no:3,name:"start_time",kind:"scalar",T:4},{no:4,name:"end_time",kind:"scalar",T:4},{no:5,name:"final",kind:"scalar",T:8},{no:6,name:"language",kind:"scalar",T:9}]),Wf=ae.makeMessageType("livekit.ChatMessage",()=>[{no:1,name:"id",kind:"scalar",T:9},{no:2,name:"timestamp",kind:"scalar",T:3},{no:3,name:"edit_timestamp",kind:"scalar",T:3,opt:!0},{no:4,name:"message",kind:"scalar",T:9},{no:5,name:"deleted",kind:"scalar",T:8},{no:6,name:"generated",kind:"scalar",T:8}]),lx=ae.makeMessageType("livekit.RpcRequest",()=>[{no:1,name:"id",kind:"scalar",T:9},{no:2,name:"method",kind:"scalar",T:9},{no:3,name:"payload",kind:"scalar",T:9},{no:4,name:"response_timeout_ms",kind:"scalar",T:13},{no:5,name:"version",kind:"scalar",T:13},{no:6,name:"compressed_payload",kind:"scalar",T:12}]),cx=ae.makeMessageType("livekit.RpcAck",()=>[{no:1,name:"request_id",kind:"scalar",T:9}]),ux=ae.makeMessageType("livekit.RpcResponse",()=>[{no:1,name:"request_id",kind:"scalar",T:9},{no:2,name:"payload",kind:"scalar",T:9,oneof:"value"},{no:3,name:"error",kind:"message",T:I2,oneof:"value"},{no:4,name:"compressed_payload",kind:"scalar",T:12,oneof:"value"}]),I2=ae.makeMessageType("livekit.RpcError",()=>[{no:1,name:"code",kind:"scalar",T:13},{no:2,name:"message",kind:"scalar",T:9},{no:3,name:"data",kind:"scalar",T:9}]),M2=ae.makeMessageType("livekit.ParticipantTracks",()=>[{no:1,name:"participant_sid",kind:"scalar",T:9},{no:2,name:"track_sids",kind:"scalar",T:9,repeated:!0}]),D2=ae.makeMessageType("livekit.ServerInfo",()=>[{no:1,name:"edition",kind:"enum",T:ae.getEnumType(A2)},{no:2,name:"version",kind:"scalar",T:9},{no:3,name:"protocol",kind:"scalar",T:5},{no:4,name:"region",kind:"scalar",T:9},{no:5,name:"node_id",kind:"scalar",T:9},{no:6,name:"debug_info",kind:"scalar",T:9},{no:7,name:"agent_protocol",kind:"scalar",T:5}]),A2=ae.makeEnum("livekit.ServerInfo.Edition",[{no:0,name:"Standard"},{no:1,name:"Cloud"}]),O2=ae.makeMessageType("livekit.ClientInfo",()=>[{no:1,name:"sdk",kind:"enum",T:ae.getEnumType(L2)},{no:2,name:"version",kind:"scalar",T:9},{no:3,name:"protocol",kind:"scalar",T:5},{no:4,name:"os",kind:"scalar",T:9},{no:5,name:"os_version",kind:"scalar",T:9},{no:6,name:"device_model",kind:"scalar",T:9},{no:7,name:"browser",kind:"scalar",T:9},{no:8,name:"browser_version",kind:"scalar",T:9},{no:9,name:"address",kind:"scalar",T:9},{no:10,name:"network",kind:"scalar",T:9},{no:11,name:"other_sdks",kind:"scalar",T:9},{no:12,name:"client_protocol",kind:"scalar",T:5}]),L2=ae.makeEnum("livekit.ClientInfo.SDK",[{no:0,name:"UNKNOWN"},{no:1,name:"JS"},{no:2,name:"SWIFT"},{no:3,name:"ANDROID"},{no:4,name:"FLUTTER"},{no:5,name:"GO"},{no:6,name:"UNITY"},{no:7,name:"REACT_NATIVE"},{no:8,name:"RUST"},{no:9,name:"PYTHON"},{no:10,name:"CPP"},{no:11,name:"UNITY_WEB"},{no:12,name:"NODE"},{no:13,name:"UNREAL"},{no:14,name:"ESP32"}]),F2=ae.makeMessageType("livekit.ClientConfiguration",()=>[{no:1,name:"video",kind:"message",T:QS},{no:2,name:"screen",kind:"message",T:QS},{no:3,name:"resume_connection",kind:"enum",T:ae.getEnumType(od)},{no:4,name:"disabled_codecs",kind:"message",T:l$},{no:5,name:"force_relay",kind:"enum",T:ae.getEnumType(od)}]),QS=ae.makeMessageType("livekit.VideoConfiguration",()=>[{no:1,name:"hardware_encoder",kind:"enum",T:ae.getEnumType(od)}]),l$=ae.makeMessageType("livekit.DisabledCodecs",()=>[{no:1,name:"codecs",kind:"message",T:Vf,repeated:!0},{no:2,name:"publish",kind:"message",T:Vf,repeated:!0}]),U2=ae.makeMessageType("livekit.TimedVersion",()=>[{no:1,name:"unix_micro",kind:"scalar",T:3},{no:2,name:"ticks",kind:"scalar",T:5}]),wv=ae.makeEnum("livekit.DataStream.OperationType",[{no:0,name:"CREATE"},{no:1,name:"UPDATE"},{no:2,name:"DELETE"},{no:3,name:"REACTION"}]),B2=ae.makeMessageType("livekit.DataStream.TextHeader",()=>[{no:1,name:"operation_type",kind:"enum",T:ae.getEnumType(wv)},{no:2,name:"version",kind:"scalar",T:5},{no:3,name:"reply_to_stream_id",kind:"scalar",T:9},{no:4,name:"attached_stream_ids",kind:"scalar",T:9,repeated:!0},{no:5,name:"generated",kind:"scalar",T:8}],{localName:"DataStream_TextHeader"}),z2=ae.makeMessageType("livekit.DataStream.ByteHeader",()=>[{no:1,name:"name",kind:"scalar",T:9}],{localName:"DataStream_ByteHeader"}),Hf=ae.makeMessageType("livekit.DataStream.Header",()=>[{no:1,name:"stream_id",kind:"scalar",T:9},{no:2,name:"timestamp",kind:"scalar",T:3},{no:3,name:"topic",kind:"scalar",T:9},{no:4,name:"mime_type",kind:"scalar",T:9},{no:5,name:"total_length",kind:"scalar",T:4,opt:!0},{no:7,name:"encryption_type",kind:"enum",T:ae.getEnumType(bn)},{no:8,name:"attributes",kind:"map",K:9,V:{kind:"scalar",T:9}},{no:9,name:"text_header",kind:"message",T:B2,oneof:"content_header"},{no:10,name:"byte_header",kind:"message",T:z2,oneof:"content_header"}],{localName:"DataStream_Header"}),qf=ae.makeMessageType("livekit.DataStream.Chunk",()=>[{no:1,name:"stream_id",kind:"scalar",T:9},{no:2,name:"chunk_index",kind:"scalar",T:4},{no:3,name:"content",kind:"scalar",T:12},{no:4,name:"version",kind:"scalar",T:5},{no:5,name:"iv",kind:"scalar",T:12,opt:!0}],{localName:"DataStream_Chunk"}),Kf=ae.makeMessageType("livekit.DataStream.Trailer",()=>[{no:1,name:"stream_id",kind:"scalar",T:9},{no:2,name:"reason",kind:"scalar",T:9},{no:3,name:"attributes",kind:"map",K:9,V:{kind:"scalar",T:9}}],{localName:"DataStream_Trailer"}),c$=ae.makeMessageType("livekit.SubscribedAudioCodec",()=>[{no:1,name:"codec",kind:"scalar",T:9},{no:2,name:"enabled",kind:"scalar",T:8}]),Gi=ae.makeEnum("livekit.SignalTarget",[{no:0,name:"PUBLISHER"},{no:1,name:"SUBSCRIBER"}]),Sv=ae.makeEnum("livekit.StreamState",[{no:0,name:"ACTIVE"},{no:1,name:"PAUSED"}]),u$=ae.makeEnum("livekit.CandidateProtocol",[{no:0,name:"UDP"},{no:1,name:"TCP"},{no:2,name:"TLS"}]),d$=ae.makeMessageType("livekit.SignalRequest",()=>[{no:1,name:"offer",kind:"message",T:lo,oneof:"message"},{no:2,name:"answer",kind:"message",T:lo,oneof:"message"},{no:3,name:"trickle",kind:"message",T:Ep,oneof:"message"},{no:4,name:"add_track",kind:"message",T:cd,oneof:"message"},{no:5,name:"mute",kind:"message",T:jp,oneof:"message"},{no:6,name:"subscription",kind:"message",T:Pp,oneof:"message"},{no:7,name:"track_setting",kind:"message",T:W2,oneof:"message"},{no:8,name:"leave",kind:"message",T:_p,oneof:"message"},{no:10,name:"update_layers",kind:"message",T:q2,oneof:"message"},{no:11,name:"subscription_permission",kind:"message",T:Y2,oneof:"message"},{no:12,name:"sync_state",kind:"message",T:yx,oneof:"message"},{no:13,name:"simulate",kind:"message",T:gs,oneof:"message"},{no:14,name:"ping",kind:"scalar",T:3,oneof:"message"},{no:15,name:"update_metadata",kind:"message",T:gx,oneof:"message"},{no:16,name:"ping_req",kind:"message",T:Q2,oneof:"message"},{no:17,name:"update_audio_track",kind:"message",T:mx,oneof:"message"},{no:18,name:"update_video_track",kind:"message",T:H2,oneof:"message"},{no:19,name:"publish_data_track_request",kind:"message",T:dx,oneof:"message"},{no:20,name:"unpublish_data_track_request",kind:"message",T:fx,oneof:"message"},{no:21,name:"update_data_subscription",kind:"message",T:$2,oneof:"message"}]),ZS=ae.makeMessageType("livekit.SignalResponse",()=>[{no:1,name:"join",kind:"message",T:m$,oneof:"message"},{no:2,name:"answer",kind:"message",T:lo,oneof:"message"},{no:3,name:"offer",kind:"message",T:lo,oneof:"message"},{no:4,name:"trickle",kind:"message",T:Ep,oneof:"message"},{no:5,name:"update",kind:"message",T:y$,oneof:"message"},{no:6,name:"track_published",kind:"message",T:px,oneof:"message"},{no:8,name:"leave",kind:"message",T:_p,oneof:"message"},{no:9,name:"mute",kind:"message",T:jp,oneof:"message"},{no:10,name:"speakers_changed",kind:"message",T:x$,oneof:"message"},{no:11,name:"room_update",kind:"message",T:b$,oneof:"message"},{no:12,name:"connection_quality",kind:"message",T:w$,oneof:"message"},{no:13,name:"stream_state_update",kind:"message",T:C$,oneof:"message"},{no:14,name:"subscribed_quality_update",kind:"message",T:N$,oneof:"message"},{no:15,name:"subscription_permission_update",kind:"message",T:j$,oneof:"message"},{no:16,name:"refresh_token",kind:"scalar",T:9,oneof:"message"},{no:17,name:"track_unpublished",kind:"message",T:v$,oneof:"message"},{no:18,name:"pong",kind:"scalar",T:3,oneof:"message"},{no:19,name:"reconnect",kind:"message",T:g$,oneof:"message"},{no:20,name:"pong_resp",kind:"message",T:_$,oneof:"message"},{no:21,name:"subscription_response",kind:"message",T:M$,oneof:"message"},{no:22,name:"request_response",kind:"message",T:D$,oneof:"message"},{no:23,name:"track_subscribed",kind:"message",T:A$,oneof:"message"},{no:24,name:"room_moved",kind:"message",T:P$,oneof:"message"},{no:25,name:"media_sections_requirement",kind:"message",T:F$,oneof:"message"},{no:26,name:"subscribed_audio_codec_update",kind:"message",T:E$,oneof:"message"},{no:27,name:"publish_data_track_response",kind:"message",T:hx,oneof:"message"},{no:28,name:"unpublish_data_track_response",kind:"message",T:h$,oneof:"message"},{no:29,name:"data_track_subscriber_handles",kind:"message",T:f$,oneof:"message"}]),Cv=ae.makeMessageType("livekit.SimulcastCodec",()=>[{no:1,name:"codec",kind:"scalar",T:9},{no:2,name:"cid",kind:"scalar",T:9},{no:4,name:"layers",kind:"message",T:ro,repeated:!0},{no:5,name:"video_layer_mode",kind:"enum",T:ae.getEnumType(E2)}]),cd=ae.makeMessageType("livekit.AddTrackRequest",()=>[{no:1,name:"cid",kind:"scalar",T:9},{no:2,name:"name",kind:"scalar",T:9},{no:3,name:"type",kind:"enum",T:ae.getEnumType(Ki)},{no:4,name:"width",kind:"scalar",T:13},{no:5,name:"height",kind:"scalar",T:13},{no:6,name:"muted",kind:"scalar",T:8},{no:7,name:"disable_dtx",kind:"scalar",T:8},{no:8,name:"source",kind:"enum",T:ae.getEnumType(Xn)},{no:9,name:"layers",kind:"message",T:ro,repeated:!0},{no:10,name:"simulcast_codecs",kind:"message",T:Cv,repeated:!0},{no:11,name:"sid",kind:"scalar",T:9},{no:12,name:"stereo",kind:"scalar",T:8},{no:13,name:"disable_red",kind:"scalar",T:8},{no:14,name:"encryption",kind:"enum",T:ae.getEnumType(bn)},{no:15,name:"stream",kind:"scalar",T:9},{no:16,name:"backup_codec_policy",kind:"enum",T:ae.getEnumType(T2)},{no:17,name:"audio_features",kind:"enum",T:ae.getEnumType(lr),repeated:!0},{no:18,name:"packet_trailer_features",kind:"enum",T:ae.getEnumType(N2),repeated:!0}]),dx=ae.makeMessageType("livekit.PublishDataTrackRequest",()=>[{no:1,name:"pub_handle",kind:"scalar",T:13},{no:2,name:"name",kind:"scalar",T:9},{no:3,name:"encryption",kind:"enum",T:ae.getEnumType(bn)}]),hx=ae.makeMessageType("livekit.PublishDataTrackResponse",()=>[{no:1,name:"info",kind:"message",T:Np}]),fx=ae.makeMessageType("livekit.UnpublishDataTrackRequest",()=>[{no:1,name:"pub_handle",kind:"scalar",T:13}]),h$=ae.makeMessageType("livekit.UnpublishDataTrackResponse",()=>[{no:1,name:"info",kind:"message",T:Np}]),f$=ae.makeMessageType("livekit.DataTrackSubscriberHandles",()=>[{no:1,name:"sub_handles",kind:"map",K:13,V:{kind:"message",T:p$}}]),p$=ae.makeMessageType("livekit.DataTrackSubscriberHandles.PublishedDataTrack",()=>[{no:1,name:"publisher_identity",kind:"scalar",T:9},{no:2,name:"publisher_sid",kind:"scalar",T:9},{no:3,name:"track_sid",kind:"scalar",T:9}],{localName:"DataTrackSubscriberHandles_PublishedDataTrack"}),Ep=ae.makeMessageType("livekit.TrickleRequest",()=>[{no:1,name:"candidateInit",kind:"scalar",T:9},{no:2,name:"target",kind:"enum",T:ae.getEnumType(Gi)},{no:3,name:"final",kind:"scalar",T:8}]),jp=ae.makeMessageType("livekit.MuteTrackRequest",()=>[{no:1,name:"sid",kind:"scalar",T:9},{no:2,name:"muted",kind:"scalar",T:8}]),m$=ae.makeMessageType("livekit.JoinResponse",()=>[{no:1,name:"room",kind:"message",T:Tp},{no:2,name:"participant",kind:"message",T:ul},{no:3,name:"other_participants",kind:"message",T:ul,repeated:!0},{no:4,name:"server_version",kind:"scalar",T:9},{no:5,name:"ice_servers",kind:"message",T:K2,repeated:!0},{no:6,name:"subscriber_primary",kind:"scalar",T:8},{no:7,name:"alternative_url",kind:"scalar",T:9},{no:8,name:"client_configuration",kind:"message",T:F2},{no:9,name:"server_region",kind:"scalar",T:9},{no:10,name:"ping_timeout",kind:"scalar",T:5},{no:11,name:"ping_interval",kind:"scalar",T:5},{no:12,name:"server_info",kind:"message",T:D2},{no:13,name:"sif_trailer",kind:"scalar",T:12},{no:14,name:"enabled_publish_codecs",kind:"message",T:Vf,repeated:!0},{no:15,name:"fast_publish",kind:"scalar",T:8}]),g$=ae.makeMessageType("livekit.ReconnectResponse",()=>[{no:1,name:"ice_servers",kind:"message",T:K2,repeated:!0},{no:2,name:"client_configuration",kind:"message",T:F2},{no:3,name:"server_info",kind:"message",T:D2},{no:4,name:"last_message_seq",kind:"scalar",T:13}]),px=ae.makeMessageType("livekit.TrackPublishedResponse",()=>[{no:1,name:"cid",kind:"scalar",T:9},{no:2,name:"track",kind:"message",T:nc}]),v$=ae.makeMessageType("livekit.TrackUnpublishedResponse",()=>[{no:1,name:"track_sid",kind:"scalar",T:9}]),lo=ae.makeMessageType("livekit.SessionDescription",()=>[{no:1,name:"type",kind:"scalar",T:9},{no:2,name:"sdp",kind:"scalar",T:9},{no:3,name:"id",kind:"scalar",T:13},{no:4,name:"mid_to_track_id",kind:"map",K:9,V:{kind:"scalar",T:9}}]),y$=ae.makeMessageType("livekit.ParticipantUpdate",()=>[{no:1,name:"participants",kind:"message",T:ul,repeated:!0}]),Pp=ae.makeMessageType("livekit.UpdateSubscription",()=>[{no:1,name:"track_sids",kind:"scalar",T:9,repeated:!0},{no:2,name:"subscribe",kind:"scalar",T:8},{no:3,name:"participant_tracks",kind:"message",T:M2,repeated:!0}]),$2=ae.makeMessageType("livekit.UpdateDataSubscription",()=>[{no:1,name:"updates",kind:"message",T:V2,repeated:!0}]),V2=ae.makeMessageType("livekit.UpdateDataSubscription.Update",()=>[{no:1,name:"track_sid",kind:"scalar",T:9},{no:2,name:"subscribe",kind:"scalar",T:8},{no:3,name:"options",kind:"message",T:i$}],{localName:"UpdateDataSubscription_Update"}),W2=ae.makeMessageType("livekit.UpdateTrackSettings",()=>[{no:1,name:"track_sids",kind:"scalar",T:9,repeated:!0},{no:3,name:"disabled",kind:"scalar",T:8},{no:4,name:"quality",kind:"enum",T:ae.getEnumType(ax)},{no:5,name:"width",kind:"scalar",T:13},{no:6,name:"height",kind:"scalar",T:13},{no:7,name:"fps",kind:"scalar",T:13},{no:8,name:"priority",kind:"scalar",T:13}]),mx=ae.makeMessageType("livekit.UpdateLocalAudioTrack",()=>[{no:1,name:"track_sid",kind:"scalar",T:9},{no:2,name:"features",kind:"enum",T:ae.getEnumType(lr),repeated:!0}]),H2=ae.makeMessageType("livekit.UpdateLocalVideoTrack",()=>[{no:1,name:"track_sid",kind:"scalar",T:9},{no:2,name:"width",kind:"scalar",T:13},{no:3,name:"height",kind:"scalar",T:13}]),_p=ae.makeMessageType("livekit.LeaveRequest",()=>[{no:1,name:"can_reconnect",kind:"scalar",T:8},{no:2,name:"reason",kind:"enum",T:ae.getEnumType(ts)},{no:3,name:"action",kind:"enum",T:ae.getEnumType(uc)},{no:4,name:"regions",kind:"message",T:R$}]),uc=ae.makeEnum("livekit.LeaveRequest.Action",[{no:0,name:"DISCONNECT"},{no:1,name:"RESUME"},{no:2,name:"RECONNECT"}]),q2=ae.makeMessageType("livekit.UpdateVideoLayers",()=>[{no:1,name:"track_sid",kind:"scalar",T:9},{no:2,name:"layers",kind:"message",T:ro,repeated:!0}]),gx=ae.makeMessageType("livekit.UpdateParticipantMetadata",()=>[{no:1,name:"metadata",kind:"scalar",T:9},{no:2,name:"name",kind:"scalar",T:9},{no:3,name:"attributes",kind:"map",K:9,V:{kind:"scalar",T:9}},{no:4,name:"request_id",kind:"scalar",T:13}]),K2=ae.makeMessageType("livekit.ICEServer",()=>[{no:1,name:"urls",kind:"scalar",T:9,repeated:!0},{no:2,name:"username",kind:"scalar",T:9},{no:3,name:"credential",kind:"scalar",T:9}]),x$=ae.makeMessageType("livekit.SpeakersChanged",()=>[{no:1,name:"speakers",kind:"message",T:_2,repeated:!0}]),b$=ae.makeMessageType("livekit.RoomUpdate",()=>[{no:1,name:"room",kind:"message",T:Tp}]),k$=ae.makeMessageType("livekit.ConnectionQualityInfo",()=>[{no:1,name:"participant_sid",kind:"scalar",T:9},{no:2,name:"quality",kind:"enum",T:ae.getEnumType(Lu)},{no:3,name:"score",kind:"scalar",T:2}]),w$=ae.makeMessageType("livekit.ConnectionQualityUpdate",()=>[{no:1,name:"updates",kind:"message",T:k$,repeated:!0}]),S$=ae.makeMessageType("livekit.StreamStateInfo",()=>[{no:1,name:"participant_sid",kind:"scalar",T:9},{no:2,name:"track_sid",kind:"scalar",T:9},{no:3,name:"state",kind:"enum",T:ae.getEnumType(Sv)}]),C$=ae.makeMessageType("livekit.StreamStateUpdate",()=>[{no:1,name:"stream_states",kind:"message",T:S$,repeated:!0}]),vx=ae.makeMessageType("livekit.SubscribedQuality",()=>[{no:1,name:"quality",kind:"enum",T:ae.getEnumType(ax)},{no:2,name:"enabled",kind:"scalar",T:8}]),T$=ae.makeMessageType("livekit.SubscribedCodec",()=>[{no:1,name:"codec",kind:"scalar",T:9},{no:2,name:"qualities",kind:"message",T:vx,repeated:!0}]),N$=ae.makeMessageType("livekit.SubscribedQualityUpdate",()=>[{no:1,name:"track_sid",kind:"scalar",T:9},{no:2,name:"subscribed_qualities",kind:"message",T:vx,repeated:!0},{no:3,name:"subscribed_codecs",kind:"message",T:T$,repeated:!0}]),E$=ae.makeMessageType("livekit.SubscribedAudioCodecUpdate",()=>[{no:1,name:"track_sid",kind:"scalar",T:9},{no:2,name:"subscribed_audio_codecs",kind:"message",T:c$,repeated:!0}]),G2=ae.makeMessageType("livekit.TrackPermission",()=>[{no:1,name:"participant_sid",kind:"scalar",T:9},{no:2,name:"all_tracks",kind:"scalar",T:8},{no:3,name:"track_sids",kind:"scalar",T:9,repeated:!0},{no:4,name:"participant_identity",kind:"scalar",T:9}]),Y2=ae.makeMessageType("livekit.SubscriptionPermission",()=>[{no:1,name:"all_participants",kind:"scalar",T:8},{no:2,name:"track_permissions",kind:"message",T:G2,repeated:!0}]),j$=ae.makeMessageType("livekit.SubscriptionPermissionUpdate",()=>[{no:1,name:"participant_sid",kind:"scalar",T:9},{no:2,name:"track_sid",kind:"scalar",T:9},{no:3,name:"allowed",kind:"scalar",T:8}]),P$=ae.makeMessageType("livekit.RoomMovedResponse",()=>[{no:1,name:"room",kind:"message",T:Tp},{no:2,name:"token",kind:"scalar",T:9},{no:3,name:"participant",kind:"message",T:ul},{no:4,name:"other_participants",kind:"message",T:ul,repeated:!0}]),yx=ae.makeMessageType("livekit.SyncState",()=>[{no:1,name:"answer",kind:"message",T:lo},{no:2,name:"subscription",kind:"message",T:Pp},{no:3,name:"publish_tracks",kind:"message",T:px,repeated:!0},{no:4,name:"data_channels",kind:"message",T:X2,repeated:!0},{no:5,name:"offer",kind:"message",T:lo},{no:6,name:"track_sids_disabled",kind:"scalar",T:9,repeated:!0},{no:7,name:"datachannel_receive_states",kind:"message",T:J2,repeated:!0},{no:8,name:"publish_data_tracks",kind:"message",T:hx,repeated:!0}]),J2=ae.makeMessageType("livekit.DataChannelReceiveState",()=>[{no:1,name:"publisher_sid",kind:"scalar",T:9},{no:2,name:"last_seq",kind:"scalar",T:13}]),X2=ae.makeMessageType("livekit.DataChannelInfo",()=>[{no:1,name:"label",kind:"scalar",T:9},{no:2,name:"id",kind:"scalar",T:13},{no:3,name:"target",kind:"enum",T:ae.getEnumType(Gi)}]),gs=ae.makeMessageType("livekit.SimulateScenario",()=>[{no:1,name:"speaker_update",kind:"scalar",T:5,oneof:"scenario"},{no:2,name:"node_failure",kind:"scalar",T:8,oneof:"scenario"},{no:3,name:"migration",kind:"scalar",T:8,oneof:"scenario"},{no:4,name:"server_leave",kind:"scalar",T:8,oneof:"scenario"},{no:5,name:"switch_candidate_protocol",kind:"enum",T:ae.getEnumType(u$),oneof:"scenario"},{no:6,name:"subscriber_bandwidth",kind:"scalar",T:3,oneof:"scenario"},{no:7,name:"disconnect_signal_on_resume",kind:"scalar",T:8,oneof:"scenario"},{no:8,name:"disconnect_signal_on_resume_no_messages",kind:"scalar",T:8,oneof:"scenario"},{no:9,name:"leave_request_full_reconnect",kind:"scalar",T:8,oneof:"scenario"}]),Q2=ae.makeMessageType("livekit.Ping",()=>[{no:1,name:"timestamp",kind:"scalar",T:3},{no:2,name:"rtt",kind:"scalar",T:3}]),_$=ae.makeMessageType("livekit.Pong",()=>[{no:1,name:"last_ping_timestamp",kind:"scalar",T:3},{no:2,name:"timestamp",kind:"scalar",T:3}]),R$=ae.makeMessageType("livekit.RegionSettings",()=>[{no:1,name:"regions",kind:"message",T:I$,repeated:!0}]),I$=ae.makeMessageType("livekit.RegionInfo",()=>[{no:1,name:"region",kind:"scalar",T:9},{no:2,name:"url",kind:"scalar",T:9},{no:3,name:"distance",kind:"scalar",T:3}]),M$=ae.makeMessageType("livekit.SubscriptionResponse",()=>[{no:1,name:"track_sid",kind:"scalar",T:9},{no:2,name:"err",kind:"enum",T:ae.getEnumType(e$)}]),D$=ae.makeMessageType("livekit.RequestResponse",()=>[{no:1,name:"request_id",kind:"scalar",T:13},{no:2,name:"reason",kind:"enum",T:ae.getEnumType(Ho)},{no:3,name:"message",kind:"scalar",T:9},{no:4,name:"trickle",kind:"message",T:Ep,oneof:"request"},{no:5,name:"add_track",kind:"message",T:cd,oneof:"request"},{no:6,name:"mute",kind:"message",T:jp,oneof:"request"},{no:7,name:"update_metadata",kind:"message",T:gx,oneof:"request"},{no:8,name:"update_audio_track",kind:"message",T:mx,oneof:"request"},{no:9,name:"update_video_track",kind:"message",T:H2,oneof:"request"},{no:10,name:"publish_data_track",kind:"message",T:dx,oneof:"request"},{no:11,name:"unpublish_data_track",kind:"message",T:fx,oneof:"request"}]),Ho=ae.makeEnum("livekit.RequestResponse.Reason",[{no:0,name:"OK"},{no:1,name:"NOT_FOUND"},{no:2,name:"NOT_ALLOWED"},{no:3,name:"LIMIT_EXCEEDED"},{no:4,name:"QUEUED"},{no:5,name:"UNSUPPORTED_TYPE"},{no:6,name:"UNCLASSIFIED_ERROR"},{no:7,name:"INVALID_HANDLE"},{no:8,name:"INVALID_NAME"},{no:9,name:"DUPLICATE_HANDLE"},{no:10,name:"DUPLICATE_NAME"}]),A$=ae.makeMessageType("livekit.TrackSubscribed",()=>[{no:1,name:"track_sid",kind:"scalar",T:9}]),Z2=ae.makeMessageType("livekit.ConnectionSettings",()=>[{no:1,name:"auto_subscribe",kind:"scalar",T:8},{no:2,name:"adaptive_stream",kind:"scalar",T:8},{no:3,name:"subscriber_allow_pause",kind:"scalar",T:8,opt:!0},{no:4,name:"disable_ice_lite",kind:"scalar",T:8},{no:5,name:"auto_subscribe_data_track",kind:"scalar",T:8,opt:!0}]),O$=ae.makeMessageType("livekit.JoinRequest",()=>[{no:1,name:"client_info",kind:"message",T:O2},{no:2,name:"connection_settings",kind:"message",T:Z2},{no:3,name:"metadata",kind:"scalar",T:9},{no:4,name:"participant_attributes",kind:"map",K:9,V:{kind:"scalar",T:9}},{no:5,name:"add_track_requests",kind:"message",T:cd,repeated:!0},{no:6,name:"publisher_offer",kind:"message",T:lo},{no:7,name:"reconnect",kind:"scalar",T:8},{no:8,name:"reconnect_reason",kind:"enum",T:ae.getEnumType(zo)},{no:9,name:"participant_sid",kind:"scalar",T:9},{no:10,name:"sync_state",kind:"message",T:yx}]),L$=ae.makeMessageType("livekit.WrappedJoinRequest",()=>[{no:1,name:"compression",kind:"enum",T:ae.getEnumType(Tv)},{no:2,name:"join_request",kind:"scalar",T:12}]),Tv=ae.makeEnum("livekit.WrappedJoinRequest.Compression",[{no:0,name:"NONE"},{no:1,name:"GZIP"}]),F$=ae.makeMessageType("livekit.MediaSectionsRequirement",()=>[{no:1,name:"num_audios",kind:"scalar",T:13},{no:2,name:"num_videos",kind:"scalar",T:13}]);function U$(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var bf={exports:{}},B$=bf.exports,eC;function z$(){return eC||(eC=1,(function(t){(function(e,n){t.exports?t.exports=n():e.log=n()})(B$,function(){var e=function(){},n="undefined",r=typeof window!==n&&typeof window.navigator!==n&&/Trident\/|MSIE /.test(window.navigator.userAgent),i=["trace","debug","info","warn","error"],s={},a=null;function c(w,S){var T=w[S];if(typeof T.bind=="function")return T.bind(w);try{return Function.prototype.bind.call(T,w)}catch{return function(){return Function.prototype.apply.apply(T,[w,arguments])}}}function h(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function d(w){return w==="debug"&&(w="log"),typeof console===n?!1:w==="trace"&&r?h:console[w]!==void 0?c(console,w):console.log!==void 0?c(console,"log"):e}function f(){for(var w=this.getLevel(),S=0;S<i.length;S++){var T=i[S];this[T]=S<w?e:this.methodFactory(T,w,this.name)}if(this.log=this.debug,typeof console===n&&w<this.levels.SILENT)return"No console available for logging"}function p(w){return function(){typeof console!==n&&(f.call(this),this[w].apply(this,arguments))}}function g(w,S,T){return d(w)||p.apply(this,arguments)}function v(w,S){var T=this,C,j,R,_="loglevel";typeof w=="string"?_+=":"+w:typeof w=="symbol"&&(_=void 0);function I(P){var V=(i[P]||"silent").toUpperCase();if(!(typeof window===n||!_)){try{window.localStorage[_]=V;return}catch{}try{window.document.cookie=encodeURIComponent(_)+"="+V+";"}catch{}}}function M(){var P;if(!(typeof window===n||!_)){try{P=window.localStorage[_]}catch{}if(typeof P===n)try{var V=window.document.cookie,F=encodeURIComponent(_),K=V.indexOf(F+"=");K!==-1&&(P=/^([^;]+)/.exec(V.slice(K+F.length+1))[1])}catch{}return T.levels[P]===void 0&&(P=void 0),P}}function L(){if(!(typeof window===n||!_)){try{window.localStorage.removeItem(_)}catch{}try{window.document.cookie=encodeURIComponent(_)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}}function $(P){var V=P;if(typeof V=="string"&&T.levels[V.toUpperCase()]!==void 0&&(V=T.levels[V.toUpperCase()]),typeof V=="number"&&V>=0&&V<=T.levels.SILENT)return V;throw new TypeError("log.setLevel() called with invalid level: "+P)}T.name=w,T.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},T.methodFactory=S||g,T.getLevel=function(){return R??j??C},T.setLevel=function(P,V){return R=$(P),V!==!1&&I(R),f.call(T)},T.setDefaultLevel=function(P){j=$(P),M()||T.setLevel(P,!1)},T.resetLevel=function(){R=null,L(),f.call(T)},T.enableAll=function(P){T.setLevel(T.levels.TRACE,P)},T.disableAll=function(P){T.setLevel(T.levels.SILENT,P)},T.rebuild=function(){if(a!==T&&(C=$(a.getLevel())),f.call(T),a===T)for(var P in s)s[P].rebuild()},C=$(a?a.getLevel():"WARN");var E=M();E!=null&&(R=$(E)),f.call(T)}a=new v,a.getLogger=function(S){if(typeof S!="symbol"&&typeof S!="string"||S==="")throw new TypeError("You must supply a name when creating a logger.");var T=s[S];return T||(T=s[S]=new v(S,a.methodFactory)),T};var k=typeof window!==n?window.log:void 0;return a.noConflict=function(){return typeof window!==n&&window.log===a&&(window.log=k),a},a.getLoggers=function(){return s},a.default=a,a})})(bf)),bf.exports}var Rp=z$(),Nv;(function(t){t[t.trace=0]="trace",t[t.debug=1]="debug",t[t.info=2]="info",t[t.warn=3]="warn",t[t.error=4]="error",t[t.silent=5]="silent"})(Nv||(Nv={}));var Nr;(function(t){t.Default="livekit",t.Room="livekit-room",t.TokenSource="livekit-token-source",t.Participant="livekit-participant",t.Track="livekit-track",t.Publication="livekit-track-publication",t.Engine="livekit-engine",t.Signal="livekit-signal",t.PCManager="livekit-pc-manager",t.PCTransport="livekit-pc-transport",t.E2EE="lk-e2ee",t.DataTracks="livekit-data-tracks"})(Nr||(Nr={}));let Tt=Rp.getLogger("livekit");Object.values(Nr).map(t=>Rp.getLogger(t));Tt.setDefaultLevel(Nv.info);function ei(t){const e=Rp.getLogger(t);return e.setDefaultLevel(Tt.getLevel()),e}const $$=Rp.getLogger("lk-e2ee"),Nu=7e3,V$=[0,300,4*300,9*300,16*300,Nu,Nu,Nu,Nu,Nu];class W${constructor(e){this._retryDelays=e!==void 0?[...e]:V$}nextRetryDelayInMs(e){if(e.retryCount>=this._retryDelays.length)return null;const n=this._retryDelays[e.retryCount];return e.retryCount<=1?n:n+Math.random()*1e3}}function H$(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,r=Object.getOwnPropertySymbols(t);i<r.length;i++)e.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(t,r[i])&&(n[r[i]]=t[r[i]]);return n}function H(t,e,n,r){function i(s){return s instanceof n?s:new n(function(a){a(s)})}return new(n||(n=Promise))(function(s,a){function c(f){try{d(r.next(f))}catch(p){a(p)}}function h(f){try{d(r.throw(f))}catch(p){a(p)}}function d(f){f.done?s(f.value):i(f.value).then(c,h)}d((r=r.apply(t,e||[])).next())})}function tC(t){var e=typeof Symbol=="function"&&Symbol.iterator,n=e&&t[e],r=0;if(n)return n.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function wc(t){return this instanceof wc?(this.v=t,this):new wc(t)}function q$(t,e,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=n.apply(t,e||[]),i,s=[];return i=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),c("next"),c("throw"),c("return",a),i[Symbol.asyncIterator]=function(){return this},i;function a(v){return function(k){return Promise.resolve(k).then(v,p)}}function c(v,k){r[v]&&(i[v]=function(w){return new Promise(function(S,T){s.push([v,w,S,T])>1||h(v,w)})},k&&(i[v]=k(i[v])))}function h(v,k){try{d(r[v](k))}catch(w){g(s[0][3],w)}}function d(v){v.value instanceof wc?Promise.resolve(v.value.v).then(f,p):g(s[0][2],v)}function f(v){h("next",v)}function p(v){h("throw",v)}function g(v,k){v(k),s.shift(),s.length&&h(s[0][0],s[0][1])}}function K$(t){var e,n;return e={},r("next"),r("throw",function(i){throw i}),r("return"),e[Symbol.iterator]=function(){return this},e;function r(i,s){e[i]=t[i]?function(a){return(n=!n)?{value:wc(t[i](a)),done:!1}:s?s(a):a}:s}}function Yi(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=t[Symbol.asyncIterator],n;return e?e.call(t):(t=typeof tC=="function"?tC(t):t[Symbol.iterator](),n={},r("next"),r("throw"),r("return"),n[Symbol.asyncIterator]=function(){return this},n);function r(s){n[s]=t[s]&&function(a){return new Promise(function(c,h){a=t[s](a),i(c,h,a.done,a.value)})}}function i(s,a,c,h){Promise.resolve(h).then(function(d){s({value:d,done:c})},a)}}var Zh={exports:{}},nC;function G$(){if(nC)return Zh.exports;nC=1;var t=typeof Reflect=="object"?Reflect:null,e=t&&typeof t.apply=="function"?t.apply:function(_,I,M){return Function.prototype.apply.call(_,I,M)},n;t&&typeof t.ownKeys=="function"?n=t.ownKeys:Object.getOwnPropertySymbols?n=function(_){return Object.getOwnPropertyNames(_).concat(Object.getOwnPropertySymbols(_))}:n=function(_){return Object.getOwnPropertyNames(_)};function r(R){console&&console.warn&&console.warn(R)}var i=Number.isNaN||function(_){return _!==_};function s(){s.init.call(this)}Zh.exports=s,Zh.exports.once=T,s.EventEmitter=s,s.prototype._events=void 0,s.prototype._eventsCount=0,s.prototype._maxListeners=void 0;var a=10;function c(R){if(typeof R!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof R)}Object.defineProperty(s,"defaultMaxListeners",{enumerable:!0,get:function(){return a},set:function(R){if(typeof R!="number"||R<0||i(R))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+R+".");a=R}}),s.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},s.prototype.setMaxListeners=function(_){if(typeof _!="number"||_<0||i(_))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+_+".");return this._maxListeners=_,this};function h(R){return R._maxListeners===void 0?s.defaultMaxListeners:R._maxListeners}s.prototype.getMaxListeners=function(){return h(this)},s.prototype.emit=function(_){for(var I=[],M=1;M<arguments.length;M++)I.push(arguments[M]);var L=_==="error",$=this._events;if($!==void 0)L=L&&$.error===void 0;else if(!L)return!1;if(L){var E;if(I.length>0&&(E=I[0]),E instanceof Error)throw E;var P=new Error("Unhandled error."+(E?" ("+E.message+")":""));throw P.context=E,P}var V=$[_];if(V===void 0)return!1;if(typeof V=="function")e(V,this,I);else for(var F=V.length,K=k(V,F),M=0;M<F;++M)e(K[M],this,I);return!0};function d(R,_,I,M){var L,$,E;if(c(I),$=R._events,$===void 0?($=R._events=Object.create(null),R._eventsCount=0):($.newListener!==void 0&&(R.emit("newListener",_,I.listener?I.listener:I),$=R._events),E=$[_]),E===void 0)E=$[_]=I,++R._eventsCount;else if(typeof E=="function"?E=$[_]=M?[I,E]:[E,I]:M?E.unshift(I):E.push(I),L=h(R),L>0&&E.length>L&&!E.warned){E.warned=!0;var P=new Error("Possible EventEmitter memory leak detected. "+E.length+" "+String(_)+" listeners added. Use emitter.setMaxListeners() to increase limit");P.name="MaxListenersExceededWarning",P.emitter=R,P.type=_,P.count=E.length,r(P)}return R}s.prototype.addListener=function(_,I){return d(this,_,I,!1)},s.prototype.on=s.prototype.addListener,s.prototype.prependListener=function(_,I){return d(this,_,I,!0)};function f(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function p(R,_,I){var M={fired:!1,wrapFn:void 0,target:R,type:_,listener:I},L=f.bind(M);return L.listener=I,M.wrapFn=L,L}s.prototype.once=function(_,I){return c(I),this.on(_,p(this,_,I)),this},s.prototype.prependOnceListener=function(_,I){return c(I),this.prependListener(_,p(this,_,I)),this},s.prototype.removeListener=function(_,I){var M,L,$,E,P;if(c(I),L=this._events,L===void 0)return this;if(M=L[_],M===void 0)return this;if(M===I||M.listener===I)--this._eventsCount===0?this._events=Object.create(null):(delete L[_],L.removeListener&&this.emit("removeListener",_,M.listener||I));else if(typeof M!="function"){for($=-1,E=M.length-1;E>=0;E--)if(M[E]===I||M[E].listener===I){P=M[E].listener,$=E;break}if($<0)return this;$===0?M.shift():w(M,$),M.length===1&&(L[_]=M[0]),L.removeListener!==void 0&&this.emit("removeListener",_,P||I)}return this},s.prototype.off=s.prototype.removeListener,s.prototype.removeAllListeners=function(_){var I,M,L;if(M=this._events,M===void 0)return this;if(M.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):M[_]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete M[_]),this;if(arguments.length===0){var $=Object.keys(M),E;for(L=0;L<$.length;++L)E=$[L],E!=="removeListener"&&this.removeAllListeners(E);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(I=M[_],typeof I=="function")this.removeListener(_,I);else if(I!==void 0)for(L=I.length-1;L>=0;L--)this.removeListener(_,I[L]);return this};function g(R,_,I){var M=R._events;if(M===void 0)return[];var L=M[_];return L===void 0?[]:typeof L=="function"?I?[L.listener||L]:[L]:I?S(L):k(L,L.length)}s.prototype.listeners=function(_){return g(this,_,!0)},s.prototype.rawListeners=function(_){return g(this,_,!1)},s.listenerCount=function(R,_){return typeof R.listenerCount=="function"?R.listenerCount(_):v.call(R,_)},s.prototype.listenerCount=v;function v(R){var _=this._events;if(_!==void 0){var I=_[R];if(typeof I=="function")return 1;if(I!==void 0)return I.length}return 0}s.prototype.eventNames=function(){return this._eventsCount>0?n(this._events):[]};function k(R,_){for(var I=new Array(_),M=0;M<_;++M)I[M]=R[M];return I}function w(R,_){for(;_+1<R.length;_++)R[_]=R[_+1];R.pop()}function S(R){for(var _=new Array(R.length),I=0;I<_.length;++I)_[I]=R[I].listener||R[I];return _}function T(R,_){return new Promise(function(I,M){function L(E){R.removeListener(_,$),M(E)}function $(){typeof R.removeListener=="function"&&R.removeListener("error",L),I([].slice.call(arguments))}j(R,_,$,{once:!0}),_!=="error"&&C(R,L,{once:!0})})}function C(R,_,I){typeof R.on=="function"&&j(R,"error",_,I)}function j(R,_,I,M){if(typeof R.on=="function")M.once?R.once(_,I):R.on(_,I);else if(typeof R.addEventListener=="function")R.addEventListener(_,function L($){M.once&&R.removeEventListener(_,L),I($)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof R)}return Zh.exports}var Di=G$();let eP=!0,tP=!0;function Fu(t,e,n){const r=t.match(e);return r&&r.length>=n&&parseFloat(r[n],10)}function xl(t,e,n){if(!t.RTCPeerConnection)return;if(!Object.getOwnPropertyDescriptor(EventTarget.prototype,"addEventListener").writable){xx("Unable to polyfill events");return}const i=t.RTCPeerConnection.prototype,s=i.addEventListener;i.addEventListener=function(c,h){if(c!==e)return s.apply(this,arguments);const d=f=>{const p=n(f);p&&(h.handleEvent?h.handleEvent(p):h(p))};return this._eventMap=this._eventMap||{},this._eventMap[e]||(this._eventMap[e]=new Map),this._eventMap[e].set(h,d),s.apply(this,[c,d])};const a=i.removeEventListener;i.removeEventListener=function(c,h){if(c!==e||!this._eventMap||!this._eventMap[e])return a.apply(this,arguments);if(!this._eventMap[e].has(h))return a.apply(this,arguments);const d=this._eventMap[e].get(h);return this._eventMap[e].delete(h),this._eventMap[e].size===0&&delete this._eventMap[e],Object.keys(this._eventMap).length===0&&delete this._eventMap,a.apply(this,[c,d])},Object.defineProperty(i,"on"+e,{get(){return this["_on"+e]},set(c){this["_on"+e]&&(this.removeEventListener(e,this["_on"+e]),delete this["_on"+e]),c&&this.addEventListener(e,this["_on"+e]=c)},enumerable:!0,configurable:!0})}function Y$(t){return typeof t!="boolean"?new Error("Argument type: "+typeof t+". Please use a boolean."):(eP=t,t?"adapter.js logging disabled":"adapter.js logging enabled")}function J$(t){return typeof t!="boolean"?new Error("Argument type: "+typeof t+". Please use a boolean."):(tP=!t,"adapter.js deprecation warnings "+(t?"disabled":"enabled"))}function xx(){if(typeof window=="object"){if(eP)return;typeof console<"u"&&typeof console.log=="function"&&console.log.apply(console,arguments)}}function bx(t,e){tP&&console.warn(t+" is deprecated, please use "+e+" instead.")}function X$(t){const e={browser:null,version:null};if(typeof t>"u"||!t.navigator||!t.navigator.userAgent)return e.browser="Not a browser.",e;const{navigator:n}=t;if(n.userAgentData&&n.userAgentData.brands){const r=n.userAgentData.brands.find(i=>i.brand==="Chromium");if(r)return{browser:"chrome",version:parseInt(r.version,10)}}if(n.mozGetUserMedia)e.browser="firefox",e.version=parseInt(Fu(n.userAgent,/Firefox\/(\d+)\./,1));else if(n.webkitGetUserMedia||t.isSecureContext===!1&&t.webkitRTCPeerConnection)e.browser="chrome",e.version=parseInt(Fu(n.userAgent,/Chrom(e|ium)\/(\d+)\./,2))||null;else if(t.RTCPeerConnection&&n.userAgent.match(/AppleWebKit\/(\d+)\./))e.browser="safari",e.version=parseInt(Fu(n.userAgent,/AppleWebKit\/(\d+)\./,1)),e.supportsUnifiedPlan=t.RTCRtpTransceiver&&"currentDirection"in t.RTCRtpTransceiver.prototype,e._safariVersion=Fu(n.userAgent,/Version\/(\d+(\.?\d+))/,1);else return e.browser="Not a supported browser.",e;return e}function rC(t){return Object.prototype.toString.call(t)==="[object Object]"}function nP(t){return rC(t)?Object.keys(t).reduce(function(e,n){const r=rC(t[n]),i=r?nP(t[n]):t[n],s=r&&!Object.keys(i).length;return i===void 0||s?e:Object.assign(e,{[n]:i})},{}):t}function Ev(t,e,n){!e||n.has(e.id)||(n.set(e.id,e),Object.keys(e).forEach(r=>{r.endsWith("Id")?Ev(t,t.get(e[r]),n):r.endsWith("Ids")&&e[r].forEach(i=>{Ev(t,t.get(i),n)})}))}function iC(t,e,n){const r=n?"outbound-rtp":"inbound-rtp",i=new Map;if(e===null)return i;const s=[];return t.forEach(a=>{a.type==="track"&&a.trackIdentifier===e.id&&s.push(a)}),s.forEach(a=>{t.forEach(c=>{c.type===r&&c.trackId===a.id&&Ev(t,c,i)})}),i}const sC=xx;function rP(t,e){const n=t&&t.navigator;if(!n.mediaDevices)return;const r=function(c){if(typeof c!="object"||c.mandatory||c.optional)return c;const h={};return Object.keys(c).forEach(d=>{if(d==="require"||d==="advanced"||d==="mediaSource")return;const f=typeof c[d]=="object"?c[d]:{ideal:c[d]};f.exact!==void 0&&typeof f.exact=="number"&&(f.min=f.max=f.exact);const p=function(g,v){return g?g+v.charAt(0).toUpperCase()+v.slice(1):v==="deviceId"?"sourceId":v};if(f.ideal!==void 0){h.optional=h.optional||[];let g={};typeof f.ideal=="number"?(g[p("min",d)]=f.ideal,h.optional.push(g),g={},g[p("max",d)]=f.ideal,h.optional.push(g)):(g[p("",d)]=f.ideal,h.optional.push(g))}f.exact!==void 0&&typeof f.exact!="number"?(h.mandatory=h.mandatory||{},h.mandatory[p("",d)]=f.exact):["min","max"].forEach(g=>{f[g]!==void 0&&(h.mandatory=h.mandatory||{},h.mandatory[p(g,d)]=f[g])})}),c.advanced&&(h.optional=(h.optional||[]).concat(c.advanced)),h},i=function(c,h){if(e.version>=61)return h(c);if(c=JSON.parse(JSON.stringify(c)),c&&typeof c.audio=="object"){const d=function(f,p,g){p in f&&!(g in f)&&(f[g]=f[p],delete f[p])};c=JSON.parse(JSON.stringify(c)),d(c.audio,"autoGainControl","googAutoGainControl"),d(c.audio,"noiseSuppression","googNoiseSuppression"),c.audio=r(c.audio)}if(c&&typeof c.video=="object"){let d=c.video.facingMode;d=d&&(typeof d=="object"?d:{ideal:d});const f=e.version<66;if(d&&(d.exact==="user"||d.exact==="environment"||d.ideal==="user"||d.ideal==="environment")&&!(n.mediaDevices.getSupportedConstraints&&n.mediaDevices.getSupportedConstraints().facingMode&&!f)){delete c.video.facingMode;let p;if(d.exact==="environment"||d.ideal==="environment"?p=["back","rear"]:(d.exact==="user"||d.ideal==="user")&&(p=["front"]),p)return n.mediaDevices.enumerateDevices().then(g=>{g=g.filter(k=>k.kind==="videoinput");let v=g.find(k=>p.some(w=>k.label.toLowerCase().includes(w)));return!v&&g.length&&p.includes("back")&&(v=g[g.length-1]),v&&(c.video.deviceId=d.exact?{exact:v.deviceId}:{ideal:v.deviceId}),c.video=r(c.video),sC("chrome: "+JSON.stringify(c)),h(c)})}c.video=r(c.video)}return sC("chrome: "+JSON.stringify(c)),h(c)},s=function(c){return e.version>=64?c:{name:{PermissionDeniedError:"NotAllowedError",PermissionDismissedError:"NotAllowedError",InvalidStateError:"NotAllowedError",DevicesNotFoundError:"NotFoundError",ConstraintNotSatisfiedError:"OverconstrainedError",TrackStartError:"NotReadableError",MediaDeviceFailedDueToShutdown:"NotAllowedError",MediaDeviceKillSwitchOn:"NotAllowedError",TabCaptureError:"AbortError",ScreenCaptureError:"AbortError",DeviceCaptureError:"AbortError"}[c.name]||c.name,message:c.message,constraint:c.constraint||c.constraintName,toString(){return this.name+(this.message&&": ")+this.message}}},a=function(c,h,d){i(c,f=>{n.webkitGetUserMedia(f,h,p=>{d&&d(s(p))})})};if(n.getUserMedia=a.bind(n),n.mediaDevices.getUserMedia){const c=n.mediaDevices.getUserMedia.bind(n.mediaDevices);n.mediaDevices.getUserMedia=function(h){return i(h,d=>c(d).then(f=>{if(d.audio&&!f.getAudioTracks().length||d.video&&!f.getVideoTracks().length)throw f.getTracks().forEach(p=>{p.stop()}),new DOMException("","NotFoundError");return f},f=>Promise.reject(s(f))))}}}function iP(t){t.MediaStream=t.MediaStream||t.webkitMediaStream}function sP(t,e){if(!(e.version>102))if(typeof t=="object"&&t.RTCPeerConnection&&!("ontrack"in t.RTCPeerConnection.prototype)){Object.defineProperty(t.RTCPeerConnection.prototype,"ontrack",{get(){return this._ontrack},set(r){this._ontrack&&this.removeEventListener("track",this._ontrack),this.addEventListener("track",this._ontrack=r)},enumerable:!0,configurable:!0});const n=t.RTCPeerConnection.prototype.setRemoteDescription;t.RTCPeerConnection.prototype.setRemoteDescription=function(){return this._ontrackpoly||(this._ontrackpoly=i=>{i.stream.addEventListener("addtrack",s=>{let a;t.RTCPeerConnection.prototype.getReceivers?a=this.getReceivers().find(h=>h.track&&h.track.id===s.track.id):a={track:s.track};const c=new Event("track");c.track=s.track,c.receiver=a,c.transceiver={receiver:a},c.streams=[i.stream],this.dispatchEvent(c)}),i.stream.getTracks().forEach(s=>{let a;t.RTCPeerConnection.prototype.getReceivers?a=this.getReceivers().find(h=>h.track&&h.track.id===s.id):a={track:s};const c=new Event("track");c.track=s,c.receiver=a,c.transceiver={receiver:a},c.streams=[i.stream],this.dispatchEvent(c)})},this.addEventListener("addstream",this._ontrackpoly)),n.apply(this,arguments)}}else xl(t,"track",n=>(n.transceiver||Object.defineProperty(n,"transceiver",{value:{receiver:n.receiver}}),n))}function aP(t){if(typeof t=="object"&&t.RTCPeerConnection&&!("getSenders"in t.RTCPeerConnection.prototype)&&"createDTMFSender"in t.RTCPeerConnection.prototype){const e=function(i,s){return{track:s,get dtmf(){return this._dtmf===void 0&&(s.kind==="audio"?this._dtmf=i.createDTMFSender(s):this._dtmf=null),this._dtmf},_pc:i}};if(!t.RTCPeerConnection.prototype.getSenders){t.RTCPeerConnection.prototype.getSenders=function(){return this._senders=this._senders||[],this._senders.slice()};const i=t.RTCPeerConnection.prototype.addTrack;t.RTCPeerConnection.prototype.addTrack=function(c,h){let d=i.apply(this,arguments);return d||(d=e(this,c),this._senders.push(d)),d};const s=t.RTCPeerConnection.prototype.removeTrack;t.RTCPeerConnection.prototype.removeTrack=function(c){s.apply(this,arguments);const h=this._senders.indexOf(c);h!==-1&&this._senders.splice(h,1)}}const n=t.RTCPeerConnection.prototype.addStream;t.RTCPeerConnection.prototype.addStream=function(s){this._senders=this._senders||[],n.apply(this,[s]),s.getTracks().forEach(a=>{this._senders.push(e(this,a))})};const r=t.RTCPeerConnection.prototype.removeStream;t.RTCPeerConnection.prototype.removeStream=function(s){this._senders=this._senders||[],r.apply(this,[s]),s.getTracks().forEach(a=>{const c=this._senders.find(h=>h.track===a);c&&this._senders.splice(this._senders.indexOf(c),1)})}}else if(typeof t=="object"&&t.RTCPeerConnection&&"getSenders"in t.RTCPeerConnection.prototype&&"createDTMFSender"in t.RTCPeerConnection.prototype&&t.RTCRtpSender&&!("dtmf"in t.RTCRtpSender.prototype)){const e=t.RTCPeerConnection.prototype.getSenders;t.RTCPeerConnection.prototype.getSenders=function(){const r=e.apply(this,[]);return r.forEach(i=>i._pc=this),r},Object.defineProperty(t.RTCRtpSender.prototype,"dtmf",{get(){return this._dtmf===void 0&&(this.track.kind==="audio"?this._dtmf=this._pc.createDTMFSender(this.track):this._dtmf=null),this._dtmf}})}}function oP(t,e){if(e.version>=67||!(typeof t=="object"&&t.RTCPeerConnection&&t.RTCRtpSender&&t.RTCRtpReceiver))return;if(!("getStats"in t.RTCRtpSender.prototype)){const r=t.RTCPeerConnection.prototype.getSenders;r&&(t.RTCPeerConnection.prototype.getSenders=function(){const a=r.apply(this,[]);return a.forEach(c=>c._pc=this),a});const i=t.RTCPeerConnection.prototype.addTrack;i&&(t.RTCPeerConnection.prototype.addTrack=function(){const a=i.apply(this,arguments);return a._pc=this,a}),t.RTCRtpSender.prototype.getStats=function(){const a=this;return this._pc.getStats().then(c=>iC(c,a.track,!0))}}if(!("getStats"in t.RTCRtpReceiver.prototype)){const r=t.RTCPeerConnection.prototype.getReceivers;r&&(t.RTCPeerConnection.prototype.getReceivers=function(){const s=r.apply(this,[]);return s.forEach(a=>a._pc=this),s}),xl(t,"track",i=>(i.receiver._pc=i.srcElement,i)),t.RTCRtpReceiver.prototype.getStats=function(){const s=this;return this._pc.getStats().then(a=>iC(a,s.track,!1))}}if(!("getStats"in t.RTCRtpSender.prototype&&"getStats"in t.RTCRtpReceiver.prototype))return;const n=t.RTCPeerConnection.prototype.getStats;t.RTCPeerConnection.prototype.getStats=function(){if(arguments.length>0&&arguments[0]instanceof t.MediaStreamTrack){const i=arguments[0];let s,a,c;return this.getSenders().forEach(h=>{h.track===i&&(s?c=!0:s=h)}),this.getReceivers().forEach(h=>(h.track===i&&(a?c=!0:a=h),h.track===i)),c||s&&a?Promise.reject(new DOMException("There are more than one sender or receiver for the track.","InvalidAccessError")):s?s.getStats():a?a.getStats():Promise.reject(new DOMException("There is no sender or receiver for the track.","InvalidAccessError"))}return n.apply(this,arguments)}}function lP(t){t.RTCPeerConnection.prototype.getLocalStreams=function(){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},Object.keys(this._shimmedLocalStreams).map(a=>this._shimmedLocalStreams[a][0])};const e=t.RTCPeerConnection.prototype.addTrack;t.RTCPeerConnection.prototype.addTrack=function(a,c){if(!c)return e.apply(this,arguments);this._shimmedLocalStreams=this._shimmedLocalStreams||{};const h=e.apply(this,arguments);return this._shimmedLocalStreams[c.id]?this._shimmedLocalStreams[c.id].indexOf(h)===-1&&this._shimmedLocalStreams[c.id].push(h):this._shimmedLocalStreams[c.id]=[c,h],h};const n=t.RTCPeerConnection.prototype.addStream;t.RTCPeerConnection.prototype.addStream=function(a){this._shimmedLocalStreams=this._shimmedLocalStreams||{},a.getTracks().forEach(d=>{if(this.getSenders().find(p=>p.track===d))throw new DOMException("Track already exists.","InvalidAccessError")});const c=this.getSenders();n.apply(this,arguments);const h=this.getSenders().filter(d=>c.indexOf(d)===-1);this._shimmedLocalStreams[a.id]=[a].concat(h)};const r=t.RTCPeerConnection.prototype.removeStream;t.RTCPeerConnection.prototype.removeStream=function(a){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},delete this._shimmedLocalStreams[a.id],r.apply(this,arguments)};const i=t.RTCPeerConnection.prototype.removeTrack;t.RTCPeerConnection.prototype.removeTrack=function(a){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},a&&Object.keys(this._shimmedLocalStreams).forEach(c=>{const h=this._shimmedLocalStreams[c].indexOf(a);h!==-1&&this._shimmedLocalStreams[c].splice(h,1),this._shimmedLocalStreams[c].length===1&&delete this._shimmedLocalStreams[c]}),i.apply(this,arguments)}}function cP(t,e){if(!t.RTCPeerConnection)return;if(t.RTCPeerConnection.prototype.addTrack&&e.version>=65)return lP(t);const n=t.RTCPeerConnection.prototype.getLocalStreams;t.RTCPeerConnection.prototype.getLocalStreams=function(){const f=n.apply(this);return this._reverseStreams=this._reverseStreams||{},f.map(p=>this._reverseStreams[p.id])};const r=t.RTCPeerConnection.prototype.addStream;t.RTCPeerConnection.prototype.addStream=function(f){if(this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},f.getTracks().forEach(p=>{if(this.getSenders().find(v=>v.track===p))throw new DOMException("Track already exists.","InvalidAccessError")}),!this._reverseStreams[f.id]){const p=new t.MediaStream(f.getTracks());this._streams[f.id]=p,this._reverseStreams[p.id]=f,f=p}r.apply(this,[f])};const i=t.RTCPeerConnection.prototype.removeStream;t.RTCPeerConnection.prototype.removeStream=function(f){this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},i.apply(this,[this._streams[f.id]||f]),delete this._reverseStreams[this._streams[f.id]?this._streams[f.id].id:f.id],delete this._streams[f.id]},t.RTCPeerConnection.prototype.addTrack=function(f,p){if(this.signalingState==="closed")throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");const g=[].slice.call(arguments,1);if(g.length!==1||!g[0].getTracks().find(w=>w===f))throw new DOMException("The adapter.js addTrack polyfill only supports a single stream which is associated with the specified track.","NotSupportedError");if(this.getSenders().find(w=>w.track===f))throw new DOMException("Track already exists.","InvalidAccessError");this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{};const k=this._streams[p.id];if(k)k.addTrack(f),Promise.resolve().then(()=>{this.dispatchEvent(new Event("negotiationneeded"))});else{const w=new t.MediaStream([f]);this._streams[p.id]=w,this._reverseStreams[w.id]=p,this.addStream(w)}return this.getSenders().find(w=>w.track===f)};function s(d,f){let p=f.sdp;return Object.keys(d._reverseStreams||[]).forEach(g=>{const v=d._reverseStreams[g],k=d._streams[v.id];p=p.replace(new RegExp(k.id,"g"),v.id)}),new RTCSessionDescription({type:f.type,sdp:p})}function a(d,f){let p=f.sdp;return Object.keys(d._reverseStreams||[]).forEach(g=>{const v=d._reverseStreams[g],k=d._streams[v.id];p=p.replace(new RegExp(v.id,"g"),k.id)}),new RTCSessionDescription({type:f.type,sdp:p})}["createOffer","createAnswer"].forEach(function(d){const f=t.RTCPeerConnection.prototype[d],p={[d](){const g=arguments;return arguments.length&&typeof arguments[0]=="function"?f.apply(this,[k=>{const w=s(this,k);g[0].apply(null,[w])},k=>{g[1]&&g[1].apply(null,k)},arguments[2]]):f.apply(this,arguments).then(k=>s(this,k))}};t.RTCPeerConnection.prototype[d]=p[d]});const c=t.RTCPeerConnection.prototype.setLocalDescription;t.RTCPeerConnection.prototype.setLocalDescription=function(){return!arguments.length||!arguments[0].type?c.apply(this,arguments):(arguments[0]=a(this,arguments[0]),c.apply(this,arguments))};const h=Object.getOwnPropertyDescriptor(t.RTCPeerConnection.prototype,"localDescription");Object.defineProperty(t.RTCPeerConnection.prototype,"localDescription",{get(){const d=h.get.apply(this);return d.type===""?d:s(this,d)}}),t.RTCPeerConnection.prototype.removeTrack=function(f){if(this.signalingState==="closed")throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");if(!f._pc)throw new DOMException("Argument 1 of RTCPeerConnection.removeTrack does not implement interface RTCRtpSender.","TypeError");if(!(f._pc===this))throw new DOMException("Sender was not created by this connection.","InvalidAccessError");this._streams=this._streams||{};let g;Object.keys(this._streams).forEach(v=>{this._streams[v].getTracks().find(w=>f.track===w)&&(g=this._streams[v])}),g&&(g.getTracks().length===1?this.removeStream(this._reverseStreams[g.id]):g.removeTrack(f.track),this.dispatchEvent(new Event("negotiationneeded")))}}function jv(t,e){!t.RTCPeerConnection&&t.webkitRTCPeerConnection&&(t.RTCPeerConnection=t.webkitRTCPeerConnection),t.RTCPeerConnection&&e.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach(function(n){const r=t.RTCPeerConnection.prototype[n],i={[n](){return arguments[0]=new(n==="addIceCandidate"?t.RTCIceCandidate:t.RTCSessionDescription)(arguments[0]),r.apply(this,arguments)}};t.RTCPeerConnection.prototype[n]=i[n]})}function uP(t,e){e.version>102||xl(t,"negotiationneeded",n=>{const r=n.target;if(!((e.version<72||r.getConfiguration&&r.getConfiguration().sdpSemantics==="plan-b")&&r.signalingState!=="stable"))return n})}var aC=Object.freeze({__proto__:null,fixNegotiationNeeded:uP,shimAddTrackRemoveTrack:cP,shimAddTrackRemoveTrackWithNative:lP,shimGetSendersWithDtmf:aP,shimGetUserMedia:rP,shimMediaStream:iP,shimOnTrack:sP,shimPeerConnection:jv,shimSenderReceiverGetStats:oP});function dP(t,e){const n=t&&t.navigator,r=t&&t.MediaStreamTrack;if(n.getUserMedia=function(i,s,a){bx("navigator.getUserMedia","navigator.mediaDevices.getUserMedia"),n.mediaDevices.getUserMedia(i).then(s,a)},!(e.version>55&&"autoGainControl"in n.mediaDevices.getSupportedConstraints())){const i=function(a,c,h){c in a&&!(h in a)&&(a[h]=a[c],delete a[c])},s=n.mediaDevices.getUserMedia.bind(n.mediaDevices);if(n.mediaDevices.getUserMedia=function(a){return typeof a=="object"&&typeof a.audio=="object"&&(a=JSON.parse(JSON.stringify(a)),i(a.audio,"autoGainControl","mozAutoGainControl"),i(a.audio,"noiseSuppression","mozNoiseSuppression")),s(a)},r&&r.prototype.getSettings){const a=r.prototype.getSettings;r.prototype.getSettings=function(){const c=a.apply(this,arguments);return i(c,"mozAutoGainControl","autoGainControl"),i(c,"mozNoiseSuppression","noiseSuppression"),c}}if(r&&r.prototype.applyConstraints){const a=r.prototype.applyConstraints;r.prototype.applyConstraints=function(c){return this.kind==="audio"&&typeof c=="object"&&(c=JSON.parse(JSON.stringify(c)),i(c,"autoGainControl","mozAutoGainControl"),i(c,"noiseSuppression","mozNoiseSuppression")),a.apply(this,[c])}}}}function Q$(t,e){t.navigator.mediaDevices&&"getDisplayMedia"in t.navigator.mediaDevices||t.navigator.mediaDevices&&(t.navigator.mediaDevices.getDisplayMedia=function(r){if(!(r&&r.video)){const i=new DOMException("getDisplayMedia without video constraints is undefined");return i.name="NotFoundError",i.code=8,Promise.reject(i)}return r.video===!0?r.video={mediaSource:e}:r.video.mediaSource=e,t.navigator.mediaDevices.getUserMedia(r)})}function hP(t){typeof t=="object"&&t.RTCTrackEvent&&"receiver"in t.RTCTrackEvent.prototype&&!("transceiver"in t.RTCTrackEvent.prototype)&&Object.defineProperty(t.RTCTrackEvent.prototype,"transceiver",{get(){return{receiver:this.receiver}}})}function Pv(t,e){typeof t!="object"||!(t.RTCPeerConnection||t.mozRTCPeerConnection)||(!t.RTCPeerConnection&&t.mozRTCPeerConnection&&(t.RTCPeerConnection=t.mozRTCPeerConnection),e.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach(function(n){const r=t.RTCPeerConnection.prototype[n],i={[n](){return arguments[0]=new(n==="addIceCandidate"?t.RTCIceCandidate:t.RTCSessionDescription)(arguments[0]),r.apply(this,arguments)}};t.RTCPeerConnection.prototype[n]=i[n]}))}function fP(t,e){if(typeof t!="object"||!(t.RTCPeerConnection||t.mozRTCPeerConnection)||e.version>=151)return;const n={inboundrtp:"inbound-rtp",outboundrtp:"outbound-rtp",candidatepair:"candidate-pair",localcandidate:"local-candidate",remotecandidate:"remote-candidate"},r=t.RTCPeerConnection.prototype.getStats;t.RTCPeerConnection.prototype.getStats=function(){const[s,a,c]=arguments;return this.signalingState==="closed"?Promise.resolve(new Map):r.apply(this,[s||null]).then(h=>{if(e.version<53&&!a)try{h.forEach(d=>{d.type=n[d.type]||d.type})}catch(d){if(d.name!=="TypeError")throw d;h.forEach((f,p)=>{h.set(p,Object.assign({},f,{type:n[f.type]||f.type}))})}return h}).then(a,c)}}function pP(t){if(!(typeof t=="object"&&t.RTCPeerConnection&&t.RTCRtpSender)||t.RTCRtpSender&&"getStats"in t.RTCRtpSender.prototype)return;const e=t.RTCPeerConnection.prototype.getSenders;e&&(t.RTCPeerConnection.prototype.getSenders=function(){const i=e.apply(this,[]);return i.forEach(s=>s._pc=this),i});const n=t.RTCPeerConnection.prototype.addTrack;n&&(t.RTCPeerConnection.prototype.addTrack=function(){const i=n.apply(this,arguments);return i._pc=this,i}),t.RTCRtpSender.prototype.getStats=function(){return this.track?this._pc.getStats(this.track):Promise.resolve(new Map)}}function mP(t){if(!(typeof t=="object"&&t.RTCPeerConnection&&t.RTCRtpSender)||t.RTCRtpSender&&"getStats"in t.RTCRtpReceiver.prototype)return;const e=t.RTCPeerConnection.prototype.getReceivers;e&&(t.RTCPeerConnection.prototype.getReceivers=function(){const r=e.apply(this,[]);return r.forEach(i=>i._pc=this),r}),xl(t,"track",n=>(n.receiver._pc=n.srcElement,n)),t.RTCRtpReceiver.prototype.getStats=function(){return this._pc.getStats(this.track)}}function gP(t){!t.RTCPeerConnection||"removeStream"in t.RTCPeerConnection.prototype||(t.RTCPeerConnection.prototype.removeStream=function(n){bx("removeStream","removeTrack"),this.getSenders().forEach(r=>{r.track&&n.getTracks().includes(r.track)&&this.removeTrack(r)})})}function vP(t){t.DataChannel&&!t.RTCDataChannel&&(t.RTCDataChannel=t.DataChannel)}function yP(t){if(!(typeof t=="object"&&t.RTCPeerConnection))return;const e=t.RTCPeerConnection.prototype.addTransceiver;e&&(t.RTCPeerConnection.prototype.addTransceiver=function(){this.setParametersPromises=[];let r=arguments[1]&&arguments[1].sendEncodings;r===void 0&&(r=[]),r=[...r];const i=r.length>0;i&&r.forEach(a=>{if("rid"in a&&!/^[a-z0-9]{0,16}$/i.test(a.rid))throw new TypeError("Invalid RID value provided.");if("scaleResolutionDownBy"in a&&!(parseFloat(a.scaleResolutionDownBy)>=1))throw new RangeError("scale_resolution_down_by must be >= 1.0");if("maxFramerate"in a&&!(parseFloat(a.maxFramerate)>=0))throw new RangeError("max_framerate must be >= 0.0")});const s=e.apply(this,arguments);if(i){const{sender:a}=s,c=a.getParameters();(!("encodings"in c)||c.encodings.length===1&&Object.keys(c.encodings[0]).length===0)&&(c.encodings=r,a.sendEncodings=r,this.setParametersPromises.push(a.setParameters(c).then(()=>{delete a.sendEncodings}).catch(()=>{delete a.sendEncodings})))}return s})}function xP(t){if(!(typeof t=="object"&&t.RTCRtpSender))return;const e=t.RTCRtpSender.prototype.getParameters;e&&(t.RTCRtpSender.prototype.getParameters=function(){const r=e.apply(this,arguments);return"encodings"in r||(r.encodings=[].concat(this.sendEncodings||[{}])),r})}function bP(t){if(!(typeof t=="object"&&t.RTCPeerConnection))return;const e=t.RTCPeerConnection.prototype.createOffer;t.RTCPeerConnection.prototype.createOffer=function(){return this.setParametersPromises&&this.setParametersPromises.length?Promise.all(this.setParametersPromises).then(()=>e.apply(this,arguments)).finally(()=>{this.setParametersPromises=[]}):e.apply(this,arguments)}}function kP(t){if(!(typeof t=="object"&&t.RTCPeerConnection))return;const e=t.RTCPeerConnection.prototype.createAnswer;t.RTCPeerConnection.prototype.createAnswer=function(){return this.setParametersPromises&&this.setParametersPromises.length?Promise.all(this.setParametersPromises).then(()=>e.apply(this,arguments)).finally(()=>{this.setParametersPromises=[]}):e.apply(this,arguments)}}var oC=Object.freeze({__proto__:null,shimAddTransceiver:yP,shimCreateAnswer:kP,shimCreateOffer:bP,shimGetDisplayMedia:Q$,shimGetParameters:xP,shimGetStats:fP,shimGetUserMedia:dP,shimOnTrack:hP,shimPeerConnection:Pv,shimRTCDataChannel:vP,shimReceiverGetStats:mP,shimRemoveStream:gP,shimSenderGetStats:pP});function wP(t){if(!(typeof t!="object"||!t.RTCPeerConnection)){if("getLocalStreams"in t.RTCPeerConnection.prototype||(t.RTCPeerConnection.prototype.getLocalStreams=function(){return this._localStreams||(this._localStreams=[]),this._localStreams}),!("addStream"in t.RTCPeerConnection.prototype)){const e=t.RTCPeerConnection.prototype.addTrack;t.RTCPeerConnection.prototype.addStream=function(r){this._localStreams||(this._localStreams=[]),this._localStreams.includes(r)||this._localStreams.push(r),r.getAudioTracks().forEach(i=>e.call(this,i,r)),r.getVideoTracks().forEach(i=>e.call(this,i,r))},t.RTCPeerConnection.prototype.addTrack=function(r){for(var i=arguments.length,s=new Array(i>1?i-1:0),a=1;a<i;a++)s[a-1]=arguments[a];return s&&s.forEach(c=>{this._localStreams?this._localStreams.includes(c)||this._localStreams.push(c):this._localStreams=[c]}),e.apply(this,arguments)}}"removeStream"in t.RTCPeerConnection.prototype||(t.RTCPeerConnection.prototype.removeStream=function(n){this._localStreams||(this._localStreams=[]);const r=this._localStreams.indexOf(n);if(r===-1)return;this._localStreams.splice(r,1);const i=n.getTracks();this.getSenders().forEach(s=>{i.includes(s.track)&&this.removeTrack(s)})})}}function SP(t){if(!(typeof t!="object"||!t.RTCPeerConnection)&&("getRemoteStreams"in t.RTCPeerConnection.prototype||(t.RTCPeerConnection.prototype.getRemoteStreams=function(){return this._remoteStreams?this._remoteStreams:[]}),!("onaddstream"in t.RTCPeerConnection.prototype))){Object.defineProperty(t.RTCPeerConnection.prototype,"onaddstream",{get(){return this._onaddstream},set(n){this._onaddstream&&(this.removeEventListener("addstream",this._onaddstream),this.removeEventListener("track",this._onaddstreampoly)),this.addEventListener("addstream",this._onaddstream=n),this.addEventListener("track",this._onaddstreampoly=r=>{r.streams.forEach(i=>{if(this._remoteStreams||(this._remoteStreams=[]),this._remoteStreams.includes(i))return;this._remoteStreams.push(i);const s=new Event("addstream");s.stream=i,this.dispatchEvent(s)})})}});const e=t.RTCPeerConnection.prototype.setRemoteDescription;t.RTCPeerConnection.prototype.setRemoteDescription=function(){const r=this;return this._onaddstreampoly||this.addEventListener("track",this._onaddstreampoly=function(i){i.streams.forEach(s=>{if(r._remoteStreams||(r._remoteStreams=[]),r._remoteStreams.indexOf(s)>=0)return;r._remoteStreams.push(s);const a=new Event("addstream");a.stream=s,r.dispatchEvent(a)})}),e.apply(r,arguments)}}}function CP(t){if(typeof t!="object"||!t.RTCPeerConnection)return;const e=t.RTCPeerConnection.prototype,n=e.createOffer,r=e.createAnswer,i=e.setLocalDescription,s=e.setRemoteDescription,a=e.addIceCandidate;e.createOffer=function(d,f){const p=arguments.length>=2?arguments[2]:arguments[0],g=n.apply(this,[p]);return f?(g.then(d,f),Promise.resolve()):g},e.createAnswer=function(d,f){const p=arguments.length>=2?arguments[2]:arguments[0],g=r.apply(this,[p]);return f?(g.then(d,f),Promise.resolve()):g};let c=function(h,d,f){const p=i.apply(this,[h]);return f?(p.then(d,f),Promise.resolve()):p};e.setLocalDescription=c,c=function(h,d,f){const p=s.apply(this,[h]);return f?(p.then(d,f),Promise.resolve()):p},e.setRemoteDescription=c,c=function(h,d,f){const p=a.apply(this,[h]);return f?(p.then(d,f),Promise.resolve()):p},e.addIceCandidate=c}function TP(t){const e=t&&t.navigator;if(e.mediaDevices&&e.mediaDevices.getUserMedia){const n=e.mediaDevices,r=n.getUserMedia.bind(n);e.mediaDevices.getUserMedia=i=>r(NP(i))}!e.getUserMedia&&e.mediaDevices&&e.mediaDevices.getUserMedia&&(e.getUserMedia=(function(r,i,s){e.mediaDevices.getUserMedia(r).then(i,s)}).bind(e))}function NP(t){return t&&t.video!==void 0?Object.assign({},t,{video:nP(t.video)}):t}function EP(t){if(!t.RTCPeerConnection)return;const e=t.RTCPeerConnection;t.RTCPeerConnection=function(r,i){if(r&&r.iceServers){const s=[];for(let a=0;a<r.iceServers.length;a++){let c=r.iceServers[a];c.urls===void 0&&c.url?(bx("RTCIceServer.url","RTCIceServer.urls"),c=JSON.parse(JSON.stringify(c)),c.urls=c.url,delete c.url,s.push(c)):s.push(r.iceServers[a])}r.iceServers=s}return new e(r,i)},t.RTCPeerConnection.prototype=e.prototype,"generateCertificate"in e&&Object.defineProperty(t.RTCPeerConnection,"generateCertificate",{get(){return e.generateCertificate}})}function jP(t){typeof t=="object"&&t.RTCTrackEvent&&"receiver"in t.RTCTrackEvent.prototype&&!("transceiver"in t.RTCTrackEvent.prototype)&&Object.defineProperty(t.RTCTrackEvent.prototype,"transceiver",{get(){return{receiver:this.receiver}}})}function PP(t){const e=t.RTCPeerConnection.prototype.createOffer;t.RTCPeerConnection.prototype.createOffer=function(r){if(r){typeof r.offerToReceiveAudio<"u"&&(r.offerToReceiveAudio=!!r.offerToReceiveAudio);const i=this.getTransceivers().find(a=>a.receiver.track.kind==="audio");r.offerToReceiveAudio===!1&&i?i.direction==="sendrecv"?i.setDirection?i.setDirection("sendonly"):i.direction="sendonly":i.direction==="recvonly"&&(i.setDirection?i.setDirection("inactive"):i.direction="inactive"):r.offerToReceiveAudio===!0&&!i&&this.addTransceiver("audio",{direction:"recvonly"}),typeof r.offerToReceiveVideo<"u"&&(r.offerToReceiveVideo=!!r.offerToReceiveVideo);const s=this.getTransceivers().find(a=>a.receiver.track.kind==="video");r.offerToReceiveVideo===!1&&s?s.direction==="sendrecv"?s.setDirection?s.setDirection("sendonly"):s.direction="sendonly":s.direction==="recvonly"&&(s.setDirection?s.setDirection("inactive"):s.direction="inactive"):r.offerToReceiveVideo===!0&&!s&&this.addTransceiver("video",{direction:"recvonly"})}return e.apply(this,arguments)}}function _P(t){typeof t!="object"||t.AudioContext||(t.AudioContext=t.webkitAudioContext)}var lC=Object.freeze({__proto__:null,shimAudioContext:_P,shimCallbacksAPI:CP,shimConstraints:NP,shimCreateOfferLegacy:PP,shimGetUserMedia:TP,shimLocalStreamsAPI:wP,shimRTCIceServerUrls:EP,shimRemoteStreamsAPI:SP,shimTrackEventTransceiver:jP}),m0={exports:{}},cC;function Z$(){return cC||(cC=1,(function(t){const e={};e.generateIdentifier=function(){return Math.random().toString(36).substring(2,12)},e.localCName=e.generateIdentifier(),e.splitLines=function(n){return n.trim().split(`
527
+ `).map(r=>r.trim())},e.splitSections=function(n){return n.split(`
528
+ m=`).map((i,s)=>(s>0?"m="+i:i).trim()+`\r
529
+ `)},e.getDescription=function(n){const r=e.splitSections(n);return r&&r[0]},e.getMediaSections=function(n){const r=e.splitSections(n);return r.shift(),r},e.matchPrefix=function(n,r){return e.splitLines(n).filter(i=>i.indexOf(r)===0)},e.parseCandidate=function(n){let r;n.indexOf("a=candidate:")===0?r=n.substring(12).split(" "):r=n.substring(10).split(" ");const i={foundation:r[0],component:{1:"rtp",2:"rtcp"}[r[1]]||r[1],protocol:r[2].toLowerCase(),priority:parseInt(r[3],10),ip:r[4],address:r[4],port:parseInt(r[5],10),type:r[7]};for(let s=8;s<r.length;s+=2)switch(r[s]){case"raddr":i.relatedAddress=r[s+1];break;case"rport":i.relatedPort=parseInt(r[s+1],10);break;case"tcptype":i.tcpType=r[s+1];break;case"ufrag":i.ufrag=r[s+1],i.usernameFragment=r[s+1];break;default:i[r[s]]===void 0&&(i[r[s]]=r[s+1]);break}return i},e.writeCandidate=function(n){const r=[];r.push(n.foundation);const i=n.component;i==="rtp"?r.push(1):i==="rtcp"?r.push(2):r.push(i),r.push(n.protocol.toUpperCase()),r.push(n.priority),r.push(n.address||n.ip),r.push(n.port);const s=n.type;return r.push("typ"),r.push(s),s!=="host"&&n.relatedAddress&&n.relatedPort!==void 0&&(r.push("raddr"),r.push(n.relatedAddress),r.push("rport"),r.push(n.relatedPort)),n.tcpType&&n.protocol.toLowerCase()==="tcp"&&(r.push("tcptype"),r.push(n.tcpType)),(n.usernameFragment||n.ufrag)&&(r.push("ufrag"),r.push(n.usernameFragment||n.ufrag)),"candidate:"+r.join(" ")},e.parseIceOptions=function(n){return n.substring(14).split(" ")},e.parseRtpMap=function(n){let r=n.substring(9).split(" ");const i={payloadType:parseInt(r.shift(),10)};return r=r[0].split("/"),i.name=r[0],i.clockRate=parseInt(r[1],10),i.channels=r.length===3?parseInt(r[2],10):1,i.numChannels=i.channels,i},e.writeRtpMap=function(n){let r=n.payloadType;n.preferredPayloadType!==void 0&&(r=n.preferredPayloadType);const i=n.channels||n.numChannels||1;return"a=rtpmap:"+r+" "+n.name+"/"+n.clockRate+(i!==1?"/"+i:"")+`\r
530
+ `},e.parseExtmap=function(n){const r=n.substring(9).split(" ");return{id:parseInt(r[0],10),direction:r[0].indexOf("/")>0?r[0].split("/")[1]:"sendrecv",uri:r[1],attributes:r.slice(2).join(" ")}},e.writeExtmap=function(n){return"a=extmap:"+(n.id||n.preferredId)+(n.direction&&n.direction!=="sendrecv"?"/"+n.direction:"")+" "+n.uri+(n.attributes?" "+n.attributes:"")+`\r
531
+ `},e.parseFmtp=function(n){const r={};let i;const s=n.substring(n.indexOf(" ")+1).split(";");for(let a=0;a<s.length;a++)i=s[a].trim().split("="),r[i[0].trim()]=i[1];return r},e.writeFmtp=function(n){let r="",i=n.payloadType;if(n.preferredPayloadType!==void 0&&(i=n.preferredPayloadType),n.parameters&&Object.keys(n.parameters).length){const s=[];Object.keys(n.parameters).forEach(a=>{n.parameters[a]!==void 0?s.push(a+"="+n.parameters[a]):s.push(a)}),r+="a=fmtp:"+i+" "+s.join(";")+`\r
532
+ `}return r},e.parseRtcpFb=function(n){const r=n.substring(n.indexOf(" ")+1).split(" ");return{type:r.shift(),parameter:r.join(" ")}},e.writeRtcpFb=function(n){let r="",i=n.payloadType;return n.preferredPayloadType!==void 0&&(i=n.preferredPayloadType),n.rtcpFeedback&&n.rtcpFeedback.length&&n.rtcpFeedback.forEach(s=>{r+="a=rtcp-fb:"+i+" "+s.type+(s.parameter&&s.parameter.length?" "+s.parameter:"")+`\r
533
+ `}),r},e.parseSsrcMedia=function(n){const r=n.indexOf(" "),i={ssrc:parseInt(n.substring(7,r),10)},s=n.indexOf(":",r);return s>-1?(i.attribute=n.substring(r+1,s),i.value=n.substring(s+1)):i.attribute=n.substring(r+1),i},e.parseSsrcGroup=function(n){const r=n.substring(13).split(" ");return{semantics:r.shift(),ssrcs:r.map(i=>parseInt(i,10))}},e.getMid=function(n){const r=e.matchPrefix(n,"a=mid:")[0];if(r)return r.substring(6)},e.parseFingerprint=function(n){const r=n.substring(14).split(" ");return{algorithm:r[0].toLowerCase(),value:r[1].toUpperCase()}},e.getDtlsParameters=function(n,r){return{role:"auto",fingerprints:e.matchPrefix(n+r,"a=fingerprint:").map(e.parseFingerprint)}},e.writeDtlsParameters=function(n,r){let i="a=setup:"+r+`\r
534
+ `;return n.fingerprints.forEach(s=>{i+="a=fingerprint:"+s.algorithm+" "+s.value+`\r
535
+ `}),i},e.parseCryptoLine=function(n){const r=n.substring(9).split(" ");return{tag:parseInt(r[0],10),cryptoSuite:r[1],keyParams:r[2],sessionParams:r.slice(3)}},e.writeCryptoLine=function(n){return"a=crypto:"+n.tag+" "+n.cryptoSuite+" "+(typeof n.keyParams=="object"?e.writeCryptoKeyParams(n.keyParams):n.keyParams)+(n.sessionParams?" "+n.sessionParams.join(" "):"")+`\r
536
+ `},e.parseCryptoKeyParams=function(n){if(n.indexOf("inline:")!==0)return null;const r=n.substring(7).split("|");return{keyMethod:"inline",keySalt:r[0],lifeTime:r[1],mkiValue:r[2]?r[2].split(":")[0]:void 0,mkiLength:r[2]?r[2].split(":")[1]:void 0}},e.writeCryptoKeyParams=function(n){return n.keyMethod+":"+n.keySalt+(n.lifeTime?"|"+n.lifeTime:"")+(n.mkiValue&&n.mkiLength?"|"+n.mkiValue+":"+n.mkiLength:"")},e.getCryptoParameters=function(n,r){return e.matchPrefix(n+r,"a=crypto:").map(e.parseCryptoLine)},e.getIceParameters=function(n,r){const i=e.matchPrefix(n+r,"a=ice-ufrag:")[0],s=e.matchPrefix(n+r,"a=ice-pwd:")[0];return i&&s?{usernameFragment:i.substring(12),password:s.substring(10)}:null},e.writeIceParameters=function(n){let r="a=ice-ufrag:"+n.usernameFragment+`\r
537
+ a=ice-pwd:`+n.password+`\r
538
+ `;return n.iceLite&&(r+=`a=ice-lite\r
539
+ `),r},e.parseRtpParameters=function(n){const r={codecs:[],headerExtensions:[],fecMechanisms:[],rtcp:[]},s=e.splitLines(n)[0].split(" ");r.profile=s[2];for(let c=3;c<s.length;c++){const h=s[c],d=e.matchPrefix(n,"a=rtpmap:"+h+" ")[0];if(d){const f=e.parseRtpMap(d),p=e.matchPrefix(n,"a=fmtp:"+h+" ");switch(f.parameters=p.length?e.parseFmtp(p[0]):{},f.rtcpFeedback=e.matchPrefix(n,"a=rtcp-fb:"+h+" ").map(e.parseRtcpFb),r.codecs.push(f),f.name.toUpperCase()){case"RED":case"ULPFEC":r.fecMechanisms.push(f.name.toUpperCase());break}}}e.matchPrefix(n,"a=extmap:").forEach(c=>{r.headerExtensions.push(e.parseExtmap(c))});const a=e.matchPrefix(n,"a=rtcp-fb:* ").map(e.parseRtcpFb);return r.codecs.forEach(c=>{a.forEach(h=>{c.rtcpFeedback.find(f=>f.type===h.type&&f.parameter===h.parameter)||c.rtcpFeedback.push(h)})}),r},e.writeRtpDescription=function(n,r){let i="";i+="m="+n+" ",i+=r.codecs.length>0?"9":"0",i+=" "+(r.profile||"UDP/TLS/RTP/SAVPF")+" ",i+=r.codecs.map(a=>a.preferredPayloadType!==void 0?a.preferredPayloadType:a.payloadType).join(" ")+`\r
540
+ `,i+=`c=IN IP4 0.0.0.0\r
541
+ `,i+=`a=rtcp:9 IN IP4 0.0.0.0\r
542
+ `,r.codecs.forEach(a=>{i+=e.writeRtpMap(a),i+=e.writeFmtp(a),i+=e.writeRtcpFb(a)});let s=0;return r.codecs.forEach(a=>{a.maxptime>s&&(s=a.maxptime)}),s>0&&(i+="a=maxptime:"+s+`\r
543
+ `),r.headerExtensions&&r.headerExtensions.forEach(a=>{i+=e.writeExtmap(a)}),i},e.parseRtpEncodingParameters=function(n){const r=[],i=e.parseRtpParameters(n),s=i.fecMechanisms.indexOf("RED")!==-1,a=i.fecMechanisms.indexOf("ULPFEC")!==-1,c=e.matchPrefix(n,"a=ssrc:").map(g=>e.parseSsrcMedia(g)).filter(g=>g.attribute==="cname"),h=c.length>0&&c[0].ssrc;let d;const f=e.matchPrefix(n,"a=ssrc-group:FID").map(g=>g.substring(17).split(" ").map(k=>parseInt(k,10)));f.length>0&&f[0].length>1&&f[0][0]===h&&(d=f[0][1]),i.codecs.forEach(g=>{if(g.name.toUpperCase()==="RTX"&&g.parameters.apt){let v={ssrc:h,codecPayloadType:parseInt(g.parameters.apt,10)};h&&d&&(v.rtx={ssrc:d}),r.push(v),s&&(v=JSON.parse(JSON.stringify(v)),v.fec={ssrc:h,mechanism:a?"red+ulpfec":"red"},r.push(v))}}),r.length===0&&h&&r.push({ssrc:h});let p=e.matchPrefix(n,"b=");return p.length&&(p[0].indexOf("b=TIAS:")===0?p=parseInt(p[0].substring(7),10):p[0].indexOf("b=AS:")===0?p=parseInt(p[0].substring(5),10)*1e3*.95-2e3*8:p=void 0,r.forEach(g=>{g.maxBitrate=p})),r},e.parseRtcpParameters=function(n){const r={},i=e.matchPrefix(n,"a=ssrc:").map(c=>e.parseSsrcMedia(c)).filter(c=>c.attribute==="cname")[0];i&&(r.cname=i.value,r.ssrc=i.ssrc);const s=e.matchPrefix(n,"a=rtcp-rsize");r.reducedSize=s.length>0,r.compound=s.length===0;const a=e.matchPrefix(n,"a=rtcp-mux");return r.mux=a.length>0,r},e.writeRtcpParameters=function(n){let r="";return n.reducedSize&&(r+=`a=rtcp-rsize\r
544
+ `),n.mux&&(r+=`a=rtcp-mux\r
545
+ `),n.ssrc!==void 0&&n.cname&&(r+="a=ssrc:"+n.ssrc+" cname:"+n.cname+`\r
546
+ `),r},e.parseMsid=function(n){let r;const i=e.matchPrefix(n,"a=msid:");if(i.length===1)return r=i[0].substring(7).split(" "),{stream:r[0],track:r[1]};const s=e.matchPrefix(n,"a=ssrc:").map(a=>e.parseSsrcMedia(a)).filter(a=>a.attribute==="msid");if(s.length>0)return r=s[0].value.split(" "),{stream:r[0],track:r[1]}},e.parseSctpDescription=function(n){const r=e.parseMLine(n),i=e.matchPrefix(n,"a=max-message-size:");let s;i.length>0&&(s=parseInt(i[0].substring(19),10)),isNaN(s)&&(s=65536);const a=e.matchPrefix(n,"a=sctp-port:");if(a.length>0)return{port:parseInt(a[0].substring(12),10),protocol:r.fmt,maxMessageSize:s};const c=e.matchPrefix(n,"a=sctpmap:");if(c.length>0){const h=c[0].substring(10).split(" ");return{port:parseInt(h[0],10),protocol:h[1],maxMessageSize:s}}},e.writeSctpDescription=function(n,r){let i=[];return n.protocol!=="DTLS/SCTP"?i=["m="+n.kind+" 9 "+n.protocol+" "+r.protocol+`\r
547
+ `,`c=IN IP4 0.0.0.0\r
548
+ `,"a=sctp-port:"+r.port+`\r
549
+ `]:i=["m="+n.kind+" 9 "+n.protocol+" "+r.port+`\r
550
+ `,`c=IN IP4 0.0.0.0\r
551
+ `,"a=sctpmap:"+r.port+" "+r.protocol+` 65535\r
552
+ `],r.maxMessageSize!==void 0&&i.push("a=max-message-size:"+r.maxMessageSize+`\r
553
+ `),i.join("")},e.generateSessionId=function(){return Math.random().toString().substr(2,22)},e.writeSessionBoilerplate=function(n,r,i){let s;const a=r!==void 0?r:2;return n?s=n:s=e.generateSessionId(),`v=0\r
554
+ o=`+(i||"thisisadapterortc")+" "+s+" "+a+` IN IP4 127.0.0.1\r
555
+ s=-\r
556
+ t=0 0\r
557
+ `},e.getDirection=function(n,r){const i=e.splitLines(n);for(let s=0;s<i.length;s++)switch(i[s]){case"a=sendrecv":case"a=sendonly":case"a=recvonly":case"a=inactive":return i[s].substring(2)}return r?e.getDirection(r):"sendrecv"},e.getKind=function(n){return e.splitLines(n)[0].split(" ")[0].substring(2)},e.isRejected=function(n){return n.split(" ",2)[1]==="0"},e.parseMLine=function(n){const i=e.splitLines(n)[0].substring(2).split(" ");return{kind:i[0],port:parseInt(i[1],10),protocol:i[2],fmt:i.slice(3).join(" ")}},e.parseOLine=function(n){const i=e.matchPrefix(n,"o=")[0].substring(2).split(" ");return{username:i[0],sessionId:i[1],sessionVersion:parseInt(i[2],10),netType:i[3],addressType:i[4],address:i[5]}},e.isValidSDP=function(n){if(typeof n!="string"||n.length===0)return!1;const r=e.splitLines(n);for(let i=0;i<r.length;i++)if(r[i].length<2||r[i].charAt(1)!=="=")return!1;return!0},t.exports=e})(m0)),m0.exports}var RP=Z$(),dc=U$(RP),eV=iz({__proto__:null,default:dc},[RP]);function kf(t){if(!t.RTCIceCandidate||t.RTCIceCandidate&&"foundation"in t.RTCIceCandidate.prototype)return;const e=t.RTCIceCandidate;t.RTCIceCandidate=function(r){if(typeof r=="object"&&r.candidate&&r.candidate.indexOf("a=")===0&&(r=JSON.parse(JSON.stringify(r)),r.candidate=r.candidate.substring(2)),r.candidate&&r.candidate.length){const i=new e(r),s=dc.parseCandidate(r.candidate);for(const a in s)a in i||Object.defineProperty(i,a,{value:s[a]});return i.toJSON=function(){return{candidate:i.candidate,sdpMid:i.sdpMid,sdpMLineIndex:i.sdpMLineIndex,usernameFragment:i.usernameFragment}},i}return new e(r)},t.RTCIceCandidate.prototype=e.prototype,xl(t,"icecandidate",n=>(n.candidate&&Object.defineProperty(n,"candidate",{value:new t.RTCIceCandidate(n.candidate),writable:"false"}),n))}function _v(t){!t.RTCIceCandidate||t.RTCIceCandidate&&"relayProtocol"in t.RTCIceCandidate.prototype||xl(t,"icecandidate",e=>{if(e.candidate){const n=dc.parseCandidate(e.candidate.candidate);n.type==="relay"&&(e.candidate.relayProtocol={0:"tls",1:"tcp",2:"udp"}[n.priority>>24])}return e})}function wf(t,e){if(!t.RTCPeerConnection)return;"sctp"in t.RTCPeerConnection.prototype||Object.defineProperty(t.RTCPeerConnection.prototype,"sctp",{get(){return typeof this._sctp>"u"?null:this._sctp}});const n=function(c){if(!c||!c.sdp)return!1;const h=dc.splitSections(c.sdp);return h.shift(),h.some(d=>{const f=dc.parseMLine(d);return f&&f.kind==="application"&&f.protocol.indexOf("SCTP")!==-1})},r=function(c){const h=c.sdp.match(/mozilla...THIS_IS_SDPARTA-(\d+)/);if(h===null||h.length<2)return-1;const d=parseInt(h[1],10);return d!==d?-1:d},i=function(c){let h=65536;return e.browser==="firefox"&&(e.version<57?c===-1?h=16384:h=2147483637:e.version<60?h=e.version===57?65535:65536:h=2147483637),h},s=function(c,h){let d=65536;e.browser==="firefox"&&e.version===57&&(d=65535);const f=dc.matchPrefix(c.sdp,"a=max-message-size:");return f.length>0?d=parseInt(f[0].substring(19),10):e.browser==="firefox"&&h!==-1&&(d=2147483637),d},a=t.RTCPeerConnection.prototype.setRemoteDescription;t.RTCPeerConnection.prototype.setRemoteDescription=function(){if(this._sctp=null,e.browser==="chrome"&&e.version>=76){const{sdpSemantics:h}=this.getConfiguration();h==="plan-b"&&Object.defineProperty(this,"sctp",{get(){return typeof this._sctp>"u"?null:this._sctp},enumerable:!0,configurable:!0})}if(n(arguments[0])){const h=r(arguments[0]),d=i(h),f=s(arguments[0],h);let p;d===0&&f===0?p=Number.POSITIVE_INFINITY:d===0||f===0?p=Math.max(d,f):p=Math.min(d,f);const g={};Object.defineProperty(g,"maxMessageSize",{get(){return p}}),this._sctp=g}return a.apply(this,arguments)}}function Sf(t,e){if(!(t.RTCPeerConnection&&"createDataChannel"in t.RTCPeerConnection.prototype)||e.browser==="chrome"&&e.version>149||e.browser==="firefox"&&e.version>60)return;function n(i,s){const a=i.send;i.send=function(){const h=arguments[0],d=h.length||h.size||h.byteLength;if(i.readyState==="open"&&s.sctp&&d>s.sctp.maxMessageSize)throw new TypeError("Message too large (can send a maximum of "+s.sctp.maxMessageSize+" bytes)");return a.apply(i,arguments)}}const r=t.RTCPeerConnection.prototype.createDataChannel;t.RTCPeerConnection.prototype.createDataChannel=function(){const s=r.apply(this,arguments);return n(s,this),s},xl(t,"datachannel",i=>(n(i.channel,i.target),i))}function Rv(t){if(!t.RTCPeerConnection||"connectionState"in t.RTCPeerConnection.prototype)return;const e=t.RTCPeerConnection.prototype;Object.defineProperty(e,"connectionState",{get(){return{completed:"connected",checking:"connecting"}[this.iceConnectionState]||this.iceConnectionState},enumerable:!0,configurable:!0}),Object.defineProperty(e,"onconnectionstatechange",{get(){return this._onconnectionstatechange||null},set(n){this._onconnectionstatechange&&(this.removeEventListener("connectionstatechange",this._onconnectionstatechange),delete this._onconnectionstatechange),n&&this.addEventListener("connectionstatechange",this._onconnectionstatechange=n)},enumerable:!0,configurable:!0}),["setLocalDescription","setRemoteDescription"].forEach(n=>{const r=e[n];e[n]=function(){return this._connectionstatechangepoly||(this._connectionstatechangepoly=i=>{const s=i.target;if(s._lastConnectionState!==s.connectionState){s._lastConnectionState=s.connectionState;const a=new Event("connectionstatechange",i);s.dispatchEvent(a)}return i},this.addEventListener("iceconnectionstatechange",this._connectionstatechangepoly)),r.apply(this,arguments)}})}function Iv(t,e){if(!t.RTCPeerConnection||e.browser==="chrome"&&e.version>=71||e.browser==="safari"&&e._safariVersion>=13.1)return;const n=t.RTCPeerConnection.prototype.setRemoteDescription;t.RTCPeerConnection.prototype.setRemoteDescription=function(i){if(i&&i.sdp&&i.sdp.indexOf(`
558
+ a=extmap-allow-mixed`)!==-1){const s=i.sdp.split(`
559
+ `).filter(a=>a.trim()!=="a=extmap-allow-mixed").join(`
560
+ `);t.RTCSessionDescription&&i instanceof t.RTCSessionDescription?arguments[0]=new t.RTCSessionDescription({type:i.type,sdp:s}):i.sdp=s}return n.apply(this,arguments)}}function Cf(t,e){if(!(t.RTCPeerConnection&&t.RTCPeerConnection.prototype))return;const n=t.RTCPeerConnection.prototype.addIceCandidate;!n||n.length===0||(t.RTCPeerConnection.prototype.addIceCandidate=function(){return arguments[0]?(e.browser==="chrome"&&e.version<78||e.browser==="firefox"&&e.version<68||e.browser==="safari")&&arguments[0]&&arguments[0].candidate===""?Promise.resolve():n.apply(this,arguments):(arguments[1]&&arguments[1].apply(null),Promise.resolve())})}function Tf(t,e){if(!(t.RTCPeerConnection&&t.RTCPeerConnection.prototype))return;const n=t.RTCPeerConnection.prototype.setLocalDescription;!n||n.length===0||(t.RTCPeerConnection.prototype.setLocalDescription=function(){let i=arguments[0]||{};if(typeof i!="object"||i.type&&i.sdp)return n.apply(this,arguments);if(i={type:i.type,sdp:i.sdp},!i.type)switch(this.signalingState){case"stable":case"have-local-offer":case"have-remote-pranswer":i.type="offer";break;default:i.type="answer";break}return i.sdp||i.type!=="offer"&&i.type!=="answer"?n.apply(this,[i]):(i.type==="offer"?this.createOffer:this.createAnswer).apply(this).then(a=>n.apply(this,[a]))})}var tV=Object.freeze({__proto__:null,removeExtmapAllowMixed:Iv,shimAddIceCandidateNullOrEmpty:Cf,shimConnectionState:Rv,shimMaxMessageSize:wf,shimParameterlessSetLocalDescription:Tf,shimRTCIceCandidate:kf,shimRTCIceCandidateRelayProtocol:_v,shimSendThrowTypeError:Sf});function nV(){let{window:t}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{shimChrome:!0,shimFirefox:!0,shimSafari:!0};const n=xx,r=X$(t),i={browserDetails:r,commonShim:tV,extractVersion:Fu,disableLog:Y$,disableWarnings:J$,sdp:eV};switch(r.browser){case"chrome":if(!aC||!jv||!e.shimChrome)return n("Chrome shim is not included in this adapter release."),i;if(r.version===null)return n("Chrome shim can not determine version, not shimming."),i;n("adapter.js shimming chrome."),i.browserShim=aC,Cf(t,r),Tf(t),rP(t,r),iP(t),jv(t,r),sP(t,r),cP(t,r),aP(t),oP(t,r),uP(t,r),kf(t),_v(t),Rv(t),wf(t,r),Sf(t,r),Iv(t,r);break;case"firefox":if(!oC||!Pv||!e.shimFirefox)return n("Firefox shim is not included in this adapter release."),i;n("adapter.js shimming firefox."),i.browserShim=oC,Cf(t,r),Tf(t),dP(t,r),Pv(t,r),fP(t,r),hP(t),gP(t),pP(t),mP(t),vP(t),yP(t),xP(t),bP(t),kP(t),kf(t),Rv(t),wf(t,r),Sf(t,r);break;case"safari":if(!lC||!e.shimSafari)return n("Safari shim is not included in this adapter release."),i;n("adapter.js shimming safari."),i.browserShim=lC,Cf(t,r),Tf(t),EP(t),PP(t),CP(t),wP(t),SP(t),jP(t),TP(t),_P(t),kf(t),_v(t),wf(t,r),Sf(t,r),Iv(t,r);break;default:n("Unsupported browser!");break}return i}nV({window:typeof window>"u"?void 0:window});var Mv,IP;class Sr extends(IP=Promise){constructor(e){super(e)}catch(e){return super.catch(e)}static reject(e){return super.reject(e)}static all(e){return super.all(e)}static race(e){return super.race(e)}}Mv=Sr;Sr.resolve=t=>Reflect.get(IP,"resolve",Mv).call(Mv,t);const rV=/version\/(\d+(\.?_?\d+)+)/i;let g0;function Qr(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0;if(typeof navigator>"u")return;const n=navigator.userAgent.toLowerCase();if(g0===void 0||e){const r=iV.find(i=>{let{test:s}=i;return s.test(n)});g0=r==null?void 0:r.describe(n)}return g0}const iV=[{test:/firefox|iceweasel|fxios/i,describe(t){return{name:"Firefox",version:Nf(/(?:firefox|iceweasel|fxios)[\s/](\d+(\.?_?\d+)+)/i,t),os:t.toLowerCase().includes("fxios")?"iOS":void 0,osVersion:v0(t)}}},{test:/chrom|crios|crmo/i,describe(t){return{name:"Chrome",version:Nf(/(?:chrome|chromium|crios|crmo)\/(\d+(\.?_?\d+)+)/i,t),os:t.toLowerCase().includes("crios")?"iOS":void 0,osVersion:v0(t)}}},{test:/safari|applewebkit/i,describe(t){return{name:"Safari",version:Nf(rV,t),os:t.includes("mobile/")?"iOS":"macOS",osVersion:v0(t)}}}];function Nf(t,e){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1;const r=e.match(t);return r&&r.length>=n&&r[n]||""}function v0(t){return t.includes("mac os")?Nf(/\(.+?(\d+_\d+(:?_\d+)?)/,t,1).replace(/_/g,"."):void 0}var sV="2.18.4";const aV=sV,oV=16;class mo extends Error{constructor(e,n,r){super(n||"an error has occurred"),this.name="LiveKitError",this.code=e,typeof(r==null?void 0:r.cause)<"u"&&(this.cause=r==null?void 0:r.cause)}}class Ai extends mo{}var xn;(function(t){t[t.NotAllowed=0]="NotAllowed",t[t.ServerUnreachable=1]="ServerUnreachable",t[t.InternalError=2]="InternalError",t[t.Cancelled=3]="Cancelled",t[t.LeaveRequest=4]="LeaveRequest",t[t.Timeout=5]="Timeout",t[t.WebSocket=6]="WebSocket",t[t.ServiceNotFound=7]="ServiceNotFound"})(xn||(xn={}));class ht extends Ai{constructor(e,n,r,i){super(1,e),this.name="ConnectionError",this.status=r,this.reason=n,this.context=i,this.reasonName=xn[n]}static notAllowed(e,n,r){return new ht(e,xn.NotAllowed,n,r)}static timeout(e){return new ht(e,xn.Timeout)}static leaveRequest(e,n){return new ht(e,xn.LeaveRequest,void 0,n)}static internal(e,n){return new ht(e,xn.InternalError,void 0,n)}static cancelled(e){return new ht(e,xn.Cancelled)}static serverUnreachable(e,n){return new ht(e,xn.ServerUnreachable,n)}static websocket(e,n,r){return new ht(e,xn.WebSocket,n,r)}static serviceNotFound(e,n){return new ht(e,xn.ServiceNotFound,void 0,n)}}class kx extends mo{constructor(e){super(21,e??"device is unsupported"),this.name="DeviceUnsupportedError"}}class da extends mo{constructor(e){super(20,e??"track is invalid"),this.name="TrackInvalidError"}}class lV extends mo{constructor(e){super(10,e??"unsupported server"),this.name="UnsupportedServer"}}class On extends mo{constructor(e){super(12,e??"unexpected connection state"),this.name="UnexpectedConnectionState"}}class nl extends mo{constructor(e){super(13,e??"unable to negotiate"),this.name="NegotiationError"}}class uC extends mo{constructor(e,n){super(15,e),this.name="PublishTrackError",this.status=n}}class dC extends Ai{constructor(e,n){super(15,e),this.name="SignalRequestError",this.reason=n,this.reasonName=typeof n=="string"?n:Ho[n]}}var Rr;(function(t){t[t.AlreadyOpened=0]="AlreadyOpened",t[t.AbnormalEnd=1]="AbnormalEnd",t[t.DecodeFailed=2]="DecodeFailed",t[t.LengthExceeded=3]="LengthExceeded",t[t.Incomplete=4]="Incomplete",t[t.HandlerAlreadyRegistered=7]="HandlerAlreadyRegistered",t[t.EncryptionTypeMismatch=8]="EncryptionTypeMismatch"})(Rr||(Rr={}));class Ei extends Ai{constructor(e,n){super(16,e),this.name="DataStreamError",this.reason=n,this.reasonName=Rr[n]}}class Jl extends mo{constructor(e){super(18,e),this.name="SignalReconnectError"}}var Gf;(function(t){t.PermissionDenied="PermissionDenied",t.NotFound="NotFound",t.DeviceInUse="DeviceInUse",t.Other="Other"})(Gf||(Gf={}));(function(t){function e(n){if(n&&"name"in n)return n.name==="NotFoundError"||n.name==="DevicesNotFoundError"?t.NotFound:n.name==="NotAllowedError"||n.name==="PermissionDeniedError"?t.PermissionDenied:n.name==="NotReadableError"||n.name==="TrackStartError"?t.DeviceInUse:t.Other}t.getFailure=e})(Gf||(Gf={}));class Qn{}Qn.setTimeout=function(){return setTimeout(...arguments)};Qn.setInterval=function(){return setInterval(...arguments)};Qn.clearTimeout=function(){return clearTimeout(...arguments)};Qn.clearInterval=function(){return clearInterval(...arguments)};var je;(function(t){t.Connected="connected",t.Reconnecting="reconnecting",t.SignalReconnecting="signalReconnecting",t.Reconnected="reconnected",t.Disconnected="disconnected",t.ConnectionStateChanged="connectionStateChanged",t.Moved="moved",t.MediaDevicesChanged="mediaDevicesChanged",t.ParticipantConnected="participantConnected",t.ParticipantDisconnected="participantDisconnected",t.TrackPublished="trackPublished",t.TrackSubscribed="trackSubscribed",t.TrackSubscriptionFailed="trackSubscriptionFailed",t.TrackUnpublished="trackUnpublished",t.TrackUnsubscribed="trackUnsubscribed",t.TrackMuted="trackMuted",t.TrackUnmuted="trackUnmuted",t.LocalTrackPublished="localTrackPublished",t.LocalTrackUnpublished="localTrackUnpublished",t.LocalAudioSilenceDetected="localAudioSilenceDetected",t.ActiveSpeakersChanged="activeSpeakersChanged",t.ParticipantMetadataChanged="participantMetadataChanged",t.ParticipantNameChanged="participantNameChanged",t.ParticipantAttributesChanged="participantAttributesChanged",t.ParticipantActive="participantActive",t.RoomMetadataChanged="roomMetadataChanged",t.DataReceived="dataReceived",t.SipDTMFReceived="sipDTMFReceived",t.TranscriptionReceived="transcriptionReceived",t.ConnectionQualityChanged="connectionQualityChanged",t.TrackStreamStateChanged="trackStreamStateChanged",t.TrackSubscriptionPermissionChanged="trackSubscriptionPermissionChanged",t.TrackSubscriptionStatusChanged="trackSubscriptionStatusChanged",t.AudioPlaybackStatusChanged="audioPlaybackChanged",t.VideoPlaybackStatusChanged="videoPlaybackChanged",t.MediaDevicesError="mediaDevicesError",t.ParticipantPermissionsChanged="participantPermissionsChanged",t.SignalConnected="signalConnected",t.RecordingStatusChanged="recordingStatusChanged",t.ParticipantEncryptionStatusChanged="participantEncryptionStatusChanged",t.EncryptionError="encryptionError",t.DCBufferStatusChanged="dcBufferStatusChanged",t.ActiveDeviceChanged="activeDeviceChanged",t.ChatMessage="chatMessage",t.LocalTrackSubscribed="localTrackSubscribed",t.MetricsReceived="metricsReceived",t.DataTrackPublished="dataTrackPublished",t.DataTrackUnpublished="dataTrackUnpublished",t.LocalDataTrackPublished="localDataTrackPublished",t.LocalDataTrackUnpublished="localDataTrackUnpublished"})(je||(je={}));var Be;(function(t){t.TrackPublished="trackPublished",t.TrackSubscribed="trackSubscribed",t.TrackSubscriptionFailed="trackSubscriptionFailed",t.TrackUnpublished="trackUnpublished",t.TrackUnsubscribed="trackUnsubscribed",t.TrackMuted="trackMuted",t.TrackUnmuted="trackUnmuted",t.LocalTrackPublished="localTrackPublished",t.LocalTrackUnpublished="localTrackUnpublished",t.LocalTrackCpuConstrained="localTrackCpuConstrained",t.LocalSenderCreated="localSenderCreated",t.ParticipantMetadataChanged="participantMetadataChanged",t.ParticipantNameChanged="participantNameChanged",t.DataReceived="dataReceived",t.SipDTMFReceived="sipDTMFReceived",t.TranscriptionReceived="transcriptionReceived",t.IsSpeakingChanged="isSpeakingChanged",t.ConnectionQualityChanged="connectionQualityChanged",t.TrackStreamStateChanged="trackStreamStateChanged",t.TrackSubscriptionPermissionChanged="trackSubscriptionPermissionChanged",t.TrackSubscriptionStatusChanged="trackSubscriptionStatusChanged",t.TrackCpuConstrained="trackCpuConstrained",t.MediaDevicesError="mediaDevicesError",t.AudioStreamAcquired="audioStreamAcquired",t.ParticipantPermissionsChanged="participantPermissionsChanged",t.PCTrackAdded="pcTrackAdded",t.AttributesChanged="attributesChanged",t.LocalTrackSubscribed="localTrackSubscribed",t.ChatMessage="chatMessage",t.Active="active"})(Be||(Be={}));var De;(function(t){t.TransportsCreated="transportsCreated",t.Connected="connected",t.Disconnected="disconnected",t.Resuming="resuming",t.Resumed="resumed",t.Restarting="restarting",t.Restarted="restarted",t.SignalResumed="signalResumed",t.SignalRestarted="signalRestarted",t.Closing="closing",t.MediaTrackAdded="mediaTrackAdded",t.ActiveSpeakersUpdate="activeSpeakersUpdate",t.DataPacketReceived="dataPacketReceived",t.RTPVideoMapUpdate="rtpVideoMapUpdate",t.DCBufferStatusChanged="dcBufferStatusChanged",t.ParticipantUpdate="participantUpdate",t.RoomUpdate="roomUpdate",t.SpeakersChanged="speakersChanged",t.StreamStateChanged="streamStateChanged",t.ConnectionQualityUpdate="connectionQualityUpdate",t.SubscriptionError="subscriptionError",t.SubscriptionPermissionUpdate="subscriptionPermissionUpdate",t.RemoteMute="remoteMute",t.SubscribedQualityUpdate="subscribedQualityUpdate",t.LocalTrackUnpublished="localTrackUnpublished",t.LocalTrackSubscribed="localTrackSubscribed",t.Offline="offline",t.SignalRequestResponse="signalRequestResponse",t.SignalConnected="signalConnected",t.RoomMoved="roomMoved",t.PublishDataTrackResponse="publishDataTrackResponse",t.UnPublishDataTrackResponse="unPublishDataTrackResponse",t.DataTrackSubscriberHandles="dataTrackSubscriberHandles",t.DataTrackPacketReceived="dataTrackPacketReceived",t.Joined="joined"})(De||(De={}));var Fe;(function(t){t.Message="message",t.Muted="muted",t.Unmuted="unmuted",t.Restarted="restarted",t.Ended="ended",t.Subscribed="subscribed",t.Unsubscribed="unsubscribed",t.CpuConstrained="cpuConstrained",t.UpdateSettings="updateSettings",t.UpdateSubscription="updateSubscription",t.AudioPlaybackStarted="audioPlaybackStarted",t.AudioPlaybackFailed="audioPlaybackFailed",t.AudioSilenceDetected="audioSilenceDetected",t.VisibilityChanged="visibilityChanged",t.VideoDimensionsChanged="videoDimensionsChanged",t.VideoPlaybackStarted="videoPlaybackStarted",t.VideoPlaybackFailed="videoPlaybackFailed",t.ElementAttached="elementAttached",t.ElementDetached="elementDetached",t.UpstreamPaused="upstreamPaused",t.UpstreamResumed="upstreamResumed",t.SubscriptionPermissionChanged="subscriptionPermissionChanged",t.SubscriptionStatusChanged="subscriptionStatusChanged",t.SubscriptionFailed="subscriptionFailed",t.TrackProcessorUpdate="trackProcessorUpdate",t.AudioTrackFeatureUpdate="audioTrackFeatureUpdate",t.TranscriptionReceived="transcriptionReceived",t.TimeSyncUpdate="timeSyncUpdate",t.PreConnectBufferFlushed="preConnectBufferFlushed"})(Fe||(Fe={}));function cV(t){return typeof t>"u"?t:typeof structuredClone=="function"?typeof t=="object"&&t!==null?structuredClone(Object.assign({},t)):structuredClone(t):JSON.parse(JSON.stringify(t))}class pn{constructor(e,n,r,i,s){if(typeof e=="object")this.width=e.width,this.height=e.height,this.aspectRatio=e.aspectRatio,this.encoding={maxBitrate:e.maxBitrate,maxFramerate:e.maxFramerate,priority:e.priority};else if(n!==void 0&&r!==void 0)this.width=e,this.height=n,this.aspectRatio=e/n,this.encoding={maxBitrate:r,maxFramerate:i,priority:s};else throw new TypeError("Unsupported options: provide at least width, height and maxBitrate")}get resolution(){return{width:this.width,height:this.height,frameRate:this.encoding.maxFramerate,aspectRatio:this.aspectRatio}}}const uV=["vp8","h264"],dV=["vp8","h264","vp9","av1","h265"];function hV(t){return!!uV.find(e=>e===t)}const fV=hV;var hC;(function(t){t[t.PREFER_REGRESSION=0]="PREFER_REGRESSION",t[t.SIMULCAST=1]="SIMULCAST",t[t.REGRESSION=2]="REGRESSION"})(hC||(hC={}));var Dv;(function(t){t.telephone={maxBitrate:12e3},t.speech={maxBitrate:24e3},t.music={maxBitrate:48e3},t.musicStereo={maxBitrate:64e3},t.musicHighQuality={maxBitrate:96e3},t.musicHighQualityStereo={maxBitrate:128e3}})(Dv||(Dv={}));const ud={h90:new pn(160,90,9e4,20),h180:new pn(320,180,16e4,20),h216:new pn(384,216,18e4,20),h360:new pn(640,360,45e4,20),h540:new pn(960,540,8e5,25),h720:new pn(1280,720,17e5,30),h1080:new pn(1920,1080,3e6,30),h1440:new pn(2560,1440,5e6,30),h2160:new pn(3840,2160,8e6,30)},Av={h120:new pn(160,120,7e4,20),h180:new pn(240,180,125e3,20),h240:new pn(320,240,14e4,20),h360:new pn(480,360,33e4,20),h480:new pn(640,480,5e5,20),h540:new pn(720,540,6e5,25),h720:new pn(960,720,13e5,30),h1080:new pn(1440,1080,23e5,30),h1440:new pn(1920,1440,38e5,30)},wx={h360fps3:new pn(640,360,2e5,3,"medium"),h360fps15:new pn(640,360,4e5,15,"medium"),h720fps5:new pn(1280,720,8e5,5,"medium"),h720fps15:new pn(1280,720,15e5,15,"medium"),h720fps30:new pn(1280,720,2e6,30,"medium"),h1080fps15:new pn(1920,1080,25e5,15,"medium"),h1080fps30:new pn(1920,1080,5e6,30,"medium"),original:new pn(0,0,7e6,30,"medium")};function MP(t,e,n){var r,i,s,a;const{optionsWithoutProcessor:c,audioProcessor:h,videoProcessor:d}=OP(t??{}),f=e==null?void 0:e.processor,p=n==null?void 0:n.processor,g=c??{};return g.audio===!0&&(g.audio={}),g.video===!0&&(g.video={}),g.audio&&(Ov(g.audio,e),(r=(s=g.audio).deviceId)!==null&&r!==void 0||(s.deviceId={ideal:"default"}),(h||f)&&(g.audio.processor=h??f)),g.video&&(Ov(g.video,n),(i=(a=g.video).deviceId)!==null&&i!==void 0||(a.deviceId={ideal:"default"}),(d||p)&&(g.video.processor=d??p)),g}function Ov(t,e){return Object.keys(e).forEach(n=>{t[n]===void 0&&(t[n]=e[n])}),t}function Sx(t){var e,n,r,i;const s={};if(t.video)if(typeof t.video=="object"){const a={},c=a,h=t.video;Object.keys(h).forEach(d=>{switch(d){case"resolution":Ov(c,h.resolution);break;default:c[d]=h[d]}}),s.video=a,(e=(r=s.video).deviceId)!==null&&e!==void 0||(r.deviceId={ideal:"default"})}else s.video=t.video?{deviceId:{ideal:"default"}}:!1;else s.video=!1;return t.audio?typeof t.audio=="object"?(s.audio=t.audio,(n=(i=s.audio).deviceId)!==null&&n!==void 0||(i.deviceId={ideal:"default"})):s.audio={deviceId:{ideal:"default"}}:s.audio=!1,s}function DP(t){return H(this,arguments,void 0,function(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:200;return(function*(){const r=AP();if(r){const i=r.createAnalyser();i.fftSize=2048;const s=i.frequencyBinCount,a=new Uint8Array(s);r.createMediaStreamSource(new MediaStream([e.mediaStreamTrack])).connect(i),yield Cr(n),i.getByteTimeDomainData(a);const h=a.some(d=>d!==128&&d!==0);return r.close(),!h}return!1})()})}function AP(){var t;const e=typeof window<"u"&&(window.AudioContext||window.webkitAudioContext);if(e){const n=new e({latencyHint:"interactive"});if(n.state==="suspended"&&typeof window<"u"&&(!((t=window.document)===null||t===void 0)&&t.body)){const r=()=>H(this,void 0,void 0,function*(){var i;try{n.state==="suspended"&&(yield n.resume())}catch(s){console.warn("Error trying to auto-resume audio context",s)}finally{(i=window.document.body)===null||i===void 0||i.removeEventListener("click",r)}});n.addEventListener("statechange",()=>{var i;n.state==="closed"&&((i=window.document.body)===null||i===void 0||i.removeEventListener("click",r))}),window.document.body.addEventListener("click",r)}return n}}function pV(t){return t==="audioinput"?Te.Source.Microphone:t==="videoinput"?Te.Source.Camera:Te.Source.Unknown}function Lv(t){return t===Te.Source.Microphone?"audioinput":t===Te.Source.Camera?"videoinput":void 0}function mV(t){var e,n;let r=(e=t.video)!==null&&e!==void 0?e:!0;return t.resolution&&t.resolution.width>0&&t.resolution.height>0&&(r=typeof r=="boolean"?{}:r,hl()?r=Object.assign(Object.assign({},r),{width:{max:t.resolution.width},height:{max:t.resolution.height},frameRate:t.resolution.frameRate}):r=Object.assign(Object.assign({},r),{width:{ideal:t.resolution.width},height:{ideal:t.resolution.height},frameRate:t.resolution.frameRate})),{audio:(n=t.audio)!==null&&n!==void 0?n:!1,video:r,controller:t.controller,selfBrowserSurface:t.selfBrowserSurface,surfaceSwitching:t.surfaceSwitching,systemAudio:t.systemAudio,preferCurrentTab:t.preferCurrentTab}}function Ku(t){return t.split("/")[1].toLowerCase()}function gV(t){const e=[];return t.forEach(n=>{n.track!==void 0&&e.push(new px({cid:n.track.mediaStreamID,track:n.trackInfo}))}),e}function Lt(t){return"mediaStreamTrack"in t?{trackID:t.sid,source:t.source,muted:t.isMuted,enabled:t.mediaStreamTrack.enabled,kind:t.kind,streamID:t.mediaStreamID,streamTrackID:t.mediaStreamTrack.id}:{trackID:t.trackSid,enabled:t.isEnabled,muted:t.isMuted,trackInfo:Object.assign({mimeType:t.mimeType,name:t.trackName,encrypted:t.isEncrypted,kind:t.kind,source:t.source},t.track?Lt(t.track):{})}}function vV(){return typeof RTCRtpReceiver<"u"&&"getSynchronizationSources"in RTCRtpReceiver}function yV(t,e){var n;t===void 0&&(t={}),e===void 0&&(e={});const r=[...Object.keys(e),...Object.keys(t)],i={};for(const s of r)t[s]!==e[s]&&(i[s]=(n=e[s])!==null&&n!==void 0?n:"");return i}function OP(t){const e=Object.assign({},t);let n,r;return typeof e.audio=="object"&&e.audio.processor&&(n=e.audio.processor,e.audio=Object.assign(Object.assign({},e.audio),{processor:void 0})),typeof e.video=="object"&&e.video.processor&&(r=e.video.processor,e.video=Object.assign(Object.assign({},e.video),{processor:void 0})),{audioProcessor:n,videoProcessor:r,optionsWithoutProcessor:cV(e)}}function xV(t){switch(t){case Xn.CAMERA:return Te.Source.Camera;case Xn.MICROPHONE:return Te.Source.Microphone;case Xn.SCREEN_SHARE:return Te.Source.ScreenShare;case Xn.SCREEN_SHARE_AUDIO:return Te.Source.ScreenShareAudio;default:return Te.Source.Unknown}}function fC(t,e){return t.width*t.height<e.width*e.height}function bV(t,e){var n;return(n=t.layers)===null||n===void 0?void 0:n.find(r=>r.quality===e)}const kV=5e3,Eu=[];var ui;(function(t){t[t.LOW=0]="LOW",t[t.MEDIUM=1]="MEDIUM",t[t.HIGH=2]="HIGH"})(ui||(ui={}));class Te extends Di.EventEmitter{get streamState(){return this._streamState}setStreamState(e){this._streamState=e}constructor(e,n){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};var i;super(),this.attachedElements=[],this.isMuted=!1,this._streamState=Te.StreamState.Active,this.isInBackground=!1,this._currentBitrate=0,this.log=Tt,this.appVisibilityChangedListener=()=>{this.backgroundTimeout&&clearTimeout(this.backgroundTimeout),document.visibilityState==="hidden"?this.backgroundTimeout=setTimeout(()=>this.handleAppVisibilityChanged(),kV):this.handleAppVisibilityChanged()},this.log=ei((i=r.loggerName)!==null&&i!==void 0?i:Nr.Track),this.loggerContextCb=r.loggerContextCb,this.setMaxListeners(100),this.kind=n,this._mediaStreamTrack=e,this._mediaStreamID=e.id,this.source=Te.Source.Unknown}get logContext(){var e;return Object.assign(Object.assign({},(e=this.loggerContextCb)===null||e===void 0?void 0:e.call(this)),Lt(this))}get currentBitrate(){return this._currentBitrate}get mediaStreamTrack(){return this._mediaStreamTrack}get mediaStreamID(){return this._mediaStreamID}attach(e){let n="audio";this.kind===Te.Kind.Video&&(n="video"),this.attachedElements.length===0&&this.kind===Te.Kind.Video&&this.addAppVisibilityListener(),e||(n==="audio"&&(Eu.forEach(s=>{s.parentElement===null&&!e&&(e=s)}),e&&Eu.splice(Eu.indexOf(e),1)),e||(e=document.createElement(n))),this.attachedElements.includes(e)||this.attachedElements.push(e),rc(this.mediaStreamTrack,e);const r=e.srcObject.getTracks(),i=r.some(s=>s.kind==="audio");return e.play().then(()=>{this.emit(i?Fe.AudioPlaybackStarted:Fe.VideoPlaybackStarted)}).catch(s=>{s.name==="NotAllowedError"?this.emit(i?Fe.AudioPlaybackFailed:Fe.VideoPlaybackFailed,s):s.name==="AbortError"?Tt.debug("".concat(i?"audio":"video"," playback aborted, likely due to new play request")):Tt.warn("could not playback ".concat(i?"audio":"video"),s),i&&e&&r.some(a=>a.kind==="video")&&s.name==="NotAllowedError"&&(e.muted=!0,e.play().catch(()=>{}))}),this.emit(Fe.ElementAttached,e),e}detach(e){try{if(e){hc(this.mediaStreamTrack,e);const r=this.attachedElements.indexOf(e);return r>=0&&(this.attachedElements.splice(r,1),this.recycleElement(e),this.emit(Fe.ElementDetached,e)),e}const n=[];return this.attachedElements.forEach(r=>{hc(this.mediaStreamTrack,r),n.push(r),this.recycleElement(r),this.emit(Fe.ElementDetached,r)}),this.attachedElements=[],n}finally{this.attachedElements.length===0&&this.removeAppVisibilityListener()}}stop(){this.stopMonitor(),this._mediaStreamTrack.stop()}enable(){this._mediaStreamTrack.enabled=!0}disable(){this._mediaStreamTrack.enabled=!1}stopMonitor(){this.monitorInterval&&clearInterval(this.monitorInterval),this.timeSyncHandle&&cancelAnimationFrame(this.timeSyncHandle)}updateLoggerOptions(e){e.loggerName&&(this.log=ei(e.loggerName)),e.loggerContextCb&&(this.loggerContextCb=e.loggerContextCb)}recycleElement(e){if(e instanceof HTMLAudioElement){let n=!0;e.pause(),Eu.forEach(r=>{r.parentElement||(n=!1)}),n&&Eu.push(e)}}handleAppVisibilityChanged(){return H(this,void 0,void 0,function*(){this.isInBackground=document.visibilityState==="hidden",!this.isInBackground&&this.kind===Te.Kind.Video&&setTimeout(()=>this.attachedElements.forEach(e=>e.play().catch(()=>{})),0)})}addAppVisibilityListener(){Yr()?(this.isInBackground=document.visibilityState==="hidden",document.addEventListener("visibilitychange",this.appVisibilityChangedListener)):this.isInBackground=!1}removeAppVisibilityListener(){Yr()&&document.removeEventListener("visibilitychange",this.appVisibilityChangedListener)}}function rc(t,e){let n;e.srcObject instanceof MediaStream?n=e.srcObject:n=new MediaStream;let r;t.kind==="audio"?r=n.getAudioTracks():r=n.getVideoTracks(),r.includes(t)||(r.forEach(i=>{n.removeTrack(i)}),n.addTrack(t)),(!hl()||!(e instanceof HTMLVideoElement))&&(e.autoplay=!0),e.muted=n.getAudioTracks().length===0,e instanceof HTMLVideoElement&&(e.playsInline=!0),e.srcObject!==n&&(e.srcObject=n,(hl()||dl())&&e instanceof HTMLVideoElement&&setTimeout(()=>{e.srcObject=n,e.play().catch(()=>{})},0))}function hc(t,e){if(e.srcObject instanceof MediaStream){const n=e.srcObject;n.removeTrack(t),n.getTracks().length>0?e.srcObject=n:e.srcObject=null}}(function(t){let e;(function(d){d.Audio="audio",d.Video="video",d.Unknown="unknown"})(e=t.Kind||(t.Kind={}));let n;(function(d){d.Camera="camera",d.Microphone="microphone",d.ScreenShare="screen_share",d.ScreenShareAudio="screen_share_audio",d.Unknown="unknown"})(n=t.Source||(t.Source={}));let r;(function(d){d.Active="active",d.Paused="paused",d.Unknown="unknown"})(r=t.StreamState||(t.StreamState={}));function i(d){switch(d){case e.Audio:return Ki.AUDIO;case e.Video:return Ki.VIDEO;default:return Ki.DATA}}t.kindToProto=i;function s(d){switch(d){case Ki.AUDIO:return e.Audio;case Ki.VIDEO:return e.Video;default:return e.Unknown}}t.kindFromProto=s;function a(d){switch(d){case n.Camera:return Xn.CAMERA;case n.Microphone:return Xn.MICROPHONE;case n.ScreenShare:return Xn.SCREEN_SHARE;case n.ScreenShareAudio:return Xn.SCREEN_SHARE_AUDIO;default:return Xn.UNKNOWN}}t.sourceToProto=a;function c(d){switch(d){case Xn.CAMERA:return n.Camera;case Xn.MICROPHONE:return n.Microphone;case Xn.SCREEN_SHARE:return n.ScreenShare;case Xn.SCREEN_SHARE_AUDIO:return n.ScreenShareAudio;default:return n.Unknown}}t.sourceFromProto=c;function h(d){switch(d){case Sv.ACTIVE:return r.Active;case Sv.PAUSED:return r.Paused;default:return r.Unknown}}t.streamStateFromProto=h})(Te||(Te={}));const wV="|",pC="https://aomediacodec.github.io/av1-rtp-spec/#dependency-descriptor-rtp-header-extension";function SV(t){const e=t.split(wV);return e.length>1?[e[0],t.substr(e[0].length+1)]:[t,""]}function Cr(t){return new Sr(e=>Qn.setTimeout(e,t))}function Fv(){return"addTransceiver"in RTCPeerConnection.prototype}function Uv(){return"addTrack"in RTCPeerConnection.prototype}function CV(){if(!("getCapabilities"in RTCRtpSender)||hl()||dl())return!1;const t=RTCRtpSender.getCapabilities("video");let e=!1;if(t){for(const n of t.codecs)if(n.mimeType.toLowerCase()==="video/av1"){e=!0;break}}return e}function TV(){if(!("getCapabilities"in RTCRtpSender)||dl())return!1;if(hl()){const n=Qr();if(n!=null&&n.version&&Ls(n.version,"16")<0||(n==null?void 0:n.os)==="iOS"&&(n!=null&&n.osVersion)&&Ls(n.osVersion,"16")<0)return!1}const t=RTCRtpSender.getCapabilities("video");let e=!1;if(t){for(const n of t.codecs)if(n.mimeType.toLowerCase()==="video/vp9"){e=!0;break}}return e}function Ji(t){return t==="av1"||t==="vp9"}function Bv(t){return!document||dd()?!1:(t||(t=document.createElement("audio")),"setSinkId"in t)}function NV(){return typeof RTCPeerConnection>"u"?!1:Fv()||Uv()}function dl(){var t;return((t=Qr())===null||t===void 0?void 0:t.name)==="Firefox"}function mC(){const t=Qr();return!!t&&t.name==="Chrome"&&t.os!=="iOS"}function hl(){var t;return((t=Qr())===null||t===void 0?void 0:t.name)==="Safari"}function dd(){const t=Qr();return(t==null?void 0:t.name)==="Safari"||(t==null?void 0:t.os)==="iOS"}function EV(){const t=Qr();return(t==null?void 0:t.name)==="Safari"&&t.version.startsWith("17.")||(t==null?void 0:t.os)==="iOS"&&!!(t!=null&&t.osVersion)&&Ls(t.osVersion,"17")>=0}function jV(t){return t||(t=Qr()),(t==null?void 0:t.name)==="Safari"&&Ls(t.version,"18.3")>0||(t==null?void 0:t.os)==="iOS"&&!!(t!=null&&t.osVersion)&&Ls(t.osVersion,"18.3")>0}function LP(){var t,e;return Yr()?(e=(t=navigator.userAgentData)===null||t===void 0?void 0:t.mobile)!==null&&e!==void 0?e:/Tablet|iPad|Mobile|Android|BlackBerry/.test(navigator.userAgent):!1}function PV(){const t=Qr(),e="17.2";if(t)return t.name!=="Safari"&&t.os!=="iOS"||t.os==="iOS"&&t.osVersion&&Ls(t.osVersion,e)>=0?!0:t.name==="Safari"&&Ls(t.version,e)>=0}function Yr(){return typeof document<"u"}function Os(){return navigator.product=="ReactNative"}function Sc(t){return t.hostname.endsWith(".livekit.cloud")||t.hostname.endsWith(".livekit.run")}function y0(t){return Sc(t)?t.hostname.split(".")[0]:null}function FP(){if(global&&global.LiveKitReactNativeGlobal)return global.LiveKitReactNativeGlobal}function UP(){if(!Os())return;let t=FP();if(t)return t.platform}function gC(){if(Yr())return window.devicePixelRatio;if(Os()){let t=FP();if(t)return t.devicePixelRatio}return 1}function Ls(t,e){const n=t.split("."),r=e.split("."),i=Math.min(n.length,r.length);for(let s=0;s<i;++s){const a=parseInt(n[s],10),c=parseInt(r[s],10);if(a>c)return 1;if(a<c)return-1;if(s===i-1&&a===c)return 0}return t===""&&e!==""?-1:e===""?1:n.length==r.length?0:n.length<r.length?-1:1}function _V(t){for(const e of t)e.target.handleResize(e)}function RV(t){for(const e of t)e.target.handleVisibilityChanged(e)}let x0=null;const vC=()=>(x0||(x0=new ResizeObserver(_V)),x0);let b0=null;const yC=()=>(b0||(b0=new IntersectionObserver(RV,{root:null,rootMargin:"0px"})),b0);function IV(){var t;const e=new O2({sdk:L2.JS,protocol:oV,version:aV});return Os()&&(e.os=(t=UP())!==null&&t!==void 0?t:""),e}function xC(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:16,e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:16,n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1,r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1;const i=document.createElement("canvas");i.width=t,i.height=e;const s=i.getContext("2d");s==null||s.fillRect(0,0,i.width,i.height),r&&s&&(s.beginPath(),s.arc(t/2,e/2,50,0,Math.PI*2,!0),s.closePath(),s.fillStyle="grey",s.fill());const a=i.captureStream(),[c]=a.getTracks();if(!c)throw Error("Could not get empty media stream video track");return c.enabled=n,c}let ju;function k0(){if(!ju){const t=new AudioContext,e=t.createOscillator(),n=t.createGain();n.gain.setValueAtTime(0,0);const r=t.createMediaStreamDestination();if(e.connect(n),n.connect(r),e.start(),[ju]=r.stream.getAudioTracks(),!ju)throw Error("Could not get empty media stream audio track");ju.enabled=!1}return ju.clone()}class Jr{get isResolved(){return this._isResolved}constructor(e,n){this._isResolved=!1,this.onFinally=n,this.promise=new Promise((r,i)=>H(this,void 0,void 0,function*(){this.resolve=r,this.reject=i,e&&(yield e(r,i))})).finally(()=>{var r;this._isResolved=!0,(r=this.onFinally)===null||r===void 0||r.call(this)})}}function MV(t){return dV.includes(t)}function rl(t){if(typeof t=="string"||typeof t=="number")return t;if(Array.isArray(t))return t[0];if(t.exact!==void 0)return Array.isArray(t.exact)?t.exact[0]:t.exact;if(t.ideal!==void 0)return Array.isArray(t.ideal)?t.ideal[0]:t.ideal;throw Error("could not unwrap constraint")}function DV(t){return t.startsWith("http")?t.replace(/^(http)/,"ws"):t}function hd(t){return t.startsWith("ws")?t.replace(/^(ws)/,"http"):t}function AV(t,e){return t.segments.map(n=>{let{id:r,text:i,language:s,startTime:a,endTime:c,final:h}=n;var d;const f=(d=e.get(r))!==null&&d!==void 0?d:Date.now(),p=Date.now();return h?e.delete(r):e.set(r,f),{id:r,text:i,startTime:Number.parseInt(a.toString()),endTime:Number.parseInt(c.toString()),final:h,language:s,firstReceivedTime:f,lastReceivedTime:p}})}function OV(t){const{id:e,timestamp:n,message:r,editTimestamp:i}=t;return{id:e,timestamp:Number.parseInt(n.toString()),editTimestamp:i?Number.parseInt(i.toString()):void 0,message:r}}function bC(t){switch(t.reason){case xn.LeaveRequest:return t.context;case xn.Cancelled:return ts.CLIENT_INITIATED;case xn.NotAllowed:return ts.USER_REJECTED;case xn.ServerUnreachable:return ts.JOIN_FAILURE;default:return ts.UNKNOWN_REASON}}function Ef(t){return t!==void 0?Number(t):void 0}function $o(t){return t!==void 0?BigInt(t):void 0}function fc(t){return!!t&&!(t instanceof MediaStreamTrack)&&t.isLocal}function Ts(t){return!!t&&t.kind==Te.Kind.Audio}function go(t){return!!t&&t.kind==Te.Kind.Video}function Wa(t){return fc(t)&&go(t)}function aa(t){return fc(t)&&Ts(t)}function zv(t){return!!t&&!t.isLocal}function LV(t){return!!t&&!t.isLocal}function w0(t){return zv(t)&&go(t)}function FV(t){return t.isLocal}function UV(t,e){const n=[];let r=new TextEncoder().encode(t);for(;r.length>e;){let i=e;for(;i>0;){const s=r[i];if(s!==void 0&&(s&192)!==128)break;i--}n.push(r.slice(0,i)),r=r.slice(i)}return r.length>0&&n.push(r),n}function BV(t){var e;const n=t.get("Cache-Control");if(n){const r=(e=n.match(/(?:^|[,\s])max-age=(\d+)/))===null||e===void 0?void 0:e[1];if(r)return parseInt(r,10)}}function $v(){return typeof CompressionStream<"u"}function zV(t,e){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;const r=$V(t,e);return n?r:Cx(r,"v1")}function $V(t,e){const n=new URL(DV(t));return e.forEach((r,i)=>{n.searchParams.set(i,r)}),Cx(n,"rtc")}function VV(t){const e=new URL(hd(t));return Cx(e,"validate")}function BP(t){return t.endsWith("/")?t:"".concat(t,"/")}function Cx(t,e){return t.pathname="".concat(BP(t.pathname)).concat(e),t}function kC(t){if(typeof t=="string")return ZS.fromJson(JSON.parse(t),{ignoreUnknownFields:!0});if(t instanceof ArrayBuffer)return ZS.fromBinary(new Uint8Array(t));throw new Error("could not decode websocket message: ".concat(typeof t))}function WV(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"Unknown reason";if(!(t instanceof AbortSignal))return e;const n=t.reason;switch(typeof n){case"string":return n;case"object":return n instanceof Error?n.message:e;default:return"toString"in n?n.toString():e}}const HV=10,Pu="lk_e2ee",qV="LKFrameEncryptionKey",KV={sharedKey:!1,ratchetSalt:qV,ratchetWindowSize:8,failureTolerance:HV,keyringSize:16,keySize:128};var io;(function(t){t.SetKey="setKey",t.RatchetRequest="ratchetRequest",t.KeyRatcheted="keyRatcheted"})(io||(io={}));var wC;(function(t){t.KeyRatcheted="keyRatcheted"})(wC||(wC={}));var Za;(function(t){t.ParticipantEncryptionStatusChanged="participantEncryptionStatusChanged",t.EncryptionError="encryptionError"})(Za||(Za={}));var SC;(function(t){t.Error="cryptorError"})(SC||(SC={}));function GV(){return YV()||Vv()}function Vv(){return typeof window.RTCRtpScriptTransform<"u"}function YV(){return typeof window.RTCRtpSender<"u"&&typeof window.RTCRtpSender.prototype.createEncodedStreams<"u"}function JV(t){var e,n,r,i,s;if(((e=t.value)===null||e===void 0?void 0:e.case)!=="sipDtmf"&&((n=t.value)===null||n===void 0?void 0:n.case)!=="metrics"&&((r=t.value)===null||r===void 0?void 0:r.case)!=="speaker"&&((i=t.value)===null||i===void 0?void 0:i.case)!=="transcription"&&((s=t.value)===null||s===void 0?void 0:s.case)!=="encryptedPacket")return new P2({value:t.value})}class XX extends Di.EventEmitter{constructor(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};super(),this.latestManuallySetKeyIndex=0,this.onKeyRatcheted=(n,r,i)=>{Tt.debug("key ratcheted event received",{ratchetResult:n,participantId:r,keyIndex:i})},this.keyInfoMap=new Map,this.options=Object.assign(Object.assign({},KV),e),this.on(io.KeyRatcheted,this.onKeyRatcheted)}onSetEncryptionKey(e,n,r){const i={key:e,participantIdentity:n,keyIndex:r};if(!this.options.sharedKey&&!n)throw new Error("participant identity needs to be passed for encryption key if sharedKey option is false");this.keyInfoMap.set("".concat(n??"shared","-").concat(r??0),i),r!==void 0&&(this.latestManuallySetKeyIndex=r),this.emit(io.SetKey,i,r!==void 0)}getKeys(){return Array.from(this.keyInfoMap.values())}getLatestManuallySetKeyIndex(){return this.latestManuallySetKeyIndex}getOptions(){return this.options}ratchetKey(e,n){this.emit(io.RatchetRequest,e,n)}}var CC;(function(t){t[t.InvalidKey=0]="InvalidKey",t[t.MissingKey=1]="MissingKey",t[t.InternalError=2]="InternalError"})(CC||(CC={}));class XV extends Di.EventEmitter{constructor(e,n){super(),this.decryptDataRequests=new Map,this.encryptDataRequests=new Map,this.onWorkerMessage=r=>{var i,s;const{kind:a,data:c}=r.data;switch(a){case"error":if(Tt.error(c.error.message),c.uuid){const f=this.decryptDataRequests.get(c.uuid);if(f!=null&&f.reject){f.reject(c.error);break}const p=this.encryptDataRequests.get(c.uuid);if(p!=null&&p.reject){p.reject(c.error);break}}this.emit(Za.EncryptionError,c.error,c.participantIdentity);break;case"initAck":c.enabled&&this.keyProvider.getKeys().forEach(f=>{this.postKey(f,!1)});break;case"enable":if(c.enabled&&this.keyProvider.getKeys().forEach(f=>{this.postKey(f,!1)}),this.encryptionEnabled!==c.enabled&&c.participantIdentity===((i=this.room)===null||i===void 0?void 0:i.localParticipant.identity))this.emit(Za.ParticipantEncryptionStatusChanged,c.enabled,this.room.localParticipant),this.encryptionEnabled=c.enabled;else if(c.participantIdentity){const f=(s=this.room)===null||s===void 0?void 0:s.getParticipantByIdentity(c.participantIdentity);if(!f)throw TypeError("couldn't set encryption status, participant not found".concat(c.participantIdentity));this.emit(Za.ParticipantEncryptionStatusChanged,c.enabled,f)}break;case"ratchetKey":this.keyProvider.emit(io.KeyRatcheted,c.ratchetResult,c.participantIdentity,c.keyIndex);break;case"decryptDataResponse":const h=this.decryptDataRequests.get(c.uuid);h!=null&&h.resolve&&h.resolve(c);break;case"encryptDataResponse":const d=this.encryptDataRequests.get(c.uuid);d!=null&&d.resolve&&d.resolve(c);break}},this.onWorkerError=r=>{Tt.error("e2ee worker encountered an error:",{error:r.error}),this.emit(Za.EncryptionError,r.error,void 0)},this.keyProvider=e.keyProvider,this.worker=e.worker,this.encryptionEnabled=!1,this.dataChannelEncryptionEnabled=n}get isEnabled(){return this.encryptionEnabled}get isDataChannelEncryptionEnabled(){return this.isEnabled&&this.dataChannelEncryptionEnabled}setup(e){if(!GV())throw new kx("tried to setup end-to-end encryption on an unsupported browser");if(Tt.info("setting up e2ee"),e!==this.room){this.room=e,this.setupEventListeners(e,this.keyProvider);const n={kind:"init",data:{keyProviderOptions:this.keyProvider.getOptions(),loglevel:$$.getLevel()}};this.worker&&(Tt.info("initializing worker",{worker:this.worker}),this.worker.onmessage=this.onWorkerMessage,this.worker.onerror=this.onWorkerError,this.worker.postMessage(n))}}setParticipantCryptorEnabled(e,n){Tt.debug("set e2ee to ".concat(e," for participant ").concat(n)),this.postEnable(e,n)}setSifTrailer(e){!e||e.length===0?Tt.warn("ignoring server sent trailer as it's empty"):this.postSifTrailer(e)}setupEngine(e){e.on(De.RTPVideoMapUpdate,n=>{this.postRTPMap(n)})}setupEventListeners(e,n){e.on(je.TrackPublished,(r,i)=>this.setParticipantCryptorEnabled(r.trackInfo.encryption!==bn.NONE,i.identity)),e.on(je.ConnectionStateChanged,r=>{r===Xt.Connected&&e.remoteParticipants.forEach(i=>{i.trackPublications.forEach(s=>{this.setParticipantCryptorEnabled(s.trackInfo.encryption!==bn.NONE,i.identity)})})}).on(je.TrackUnsubscribed,(r,i,s)=>{var a;const c={kind:"removeTransform",data:{participantIdentity:s.identity,trackId:r.mediaStreamID}};(a=this.worker)===null||a===void 0||a.postMessage(c)}).on(je.TrackSubscribed,(r,i,s)=>{this.setupE2EEReceiver(r,s.identity,i.trackInfo)}).on(je.SignalConnected,()=>{if(!this.room)throw new TypeError("expected room to be present on signal connect");const r=n.getLatestManuallySetKeyIndex();n.getKeys().forEach(i=>{var s;this.postKey(i,r===((s=i.keyIndex)!==null&&s!==void 0?s:0))}),this.setParticipantCryptorEnabled(this.room.localParticipant.isE2EEEnabled,this.room.localParticipant.identity)}),e.localParticipant.on(Be.LocalSenderCreated,(r,i)=>H(this,void 0,void 0,function*(){this.setupE2EESender(i,r)})),e.localParticipant.on(Be.LocalTrackPublished,r=>{if(!go(r.track)||!dd())return;const i={kind:"updateCodec",data:{trackId:r.track.mediaStreamID,codec:Ku(r.trackInfo.codecs[0].mimeType),participantIdentity:this.room.localParticipant.identity}};this.worker.postMessage(i)}),n.on(io.SetKey,(r,i)=>this.postKey(r,i??!0)).on(io.RatchetRequest,(r,i)=>this.postRatchetRequest(r,i))}encryptData(e){return H(this,void 0,void 0,function*(){if(!this.worker)throw Error("could not encrypt data, worker is missing");const n=crypto.randomUUID(),r={kind:"encryptDataRequest",data:{uuid:n,payload:e,participantIdentity:this.room.localParticipant.identity}},i=new Jr;return i.onFinally=()=>{this.encryptDataRequests.delete(n)},this.encryptDataRequests.set(n,i),this.worker.postMessage(r),i.promise})}handleEncryptedData(e,n,r,i){if(!this.worker)throw Error("could not handle encrypted data, worker is missing");const s=crypto.randomUUID(),a={kind:"decryptDataRequest",data:{uuid:s,payload:e,iv:n,participantIdentity:r,keyIndex:i}},c=new Jr;return c.onFinally=()=>{this.decryptDataRequests.delete(s)},this.decryptDataRequests.set(s,c),this.worker.postMessage(a),c.promise}postRatchetRequest(e,n){if(!this.worker)throw Error("could not ratchet key, worker is missing");const r={kind:"ratchetRequest",data:{participantIdentity:e,keyIndex:n}};this.worker.postMessage(r)}postKey(e,n){let{key:r,participantIdentity:i,keyIndex:s}=e;var a;if(!this.worker)throw Error("could not set key, worker is missing");const c={kind:"setKey",data:{participantIdentity:i,isPublisher:i===((a=this.room)===null||a===void 0?void 0:a.localParticipant.identity),key:r,keyIndex:s,updateCurrentKeyIndex:n}};this.worker.postMessage(c)}postEnable(e,n){if(this.worker){const r={kind:"enable",data:{enabled:e,participantIdentity:n}};this.worker.postMessage(r)}else throw new ReferenceError("failed to enable e2ee, worker is not ready")}postRTPMap(e){var n;if(!this.worker)throw TypeError("could not post rtp map, worker is missing");if(!(!((n=this.room)===null||n===void 0)&&n.localParticipant.identity))throw TypeError("could not post rtp map, local participant identity is missing");const r={kind:"setRTPMap",data:{map:e,participantIdentity:this.room.localParticipant.identity}};this.worker.postMessage(r)}postSifTrailer(e){if(!this.worker)throw Error("could not post SIF trailer, worker is missing");const n={kind:"setSifTrailer",data:{trailer:e}};this.worker.postMessage(n)}setupE2EEReceiver(e,n,r){if(e.receiver){if(!(r!=null&&r.mimeType)||r.mimeType==="")throw new TypeError("MimeType missing from trackInfo, cannot set up E2EE cryptor");this.handleReceiver(e.receiver,e.mediaStreamID,n,e.kind==="video"?Ku(r.mimeType):void 0)}}setupE2EESender(e,n){if(!fc(e)||!n){n||Tt.warn("early return because sender is not ready");return}this.handleSender(n,e.mediaStreamID,void 0)}handleReceiver(e,n,r,i){return H(this,void 0,void 0,function*(){if(this.worker){if(Vv()&&!mC()){const s={kind:"decode",participantIdentity:r,trackId:n,codec:i};e.transform=new RTCRtpScriptTransform(this.worker,s)}else{if(Pu in e&&i){const h={kind:"updateCodec",data:{trackId:n,codec:i,participantIdentity:r}};this.worker.postMessage(h);return}let s=e.writableStream,a=e.readableStream;if(!s||!a){const h=e.createEncodedStreams();e.writableStream=h.writable,s=h.writable,e.readableStream=h.readable,a=h.readable}const c={kind:"decode",data:{readableStream:a,writableStream:s,trackId:n,codec:i,participantIdentity:r,isReuse:Pu in e}};this.worker.postMessage(c,[a,s])}e[Pu]=!0}})}handleSender(e,n,r){var i;if(!(Pu in e||!this.worker)){if(!(!((i=this.room)===null||i===void 0)&&i.localParticipant.identity)||this.room.localParticipant.identity==="")throw TypeError("local identity needs to be known in order to set up encrypted sender");if(Vv()&&!mC()){Tt.info("initialize script transform");const s={kind:"encode",participantIdentity:this.room.localParticipant.identity,trackId:n,codec:r};e.transform=new RTCRtpScriptTransform(this.worker,s)}else{Tt.info("initialize encoded streams");const s=e.createEncodedStreams(),a={kind:"encode",data:{readableStream:s.readable,writableStream:s.writable,codec:r,trackId:n,participantIdentity:this.room.localParticipant.identity,isReuse:!1}};this.worker.postMessage(a,[s.readable,s.writable])}e[Pu]=!0}}}const QV=500,ZV=15e3;class pc{constructor(){this.failedConnectionAttempts=new Map,this.backOffPromises=new Map}static getInstance(){return this._instance||(this._instance=new pc),this._instance}addFailedConnectionAttempt(e){var n;const r=new URL(e),i=y0(r);if(!i)return;let s=(n=this.failedConnectionAttempts.get(i))!==null&&n!==void 0?n:0;this.failedConnectionAttempts.set(i,s+1),this.backOffPromises.set(i,Cr(Math.min(QV*Math.pow(2,s),ZV)))}getBackOffPromise(e){const n=new URL(e),r=n&&y0(n);return r&&this.backOffPromises.get(r)||Promise.resolve()}resetFailedConnectionAttempts(e){const n=new URL(e),r=n&&y0(n);r&&(this.failedConnectionAttempts.set(r,0),this.backOffPromises.set(r,Promise.resolve()))}resetAll(){this.backOffPromises.clear(),this.failedConnectionAttempts.clear()}}pc._instance=null;const S0="default";class cr{constructor(){this._previousDevices=[]}static getInstance(){return this.instance===void 0&&(this.instance=new cr),this.instance}get previousDevices(){return this._previousDevices}getDevices(e){return H(this,arguments,void 0,function(n){var r=this;let i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0;return(function*(){var s;if(((s=cr.userMediaPromiseMap)===null||s===void 0?void 0:s.size)>0){Tt.debug("awaiting getUserMedia promise");try{n?yield cr.userMediaPromiseMap.get(n):yield Promise.all(cr.userMediaPromiseMap.values())}catch{Tt.warn("error waiting for media permissons")}}let a=yield navigator.mediaDevices.enumerateDevices();if(i&&!(hl()&&r.hasDeviceInUse(n))&&(a.filter(h=>h.kind===n).length===0||a.some(h=>{const d=h.label==="",f=n?h.kind===n:!0;return d&&f}))){const h={video:n!=="audioinput"&&n!=="audiooutput",audio:n!=="videoinput"&&{deviceId:{ideal:"default"}}},d=yield navigator.mediaDevices.getUserMedia(h);a=yield navigator.mediaDevices.enumerateDevices(),d.getTracks().forEach(f=>{f.stop()})}return r._previousDevices=a,n&&(a=a.filter(c=>c.kind===n)),a})()})}normalizeDeviceId(e,n,r){return H(this,void 0,void 0,function*(){if(n!==S0)return n;const i=yield this.getDevices(e),s=i.find(c=>c.deviceId===S0);if(!s){Tt.warn("could not reliably determine default device");return}const a=i.find(c=>c.deviceId!==S0&&c.groupId===(r??s.groupId));if(!a){Tt.warn("could not reliably determine default device");return}return a==null?void 0:a.deviceId})}hasDeviceInUse(e){return e?cr.userMediaPromiseMap.has(e):cr.userMediaPromiseMap.size>0}}cr.mediaDeviceKinds=["audioinput","audiooutput","videoinput"];cr.userMediaPromiseMap=new Map;const Tx=65535,zP=4294967295;class ns{static u16(e){return new ns(e,Tx)}static u32(e){return new ns(e,zP)}constructor(e,n){if(this.value=e,e<0)throw new Error("WrapAroundUnsignedInt: cannot faithfully represent an integer smaller than 0");if(n>Number.MAX_SAFE_INTEGER)throw new Error("WrapAroundUnsignedInt: cannot faithfully represent an integer bigger than MAX_SAFE_INTEGER.");this.maxSize=n,this.clamp()}clamp(){for(;this.value>this.maxSize;)this.value-=this.maxSize+1;for(;this.value<0;)this.value+=this.maxSize+1}clone(){return new ns(this.value,this.maxSize)}update(e){this.value=e(this.value),this.clamp()}increment(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:1;this.update(n=>n+e)}decrement(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:1;this.update(n=>n-e)}getThenIncrement(){const e=this.value;return this.increment(),new ns(e,this.maxSize)}isBefore(e){const n=this.value>>>0,i=(e.value>>>0)-n>>>0;return i!==0&&i<this.maxSize+1}}class mc{static fromRtpTicks(e){return new mc(e,9e4)}static rtpRandom(){const e=Math.round(Math.random()*zP);return mc.fromRtpTicks(e)}constructor(e,n){this.timestamp=ns.u32(e),this.rateInHz=n}asTicks(){return this.timestamp.value}clone(){return new mc(this.timestamp.value,this.rateInHz)}wrappingAdd(e){this.timestamp.increment(e)}isBefore(e){return this.timestamp.isBefore(e.timestamp)}}class qo{constructor(e,n,r){this.epoch=n,this.base=r,this.previous=r.clone(),this.rateInHz=e}static startingNow(e,n){return new qo(n,new Date,e)}static startingAtTime(e,n,r){return new qo(r,e,n)}static rtpStartingNow(e){return qo.startingNow(e,9e4)}static rtpStartingAtTime(e,n){return qo.startingAtTime(e,n,9e4)}now(){return this.at(new Date)}at(e){let n=e.getTime()-this.epoch.getTime(),r=qo.durationInMsToTicks(n,this.rateInHz),i=this.base.clone();return i.wrappingAdd(r),i.isBefore(this.previous)&&(i=this.previous),this.previous=i.clone(),i.clone()}static durationInMsToTicks(e,n){let i=(e*1e6*n+5e8)/1e9;return Math.round(i)}}function Nx(t){if(t instanceof DataView)return t;if(t instanceof ArrayBuffer)return new DataView(t);if(t instanceof Uint8Array)return new DataView(t.buffer,t.byteOffset,t.byteLength);throw new Error("Error coercing ".concat(t," to DataView - input was not DataView, ArrayBuffer, or Uint8Array."))}var il;(function(t){t[t.Reserved=0]="Reserved",t[t.TooLarge=1]="TooLarge"})(il||(il={}));class Cc extends Ai{constructor(e,n){super(19,e),this.name="DataTrackHandleError",this.reason=n,this.reasonName=il[n]}isReason(e){return this.reason===e}static tooLarge(){return new Cc("Value too large to be a valid track handle",il.TooLarge)}static reserved(e){return new Cc("0x".concat(e.toString(16)," is a reserved value."),il.Reserved)}}const eW={fromNumber(t){if(t===0)throw Cc.reserved(t);if(t>Tx)throw Cc.tooLarge();return t}};class tW{constructor(){this.value=0}get(){return this.value+=1,this.value>Tx?null:this.value}}const Yf={from(t){return{sid:t.sid,pubHandle:t.pubHandle,name:t.name,usesE2ee:t.encryption!==bn.NONE}},toProtobuf(t){return new Np({sid:t.sid,pubHandle:t.pubHandle,name:t.name,encryption:t.usesE2ee?bn.GCM:bn.NONE})}};var Gu;(function(t){t[t.WAITING=0]="WAITING",t[t.RUNNING=1]="RUNNING",t[t.COMPLETED=2]="COMPLETED"})(Gu||(Gu={}));class nW{constructor(){this.pendingTasks=new Map,this.taskMutex=new fr,this.nextTaskIndex=0}run(e){return H(this,void 0,void 0,function*(){const n={id:this.nextTaskIndex++,enqueuedAt:Date.now(),status:Gu.WAITING};this.pendingTasks.set(n.id,n);const r=yield this.taskMutex.lock();try{return n.executedAt=Date.now(),n.status=Gu.RUNNING,yield e()}finally{n.status=Gu.COMPLETED,this.pendingTasks.delete(n.id),r()}})}flush(){return H(this,void 0,void 0,function*(){return this.run(()=>H(this,void 0,void 0,function*(){}))})}snapshot(){return Array.from(this.pendingTasks.values())}}class rW{get readyState(){return this.ws.readyState}constructor(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};var r,i;if(!((r=n.signal)===null||r===void 0)&&r.aborted)throw new DOMException("This operation was aborted","AbortError");this.url=e;const s=new WebSocket(e,(i=n.protocols)!==null&&i!==void 0?i:[]);s.binaryType="arraybuffer",this.ws=s;const a=function(){let{closeCode:c,reason:h}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return s.close(c,h)};this.opened=new Sr((c,h)=>{const d=()=>{h(ht.websocket("Encountered websocket error during connection establishment"))};s.onopen=()=>{c({readable:new ReadableStream({start(f){s.onmessage=p=>{let{data:g}=p;return f.enqueue(g)},s.onerror=p=>f.error(p)},cancel:a}),writable:new WritableStream({write(f){s.send(f)},abort(){s.close()},close:a}),protocol:s.protocol,extensions:s.extensions}),s.removeEventListener("error",d)},s.addEventListener("error",d)}),this.closed=new Sr((c,h)=>{const d=()=>H(this,void 0,void 0,function*(){const f=new Sr(g=>{s.readyState!==WebSocket.CLOSED&&s.addEventListener("close",v=>{g(v)},{once:!0})}),p=yield Sr.race([Cr(250),f]);p?c(p):h(ht.websocket("Encountered unspecified websocket error without a timely close event"))});s.onclose=f=>{let{code:p,reason:g}=f;c({closeCode:p,reason:g}),s.removeEventListener("error",d)},s.addEventListener("error",d)}),n.signal&&(n.signal.onabort=()=>s.close()),this.close=a}}const iW=["syncState","trickle","offer","answer","simulate","leave"];function sW(t){const e=iW.indexOf(t.case)>=0;return Tt.trace("request allowed to bypass queue:",{canPass:e,req:t}),e}var yn;(function(t){t[t.CONNECTING=0]="CONNECTING",t[t.CONNECTED=1]="CONNECTED",t[t.RECONNECTING=2]="RECONNECTING",t[t.DISCONNECTING=3]="DISCONNECTING",t[t.DISCONNECTED=4]="DISCONNECTED"})(yn||(yn={}));const aW=250;class Ex{get currentState(){return this.state}get isDisconnected(){return this.state===yn.DISCONNECTING||this.state===yn.DISCONNECTED}get isEstablishingConnection(){return this.state===yn.CONNECTING||this.state===yn.RECONNECTING}getNextRequestId(){return this._requestId+=1,this._requestId}constructor(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1,n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};var r;this.rtt=0,this.state=yn.DISCONNECTED,this.log=Tt,this._requestId=0,this.useV0SignalPath=!1,this.resetCallbacks=()=>{this.onAnswer=void 0,this.onLeave=void 0,this.onLocalTrackPublished=void 0,this.onLocalTrackUnpublished=void 0,this.onNegotiateRequested=void 0,this.onOffer=void 0,this.onRemoteMuteChanged=void 0,this.onSubscribedQualityUpdate=void 0,this.onTokenRefresh=void 0,this.onTrickle=void 0,this.onClose=void 0,this.onMediaSectionsRequirement=void 0},this.log=ei((r=n.loggerName)!==null&&r!==void 0?r:Nr.Signal),this.loggerContextCb=n.loggerContextCb,this.useJSON=e,this.requestQueue=new nW,this.queuedRequests=[],this.closingLock=new fr,this.connectionLock=new fr,this.state=yn.DISCONNECTED}get logContext(){var e,n;return(n=(e=this.loggerContextCb)===null||e===void 0?void 0:e.call(this))!==null&&n!==void 0?n:{}}join(e,n,r,i){return H(this,arguments,void 0,function(s,a,c,h){var d=this;let f=arguments.length>4&&arguments[4]!==void 0?arguments[4]:!1,p=arguments.length>5?arguments[5]:void 0;return(function*(){return d.state=yn.CONNECTING,d.options=c,yield d.connect(s,a,c,h,f,p)})()})}reconnect(e,n,r,i){return H(this,void 0,void 0,function*(){if(!this.options){this.log.warn("attempted to reconnect without signal options being set, ignoring",this.logContext);return}return this.state=yn.RECONNECTING,this.clearPingInterval(),yield this.connect(e,n,Object.assign(Object.assign({},this.options),{reconnect:!0,sid:r,reconnectReason:i}),void 0,this.useV0SignalPath)})}connect(e,n,r,i){return H(this,arguments,void 0,function(s,a,c,h){var d=this;let f=arguments.length>4&&arguments[4]!==void 0?arguments[4]:!1,p=arguments.length>5?arguments[5]:void 0;return(function*(){const g=yield d.connectionLock.lock();d.connectOptions=c,d.useV0SignalPath=f;const v=IV(),k=f?oW(a,v,c):yield lW(a,v,c,p),w=zV(s,k,f).toString(),S=VV(w).toString();return new Promise((T,C)=>H(d,void 0,void 0,function*(){var j,R;try{let _=!1;const I=P=>H(this,void 0,void 0,function*(){if(_)return;_=!0;const V=P instanceof Event?P.currentTarget:P,F=WV(V,"Abort handler called");this.streamWriter&&!this.isDisconnected?this.sendLeave().then(()=>this.close(F)).catch(K=>{this.log.error(K),this.close()}):this.close(),M(),C(ht.cancelled(F))});h==null||h.addEventListener("abort",I);const M=()=>{clearTimeout(L),h==null||h.removeEventListener("abort",I)},L=setTimeout(()=>{I(ht.timeout("room connection has timed out (signal)"))},c.websocketTimeout),$=(P,V)=>{this.handleSignalConnected(P,L,V)},E=new URL(w);E.searchParams.has("access_token")&&E.searchParams.set("access_token","<redacted>"),this.log.debug("connecting to ".concat(E),Object.assign({reconnect:c.reconnect,reconnectReason:c.reconnectReason},this.logContext)),this.ws&&(yield this.close(!1)),this.ws=new rW(w);try{this.ws.closed.then(Z=>{var D;this.isEstablishingConnection&&C(ht.internal("Websocket got closed during a (re)connection attempt: ".concat(Z.reason))),Z.closeCode!==1e3&&(this.log.warn("websocket closed",Object.assign(Object.assign({},this.logContext),{reason:Z.reason,code:Z.closeCode,wasClean:Z.closeCode===1e3,state:this.state})),this.state===yn.CONNECTED&&this.handleOnClose((D=Z.reason)!==null&&D!==void 0?D:"Unexpected WS error"))}).catch(Z=>{this.isEstablishingConnection&&C(ht.internal("Websocket error during a (re)connection attempt: ".concat(Z)))});const P=yield this.ws.opened.catch(Z=>H(this,void 0,void 0,function*(){if(this.state!==yn.CONNECTED){this.state=yn.DISCONNECTED,clearTimeout(L);const D=yield this.handleConnectionError(Z,S);C(D);return}this.handleWSError(Z),C(Z)}));if(clearTimeout(L),!P)return;const V=P.readable.getReader();this.streamWriter=P.writable.getWriter();const F=yield V.read();if(V.releaseLock(),!F.value)throw ht.internal("no message received as first message");const K=kC(F.value),J=this.validateFirstMessage(K,(j=c.reconnect)!==null&&j!==void 0?j:!1);if(!J.isValid){C(J.error);return}((R=K.message)===null||R===void 0?void 0:R.case)==="join"&&(this.pingTimeoutDuration=K.message.value.pingTimeout,this.pingIntervalDuration=K.message.value.pingInterval,this.pingTimeoutDuration&&this.pingTimeoutDuration>0&&this.log.debug("ping config",Object.assign(Object.assign({},this.logContext),{timeout:this.pingTimeoutDuration,interval:this.pingIntervalDuration})),this.onJoined&&this.onJoined(K.message.value));const Q=J.shouldProcessFirstMessage?K:void 0;$(P,Q),T(J.response)}catch(P){C(P)}finally{M()}}finally{g()}}))})()})}startReadingLoop(e,n){return H(this,void 0,void 0,function*(){for(n&&this.handleSignalResponse(n);;){this.signalLatency&&(yield Cr(this.signalLatency));const{done:r,value:i}=yield e.read();if(r)break;const s=kC(i);this.handleSignalResponse(s)}})}close(){return H(this,arguments,void 0,function(){var e=this;let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!0,r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"Close method called on signal client";return(function*(){if([yn.DISCONNECTING||yn.DISCONNECTED].includes(e.state)){e.log.debug("ignoring signal close as it's already in disconnecting state");return}const i=yield e.closingLock.lock();try{if(e.clearPingInterval(),n&&(e.state=yn.DISCONNECTING),e.ws){e.ws.close({closeCode:1e3,reason:r});const s=e.ws.closed;e.ws=void 0,e.streamWriter=void 0,yield Promise.race([s,Cr(aW)])}}catch(s){e.log.debug("websocket error while closing",Object.assign(Object.assign({},e.logContext),{error:s}))}finally{n&&(e.state=yn.DISCONNECTED),i()}})()})}sendOffer(e,n){this.log.debug("sending offer",Object.assign(Object.assign({},this.logContext),{offerSdp:e.sdp})),this.sendRequest({case:"offer",value:Ko(e,n)})}sendAnswer(e,n){return this.log.debug("sending answer",Object.assign(Object.assign({},this.logContext),{answerSdp:e.sdp})),this.sendRequest({case:"answer",value:Ko(e,n)})}sendIceCandidate(e,n){return this.log.debug("sending ice candidate",Object.assign(Object.assign({},this.logContext),{candidate:e})),this.sendRequest({case:"trickle",value:new Ep({candidateInit:JSON.stringify(e),target:n})})}sendMuteTrack(e,n){return this.sendRequest({case:"mute",value:new jp({sid:e,muted:n})})}sendAddTrack(e){return this.sendRequest({case:"addTrack",value:e})}sendUpdateLocalMetadata(e,n){return H(this,arguments,void 0,function(r,i){var s=this;let a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return(function*(){const c=s.getNextRequestId();return yield s.sendRequest({case:"updateMetadata",value:new gx({requestId:c,metadata:r,name:i,attributes:a})}),c})()})}sendUpdateTrackSettings(e){this.sendRequest({case:"trackSetting",value:e})}sendUpdateSubscription(e){return this.sendRequest({case:"subscription",value:e})}sendSyncState(e){return this.sendRequest({case:"syncState",value:e})}sendUpdateVideoLayers(e,n){return this.sendRequest({case:"updateLayers",value:new q2({trackSid:e,layers:n})})}sendUpdateSubscriptionPermissions(e,n){return this.sendRequest({case:"subscriptionPermission",value:new Y2({allParticipants:e,trackPermissions:n})})}sendSimulateScenario(e){return this.sendRequest({case:"simulate",value:e})}sendPing(){return Promise.all([this.sendRequest({case:"ping",value:In.parse(Date.now())}),this.sendRequest({case:"pingReq",value:new Q2({timestamp:In.parse(Date.now()),rtt:In.parse(this.rtt)})})])}sendUpdateLocalAudioTrack(e,n){return this.sendRequest({case:"updateAudioTrack",value:new mx({trackSid:e,features:n})})}sendLeave(){return this.sendRequest({case:"leave",value:new _p({reason:ts.CLIENT_INITIATED,action:uc.DISCONNECT})})}sendPublishDataTrackRequest(e,n,r){return this.sendRequest({case:"publishDataTrackRequest",value:new dx({pubHandle:e,name:n,encryption:r?bn.GCM:bn.NONE})})}sendUnPublishDataTrackRequest(e){return this.sendRequest({case:"unpublishDataTrackRequest",value:new fx({pubHandle:e})})}sendUpdateDataSubscription(e,n){return this.sendRequest({case:"updateDataSubscription",value:new $2({updates:[new V2({trackSid:e,subscribe:n})]})})}sendRequest(e){return H(this,arguments,void 0,function(n){var r=this;let i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;return(function*(){if(!i&&!sW(n)&&r.state===yn.RECONNECTING){r.queuedRequests.push(()=>H(r,void 0,void 0,function*(){yield this.sendRequest(n,!0)}));return}if(i||(yield r.requestQueue.flush()),r.signalLatency&&(yield Cr(r.signalLatency)),r.isDisconnected){r.log.debug("skipping signal request (type: ".concat(n.case,") - SignalClient disconnected"));return}if(!r.streamWriter){r.log.error("cannot send signal request before connected, type: ".concat(n==null?void 0:n.case),r.logContext);return}const a=new d$({message:n});try{r.useJSON?yield r.streamWriter.write(a.toJsonString()):yield r.streamWriter.write(a.toBinary())}catch(c){r.log.error("error sending signal message",Object.assign(Object.assign({},r.logContext),{error:c}))}})()})}handleSignalResponse(e){var n,r;const i=e.message;if(i==null){this.log.debug("received unsupported message",this.logContext);return}let s=!1;if(i.case==="answer"){const a=TC(i.value);this.onAnswer&&this.onAnswer(a,i.value.id,i.value.midToTrackId)}else if(i.case==="offer"){const a=TC(i.value);this.onOffer&&this.onOffer(a,i.value.id,i.value.midToTrackId)}else if(i.case==="trickle"){const a=JSON.parse(i.value.candidateInit);this.onTrickle&&this.onTrickle(a,i.value.target)}else i.case==="update"?this.onParticipantUpdate&&this.onParticipantUpdate((n=i.value.participants)!==null&&n!==void 0?n:[]):i.case==="trackPublished"?this.onLocalTrackPublished&&this.onLocalTrackPublished(i.value):i.case==="speakersChanged"?this.onSpeakersChanged&&this.onSpeakersChanged((r=i.value.speakers)!==null&&r!==void 0?r:[]):i.case==="leave"?this.onLeave&&this.onLeave(i.value):i.case==="mute"?this.onRemoteMuteChanged&&this.onRemoteMuteChanged(i.value.sid,i.value.muted):i.case==="roomUpdate"?this.onRoomUpdate&&i.value.room&&this.onRoomUpdate(i.value.room):i.case==="connectionQuality"?this.onConnectionQuality&&this.onConnectionQuality(i.value):i.case==="streamStateUpdate"?this.onStreamStateUpdate&&this.onStreamStateUpdate(i.value):i.case==="subscribedQualityUpdate"?this.onSubscribedQualityUpdate&&this.onSubscribedQualityUpdate(i.value):i.case==="subscriptionPermissionUpdate"?this.onSubscriptionPermissionUpdate&&this.onSubscriptionPermissionUpdate(i.value):i.case==="refreshToken"?this.onTokenRefresh&&this.onTokenRefresh(i.value):i.case==="trackUnpublished"?this.onLocalTrackUnpublished&&this.onLocalTrackUnpublished(i.value):i.case==="subscriptionResponse"?this.onSubscriptionError&&this.onSubscriptionError(i.value):i.case==="pong"||(i.case==="pongResp"?(this.rtt=Date.now()-Number.parseInt(i.value.lastPingTimestamp.toString()),this.resetPingTimeout(),s=!0):i.case==="requestResponse"?this.onRequestResponse&&this.onRequestResponse(i.value):i.case==="trackSubscribed"?this.onLocalTrackSubscribed&&this.onLocalTrackSubscribed(i.value.trackSid):i.case==="roomMoved"?(this.onTokenRefresh&&this.onTokenRefresh(i.value.token),this.onRoomMoved&&this.onRoomMoved(i.value)):i.case==="mediaSectionsRequirement"?this.onMediaSectionsRequirement&&this.onMediaSectionsRequirement(i.value):i.case==="publishDataTrackResponse"?this.onPublishDataTrackResponse&&this.onPublishDataTrackResponse(i.value):i.case==="unpublishDataTrackResponse"?this.onUnPublishDataTrackResponse&&this.onUnPublishDataTrackResponse(i.value):i.case==="dataTrackSubscriberHandles"?this.onDataTrackSubscriberHandles&&this.onDataTrackSubscriberHandles(i.value):this.log.debug("unsupported message",Object.assign(Object.assign({},this.logContext),{msgCase:i.case})));s||this.resetPingTimeout()}setReconnected(){for(;this.queuedRequests.length>0;){const e=this.queuedRequests.shift();e&&this.requestQueue.run(e)}}handleOnClose(e){return H(this,void 0,void 0,function*(){if(this.state===yn.DISCONNECTED)return;const n=this.onClose;yield this.close(void 0,e),this.log.debug("websocket connection closed: ".concat(e),Object.assign(Object.assign({},this.logContext),{reason:e})),n&&n(e)})}handleWSError(e){this.log.error("websocket error",Object.assign(Object.assign({},this.logContext),{error:e}))}resetPingTimeout(){if(this.clearPingTimeout(),!this.pingTimeoutDuration){this.log.warn("ping timeout duration not set",this.logContext);return}this.pingTimeout=Qn.setTimeout(()=>{this.log.warn("ping timeout triggered. last pong received at: ".concat(new Date(Date.now()-this.pingTimeoutDuration*1e3).toUTCString()),this.logContext),this.handleOnClose("ping timeout")},this.pingTimeoutDuration*1e3)}clearPingTimeout(){this.pingTimeout&&Qn.clearTimeout(this.pingTimeout)}startPingInterval(){if(this.clearPingInterval(),this.resetPingTimeout(),!this.pingIntervalDuration){this.log.warn("ping interval duration not set",this.logContext);return}this.log.debug("start ping interval",this.logContext),this.pingInterval=Qn.setInterval(()=>{this.sendPing()},this.pingIntervalDuration*1e3)}clearPingInterval(){this.log.debug("clearing ping interval",this.logContext),this.clearPingTimeout(),this.pingInterval&&Qn.clearInterval(this.pingInterval)}handleSignalConnected(e,n,r){this.state=yn.CONNECTED,clearTimeout(n),this.startPingInterval(),this.startReadingLoop(e.readable.getReader(),r)}validateFirstMessage(e,n){var r,i,s,a,c;return((r=e.message)===null||r===void 0?void 0:r.case)==="join"?{isValid:!0,response:e.message.value}:this.state===yn.RECONNECTING&&((i=e.message)===null||i===void 0?void 0:i.case)!=="leave"?((s=e.message)===null||s===void 0?void 0:s.case)==="reconnect"?{isValid:!0,response:e.message.value}:(this.log.debug("declaring signal reconnected without reconnect response received",this.logContext),{isValid:!0,response:void 0,shouldProcessFirstMessage:!0}):this.isEstablishingConnection&&((a=e.message)===null||a===void 0?void 0:a.case)==="leave"?{isValid:!1,error:ht.leaveRequest("Received leave request while trying to (re)connect",e.message.value.reason)}:n?{isValid:!1,error:ht.internal("Unexpected first message")}:{isValid:!1,error:ht.internal("did not receive join response, got ".concat((c=e.message)===null||c===void 0?void 0:c.case," instead"))}}handleConnectionError(e,n){return H(this,void 0,void 0,function*(){try{const r=yield fetch(n);switch(r.status){case 404:return ht.serviceNotFound("v1 RTC path not found. Consider upgrading your LiveKit server version","v0-rtc");case 401:case 403:const i=yield r.text();return ht.notAllowed(i,r.status);default:break}return e instanceof ht?e:ht.internal("Encountered unknown websocket error during connection: ".concat(e),{status:r.status,statusText:r.statusText})}catch(r){return r instanceof ht?r:ht.serverUnreachable(r instanceof Error?r.message:"server was not reachable")}})}}function TC(t){const e={type:"offer",sdp:t.sdp};switch(t.type){case"answer":case"offer":case"pranswer":case"rollback":e.type=t.type;break}return e}function Ko(t,e){return new lo({sdp:t.sdp,type:t.type,id:e})}function oW(t,e,n){var r;const i=new URLSearchParams;return i.set("access_token",t),n.reconnect&&(i.set("reconnect","1"),n.sid&&i.set("sid",n.sid)),i.set("auto_subscribe",n.autoSubscribe?"1":"0"),i.set("sdk",Os()?"reactnative":"js"),i.set("version",e.version),i.set("protocol",e.protocol.toString()),e.deviceModel&&i.set("device_model",e.deviceModel),e.os&&i.set("os",e.os),e.osVersion&&i.set("os_version",e.osVersion),e.browser&&i.set("browser",e.browser),e.browserVersion&&i.set("browser_version",e.browserVersion),n.adaptiveStream&&i.set("adaptive_stream","1"),n.reconnectReason&&i.set("reconnect_reason",n.reconnectReason.toString()),!((r=navigator.connection)===null||r===void 0)&&r.type&&i.set("network",navigator.connection.type),i}function lW(t,e,n,r){return H(this,void 0,void 0,function*(){const i=new URLSearchParams;i.set("access_token",t);const s=new O$({clientInfo:e,connectionSettings:new Z2({autoSubscribe:!!n.autoSubscribe,adaptiveStream:!!n.adaptiveStream}),reconnect:!!n.reconnect,participantSid:n.sid?n.sid:void 0,publisherOffer:r});n.reconnectReason&&(s.reconnectReason=n.reconnectReason);const a=s.toBinary();let c,h;if($v()){const g=new CompressionStream("gzip"),v=g.writable.getWriter();v.write(new Uint8Array(a)),v.close();const k=[],w=g.readable.getReader();for(;;){const{done:j,value:R}=yield w.read();if(j)break;k.push(R)}const S=k.reduce((j,R)=>j+R.length,0),T=new Uint8Array(S);let C=0;for(const j of k)T.set(j,C),C+=j.length;c=T,h=Tv.GZIP}else c=a,h=Tv.NONE;const f=new L$({joinRequest:c,compression:h}).toBinary(),p=g=>{const v=Array.from(g,k=>String.fromCodePoint(k)).join("");return btoa(v)};return i.set("join_request",p(f).replace(/\+/g,"-").replace(/\//g,"_")),i})}class NC{constructor(){this.buffer=[],this._totalSize=0}push(e){this.buffer.push(e),this._totalSize+=e.data.byteLength}pop(){const e=this.buffer.shift();return e&&(this._totalSize-=e.data.byteLength),e}getAll(){return this.buffer.slice()}popToSequence(e){for(;this.buffer.length>0&&this.buffer[0].sequence<=e;)this.pop()}alignBufferedAmount(e){for(;this.buffer.length>0;){const n=this.buffer[0];if(this._totalSize-n.data.byteLength<=e)break;this.pop()}}get length(){return this.buffer.length}}class cW{constructor(e){this._map=new Map,this._lastCleanup=0,this.ttl=e}set(e,n){const r=Date.now();r-this._lastCleanup>this.ttl/2&&this.cleanup();const i=r+this.ttl;return this._map.set(e,{value:n,expiresAt:i}),this}get(e){const n=this._map.get(e);if(n){if(n.expiresAt<Date.now()){this._map.delete(e);return}return n.value}}has(e){const n=this._map.get(e);return n?n.expiresAt<Date.now()?(this._map.delete(e),!1):!0:!1}delete(e){return this._map.delete(e)}clear(){this._map.clear()}cleanup(){const e=Date.now();for(const[n,r]of this._map.entries())r.expiresAt<e&&this._map.delete(n);this._lastCleanup=e}get size(){return this.cleanup(),this._map.size}forEach(e){this.cleanup();for(const[n,r]of this._map.entries())r.expiresAt>=Date.now()&&e(r.value,n,this.asValueMap())}map(e){this.cleanup();const n=[],r=this.asValueMap();for(const[i,s]of r.entries())n.push(e(s,i,r));return n}asValueMap(){const e=new Map;for(const[n,r]of this._map.entries())r.expiresAt>=Date.now()&&e.set(n,r.value);return e}}var $i={},C0={},T0={exports:{}},EC;function jx(){if(EC)return T0.exports;EC=1;var t=T0.exports={v:[{name:"version",reg:/^(\d*)$/}],o:[{name:"origin",reg:/^(\S*) (\d*) (\d*) (\S*) IP(\d) (\S*)/,names:["username","sessionId","sessionVersion","netType","ipVer","address"],format:"%s %s %d %s IP%d %s"}],s:[{name:"name"}],i:[{name:"description"}],u:[{name:"uri"}],e:[{name:"email"}],p:[{name:"phone"}],z:[{name:"timezones"}],r:[{name:"repeats"}],t:[{name:"timing",reg:/^(\d*) (\d*)/,names:["start","stop"],format:"%d %d"}],c:[{name:"connection",reg:/^IN IP(\d) (\S*)/,names:["version","ip"],format:"IN IP%d %s"}],b:[{push:"bandwidth",reg:/^(TIAS|AS|CT|RR|RS):(\d*)/,names:["type","limit"],format:"%s:%s"}],m:[{reg:/^(\w*) (\d*) ([\w/]*)(?: (.*))?/,names:["type","port","protocol","payloads"],format:"%s %d %s %s"}],a:[{push:"rtp",reg:/^rtpmap:(\d*) ([\w\-.]*)(?:\s*\/(\d*)(?:\s*\/(\S*))?)?/,names:["payload","codec","rate","encoding"],format:function(e){return e.encoding?"rtpmap:%d %s/%s/%s":e.rate?"rtpmap:%d %s/%s":"rtpmap:%d %s"}},{push:"fmtp",reg:/^fmtp:(\d*) ([\S| ]*)/,names:["payload","config"],format:"fmtp:%d %s"},{name:"control",reg:/^control:(.*)/,format:"control:%s"},{name:"rtcp",reg:/^rtcp:(\d*)(?: (\S*) IP(\d) (\S*))?/,names:["port","netType","ipVer","address"],format:function(e){return e.address!=null?"rtcp:%d %s IP%d %s":"rtcp:%d"}},{push:"rtcpFbTrrInt",reg:/^rtcp-fb:(\*|\d*) trr-int (\d*)/,names:["payload","value"],format:"rtcp-fb:%s trr-int %d"},{push:"rtcpFb",reg:/^rtcp-fb:(\*|\d*) ([\w-_]*)(?: ([\w-_]*))?/,names:["payload","type","subtype"],format:function(e){return e.subtype!=null?"rtcp-fb:%s %s %s":"rtcp-fb:%s %s"}},{push:"ext",reg:/^extmap:(\d+)(?:\/(\w+))?(?: (urn:ietf:params:rtp-hdrext:encrypt))? (\S*)(?: (\S*))?/,names:["value","direction","encrypt-uri","uri","config"],format:function(e){return"extmap:%d"+(e.direction?"/%s":"%v")+(e["encrypt-uri"]?" %s":"%v")+" %s"+(e.config?" %s":"")}},{name:"extmapAllowMixed",reg:/^(extmap-allow-mixed)/},{push:"crypto",reg:/^crypto:(\d*) ([\w_]*) (\S*)(?: (\S*))?/,names:["id","suite","config","sessionConfig"],format:function(e){return e.sessionConfig!=null?"crypto:%d %s %s %s":"crypto:%d %s %s"}},{name:"setup",reg:/^setup:(\w*)/,format:"setup:%s"},{name:"connectionType",reg:/^connection:(new|existing)/,format:"connection:%s"},{name:"mid",reg:/^mid:([^\s]*)/,format:"mid:%s"},{name:"msid",reg:/^msid:(.*)/,format:"msid:%s"},{name:"ptime",reg:/^ptime:(\d*(?:\.\d*)*)/,format:"ptime:%d"},{name:"maxptime",reg:/^maxptime:(\d*(?:\.\d*)*)/,format:"maxptime:%d"},{name:"direction",reg:/^(sendrecv|recvonly|sendonly|inactive)/},{name:"icelite",reg:/^(ice-lite)/},{name:"iceUfrag",reg:/^ice-ufrag:(\S*)/,format:"ice-ufrag:%s"},{name:"icePwd",reg:/^ice-pwd:(\S*)/,format:"ice-pwd:%s"},{name:"fingerprint",reg:/^fingerprint:(\S*) (\S*)/,names:["type","hash"],format:"fingerprint:%s %s"},{push:"candidates",reg:/^candidate:(\S*) (\d*) (\S*) (\d*) (\S*) (\d*) typ (\S*)(?: raddr (\S*) rport (\d*))?(?: tcptype (\S*))?(?: generation (\d*))?(?: network-id (\d*))?(?: network-cost (\d*))?/,names:["foundation","component","transport","priority","ip","port","type","raddr","rport","tcptype","generation","network-id","network-cost"],format:function(e){var n="candidate:%s %d %s %d %s %d typ %s";return n+=e.raddr!=null?" raddr %s rport %d":"%v%v",n+=e.tcptype!=null?" tcptype %s":"%v",e.generation!=null&&(n+=" generation %d"),n+=e["network-id"]!=null?" network-id %d":"%v",n+=e["network-cost"]!=null?" network-cost %d":"%v",n}},{name:"endOfCandidates",reg:/^(end-of-candidates)/},{name:"remoteCandidates",reg:/^remote-candidates:(.*)/,format:"remote-candidates:%s"},{name:"iceOptions",reg:/^ice-options:(\S*)/,format:"ice-options:%s"},{push:"ssrcs",reg:/^ssrc:(\d*) ([\w_-]*)(?::(.*))?/,names:["id","attribute","value"],format:function(e){var n="ssrc:%d";return e.attribute!=null&&(n+=" %s",e.value!=null&&(n+=":%s")),n}},{push:"ssrcGroups",reg:/^ssrc-group:([\x21\x23\x24\x25\x26\x27\x2A\x2B\x2D\x2E\w]*) (.*)/,names:["semantics","ssrcs"],format:"ssrc-group:%s %s"},{name:"msidSemantic",reg:/^msid-semantic:\s?(\w*) (\S*)/,names:["semantic","token"],format:"msid-semantic: %s %s"},{push:"groups",reg:/^group:(\w*) (.*)/,names:["type","mids"],format:"group:%s %s"},{name:"rtcpMux",reg:/^(rtcp-mux)/},{name:"rtcpRsize",reg:/^(rtcp-rsize)/},{name:"sctpmap",reg:/^sctpmap:([\w_/]*) (\S*)(?: (\S*))?/,names:["sctpmapNumber","app","maxMessageSize"],format:function(e){return e.maxMessageSize!=null?"sctpmap:%s %s %s":"sctpmap:%s %s"}},{name:"xGoogleFlag",reg:/^x-google-flag:([^\s]*)/,format:"x-google-flag:%s"},{push:"rids",reg:/^rid:([\d\w]+) (\w+)(?: ([\S| ]*))?/,names:["id","direction","params"],format:function(e){return e.params?"rid:%s %s %s":"rid:%s %s"}},{push:"imageattrs",reg:new RegExp("^imageattr:(\\d+|\\*)[\\s\\t]+(send|recv)[\\s\\t]+(\\*|\\[\\S+\\](?:[\\s\\t]+\\[\\S+\\])*)(?:[\\s\\t]+(recv|send)[\\s\\t]+(\\*|\\[\\S+\\](?:[\\s\\t]+\\[\\S+\\])*))?"),names:["pt","dir1","attrs1","dir2","attrs2"],format:function(e){return"imageattr:%s %s %s"+(e.dir2?" %s %s":"")}},{name:"simulcast",reg:new RegExp("^simulcast:(send|recv) ([a-zA-Z0-9\\-_~;,]+)(?:\\s?(send|recv) ([a-zA-Z0-9\\-_~;,]+))?$"),names:["dir1","list1","dir2","list2"],format:function(e){return"simulcast:%s %s"+(e.dir2?" %s %s":"")}},{name:"simulcast_03",reg:/^simulcast:[\s\t]+([\S+\s\t]+)$/,names:["value"],format:"simulcast: %s"},{name:"framerate",reg:/^framerate:(\d+(?:$|\.\d+))/,format:"framerate:%s"},{name:"sourceFilter",reg:/^source-filter: *(excl|incl) (\S*) (IP4|IP6|\*) (\S*) (.*)/,names:["filterMode","netType","addressTypes","destAddress","srcList"],format:"source-filter: %s %s %s %s %s"},{name:"bundleOnly",reg:/^(bundle-only)/},{name:"label",reg:/^label:(.+)/,format:"label:%s"},{name:"sctpPort",reg:/^sctp-port:(\d+)$/,format:"sctp-port:%s"},{name:"maxMessageSize",reg:/^max-message-size:(\d+)$/,format:"max-message-size:%s"},{push:"tsRefClocks",reg:/^ts-refclk:([^\s=]*)(?:=(\S*))?/,names:["clksrc","clksrcExt"],format:function(e){return"ts-refclk:%s"+(e.clksrcExt!=null?"=%s":"")}},{name:"mediaClk",reg:/^mediaclk:(?:id=(\S*))? *([^\s=]*)(?:=(\S*))?(?: *rate=(\d+)\/(\d+))?/,names:["id","mediaClockName","mediaClockValue","rateNumerator","rateDenominator"],format:function(e){var n="mediaclk:";return n+=e.id!=null?"id=%s %s":"%v%s",n+=e.mediaClockValue!=null?"=%s":"",n+=e.rateNumerator!=null?" rate=%s":"",n+=e.rateDenominator!=null?"/%s":"",n}},{name:"keywords",reg:/^keywds:(.+)$/,format:"keywds:%s"},{name:"content",reg:/^content:(.+)/,format:"content:%s"},{name:"bfcpFloorCtrl",reg:/^floorctrl:(c-only|s-only|c-s)/,format:"floorctrl:%s"},{name:"bfcpConfId",reg:/^confid:(\d+)/,format:"confid:%s"},{name:"bfcpUserId",reg:/^userid:(\d+)/,format:"userid:%s"},{name:"bfcpFloorId",reg:/^floorid:(.+) (?:m-stream|mstrm):(.+)/,names:["id","mStream"],format:"floorid:%s mstrm:%s"},{push:"invalid",names:["value"]}]};return Object.keys(t).forEach(function(e){var n=t[e];n.forEach(function(r){r.reg||(r.reg=/(.*)/),r.format||(r.format="%s")})}),T0.exports}var jC;function uW(){return jC||(jC=1,(function(t){var e=function(c){return String(Number(c))===c?Number(c):c},n=function(c,h,d,f){if(f&&!d)h[f]=e(c[1]);else for(var p=0;p<d.length;p+=1)c[p+1]!=null&&(h[d[p]]=e(c[p+1]))},r=function(c,h,d){var f=c.name&&c.names;c.push&&!h[c.push]?h[c.push]=[]:f&&!h[c.name]&&(h[c.name]={});var p=c.push?{}:f?h[c.name]:h;n(d.match(c.reg),p,c.names,c.name),c.push&&h[c.push].push(p)},i=jx(),s=RegExp.prototype.test.bind(/^([a-z])=(.*)/);t.parse=function(c){var h={},d=[],f=h;return c.split(/(\r\n|\r|\n)/).filter(s).forEach(function(p){var g=p[0],v=p.slice(2);g==="m"&&(d.push({rtp:[],fmtp:[]}),f=d[d.length-1]);for(var k=0;k<(i[g]||[]).length;k+=1){var w=i[g][k];if(w.reg.test(v))return r(w,f,v)}}),h.media=d,h};var a=function(c,h){var d=h.split(/=(.+)/,2);return d.length===2?c[d[0]]=e(d[1]):d.length===1&&h.length>1&&(c[d[0]]=void 0),c};t.parseParams=function(c){return c.split(/;\s?/).reduce(a,{})},t.parseFmtpConfig=t.parseParams,t.parsePayloads=function(c){return c.toString().split(" ").map(Number)},t.parseRemoteCandidates=function(c){for(var h=[],d=c.split(" ").map(e),f=0;f<d.length;f+=3)h.push({component:d[f],ip:d[f+1],port:d[f+2]});return h},t.parseImageAttributes=function(c){return c.split(" ").map(function(h){return h.substring(1,h.length-1).split(",").reduce(a,{})})},t.parseSimulcastStreamList=function(c){return c.split(";").map(function(h){return h.split(",").map(function(d){var f,p=!1;return d[0]!=="~"?f=e(d):(f=e(d.substring(1,d.length)),p=!0),{scid:f,paused:p}})})}})(C0)),C0}var N0,PC;function dW(){if(PC)return N0;PC=1;var t=jx(),e=/%[sdv%]/g,n=function(a){var c=1,h=arguments,d=h.length;return a.replace(e,function(f){if(c>=d)return f;var p=h[c];switch(c+=1,f){case"%%":return"%";case"%s":return String(p);case"%d":return Number(p);case"%v":return""}})},r=function(a,c,h){var d=c.format instanceof Function?c.format(c.push?h:h[c.name]):c.format,f=[a+"="+d];if(c.names)for(var p=0;p<c.names.length;p+=1){var g=c.names[p];c.name?f.push(h[c.name][g]):f.push(h[c.names[p]])}else f.push(h[c.name]);return n.apply(null,f)},i=["v","o","s","i","u","e","p","c","b","t","r","z","a"],s=["i","c","b","a"];return N0=function(a,c){c=c||{},a.version==null&&(a.version=0),a.name==null&&(a.name=" "),a.media.forEach(function(p){p.payloads==null&&(p.payloads="")});var h=c.outerOrder||i,d=c.innerOrder||s,f=[];return h.forEach(function(p){t[p].forEach(function(g){g.name in a&&a[g.name]!=null?f.push(r(p,g,a)):g.push in a&&a[g.push]!=null&&a[g.push].forEach(function(v){f.push(r(p,g,v))})})}),a.media.forEach(function(p){f.push(r("m",t.m[0],p)),d.forEach(function(g){t[g].forEach(function(v){v.name in p&&p[v.name]!=null?f.push(r(g,v,p)):v.push in p&&p[v.push]!=null&&p[v.push].forEach(function(k){f.push(r(g,v,k))})})})}),f.join(`\r
561
+ `)+`\r
562
+ `},N0}var _C;function hW(){if(_C)return $i;_C=1;var t=uW(),e=dW(),n=jx();return $i.grammar=n,$i.write=e,$i.parse=t.parse,$i.parseParams=t.parseParams,$i.parseFmtpConfig=t.parseFmtpConfig,$i.parsePayloads=t.parsePayloads,$i.parseRemoteCandidates=t.parseRemoteCandidates,$i.parseImageAttributes=t.parseImageAttributes,$i.parseSimulcastStreamList=t.parseSimulcastStreamList,$i}var Ti=hW();function Px(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:50,n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};var r,i;let s;const a=(r=n.isImmediate)!==null&&r!==void 0?r:!1,c=(i=n.callback)!==null&&i!==void 0?i:!1,h=n.maxWait;let d=Date.now(),f=[];function p(){if(h!==void 0){const v=Date.now()-d;if(v+e>=h)return h-v}return e}const g=function(){for(var v=arguments.length,k=new Array(v),w=0;w<v;w++)k[w]=arguments[w];const S=this;return new Promise((T,C)=>{const j=function(){if(s=void 0,d=Date.now(),!a){const _=t.apply(S,k);c&&c(_),f.forEach(I=>{let{resolve:M}=I;return M(_)}),f=[]}},R=a&&s===void 0;if(s!==void 0&&Qn.clearTimeout(s),s=Qn.setTimeout(j,p()),R){const _=t.apply(S,k);return c&&c(_),T(_)}f.push({resolve:T,reject:C})})};return g.cancel=function(v){s!==void 0&&Qn.clearTimeout(s),f.forEach(k=>{let{reject:w}=k;return w(v)}),f=[]},g}const fW=.7,pW=20,sl={NegotiationStarted:"negotiationStarted",NegotiationComplete:"negotiationComplete",RTPVideoPayloadTypes:"rtpVideoPayloadTypes"};class RC extends Di.EventEmitter{get pc(){return this._pc||(this._pc=this.createPC()),this._pc}constructor(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};var r;super(),this.log=Tt,this.ddExtID=0,this.latestOfferId=0,this.pendingCandidates=[],this.restartingIce=!1,this.renegotiate=!1,this.trackBitrates=[],this.remoteStereoMids=[],this.remoteNackMids=[],this.negotiate=Px(i=>H(this,void 0,void 0,function*(){this.emit(sl.NegotiationStarted);try{yield this.createAndSendOffer()}catch(s){if(i)i(s);else throw s}}),pW),this.close=()=>{this._pc&&(this.pendingInitialOffer=void 0,this._pc.close(),this._pc.onconnectionstatechange=null,this._pc.oniceconnectionstatechange=null,this._pc.onicegatheringstatechange=null,this._pc.ondatachannel=null,this._pc.onnegotiationneeded=null,this._pc.onsignalingstatechange=null,this._pc.onicecandidate=null,this._pc.ondatachannel=null,this._pc.ontrack=null,this._pc.onconnectionstatechange=null,this._pc.oniceconnectionstatechange=null,this._pc=null)},this.log=ei((r=n.loggerName)!==null&&r!==void 0?r:Nr.PCTransport),this.loggerOptions=n,this.config=e,this._pc=this.createPC(),this.offerLock=new fr}createPC(){const e=new RTCPeerConnection(this.config);return e.onicecandidate=n=>{var r;n.candidate&&((r=this.onIceCandidate)===null||r===void 0||r.call(this,n.candidate))},e.onicecandidateerror=n=>{var r;(r=this.onIceCandidateError)===null||r===void 0||r.call(this,n)},e.oniceconnectionstatechange=()=>{var n;(n=this.onIceConnectionStateChange)===null||n===void 0||n.call(this,e.iceConnectionState)},e.onsignalingstatechange=()=>{var n;(n=this.onSignalingStatechange)===null||n===void 0||n.call(this,e.signalingState)},e.onconnectionstatechange=()=>{var n;(n=this.onConnectionStateChange)===null||n===void 0||n.call(this,e.connectionState)},e.ondatachannel=n=>{var r;(r=this.onDataChannel)===null||r===void 0||r.call(this,n)},e.ontrack=n=>{var r;(r=this.onTrack)===null||r===void 0||r.call(this,n)},e}get logContext(){var e,n;return Object.assign({},(n=(e=this.loggerOptions).loggerContextCb)===null||n===void 0?void 0:n.call(e))}get isICEConnected(){return this._pc!==null&&(this.pc.iceConnectionState==="connected"||this.pc.iceConnectionState==="completed")}addIceCandidate(e){return H(this,void 0,void 0,function*(){if(this.pc.remoteDescription&&!this.restartingIce)return this.pc.addIceCandidate(e);this.pendingCandidates.push(e)})}setRemoteDescription(e,n){return H(this,void 0,void 0,function*(){var r,i;if(e.type==="answer"&&this.latestOfferId>0&&n>0&&n!==this.latestOfferId)return this.log.warn("ignoring answer for old offer",Object.assign(Object.assign({},this.logContext),{offerId:n,latestOfferId:this.latestOfferId})),!1;let s;if(e.type==="offer"){let{stereoMids:a,nackMids:c}=mW(e);this.remoteStereoMids=a,this.remoteNackMids=c}else if(e.type==="answer"){if(this.pendingInitialOffer&&this._pc){const c=this.pendingInitialOffer;this.pendingInitialOffer=void 0;const h=Ti.parse((r=c.sdp)!==null&&r!==void 0?r:"");h.media.forEach(d=>{ef(d)}),this.log.debug("setting pending initial offer before processing answer",this.logContext),yield this.setMungedSDP(c,Ti.write(h))}const a=Ti.parse((i=e.sdp)!==null&&i!==void 0?i:"");a.media.forEach(c=>{const h=_x(c.mid);c.type==="audio"&&this.trackBitrates.some(d=>{if(!d.transceiver||h!=d.transceiver.mid)return!1;let f=0;if(c.rtp.some(g=>g.codec.toUpperCase()===d.codec.toUpperCase()?(f=g.payload,!0):!1),f===0)return!0;let p=!1;for(const g of c.fmtp)if(g.payload===f){g.config=g.config.split(";").filter(v=>!v.includes("maxaveragebitrate")).join(";"),d.maxbr>0&&(g.config+=";maxaveragebitrate=".concat(d.maxbr*1e3)),p=!0;break}return p||d.maxbr>0&&c.fmtp.push({payload:f,config:"maxaveragebitrate=".concat(d.maxbr*1e3)}),!0})}),s=Ti.write(a)}return yield this.setMungedSDP(e,s,!0),this.pendingCandidates.forEach(a=>{this.pc.addIceCandidate(a)}),this.pendingCandidates=[],this.restartingIce=!1,this.renegotiate?(this.renegotiate=!1,yield this.createAndSendOffer()):e.type==="answer"&&(this.emit(sl.NegotiationComplete),e.sdp&&Ti.parse(e.sdp).media.forEach(c=>{c.type==="video"&&this.emit(sl.RTPVideoPayloadTypes,c.rtp)})),!0})}createInitialOffer(){return H(this,void 0,void 0,function*(){var e;const n=yield this.offerLock.lock();try{if(this.pc.signalingState!=="stable"){this.log.warn("signaling state is not stable, cannot create initial offer",this.logContext);return}const r=this.latestOfferId+1;this.latestOfferId=r;const i=yield this.pc.createOffer();this.pendingInitialOffer={sdp:i.sdp,type:i.type};const s=Ti.parse((e=i.sdp)!==null&&e!==void 0?e:"");return s.media.forEach(a=>{ef(a)}),i.sdp=Ti.write(s),{offer:i,offerId:r}}finally{n()}})}createAndSendOffer(e){return H(this,void 0,void 0,function*(){var n;const r=yield this.offerLock.lock();try{if(this.onOffer===void 0)return;if(e!=null&&e.iceRestart&&(this.log.debug("restarting ICE",this.logContext),this.restartingIce=!0),this._pc&&(this._pc.signalingState==="have-local-offer"||this.pendingInitialOffer)){const c=this._pc.remoteDescription;if(e!=null&&e.iceRestart&&c)yield this._pc.setRemoteDescription(c);else{this.renegotiate=!0,this.log.debug("requesting renegotiation",Object.assign({},this.logContext));return}}else if(!this._pc||this._pc.signalingState==="closed"){this.log.warn("could not createOffer with closed peer connection",this.logContext);return}this.log.debug("starting to negotiate",this.logContext);const i=this.latestOfferId+1;this.latestOfferId=i;const s=yield this.pc.createOffer(e);this.log.debug("original offer",Object.assign({sdp:s.sdp},this.logContext));const a=Ti.parse((n=s.sdp)!==null&&n!==void 0?n:"");if(a.media.forEach(c=>{ef(c),c.type==="audio"?IC(c,["all"],[]):c.type==="video"&&this.trackBitrates.some(h=>{if(!c.msid||!h.cid||!c.msid.includes(h.cid))return!1;let d=0;if(c.rtp.some(p=>p.codec.toUpperCase()===h.codec.toUpperCase()?(d=p.payload,!0):!1),d===0||(Ji(h.codec)&&!hl()&&this.ensureVideoDDExtensionForSVC(c,a),!Ji(h.codec)))return!0;const f=Math.round(h.maxbr*fW);for(const p of c.fmtp)if(p.payload===d){p.config.includes("x-google-start-bitrate")||(p.config+=";x-google-start-bitrate=".concat(f));break}return!0})}),this.latestOfferId>i){this.log.warn("latestOfferId mismatch",Object.assign(Object.assign({},this.logContext),{latestOfferId:this.latestOfferId,offerId:i}));return}yield this.setMungedSDP(s,Ti.write(a)),this.onOffer(s,this.latestOfferId)}finally{r()}})}createAndSetAnswer(){return H(this,void 0,void 0,function*(){var e;const n=yield this.pc.createAnswer(),r=Ti.parse((e=n.sdp)!==null&&e!==void 0?e:"");return r.media.forEach(i=>{ef(i),i.type==="audio"&&IC(i,this.remoteStereoMids,this.remoteNackMids)}),yield this.setMungedSDP(n,Ti.write(r)),n})}createDataChannel(e,n){return this.pc.createDataChannel(e,n)}addTransceiver(e,n){return this.pc.addTransceiver(e,n)}addTransceiverOfKind(e,n){return this.pc.addTransceiver(e,n)}addTrack(e){if(!this._pc)throw new On("PC closed, cannot add track");return this._pc.addTrack(e)}setTrackCodecBitrate(e){this.trackBitrates.push(e)}setConfiguration(e){var n;if(!this._pc)throw new On("PC closed, cannot configure");return(n=this._pc)===null||n===void 0?void 0:n.setConfiguration(e)}canRemoveTrack(){var e;return!!(!((e=this._pc)===null||e===void 0)&&e.removeTrack)}removeTrack(e){var n;return(n=this._pc)===null||n===void 0?void 0:n.removeTrack(e)}getConnectionState(){var e,n;return(n=(e=this._pc)===null||e===void 0?void 0:e.connectionState)!==null&&n!==void 0?n:"closed"}getICEConnectionState(){var e,n;return(n=(e=this._pc)===null||e===void 0?void 0:e.iceConnectionState)!==null&&n!==void 0?n:"closed"}getSignallingState(){var e,n;return(n=(e=this._pc)===null||e===void 0?void 0:e.signalingState)!==null&&n!==void 0?n:"closed"}getTransceivers(){var e,n;return(n=(e=this._pc)===null||e===void 0?void 0:e.getTransceivers())!==null&&n!==void 0?n:[]}getSenders(){var e,n;return(n=(e=this._pc)===null||e===void 0?void 0:e.getSenders())!==null&&n!==void 0?n:[]}getLocalDescription(){var e;return(e=this._pc)===null||e===void 0?void 0:e.localDescription}getRemoteDescription(){var e;return(e=this.pc)===null||e===void 0?void 0:e.remoteDescription}getStats(){return this.pc.getStats()}getConnectedAddress(){return H(this,void 0,void 0,function*(){var e;if(!this._pc)return;let n="";const r=new Map,i=new Map;if((yield this._pc.getStats()).forEach(c=>{switch(c.type){case"transport":n=c.selectedCandidatePairId;break;case"candidate-pair":n===""&&c.selected&&(n=c.id),r.set(c.id,c);break;case"remote-candidate":i.set(c.id,"".concat(c.address,":").concat(c.port));break}}),n==="")return;const a=(e=r.get(n))===null||e===void 0?void 0:e.remoteCandidateId;if(a!==void 0)return i.get(a)})}setMungedSDP(e,n,r){return H(this,void 0,void 0,function*(){var i,s;if(n){const a=e.sdp;e.sdp=n;try{this.log.debug("setting munged ".concat(r?"remote":"local"," description"),this.logContext),r?yield this.pc.setRemoteDescription(e):yield this.pc.setLocalDescription(e);return}catch(c){this.log.warn("not able to set ".concat(e.type,", falling back to unmodified sdp"),Object.assign(Object.assign({},this.logContext),{error:c,sdp:n})),e.sdp=a}}try{r?yield(i=this._pc)===null||i===void 0?void 0:i.setRemoteDescription(e):yield(s=this._pc)===null||s===void 0?void 0:s.setLocalDescription(e)}catch(a){let c="unknown error";a instanceof Error?c=a.message:typeof a=="string"&&(c=a);const h={error:c,sdp:e.sdp};throw!r&&this.pc.remoteDescription&&(h.remoteSdp=this.pc.remoteDescription),this.log.error("unable to set ".concat(e.type),Object.assign(Object.assign({},this.logContext),{fields:h})),new nl(c)}})}ensureVideoDDExtensionForSVC(e,n){var r,i;if(!((r=e.ext)===null||r===void 0?void 0:r.some(a=>a.uri===pC))){if(this.ddExtID===0){let a=0;n.media.forEach(c=>{var h;c.type==="video"&&((h=c.ext)===null||h===void 0||h.forEach(d=>{d.value>a&&(a=d.value)}))}),this.ddExtID=a+1}(i=e.ext)===null||i===void 0||i.push({value:this.ddExtID,uri:pC})}}}function IC(t,e,n){const r=_x(t.mid);let i=0;t.rtp.some(s=>s.codec==="opus"?(i=s.payload,!0):!1),i>0&&(t.rtcpFb||(t.rtcpFb=[]),n.includes(r)&&!t.rtcpFb.some(s=>s.payload===i&&s.type==="nack")&&t.rtcpFb.push({payload:i,type:"nack"}),(e.includes(r)||e.length===1&&e[0]==="all")&&t.fmtp.some(s=>s.payload===i?(s.config.includes("stereo=1")||(s.config+=";stereo=1"),!0):!1))}function mW(t){var e;const n=[],r=[],i=Ti.parse((e=t.sdp)!==null&&e!==void 0?e:"");let s=0;return i.media.forEach(a=>{var c;const h=_x(a.mid);a.type==="audio"&&(a.rtp.some(d=>d.codec==="opus"?(s=d.payload,!0):!1),!((c=a.rtcpFb)===null||c===void 0)&&c.some(d=>d.payload===s&&d.type==="nack")&&r.push(h),a.fmtp.some(d=>d.payload===s?(d.config.includes("sprop-stereo=1")&&n.push(h),!0):!1))}),{stereoMids:n,nackMids:r}}function ef(t){if(t.connection){const e=t.connection.ip.indexOf(":")>=0;(t.connection.version===4&&e||t.connection.version===6&&!e)&&(t.connection.ip="0.0.0.0",t.connection.version=4)}}function _x(t){return typeof t=="number"?t.toFixed(0):t}const Wv="vp8",gW={audioPreset:Dv.music,dtx:!0,red:!0,forceStereo:!1,simulcast:!0,screenShareEncoding:wx.h1080fps15.encoding,stopMicTrackOnMute:!1,videoCodec:Wv,backupCodec:!0,preConnectBuffer:!1},$P={deviceId:{ideal:"default"},autoGainControl:!0,echoCancellation:!0,noiseSuppression:!0,voiceIsolation:!0},VP={deviceId:{ideal:"default"},resolution:ud.h720.resolution},vW={adaptiveStream:!1,dynacast:!1,stopLocalTrackOnUnpublish:!0,reconnectPolicy:new W$,disconnectOnPageLeave:!0,webAudioMix:!1,singlePeerConnection:!0},Rx={autoSubscribe:!0,maxRetries:1,peerConnectionTimeout:15e3,websocketTimeout:15e3};var Ln;(function(t){t[t.NEW=0]="NEW",t[t.CONNECTING=1]="CONNECTING",t[t.CONNECTED=2]="CONNECTED",t[t.FAILED=3]="FAILED",t[t.CLOSING=4]="CLOSING",t[t.CLOSED=5]="CLOSED"})(Ln||(Ln={}));class MC{get needsPublisher(){return this.isPublisherConnectionRequired}get needsSubscriber(){return this.isSubscriberConnectionRequired}get currentState(){return this.state}get mode(){return this._mode}constructor(e,n,r){var i;this.peerConnectionTimeout=Rx.peerConnectionTimeout,this.log=Tt,this.updateState=()=>{var s,a;const c=this.state,h=this.requiredTransports.map(d=>d.getConnectionState());h.every(d=>d==="connected")?this.state=Ln.CONNECTED:h.some(d=>d==="failed")?this.state=Ln.FAILED:h.some(d=>d==="connecting")?this.state=Ln.CONNECTING:h.every(d=>d==="closed")?this.state=Ln.CLOSED:h.some(d=>d==="closed")?this.state=Ln.CLOSING:h.every(d=>d==="new")&&(this.state=Ln.NEW),c!==this.state&&(this.log.debug("pc state change: from ".concat(Ln[c]," to ").concat(Ln[this.state]),this.logContext),(s=this.onStateChange)===null||s===void 0||s.call(this,this.state,this.publisher.getConnectionState(),(a=this.subscriber)===null||a===void 0?void 0:a.getConnectionState()))},this.log=ei((i=n.loggerName)!==null&&i!==void 0?i:Nr.PCManager),this.loggerOptions=n,this.isPublisherConnectionRequired=e!=="subscriber-primary",this.isSubscriberConnectionRequired=e==="subscriber-primary",this.publisher=new RC(r,n),this._mode=e,e!=="publisher-only"&&(this.subscriber=new RC(r,n),this.subscriber.onConnectionStateChange=this.updateState,this.subscriber.onIceConnectionStateChange=this.updateState,this.subscriber.onSignalingStatechange=this.updateState,this.subscriber.onIceCandidate=s=>{var a;(a=this.onIceCandidate)===null||a===void 0||a.call(this,s,Gi.SUBSCRIBER)},this.subscriber.onDataChannel=s=>{var a;(a=this.onDataChannel)===null||a===void 0||a.call(this,s)},this.subscriber.onTrack=s=>{var a;(a=this.onTrack)===null||a===void 0||a.call(this,s)}),this.publisher.onConnectionStateChange=this.updateState,this.publisher.onIceConnectionStateChange=this.updateState,this.publisher.onSignalingStatechange=this.updateState,this.publisher.onIceCandidate=s=>{var a;(a=this.onIceCandidate)===null||a===void 0||a.call(this,s,Gi.PUBLISHER)},this.publisher.onTrack=s=>{var a;(a=this.onTrack)===null||a===void 0||a.call(this,s)},this.publisher.onOffer=(s,a)=>{var c;(c=this.onPublisherOffer)===null||c===void 0||c.call(this,s,a)},this.state=Ln.NEW,this.connectionLock=new fr,this.remoteOfferLock=new fr}get logContext(){var e,n;return Object.assign({},(n=(e=this.loggerOptions).loggerContextCb)===null||n===void 0?void 0:n.call(e))}requirePublisher(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!0;this.isPublisherConnectionRequired=e,this.updateState()}createAndSendPublisherOffer(e){return this.publisher.createAndSendOffer(e)}setPublisherAnswer(e,n){return this.publisher.setRemoteDescription(e,n)}removeTrack(e){return this.publisher.removeTrack(e)}close(){return H(this,void 0,void 0,function*(){var e;if(this.publisher&&this.publisher.getSignallingState()!=="closed"){const n=this.publisher;for(const r of n.getSenders())try{n.canRemoveTrack()&&n.removeTrack(r)}catch(i){this.log.warn("could not removeTrack",Object.assign(Object.assign({},this.logContext),{error:i}))}}yield Promise.all([this.publisher.close(),(e=this.subscriber)===null||e===void 0?void 0:e.close()]),this.updateState()})}triggerIceRestart(){return H(this,void 0,void 0,function*(){this.subscriber&&(this.subscriber.restartingIce=!0),this.needsPublisher&&(yield this.createAndSendPublisherOffer({iceRestart:!0}))})}addIceCandidate(e,n){return H(this,void 0,void 0,function*(){var r;n===Gi.PUBLISHER?yield this.publisher.addIceCandidate(e):yield(r=this.subscriber)===null||r===void 0?void 0:r.addIceCandidate(e)})}createSubscriberAnswerFromOffer(e,n){return H(this,void 0,void 0,function*(){var r,i,s;this.log.debug("received server offer",Object.assign(Object.assign({},this.logContext),{RTCSdpType:e.type,sdp:e.sdp,signalingState:(r=this.subscriber)===null||r===void 0?void 0:r.getSignallingState().toString()}));const a=yield this.remoteOfferLock.lock();try{return(yield(i=this.subscriber)===null||i===void 0?void 0:i.setRemoteDescription(e,n))?yield(s=this.subscriber)===null||s===void 0?void 0:s.createAndSetAnswer():void 0}finally{a()}})}updateConfiguration(e,n){var r;this.publisher.setConfiguration(e),(r=this.subscriber)===null||r===void 0||r.setConfiguration(e),n&&this.triggerIceRestart()}ensurePCTransportConnection(e,n){return H(this,void 0,void 0,function*(){var r;const i=yield this.connectionLock.lock();try{this.isPublisherConnectionRequired&&this.publisher.getConnectionState()!=="connected"&&this.publisher.getConnectionState()!=="connecting"&&(this.log.debug("negotiation required, start negotiating",this.logContext),this.publisher.negotiate()),yield Promise.all((r=this.requiredTransports)===null||r===void 0?void 0:r.map(s=>this.ensureTransportConnected(s,e,n)))}finally{i()}})}negotiate(e){return H(this,void 0,void 0,function*(){return new Sr((n,r)=>H(this,void 0,void 0,function*(){let i=setTimeout(()=>{r(new nl("negotiation timed out"))},this.peerConnectionTimeout);const s=()=>{clearTimeout(i),this.publisher.off(sl.NegotiationStarted,c),e.signal.removeEventListener("abort",a)},a=()=>{s(),r(new nl("negotiation aborted"))},c=()=>{e.signal.aborted||(clearTimeout(i),i=setTimeout(()=>{s(),r(new nl("negotiation timed out"))},this.peerConnectionTimeout))};e.signal.addEventListener("abort",a),this.publisher.on(sl.NegotiationStarted,c),this.publisher.once(sl.NegotiationComplete,()=>{s(),n()}),yield this.publisher.negotiate(h=>{s(),h instanceof Error?r(h):r(new Error(String(h)))})}))})}addPublisherTransceiver(e,n){return this.publisher.addTransceiver(e,n)}addPublisherTransceiverOfKind(e,n){return this.publisher.addTransceiverOfKind(e,n)}getMidForReceiver(e){const r=(this.subscriber?this.subscriber.getTransceivers():this.publisher.getTransceivers()).find(i=>i.receiver===e);return r==null?void 0:r.mid}addPublisherTrack(e){return this.publisher.addTrack(e)}createPublisherDataChannel(e,n){return this.publisher.createDataChannel(e,n)}getConnectedAddress(e){return e===Gi.PUBLISHER?this.publisher.getConnectedAddress():e===Gi.SUBSCRIBER?this.publisher.getConnectedAddress():this.requiredTransports[0].getConnectedAddress()}get requiredTransports(){const e=[];return this.isPublisherConnectionRequired&&e.push(this.publisher),this.isSubscriberConnectionRequired&&this.subscriber&&e.push(this.subscriber),e}ensureTransportConnected(e,n){return H(this,arguments,void 0,function(r,i){var s=this;let a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.peerConnectionTimeout;return(function*(){if(r.getConnectionState()!=="connected")return new Promise((h,d)=>H(s,void 0,void 0,function*(){const f=()=>{this.log.warn("abort transport connection",this.logContext),Qn.clearTimeout(p),d(ht.cancelled("room connection has been cancelled"))};i!=null&&i.signal.aborted&&f(),i==null||i.signal.addEventListener("abort",f);const p=Qn.setTimeout(()=>{i==null||i.signal.removeEventListener("abort",f),d(ht.internal("could not establish pc connection"))},a);for(;this.state!==Ln.CONNECTED;)if(yield Cr(50),i!=null&&i.signal.aborted){d(ht.cancelled("room connection has been cancelled"));return}Qn.clearTimeout(p),i==null||i.signal.removeEventListener("abort",f),h()}))})()})}}const WP=5e3,yW=3e4;class qt{static fetchRegionSettings(e,n,r){return H(this,void 0,void 0,function*(){const i=yield qt.fetchLock.lock();try{const s=yield fetch("".concat(xW(e),"/regions"),{headers:{authorization:"Bearer ".concat(n)},signal:r});if(s.ok){const a=BV(s.headers),c=a?a*1e3:WP;return{regionSettings:yield s.json(),updatedAtInMs:Date.now(),maxAgeInMs:c}}else throw s.status===401?ht.notAllowed("Could not fetch region settings: ".concat(s.statusText),s.status):ht.internal("Could not fetch region settings: ".concat(s.statusText))}catch(s){throw s instanceof ht?s:r!=null&&r.aborted?ht.cancelled("Region fetching was aborted"):ht.serverUnreachable("Could not fetch region settings, ".concat(s instanceof Error?"".concat(s.name,": ").concat(s.message):s))}finally{i()}})}static scheduleRefetch(e,n,r){return H(this,void 0,void 0,function*(){const i=qt.settingsTimeouts.get(e.hostname);clearTimeout(i),qt.settingsTimeouts.set(e.hostname,setTimeout(()=>H(this,void 0,void 0,function*(){try{const s=yield qt.fetchRegionSettings(e,n);qt.updateCachedRegionSettings(e,n,s)}catch(s){if(s instanceof ht&&s.reason===xn.NotAllowed){Tt.debug("token is not valid, cancelling auto region refresh");return}Tt.debug("auto refetching of region settings failed",{error:s}),qt.scheduleRefetch(e,n,r)}}),r))})}static updateCachedRegionSettings(e,n,r){qt.cache.set(e.hostname,r),qt.scheduleRefetch(e,n,r.maxAgeInMs)}static stopRefetch(e){const n=qt.settingsTimeouts.get(e);n&&(clearTimeout(n),qt.settingsTimeouts.delete(e))}static scheduleCleanup(e){let n=qt.connectionTrackers.get(e);n&&(n.cleanupTimeout&&clearTimeout(n.cleanupTimeout),n.cleanupTimeout=setTimeout(()=>{const r=qt.connectionTrackers.get(e);r&&r.connectionCount===0&&(Tt.debug("stopping region refetch after disconnect delay",{hostname:e}),qt.stopRefetch(e)),r&&(r.cleanupTimeout=void 0)},yW))}static cancelCleanup(e){const n=qt.connectionTrackers.get(e);n!=null&&n.cleanupTimeout&&(clearTimeout(n.cleanupTimeout),n.cleanupTimeout=void 0)}notifyConnected(){const e=this.serverUrl.hostname;let n=qt.connectionTrackers.get(e);n||(n={connectionCount:0},qt.connectionTrackers.set(e,n)),n.connectionCount++,qt.cancelCleanup(e)}notifyDisconnected(){const e=this.serverUrl.hostname,n=qt.connectionTrackers.get(e);n&&(n.connectionCount=Math.max(0,n.connectionCount-1),n.connectionCount===0&&qt.scheduleCleanup(e))}constructor(e,n){this.attemptedRegions=[],this.serverUrl=new URL(e),this.token=n}updateToken(e){this.token=e}isCloud(){return Sc(this.serverUrl)}getServerUrl(){return this.serverUrl}fetchRegionSettings(e){return H(this,void 0,void 0,function*(){return qt.fetchRegionSettings(this.serverUrl,this.token,e)})}getNextBestRegionUrl(e){return H(this,void 0,void 0,function*(){if(!this.isCloud())throw Error("region availability is only supported for LiveKit Cloud domains");let n=qt.cache.get(this.serverUrl.hostname);(!n||Date.now()-n.updatedAtInMs>n.maxAgeInMs)&&(n=yield this.fetchRegionSettings(e),qt.updateCachedRegionSettings(this.serverUrl,this.token,n));const r=n.regionSettings.regions.filter(i=>!this.attemptedRegions.find(s=>s.url===i.url));if(r.length>0){const i=r[0];return this.attemptedRegions.push(i),Tt.debug("next region: ".concat(i.region)),i.url}else return null})}resetAttempts(){this.attemptedRegions=[]}setServerReportedRegions(e){qt.updateCachedRegionSettings(this.serverUrl,this.token,e)}}qt.cache=new Map;qt.settingsTimeouts=new Map;qt.connectionTrackers=new Map;qt.fetchLock=new fr;function xW(t){return"".concat(t.protocol.replace("ws","http"),"//").concat(t.host,"/settings")}class zn extends Error{constructor(e,n,r){super(n),this.code=e,this.message=DC(n,zn.MAX_MESSAGE_BYTES),this.data=r?DC(r,zn.MAX_DATA_BYTES):void 0}static fromProto(e){return new zn(e.code,e.message,e.data)}toProto(){return new I2({code:this.code,message:this.message,data:this.data})}static builtIn(e,n){return new zn(zn.ErrorCode[e],zn.ErrorMessage[e],n)}}zn.MAX_MESSAGE_BYTES=256;zn.MAX_DATA_BYTES=15360;zn.ErrorCode={APPLICATION_ERROR:1500,CONNECTION_TIMEOUT:1501,RESPONSE_TIMEOUT:1502,RECIPIENT_DISCONNECTED:1503,RESPONSE_PAYLOAD_TOO_LARGE:1504,SEND_FAILED:1505,UNSUPPORTED_METHOD:1400,RECIPIENT_NOT_FOUND:1401,REQUEST_PAYLOAD_TOO_LARGE:1402,UNSUPPORTED_SERVER:1403,UNSUPPORTED_VERSION:1404};zn.ErrorMessage={APPLICATION_ERROR:"Application error in method handler",CONNECTION_TIMEOUT:"Connection timeout",RESPONSE_TIMEOUT:"Response timeout",RECIPIENT_DISCONNECTED:"Recipient disconnected",RESPONSE_PAYLOAD_TOO_LARGE:"Response payload too large",SEND_FAILED:"Failed to send",UNSUPPORTED_METHOD:"Method not supported at destination",RECIPIENT_NOT_FOUND:"Recipient not found",REQUEST_PAYLOAD_TOO_LARGE:"Request payload too large",UNSUPPORTED_SERVER:"RPC not supported by server",UNSUPPORTED_VERSION:"Unsupported RPC version"};const HP=15360;function Ix(t){return new TextEncoder().encode(t).length}function DC(t,e){if(Ix(t)<=e)return t;let n=0,r=t.length;const i=new TextEncoder;for(;n<r;){const s=Math.floor((n+r+1)/2);i.encode(t.slice(0,s)).length<=e?n=s:r=s-1}return t.slice(0,n)}const Mx=2e3;function Ip(t,e){if(!e)return 0;let n,r;return"bytesReceived"in t?(n=t.bytesReceived,r=e.bytesReceived):"bytesSent"in t&&(n=t.bytesSent,r=e.bytesSent),n===void 0||r===void 0||t.timestamp===void 0||e.timestamp===void 0?0:(n-r)*8*1e3/(t.timestamp-e.timestamp)}const Dx=typeof MediaRecorder<"u";class bW{constructor(){throw new Error("MediaRecorder is not available in this environment")}}const kW=Dx?MediaRecorder:bW;class wW extends kW{constructor(e,n){if(!Dx)throw new Error("MediaRecorder is not available in this environment");super(new MediaStream([e.mediaStreamTrack]),n);let r,i;const s=()=>i===void 0,a=()=>{this.removeEventListener("dataavailable",r),this.removeEventListener("stop",a),this.removeEventListener("error",c),i==null||i.close(),i=void 0},c=h=>{i==null||i.error(h),this.removeEventListener("dataavailable",r),this.removeEventListener("stop",a),this.removeEventListener("error",c),i=void 0};this.byteStream=new ReadableStream({start:h=>{i=h,r=d=>H(this,void 0,void 0,function*(){let f;if(d.data.arrayBuffer){const p=yield d.data.arrayBuffer();f=new Uint8Array(p)}else if(d.data.byteArray)f=d.data.byteArray;else throw new Error("no data available!");s()||h.enqueue(f)}),this.addEventListener("dataavailable",r)},cancel:()=>{a()}}),this.addEventListener("stop",a),this.addEventListener("error",c)}}function SW(){return Dx}const CW=1e3,TW=1e4;class qP extends Te{get sender(){return this._sender}set sender(e){this._sender=e}get constraints(){return this._constraints}get hasPreConnectBuffer(){return!!this.localTrackRecorder}constructor(e,n,r){let i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1,s=arguments.length>4?arguments[4]:void 0;super(e,n,s),this.manuallyStopped=!1,this.pendingDeviceChange=!1,this._isUpstreamPaused=!1,this.handleTrackMuteEvent=()=>this.debouncedTrackMuteHandler().catch(()=>this.log.debug("track mute bounce got cancelled by an unmute event",this.logContext)),this.debouncedTrackMuteHandler=Px(()=>H(this,void 0,void 0,function*(){yield this.pauseUpstream()}),5e3),this.handleTrackUnmuteEvent=()=>H(this,void 0,void 0,function*(){this.debouncedTrackMuteHandler.cancel("unmute"),yield this.resumeUpstream()}),this.handleEnded=()=>{this.isInBackground&&(this.reacquireTrack=!0),this._mediaStreamTrack.removeEventListener("mute",this.handleTrackMuteEvent),this._mediaStreamTrack.removeEventListener("unmute",this.handleTrackUnmuteEvent),this.emit(Fe.Ended,this)},this.reacquireTrack=!1,this.providedByUser=i,this.muteLock=new fr,this.pauseUpstreamLock=new fr,this.trackChangeLock=new fr,this.trackChangeLock.lock().then(a=>H(this,void 0,void 0,function*(){try{yield this.setMediaStreamTrack(e,!0)}finally{a()}})),this._constraints=e.getConstraints(),r&&(this._constraints=r)}get id(){return this._mediaStreamTrack.id}get dimensions(){if(this.kind!==Te.Kind.Video)return;const{width:e,height:n}=this._mediaStreamTrack.getSettings();if(e&&n)return{width:e,height:n}}get isUpstreamPaused(){return this._isUpstreamPaused}get isUserProvided(){return this.providedByUser}get mediaStreamTrack(){var e,n;return(n=(e=this.processor)===null||e===void 0?void 0:e.processedTrack)!==null&&n!==void 0?n:this._mediaStreamTrack}get isLocal(){return!0}getSourceTrackSettings(){return this._mediaStreamTrack.getSettings()}setMediaStreamTrack(e,n,r){return H(this,void 0,void 0,function*(){var i;if(e===this._mediaStreamTrack&&!n)return;this._mediaStreamTrack&&(this.attachedElements.forEach(a=>{hc(this._mediaStreamTrack,a)}),this.debouncedTrackMuteHandler.cancel("new-track"),this._mediaStreamTrack.removeEventListener("ended",this.handleEnded),this._mediaStreamTrack.removeEventListener("mute",this.handleTrackMuteEvent),this._mediaStreamTrack.removeEventListener("unmute",this.handleTrackUnmuteEvent)),this.mediaStream=new MediaStream([e]),e&&(e.addEventListener("ended",this.handleEnded),e.addEventListener("mute",this.handleTrackMuteEvent),e.addEventListener("unmute",this.handleTrackUnmuteEvent),this._constraints=e.getConstraints());let s;if(this.processor&&e){if(this.log.debug("restarting processor",this.logContext),this.kind==="unknown")throw TypeError("cannot set processor on track of unknown kind");this.processorElement&&(rc(e,this.processorElement),this.processorElement.muted=!0),yield this.processor.restart({track:e,kind:this.kind,element:this.processorElement}),s=this.processor.processedTrack}this.sender&&((i=this.sender.transport)===null||i===void 0?void 0:i.state)!=="closed"&&(yield this.sender.replaceTrack(s??e)),!this.providedByUser&&this._mediaStreamTrack!==e&&this._mediaStreamTrack.stop(),this._mediaStreamTrack=e,e&&(this._mediaStreamTrack.enabled=r?!0:!this.isMuted,yield this.resumeUpstream(),this.attachedElements.forEach(a=>{rc(s??e,a)}))})}waitForDimensions(){return H(this,arguments,void 0,function(){var e=this;let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:CW;return(function*(){var r;if(e.kind===Te.Kind.Audio)throw new Error("cannot get dimensions for audio tracks");((r=Qr())===null||r===void 0?void 0:r.os)==="iOS"&&(yield Cr(10));const i=Date.now();for(;Date.now()-i<n;){const s=e.dimensions;if(s)return s;yield Cr(50)}throw new da("unable to get track dimensions after timeout")})()})}setDeviceId(e){return H(this,void 0,void 0,function*(){return this._constraints.deviceId===e&&this._mediaStreamTrack.getSettings().deviceId===rl(e)?!0:(this._constraints.deviceId=e,this.isMuted?(this.pendingDeviceChange=!0,!0):(yield this.restartTrack(),rl(e)===this._mediaStreamTrack.getSettings().deviceId))})}getDeviceId(){return H(this,arguments,void 0,function(){var e=this;let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!0;return(function*(){if(e.source===Te.Source.ScreenShare)return;const{deviceId:r,groupId:i}=e._mediaStreamTrack.getSettings(),s=e.kind===Te.Kind.Audio?"audioinput":"videoinput";return n?cr.getInstance().normalizeDeviceId(s,r,i):r})()})}mute(){return H(this,void 0,void 0,function*(){return this.setTrackMuted(!0),this})}unmute(){return H(this,void 0,void 0,function*(){return this.setTrackMuted(!1),this})}replaceTrack(e,n){return H(this,void 0,void 0,function*(){const r=yield this.trackChangeLock.lock();try{if(!this.sender)throw new da("unable to replace an unpublished track");let i,s;return typeof n=="boolean"?i=n:n!==void 0&&(i=n.userProvidedTrack,s=n.stopProcessor),this.providedByUser=i??!0,this.log.debug("replace MediaStreamTrack",this.logContext),yield this.setMediaStreamTrack(e),s&&this.processor&&(yield this.internalStopProcessor()),this}finally{r()}})}restart(e,n){return H(this,void 0,void 0,function*(){this.manuallyStopped=!1;const r=yield this.trackChangeLock.lock();try{e||(e=this._constraints);const{deviceId:i,facingMode:s}=e,a=H$(e,["deviceId","facingMode"]);this.log.debug("restarting track with constraints",Object.assign(Object.assign({},this.logContext),{constraints:e}));const c={audio:!1,video:!1};this.kind===Te.Kind.Video?c.video=i||s?{deviceId:i,facingMode:s}:!0:c.audio=i?Object.assign({deviceId:i},a):!0,this.attachedElements.forEach(f=>{hc(this.mediaStreamTrack,f)}),this._mediaStreamTrack.removeEventListener("ended",this.handleEnded),this._mediaStreamTrack.stop();const d=(yield navigator.mediaDevices.getUserMedia(c)).getTracks()[0];return this.kind===Te.Kind.Video&&(yield d.applyConstraints(a)),d.addEventListener("ended",this.handleEnded),this.log.debug("re-acquired MediaStreamTrack",this.logContext),yield this.setMediaStreamTrack(d,!1,n),this._constraints=e,this.pendingDeviceChange=!1,this.emit(Fe.Restarted,this),this.manuallyStopped&&(this.log.warn("track was stopped during a restart, stopping restarted track",this.logContext),this.stop()),this}finally{r()}})}setTrackMuted(e){this.log.debug("setting ".concat(this.kind," track ").concat(e?"muted":"unmuted"),this.logContext),!(this.isMuted===e&&this._mediaStreamTrack.enabled!==e)&&(this.isMuted=e,this._mediaStreamTrack.enabled=!e,this.emit(e?Fe.Muted:Fe.Unmuted,this))}get needsReAcquisition(){return this._mediaStreamTrack.readyState!=="live"||this._mediaStreamTrack.muted||!this._mediaStreamTrack.enabled||this.reacquireTrack}handleAppVisibilityChanged(){const e=Object.create(null,{handleAppVisibilityChanged:{get:()=>super.handleAppVisibilityChanged}});return H(this,void 0,void 0,function*(){yield e.handleAppVisibilityChanged.call(this),LP()&&(this.log.debug("visibility changed, is in Background: ".concat(this.isInBackground),this.logContext),!this.isInBackground&&this.needsReAcquisition&&!this.isUserProvided&&!this.isMuted&&(this.log.debug("track needs to be reacquired, restarting ".concat(this.source),this.logContext),yield this.restart(),this.reacquireTrack=!1))})}stop(){var e;this.manuallyStopped=!0,super.stop(),this._mediaStreamTrack.removeEventListener("ended",this.handleEnded),this._mediaStreamTrack.removeEventListener("mute",this.handleTrackMuteEvent),this._mediaStreamTrack.removeEventListener("unmute",this.handleTrackUnmuteEvent),(e=this.processor)===null||e===void 0||e.destroy(),this.processor=void 0}pauseUpstream(){return H(this,void 0,void 0,function*(){var e;const n=yield this.pauseUpstreamLock.lock();try{if(this._isUpstreamPaused===!0)return;if(!this.sender){this.log.warn("unable to pause upstream for an unpublished track",this.logContext);return}this._isUpstreamPaused=!0,this.emit(Fe.UpstreamPaused,this);const r=Qr();if((r==null?void 0:r.name)==="Safari"&&Ls(r.version,"12.0")<0)throw new kx("pauseUpstream is not supported on Safari < 12.");((e=this.sender.transport)===null||e===void 0?void 0:e.state)!=="closed"&&(yield this.sender.replaceTrack(null))}finally{n()}})}resumeUpstream(){return H(this,void 0,void 0,function*(){var e;const n=yield this.pauseUpstreamLock.lock();try{if(this._isUpstreamPaused===!1)return;if(!this.sender){this.log.warn("unable to resume upstream for an unpublished track",this.logContext);return}this._isUpstreamPaused=!1,this.emit(Fe.UpstreamResumed,this),((e=this.sender.transport)===null||e===void 0?void 0:e.state)!=="closed"&&(yield this.sender.replaceTrack(this.mediaStreamTrack))}finally{n()}})}getRTCStatsReport(){return H(this,void 0,void 0,function*(){var e;return!((e=this.sender)===null||e===void 0)&&e.getStats?yield this.sender.getStats():void 0})}setProcessor(e){return H(this,arguments,void 0,function(n){var r=this;let i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0;return(function*(){var s;const a=yield r.trackChangeLock.lock();try{r.log.debug("setting up processor",r.logContext);const c=document.createElement(r.kind),h={kind:r.kind,track:r._mediaStreamTrack,element:c,audioContext:r.audioContext};if(yield n.init(h),r.log.debug("processor initialized",r.logContext),r.processor&&(yield r.internalStopProcessor()),r.kind==="unknown")throw TypeError("cannot set processor on track of unknown kind");if(rc(r._mediaStreamTrack,c),c.muted=!0,c.play().catch(d=>{d instanceof DOMException&&d.name==="AbortError"?(r.log.warn("failed to play processor element, retrying",Object.assign(Object.assign({},r.logContext),{error:d})),setTimeout(()=>{c.play().catch(f=>{r.log.error("failed to play processor element",Object.assign(Object.assign({},r.logContext),{err:f}))})},100)):r.log.error("failed to play processor element",Object.assign(Object.assign({},r.logContext),{error:d}))}),r.processor=n,r.processorElement=c,r.processor.processedTrack){for(const d of r.attachedElements)d!==r.processorElement&&i&&(hc(r._mediaStreamTrack,d),rc(r.processor.processedTrack,d));yield(s=r.sender)===null||s===void 0?void 0:s.replaceTrack(r.processor.processedTrack)}r.emit(Fe.TrackProcessorUpdate,r.processor)}finally{a()}})()})}getProcessor(){return this.processor}stopProcessor(){return H(this,arguments,void 0,function(){var e=this;let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!0;return(function*(){const r=yield e.trackChangeLock.lock();try{yield e.internalStopProcessor(n)}finally{r()}})()})}internalStopProcessor(){return H(this,arguments,void 0,function(){var e=this;let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!0;return(function*(){var r,i;e.processor&&(e.log.debug("stopping processor",e.logContext),(r=e.processor.processedTrack)===null||r===void 0||r.stop(),yield e.processor.destroy(),e.processor=void 0,n||((i=e.processorElement)===null||i===void 0||i.remove(),e.processorElement=void 0),yield e._mediaStreamTrack.applyConstraints(e._constraints),yield e.setMediaStreamTrack(e._mediaStreamTrack,!0),e.emit(Fe.TrackProcessorUpdate))})()})}startPreConnectBuffer(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:100;if(!SW()){this.log.warn("MediaRecorder is not available, cannot start preconnect buffer",this.logContext);return}if(this.localTrackRecorder){this.log.warn("preconnect buffer already started");return}else{let n="audio/webm;codecs=opus";MediaRecorder.isTypeSupported(n)||(n="video/mp4"),this.localTrackRecorder=new wW(this,{mimeType:n})}this.localTrackRecorder.start(e),this.autoStopPreConnectBuffer=setTimeout(()=>{this.log.warn("preconnect buffer timed out, stopping recording automatically",this.logContext),this.stopPreConnectBuffer()},TW)}stopPreConnectBuffer(){clearTimeout(this.autoStopPreConnectBuffer),this.localTrackRecorder&&(this.localTrackRecorder.stop(),this.localTrackRecorder=void 0)}getPreConnectBuffer(){var e;return(e=this.localTrackRecorder)===null||e===void 0?void 0:e.byteStream}getPreConnectBufferMimeType(){var e;return(e=this.localTrackRecorder)===null||e===void 0?void 0:e.mimeType}}class Jf extends qP{get enhancedNoiseCancellation(){return this.isKrispNoiseFilterEnabled}constructor(e,n){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,i=arguments.length>3?arguments[3]:void 0,s=arguments.length>4?arguments[4]:void 0;super(e,Te.Kind.Audio,n,r,s),this.stopOnMute=!1,this.isKrispNoiseFilterEnabled=!1,this.monitorSender=()=>H(this,void 0,void 0,function*(){if(!this.sender){this._currentBitrate=0;return}let a;try{a=yield this.getSenderStats()}catch(c){this.log.error("could not get audio sender stats",Object.assign(Object.assign({},this.logContext),{error:c}));return}a&&this.prevStats&&(this._currentBitrate=Ip(a,this.prevStats)),this.prevStats=a}),this.handleKrispNoiseFilterEnable=()=>{this.isKrispNoiseFilterEnabled=!0,this.log.debug("Krisp noise filter enabled",this.logContext),this.emit(Fe.AudioTrackFeatureUpdate,this,lr.TF_ENHANCED_NOISE_CANCELLATION,!0)},this.handleKrispNoiseFilterDisable=()=>{this.isKrispNoiseFilterEnabled=!1,this.log.debug("Krisp noise filter disabled",this.logContext),this.emit(Fe.AudioTrackFeatureUpdate,this,lr.TF_ENHANCED_NOISE_CANCELLATION,!1)},this.audioContext=i,this.checkForSilence()}mute(){const e=Object.create(null,{mute:{get:()=>super.mute}});return H(this,void 0,void 0,function*(){const n=yield this.muteLock.lock();try{return this.isMuted?(this.log.debug("Track already muted",this.logContext),this):(this.source===Te.Source.Microphone&&this.stopOnMute&&!this.isUserProvided&&(this.log.debug("stopping mic track",this.logContext),this._mediaStreamTrack.stop()),yield e.mute.call(this),this)}finally{n()}})}unmute(){const e=Object.create(null,{unmute:{get:()=>super.unmute}});return H(this,void 0,void 0,function*(){const n=yield this.muteLock.lock();try{return this.isMuted?(this.source===Te.Source.Microphone&&(this.stopOnMute||this._mediaStreamTrack.readyState==="ended"||this.pendingDeviceChange)&&!this.isUserProvided&&(this.log.debug("reacquiring mic track",this.logContext),yield this.restart(void 0,!0)),yield e.unmute.call(this),this):(this.log.debug("Track already unmuted",this.logContext),this)}finally{n()}})}restartTrack(e){return H(this,void 0,void 0,function*(){let n;if(e){const r=Sx({audio:e});typeof r.audio!="boolean"&&(n=r.audio)}yield this.restart(n)})}restart(e,n){const r=Object.create(null,{restart:{get:()=>super.restart}});return H(this,void 0,void 0,function*(){const i=yield r.restart.call(this,e,n);return this.checkForSilence(),i})}startMonitor(){Yr()&&(this.monitorInterval||(this.monitorInterval=setInterval(()=>{this.monitorSender()},Mx)))}setProcessor(e){return H(this,void 0,void 0,function*(){var n;const r=yield this.trackChangeLock.lock();try{if(!Os()&&!this.audioContext)throw Error("Audio context needs to be set on LocalAudioTrack in order to enable processors");this.processor&&(yield this.internalStopProcessor());const i={kind:this.kind,track:this._mediaStreamTrack,audioContext:this.audioContext};this.log.debug("setting up audio processor ".concat(e.name),this.logContext),yield e.init(i),this.processor=e,this.processor.processedTrack&&(yield(n=this.sender)===null||n===void 0?void 0:n.replaceTrack(this.processor.processedTrack),this.processor.processedTrack.addEventListener("enable-lk-krisp-noise-filter",this.handleKrispNoiseFilterEnable),this.processor.processedTrack.addEventListener("disable-lk-krisp-noise-filter",this.handleKrispNoiseFilterDisable)),this.emit(Fe.TrackProcessorUpdate,this.processor)}finally{r()}})}setAudioContext(e){this.audioContext=e}getSenderStats(){return H(this,void 0,void 0,function*(){var e;if(!(!((e=this.sender)===null||e===void 0)&&e.getStats))return;const n=yield this.sender.getStats();let r;return n.forEach(i=>{i.type==="outbound-rtp"&&(r={type:"audio",streamId:i.id,packetsSent:i.packetsSent,packetsLost:i.packetsLost,bytesSent:i.bytesSent,timestamp:i.timestamp,roundTripTime:i.roundTripTime,jitter:i.jitter})}),r})}checkForSilence(){return H(this,void 0,void 0,function*(){const e=yield DP(this);return e&&(this.isMuted||this.log.debug("silence detected on local audio track",this.logContext),this.emit(Fe.AudioSilenceDetected)),e})}}function NW(t,e,n){switch(t.kind){case"audio":return new Jf(t,e,!1,void 0,n);case"video":return new Xf(t,e,!1,n);default:throw new da("unsupported track type: ".concat(t.kind))}}const EW=Object.values(ud),jW=Object.values(Av),PW=Object.values(wx),_W=[ud.h180,ud.h360],RW=[Av.h180,Av.h360],IW=t=>[{scaleResolutionDownBy:2,fps:t.encoding.maxFramerate}].map(n=>{var r,i;return new pn(Math.floor(t.width/n.scaleResolutionDownBy),Math.floor(t.height/n.scaleResolutionDownBy),Math.max(15e4,Math.floor(t.encoding.maxBitrate/(Math.pow(n.scaleResolutionDownBy,2)*(((r=t.encoding.maxFramerate)!==null&&r!==void 0?r:30)/((i=n.fps)!==null&&i!==void 0?i:30))))),n.fps,t.encoding.priority)}),Hv=["q","h","f"];function qv(t,e,n,r){var i,s;let a=r==null?void 0:r.videoEncoding;t&&(a=r==null?void 0:r.screenShareEncoding);const c=r==null?void 0:r.simulcast,h=r==null?void 0:r.scalabilityMode,d=r==null?void 0:r.videoCodec;if(!a&&!c&&!h||!e||!n)return[{}];a||(a=DW(t,e,n,d),Tt.debug("using video encoding",a));const f=a.maxFramerate,p=new pn(e,n,a.maxBitrate,a.maxFramerate,a.priority);if(h&&Ji(d)){const k=new KP(h),w=[];if(k.spatial>3)throw new Error("unsupported scalabilityMode: ".concat(h));const S=Qr();if(dd()||Os()||(S==null?void 0:S.name)==="Chrome"&&Ls(S==null?void 0:S.version,"113")<0){const T=k.suffix=="h"?2:3,C=jV(S);for(let j=0;j<k.spatial;j+=1)w.push({rid:Hv[2-j],maxBitrate:a.maxBitrate/Math.pow(T,j),maxFramerate:p.encoding.maxFramerate,scaleResolutionDownBy:C?Math.pow(2,j):void 0});w[0].scalabilityMode=h}else w.push({maxBitrate:a.maxBitrate,maxFramerate:p.encoding.maxFramerate,scalabilityMode:h});return p.encoding.priority&&(w[0].priority=p.encoding.priority,w[0].networkPriority=p.encoding.priority),Tt.debug("using svc encoding",{encodings:w}),w}if(!c)return[a];let g=[];t?g=(i=OC(r==null?void 0:r.screenShareSimulcastLayers))!==null&&i!==void 0?i:AC(t,p):g=(s=OC(r==null?void 0:r.videoSimulcastLayers))!==null&&s!==void 0?s:AC(t,p);let v;if(g.length>0){const k=g[0];g.length>1&&([,v]=g);const w=Math.max(e,n);if(w>=960&&v)return E0(e,n,[k,v,p],f);if(w>=480)return E0(e,n,[k,p],f)}return E0(e,n,[p])}function MW(t,e,n){var r,i,s,a;if(!n.backupCodec||n.backupCodec===!0||n.backupCodec.codec===n.videoCodec)return;e!==n.backupCodec.codec&&Tt.warn("requested a different codec than specified as backup",{serverRequested:e,backup:n.backupCodec.codec}),n.videoCodec=e,n.videoEncoding=n.backupCodec.encoding;const c=t.mediaStreamTrack.getSettings(),h=(r=c.width)!==null&&r!==void 0?r:(i=t.dimensions)===null||i===void 0?void 0:i.width,d=(s=c.height)!==null&&s!==void 0?s:(a=t.dimensions)===null||a===void 0?void 0:a.height;return t.source===Te.Source.ScreenShare&&n.simulcast&&(n.simulcast=!1),qv(t.source===Te.Source.ScreenShare,h,d,n)}function DW(t,e,n,r){const i=AW(t,e,n);let{encoding:s}=i[0];const a=Math.max(e,n);for(let c=0;c<i.length;c+=1){const h=i[c];if(s=h.encoding,h.width>=a)break}if(r)switch(r){case"av1":case"h265":s=Object.assign({},s),s.maxBitrate=s.maxBitrate*.7;break;case"vp9":s=Object.assign({},s),s.maxBitrate=s.maxBitrate*.85;break}return s}function AW(t,e,n){if(t)return PW;const r=e>n?e/n:n/e;return Math.abs(r-16/9)<Math.abs(r-4/3)?EW:jW}function AC(t,e){if(t)return IW(e);const{width:n,height:r}=e,i=n>r?n/r:r/n;return Math.abs(i-16/9)<Math.abs(i-4/3)?_W:RW}function E0(t,e,n,r){const i=[];if(n.forEach((s,a)=>{if(a>=Hv.length)return;const c=Math.min(t,e),d={rid:Hv[a],scaleResolutionDownBy:Math.max(1,c/Math.min(s.width,s.height)),maxBitrate:s.encoding.maxBitrate},f=r&&s.encoding.maxFramerate?Math.min(r,s.encoding.maxFramerate):s.encoding.maxFramerate;f&&(d.maxFramerate=f);const p=dl()||a===0;s.encoding.priority&&p&&(d.priority=s.encoding.priority,d.networkPriority=s.encoding.priority),i.push(d)}),Os()&&UP()==="ios"){let s;i.forEach(c=>{s?c.maxFramerate&&c.maxFramerate>s&&(s=c.maxFramerate):s=c.maxFramerate});let a=!0;i.forEach(c=>{var h;c.maxFramerate!=s&&(a&&(a=!1,Tt.info("Simulcast on iOS React-Native requires all encodings to share the same framerate.")),Tt.info('Setting framerate of encoding "'.concat((h=c.rid)!==null&&h!==void 0?h:"",'" to ').concat(s)),c.maxFramerate=s)})}return i}function OC(t){if(t)return t.sort((e,n)=>{const{encoding:r}=e,{encoding:i}=n;return r.maxBitrate>i.maxBitrate?1:r.maxBitrate<i.maxBitrate?-1:r.maxBitrate===i.maxBitrate&&r.maxFramerate&&i.maxFramerate?r.maxFramerate>i.maxFramerate?1:-1:0})}class KP{constructor(e){const n=e.match(/^L(\d)T(\d)(h|_KEY|_KEY_SHIFT){0,1}$/);if(!n)throw new Error("invalid scalability mode");if(this.spatial=parseInt(n[1]),this.temporal=parseInt(n[2]),n.length>3)switch(n[3]){case"h":case"_KEY":case"_KEY_SHIFT":this.suffix=n[3]}}toString(){var e;return"L".concat(this.spatial,"T").concat(this.temporal).concat((e=this.suffix)!==null&&e!==void 0?e:"")}}function OW(t){return t.source===Te.Source.ScreenShare||t.constraints.height&&rl(t.constraints.height)>=1080?"maintain-resolution":"balanced"}const LW=5e3;class Xf extends qP{get sender(){return this._sender}set sender(e){this._sender=e,this.degradationPreference&&this.setDegradationPreference(this.degradationPreference)}constructor(e,n){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,i=arguments.length>3?arguments[3]:void 0;super(e,Te.Kind.Video,n,r,i),this.simulcastCodecs=new Map,this.degradationPreference="balanced",this.isCpuConstrained=!1,this.optimizeForPerformance=!1,this.monitorSender=()=>H(this,void 0,void 0,function*(){if(!this.sender){this._currentBitrate=0;return}let s;try{s=yield this.getSenderStats()}catch(h){this.log.error("could not get video sender stats",Object.assign(Object.assign({},this.logContext),{error:h}));return}const a=new Map(s.map(h=>[h.rid,h])),c=s.some(h=>h.qualityLimitationReason==="cpu");if(c!==this.isCpuConstrained&&(this.isCpuConstrained=c,this.isCpuConstrained&&this.emit(Fe.CpuConstrained)),this.prevStats){let h=0;a.forEach((d,f)=>{var p;const g=(p=this.prevStats)===null||p===void 0?void 0:p.get(f);h+=Ip(d,g)}),this._currentBitrate=h}this.prevStats=a}),this.senderLock=new fr}get isSimulcast(){return!!(this.sender&&this.sender.getParameters().encodings.length>1)}startMonitor(e){var n;if(this.signalClient=e,!Yr())return;const r=(n=this.sender)===null||n===void 0?void 0:n.getParameters();r&&(this.encodings=r.encodings),!this.monitorInterval&&(this.monitorInterval=setInterval(()=>{this.monitorSender()},Mx))}stop(){this._mediaStreamTrack.getConstraints(),this.simulcastCodecs.forEach(e=>{e.mediaStreamTrack.stop()}),super.stop()}pauseUpstream(){const e=Object.create(null,{pauseUpstream:{get:()=>super.pauseUpstream}});return H(this,void 0,void 0,function*(){var n,r,i,s,a;yield e.pauseUpstream.call(this);try{for(var c=!0,h=Yi(this.simulcastCodecs.values()),d;d=yield h.next(),n=d.done,!n;c=!0)s=d.value,c=!1,yield(a=s.sender)===null||a===void 0?void 0:a.replaceTrack(null)}catch(f){r={error:f}}finally{try{!c&&!n&&(i=h.return)&&(yield i.call(h))}finally{if(r)throw r.error}}})}resumeUpstream(){const e=Object.create(null,{resumeUpstream:{get:()=>super.resumeUpstream}});return H(this,void 0,void 0,function*(){var n,r,i,s,a;yield e.resumeUpstream.call(this);try{for(var c=!0,h=Yi(this.simulcastCodecs.values()),d;d=yield h.next(),n=d.done,!n;c=!0){s=d.value,c=!1;const f=s;yield(a=f.sender)===null||a===void 0?void 0:a.replaceTrack(f.mediaStreamTrack)}}catch(f){r={error:f}}finally{try{!c&&!n&&(i=h.return)&&(yield i.call(h))}finally{if(r)throw r.error}}})}mute(){const e=Object.create(null,{mute:{get:()=>super.mute}});return H(this,void 0,void 0,function*(){const n=yield this.muteLock.lock();try{return this.isMuted?(this.log.debug("Track already muted",this.logContext),this):(this.source===Te.Source.Camera&&!this.isUserProvided&&(this.log.debug("stopping camera track",this.logContext),this._mediaStreamTrack.stop()),yield e.mute.call(this),this)}finally{n()}})}unmute(){const e=Object.create(null,{unmute:{get:()=>super.unmute}});return H(this,void 0,void 0,function*(){const n=yield this.muteLock.lock();try{return this.isMuted?(this.source===Te.Source.Camera&&!this.isUserProvided&&(this.log.debug("reacquiring camera track",this.logContext),yield this.restart(void 0,!0)),yield e.unmute.call(this),this):(this.log.debug("Track already unmuted",this.logContext),this)}finally{n()}})}setTrackMuted(e){super.setTrackMuted(e);for(const n of this.simulcastCodecs.values())n.mediaStreamTrack.enabled=!e}getSenderStats(){return H(this,void 0,void 0,function*(){var e;if(!(!((e=this.sender)===null||e===void 0)&&e.getStats))return[];const n=[],r=yield this.sender.getStats();return r.forEach(i=>{var s;if(i.type==="outbound-rtp"){const a={type:"video",streamId:i.id,frameHeight:i.frameHeight,frameWidth:i.frameWidth,framesPerSecond:i.framesPerSecond,framesSent:i.framesSent,firCount:i.firCount,pliCount:i.pliCount,nackCount:i.nackCount,packetsSent:i.packetsSent,bytesSent:i.bytesSent,qualityLimitationReason:i.qualityLimitationReason,qualityLimitationDurations:i.qualityLimitationDurations,qualityLimitationResolutionChanges:i.qualityLimitationResolutionChanges,rid:(s=i.rid)!==null&&s!==void 0?s:i.id,retransmittedPacketsSent:i.retransmittedPacketsSent,targetBitrate:i.targetBitrate,timestamp:i.timestamp},c=r.get(i.remoteId);c&&(a.jitter=c.jitter,a.packetsLost=c.packetsLost,a.roundTripTime=c.roundTripTime),n.push(a)}}),n.sort((i,s)=>{var a,c;return((a=s.frameWidth)!==null&&a!==void 0?a:0)-((c=i.frameWidth)!==null&&c!==void 0?c:0)}),n})}setPublishingQuality(e){const n=[];for(let r=ui.LOW;r<=ui.HIGH;r+=1)n.push(new vx({quality:r,enabled:r<=e}));this.log.debug("setting publishing quality. max quality ".concat(e),this.logContext),this.setPublishingLayers(Ji(this.codec),n)}restartTrack(e){return H(this,void 0,void 0,function*(){var n,r,i,s,a;let c;if(e){const p=Sx({video:e});typeof p.video!="boolean"&&(c=p.video)}yield this.restart(c),this.isCpuConstrained=!1;try{for(var h=!0,d=Yi(this.simulcastCodecs.values()),f;f=yield d.next(),n=f.done,!n;h=!0){s=f.value,h=!1;const p=s;p.sender&&((a=p.sender.transport)===null||a===void 0?void 0:a.state)!=="closed"&&(p.mediaStreamTrack=this.mediaStreamTrack.clone(),yield p.sender.replaceTrack(p.mediaStreamTrack))}}catch(p){r={error:p}}finally{try{!h&&!n&&(i=d.return)&&(yield i.call(d))}finally{if(r)throw r.error}}})}setProcessor(e){const n=Object.create(null,{setProcessor:{get:()=>super.setProcessor}});return H(this,arguments,void 0,function(r){var i=this;let s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0;return(function*(){var a,c,h,d,f,p;if(yield n.setProcessor.call(i,r,s),!((f=i.processor)===null||f===void 0)&&f.processedTrack)try{for(var g=!0,v=Yi(i.simulcastCodecs.values()),k;k=yield v.next(),a=k.done,!a;g=!0)d=k.value,g=!1,yield(p=d.sender)===null||p===void 0?void 0:p.replaceTrack(i.processor.processedTrack)}catch(w){c={error:w}}finally{try{!g&&!a&&(h=v.return)&&(yield h.call(v))}finally{if(c)throw c.error}}})()})}setDegradationPreference(e){return H(this,void 0,void 0,function*(){if(this.degradationPreference=e,this.sender)try{this.log.debug("setting degradationPreference to ".concat(e),this.logContext);const n=this.sender.getParameters();n.degradationPreference=e,this.sender.setParameters(n)}catch(n){this.log.warn("failed to set degradationPreference",Object.assign({error:n},this.logContext))}})}addSimulcastTrack(e,n){if(this.simulcastCodecs.has(e)){this.log.error("".concat(e," already added, skipping adding simulcast codec"),this.logContext);return}const r={codec:e,mediaStreamTrack:this.mediaStreamTrack.clone(),sender:void 0,encodings:n};return this.simulcastCodecs.set(e,r),r}setSimulcastTrackSender(e,n){const r=this.simulcastCodecs.get(e);r&&(r.sender=n,setTimeout(()=>{this.subscribedCodecs&&this.setPublishingCodecs(this.subscribedCodecs)},LW))}setPublishingCodecs(e){return H(this,void 0,void 0,function*(){var n,r,i,s,a,c,h;if(this.log.debug("setting publishing codecs",Object.assign(Object.assign({},this.logContext),{codecs:e,currentCodec:this.codec})),!this.codec&&e.length>0)return yield this.setPublishingLayers(Ji(e[0].codec),e[0].qualities),[];this.subscribedCodecs=e;const d=[];try{for(n=!0,r=Yi(e);i=yield r.next(),s=i.done,!s;n=!0){h=i.value,n=!1;const f=h;if(!this.codec||this.codec===f.codec)yield this.setPublishingLayers(Ji(f.codec),f.qualities);else{const p=this.simulcastCodecs.get(f.codec);if(this.log.debug("try setPublishingCodec for ".concat(f.codec),Object.assign(Object.assign({},this.logContext),{simulcastCodecInfo:p})),!p||!p.sender){for(const g of f.qualities)if(g.enabled){d.push(f.codec);break}}else p.encodings&&(this.log.debug("try setPublishingLayersForSender ".concat(f.codec),this.logContext),yield LC(p.sender,p.encodings,f.qualities,this.senderLock,Ji(f.codec),this.log,this.logContext))}}}catch(f){a={error:f}}finally{try{!n&&!s&&(c=r.return)&&(yield c.call(r))}finally{if(a)throw a.error}}return d})}setPublishingLayers(e,n){return H(this,void 0,void 0,function*(){if(this.optimizeForPerformance){this.log.info("skipping setPublishingLayers due to optimized publishing performance",Object.assign(Object.assign({},this.logContext),{qualities:n}));return}this.log.debug("setting publishing layers",Object.assign(Object.assign({},this.logContext),{qualities:n})),!(!this.sender||!this.encodings)&&(yield LC(this.sender,this.encodings,n,this.senderLock,e,this.log,this.logContext))})}prioritizePerformance(){return H(this,void 0,void 0,function*(){if(!this.sender)throw new Error("sender not found");const e=yield this.senderLock.lock();try{this.optimizeForPerformance=!0;const n=this.sender.getParameters();n.encodings=n.encodings.map((r,i)=>{var s;return Object.assign(Object.assign({},r),{active:i===0,scaleResolutionDownBy:Math.max(1,Math.ceil(((s=this.mediaStreamTrack.getSettings().height)!==null&&s!==void 0?s:360)/360)),scalabilityMode:i===0&&Ji(this.codec)?"L1T3":void 0,maxFramerate:i===0?15:0,maxBitrate:i===0?r.maxBitrate:0})}),this.log.debug("setting performance optimised encodings",Object.assign(Object.assign({},this.logContext),{encodings:n.encodings})),this.encodings=n.encodings,yield this.sender.setParameters(n)}catch(n){this.log.error("failed to set performance optimised encodings",Object.assign(Object.assign({},this.logContext),{error:n})),this.optimizeForPerformance=!1}finally{e()}})}handleAppVisibilityChanged(){const e=Object.create(null,{handleAppVisibilityChanged:{get:()=>super.handleAppVisibilityChanged}});return H(this,void 0,void 0,function*(){yield e.handleAppVisibilityChanged.call(this),LP()&&this.isInBackground&&this.source===Te.Source.Camera&&(this._mediaStreamTrack.enabled=!1)})}}function LC(t,e,n,r,i,s,a){return H(this,void 0,void 0,function*(){const c=yield r.lock();s.debug("setPublishingLayersForSender",Object.assign(Object.assign({},a),{sender:t,qualities:n,senderEncodings:e}));try{const h=t.getParameters(),{encodings:d}=h;if(!d)return;if(d.length!==e.length){s.warn("cannot set publishing layers, encodings mismatch",Object.assign(Object.assign({},a),{encodings:d,senderEncodings:e}));return}let f=!1;!1&&d[0].scalabilityMode||(i&&n.some(v=>v.enabled)&&n.forEach(v=>v.enabled=!0),d.forEach((g,v)=>{var k;let w=(k=g.rid)!==null&&k!==void 0?k:"";w===""&&(w="q");const S=GP(w),T=n.find(C=>C.quality===S);T&&g.active!==T.enabled&&(f=!0,g.active=T.enabled,s.debug("setting layer ".concat(T.quality," to ").concat(g.active?"enabled":"disabled"),a),dl()&&(T.enabled?(g.scaleResolutionDownBy=e[v].scaleResolutionDownBy,g.maxBitrate=e[v].maxBitrate,g.maxFrameRate=e[v].maxFrameRate):(g.scaleResolutionDownBy=4,g.maxBitrate=10,g.maxFrameRate=2)))})),f&&(h.encodings=d,s.debug("setting encodings",Object.assign(Object.assign({},a),{encodings:h.encodings})),yield t.setParameters(h))}finally{c()}})}function GP(t){switch(t){case"f":return ui.HIGH;case"h":return ui.MEDIUM;case"q":return ui.LOW;default:return ui.HIGH}}function FC(t,e,n,r){if(!n)return[new ro({quality:ui.HIGH,width:t,height:e,bitrate:0,ssrc:0})];if(r){const i=n[0].scalabilityMode,s=new KP(i),a=[],c=s.suffix=="h"?1.5:2,h=s.suffix=="h"?2:3;for(let d=0;d<s.spatial;d+=1)a.push(new ro({quality:Math.min(ui.HIGH,s.spatial-1)-d,width:Math.ceil(t/Math.pow(c,d)),height:Math.ceil(e/Math.pow(c,d)),bitrate:n[0].maxBitrate?Math.ceil(n[0].maxBitrate/Math.pow(h,d)):0,ssrc:0}));return a}return n.map(i=>{var s,a,c;const h=(s=i.scaleResolutionDownBy)!==null&&s!==void 0?s:1;let d=GP((a=i.rid)!==null&&a!==void 0?a:"");return new ro({quality:d,width:Math.ceil(t/h),height:Math.ceil(e/h),bitrate:(c=i.maxBitrate)!==null&&c!==void 0?c:0,ssrc:0})})}const UC="_lossy",BC="_reliable",zC="_data_track",FW=2*1e3,j0="leave-reconnect",UW=3e4,BW=8*1024,zW=256*1024,$W=3,VW=3;var Ni;(function(t){t[t.New=0]="New",t[t.Connected=1]="Connected",t[t.Disconnected=2]="Disconnected",t[t.Reconnecting=3]="Reconnecting",t[t.Closed=4]="Closed"})(Ni||(Ni={}));var It;(function(t){t[t.RELIABLE=0]="RELIABLE",t[t.LOSSY=1]="LOSSY",t[t.DATA_TRACK_LOSSY=2]="DATA_TRACK_LOSSY"})(It||(It={}));class WW extends Di.EventEmitter{get isClosed(){return this._isClosed}get isNewlyCreated(){return this._isNewlyCreated}get pendingReconnect(){return!!this.reconnectTimeout}constructor(e){var n;super(),this.options=e,this.rtcConfig={},this.peerConnectionTimeout=Rx.peerConnectionTimeout,this.fullReconnectOnNext=!1,this.latestRemoteOfferId=0,this.subscriberPrimary=!1,this.pcState=Ni.New,this._isClosed=!0,this._isNewlyCreated=!0,this.pendingTrackResolvers={},this.reconnectAttempts=0,this.reconnectStart=0,this.attemptingReconnect=!1,this.joinAttempts=0,this.maxJoinAttempts=1,this.shouldFailNext=!1,this.shouldFailOnV1Path=!1,this.log=Tt,this.reliableDataSequence=1,this.reliableMessageBuffer=new NC,this.reliableReceivedState=new cW(UW),this.lossyDataStatCurrentBytes=0,this.lossyDataStatByterate=0,this.lossyDataDropCount=0,this.midToTrackId={},this.isWaitingForNetworkReconnect=!1,this.handleDataChannel=r=>H(this,[r],void 0,function(i){var s=this;let{channel:a}=i;return(function*(){if(!a)return;let c;if(a.label===BC)s.reliableDCSub=a,c=s.handleDataMessage;else if(a.label===UC)s.lossyDCSub=a,c=s.handleDataMessage;else if(a.label===zC)s.dataTrackDCSub=a,c=s.handleDataTrackMessage;else return;s.log.debug("on data channel ".concat(a.id,", ").concat(a.label),s.logContext),a.onmessage=c})()}),this.handleDataMessage=r=>H(this,void 0,void 0,function*(){var i,s,a,c,h;const d=yield this.dataProcessLock.lock();try{let f;if(r.data instanceof ArrayBuffer)f=r.data;else if(r.data instanceof Blob)f=yield r.data.arrayBuffer();else{this.log.error("unsupported data type",Object.assign(Object.assign({},this.logContext),{data:r.data}));return}const p=Mr.fromBinary(new Uint8Array(f));if(p.sequence>0&&p.participantSid!==""){const g=this.reliableReceivedState.get(p.participantSid);if(g&&p.sequence<=g)return;this.reliableReceivedState.set(p.participantSid,p.sequence)}if(((i=p.value)===null||i===void 0?void 0:i.case)==="speaker")this.emit(De.ActiveSpeakersUpdate,p.value.value.speakers);else if(((s=p.value)===null||s===void 0?void 0:s.case)==="encryptedPacket"){if(!this.e2eeManager){this.log.error("Received encrypted packet but E2EE not set up",this.logContext);return}const g=yield(a=this.e2eeManager)===null||a===void 0?void 0:a.handleEncryptedData(p.value.value.encryptedValue,p.value.value.iv,p.participantIdentity,p.value.value.keyIndex),v=P2.fromBinary(g.payload),k=new Mr({value:v.value,participantIdentity:p.participantIdentity,participantSid:p.participantSid});((c=k.value)===null||c===void 0?void 0:c.case)==="user"&&$C(k,k.value.value),this.emit(De.DataPacketReceived,k,p.value.value.encryptionType)}else((h=p.value)===null||h===void 0?void 0:h.case)==="user"&&$C(p,p.value.value),this.emit(De.DataPacketReceived,p,bn.NONE)}finally{d()}}),this.handleDataTrackMessage=r=>H(this,void 0,void 0,function*(){let i;if(r.data instanceof ArrayBuffer)i=r.data;else if(r.data instanceof Blob)i=yield r.data.arrayBuffer();else{this.log.error("unsupported data type",Object.assign(Object.assign({},this.logContext),{data:r.data}));return}this.emit("dataTrackPacketReceived",new Uint8Array(i))}),this.handleDataError=r=>{const s=r.currentTarget.maxRetransmits===0?"lossy":"reliable";if(r instanceof ErrorEvent&&r.error){const{error:a}=r.error;this.log.error("DataChannel error on ".concat(s,": ").concat(r.message),Object.assign(Object.assign({},this.logContext),{error:a}))}else this.log.error("Unknown DataChannel error on ".concat(s),Object.assign(Object.assign({},this.logContext),{event:r}))},this.handleBufferedAmountLow=r=>{this.updateAndEmitDCBufferStatus(r)},this.handleDisconnect=(r,i)=>{if(this._isClosed)return;this.log.warn("".concat(r," disconnected"),this.logContext),this.reconnectAttempts===0&&(this.reconnectStart=Date.now());const s=h=>{this.log.warn("could not recover connection after ".concat(this.reconnectAttempts," attempts, ").concat(h,"ms. giving up"),this.logContext),this.emit(De.Disconnected),this.close()},a=Date.now()-this.reconnectStart;let c=this.getNextRetryDelay({elapsedMs:a,retryCount:this.reconnectAttempts});if(c===null){s(a);return}r===j0&&(c=0),this.log.debug("reconnecting in ".concat(c,"ms"),this.logContext),this.clearReconnectTimeout(),this.token&&this.regionUrlProvider&&this.regionUrlProvider.updateToken(this.token),this.reconnectTimeout=Qn.setTimeout(()=>this.attemptReconnect(i).finally(()=>this.reconnectTimeout=void 0),c)},this.waitForRestarted=()=>new Promise((r,i)=>{this.pcState===Ni.Connected&&r();const s=()=>{this.off(De.Disconnected,a),r()},a=()=>{this.off(De.Restarted,s),i()};this.once(De.Restarted,s),this.once(De.Disconnected,a)}),this.updateAndEmitDCBufferStatus=r=>{if(r===It.RELIABLE){const s=this.dataChannelForKind(r);s&&this.reliableMessageBuffer.alignBufferedAmount(s.bufferedAmount)}const i=this.isBufferStatusLow(r);typeof i<"u"&&i!==this.dcBufferStatus.get(r)&&(this.dcBufferStatus.set(r,i),this.emit(De.DCBufferStatusChanged,i,r))},this.isBufferStatusLow=r=>{const i=this.dataChannelForKind(r);if(i)return i.bufferedAmount<=i.bufferedAmountLowThreshold},this.handleBrowserOnLine=()=>H(this,void 0,void 0,function*(){!this.url||!(yield fetch(hd(this.url),{method:"HEAD"}).then(i=>i.ok).catch(()=>!1))||(this.log.info("detected network reconnected"),(this.client.currentState===yn.RECONNECTING||this.isWaitingForNetworkReconnect&&this.client.currentState===yn.CONNECTED)&&(this.clearReconnectTimeout(),this.attemptReconnect(zo.RR_SIGNAL_DISCONNECTED),this.isWaitingForNetworkReconnect=!1))}),this.handleBrowserOffline=()=>H(this,void 0,void 0,function*(){if(this.url)try{yield Promise.race([fetch(hd(this.url),{method:"HEAD"}),Cr(4e3).then(()=>Promise.reject())])}catch{window.navigator.onLine===!1&&(this.log.info("detected network interruption"),this.isWaitingForNetworkReconnect=!0)}}),this.log=ei((n=e.loggerName)!==null&&n!==void 0?n:Nr.Engine),this.loggerOptions={loggerName:e.loggerName,loggerContextCb:()=>this.logContext},this.client=new Ex(void 0,this.loggerOptions),this.client.signalLatency=this.options.expSignalLatency,this.reconnectPolicy=this.options.reconnectPolicy,this.closingLock=new fr,this.dataProcessLock=new fr,this.dcBufferStatus=new Map([[It.RELIABLE,!0],[It.LOSSY,!0],[It.DATA_TRACK_LOSSY,!0]]),this.client.onParticipantUpdate=r=>this.emit(De.ParticipantUpdate,r),this.client.onConnectionQuality=r=>this.emit(De.ConnectionQualityUpdate,r),this.client.onRoomUpdate=r=>this.emit(De.RoomUpdate,r),this.client.onSubscriptionError=r=>this.emit(De.SubscriptionError,r),this.client.onSubscriptionPermissionUpdate=r=>this.emit(De.SubscriptionPermissionUpdate,r),this.client.onSpeakersChanged=r=>this.emit(De.SpeakersChanged,r),this.client.onStreamStateUpdate=r=>this.emit(De.StreamStateChanged,r),this.client.onRequestResponse=r=>this.emit(De.SignalRequestResponse,r),this.client.onParticipantUpdate=r=>this.emit(De.ParticipantUpdate,r),this.client.onJoined=r=>this.emit(De.Joined,r)}get logContext(){var e,n,r,i,s,a;return{room:(n=(e=this.latestJoinResponse)===null||e===void 0?void 0:e.room)===null||n===void 0?void 0:n.name,roomID:(i=(r=this.latestJoinResponse)===null||r===void 0?void 0:r.room)===null||i===void 0?void 0:i.sid,participant:(a=(s=this.latestJoinResponse)===null||s===void 0?void 0:s.participant)===null||a===void 0?void 0:a.identity,participantID:this.participantSid}}join(e,n,r,i){return H(this,arguments,void 0,function(s,a,c,h){var d=this;let f=arguments.length>4&&arguments[4]!==void 0?arguments[4]:!1;return(function*(){var p,g,v,k,w,S;d._isNewlyCreated=!1,d.url=s,d.token=a,d.signalOpts=c,d.maxJoinAttempts=c.maxRetries;try{d.joinAttempts+=1,d.setupSignalClientCallbacks();let T;if(!f&&$v()){d.pcManager||(yield d.configure(),d.createDataChannels(),d.addMediaSections($W,VW));const R=yield(p=d.pcManager)===null||p===void 0?void 0:p.publisher.createInitialOffer();R&&(T=Ko(R.offer,R.offerId))}if(h!=null&&h.aborted)throw ht.cancelled("Connection aborted");if(!f&&d.shouldFailOnV1Path)throw d.shouldFailOnV1Path=!1,ht.serviceNotFound("Simulated v1 path failure","v0-rtc");Tt.warn("joining signal with ",s);const C=yield d.client.join(s,a,c,h,f,T);d._isClosed=!1,d.latestJoinResponse=C,d.participantSid=(g=C.participant)===null||g===void 0?void 0:g.sid,d.subscriberPrimary=C.subscriberPrimary,!f&&$v()?(v=d.pcManager)===null||v===void 0||v.updateConfiguration(d.makeRTCConfiguration(C)):(d.pcManager||(yield d.configure(C,!f)),(!d.subscriberPrimary||C.fastPublish)&&d.negotiate().catch(R=>{Tt.error(R,d.logContext)})),d.registerOnLineListener(),d.clientConfiguration=C.clientConfiguration,d.emit(De.SignalConnected,C);let j=C.serverInfo;return j||(j={version:C.serverVersion,region:C.serverRegion}),d.log.debug("connected to Livekit Server ".concat(Object.entries(j).map(R=>{let[_,I]=R;return"".concat(_,": ").concat(I)}).join(", ")),{room:(k=C.room)===null||k===void 0?void 0:k.name,roomSid:(w=C.room)===null||w===void 0?void 0:w.sid,identity:(S=C.participant)===null||S===void 0?void 0:S.identity}),{joinResponse:C,serverInfo:j}}catch(T){if(T instanceof ht){if(T.reason===xn.ServerUnreachable){if(d.log.warn("Couldn't connect to server, attempt ".concat(d.joinAttempts," of ").concat(d.maxJoinAttempts),d.logContext),d.joinAttempts<d.maxJoinAttempts)return d.join(s,a,c,h,f)}else if(T.reason===xn.ServiceNotFound)return d.log.warn("Initial connection failed: ".concat(T.message," – Retrying")),d.pcManager&&(d.pcManager.onStateChange=void 0,yield d.cleanupPeerConnections()),d.join(s,a,c,h,!0)}throw T}})()})}close(){return H(this,void 0,void 0,function*(){const e=yield this.closingLock.lock();if(this.isClosed){e();return}try{this._isClosed=!0,this.joinAttempts=0,this.emit(De.Closing),this.removeAllListeners(),this.deregisterOnLineListener(),this.clearPendingReconnect(),this.cleanupLossyDataStats(),yield this.cleanupPeerConnections(),yield this.cleanupClient()}finally{e()}})}cleanupPeerConnections(){return H(this,void 0,void 0,function*(){var e;yield(e=this.pcManager)===null||e===void 0?void 0:e.close(),this.pcManager=void 0;const n=r=>{r&&(r.close(),r.onbufferedamountlow=null,r.onclose=null,r.onclosing=null,r.onerror=null,r.onmessage=null,r.onopen=null)};n(this.lossyDC),n(this.lossyDCSub),n(this.reliableDC),n(this.reliableDCSub),n(this.dataTrackDC),n(this.dataTrackDCSub),this.lossyDC=void 0,this.lossyDCSub=void 0,this.reliableDC=void 0,this.reliableDCSub=void 0,this.dataTrackDC=void 0,this.dataTrackDCSub=void 0,this.reliableMessageBuffer=new NC,this.reliableDataSequence=1,this.reliableReceivedState.clear()})}cleanupLossyDataStats(){this.lossyDataStatByterate=0,this.lossyDataStatCurrentBytes=0,this.lossyDataStatInterval&&(clearInterval(this.lossyDataStatInterval),this.lossyDataStatInterval=void 0),this.lossyDataDropCount=0}cleanupClient(){return H(this,void 0,void 0,function*(){yield this.client.close(),this.client.resetCallbacks()})}addTrack(e){if(this.pendingTrackResolvers[e.cid])throw new da("a track with the same ID has already been published");return new Promise((n,r)=>{const i=setTimeout(()=>{delete this.pendingTrackResolvers[e.cid],r(ht.timeout("publication of local track timed out, no response from server"))},1e4);this.pendingTrackResolvers[e.cid]={resolve:s=>{clearTimeout(i),n(s)},reject:()=>{clearTimeout(i),r(new Error("Cancelled publication by calling unpublish"))}},this.client.sendAddTrack(e)})}removeTrack(e){if(e.track&&this.pendingTrackResolvers[e.track.id]){const{reject:n}=this.pendingTrackResolvers[e.track.id];n&&n(),delete this.pendingTrackResolvers[e.track.id]}try{return this.pcManager.removeTrack(e),!0}catch(n){this.log.warn("failed to remove track",Object.assign(Object.assign({},this.logContext),{error:n}))}return!1}updateMuteStatus(e,n){this.client.sendMuteTrack(e,n)}get dataSubscriberReadyState(){var e;return(e=this.reliableDCSub)===null||e===void 0?void 0:e.readyState}getConnectedServerAddress(){return H(this,void 0,void 0,function*(){var e;return(e=this.pcManager)===null||e===void 0?void 0:e.getConnectedAddress()})}setRegionUrlProvider(e){this.regionUrlProvider=e}configure(e,n){return H(this,void 0,void 0,function*(){var r;if(!(this.pcManager&&this.pcManager.currentState!==Ln.NEW)){if(e){this.participantSid=(r=e.participant)===null||r===void 0?void 0:r.sid;const i=this.makeRTCConfiguration(e);this.pcManager=new MC(n?"publisher-only":e.subscriberPrimary?"subscriber-primary":"publisher-primary",this.loggerOptions,i)}else{const i=this.makeRTCConfiguration();this.pcManager=new MC("publisher-only",this.loggerOptions,i)}this.emit(De.TransportsCreated,this.pcManager.publisher,this.pcManager.subscriber),this.pcManager.onIceCandidate=(i,s)=>{this.client.sendIceCandidate(i,s)},this.pcManager.onPublisherOffer=(i,s)=>{this.client.sendOffer(i,s)},this.pcManager.onDataChannel=this.handleDataChannel,this.pcManager.onStateChange=(i,s,a)=>H(this,void 0,void 0,function*(){if(this.log.debug("primary PC state changed ".concat(i),this.logContext),["closed","disconnected","failed"].includes(s)&&(this.publisherConnectionPromise=void 0),i===Ln.CONNECTED){const d=this.pcState===Ni.New;this.pcState=Ni.Connected,d&&this.emit(De.Connected,this.latestJoinResponse)}else i===Ln.FAILED&&(this.pcState===Ni.Connected||this.pcState===Ni.Reconnecting)&&(this.pcState=Ni.Disconnected,this.handleDisconnect("peerconnection failed",a==="failed"?zo.RR_SUBSCRIBER_FAILED:zo.RR_PUBLISHER_FAILED));const c=this.client.isDisconnected||this.client.currentState===yn.RECONNECTING,h=[Ln.FAILED,Ln.CLOSING,Ln.CLOSED].includes(i);c&&h&&!this._isClosed&&this.emit(De.Offline)}),this.pcManager.onTrack=i=>{i.streams.length!==0&&this.emit(De.MediaTrackAdded,i.track,i.streams[0],i.receiver)}}})}setupSignalClientCallbacks(){this.client.onAnswer=(e,n,r)=>H(this,void 0,void 0,function*(){this.pcManager&&(this.log.debug("received server answer",Object.assign(Object.assign({},this.logContext),{RTCSdpType:e.type,sdp:e.sdp,midToTrackId:r})),this.midToTrackId=r,yield this.pcManager.setPublisherAnswer(e,n))}),this.client.onTrickle=(e,n)=>{this.pcManager&&(this.log.debug("got ICE candidate from peer",Object.assign(Object.assign({},this.logContext),{candidate:e,target:n})),this.pcManager.addIceCandidate(e,n))},this.client.onOffer=(e,n,r)=>H(this,void 0,void 0,function*(){if(this.latestRemoteOfferId=n,!this.pcManager)return;this.midToTrackId=r;const i=yield this.pcManager.createSubscriberAnswerFromOffer(e,n);i&&this.client.sendAnswer(i,n)}),this.client.onLocalTrackPublished=e=>{var n;if(this.log.debug("received trackPublishedResponse",Object.assign(Object.assign({},this.logContext),{cid:e.cid,track:(n=e.track)===null||n===void 0?void 0:n.sid})),!this.pendingTrackResolvers[e.cid]){this.log.error("missing track resolver for ".concat(e.cid),Object.assign(Object.assign({},this.logContext),{cid:e.cid}));return}const{resolve:r}=this.pendingTrackResolvers[e.cid];delete this.pendingTrackResolvers[e.cid],r(e.track)},this.client.onLocalTrackUnpublished=e=>{this.emit(De.LocalTrackUnpublished,e)},this.client.onLocalTrackSubscribed=e=>{this.emit(De.LocalTrackSubscribed,e)},this.client.onTokenRefresh=e=>{var n;this.token=e,(n=this.regionUrlProvider)===null||n===void 0||n.updateToken(e)},this.client.onRemoteMuteChanged=(e,n)=>{this.emit(De.RemoteMute,e,n)},this.client.onSubscribedQualityUpdate=e=>{this.emit(De.SubscribedQualityUpdate,e)},this.client.onRoomMoved=e=>{var n;this.participantSid=(n=e.participant)===null||n===void 0?void 0:n.sid,this.latestJoinResponse&&(this.latestJoinResponse.room=e.room),this.emit(De.RoomMoved,e)},this.client.onMediaSectionsRequirement=e=>{this.addMediaSections(e.numAudios,e.numVideos),this.negotiate()},this.client.onPublishDataTrackResponse=e=>{this.emit(De.PublishDataTrackResponse,e)},this.client.onUnPublishDataTrackResponse=e=>{this.emit(De.UnPublishDataTrackResponse,e)},this.client.onDataTrackSubscriberHandles=e=>{this.emit(De.DataTrackSubscriberHandles,e)},this.client.onClose=()=>{this.handleDisconnect("signal",zo.RR_SIGNAL_DISCONNECTED)},this.client.onLeave=e=>{switch(this.log.debug("client leave request",Object.assign(Object.assign({},this.logContext),{reason:e==null?void 0:e.reason})),e.regions&&this.regionUrlProvider&&(this.log.debug("updating regions",this.logContext),this.regionUrlProvider.setServerReportedRegions({updatedAtInMs:Date.now(),maxAgeInMs:WP,regionSettings:e.regions})),e.action){case uc.DISCONNECT:this.emit(De.Disconnected,e==null?void 0:e.reason),this.close();break;case uc.RECONNECT:this.fullReconnectOnNext=!0,this.handleDisconnect(j0);break;case uc.RESUME:this.handleDisconnect(j0)}}}makeRTCConfiguration(e){var n;const r=Object.assign({},this.rtcConfig);if(!((n=this.signalOpts)===null||n===void 0)&&n.e2eeEnabled&&(this.log.debug("E2EE - setting up transports with insertable streams",this.logContext),r.encodedInsertableStreams=!0),r.sdpSemantics="unified-plan",r.continualGatheringPolicy="gather_continually",!e)return r;if(e.iceServers&&!r.iceServers){const i=[];e.iceServers.forEach(s=>{const a={urls:s.urls};s.username&&(a.username=s.username),s.credential&&(a.credential=s.credential),i.push(a)}),r.iceServers=i}return e.clientConfiguration&&e.clientConfiguration.forceRelay===od.ENABLED&&(r.iceTransportPolicy="relay"),r}addMediaSections(e,n){var r,i;const s={direction:"recvonly"};for(let a=0;a<e;a++)(r=this.pcManager)===null||r===void 0||r.addPublisherTransceiverOfKind("audio",s);for(let a=0;a<n;a++)(i=this.pcManager)===null||i===void 0||i.addPublisherTransceiverOfKind("video",s)}createDataChannels(){this.pcManager&&(this.lossyDC&&(this.lossyDC.onmessage=null,this.lossyDC.onerror=null),this.reliableDC&&(this.reliableDC.onmessage=null,this.reliableDC.onerror=null),this.dataTrackDC&&(this.dataTrackDC.onmessage=null,this.dataTrackDC.onerror=null),this.lossyDC=this.pcManager.createPublisherDataChannel(UC,{ordered:!1,maxRetransmits:0}),this.reliableDC=this.pcManager.createPublisherDataChannel(BC,{ordered:!0}),this.dataTrackDC=this.pcManager.createPublisherDataChannel(zC,{ordered:!1,maxRetransmits:0}),this.lossyDC.onmessage=this.handleDataMessage,this.reliableDC.onmessage=this.handleDataMessage,this.dataTrackDC.onmessage=this.handleDataTrackMessage,this.lossyDC.onerror=this.handleDataError,this.reliableDC.onerror=this.handleDataError,this.dataTrackDC.onerror=this.handleDataError,this.lossyDC.bufferedAmountLowThreshold=65535,this.reliableDC.bufferedAmountLowThreshold=65535,this.dataTrackDC.bufferedAmountLowThreshold=65535,this.lossyDC.onbufferedamountlow=()=>this.handleBufferedAmountLow(It.LOSSY),this.reliableDC.onbufferedamountlow=()=>this.handleBufferedAmountLow(It.RELIABLE),this.dataTrackDC.onbufferedamountlow=()=>this.handleBufferedAmountLow(It.DATA_TRACK_LOSSY),this.cleanupLossyDataStats(),this.lossyDataStatInterval=setInterval(()=>{this.lossyDataStatByterate=this.lossyDataStatCurrentBytes,this.lossyDataStatCurrentBytes=0;const e=this.dataChannelForKind(It.LOSSY);if(e){const n=this.lossyDataStatByterate/10;e.bufferedAmountLowThreshold=Math.min(Math.max(n,BW),zW)}},1e3))}createSender(e,n,r){return H(this,void 0,void 0,function*(){if(Fv())return yield this.createTransceiverRTCRtpSender(e,n,r);if(Uv())return this.log.warn("using add-track fallback",this.logContext),yield this.createRTCRtpSender(e.mediaStreamTrack);throw new On("Required webRTC APIs not supported on this device")})}createSimulcastSender(e,n,r,i){return H(this,void 0,void 0,function*(){if(Fv())return this.createSimulcastTransceiverSender(e,n,r,i);if(Uv())return this.log.debug("using add-track fallback",this.logContext),this.createRTCRtpSender(e.mediaStreamTrack);throw new On("Cannot stream on this device")})}createTransceiverRTCRtpSender(e,n,r){return H(this,void 0,void 0,function*(){if(!this.pcManager)throw new On("publisher is closed");const i=[];e.mediaStream&&i.push(e.mediaStream),go(e)&&(e.codec=n.videoCodec);const s={direction:"sendonly",streams:i};return r&&(s.sendEncodings=r),(yield this.pcManager.addPublisherTransceiver(e.mediaStreamTrack,s)).sender})}createSimulcastTransceiverSender(e,n,r,i){return H(this,void 0,void 0,function*(){if(!this.pcManager)throw new On("publisher is closed");const s={direction:"sendonly"};i&&(s.sendEncodings=i);const a=yield this.pcManager.addPublisherTransceiver(n.mediaStreamTrack,s);if(r.videoCodec)return e.setSimulcastTrackSender(r.videoCodec,a.sender),a.sender})}createRTCRtpSender(e){return H(this,void 0,void 0,function*(){if(!this.pcManager)throw new On("publisher is closed");return this.pcManager.addPublisherTrack(e)})}attemptReconnect(e){return H(this,void 0,void 0,function*(){var n,r,i;if(!this._isClosed){if(this.attemptingReconnect){Tt.warn("already attempting reconnect, returning early",this.logContext);return}(((n=this.clientConfiguration)===null||n===void 0?void 0:n.resumeConnection)===od.DISABLED||((i=(r=this.pcManager)===null||r===void 0?void 0:r.currentState)!==null&&i!==void 0?i:Ln.NEW)===Ln.NEW)&&(this.fullReconnectOnNext=!0);try{this.attemptingReconnect=!0,this.fullReconnectOnNext?yield this.restartConnection():yield this.resumeConnection(e),this.clearPendingReconnect(),this.fullReconnectOnNext=!1}catch(s){this.reconnectAttempts+=1;let a=!0;s instanceof On?(this.log.debug("received unrecoverable error",Object.assign(Object.assign({},this.logContext),{error:s})),a=!1):s instanceof Jl||(this.fullReconnectOnNext=!0),a?this.handleDisconnect("reconnect",zo.RR_UNKNOWN):(this.log.info("could not recover connection after ".concat(this.reconnectAttempts," attempts, ").concat(Date.now()-this.reconnectStart,"ms. giving up"),this.logContext),this.emit(De.Disconnected),yield this.close())}finally{this.attemptingReconnect=!1}}})}getNextRetryDelay(e){try{return this.reconnectPolicy.nextRetryDelayInMs(e)}catch(n){this.log.warn("encountered error in reconnect policy",Object.assign(Object.assign({},this.logContext),{error:n}))}return null}restartConnection(e){return H(this,void 0,void 0,function*(){var n,r,i;try{if(!this.url||!this.token)throw new On("could not reconnect, url or token not saved");this.log.info("reconnecting, attempt: ".concat(this.reconnectAttempts),this.logContext),this.emit(De.Restarting),this.client.isDisconnected||(yield this.client.sendLeave()),yield this.cleanupPeerConnections(),yield this.cleanupClient();let s;try{if(!this.signalOpts)throw this.log.warn("attempted connection restart, without signal options present",this.logContext),new Jl;s=(yield this.join(e??this.url,this.token,this.signalOpts,void 0,!this.options.singlePeerConnection)).joinResponse}catch(a){throw a instanceof ht&&a.reason===xn.NotAllowed?new On("could not reconnect, token might be expired"):new Jl}if(this.shouldFailNext)throw this.shouldFailNext=!1,new Error("simulated failure");if(this.client.setReconnected(),this.emit(De.SignalRestarted,s),yield this.waitForPCReconnected(),this.client.currentState!==yn.CONNECTED)throw new Jl("Signal connection got severed during reconnect");(n=this.regionUrlProvider)===null||n===void 0||n.resetAttempts(),this.emit(De.Restarted)}catch(s){const a=yield(r=this.regionUrlProvider)===null||r===void 0?void 0:r.getNextBestRegionUrl();if(a){yield this.restartConnection(a);return}else throw(i=this.regionUrlProvider)===null||i===void 0||i.resetAttempts(),s}})}resumeConnection(e){return H(this,void 0,void 0,function*(){var n;if(!this.url||!this.token)throw new On("could not reconnect, url or token not saved");if(!this.pcManager)throw new On("publisher and subscriber connections unset");this.log.info("resuming signal connection, attempt ".concat(this.reconnectAttempts),this.logContext),this.emit(De.Resuming);let r;try{this.setupSignalClientCallbacks(),r=yield this.client.reconnect(this.url,this.token,this.participantSid,e)}catch(i){let s="";throw i instanceof Error&&(s=i.message,this.log.error(i.message,Object.assign(Object.assign({},this.logContext),{error:i}))),i instanceof ht&&i.reason===xn.NotAllowed?new On("could not reconnect, token might be expired"):i instanceof ht&&i.reason===xn.LeaveRequest?i:new Jl(s)}if(this.emit(De.SignalResumed),r){const i=this.makeRTCConfiguration(r);this.pcManager.updateConfiguration(i),this.latestJoinResponse&&(this.latestJoinResponse.serverInfo=r.serverInfo)}else this.log.warn("Did not receive reconnect response",this.logContext);if(this.shouldFailNext)throw this.shouldFailNext=!1,new Error("simulated failure");if(yield this.pcManager.triggerIceRestart(),yield this.waitForPCReconnected(),this.client.currentState!==yn.CONNECTED)throw new Jl("Signal connection got severed during reconnect");this.client.setReconnected(),((n=this.reliableDC)===null||n===void 0?void 0:n.readyState)==="open"&&this.reliableDC.id===null&&this.createDataChannels(),r!=null&&r.lastMessageSeq&&this.resendReliableMessagesForResume(r.lastMessageSeq),this.emit(De.Resumed)})}waitForPCInitialConnection(e,n){return H(this,void 0,void 0,function*(){if(!this.pcManager)throw new On("PC manager is closed");yield this.pcManager.ensurePCTransportConnection(n,e)})}waitForPCReconnected(){return H(this,void 0,void 0,function*(){this.pcState=Ni.Reconnecting,this.log.debug("waiting for peer connection to reconnect",this.logContext);try{if(yield Cr(FW),!this.pcManager)throw new On("PC manager is closed");yield this.pcManager.ensurePCTransportConnection(void 0,this.peerConnectionTimeout),this.pcState=Ni.Connected}catch(e){throw this.pcState=Ni.Disconnected,ht.internal("could not establish PC connection, ".concat(e.message))}})}publishRpcResponse(e,n,r,i){return H(this,void 0,void 0,function*(){const s=new Mr({destinationIdentities:[e],kind:Zo.RELIABLE,value:{case:"rpcResponse",value:new ux({requestId:n,value:i?{case:"error",value:i.toProto()}:{case:"payload",value:r??""}})}});yield this.sendDataPacket(s,It.RELIABLE)})}publishRpcAck(e,n){return H(this,void 0,void 0,function*(){const r=new Mr({destinationIdentities:[e],kind:Zo.RELIABLE,value:{case:"rpcAck",value:new cx({requestId:n})}});yield this.sendDataPacket(r,It.RELIABLE)})}sendDataPacket(e,n){return H(this,void 0,void 0,function*(){if(yield this.ensurePublisherConnected(n),this.e2eeManager&&this.e2eeManager.isDataChannelEncryptionEnabled){const i=JV(e);if(i){const s=yield this.e2eeManager.encryptData(i.toBinary());e.value={case:"encryptedPacket",value:new j2({encryptedValue:s.payload,iv:s.iv,keyIndex:s.keyIndex})}}}n===It.RELIABLE&&(e.sequence=this.reliableDataSequence,this.reliableDataSequence+=1);const r=e.toBinary();switch(n){case It.LOSSY:case It.DATA_TRACK_LOSSY:return this.sendLossyBytes(r,n);case It.RELIABLE:const i=this.dataChannelForKind(n);if(i){if(yield this.waitForBufferStatusLow(n),this.reliableMessageBuffer.push({data:r,sequence:e.sequence}),this.attemptingReconnect)return;i.send(r)}this.updateAndEmitDCBufferStatus(n);break}})}sendLossyBytes(e,n){return H(this,arguments,void 0,function(r,i){var s=this;let a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:"drop";return(function*(){yield s.ensurePublisherConnected(i);const c=s.dataChannelForKind(i);if(c){if(!s.isBufferStatusLow(i))switch(a){case"wait":yield s.waitForBufferStatusLow(i);break;case"drop":s.lossyDataDropCount+=1,s.lossyDataDropCount%100===0&&s.log.warn("dropping lossy data channel messages, total dropped: ".concat(s.lossyDataDropCount),s.logContext);return}if(s.lossyDataStatCurrentBytes+=r.byteLength,s.attemptingReconnect)return;c.send(r)}s.updateAndEmitDCBufferStatus(i)})()})}resendReliableMessagesForResume(e){return H(this,void 0,void 0,function*(){yield this.ensurePublisherConnected(It.RELIABLE);const n=this.dataChannelForKind(It.RELIABLE);n&&(this.reliableMessageBuffer.popToSequence(e),this.reliableMessageBuffer.getAll().forEach(r=>{n.send(r.data)})),this.updateAndEmitDCBufferStatus(It.RELIABLE)})}waitForBufferStatusLow(e){return H(this,void 0,void 0,function*(){return new Sr((n,r)=>H(this,void 0,void 0,function*(){if(this.isClosed&&r(new On("engine closed")),this.isBufferStatusLow(e))n();else{const i=()=>r(new On("engine closed"));this.once(De.Closing,i);const s=this.dataChannelForKind(e);if(!s){r(new On("DataChannel not found, kind: ".concat(e)));return}s.addEventListener("bufferedamountlow",()=>{this.off(De.Closing,i),n()},{once:!0})}}))})}ensureDataTransportConnected(e){return H(this,arguments,void 0,function(n){var r=this;let i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.subscriberPrimary;return(function*(){var s;if(!r.pcManager)throw new On("PC manager is closed");const a=i?r.pcManager.subscriber:r.pcManager.publisher,c=i?"Subscriber":"Publisher";if(!a)throw ht.internal("".concat(c," connection not set"));let h=!1;!i&&!r.dataChannelForKind(n,i)&&(r.createDataChannels(),h=!0),!h&&!i&&!r.pcManager.publisher.isICEConnected&&r.pcManager.publisher.getICEConnectionState()!=="checking"&&(h=!0),h&&r.negotiate().catch(p=>{Tt.error(p,r.logContext)});const d=r.dataChannelForKind(n,i);if((d==null?void 0:d.readyState)==="open")return;const f=new Date().getTime()+r.peerConnectionTimeout;for(;new Date().getTime()<f;){if(a.isICEConnected&&((s=r.dataChannelForKind(n,i))===null||s===void 0?void 0:s.readyState)==="open")return;yield Cr(50)}throw ht.internal("could not establish ".concat(c," connection, state: ").concat(a.getICEConnectionState()))})()})}ensurePublisherConnected(e){return H(this,void 0,void 0,function*(){this.publisherConnectionPromise||(this.publisherConnectionPromise=this.ensureDataTransportConnected(e,!1)),yield this.publisherConnectionPromise})}verifyTransport(){return!(!this.pcManager||![Ln.CONNECTING,Ln.CONNECTED].includes(this.pcManager.currentState)||!this.client.ws||this.client.ws.readyState===WebSocket.CLOSED)}negotiate(){return H(this,void 0,void 0,function*(){return new Sr((e,n)=>H(this,void 0,void 0,function*(){if(!this.pcManager){n(new nl("PC manager is closed"));return}this.pcManager.requirePublisher(),this.pcManager.publisher.getTransceivers().length==0&&!this.lossyDC&&!this.reliableDC&&!this.dataTrackDC&&this.createDataChannels();const r=new AbortController,i=()=>{r.abort(),this.log.debug("engine disconnected while negotiation was ongoing",this.logContext),e()};this.isClosed&&n(new nl("cannot negotiate on closed engine")),this.on(De.Closing,i),this.on(De.Restarting,i),this.pcManager.publisher.once(sl.RTPVideoPayloadTypes,s=>{const a=new Map;s.forEach(c=>{const h=c.codec.toLowerCase();MV(h)&&a.set(c.payload,h)}),this.emit(De.RTPVideoMapUpdate,a)});try{yield this.pcManager.negotiate(r),e()}catch(s){if(r.signal.aborted){e();return}s instanceof nl&&(this.fullReconnectOnNext=!0),this.handleDisconnect("negotiation",zo.RR_UNKNOWN),s instanceof Error?n(s):n(new Error(String(s)))}finally{this.off(De.Closing,i),this.off(De.Restarting,i)}}))})}dataChannelForKind(e,n){switch(e){case It.RELIABLE:return n?this.reliableDCSub:this.reliableDC;case It.LOSSY:return n?this.lossyDCSub:this.lossyDC;case It.DATA_TRACK_LOSSY:return n?this.dataTrackDCSub:this.dataTrackDC}}sendSyncState(e,n,r){var i,s,a,c;if(!this.pcManager){this.log.warn("sync state cannot be sent without peer connection setup",this.logContext);return}const h=this.pcManager.publisher.getLocalDescription(),d=this.pcManager.publisher.getRemoteDescription(),f=(i=this.pcManager.subscriber)===null||i===void 0?void 0:i.getRemoteDescription(),p=(s=this.pcManager.subscriber)===null||s===void 0?void 0:s.getLocalDescription(),g=(c=(a=this.signalOpts)===null||a===void 0?void 0:a.autoSubscribe)!==null&&c!==void 0?c:!0,v=new Array,k=new Array;e.forEach(w=>{w.isDesired!==g&&v.push(w.trackSid),w.isEnabled||k.push(w.trackSid)}),this.client.sendSyncState(new yx({answer:this.pcManager.mode==="publisher-only"?d?Ko({sdp:d.sdp,type:d.type}):void 0:p?Ko({sdp:p.sdp,type:p.type}):void 0,offer:this.pcManager.mode==="publisher-only"?h?Ko({sdp:h.sdp,type:h.type}):void 0:f?Ko({sdp:f.sdp,type:f.type}):void 0,subscription:new Pp({trackSids:v,subscribe:!g,participantTracks:[]}),publishTracks:gV(n),dataChannels:this.dataChannelsInfo(),trackSidsDisabled:k,datachannelReceiveStates:this.reliableReceivedState.map((w,S)=>new J2({publisherSid:S,lastSeq:w})),publishDataTracks:r.map(w=>new hx({info:Yf.toProtobuf(w)}))}))}failNext(){this.shouldFailNext=!0}failNextV1Path(){this.shouldFailOnV1Path=!0}dataChannelsInfo(){const e=[],n=(r,i)=>{(r==null?void 0:r.id)!==void 0&&r.id!==null&&e.push(new X2({label:r.label,id:r.id,target:i}))};return n(this.dataChannelForKind(It.LOSSY),Gi.PUBLISHER),n(this.dataChannelForKind(It.RELIABLE),Gi.PUBLISHER),n(this.dataChannelForKind(It.LOSSY,!0),Gi.SUBSCRIBER),n(this.dataChannelForKind(It.RELIABLE,!0),Gi.SUBSCRIBER),e}clearReconnectTimeout(){this.reconnectTimeout&&Qn.clearTimeout(this.reconnectTimeout)}clearPendingReconnect(){this.clearReconnectTimeout(),this.reconnectAttempts=0}registerOnLineListener(){Yr()&&(window.addEventListener("online",this.handleBrowserOnLine),window.addEventListener("offline",this.handleBrowserOffline))}deregisterOnLineListener(){Yr()&&(window.removeEventListener("online",this.handleBrowserOnLine),window.removeEventListener("offline",this.handleBrowserOffline))}getTrackIdForReceiver(e){var n;const r=(n=this.pcManager)===null||n===void 0?void 0:n.getMidForReceiver(e);if(r){const i=Object.entries(this.midToTrackId).find(s=>{let[a]=s;return a===r});if(i)return i[1]}}}function $C(t,e){const n=t.participantIdentity?t.participantIdentity:e.participantIdentity;t.participantIdentity=n,e.participantIdentity=n;const r=t.destinationIdentities.length!==0?t.destinationIdentities:e.destinationIdentities;t.destinationIdentities=r,e.destinationIdentities=r}class YP{get info(){return this._info}validateBytesReceived(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1;if(!(typeof this.totalByteSize!="number"||this.totalByteSize===0)){if(e&&this.bytesReceived<this.totalByteSize)throw new Ei("Not enough chunk(s) received - expected ".concat(this.totalByteSize," bytes of data total, only received ").concat(this.bytesReceived," bytes"),Rr.Incomplete);if(this.bytesReceived>this.totalByteSize)throw new Ei("Extra chunk(s) received - expected ".concat(this.totalByteSize," bytes of data total, received ").concat(this.bytesReceived," bytes"),Rr.LengthExceeded)}}constructor(e,n,r){this.reader=n,this.totalByteSize=r,this._info=e,this.bytesReceived=0}}class HW extends YP{handleChunkReceived(e){var n;this.bytesReceived+=e.content.byteLength,this.validateBytesReceived();const r=this.totalByteSize?this.bytesReceived/this.totalByteSize:void 0;(n=this.onProgress)===null||n===void 0||n.call(this,r)}[Symbol.asyncIterator](){const e=this.reader.getReader();e.closed.catch(()=>{});const n=()=>{e.releaseLock(),this.signal=void 0};return{next:()=>H(this,void 0,void 0,function*(){try{const r=this.signal;if(r!=null&&r.aborted)throw r.reason;const i=yield new Promise((s,a)=>{if(r){const c=()=>a(r.reason);r.addEventListener("abort",c,{once:!0}),e.read().then(s,a).finally(()=>{r.removeEventListener("abort",c)})}else e.read().then(s,a)});return i.done?(this.validateBytesReceived(!0),{done:!0,value:void 0}):(this.handleChunkReceived(i.value),{done:!1,value:i.value.content})}catch(r){throw n(),r}}),return(){return H(this,void 0,void 0,function*(){return n(),{done:!0,value:void 0}})}}}withAbortSignal(e){return this.signal=e,this}readAll(){return H(this,arguments,void 0,function(){var e=this;let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return(function*(){var r,i,s,a;let c=new Set;const h=n.signal?e.withAbortSignal(n.signal):e;try{for(var d=!0,f=Yi(h),p;p=yield f.next(),r=p.done,!r;d=!0){a=p.value,d=!1;const g=a;c.add(g)}}catch(g){i={error:g}}finally{try{!d&&!r&&(s=f.return)&&(yield s.call(f))}finally{if(i)throw i.error}}return Array.from(c)})()})}}class qW extends YP{constructor(e,n,r){super(e,n,r),this.receivedChunks=new Map}handleChunkReceived(e){var n;const r=Ef(e.chunkIndex),i=this.receivedChunks.get(r);if(i&&i.version>e.version)return;this.receivedChunks.set(r,e),this.bytesReceived+=e.content.byteLength,this.validateBytesReceived();const s=this.totalByteSize?this.bytesReceived/this.totalByteSize:void 0;(n=this.onProgress)===null||n===void 0||n.call(this,s)}[Symbol.asyncIterator](){const e=this.reader.getReader();e.closed.catch(()=>{});const n=new TextDecoder("utf-8",{fatal:!0}),r=this.signal,i=()=>{e.releaseLock(),this.signal=void 0};return{next:()=>H(this,void 0,void 0,function*(){try{if(r!=null&&r.aborted)throw r.reason;const s=yield new Promise((a,c)=>{if(r){const h=()=>c(r.reason);r.addEventListener("abort",h,{once:!0}),e.read().then(a,c).finally(()=>{r.removeEventListener("abort",h)})}else e.read().then(a,c)});if(s.done)return this.validateBytesReceived(!0),{done:!0,value:void 0};{this.handleChunkReceived(s.value);let a;try{a=n.decode(s.value.content)}catch(c){throw new Ei("Cannot decode datastream chunk ".concat(s.value.chunkIndex," as text: ").concat(c),Rr.DecodeFailed)}return{done:!1,value:a}}}catch(s){throw i(),s}}),return(){return H(this,void 0,void 0,function*(){return i(),{done:!0,value:void 0}})}}}withAbortSignal(e){return this.signal=e,this}readAll(){return H(this,arguments,void 0,function(){var e=this;let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return(function*(){var r,i,s,a;let c="";const h=n.signal?e.withAbortSignal(n.signal):e;try{for(var d=!0,f=Yi(h),p;p=yield f.next(),r=p.done,!r;d=!0)a=p.value,d=!1,c+=a}catch(g){i={error:g}}finally{try{!d&&!r&&(s=f.return)&&(yield s.call(f))}finally{if(i)throw i.error}}return c})()})}}class KW{constructor(){this.log=Tt,this.byteStreamControllers=new Map,this.textStreamControllers=new Map,this.byteStreamHandlers=new Map,this.textStreamHandlers=new Map,this.isConnected=!1,this.bufferedPackets=[]}setConnected(e){this.isConnected=e,e&&this.flushBufferedPackets()}flushBufferedPackets(){const e=this.bufferedPackets;this.bufferedPackets=[];for(const{packet:n,encryptionType:r}of e)this.handleDataStreamPacket(n,r)}registerTextStreamHandler(e,n){if(this.textStreamHandlers.has(e))throw new Ei('A text stream handler for topic "'.concat(e,'" has already been set.'),Rr.HandlerAlreadyRegistered);this.textStreamHandlers.set(e,n)}unregisterTextStreamHandler(e){this.textStreamHandlers.delete(e)}registerByteStreamHandler(e,n){if(this.byteStreamHandlers.has(e))throw new Ei('A byte stream handler for topic "'.concat(e,'" has already been set.'),Rr.HandlerAlreadyRegistered);this.byteStreamHandlers.set(e,n)}unregisterByteStreamHandler(e){this.byteStreamHandlers.delete(e)}clearControllers(){this.byteStreamControllers.clear(),this.textStreamControllers.clear(),this.bufferedPackets=[]}validateParticipantHasNoActiveDataStreams(e){const n=Array.from(this.textStreamControllers.entries()).filter(i=>i[1].sendingParticipantIdentity===e),r=Array.from(this.byteStreamControllers.entries()).filter(i=>i[1].sendingParticipantIdentity===e);if(n.length>0||r.length>0){const i=new Ei("Participant ".concat(e," unexpectedly disconnected in the middle of sending data"),Rr.AbnormalEnd);for(const[s,a]of r)a.controller.error(i),this.byteStreamControllers.delete(s);for(const[s,a]of n)a.controller.error(i),this.textStreamControllers.delete(s)}}handleDataStreamPacket(e,n){if(!this.isConnected){this.bufferedPackets.push({packet:e,encryptionType:n});return}switch(e.value.case){case"streamHeader":return this.handleStreamHeader(e.value.value,e.participantIdentity,n);case"streamChunk":return this.handleStreamChunk(e.value.value,n);case"streamTrailer":return this.handleStreamTrailer(e.value.value,n);default:throw new Error('DataPacket of value "'.concat(e.value.case,'" is not data stream related!'))}}handleStreamHeader(e,n,r){var i;if(e.contentHeader.case==="byteHeader"){const s=this.byteStreamHandlers.get(e.topic);if(!s){this.log.debug("ignoring incoming byte stream due to no handler for topic",e.topic);return}let a;const c={id:e.streamId,name:(i=e.contentHeader.value.name)!==null&&i!==void 0?i:"unknown",mimeType:e.mimeType,size:e.totalLength?Number(e.totalLength):void 0,topic:e.topic,timestamp:Ef(e.timestamp),attributes:e.attributes,encryptionType:r},h=new ReadableStream({start:d=>{if(a=d,this.textStreamControllers.has(e.streamId))throw new Ei("A data stream read is already in progress for a stream with id ".concat(e.streamId,"."),Rr.AlreadyOpened);this.byteStreamControllers.set(e.streamId,{info:c,controller:a,startTime:Date.now(),sendingParticipantIdentity:n})}});s(new HW(c,h,Ef(e.totalLength)),{identity:n})}else if(e.contentHeader.case==="textHeader"){const s=this.textStreamHandlers.get(e.topic);if(!s){this.log.debug("ignoring incoming text stream due to no handler for topic",e.topic);return}let a;const c={id:e.streamId,mimeType:e.mimeType,size:e.totalLength?Number(e.totalLength):void 0,topic:e.topic,timestamp:Number(e.timestamp),attributes:e.attributes,encryptionType:r,attachedStreamIds:e.contentHeader.value.attachedStreamIds},h=new ReadableStream({start:d=>{if(a=d,this.textStreamControllers.has(e.streamId))throw new Ei("A data stream read is already in progress for a stream with id ".concat(e.streamId,"."),Rr.AlreadyOpened);this.textStreamControllers.set(e.streamId,{info:c,controller:a,startTime:Date.now(),sendingParticipantIdentity:n})}});s(new qW(c,h,Ef(e.totalLength)),{identity:n})}}handleStreamChunk(e,n){const r=this.byteStreamControllers.get(e.streamId);r&&(r.info.encryptionType!==n?(r.controller.error(new Ei("Encryption type mismatch for stream ".concat(e.streamId,". Expected ").concat(n,", got ").concat(r.info.encryptionType),Rr.EncryptionTypeMismatch)),this.byteStreamControllers.delete(e.streamId)):e.content.length>0&&r.controller.enqueue(e));const i=this.textStreamControllers.get(e.streamId);i&&(i.info.encryptionType!==n?(i.controller.error(new Ei("Encryption type mismatch for stream ".concat(e.streamId,". Expected ").concat(n,", got ").concat(i.info.encryptionType),Rr.EncryptionTypeMismatch)),this.textStreamControllers.delete(e.streamId)):e.content.length>0&&i.controller.enqueue(e))}handleStreamTrailer(e,n){const r=this.textStreamControllers.get(e.streamId);r&&(r.info.encryptionType!==n?r.controller.error(new Ei("Encryption type mismatch for stream ".concat(e.streamId,". Expected ").concat(n,", got ").concat(r.info.encryptionType),Rr.EncryptionTypeMismatch)):(r.info.attributes=Object.assign(Object.assign({},r.info.attributes),e.attributes),r.controller.close(),this.textStreamControllers.delete(e.streamId)));const i=this.byteStreamControllers.get(e.streamId);i&&(i.info.encryptionType!==n?i.controller.error(new Ei("Encryption type mismatch for stream ".concat(e.streamId,". Expected ").concat(n,", got ").concat(i.info.encryptionType),Rr.EncryptionTypeMismatch)):(i.info.attributes=Object.assign(Object.assign({},i.info.attributes),e.attributes),i.controller.close()),this.byteStreamControllers.delete(e.streamId))}}class JP{constructor(e,n,r){this.writableStream=e,this.defaultWriter=e.getWriter(),this.onClose=r,this.info=n}write(e){return this.defaultWriter.write(e)}close(){return H(this,void 0,void 0,function*(){var e;yield this.defaultWriter.close(),this.defaultWriter.releaseLock(),(e=this.onClose)===null||e===void 0||e.call(this)})}}class GW extends JP{}class YW extends JP{}const VC=15e3;class JW{constructor(e,n){this.engine=e,this.log=n}setupEngine(e){this.engine=e}sendText(e,n){return H(this,void 0,void 0,function*(){var r;const i=crypto.randomUUID(),a=new TextEncoder().encode(e).byteLength,c=(r=n==null?void 0:n.attachments)===null||r===void 0?void 0:r.map(()=>crypto.randomUUID()),h=new Array(c?c.length+1:1).fill(0),d=(p,g)=>{var v;h[g]=p;const k=h.reduce((w,S)=>w+S,0);(v=n==null?void 0:n.onProgress)===null||v===void 0||v.call(n,k)},f=yield this.streamText({streamId:i,totalSize:a,destinationIdentities:n==null?void 0:n.destinationIdentities,topic:n==null?void 0:n.topic,attachedStreamIds:c,attributes:n==null?void 0:n.attributes});return yield f.write(e),d(1,0),yield f.close(),n!=null&&n.attachments&&c&&(yield Promise.all(n.attachments.map((p,g)=>H(this,void 0,void 0,function*(){return this._sendFile(c[g],p,{topic:n.topic,mimeType:p.type,onProgress:v=>{d(v,g+1)}})})))),f.info})}streamText(e){return H(this,void 0,void 0,function*(){var n,r,i;const s=(n=e==null?void 0:e.streamId)!==null&&n!==void 0?n:crypto.randomUUID(),a={id:s,mimeType:"text/plain",timestamp:Date.now(),topic:(r=e==null?void 0:e.topic)!==null&&r!==void 0?r:"",size:e==null?void 0:e.totalSize,attributes:e==null?void 0:e.attributes,encryptionType:!((i=this.engine.e2eeManager)===null||i===void 0)&&i.isDataChannelEncryptionEnabled?bn.GCM:bn.NONE,attachedStreamIds:e==null?void 0:e.attachedStreamIds},c=new Hf({streamId:s,mimeType:a.mimeType,topic:a.topic,timestamp:$o(a.timestamp),totalLength:$o(a.size),attributes:a.attributes,contentHeader:{case:"textHeader",value:new B2({version:e==null?void 0:e.version,attachedStreamIds:a.attachedStreamIds,replyToStreamId:e==null?void 0:e.replyToStreamId,operationType:(e==null?void 0:e.type)==="update"?wv.UPDATE:wv.CREATE})}}),h=e==null?void 0:e.destinationIdentities,d=new Mr({destinationIdentities:h,value:{case:"streamHeader",value:c}});yield this.engine.sendDataPacket(d,It.RELIABLE);let f=0;const p=this.engine,g=new WritableStream({write(w){return H(this,void 0,void 0,function*(){for(const S of UV(w,VC)){const T=new qf({content:S,streamId:s,chunkIndex:$o(f)}),C=new Mr({destinationIdentities:h,value:{case:"streamChunk",value:T}});yield p.sendDataPacket(C,It.RELIABLE),f+=1}})},close(){return H(this,void 0,void 0,function*(){const w=new Kf({streamId:s}),S=new Mr({destinationIdentities:h,value:{case:"streamTrailer",value:w}});yield p.sendDataPacket(S,It.RELIABLE)})},abort(w){console.log("Sink error:",w)}});let v=()=>H(this,void 0,void 0,function*(){yield k.close()});p.once(De.Closing,v);const k=new GW(g,a,()=>this.engine.off(De.Closing,v));return k})}sendFile(e,n){return H(this,void 0,void 0,function*(){const r=crypto.randomUUID();return yield this._sendFile(r,e,n),{id:r}})}_sendFile(e,n,r){return H(this,void 0,void 0,function*(){var i;const s=yield this.streamBytes({streamId:e,totalSize:n.size,name:n.name,mimeType:(i=r==null?void 0:r.mimeType)!==null&&i!==void 0?i:n.type,topic:r==null?void 0:r.topic,destinationIdentities:r==null?void 0:r.destinationIdentities}),a=n.stream().getReader();for(;;){const{done:c,value:h}=yield a.read();if(c)break;yield s.write(h)}return yield s.close(),s.info})}streamBytes(e){return H(this,void 0,void 0,function*(){var n,r,i,s,a;const c=(n=e==null?void 0:e.streamId)!==null&&n!==void 0?n:crypto.randomUUID(),h=e==null?void 0:e.destinationIdentities,d={id:c,mimeType:(r=e==null?void 0:e.mimeType)!==null&&r!==void 0?r:"application/octet-stream",topic:(i=e==null?void 0:e.topic)!==null&&i!==void 0?i:"",timestamp:Date.now(),attributes:e==null?void 0:e.attributes,size:e==null?void 0:e.totalSize,name:(s=e==null?void 0:e.name)!==null&&s!==void 0?s:"unknown",encryptionType:!((a=this.engine.e2eeManager)===null||a===void 0)&&a.isDataChannelEncryptionEnabled?bn.GCM:bn.NONE},f=new Hf({totalLength:$o(d.size),mimeType:d.mimeType,streamId:c,topic:d.topic,timestamp:$o(Date.now()),attributes:d.attributes,contentHeader:{case:"byteHeader",value:new z2({name:d.name})}}),p=new Mr({destinationIdentities:h,value:{case:"streamHeader",value:f}});yield this.engine.sendDataPacket(p,It.RELIABLE);let g=0;const v=new fr,k=this.engine,w=this.log,S=new WritableStream({write(C){return H(this,void 0,void 0,function*(){const j=yield v.lock();let R=0;try{for(;R<C.byteLength;){const _=C.slice(R,R+VC),I=new Mr({destinationIdentities:h,value:{case:"streamChunk",value:new qf({content:_,streamId:c,chunkIndex:$o(g)})}});yield k.sendDataPacket(I,It.RELIABLE),g+=1,R+=_.byteLength}}finally{j()}})},close(){return H(this,void 0,void 0,function*(){const C=new Kf({streamId:c}),j=new Mr({destinationIdentities:h,value:{case:"streamTrailer",value:C}});yield k.sendDataPacket(j,It.RELIABLE)})},abort(C){w.error("Sink error:",C)}});return new YW(S,d)})}}function XP(t){if(t.length===0)return new AbortController().signal;if(t.length===1)return t[0];for(const i of t)if(i.aborted)return i;const e=new AbortController,n=Array(t.length),r=()=>{for(const i of n)i()};return t.forEach((i,s)=>{const a=()=>{e.abort(i.reason),r()};i.addEventListener("abort",a),n[s]=()=>i.removeEventListener("abort",a)}),e.signal}function QP(t){const e=new AbortController;return setTimeout(()=>{e.abort(new DOMException("signal timed out after ".concat(t," ms"),"TimeoutError"))},t),e.signal}const $n=1,ta=2,WC=4,XW=8,HC=0,qC=12,KC=5,QW=7,GC=3,ZW=3,YC=2,JC=1,XC=0,QC=3,eH=2,ZC=2,tH=1,nH=0;var oa;(function(t){t[t.TooShort=0]="TooShort",t[t.HeaderOverrun=1]="HeaderOverrun",t[t.MissingExtWords=2]="MissingExtWords",t[t.UnsupportedVersion=3]="UnsupportedVersion",t[t.InvalidHandle=4]="InvalidHandle",t[t.MalformedExt=5]="MalformedExt"})(oa||(oa={}));class Dr extends Ai{constructor(e,n,r){super(19,e,r),this.name="DataTrackDeserializeError",this.reason=n,this.reasonName=oa[n]}static tooShort(){return new Dr("Too short to contain a valid header",oa.TooShort)}static headerOverrun(){return new Dr("Header exceeds total packet length",oa.HeaderOverrun)}static missingExtWords(){return new Dr("Extension word indicator is missing",oa.MissingExtWords)}static unsupportedVersion(e){return new Dr("Unsupported version ".concat(e),oa.UnsupportedVersion)}static invalidHandle(e){return new Dr("invalid track handle: ".concat(e.message),oa.InvalidHandle,{cause:e})}static malformedExt(e){return new Dr("Extension with tag ".concat(e," is malformed"),oa.MalformedExt)}}var Yu;(function(t){t[t.TooSmallForHeader=0]="TooSmallForHeader",t[t.TooSmallForPayload=1]="TooSmallForPayload"})(Yu||(Yu={}));class fd extends Ai{constructor(e,n,r){super(19,e,r),this.name="DataTrackSerializeError",this.reason=n,this.reasonName=Yu[n]}static tooSmallForHeader(){return new fd("Buffer cannot fit header",Yu.TooSmallForHeader)}static tooSmallForPayload(){return new fd("Buffer cannot fit payload",Yu.TooSmallForPayload)}}class Mp{toBinary(){const e=this.toBinaryLengthBytes(),n=new ArrayBuffer(e),r=new DataView(n),i=this.toBinaryInto(r);if(e!==i)throw new Error("".concat(this.constructor.name,".toBinary: written bytes (").concat(i," bytes) not equal to allocated array buffer length (").concat(e," bytes)."));return new Uint8Array(n)}}var Tc;(function(t){t[t.UserTimestamp=2]="UserTimestamp",t[t.E2ee=1]="E2ee"})(Tc||(Tc={}));class ZP extends Mp{}class Xi extends ZP{constructor(e){super(),this.timestamp=e}toBinaryLengthBytes(){return $n+$n+Xi.lengthBytes}toBinaryInto(e){let n=0;e.setUint8(n,Xi.tag),n+=$n,e.setUint8(n,Xi.lengthBytes),n+=$n,e.setBigUint64(n,this.timestamp),n+=XW;const r=this.toBinaryLengthBytes();if(n!==r)throw new Error("DataTrackUserTimestampExtension.toBinaryInto: Wrote ".concat(n," bytes but expected length was ").concat(r," bytes"));return n}toJSON(){return{tag:Xi.tag,lengthBytes:Xi.lengthBytes,timestamp:this.timestamp}}}Xi.tag=Tc.UserTimestamp;Xi.lengthBytes=8;class Qi extends ZP{constructor(e,n){super(),this.keyIndex=e,this.iv=n}toBinaryLengthBytes(){return $n+$n+Qi.lengthBytes}toBinaryInto(e){let n=0;e.setUint8(n,Qi.tag),n+=$n,e.setUint8(n,Qi.lengthBytes),n+=$n,e.setUint8(n,this.keyIndex),n+=$n;for(let i=0;i<this.iv.length;i+=1)e.setUint8(n,this.iv[i]),n+=$n;const r=this.toBinaryLengthBytes();if(n!==r)throw new Error("DataTrackE2eeExtension.toBinaryInto: Wrote ".concat(n," bytes but expected length was ").concat(r," bytes"));return n}toJSON(){return{tag:Qi.tag,lengthBytes:Qi.lengthBytes,keyIndex:this.keyIndex,iv:this.iv}}}Qi.tag=Tc.E2ee;Qi.lengthBytes=13;class gc extends Mp{constructor(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};super(),this.userTimestamp=e.userTimestamp,this.e2ee=e.e2ee}toBinaryLengthBytes(){let e=0;return this.userTimestamp&&(e+=this.userTimestamp.toBinaryLengthBytes()),this.e2ee&&(e+=this.e2ee.toBinaryLengthBytes()),e}toBinaryInto(e){let n=0;if(this.e2ee){const i=this.e2ee.toBinaryInto(e);n+=i}if(this.userTimestamp){const i=this.userTimestamp.toBinaryInto(new DataView(e.buffer,e.byteOffset+n));n+=i}const r=this.toBinaryLengthBytes();if(n!==r)throw new Error("DataTrackExtensions.toBinaryInto: Wrote ".concat(n," bytes but expected length was ").concat(r," bytes"));return n}static fromBinary(e){const n=Nx(e);let r,i,s=0;for(;n.byteLength-s>=$n+$n;){const a=n.getUint8(s);s+=$n;const c=n.getUint8(s);if(s+=$n,a!==nH)switch(a){case Tc.UserTimestamp:if(n.byteLength-s<Xi.lengthBytes)throw Dr.malformedExt(a);r=new Xi(n.getBigUint64(s)),s+=c;break;case Tc.E2ee:if(n.byteLength-s<Qi.lengthBytes)throw Dr.malformedExt(a);const h=n.getUint8(s),d=new Uint8Array(12);for(let f=0;f<d.length;f+=1){let p=s;p+=$n,p+=f*$n,d[f]=n.getUint8(p)}i=new Qi(h,d),s+=c;break;default:if(n.byteLength-s<c)throw Dr.malformedExt(a);s+=c;break}}return[new gc({userTimestamp:r,e2ee:i}),n.byteLength]}toJSON(){var e,n,r,i;return{userTimestamp:(n=(e=this.userTimestamp)===null||e===void 0?void 0:e.toJSON())!==null&&n!==void 0?n:null,e2ee:(i=(r=this.e2ee)===null||r===void 0?void 0:r.toJSON())!==null&&i!==void 0?i:null}}}const e_={from(t){return{payload:t.payload,extensions:new gc({userTimestamp:t.userTimestamp?new Xi(t.userTimestamp):void 0})}},lossyIntoFrame(t){var e;return{payload:t.payload,userTimestamp:(e=t.extensions.userTimestamp)===null||e===void 0?void 0:e.timestamp}}},t_=Symbol.for("lk.track"),n_=Symbol.for("lk.data-track");class r_{constructor(e,n,r){this.trackSymbol=t_,this.isLocal=!1,this.typeSymbol=n_,this.info=e,this.manager=n,this.publisherIdentity=r.publisherIdentity}subscribe(e){try{const[n]=this.manager.openSubscriptionStream(this.info.sid,e==null?void 0:e.signal,e==null?void 0:e.bufferSize);return n}catch(n){throw n}}}class pd extends Mp{constructor(e){var n;super(),this.marker=e.marker,this.trackHandle=e.trackHandle,this.sequence=e.sequence,this.frameNumber=e.frameNumber,this.timestamp=e.timestamp,this.extensions=(n=e.extensions)!==null&&n!==void 0?n:new gc}extensionsMetrics(){const e=this.extensions.toBinaryLengthBytes(),n=Math.ceil(e/4),r=n*4-e;return{lengthBytes:e,lengthWords:n,paddingLengthBytes:r}}toBinaryLengthBytes(){const{lengthBytes:e,paddingLengthBytes:n}=this.extensionsMetrics();let r=qC;return e>0&&(r+=eH+e+n),r}toBinaryInto(e){if(e.byteLength<this.toBinaryLengthBytes())throw fd.tooSmallForHeader();let n=HC<<KC,r;switch(this.marker){case Rn.Inter:r=XC;break;case Rn.Final:r=JC;break;case Rn.Start:r=YC;break;case Rn.Single:r=QC;break}n|=r<<GC;const{lengthBytes:i,lengthWords:s,paddingLengthBytes:a}=this.extensionsMetrics();i>0&&(n|=1<<ZC);let c=0;if(e.setUint8(c,n),c+=$n,e.setUint8(c,0),c+=$n,e.setUint16(c,this.trackHandle),c+=ta,e.setUint16(c,this.sequence.value),c+=ta,e.setUint16(c,this.frameNumber.value),c+=ta,e.setUint32(c,this.timestamp.asTicks()),c+=WC,i>0){const d=s-1;e.setUint16(c,d),c+=ta;const f=this.extensions.toBinaryInto(new DataView(e.buffer,e.byteOffset+c));c+=f;for(let p=0;p<a;p+=1)e.setUint8(c,0),c+=$n}const h=this.toBinaryLengthBytes();if(c!==h)throw new Error("DataTrackPacketHeader.toBinaryInto: Wrote ".concat(c," bytes but expected length was ").concat(h," bytes"));return h}static fromBinary(e){const n=Nx(e);if(n.byteLength<qC)throw Dr.tooShort();let r=0;const i=n.getUint8(r);r+=$n;const s=i>>KC&QW;if(s>HC)throw Dr.unsupportedVersion(s);let a;switch(i>>GC&ZW){case YC:a=Rn.Start;break;case JC:a=Rn.Final;break;case QC:a=Rn.Single;break;case XC:default:a=Rn.Inter;break}const c=(i>>ZC&tH)>0;r+=$n;let h;try{h=eW.fromNumber(n.getUint16(r))}catch(v){throw v instanceof Cc&&(v.isReason(il.Reserved)||v.isReason(il.TooLarge))?Dr.invalidHandle(v):v}r+=ta;const d=ns.u16(n.getUint16(r));r+=ta;const f=ns.u16(n.getUint16(r));r+=ta;const p=mc.fromRtpTicks(n.getUint32(r));r+=WC;let g=new gc;if(c){if(n.byteLength-r<ta)throw Dr.missingExtWords();let v=n.getUint16(r);r+=ta;let w=4*(v+1);if(r+w>n.byteLength)throw Dr.headerOverrun();let S=new DataView(n.buffer,n.byteOffset+r,w);const[T,C]=gc.fromBinary(S);g=T,r+=C}return[new pd({marker:a,trackHandle:h,sequence:d,frameNumber:f,timestamp:p,extensions:g}),r]}toJSON(){return{marker:this.marker,trackHandle:this.trackHandle,sequence:this.sequence.value,frameNumber:this.frameNumber.value,timestamp:this.timestamp.asTicks(),extensions:this.extensions.toJSON()}}}var Rn;(function(t){t[t.Start=0]="Start",t[t.Inter=1]="Inter",t[t.Final=2]="Final",t[t.Single=3]="Single"})(Rn||(Rn={}));class Dp extends Mp{constructor(e,n){super(),this.header=e,this.payload=n}toBinaryLengthBytes(){return this.header.toBinaryLengthBytes()+this.payload.byteLength}toBinaryInto(e){let n=0;const r=this.header.toBinaryInto(e);if(n+=r,e.byteLength-n<this.payload.byteLength)throw fd.tooSmallForPayload();for(let s=0;s<this.payload.length;s+=1)e.setUint8(n,this.payload[s]),n+=$n;const i=this.toBinaryLengthBytes();if(n!==i)throw new Error("DataTrackPacket.toBinaryInto: Wrote ".concat(n," bytes but expected length was ").concat(i," bytes"));return i}static fromBinary(e){const n=Nx(e),[r,i]=pd.fromBinary(n),s=n.buffer.slice(n.byteOffset+i,n.byteOffset+n.byteLength);return[new Dp(r,new Uint8Array(s)),n.byteLength]}toJSON(){return{header:this.header.toJSON(),payload:this.payload}}}const P0=ei(Nr.DataTracks);class qi extends Ai{constructor(e,n,r,i){super(19,"Frame ".concat(r," dropped: ").concat(e),i),this.name="DataTrackDepacketizerDropError",this.reason=n,this.reasonName=Go[n],this.frameNumber=r}static interrupted(e,n){return new qi("Interrupted by the start of a new frame ".concat(n),Go.Interrupted,e)}static unknownFrame(e){return new qi("Initial packet was never received.",Go.UnknownFrame,e)}static bufferFull(e){return new qi("Reorder buffer is full.",Go.BufferFull,e)}static incomplete(e,n,r){return new qi("Not all packets received before final packet. Received ".concat(n," packets, expected ").concat(r," packets."),Go.Incomplete,e)}}var Go;(function(t){t[t.Interrupted=0]="Interrupted",t[t.UnknownFrame=1]="UnknownFrame",t[t.BufferFull=2]="BufferFull",t[t.Incomplete=3]="Incomplete"})(Go||(Go={}));class Ap{constructor(){this.partial=null}push(e,n){switch(e.header.marker){case Rn.Single:return this.frameFromSingle(e,n);case Rn.Start:return this.beginPartial(e,n);case Rn.Inter:case Rn.Final:return this.pushToPartial(e)}}reset(){this.partial=null}frameFromSingle(e,n){if(e.header.marker!==Rn.Single)throw new Error("Depacketizer.frameFromSingle: packet.header.marker was not FrameMarker.Single, found ".concat(e.header.marker,"."));if(this.partial)if(n!=null&&n.errorOnPartialFrames){const r=this.partial.frameNumber;throw this.reset(),qi.interrupted(r,e.header.frameNumber.value)}else P0.warn("Data track frame ".concat(this.partial.frameNumber," was interrupted by the start of a new frame, dropping."));return this.reset(),{payload:e.payload,extensions:e.header.extensions}}beginPartial(e,n){if(e.header.marker!==Rn.Start)throw new Error("Depacketizer.beginPartial: packet.header.marker was not FrameMarker.Start, found ".concat(e.header.marker,"."));if(this.partial)if(n!=null&&n.errorOnPartialFrames){const i=this.partial.frameNumber;throw this.reset(),qi.interrupted(i,e.header.frameNumber.value)}else P0.warn("Data track frame ".concat(this.partial.frameNumber," was interrupted by the start of a new frame ").concat(e.header.frameNumber.value,", dropping."));this.reset();const r=e.header.sequence;return this.partial={frameNumber:e.header.frameNumber.value,startSequence:r,extensions:e.header.extensions,payloads:new Map([[r.value,e.payload]])},null}pushToPartial(e){if(e.header.marker!==Rn.Inter&&e.header.marker!==Rn.Final)throw new Error("Depacketizer.pushToPartial: packet.header.marker was not FrameMarker.Inter or FrameMarker.Final, found ".concat(e.header.marker,"."));if(!this.partial)throw this.reset(),qi.unknownFrame(e.header.frameNumber.value);if(e.header.frameNumber.value!==this.partial.frameNumber){const n=this.partial.frameNumber;throw this.reset(),qi.interrupted(n,e.header.frameNumber.value)}if(this.partial.payloads.size>=Ap.MAX_BUFFER_PACKETS){const n=this.partial.frameNumber;throw this.reset(),qi.bufferFull(n)}return this.partial.payloads.has(e.header.sequence.value)&&P0.warn("Data track frame ".concat(this.partial.frameNumber," received duplicate packet for sequence ").concat(e.header.sequence.value,", so replacing with newly received packet.")),this.partial.payloads.set(e.header.sequence.value,e.payload),e.header.marker===Rn.Final?this.finalize(this.partial,e.header.sequence.value):null}finalize(e,n){const r=e.payloads.size;let i=0;for(const h of e.payloads.values())i+=h.length;const s=new Uint8Array(i);let a=e.startSequence.clone(),c=0;for(;;){const h=e.payloads.get(a.value);if(!h)break;e.payloads.delete(a.value);const d=s.length-c;if(h.length>d)throw new Error("Depacketizer.finalize: Expected at least ".concat(h.length," more bytes left in the payload buffer, only got ").concat(d," bytes."));if(s.set(h,c),c+=h.length,a.value!=n){a.increment();continue}return this.reset(),{payload:s,extensions:e.extensions}}throw this.reset(),qi.incomplete(e.frameNumber,r,n-e.startSequence.value+1)}}Ap.MAX_BUFFER_PACKETS=128;var Yo;(function(t){t[t.Unpublished=0]="Unpublished",t[t.Timeout=1]="Timeout",t[t.Disconnected=2]="Disconnected",t[t.Cancelled=4]="Cancelled"})(Yo||(Yo={}));class qr extends Ai{constructor(e,n,r){super(22,e,r),this.name="DataTrackSubscribeError",this.reason=n,this.reasonName=Yo[n]}static unpublished(){return new qr("The track has been unpublished and is no longer available",Yo.Unpublished)}static timeout(){return new qr("Request to subscribe to data track timed-out",Yo.Timeout)}static disconnected(){return new qr("Cannot subscribe to data track when disconnected",Yo.Disconnected)}static cancelled(){return new qr("Subscription to data track cancelled by caller",Yo.Cancelled)}}const _0=ei(Nr.DataTracks);class rH{constructor(e){var n;const r=e.e2eeManager!==null;if(e.info.usesE2ee!==r)throw new Error("IncomingDataTrackPipeline: DataTrackInfo.usesE2ee must match presence of decryptionProvider");const i=new Ap;this.publisherIdentity=e.publisherIdentity,this.e2eeManager=(n=e.e2eeManager)!==null&&n!==void 0?n:null,this.depacketizer=i}updateE2eeManager(e){this.e2eeManager=e}processPacket(e){return H(this,void 0,void 0,function*(){const n=this.depacketize(e);if(!n)return null;const r=yield this.decryptIfNeeded(n);return r||null})}depacketize(e){let n;try{n=this.depacketizer.push(e)}catch(r){return _0.warn("Data frame depacketize error: ".concat(r)),null}return n}decryptIfNeeded(e){return H(this,void 0,void 0,function*(){var n,r;const i=this.e2eeManager;if(!i)return e;const s=(r=(n=e.extensions)===null||n===void 0?void 0:n.e2ee)!==null&&r!==void 0?r:null;if(!s)return _0.error("Missing E2EE meta"),null;let a;try{a=yield i.handleEncryptedData(e.payload,s.iv,this.publisherIdentity,s.keyIndex)}catch(c){return _0.error("Error decrypting packet: ".concat(c)),null}return e.payload=a.payload,e})}}const yr=ei(Nr.DataTracks),iH=1e4,sH=16;class aH extends Di.EventEmitter{constructor(e){var n;super(),this.descriptors=new Map,this.subscriptionHandles=new Map,this.e2eeManager=(n=e==null?void 0:e.e2eeManager)!==null&&n!==void 0?n:null}updateE2eeManager(e){this.e2eeManager=e;for(const n of this.descriptors.values())n.subscription.type==="active"&&n.subscription.pipeline.updateE2eeManager(e)}openSubscriptionStream(e,n){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:sH,i=null;const s=new Jr,a=()=>{n==null||n.removeEventListener("abort",h)},c=()=>{if(a(),!i){yr.warn("ReadableStream subscribed to ".concat(e," was not started."));return}const f=this.descriptors.get(e);if(!f){yr.warn("Unknown track ".concat(e,", skipping cancel..."));return}if(f.subscription.type!=="active"){yr.warn("Subscription for track ".concat(e," is not active, skipping cancel..."));return}f.subscription.streamControllers.delete(i),f.subscription.streamControllers.size===0&&this.unSubscribeRequest(f.info.sid)},h=()=>{var f;if(!i)return;const p=this.descriptors.get(e);(p==null?void 0:p.subscription.type)==="active"&&p.subscription.streamControllers.delete(i),i.error(qr.cancelled()),(f=s.reject)===null||f===void 0||f.call(s,qr.cancelled()),c()};return[new ReadableStream({start:f=>{i=f,this.subscribeRequest(e,n).then(()=>H(this,void 0,void 0,function*(){var p,g,v;const k=this.descriptors.get(e);if(!k){yr.error("Unknown track ".concat(e));const w=qr.disconnected();f.error(w),(p=s.reject)===null||p===void 0||p.call(s,w);return}if(k.subscription.type!=="active"){yr.error("Subscription for track ".concat(e," is not active"));const w=qr.disconnected();f.error(w),(g=s.reject)===null||g===void 0||g.call(s,w);return}if(n!=null&&n.aborted){h();return}n==null||n.addEventListener("abort",h),k.subscription.streamControllers.set(f,a),(v=s.resolve)===null||v===void 0||v.call(s)})).catch(p=>{var g;f.error(p),(g=s.reject)===null||g===void 0||g.call(s,p)})},cancel:()=>{c()}},new CountQueuingStrategy({highWaterMark:r})),s.promise]}subscribeRequest(e,n){return H(this,void 0,void 0,function*(){const r=this.descriptors.get(e);if(!r)throw new Error("Cannot subscribe to unknown track");const i=(s,a,c)=>H(this,void 0,void 0,function*(){if(s.subscription.type==="active")return;if(s.subscription.type!=="pending")throw new Error("Descriptor for track ".concat(e," is not pending, found ").concat(s.subscription.type));const h=XP([a,c].filter(p=>typeof p<"u")),d=new Jr;s.subscription.completionFuture.promise.then(()=>{var p;return(p=d.resolve)===null||p===void 0?void 0:p.call(d)}).catch(p=>{var g;return(g=d.reject)===null||g===void 0?void 0:g.call(d,p)});const f=()=>{var p;if(s.subscription.type==="pending"){if(s.subscription.pendingRequestCount-=1,c!=null&&c.aborted){s.subscription.cancel();return}if(s.subscription.pendingRequestCount<=0){s.subscription.cancel();return}(p=d.reject)===null||p===void 0||p.call(d,qr.cancelled())}};h.aborted&&f(),h.addEventListener("abort",f),yield d.promise,h.removeEventListener("abort",f)});switch(r.subscription.type){case"none":{r.subscription={type:"pending",completionFuture:new Jr,pendingRequestCount:1,cancel:()=>{var a,c;const h=r.subscription;r.subscription={type:"none"},this.emit("sfuUpdateSubscription",{sid:e,subscribe:!1}),h.type==="pending"&&((c=(a=h.completionFuture).reject)===null||c===void 0||c.call(a,s.aborted?qr.timeout():qr.cancelled()))}},this.emit("sfuUpdateSubscription",{sid:e,subscribe:!0});const s=QP(iH);yield i(r,n,s);return}case"pending":{r.subscription.pendingRequestCount+=1,yield i(r,n);return}case"active":return}})}querySubscribed(){return H(this,void 0,void 0,function*(){return Array.from(this.descriptors.values()).filter(n=>n.subscription.type==="active").map(n=>[n.info,n.publisherIdentity])})}unSubscribeRequest(e){var n;const r=this.descriptors.get(e);if(!r)throw new Error("Cannot subscribe to unknown track");if(r.subscription.type!=="active"){yr.warn("Unexpected descriptor state in unSubscribeRequest, expected active, found ".concat((n=r.subscription)===null||n===void 0?void 0:n.type));return}this.closeStreamControllers(r.subscription.streamControllers,e);const i=r.subscription;r.subscription={type:"none"},this.subscriptionHandles.delete(i.subcriptionHandle),this.emit("sfuUpdateSubscription",{sid:e,subscribe:!1})}closeStreamControllers(e,n){for(const[r,i]of e){i();try{r.close()}catch(s){yr.warn("Failed to close readable stream for track ".concat(n,": ").concat(s))}}}receiveSfuPublicationUpdates(e){return H(this,void 0,void 0,function*(){if(e.size===0)return;const n=new Map;for(const[r,i]of e.entries()){const s=new Set;for(const a of i)s.add(a.sid),!this.descriptors.has(a.sid)&&(yield this.handleTrackPublished(r,a));n.set(r,s)}for(const[r,i]of n.entries()){let a=Array.from(this.descriptors.entries()).filter(c=>{let[h,d]=c;return d.publisherIdentity===r}).map(c=>{let[h]=c;return h}).filter(c=>!i.has(c));for(const c of a)this.handleTrackUnpublished(c)}})}queryPublications(){return H(this,void 0,void 0,function*(){return Array.from(this.descriptors.values()).map(e=>e.info)})}handleTrackPublished(e,n){return H(this,void 0,void 0,function*(){if(this.descriptors.has(n.sid)){yr.error("Existing descriptor for track ".concat(n.sid));return}let r={info:n,publisherIdentity:e,subscription:{type:"none"}};this.descriptors.set(r.info.sid,r);const i=new r_(r.info,this,{publisherIdentity:e});this.emit("trackPublished",{track:i})})}handleTrackUnpublished(e){const n=this.descriptors.get(e);if(!n){yr.error("Unknown track ".concat(e));return}this.descriptors.delete(e),n.subscription.type==="active"&&(this.closeStreamControllers(n.subscription.streamControllers,e),this.subscriptionHandles.delete(n.subscription.subcriptionHandle)),this.emit("trackUnpublished",{sid:e,publisherIdentity:n.publisherIdentity})}receivedSfuSubscriberHandles(e){for(const[n,r]of e.entries())this.registerSubscriberHandle(n,r)}registerSubscriberHandle(e,n){var r,i;const s=this.descriptors.get(n);if(!s){yr.error("Unknown track ".concat(n));return}switch(s.subscription.type){case"none":{yr.warn("No subscription for ".concat(n));return}case"active":{s.subscription.subcriptionHandle=e,this.subscriptionHandles.set(e,n);return}case"pending":{const a=new rH({info:s.info,publisherIdentity:s.publisherIdentity,e2eeManager:this.e2eeManager}),c=s.subscription;s.subscription={type:"active",subcriptionHandle:e,pipeline:a,streamControllers:new Map},this.subscriptionHandles.set(e,n),(i=(r=c.completionFuture).resolve)===null||i===void 0||i.call(r)}}}packetReceived(e){return H(this,void 0,void 0,function*(){let n;try{[n]=Dp.fromBinary(e)}catch(a){yr.error("Failed to deserialize packet: ".concat(a));return}const r=this.subscriptionHandles.get(n.header.trackHandle);if(!r){yr.warn("Unknown subscriber handle ".concat(n.header.trackHandle));return}const i=this.descriptors.get(r);if(!i){yr.error("Missing descriptor for track ".concat(r));return}if(i.subscription.type!=="active"){yr.warn("Received packet for track ".concat(r," without active subscription"));return}const s=yield i.subscription.pipeline.processPacket(n);if(s)for(const a of i.subscription.streamControllers.keys()){if(a.desiredSize!==null&&a.desiredSize<=0){yr.warn("Cannot send frame to subscribers: readable stream is full (desiredSize is ".concat(a.desiredSize,"). To increase this threshold, set a higher 'options.highWaterMark' when calling .subscribe()."));continue}const c=e_.lossyIntoFrame(s);a.enqueue(c)}})}resendSubscriptionUpdates(){for(const[e,n]of this.descriptors)n.subscription.type!=="none"&&this.emit("sfuUpdateSubscription",{sid:e,subscribe:!0})}handleRemoteParticipantDisconnected(e){var n,r;for(const i of this.descriptors.values())if(i.publisherIdentity===e)switch(i.subscription.type){case"none":break;case"pending":(r=(n=i.subscription.completionFuture).reject)===null||r===void 0||r.call(n,qr.disconnected());break;case"active":this.unSubscribeRequest(i.info.sid);break}}shutdown(){var e,n;for(const r of this.descriptors.values())this.emit("trackUnpublished",{sid:r.info.sid,publisherIdentity:r.publisherIdentity}),r.subscription.type==="pending"&&((n=(e=r.subscription.completionFuture).reject)===null||n===void 0||n.call(e,qr.disconnected())),r.subscription.type==="active"&&this.closeStreamControllers(r.subscription.streamControllers,r.info.sid);this.descriptors.clear()}}class Op extends Ai{constructor(e,n,r){super(19,e,r),this.name="DataTrackPacketizerError",this.reason=n,this.reasonName=Qf[n]}static mtuTooShort(){return new Op("MTU is too short to send frame",Qf.MtuTooShort)}}var Qf;(function(t){t[t.MtuTooShort=0]="MtuTooShort"})(Qf||(Qf={}));class Ax{constructor(e,n){this.sequence=ns.u16(0),this.frameNumber=ns.u16(0),this.clock=qo.rtpStartingNow(mc.rtpRandom()),this.handle=e,this.mtuSizeBytes=n}static computeFrameMarker(e,n){return n<=1?Rn.Single:e===0?Rn.Start:e===n-1?Rn.Final:Rn.Inter}*packetize(e,n){var r;const i=this.frameNumber.getThenIncrement(),s={marker:Rn.Inter,trackHandle:this.handle,sequence:ns.u16(0),frameNumber:i,timestamp:(r=n==null?void 0:n.now)!==null&&r!==void 0?r:this.clock.now(),extensions:e.extensions},a=new pd(s).toBinaryLengthBytes();if(a>=this.mtuSizeBytes)throw Op.mtuTooShort();const c=this.mtuSizeBytes-a,h=Math.ceil(e.payload.byteLength/c);for(let d=0,f=0;f<e.payload.byteLength;[d,f]=[d+1,f+c]){const p=this.sequence.getThenIncrement(),g=new pd(Object.assign(Object.assign({},s),{marker:Ax.computeFrameMarker(d,h),sequence:p})),v=Math.min(c,e.payload.byteLength-f),k=new Uint8Array(e.payload.buffer,e.payload.byteOffset+f,v);yield new Dp(g,k)}}}var Vi;(function(t){t[t.NotAllowed=0]="NotAllowed",t[t.DuplicateName=1]="DuplicateName",t[t.Timeout=2]="Timeout",t[t.LimitReached=3]="LimitReached",t[t.Disconnected=4]="Disconnected",t[t.Cancelled=5]="Cancelled",t[t.InvalidName=6]="InvalidName",t[t.Unknown=7]="Unknown"})(Vi||(Vi={}));class rr extends Ai{constructor(e,n,r){super(21,e,r),this.name="DataTrackPublishError",this.reason=n,this.reasonName=Vi[n],this.rawMessage=r==null?void 0:r.rawMessage}static notAllowed(e){return new rr("Data track publishing unauthorized",Vi.NotAllowed,{rawMessage:e})}static duplicateName(e){return new rr("Track name already taken",Vi.DuplicateName,{rawMessage:e})}static invalidName(e){return new rr("Track name is invalid",Vi.InvalidName,{rawMessage:e})}static timeout(){return new rr("Publish data track timed-out. Does the LiveKit server support data tracks?",Vi.Timeout)}static limitReached(e){return new rr("Data track publication limit reached",Vi.LimitReached,{rawMessage:e})}static unknown(e,n){return new rr("Received RequestResponse for publishDataTrack, but reason was unrecognised (".concat(e,", ").concat(n,")"),Vi.Unknown)}static disconnected(){return new rr("Room disconnected",Vi.Disconnected)}static cancelled(){return new rr("Publish data track cancelled by caller",Vi.Cancelled)}}var Ju;(function(t){t[t.TrackUnpublished=0]="TrackUnpublished",t[t.Dropped=1]="Dropped"})(Ju||(Ju={}));class eo extends Ai{constructor(e,n,r){super(22,e,r),this.name="DataTrackPushFrameError",this.reason=n,this.reasonName=Ju[n]}static trackUnpublished(){return new eo("Track is no longer published",Ju.TrackUnpublished)}static dropped(e){return new eo("Frame was dropped",Ju.Dropped,{cause:e})}}var Xu;(function(t){t[t.Packetizer=0]="Packetizer",t[t.Encryption=1]="Encryption"})(Xu||(Xu={}));class md extends Ai{constructor(e,n,r){super(21,e,r),this.name="DataTrackOutgoingPipelineError",this.reason=n,this.reasonName=Xu[n]}static packetizer(e){return new md("Error packetizing frame",Xu.Packetizer,{cause:e})}static encryption(e){return new md("Error encrypting frame",Xu.Encryption,{cause:e})}}class Lp{constructor(e,n){this.trackSymbol=t_,this.isLocal=!0,this.typeSymbol=n_,this.handle=null,this.log=Tt,this.options=e,this.manager=n,this.log=ei(Nr.DataTracks)}static withExplicitHandle(e,n,r){const i=new Lp(e,n);return i.handle=r,i}get info(){const e=this.descriptor;if((e==null?void 0:e.type)==="active")return e.info}get descriptor(){return this.handle?this.manager.getDescriptor(this.handle):null}publish(e){return H(this,void 0,void 0,function*(){try{this.handle=yield this.manager.publishRequest(this.options,e)}catch(n){throw n}})}isPublished(){var e;return((e=this.descriptor)===null||e===void 0?void 0:e.type)==="active"&&this.descriptor.publishState!=="unpublished"}tryPush(e){if(!this.handle)throw eo.trackUnpublished();const n=e_.from(e);try{return this.manager.tryProcessAndSend(this.handle,n)}catch(r){throw r}}unpublish(){return H(this,void 0,void 0,function*(){if(!this.handle){Tt.warn('Data track "'.concat(this.options.name,'" is not published, so unpublishing has no effect.'));return}try{yield this.manager.unpublishRequest(this.handle)}catch(e){throw e}})}}class Fp{constructor(e){this.e2eeManager=e.e2eeManager,this.packetizer=new Ax(e.info.pubHandle,Fp.TRANSPORT_MTU_BYTES)}updateE2eeManager(e){this.e2eeManager=e}processFrame(e){return q$(this,arguments,function*(){const r=yield wc(this.encryptIfNeeded(e));try{yield wc(yield*K$(Yi(this.packetizer.packetize(r))))}catch(i){throw i instanceof Op?md.packetizer(i):i}})}encryptIfNeeded(e){return H(this,void 0,void 0,function*(){if(!this.e2eeManager)return e;let n;try{n=yield this.e2eeManager.encryptData(e.payload)}catch(r){throw md.encryption(r)}return e.payload=n.payload,e.extensions.e2ee=new Qi(n.keyIndex,n.iv),e})}}Fp.TRANSPORT_MTU_BYTES=16e3;const na=ei(Nr.DataTracks),eT={pending(){return{type:"pending",completionFuture:new Jr}},active(t,e){return{type:"active",info:t,publishState:"published",pipeline:new Fp({info:t,e2eeManager:e}),unpublishingFuture:new Jr}}},oH=1e4;class Ox extends Di.EventEmitter{constructor(e){var n;super(),this.handleAllocator=new tW,this.descriptors=new Map,this.e2eeManager=(n=e==null?void 0:e.e2eeManager)!==null&&n!==void 0?n:null}static withDescriptors(e){const n=new Ox;return n.descriptors=e,n}updateE2eeManager(e){this.e2eeManager=e;for(const n of this.descriptors.values())n.type==="active"&&n.pipeline.updateE2eeManager(e)}getDescriptor(e){var n;return(n=this.descriptors.get(e))!==null&&n!==void 0?n:null}tryProcessAndSend(e,n){return H(this,void 0,void 0,function*(){var r,i,s,a;const c=this.getDescriptor(e);if((c==null?void 0:c.type)!=="active"||c.publishState==="unpublished")throw eo.trackUnpublished();if(c.publishState==="republishing")throw eo.dropped("Data track republishing");try{try{for(var h=!0,d=Yi(c.pipeline.processFrame(n)),f;f=yield d.next(),r=f.done,!r;h=!0){a=f.value,h=!1;const p=a;this.emit("packetAvailable",{bytes:p.toBinary()})}}catch(p){i={error:p}}finally{try{!h&&!r&&(s=d.return)&&(yield s.call(d))}finally{if(i)throw i.error}}}catch(p){throw eo.dropped(p)}})}publishRequest(e,n){return H(this,void 0,void 0,function*(){const r=this.handleAllocator.get();if(!r)throw rr.limitReached();const i=QP(oH),s=n?XP([n,i]):i;if(this.descriptors.has(r))throw new Error("Descriptor for handle already exists");const a=eT.pending();this.descriptors.set(r,a);const c=()=>{var h,d;const f=this.descriptors.get(r);if(!f){na.warn("No descriptor for ".concat(r));return}this.descriptors.delete(r),this.emit("sfuUnpublishRequest",{handle:r}),f.type==="pending"&&((d=(h=f.completionFuture).reject)===null||d===void 0||d.call(h,i.aborted?rr.timeout():rr.cancelled()))};return s.aborted?(c(),a.completionFuture.promise.then(()=>r)):(s.addEventListener("abort",c),this.emit("sfuPublishRequest",{handle:r,name:e.name,usesE2ee:this.e2eeManager!==null}),yield a.completionFuture.promise,s.removeEventListener("abort",c),this.emit("trackPublished",{track:Lp.withExplicitHandle(e,this,r)}),r)})}queryPublished(){return Array.from(this.descriptors.values()).filter(n=>n.type==="active").map(n=>n.info)}unpublishRequest(e){return H(this,void 0,void 0,function*(){const n=this.descriptors.get(e);if(!n){na.warn("No descriptor for ".concat(e));return}if(n.type!=="active"){na.warn("Track ".concat(e," not active"));return}this.emit("sfuUnpublishRequest",{handle:e}),yield n.unpublishingFuture.promise,this.emit("trackUnpublished",{sid:n.info.sid})})}receivedSfuPublishResponse(e,n){var r,i,s,a;const c=this.descriptors.get(e);if(!c){na.warn("No descriptor for ".concat(e));return}switch(this.descriptors.delete(e),c.type){case"pending":{if(n.type==="ok"){const h=n.data,d=h.usesE2ee?this.e2eeManager:null;this.descriptors.set(h.pubHandle,eT.active(h,d)),(i=(r=c.completionFuture).resolve)===null||i===void 0||i.call(r)}else(a=(s=c.completionFuture).reject)===null||a===void 0||a.call(s,n.error);return}case"active":{if(c.publishState!=="republishing"){na.warn("Track ".concat(e," already active"));return}if(n.type==="error"){na.warn("Republish failed for track ".concat(e));return}na.debug("Track ".concat(e," republished")),c.info.sid=n.data.sid,c.publishState="published",this.descriptors.set(c.info.pubHandle,c)}}}receivedSfuUnpublishResponse(e){var n,r;const i=this.descriptors.get(e);if(!i){na.warn("No descriptor for ".concat(e));return}if(this.descriptors.delete(e),i.type!=="active"){na.warn("Track ".concat(e," not active"));return}i.publishState="unpublished",(r=(n=i.unpublishingFuture).resolve)===null||r===void 0||r.call(n)}sfuWillRepublishTracks(){var e,n;for(const[r,i]of this.descriptors.entries())switch(i.type){case"pending":this.descriptors.delete(r),(n=(e=i.completionFuture).reject)===null||n===void 0||n.call(e,rr.disconnected());break;case"active":i.publishState="republishing",this.emit("sfuPublishRequest",{handle:i.info.pubHandle,name:i.info.name,usesE2ee:i.info.usesE2ee})}}shutdown(){return H(this,void 0,void 0,function*(){var e,n,r,i;for(const s of this.descriptors.values())switch(s.type){case"pending":(n=(e=s.completionFuture).reject)===null||n===void 0||n.call(e,rr.disconnected());break;case"active":(i=(r=s.unpublishingFuture).resolve)===null||i===void 0||i.call(r),yield this.unpublishRequest(s.info.pubHandle);break}this.descriptors.clear()})}}class i_ extends Te{constructor(e,n,r,i,s){super(e,r,s),this.sid=n,this.receiver=i}get isLocal(){return!1}setMuted(e){this.isMuted!==e&&(this.isMuted=e,this._mediaStreamTrack.enabled=!e,this.emit(e?Fe.Muted:Fe.Unmuted,this))}setMediaStream(e){this.mediaStream=e;const n=r=>{r.track===this._mediaStreamTrack&&(e.removeEventListener("removetrack",n),this.receiver&&"playoutDelayHint"in this.receiver&&(this.receiver.playoutDelayHint=void 0),this.receiver=void 0,this._currentBitrate=0,this.emit(Fe.Ended,this))};e.addEventListener("removetrack",n)}start(){this.startMonitor(),super.enable()}stop(){this.stopMonitor(),super.disable()}getRTCStatsReport(){return H(this,void 0,void 0,function*(){var e;return!((e=this.receiver)===null||e===void 0)&&e.getStats?yield this.receiver.getStats():void 0})}setPlayoutDelay(e){this.receiver?"playoutDelayHint"in this.receiver?this.receiver.playoutDelayHint=e:this.log.warn("Playout delay not supported in this browser"):this.log.warn("Cannot set playout delay, track already ended")}getPlayoutDelay(){if(this.receiver){if("playoutDelayHint"in this.receiver)return this.receiver.playoutDelayHint;this.log.warn("Playout delay not supported in this browser")}else this.log.warn("Cannot get playout delay, track already ended");return 0}startMonitor(){this.monitorInterval||(this.monitorInterval=setInterval(()=>this.monitorReceiver(),Mx)),vV()&&this.registerTimeSyncUpdate()}registerTimeSyncUpdate(){const e=()=>{var n;this.timeSyncHandle=requestAnimationFrame(()=>e());const r=(n=this.receiver)===null||n===void 0?void 0:n.getSynchronizationSources()[0];if(r){const{timestamp:i,rtpTimestamp:s}=r;s&&this.rtpTimestamp!==s&&(this.emit(Fe.TimeSyncUpdate,{timestamp:i,rtpTimestamp:s}),this.rtpTimestamp=s)}};e()}}class lH extends i_{constructor(e,n,r,i,s,a){super(e,n,Te.Kind.Audio,r,a),this.monitorReceiver=()=>H(this,void 0,void 0,function*(){if(!this.receiver){this._currentBitrate=0;return}const c=yield this.getReceiverStats();c&&this.prevStats&&this.receiver&&(this._currentBitrate=Ip(c,this.prevStats)),this.prevStats=c}),this.audioContext=i,this.webAudioPluginNodes=[],s&&(this.sinkId=s.deviceId)}setVolume(e){var n;for(const r of this.attachedElements)this.audioContext?(n=this.gainNode)===null||n===void 0||n.gain.setTargetAtTime(e,0,.1):r.volume=e;Os()&&this._mediaStreamTrack._setVolume(e),this.elementVolume=e}getVolume(){if(this.elementVolume)return this.elementVolume;if(Os())return 1;let e=0;return this.attachedElements.forEach(n=>{n.volume>e&&(e=n.volume)}),e}setSinkId(e){return H(this,void 0,void 0,function*(){this.sinkId=e,yield Promise.all(this.attachedElements.map(n=>{if(Bv(n))return n.setSinkId(e)}))})}attach(e){const n=this.attachedElements.length===0;return e?super.attach(e):e=super.attach(),this.sinkId&&Bv(e)&&e.setSinkId(this.sinkId).catch(r=>{this.log.error("Failed to set sink id on remote audio track",r,this.logContext)}),this.audioContext&&n&&(this.log.debug("using audio context mapping",this.logContext),this.connectWebAudio(this.audioContext,e),e.volume=0,e.muted=!0),this.elementVolume&&this.setVolume(this.elementVolume),e}detach(e){let n;return e?(n=super.detach(e),this.audioContext&&(this.attachedElements.length>0?this.connectWebAudio(this.audioContext,this.attachedElements[0]):this.disconnectWebAudio())):(n=super.detach(),this.disconnectWebAudio()),n}setAudioContext(e){this.audioContext=e,e&&this.attachedElements.length>0?this.connectWebAudio(e,this.attachedElements[0]):e||this.disconnectWebAudio()}setWebAudioPlugins(e){this.webAudioPluginNodes=e,this.attachedElements.length>0&&this.audioContext&&this.connectWebAudio(this.audioContext,this.attachedElements[0])}connectWebAudio(e,n){this.disconnectWebAudio(),this.sourceNode=e.createMediaStreamSource(n.srcObject);let r=this.sourceNode;this.webAudioPluginNodes.forEach(i=>{r.connect(i),r=i}),this.gainNode=e.createGain(),r.connect(this.gainNode),this.gainNode.connect(e.destination),this.elementVolume&&this.gainNode.gain.setTargetAtTime(this.elementVolume,0,.1),e.state!=="running"&&e.resume().then(()=>{e.state!=="running"&&this.emit(Fe.AudioPlaybackFailed,new Error("Audio Context couldn't be started automatically"))}).catch(i=>{this.emit(Fe.AudioPlaybackFailed,i)})}disconnectWebAudio(){var e,n;(e=this.gainNode)===null||e===void 0||e.disconnect(),(n=this.sourceNode)===null||n===void 0||n.disconnect(),this.gainNode=void 0,this.sourceNode=void 0}getReceiverStats(){return H(this,void 0,void 0,function*(){if(!this.receiver||!this.receiver.getStats)return;const e=yield this.receiver.getStats();let n;return e.forEach(r=>{r.type==="inbound-rtp"&&(n={type:"audio",streamId:r.id,timestamp:r.timestamp,jitter:r.jitter,bytesReceived:r.bytesReceived,concealedSamples:r.concealedSamples,concealmentEvents:r.concealmentEvents,silentConcealedSamples:r.silentConcealedSamples,silentConcealmentEvents:r.silentConcealmentEvents,totalAudioEnergy:r.totalAudioEnergy,totalSamplesDuration:r.totalSamplesDuration})}),n})}}const R0=100;class cH extends i_{constructor(e,n,r,i,s){super(e,n,Te.Kind.Video,r,s),this.elementInfos=[],this.monitorReceiver=()=>H(this,void 0,void 0,function*(){if(!this.receiver){this._currentBitrate=0;return}const a=yield this.getReceiverStats();a&&this.prevStats&&this.receiver&&(this._currentBitrate=Ip(a,this.prevStats)),this.prevStats=a}),this.debouncedHandleResize=Px(()=>{this.updateDimensions()},R0),this.adaptiveStreamSettings=i}get isAdaptiveStream(){return this.adaptiveStreamSettings!==void 0}setStreamState(e){super.setStreamState(e),this.log.debug("setStreamState",e),this.isAdaptiveStream&&e===Te.StreamState.Active&&this.updateVisibility()}get mediaStreamTrack(){return this._mediaStreamTrack}setMuted(e){super.setMuted(e),this.attachedElements.forEach(n=>{e?hc(this._mediaStreamTrack,n):rc(this._mediaStreamTrack,n)})}attach(e){if(e?super.attach(e):e=super.attach(),this.adaptiveStreamSettings&&this.elementInfos.find(n=>n.element===e)===void 0){const n=new uH(e);this.observeElementInfo(n)}return e}observeElementInfo(e){this.adaptiveStreamSettings&&this.elementInfos.find(n=>n===e)===void 0?(e.handleResize=()=>{this.debouncedHandleResize()},e.handleVisibilityChanged=()=>{this.updateVisibility()},this.elementInfos.push(e),e.observe(),this.debouncedHandleResize(),this.updateVisibility()):this.log.warn("visibility resize observer not triggered",this.logContext)}stopObservingElementInfo(e){if(!this.isAdaptiveStream){this.log.warn("stopObservingElementInfo ignored",this.logContext);return}const n=this.elementInfos.filter(r=>r===e);for(const r of n)r.stopObserving();this.elementInfos=this.elementInfos.filter(r=>r!==e),this.updateVisibility(),this.debouncedHandleResize()}detach(e){let n=[];if(e)return this.stopObservingElement(e),super.detach(e);n=super.detach();for(const r of n)this.stopObservingElement(r);return n}getDecoderImplementation(){var e;return(e=this.prevStats)===null||e===void 0?void 0:e.decoderImplementation}getReceiverStats(){return H(this,void 0,void 0,function*(){if(!this.receiver||!this.receiver.getStats)return;const e=yield this.receiver.getStats();let n,r="",i=new Map;return e.forEach(s=>{s.type==="inbound-rtp"?(r=s.codecId,n={type:"video",streamId:s.id,framesDecoded:s.framesDecoded,framesDropped:s.framesDropped,framesReceived:s.framesReceived,packetsReceived:s.packetsReceived,packetsLost:s.packetsLost,frameWidth:s.frameWidth,frameHeight:s.frameHeight,pliCount:s.pliCount,firCount:s.firCount,nackCount:s.nackCount,jitter:s.jitter,timestamp:s.timestamp,bytesReceived:s.bytesReceived,decoderImplementation:s.decoderImplementation}):s.type==="codec"&&i.set(s.id,s)}),n&&r!==""&&i.get(r)&&(n.mimeType=i.get(r).mimeType),n})}stopObservingElement(e){const n=this.elementInfos.filter(r=>r.element===e);for(const r of n)this.stopObservingElementInfo(r)}handleAppVisibilityChanged(){const e=Object.create(null,{handleAppVisibilityChanged:{get:()=>super.handleAppVisibilityChanged}});return H(this,void 0,void 0,function*(){yield e.handleAppVisibilityChanged.call(this),this.isAdaptiveStream&&this.updateVisibility()})}updateVisibility(e){var n,r;const i=this.elementInfos.reduce((h,d)=>Math.max(h,d.visibilityChangedAt||0),0),s=!((r=(n=this.adaptiveStreamSettings)===null||n===void 0?void 0:n.pauseVideoInBackground)!==null&&r!==void 0)||r?this.isInBackground:!1,a=this.elementInfos.some(h=>h.pictureInPicture),c=this.elementInfos.some(h=>h.visible)&&!s||a;if(!(this.lastVisible===c&&!e)){if(!c&&Date.now()-i<R0){Qn.setTimeout(()=>{this.updateVisibility()},R0);return}this.lastVisible=c,this.emit(Fe.VisibilityChanged,c,this)}}updateDimensions(){var e,n;let r=0,i=0;const s=this.getPixelDensity();for(const a of this.elementInfos){const c=a.width()*s,h=a.height()*s;c+h>r+i&&(r=c,i=h)}((e=this.lastDimensions)===null||e===void 0?void 0:e.width)===r&&((n=this.lastDimensions)===null||n===void 0?void 0:n.height)===i||(this.lastDimensions={width:r,height:i},this.emit(Fe.VideoDimensionsChanged,this.lastDimensions,this))}getPixelDensity(){var e;const n=(e=this.adaptiveStreamSettings)===null||e===void 0?void 0:e.pixelDensity;return n==="screen"?gC():n||(gC()>2?2:1)}}class uH{get visible(){return this.isPiP||this.isIntersecting}get pictureInPicture(){return this.isPiP}constructor(e,n){this.onVisibilityChanged=r=>{var i;const{target:s,isIntersecting:a}=r;s===this.element&&(this.isIntersecting=a,this.isPiP=_u(this.element),this.visibilityChangedAt=Date.now(),(i=this.handleVisibilityChanged)===null||i===void 0||i.call(this))},this.onEnterPiP=()=>{var r,i,s;(i=(r=window.documentPictureInPicture)===null||r===void 0?void 0:r.window)===null||i===void 0||i.addEventListener("pagehide",this.onLeavePiP),this.isPiP=_u(this.element),(s=this.handleVisibilityChanged)===null||s===void 0||s.call(this)},this.onLeavePiP=()=>{var r;this.isPiP=_u(this.element),(r=this.handleVisibilityChanged)===null||r===void 0||r.call(this)},this.element=e,this.isIntersecting=n??Kv(e),this.isPiP=Yr()&&_u(e),this.visibilityChangedAt=0}width(){return this.element.clientWidth}height(){return this.element.clientHeight}observe(){var e,n,r;this.isIntersecting=Kv(this.element),this.isPiP=_u(this.element),this.element.handleResize=()=>{var i;(i=this.handleResize)===null||i===void 0||i.call(this)},this.element.handleVisibilityChanged=this.onVisibilityChanged,yC().observe(this.element),vC().observe(this.element),this.element.addEventListener("enterpictureinpicture",this.onEnterPiP),this.element.addEventListener("leavepictureinpicture",this.onLeavePiP),(e=window.documentPictureInPicture)===null||e===void 0||e.addEventListener("enter",this.onEnterPiP),(r=(n=window.documentPictureInPicture)===null||n===void 0?void 0:n.window)===null||r===void 0||r.addEventListener("pagehide",this.onLeavePiP)}stopObserving(){var e,n,r,i,s;(e=yC())===null||e===void 0||e.unobserve(this.element),(n=vC())===null||n===void 0||n.unobserve(this.element),this.element.removeEventListener("enterpictureinpicture",this.onEnterPiP),this.element.removeEventListener("leavepictureinpicture",this.onLeavePiP),(r=window.documentPictureInPicture)===null||r===void 0||r.removeEventListener("enter",this.onEnterPiP),(s=(i=window.documentPictureInPicture)===null||i===void 0?void 0:i.window)===null||s===void 0||s.removeEventListener("pagehide",this.onLeavePiP)}}function _u(t){var e,n;return document.pictureInPictureElement===t?!0:!((e=window.documentPictureInPicture)===null||e===void 0)&&e.window?Kv(t,(n=window.documentPictureInPicture)===null||n===void 0?void 0:n.window):!1}function Kv(t,e){const n=e||window;let r=t.offsetTop,i=t.offsetLeft;const s=t.offsetWidth,a=t.offsetHeight,{hidden:c}=t,{display:h}=getComputedStyle(t);for(;t.offsetParent;)t=t.offsetParent,r+=t.offsetTop,i+=t.offsetLeft;return r<n.pageYOffset+n.innerHeight&&i<n.pageXOffset+n.innerWidth&&r+a>n.pageYOffset&&i+s>n.pageXOffset&&!c&&h!=="none"}class la extends Di.EventEmitter{constructor(e,n,r,i){var s;super(),this.metadataMuted=!1,this.encryption=bn.NONE,this.log=Tt,this.handleMuted=()=>{this.emit(Fe.Muted)},this.handleUnmuted=()=>{this.emit(Fe.Unmuted)},this.log=ei((s=i==null?void 0:i.loggerName)!==null&&s!==void 0?s:Nr.Publication),this.loggerContextCb=this.loggerContextCb,this.setMaxListeners(100),this.kind=e,this.trackSid=n,this.trackName=r,this.source=Te.Source.Unknown}setTrack(e){this.track&&(this.track.off(Fe.Muted,this.handleMuted),this.track.off(Fe.Unmuted,this.handleUnmuted)),this.track=e,e&&(e.on(Fe.Muted,this.handleMuted),e.on(Fe.Unmuted,this.handleUnmuted))}get logContext(){var e;return Object.assign(Object.assign({},(e=this.loggerContextCb)===null||e===void 0?void 0:e.call(this)),Lt(this))}get isMuted(){return this.metadataMuted}get isEnabled(){return!0}get isSubscribed(){return this.track!==void 0}get isEncrypted(){return this.encryption!==bn.NONE}get audioTrack(){if(Ts(this.track))return this.track}get videoTrack(){if(go(this.track))return this.track}updateInfo(e){this.trackSid=e.sid,this.trackName=e.name,this.source=Te.sourceFromProto(e.source),this.mimeType=e.mimeType,this.kind===Te.Kind.Video&&e.width>0&&(this.dimensions={width:e.width,height:e.height},this.simulcasted=e.simulcast),this.encryption=e.encryption,this.trackInfo=e,this.log.debug("update publication info",Object.assign(Object.assign({},this.logContext),{info:e}))}}(function(t){(function(e){e.Desired="desired",e.Subscribed="subscribed",e.Unsubscribed="unsubscribed"})(t.SubscriptionStatus||(t.SubscriptionStatus={})),(function(e){e.Allowed="allowed",e.NotAllowed="not_allowed"})(t.PermissionStatus||(t.PermissionStatus={}))})(la||(la={}));class Gv extends la{get isUpstreamPaused(){var e;return(e=this.track)===null||e===void 0?void 0:e.isUpstreamPaused}constructor(e,n,r,i){super(e,n.sid,n.name,i),this.track=void 0,this.handleTrackEnded=()=>{this.emit(Fe.Ended)},this.handleCpuConstrained=()=>{this.track&&go(this.track)&&this.emit(Fe.CpuConstrained,this.track)},this.updateInfo(n),this.setTrack(r)}setTrack(e){this.track&&(this.track.off(Fe.Ended,this.handleTrackEnded),this.track.off(Fe.CpuConstrained,this.handleCpuConstrained)),super.setTrack(e),e&&(e.on(Fe.Ended,this.handleTrackEnded),e.on(Fe.CpuConstrained,this.handleCpuConstrained))}get isMuted(){return this.track?this.track.isMuted:super.isMuted}get audioTrack(){return super.audioTrack}get videoTrack(){return super.videoTrack}get isLocal(){return!0}mute(){return H(this,void 0,void 0,function*(){var e;return(e=this.track)===null||e===void 0?void 0:e.mute()})}unmute(){return H(this,void 0,void 0,function*(){var e;return(e=this.track)===null||e===void 0?void 0:e.unmute()})}pauseUpstream(){return H(this,void 0,void 0,function*(){var e;yield(e=this.track)===null||e===void 0?void 0:e.pauseUpstream()})}resumeUpstream(){return H(this,void 0,void 0,function*(){var e;yield(e=this.track)===null||e===void 0?void 0:e.resumeUpstream()})}getTrackFeatures(){var e;if(Ts(this.track)){const n=this.track.getSourceTrackSettings(),r=new Set;return n.autoGainControl&&r.add(lr.TF_AUTO_GAIN_CONTROL),n.echoCancellation&&r.add(lr.TF_ECHO_CANCELLATION),n.noiseSuppression&&r.add(lr.TF_NOISE_SUPPRESSION),n.channelCount&&n.channelCount>1&&r.add(lr.TF_STEREO),!((e=this.options)===null||e===void 0)&&e.dtx||r.add(lr.TF_NO_DTX),this.track.enhancedNoiseCancellation&&r.add(lr.TF_ENHANCED_NOISE_CANCELLATION),Array.from(r.values())}else return[]}}function Up(t,e){return H(this,void 0,void 0,function*(){t??(t={});let n=!1;const{audioProcessor:r,videoProcessor:i,optionsWithoutProcessor:s}=OP(t);let a=s.audio,c=s.video;if(r&&typeof s.audio=="object"&&(s.audio.processor=r),i&&typeof s.video=="object"&&(s.video.processor=i),t.audio&&typeof s.audio=="object"&&typeof s.audio.deviceId=="string"){const p=s.audio.deviceId;s.audio.deviceId={exact:p},n=!0,a=Object.assign(Object.assign({},s.audio),{deviceId:{ideal:p}})}if(s.video&&typeof s.video=="object"&&typeof s.video.deviceId=="string"){const p=s.video.deviceId;s.video.deviceId={exact:p},n=!0,c=Object.assign(Object.assign({},s.video),{deviceId:{ideal:p}})}s.audio===!0?s.audio={deviceId:"default"}:typeof s.audio=="object"&&s.audio!==null&&(s.audio=Object.assign(Object.assign({},s.audio),{deviceId:s.audio.deviceId||"default"})),s.video===!0?s.video={deviceId:"default"}:typeof s.video=="object"&&!s.video.deviceId&&(s.video.deviceId="default");const h=MP(s,$P,VP),d=Sx(h),f=navigator.mediaDevices.getUserMedia(d);s.audio&&(cr.userMediaPromiseMap.set("audioinput",f),f.catch(()=>cr.userMediaPromiseMap.delete("audioinput"))),s.video&&(cr.userMediaPromiseMap.set("videoinput",f),f.catch(()=>cr.userMediaPromiseMap.delete("videoinput")));try{const p=yield f;return yield Promise.all(p.getTracks().map(g=>H(this,void 0,void 0,function*(){const v=g.kind==="audio";let k=v?h.audio:h.video;(typeof k=="boolean"||!k)&&(k={});let w;const S=v?d.audio:d.video;typeof S!="boolean"&&(w=S);const T=g.getSettings().deviceId;w!=null&&w.deviceId&&rl(w.deviceId)!==T?w.deviceId=T:w||(w={deviceId:T});const C=NW(g,w,e);return C.kind===Te.Kind.Video?C.source=Te.Source.Camera:C.kind===Te.Kind.Audio&&(C.source=Te.Source.Microphone),C.mediaStream=p,Ts(C)&&r?yield C.setProcessor(r):go(C)&&i&&(yield C.setProcessor(i)),C})))}catch(p){if(!n)throw p;return Up(Object.assign(Object.assign({},t),{audio:a,video:c}),e)}})}function dH(t){return H(this,void 0,void 0,function*(){return(yield Up({audio:!1,video:!0}))[0]})}function hH(t){return H(this,void 0,void 0,function*(){return(yield Up({audio:!0,video:!1}))[0]})}var Xa;(function(t){t.Excellent="excellent",t.Good="good",t.Poor="poor",t.Lost="lost",t.Unknown="unknown"})(Xa||(Xa={}));function fH(t){switch(t){case Lu.EXCELLENT:return Xa.Excellent;case Lu.GOOD:return Xa.Good;case Lu.POOR:return Xa.Poor;case Lu.LOST:return Xa.Lost;default:return Xa.Unknown}}class s_ extends Di.EventEmitter{get logContext(){var e,n;return Object.assign({},(n=(e=this.loggerOptions)===null||e===void 0?void 0:e.loggerContextCb)===null||n===void 0?void 0:n.call(e))}get isEncrypted(){return this.trackPublications.size>0&&Array.from(this.trackPublications.values()).every(e=>e.isEncrypted)}get isAgent(){var e;return((e=this.permissions)===null||e===void 0?void 0:e.agent)||this.kind===ld.AGENT}get isActive(){var e;return((e=this.participantInfo)===null||e===void 0?void 0:e.state)===cc.ACTIVE}get kind(){return this._kind}get attributes(){return Object.freeze(Object.assign({},this._attributes))}constructor(e,n,r,i,s,a){let c=arguments.length>6&&arguments[6]!==void 0?arguments[6]:ld.STANDARD;var h;super(),this.audioLevel=0,this.isSpeaking=!1,this._connectionQuality=Xa.Unknown,this.log=Tt,this.log=ei((h=a==null?void 0:a.loggerName)!==null&&h!==void 0?h:Nr.Participant),this.loggerOptions=a,this.setMaxListeners(100),this.sid=e,this.identity=n,this.name=r,this.metadata=i,this.audioTrackPublications=new Map,this.videoTrackPublications=new Map,this.trackPublications=new Map,this._kind=c,this._attributes=s??{}}getTrackPublications(){return Array.from(this.trackPublications.values())}getTrackPublication(e){for(const[,n]of this.trackPublications)if(n.source===e)return n}getTrackPublicationByName(e){for(const[,n]of this.trackPublications)if(n.trackName===e)return n}waitUntilActive(){return this.isActive?Promise.resolve():this.activeFuture?this.activeFuture.promise:(this.activeFuture=new Jr,this.once(Be.Active,()=>{var e,n;(n=(e=this.activeFuture)===null||e===void 0?void 0:e.resolve)===null||n===void 0||n.call(e),this.activeFuture=void 0}),this.activeFuture.promise)}get connectionQuality(){return this._connectionQuality}get isCameraEnabled(){var e;const n=this.getTrackPublication(Te.Source.Camera);return!(!((e=n==null?void 0:n.isMuted)!==null&&e!==void 0)||e)}get isMicrophoneEnabled(){var e;const n=this.getTrackPublication(Te.Source.Microphone);return!(!((e=n==null?void 0:n.isMuted)!==null&&e!==void 0)||e)}get isScreenShareEnabled(){return!!this.getTrackPublication(Te.Source.ScreenShare)}get isLocal(){return!1}get joinedAt(){return this.participantInfo?new Date(Number.parseInt(this.participantInfo.joinedAt.toString())*1e3):new Date}updateInfo(e){var n;return this.participantInfo&&this.participantInfo.sid===e.sid&&this.participantInfo.version>e.version?!1:(this.identity=e.identity,this.sid=e.sid,this._setName(e.name),this._setMetadata(e.metadata),this._setAttributes(e.attributes),e.state===cc.ACTIVE&&((n=this.participantInfo)===null||n===void 0?void 0:n.state)!==cc.ACTIVE&&this.emit(Be.Active),e.permission&&this.setPermissions(e.permission),this.participantInfo=e,!0)}_setMetadata(e){const n=this.metadata!==e,r=this.metadata;this.metadata=e,n&&this.emit(Be.ParticipantMetadataChanged,r)}_setName(e){const n=this.name!==e;this.name=e,n&&this.emit(Be.ParticipantNameChanged,e)}_setAttributes(e){const n=yV(this.attributes,e);this._attributes=e,Object.keys(n).length>0&&this.emit(Be.AttributesChanged,n)}setPermissions(e){var n,r,i,s,a,c;const h=this.permissions,d=e.canPublish!==((n=this.permissions)===null||n===void 0?void 0:n.canPublish)||e.canSubscribe!==((r=this.permissions)===null||r===void 0?void 0:r.canSubscribe)||e.canPublishData!==((i=this.permissions)===null||i===void 0?void 0:i.canPublishData)||e.hidden!==((s=this.permissions)===null||s===void 0?void 0:s.hidden)||e.recorder!==((a=this.permissions)===null||a===void 0?void 0:a.recorder)||e.canPublishSources.length!==this.permissions.canPublishSources.length||e.canPublishSources.some((f,p)=>{var g;return f!==((g=this.permissions)===null||g===void 0?void 0:g.canPublishSources[p])})||e.canSubscribeMetrics!==((c=this.permissions)===null||c===void 0?void 0:c.canSubscribeMetrics);return this.permissions=e,d&&this.emit(Be.ParticipantPermissionsChanged,h),d}setIsSpeaking(e){e!==this.isSpeaking&&(this.isSpeaking=e,e&&(this.lastSpokeAt=new Date),this.emit(Be.IsSpeakingChanged,e))}setConnectionQuality(e){const n=this._connectionQuality;this._connectionQuality=fH(e),n!==this._connectionQuality&&this.emit(Be.ConnectionQualityChanged,this._connectionQuality)}setDisconnected(){var e,n;this.activeFuture&&((n=(e=this.activeFuture).reject)===null||n===void 0||n.call(e,new Error("Participant disconnected")),this.activeFuture=void 0)}setAudioContext(e){this.audioContext=e,this.audioTrackPublications.forEach(n=>Ts(n.track)&&n.track.setAudioContext(e))}addTrackPublication(e){e.on(Fe.Muted,()=>{this.emit(Be.TrackMuted,e)}),e.on(Fe.Unmuted,()=>{this.emit(Be.TrackUnmuted,e)});const n=e;switch(n.track&&(n.track.sid=e.trackSid),this.trackPublications.set(e.trackSid,e),e.kind){case Te.Kind.Audio:this.audioTrackPublications.set(e.trackSid,e);break;case Te.Kind.Video:this.videoTrackPublications.set(e.trackSid,e);break}}}function pH(t){var e,n,r;if(!t.participantSid&&!t.participantIdentity)throw new Error("Invalid track permission, must provide at least one of participantIdentity and participantSid");return new G2({participantIdentity:(e=t.participantIdentity)!==null&&e!==void 0?e:"",participantSid:(n=t.participantSid)!==null&&n!==void 0?n:"",allTracks:(r=t.allowAll)!==null&&r!==void 0?r:!1,trackSids:t.allowedTrackSids||[]})}class mH extends s_{constructor(e,n,r,i,s,a,c){super(e,n,void 0,void 0,void 0,{loggerName:i.loggerName,loggerContextCb:()=>this.engine.logContext}),this.pendingPublishing=new Set,this.pendingPublishPromises=new Map,this.participantTrackPermissions=[],this.allParticipantsAllowedToSubscribe=!0,this.encryptionType=bn.NONE,this.e2eeStateMutex=new fr,this.enabledPublishVideoCodecs=[],this.pendingAcks=new Map,this.pendingResponses=new Map,this.handleReconnecting=()=>{this.reconnectFuture||(this.reconnectFuture=new Jr)},this.handleReconnected=()=>{var h,d;(d=(h=this.reconnectFuture)===null||h===void 0?void 0:h.resolve)===null||d===void 0||d.call(h),this.reconnectFuture=void 0,this.updateTrackSubscriptionPermissions()},this.handleClosing=()=>{var h,d,f,p,g,v;this.reconnectFuture&&(this.reconnectFuture.promise.catch(k=>this.log.warn(k.message,this.logContext)),(d=(h=this.reconnectFuture)===null||h===void 0?void 0:h.reject)===null||d===void 0||d.call(h,new Error("Got disconnected during reconnection attempt")),this.reconnectFuture=void 0),this.signalConnectedFuture&&((p=(f=this.signalConnectedFuture).reject)===null||p===void 0||p.call(f,new Error("Got disconnected without signal connected")),this.signalConnectedFuture=void 0),(v=(g=this.activeAgentFuture)===null||g===void 0?void 0:g.reject)===null||v===void 0||v.call(g,new Error("Got disconnected without active agent present")),this.activeAgentFuture=void 0,this.firstActiveAgent=void 0},this.handleSignalConnected=h=>{var d,f;h.participant&&this.updateInfo(h.participant),this.signalConnectedFuture||(this.signalConnectedFuture=new Jr),(f=(d=this.signalConnectedFuture).resolve)===null||f===void 0||f.call(d)},this.handleSignalRequestResponse=h=>{const{requestId:d,reason:f,message:p}=h,g=this.pendingSignalRequests.get(d);switch(g&&(f!==Ho.OK&&g.reject(new dC(p,f)),this.pendingSignalRequests.delete(d)),h.request.case){case"publishDataTrack":{let v;switch(h.reason){case Ho.NOT_ALLOWED:v=rr.notAllowed(h.message);break;case Ho.DUPLICATE_NAME:v=rr.duplicateName(h.message);break;case Ho.INVALID_NAME:v=rr.invalidName(h.message);break;case Ho.LIMIT_EXCEEDED:v=rr.limitReached(h.message);break;default:v=rr.unknown(h.reason,h.message);return}this.roomOutgoingDataTrackManager.receivedSfuPublishResponse(h.request.value.pubHandle,{type:"error",error:v});break}}},this.handleDataPacket=h=>{switch(h.value.case){case"rpcResponse":let d=h.value.value,f=null,p=null;d.value.case==="payload"?f=d.value.value:d.value.case==="error"&&(p=zn.fromProto(d.value.value)),this.handleIncomingRpcResponse(d.requestId,f,p);break;case"rpcAck":let g=h.value.value;this.handleIncomingRpcAck(g.requestId);break}},this.updateTrackSubscriptionPermissions=()=>{this.log.debug("updating track subscription permissions",Object.assign(Object.assign({},this.logContext),{allParticipantsAllowed:this.allParticipantsAllowedToSubscribe,participantTrackPermissions:this.participantTrackPermissions})),this.engine.client.sendUpdateSubscriptionPermissions(this.allParticipantsAllowedToSubscribe,this.participantTrackPermissions.map(h=>pH(h)))},this.onTrackUnmuted=h=>{this.onTrackMuted(h,h.isUpstreamPaused)},this.onTrackMuted=(h,d)=>{if(d===void 0&&(d=!0),!h.sid){this.log.error("could not update mute status for unpublished track",Object.assign(Object.assign({},this.logContext),Lt(h)));return}this.engine.updateMuteStatus(h.sid,d)},this.onTrackUpstreamPaused=h=>{this.log.debug("upstream paused",Object.assign(Object.assign({},this.logContext),Lt(h))),this.onTrackMuted(h,!0)},this.onTrackUpstreamResumed=h=>{this.log.debug("upstream resumed",Object.assign(Object.assign({},this.logContext),Lt(h))),this.onTrackMuted(h,h.isMuted)},this.onTrackFeatureUpdate=h=>{const d=this.audioTrackPublications.get(h.sid);if(!d){this.log.warn("Could not update local audio track settings, missing publication for track ".concat(h.sid),this.logContext);return}this.engine.client.sendUpdateLocalAudioTrack(d.trackSid,d.getTrackFeatures())},this.onTrackCpuConstrained=(h,d)=>{this.log.debug("track cpu constrained",Object.assign(Object.assign({},this.logContext),Lt(d))),this.emit(Be.LocalTrackCpuConstrained,h,d)},this.handleSubscribedQualityUpdate=h=>H(this,void 0,void 0,function*(){var d,f,p,g,v;if(!(!((v=this.roomOptions)===null||v===void 0)&&v.dynacast))return;const k=this.videoTrackPublications.get(h.trackSid);if(!k){this.log.warn("received subscribed quality update for unknown track",Object.assign(Object.assign({},this.logContext),{trackSid:h.trackSid}));return}if(!k.videoTrack)return;const w=yield k.videoTrack.setPublishingCodecs(h.subscribedCodecs);try{for(var S=!0,T=Yi(w),C;C=yield T.next(),d=C.done,!d;S=!0){g=C.value,S=!1;const j=g;fV(j)&&(this.log.debug("publish ".concat(j," for ").concat(k.videoTrack.sid),Object.assign(Object.assign({},this.logContext),Lt(k))),yield this.publishAdditionalCodecForTrack(k.videoTrack,j,k.options))}}catch(j){f={error:j}}finally{try{!S&&!d&&(p=T.return)&&(yield p.call(T))}finally{if(f)throw f.error}}}),this.handleLocalTrackUnpublished=h=>{const d=this.trackPublications.get(h.trackSid);if(!d){this.log.warn("received unpublished event for unknown track",Object.assign(Object.assign({},this.logContext),{trackSid:h.trackSid}));return}this.unpublishTrack(d.track)},this.handleTrackEnded=h=>H(this,void 0,void 0,function*(){if(h.source===Te.Source.ScreenShare||h.source===Te.Source.ScreenShareAudio)this.log.debug("unpublishing local track due to TrackEnded",Object.assign(Object.assign({},this.logContext),Lt(h))),this.unpublishTrack(h);else if(h.isUserProvided)yield h.mute();else if(aa(h)||Wa(h))try{if(Yr())try{const d=yield navigator==null?void 0:navigator.permissions.query({name:h.source===Te.Source.Camera?"camera":"microphone"});if(d&&d.state==="denied")throw this.log.warn("user has revoked access to ".concat(h.source),Object.assign(Object.assign({},this.logContext),Lt(h))),d.onchange=()=>{d.state!=="denied"&&(h.isMuted||h.restartTrack(),d.onchange=null)},new Error("GetUserMedia Permission denied")}catch{}h.isMuted||(this.log.debug("track ended, attempting to use a different device",Object.assign(Object.assign({},this.logContext),Lt(h))),aa(h)?yield h.restartTrack({deviceId:"default"}):yield h.restartTrack())}catch{this.log.warn("could not restart track, muting instead",Object.assign(Object.assign({},this.logContext),Lt(h))),yield h.mute()}}),this.audioTrackPublications=new Map,this.videoTrackPublications=new Map,this.trackPublications=new Map,this.engine=r,this.roomOptions=i,this.setupEngine(r),this.activeDeviceMap=new Map([["audioinput","default"],["videoinput","default"],["audiooutput","default"]]),this.pendingSignalRequests=new Map,this.rpcHandlers=s,this.roomOutgoingDataStreamManager=a,this.roomOutgoingDataTrackManager=c}get lastCameraError(){return this.cameraError}get lastMicrophoneError(){return this.microphoneError}get isE2EEEnabled(){return this.encryptionType!==bn.NONE}getTrackPublication(e){const n=super.getTrackPublication(e);if(n)return n}getTrackPublicationByName(e){const n=super.getTrackPublicationByName(e);if(n)return n}setupEngine(e){var n;this.engine=e,this.engine.on(De.RemoteMute,(r,i)=>{const s=this.trackPublications.get(r);!s||!s.track||(i?s.mute():s.unmute())}),!((n=this.signalConnectedFuture)===null||n===void 0)&&n.isResolved&&(this.signalConnectedFuture=void 0),this.engine.on(De.Connected,this.handleReconnected).on(De.SignalConnected,this.handleSignalConnected).on(De.SignalRestarted,this.handleReconnected).on(De.SignalResumed,this.handleReconnected).on(De.Restarting,this.handleReconnecting).on(De.Resuming,this.handleReconnecting).on(De.LocalTrackUnpublished,this.handleLocalTrackUnpublished).on(De.SubscribedQualityUpdate,this.handleSubscribedQualityUpdate).on(De.Closing,this.handleClosing).on(De.SignalRequestResponse,this.handleSignalRequestResponse).on(De.DataPacketReceived,this.handleDataPacket)}setMetadata(e){return H(this,void 0,void 0,function*(){yield this.requestMetadataUpdate({metadata:e})})}setName(e){return H(this,void 0,void 0,function*(){yield this.requestMetadataUpdate({name:e})})}setAttributes(e){return H(this,void 0,void 0,function*(){yield this.requestMetadataUpdate({attributes:e})})}requestMetadataUpdate(e){return H(this,arguments,void 0,function(n){var r=this;let{metadata:i,name:s,attributes:a}=n;return(function*(){return new Sr((c,h)=>H(r,void 0,void 0,function*(){var d,f;try{let p=!1;const g=yield this.engine.client.sendUpdateLocalMetadata((d=i??this.metadata)!==null&&d!==void 0?d:"",(f=s??this.name)!==null&&f!==void 0?f:"",a),v=performance.now();for(this.pendingSignalRequests.set(g,{resolve:c,reject:k=>{h(k),p=!0},values:{name:s,metadata:i,attributes:a}});performance.now()-v<5e3&&!p;){if((!s||this.name===s)&&(!i||this.metadata===i)&&(!a||Object.entries(a).every(k=>{let[w,S]=k;return this.attributes[w]===S||S===""&&!this.attributes[w]}))){this.pendingSignalRequests.delete(g),c();return}yield Cr(50)}h(new dC("Request to update local metadata timed out","TimeoutError"))}catch(p){p instanceof Error?h(p):h(new Error(String(p)))}}))})()})}setCameraEnabled(e,n,r){return this.setTrackEnabled(Te.Source.Camera,e,n,r)}setMicrophoneEnabled(e,n,r){return this.setTrackEnabled(Te.Source.Microphone,e,n,r)}setScreenShareEnabled(e,n,r){return this.setTrackEnabled(Te.Source.ScreenShare,e,n,r)}setE2EEEnabled(e){return H(this,void 0,void 0,function*(){const n=yield this.e2eeStateMutex.lock();try{if(this.encryptionType=e?bn.GCM:bn.NONE,yield Promise.all(this.pendingPublishPromises.values()),this.trackPublications.size===0||Array.from(this.trackPublications.values()).every(r=>r.isEncrypted===e))return;yield this.republishAllTracks(void 0,!1)}finally{n()}})}setTrackEnabled(e,n,r,i){return H(this,void 0,void 0,function*(){var s,a;this.log.debug("setTrackEnabled",Object.assign(Object.assign({},this.logContext),{source:e,enabled:n})),this.republishPromise&&(yield this.republishPromise);let c=this.getTrackPublication(e);if(n)if(c)yield c.unmute();else{let h;if(this.pendingPublishing.has(e)){const d=yield this.waitForPendingPublicationOfSource(e);return d||this.log.info("waiting for pending publication promise timed out",Object.assign(Object.assign({},this.logContext),{source:e})),yield d==null?void 0:d.unmute(),d}this.pendingPublishing.add(e);try{switch(e){case Te.Source.Camera:h=yield this.createTracks({video:(s=r)!==null&&s!==void 0?s:!0});break;case Te.Source.Microphone:h=yield this.createTracks({audio:(a=r)!==null&&a!==void 0?a:!0});break;case Te.Source.ScreenShare:h=yield this.createScreenTracks(Object.assign({},r));break;default:throw new da(e)}}catch(d){throw h==null||h.forEach(f=>{f.stop()}),d instanceof Error&&this.emit(Be.MediaDevicesError,d,Lv(e)),this.pendingPublishing.delete(e),d}for(const d of h){const f=Object.assign(Object.assign({},this.roomOptions.publishDefaults),r);e===Te.Source.Microphone&&Ts(d)&&f.preConnectBuffer&&(this.log.info("starting preconnect buffer for microphone",Object.assign({},this.logContext)),d.startPreConnectBuffer())}try{const d=[];for(const p of h)this.log.info("publishing track",Object.assign(Object.assign({},this.logContext),Lt(p))),d.push(this.publishTrack(p,i));[c]=yield Promise.all(d)}catch(d){throw h==null||h.forEach(f=>{f.stop()}),d}finally{this.pendingPublishing.delete(e)}}else if(!(c!=null&&c.track)&&this.pendingPublishing.has(e)&&(c=yield this.waitForPendingPublicationOfSource(e),c||this.log.info("waiting for pending publication promise timed out",Object.assign(Object.assign({},this.logContext),{source:e}))),c&&c.track)if(e===Te.Source.ScreenShare){c=yield this.unpublishTrack(c.track);const h=this.getTrackPublication(Te.Source.ScreenShareAudio);h&&h.track&&this.unpublishTrack(h.track)}else yield c.mute();return c})}enableCameraAndMicrophone(){return H(this,void 0,void 0,function*(){if(!(this.pendingPublishing.has(Te.Source.Camera)||this.pendingPublishing.has(Te.Source.Microphone))){this.pendingPublishing.add(Te.Source.Camera),this.pendingPublishing.add(Te.Source.Microphone);try{const e=yield this.createTracks({audio:!0,video:!0});yield Promise.all(e.map(n=>this.publishTrack(n)))}finally{this.pendingPublishing.delete(Te.Source.Camera),this.pendingPublishing.delete(Te.Source.Microphone)}}})}createTracks(e){return H(this,void 0,void 0,function*(){var n,r;e??(e={});const i=MP(e,(n=this.roomOptions)===null||n===void 0?void 0:n.audioCaptureDefaults,(r=this.roomOptions)===null||r===void 0?void 0:r.videoCaptureDefaults);try{return(yield Up(i,{loggerName:this.roomOptions.loggerName,loggerContextCb:()=>this.logContext})).map(c=>(Ts(c)&&(this.microphoneError=void 0,c.setAudioContext(this.audioContext),c.source=Te.Source.Microphone,this.emit(Be.AudioStreamAcquired)),go(c)&&(this.cameraError=void 0,c.source=Te.Source.Camera),c))}catch(s){throw s instanceof Error&&(e.audio&&(this.microphoneError=s),e.video&&(this.cameraError=s)),s}})}createScreenTracks(e){return H(this,void 0,void 0,function*(){if(e===void 0&&(e={}),navigator.mediaDevices.getDisplayMedia===void 0)throw new kx("getDisplayMedia not supported");e.resolution===void 0&&!EV()&&(e.resolution=wx.h1080fps30.resolution);const n=mV(e),r=yield navigator.mediaDevices.getDisplayMedia(n),i=r.getVideoTracks();if(i.length===0)throw new da("no video track found");const s=new Xf(i[0],void 0,!1,{loggerName:this.roomOptions.loggerName,loggerContextCb:()=>this.logContext});s.source=Te.Source.ScreenShare,e.contentHint&&(s.mediaStreamTrack.contentHint=e.contentHint);const a=[s];if(r.getAudioTracks().length>0){this.emit(Be.AudioStreamAcquired);const c=new Jf(r.getAudioTracks()[0],void 0,!1,this.audioContext,{loggerName:this.roomOptions.loggerName,loggerContextCb:()=>this.logContext});c.source=Te.Source.ScreenShareAudio,a.push(c)}return a})}publishTrack(e,n){return H(this,void 0,void 0,function*(){return this.publishOrRepublishTrack(e,n)})}publishOrRepublishTrack(e,n){return H(this,arguments,void 0,function(r,i){var s=this;let a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;return(function*(){var c,h,d,f;aa(r)&&r.setAudioContext(s.audioContext),yield(c=s.reconnectFuture)===null||c===void 0?void 0:c.promise,s.republishPromise&&!a&&(yield s.republishPromise),fc(r)&&s.pendingPublishPromises.has(r)&&(yield s.pendingPublishPromises.get(r));let p;if(r instanceof MediaStreamTrack)p=r.getConstraints();else{p=r.constraints;let T;switch(r.source){case Te.Source.Microphone:T="audioinput";break;case Te.Source.Camera:T="videoinput"}T&&s.activeDeviceMap.has(T)&&(p=Object.assign(Object.assign({},p),{deviceId:s.activeDeviceMap.get(T)}))}if(r instanceof MediaStreamTrack)switch(r.kind){case"audio":r=new Jf(r,p,!0,s.audioContext,{loggerName:s.roomOptions.loggerName,loggerContextCb:()=>s.logContext});break;case"video":r=new Xf(r,p,!0,{loggerName:s.roomOptions.loggerName,loggerContextCb:()=>s.logContext});break;default:throw new da("unsupported MediaStreamTrack kind ".concat(r.kind))}else r.updateLoggerOptions({loggerName:s.roomOptions.loggerName,loggerContextCb:()=>s.logContext});let g;if(s.trackPublications.forEach(T=>{T.track&&T.track===r&&(g=T)}),g)return s.log.warn("track has already been published, skipping",Object.assign(Object.assign({},s.logContext),Lt(g))),g;const v=Object.assign(Object.assign({},s.roomOptions.publishDefaults),i),k="channelCount"in r.mediaStreamTrack.getSettings()&&r.mediaStreamTrack.getSettings().channelCount===2||r.mediaStreamTrack.getConstraints().channelCount===2,w=(h=v.forceStereo)!==null&&h!==void 0?h:k;w&&(v.dtx===void 0&&s.log.info("Opus DTX will be disabled for stereo tracks by default. Enable them explicitly to make it work.",Object.assign(Object.assign({},s.logContext),Lt(r))),v.red===void 0&&s.log.info("Opus RED will be disabled for stereo tracks by default. Enable them explicitly to make it work."),(d=v.dtx)!==null&&d!==void 0||(v.dtx=!1),(f=v.red)!==null&&f!==void 0||(v.red=!1)),!PV()&&s.roomOptions.e2ee&&(s.log.info("End-to-end encryption is set up, simulcast publishing will be disabled on Safari versions and iOS browsers running iOS < v17.2",Object.assign({},s.logContext)),v.simulcast=!1),v.source&&(r.source=v.source);const S=new Promise((T,C)=>H(s,void 0,void 0,function*(){try{if(this.engine.client.currentState!==yn.CONNECTED){this.log.debug("deferring track publication until signal is connected",Object.assign(Object.assign({},this.logContext),{track:Lt(r)}));let j=!1;const R=setTimeout(()=>{j=!0,r.stop(),C(new uC("publishing rejected as engine not connected within timeout",408))},15e3);if(yield this.waitUntilEngineConnected(),clearTimeout(R),j)return;const _=yield this.publish(r,v,w);T(_)}else try{const j=yield this.publish(r,v,w);T(j)}catch(j){C(j)}}catch(j){C(j)}}));s.pendingPublishPromises.set(r,S);try{return yield S}catch(T){throw T}finally{s.pendingPublishPromises.delete(r)}})()})}waitUntilEngineConnected(){return this.signalConnectedFuture||(this.signalConnectedFuture=new Jr),this.signalConnectedFuture.promise}hasPermissionsToPublish(e){if(!this.permissions)return this.log.warn("no permissions present for publishing track",Object.assign(Object.assign({},this.logContext),Lt(e))),!1;const{canPublish:n,canPublishSources:r}=this.permissions;return n&&(r.length===0||r.map(i=>xV(i)).includes(e.source))?!0:(this.log.warn("insufficient permissions to publish",Object.assign(Object.assign({},this.logContext),Lt(e))),!1)}publish(e,n,r){return H(this,void 0,void 0,function*(){var i,s,a,c,h,d,f,p,g,v;if(!this.hasPermissionsToPublish(e))throw new uC("failed to publish track, insufficient permissions",403);Array.from(this.trackPublications.values()).find($=>fc(e)&&$.source===e.source)&&e.source!==Te.Source.Unknown&&this.log.info("publishing a second track with the same source: ".concat(e.source),Object.assign(Object.assign({},this.logContext),Lt(e))),n.stopMicTrackOnMute&&Ts(e)&&(e.stopOnMute=!0),e.source===Te.Source.ScreenShare&&dl()&&(n.simulcast=!1),n.videoCodec==="av1"&&!CV()&&(n.videoCodec=void 0),n.videoCodec==="vp9"&&!TV()&&(n.videoCodec=void 0),n.videoCodec===void 0&&(n.videoCodec=Wv),this.enabledPublishVideoCodecs.length>0&&(this.enabledPublishVideoCodecs.some($=>n.videoCodec===Ku($.mime))||(n.videoCodec=Ku(this.enabledPublishVideoCodecs[0].mime)));const w=n.videoCodec;e.on(Fe.Muted,this.onTrackMuted),e.on(Fe.Unmuted,this.onTrackUnmuted),e.on(Fe.Ended,this.handleTrackEnded),e.on(Fe.UpstreamPaused,this.onTrackUpstreamPaused),e.on(Fe.UpstreamResumed,this.onTrackUpstreamResumed),e.on(Fe.AudioTrackFeatureUpdate,this.onTrackFeatureUpdate);const S=[],T=!(!((i=n.dtx)!==null&&i!==void 0)||i),C=e.getSourceTrackSettings();C.autoGainControl&&S.push(lr.TF_AUTO_GAIN_CONTROL),C.echoCancellation&&S.push(lr.TF_ECHO_CANCELLATION),C.noiseSuppression&&S.push(lr.TF_NOISE_SUPPRESSION),C.channelCount&&C.channelCount>1&&S.push(lr.TF_STEREO),T&&S.push(lr.TF_NO_DTX),aa(e)&&e.hasPreConnectBuffer&&S.push(lr.TF_PRECONNECT_BUFFER);const j=new cd({cid:e.mediaStreamTrack.id,name:n.name,type:Te.kindToProto(e.kind),muted:e.isMuted,source:Te.sourceToProto(e.source),disableDtx:T,encryption:this.encryptionType,stereo:r,disableRed:this.isE2EEEnabled||!(!((s=n.red)!==null&&s!==void 0)||s),stream:n==null?void 0:n.stream,backupCodecPolicy:n==null?void 0:n.backupCodecPolicy,audioFeatures:S});let R;if(e.kind===Te.Kind.Video){let $={width:0,height:0};try{$=yield e.waitForDimensions()}catch{const P=(c=(a=this.roomOptions.videoCaptureDefaults)===null||a===void 0?void 0:a.resolution)!==null&&c!==void 0?c:ud.h720.resolution;$={width:P.width,height:P.height},this.log.error("could not determine track dimensions, using defaults",Object.assign(Object.assign(Object.assign({},this.logContext),Lt(e)),{dims:$}))}j.width=$.width,j.height=$.height,Wa(e)&&(Ji(w)&&(e.source===Te.Source.ScreenShare&&(n.scalabilityMode="L1T3","contentHint"in e.mediaStreamTrack&&(e.mediaStreamTrack.contentHint="motion",this.log.info("forcing contentHint to motion for screenshare with SVC codecs",Object.assign(Object.assign({},this.logContext),Lt(e))))),n.scalabilityMode=(h=n.scalabilityMode)!==null&&h!==void 0?h:"L3T3_KEY"),j.simulcastCodecs=[new Cv({codec:w,cid:e.mediaStreamTrack.id})],n.backupCodec===!0&&(n.backupCodec={codec:Wv}),n.backupCodec&&w!==n.backupCodec.codec&&j.encryption===bn.NONE&&(this.roomOptions.dynacast||(this.roomOptions.dynacast=!0),j.simulcastCodecs.push(new Cv({codec:n.backupCodec.codec,cid:""})))),R=qv(e.source===Te.Source.ScreenShare,j.width,j.height,n),j.layers=FC(j.width,j.height,R,Ji(n.videoCodec))}else e.kind===Te.Kind.Audio&&(R=[{maxBitrate:(d=n.audioPreset)===null||d===void 0?void 0:d.maxBitrate,priority:(p=(f=n.audioPreset)===null||f===void 0?void 0:f.priority)!==null&&p!==void 0?p:"high",networkPriority:(v=(g=n.audioPreset)===null||g===void 0?void 0:g.priority)!==null&&v!==void 0?v:"high"}]);if(!this.engine||this.engine.isClosed)throw new On("cannot publish track when not connected");const _=()=>H(this,void 0,void 0,function*(){var $,E,P;if(!this.engine.pcManager)throw new On("pcManager is not ready");if(e.sender=yield this.engine.createSender(e,n,R),this.emit(Be.LocalSenderCreated,e.sender,e),Wa(e)&&(($=n.degradationPreference)!==null&&$!==void 0||(n.degradationPreference=OW(e)),e.setDegradationPreference(n.degradationPreference)),R)if(dl()&&e.kind===Te.Kind.Audio){let V;for(const F of this.engine.pcManager.publisher.getTransceivers())if(F.sender===e.sender){V=F;break}V&&this.engine.pcManager.publisher.setTrackCodecBitrate({transceiver:V,codec:"opus",maxbr:!((E=R[0])===null||E===void 0)&&E.maxBitrate?R[0].maxBitrate/1e3:0})}else e.codec&&Ji(e.codec)&&(!((P=R[0])===null||P===void 0)&&P.maxBitrate)&&this.engine.pcManager.publisher.setTrackCodecBitrate({cid:j.cid,codec:e.codec,maxbr:R[0].maxBitrate/1e3});yield this.engine.negotiate()});let I;const M=new Promise(($,E)=>H(this,void 0,void 0,function*(){var P;try{I=yield this.engine.addTrack(j),$(I)}catch(V){e.sender&&(!((P=this.engine.pcManager)===null||P===void 0)&&P.publisher)&&(this.engine.pcManager.publisher.removeTrack(e.sender),yield this.engine.negotiate().catch(F=>{this.log.error("failed to negotiate after removing track due to failed add track request",Object.assign(Object.assign(Object.assign({},this.logContext),Lt(e)),{error:F}))})),E(V)}}));if(this.enabledPublishVideoCodecs.length>0)I=(yield Promise.all([M,_()]))[0];else{I=yield M;let $;if(I.codecs.forEach(E=>{$===void 0&&($=E.mimeType)}),$&&e.kind===Te.Kind.Video){const E=Ku($);E!==w&&(this.log.debug("falling back to server selected codec",Object.assign(Object.assign(Object.assign({},this.logContext),Lt(e)),{codec:E})),n.videoCodec=E,R=qv(e.source===Te.Source.ScreenShare,j.width,j.height,n))}yield _()}const L=new Gv(e.kind,I,e,{loggerName:this.roomOptions.loggerName,loggerContextCb:()=>this.logContext});if(L.on(Fe.CpuConstrained,$=>this.onTrackCpuConstrained($,L)),L.options=n,e.sid=I.sid,this.log.debug("publishing ".concat(e.kind," with encodings"),Object.assign(Object.assign({},this.logContext),{encodings:R,trackInfo:I})),Wa(e)?e.startMonitor(this.engine.client):aa(e)&&e.startMonitor(),this.addTrackPublication(L),this.emit(Be.LocalTrackPublished,L),aa(e)&&I.audioFeatures.includes(lr.TF_PRECONNECT_BUFFER)){const $=e.getPreConnectBuffer(),E=e.getPreConnectBufferMimeType();this.on(Be.LocalTrackSubscribed,P=>{if(P.trackSid===I.sid){if(!e.hasPreConnectBuffer){this.log.warn("subscribe event came to late, buffer already closed",this.logContext);return}this.log.debug("finished recording preconnect buffer",Object.assign(Object.assign({},this.logContext),Lt(e))),e.stopPreConnectBuffer()}}),$&&new Promise((V,F)=>H(this,void 0,void 0,function*(){var K,J,Q,Z,D,ne;try{this.log.debug("waiting for agent",Object.assign(Object.assign({},this.logContext),Lt(e)));const B=setTimeout(()=>{F(new Error("agent not active within 10 seconds"))},1e4),X=yield this.waitUntilActiveAgentPresent();clearTimeout(B),this.log.debug("sending preconnect buffer",Object.assign(Object.assign({},this.logContext),Lt(e)));const ye=yield this.streamBytes({name:"preconnect-buffer",mimeType:E,topic:"lk.agent.pre-connect-audio-buffer",destinationIdentities:[X.identity],attributes:{trackId:L.trackSid,sampleRate:String((D=C.sampleRate)!==null&&D!==void 0?D:"48000"),channels:String((ne=C.channelCount)!==null&&ne!==void 0?ne:"1")}});try{for(var A=!0,z=Yi($),ee;ee=yield z.next(),K=ee.done,!K;A=!0){Z=ee.value,A=!1;const se=Z;yield ye.write(se)}}catch(se){J={error:se}}finally{try{!A&&!K&&(Q=z.return)&&(yield Q.call(z))}finally{if(J)throw J.error}}yield ye.close(),V()}catch(B){F(B)}})).then(()=>{this.log.debug("preconnect buffer sent successfully",Object.assign(Object.assign({},this.logContext),Lt(e)))}).catch(V=>{this.log.error("error sending preconnect buffer",Object.assign(Object.assign(Object.assign({},this.logContext),Lt(e)),{error:V}))})}return L})}get isLocal(){return!0}publishAdditionalCodecForTrack(e,n,r){return H(this,void 0,void 0,function*(){var i;if(this.encryptionType!==bn.NONE)return;let s;if(this.trackPublications.forEach(v=>{v.track&&v.track===e&&(s=v)}),!s)throw new da("track is not published");if(!Wa(e))throw new da("track is not a video track");const a=Object.assign(Object.assign({},(i=this.roomOptions)===null||i===void 0?void 0:i.publishDefaults),r),c=MW(e,n,a);if(!c){this.log.info("backup codec has been disabled, ignoring request to add additional codec for track",Object.assign(Object.assign({},this.logContext),Lt(e)));return}const h=e.addSimulcastTrack(n,c);if(!h)return;const d=new cd({cid:h.mediaStreamTrack.id,type:Te.kindToProto(e.kind),muted:e.isMuted,source:Te.sourceToProto(e.source),sid:e.sid,simulcastCodecs:[{codec:a.videoCodec,cid:h.mediaStreamTrack.id}]});if(d.layers=FC(d.width,d.height,c),!this.engine||this.engine.isClosed)throw new On("cannot publish track when not connected");const f=()=>H(this,void 0,void 0,function*(){yield this.engine.createSimulcastSender(e,h,a,c),yield this.engine.negotiate()}),g=(yield Promise.all([this.engine.addTrack(d),f()]))[0];this.log.debug("published ".concat(n," for track ").concat(e.sid),Object.assign(Object.assign({},this.logContext),{encodings:c,trackInfo:g}))})}unpublishTrack(e,n){return H(this,void 0,void 0,function*(){var r,i;if(fc(e)){const d=this.pendingPublishPromises.get(e);d&&(this.log.info("awaiting publish promise before attempting to unpublish",Object.assign(Object.assign({},this.logContext),Lt(e))),yield d)}const s=this.getPublicationForTrack(e),a=s?Lt(s):void 0;if(this.log.debug("unpublishing track",Object.assign(Object.assign({},this.logContext),a)),!s||!s.track){this.log.warn("track was not unpublished because no publication was found",Object.assign(Object.assign({},this.logContext),a));return}e=s.track,e.off(Fe.Muted,this.onTrackMuted),e.off(Fe.Unmuted,this.onTrackUnmuted),e.off(Fe.Ended,this.handleTrackEnded),e.off(Fe.UpstreamPaused,this.onTrackUpstreamPaused),e.off(Fe.UpstreamResumed,this.onTrackUpstreamResumed),e.off(Fe.AudioTrackFeatureUpdate,this.onTrackFeatureUpdate),n===void 0&&(n=(i=(r=this.roomOptions)===null||r===void 0?void 0:r.stopLocalTrackOnUnpublish)!==null&&i!==void 0?i:!0),n?e.stop():e.stopMonitor();let c=!1;const h=e.sender;if(e.sender=void 0,this.engine.pcManager&&this.engine.pcManager.currentState<Ln.FAILED&&h)try{for(const d of this.engine.pcManager.publisher.getTransceivers())d.sender===h&&(d.direction="inactive",c=!0);if(this.engine.removeTrack(h)&&(c=!0),Wa(e)){for(const[,d]of e.simulcastCodecs)d.sender&&(this.engine.removeTrack(d.sender)&&(c=!0),d.sender=void 0);e.simulcastCodecs.clear()}}catch(d){this.log.warn("failed to unpublish track",Object.assign(Object.assign(Object.assign({},this.logContext),a),{error:d}))}switch(this.trackPublications.delete(s.trackSid),s.kind){case Te.Kind.Audio:this.audioTrackPublications.delete(s.trackSid);break;case Te.Kind.Video:this.videoTrackPublications.delete(s.trackSid);break}return this.emit(Be.LocalTrackUnpublished,s),s.setTrack(void 0),c&&(yield this.engine.negotiate()),s})}unpublishTracks(e){return H(this,void 0,void 0,function*(){return(yield Promise.all(e.map(r=>this.unpublishTrack(r)))).filter(r=>!!r)})}republishAllTracks(e){return H(this,arguments,void 0,function(n){var r=this;let i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0;return(function*(){r.republishPromise&&(yield r.republishPromise),r.republishPromise=new Sr((s,a)=>H(r,void 0,void 0,function*(){try{const c=[];this.trackPublications.forEach(h=>{h.track&&(n&&(h.options=Object.assign(Object.assign({},h.options),n)),c.push(h))}),yield Promise.all(c.map(h=>H(this,void 0,void 0,function*(){const d=h.track;yield this.unpublishTrack(d,!1),i&&!d.isMuted&&d.source!==Te.Source.ScreenShare&&d.source!==Te.Source.ScreenShareAudio&&(aa(d)||Wa(d))&&!d.isUserProvided&&(this.log.debug("restarting existing track",Object.assign(Object.assign({},this.logContext),{track:h.trackSid})),yield d.restartTrack()),yield this.publishOrRepublishTrack(d,h.options,!0)}))),s()}catch(c){c instanceof Error?a(c):a(new Error(String(c)))}finally{this.republishPromise=void 0}})),yield r.republishPromise})()})}publishData(e){return H(this,arguments,void 0,function(n){var r=this;let i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return(function*(){const s=i.reliable?It.RELIABLE:It.LOSSY,a=i.reliable?Zo.RELIABLE:Zo.LOSSY,c=i.destinationIdentities,h=i.topic;let d=new ox({participantIdentity:r.identity,payload:n,destinationIdentities:c,topic:h});const f=new Mr({kind:a,value:{case:"user",value:d}});yield r.engine.sendDataPacket(f,s)})()})}publishDtmf(e,n){return H(this,void 0,void 0,function*(){const r=new Mr({kind:Zo.RELIABLE,value:{case:"sipDtmf",value:new R2({code:e,digit:n})}});yield this.engine.sendDataPacket(r,It.RELIABLE)})}sendChatMessage(e,n){return H(this,void 0,void 0,function*(){const r={id:crypto.randomUUID(),message:e,timestamp:Date.now(),attachedFiles:n==null?void 0:n.attachments},i=new Mr({value:{case:"chatMessage",value:new Wf(Object.assign(Object.assign({},r),{timestamp:In.parse(r.timestamp)}))}});return yield this.engine.sendDataPacket(i,It.RELIABLE),this.emit(Be.ChatMessage,r),r})}editChatMessage(e,n){return H(this,void 0,void 0,function*(){const r=Object.assign(Object.assign({},n),{message:e,editTimestamp:Date.now()}),i=new Mr({value:{case:"chatMessage",value:new Wf(Object.assign(Object.assign({},r),{timestamp:In.parse(r.timestamp),editTimestamp:In.parse(r.editTimestamp)}))}});return yield this.engine.sendDataPacket(i,It.RELIABLE),this.emit(Be.ChatMessage,r),r})}sendText(e,n){return H(this,void 0,void 0,function*(){return this.roomOutgoingDataStreamManager.sendText(e,n)})}streamText(e){return H(this,void 0,void 0,function*(){return this.roomOutgoingDataStreamManager.streamText(e)})}sendFile(e,n){return H(this,void 0,void 0,function*(){return this.roomOutgoingDataStreamManager.sendFile(e,n)})}streamBytes(e){return H(this,void 0,void 0,function*(){return this.roomOutgoingDataStreamManager.streamBytes(e)})}performRpc(e){let{destinationIdentity:n,method:r,payload:i,responseTimeout:s=15e3}=e;const a=7e3,c=a+1e3;return new Sr((h,d)=>H(this,void 0,void 0,function*(){var f,p,g,v;if(Ix(i)>HP){d(zn.builtIn("REQUEST_PAYLOAD_TOO_LARGE"));return}if(!((p=(f=this.engine.latestJoinResponse)===null||f===void 0?void 0:f.serverInfo)===null||p===void 0)&&p.version&&Ls((v=(g=this.engine.latestJoinResponse)===null||g===void 0?void 0:g.serverInfo)===null||v===void 0?void 0:v.version,"1.8.0")<0){d(zn.builtIn("UNSUPPORTED_SERVER"));return}const k=Math.max(s,c),w=crypto.randomUUID();yield this.publishRpcRequest(n,w,r,i,k);const S=setTimeout(()=>{this.pendingAcks.delete(w),d(zn.builtIn("CONNECTION_TIMEOUT")),this.pendingResponses.delete(w),clearTimeout(T)},a);this.pendingAcks.set(w,{resolve:()=>{clearTimeout(S)},participantIdentity:n});const T=setTimeout(()=>{this.pendingResponses.delete(w),d(zn.builtIn("RESPONSE_TIMEOUT"))},s);this.pendingResponses.set(w,{resolve:(C,j)=>{clearTimeout(T),this.pendingAcks.has(w)&&(this.log.warn("RPC response received before ack",w),this.pendingAcks.delete(w),clearTimeout(S)),j?d(j):h(C??"")},participantIdentity:n})}))}registerRpcMethod(e,n){this.rpcHandlers.has(e)&&this.log.warn("you're overriding the RPC handler for method ".concat(e,", in the future this will throw an error")),this.rpcHandlers.set(e,n)}unregisterRpcMethod(e){this.rpcHandlers.delete(e)}setTrackSubscriptionPermissions(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[];this.participantTrackPermissions=n,this.allParticipantsAllowedToSubscribe=e,this.engine.client.isDisconnected||this.updateTrackSubscriptionPermissions()}handleIncomingRpcAck(e){const n=this.pendingAcks.get(e);n?(n.resolve(),this.pendingAcks.delete(e)):console.error("Ack received for unexpected RPC request",e)}handleIncomingRpcResponse(e,n,r){const i=this.pendingResponses.get(e);i?(i.resolve(n,r),this.pendingResponses.delete(e)):console.error("Response received for unexpected RPC request",e)}publishRpcRequest(e,n,r,i,s){return H(this,void 0,void 0,function*(){const a=new Mr({destinationIdentities:[e],kind:Zo.RELIABLE,value:{case:"rpcRequest",value:new lx({id:n,method:r,payload:i,responseTimeoutMs:s,version:1})}});yield this.engine.sendDataPacket(a,It.RELIABLE)})}handleParticipantDisconnected(e){for(const[n,{participantIdentity:r}]of this.pendingAcks)r===e&&this.pendingAcks.delete(n);for(const[n,{participantIdentity:r,resolve:i}]of this.pendingResponses)r===e&&(i(null,zn.builtIn("RECIPIENT_DISCONNECTED")),this.pendingResponses.delete(n))}setEnabledPublishCodecs(e){this.enabledPublishVideoCodecs=e.filter(n=>n.mime.split("/")[0].toLowerCase()==="video")}updateInfo(e){return super.updateInfo(e)?(e.tracks.forEach(n=>{var r,i;const s=this.trackPublications.get(n.sid);if(s){const a=s.isMuted||((i=(r=s.track)===null||r===void 0?void 0:r.isUpstreamPaused)!==null&&i!==void 0?i:!1);a!==n.muted&&(this.log.debug("updating server mute state after reconcile",Object.assign(Object.assign(Object.assign({},this.logContext),Lt(s)),{mutedOnServer:a})),this.engine.client.sendMuteTrack(n.sid,a))}}),!0):!1}setActiveAgent(e){var n,r,i,s;this.firstActiveAgent=e,e&&!this.firstActiveAgent&&(this.firstActiveAgent=e),e?(r=(n=this.activeAgentFuture)===null||n===void 0?void 0:n.resolve)===null||r===void 0||r.call(n,e):(s=(i=this.activeAgentFuture)===null||i===void 0?void 0:i.reject)===null||s===void 0||s.call(i,new Error("Agent disconnected")),this.activeAgentFuture=void 0}waitUntilActiveAgentPresent(){return this.firstActiveAgent?Promise.resolve(this.firstActiveAgent):(this.activeAgentFuture||(this.activeAgentFuture=new Jr),this.activeAgentFuture.promise)}getPublicationForTrack(e){let n;return this.trackPublications.forEach(r=>{const i=r.track;i&&(e instanceof MediaStreamTrack?(aa(i)||Wa(i))&&i.mediaStreamTrack===e&&(n=r):e===i&&(n=r))}),n}waitForPendingPublicationOfSource(e){return H(this,void 0,void 0,function*(){const r=Date.now();for(;Date.now()<r+1e4;){const i=Array.from(this.pendingPublishPromises.entries()).find(s=>{let[a]=s;return a.source===e});if(i)return i[1];yield Cr(20)}})}publishDataTrack(e){return H(this,void 0,void 0,function*(){const n=new Lp(e,this.roomOutgoingDataTrackManager);return yield n.publish(),n})}}class tT extends DOMException{constructor(e,n){super(e,"AbortError"),this.reason=n}}class gH extends Map{constructor(){super(...arguments),this.pending=new Map}set(e,n){var r,i;super.set(e,n);const s=(r=this.pending)===null||r===void 0?void 0:r.get(e);if(s){for(const a of s)a.isResolved||(i=a.resolve)===null||i===void 0||i.call(a,n);this.pending.delete(e)}return this}get[Symbol.toStringTag](){return"DeferrableMap"}getDeferred(e,n){return H(this,void 0,void 0,function*(){const r=this.get(e);if(typeof r<"u")return r;if(n!=null&&n.aborted)throw new tT("The operation was aborted.",n.reason);const i=new Jr(void 0,()=>{const a=this.pending.get(e);if(!a)return;const c=a.indexOf(i);c!==-1&&a.splice(c,1),a.length===0&&this.pending.delete(e)}),s=this.pending.get(e);if(s?s.push(i):this.pending.set(e,[i]),n){const a=()=>{var c;i.isResolved||(c=i.reject)===null||c===void 0||c.call(i,new tT("The operation was aborted.",n.reason))};n.addEventListener("abort",a,{once:!0}),i.promise.finally(()=>{n.removeEventListener("abort",a)})}return i.promise})}}class vH extends la{constructor(e,n,r,i){super(e,n.sid,n.name,i),this.track=void 0,this.allowed=!0,this.requestedDisabled=void 0,this.visible=!0,this.handleEnded=s=>{this.setTrack(void 0),this.emit(Fe.Ended,s)},this.handleVisibilityChange=s=>{this.log.debug("adaptivestream video visibility ".concat(this.trackSid,", visible=").concat(s),this.logContext),this.visible=s,this.emitTrackUpdate()},this.handleVideoDimensionsChange=s=>{this.log.debug("adaptivestream video dimensions ".concat(s.width,"x").concat(s.height),this.logContext),this.videoDimensionsAdaptiveStream=s,this.emitTrackUpdate()},this.subscribed=r,this.updateInfo(n)}setSubscribed(e){const n=this.subscriptionStatus,r=this.permissionStatus;this.subscribed=e,e&&(this.allowed=!0);const i=new Pp({trackSids:[this.trackSid],subscribe:this.subscribed,participantTracks:[new M2({participantSid:"",trackSids:[this.trackSid]})]});this.emit(Fe.UpdateSubscription,i),this.emitSubscriptionUpdateIfChanged(n),this.emitPermissionUpdateIfChanged(r)}get subscriptionStatus(){return this.subscribed===!1?la.SubscriptionStatus.Unsubscribed:super.isSubscribed?la.SubscriptionStatus.Subscribed:la.SubscriptionStatus.Desired}get permissionStatus(){return this.allowed?la.PermissionStatus.Allowed:la.PermissionStatus.NotAllowed}get isSubscribed(){return this.subscribed===!1?!1:super.isSubscribed}get isDesired(){return this.subscribed!==!1}get isEnabled(){return this.requestedDisabled!==void 0?!this.requestedDisabled:this.isAdaptiveStream?this.visible:!0}get isLocal(){return!1}setEnabled(e){!this.isManualOperationAllowed()||this.requestedDisabled===!e||(this.requestedDisabled=!e,this.emitTrackUpdate())}setVideoQuality(e){!this.isManualOperationAllowed()||this.requestedMaxQuality===e||(this.requestedMaxQuality=e,this.requestedVideoDimensions=void 0,this.emitTrackUpdate())}setVideoDimensions(e){var n,r;this.isManualOperationAllowed()&&(((n=this.requestedVideoDimensions)===null||n===void 0?void 0:n.width)===e.width&&((r=this.requestedVideoDimensions)===null||r===void 0?void 0:r.height)===e.height||(w0(this.track)&&(this.requestedVideoDimensions=e),this.requestedMaxQuality=void 0,this.emitTrackUpdate()))}setVideoFPS(e){this.isManualOperationAllowed()&&w0(this.track)&&this.fps!==e&&(this.fps=e,this.emitTrackUpdate())}get videoQuality(){var e;return(e=this.requestedMaxQuality)!==null&&e!==void 0?e:ui.HIGH}setTrack(e){const n=this.subscriptionStatus,r=this.permissionStatus,i=this.track;i!==e&&(i&&(i.off(Fe.VideoDimensionsChanged,this.handleVideoDimensionsChange),i.off(Fe.VisibilityChanged,this.handleVisibilityChange),i.off(Fe.Ended,this.handleEnded),i.detach(),i.stopMonitor(),this.emit(Fe.Unsubscribed,i)),super.setTrack(e),e&&(e.sid=this.trackSid,e.on(Fe.VideoDimensionsChanged,this.handleVideoDimensionsChange),e.on(Fe.VisibilityChanged,this.handleVisibilityChange),e.on(Fe.Ended,this.handleEnded),this.emit(Fe.Subscribed,e)),this.emitPermissionUpdateIfChanged(r),this.emitSubscriptionUpdateIfChanged(n))}setAllowed(e){const n=this.subscriptionStatus,r=this.permissionStatus;this.allowed=e,this.emitPermissionUpdateIfChanged(r),this.emitSubscriptionUpdateIfChanged(n)}setSubscriptionError(e){this.emit(Fe.SubscriptionFailed,e)}updateInfo(e){super.updateInfo(e);const n=this.metadataMuted;this.metadataMuted=e.muted,this.track?this.track.setMuted(e.muted):n!==e.muted&&this.emit(e.muted?Fe.Muted:Fe.Unmuted)}emitSubscriptionUpdateIfChanged(e){const n=this.subscriptionStatus;e!==n&&this.emit(Fe.SubscriptionStatusChanged,n,e)}emitPermissionUpdateIfChanged(e){this.permissionStatus!==e&&this.emit(Fe.SubscriptionPermissionChanged,this.permissionStatus,e)}isManualOperationAllowed(){return this.isDesired?!0:(this.log.warn("cannot update track settings when not subscribed",this.logContext),!1)}get isAdaptiveStream(){return w0(this.track)&&this.track.isAdaptiveStream}emitTrackUpdate(){const e=new W2({trackSids:[this.trackSid],disabled:!this.isEnabled,fps:this.fps});if(this.kind===Te.Kind.Video){let n=this.requestedVideoDimensions;if(this.videoDimensionsAdaptiveStream!==void 0)if(n)fC(this.videoDimensionsAdaptiveStream,n)&&(this.log.debug("using adaptive stream dimensions instead of requested",Object.assign(Object.assign({},this.logContext),this.videoDimensionsAdaptiveStream)),n=this.videoDimensionsAdaptiveStream);else if(this.requestedMaxQuality!==void 0&&this.trackInfo){const r=bV(this.trackInfo,this.requestedMaxQuality);r&&fC(this.videoDimensionsAdaptiveStream,r)&&(this.log.debug("using adaptive stream dimensions instead of max quality layer",Object.assign(Object.assign({},this.logContext),this.videoDimensionsAdaptiveStream)),n=this.videoDimensionsAdaptiveStream)}else this.log.debug("using adaptive stream dimensions",Object.assign(Object.assign({},this.logContext),this.videoDimensionsAdaptiveStream)),n=this.videoDimensionsAdaptiveStream;n?(e.width=Math.ceil(n.width),e.height=Math.ceil(n.height)):this.requestedMaxQuality!==void 0?(this.log.debug("using requested max quality",Object.assign(Object.assign({},this.logContext),{quality:this.requestedMaxQuality})),e.quality=this.requestedMaxQuality):(this.log.debug("using default quality",Object.assign(Object.assign({},this.logContext),{quality:ui.HIGH})),e.quality=ui.HIGH)}this.emit(Fe.UpdateSettings,e)}}class Zf extends s_{static fromParticipantInfo(e,n,r,i){return new Zf(e,n.sid,n.identity,n.name,n.metadata,n.attributes,r,n.kind,n.dataTracks.map(s=>{const a=Yf.from(s);return new r_(a,i,{publisherIdentity:n.identity})}))}get logContext(){return Object.assign(Object.assign({},super.logContext),{remoteParticipantID:this.sid,remoteParticipant:this.identity})}constructor(e,n,r,i,s,a,c){let h=arguments.length>7&&arguments[7]!==void 0?arguments[7]:ld.STANDARD,d=arguments.length>8&&arguments[8]!==void 0?arguments[8]:[];super(n,r||"",i,s,a,c,h),this.signalClient=e,this.trackPublications=new Map,this.audioTrackPublications=new Map,this.videoTrackPublications=new Map,this.dataTracks=new gH(d.map(f=>[f.info.name,f])),this.volumeMap=new Map}addTrackPublication(e){super.addTrackPublication(e),e.on(Fe.UpdateSettings,n=>{this.log.debug("send update settings",Object.assign(Object.assign(Object.assign({},this.logContext),Lt(e)),{settings:n})),this.signalClient.sendUpdateTrackSettings(n)}),e.on(Fe.UpdateSubscription,n=>{n.participantTracks.forEach(r=>{r.participantSid=this.sid}),this.signalClient.sendUpdateSubscription(n)}),e.on(Fe.SubscriptionPermissionChanged,n=>{this.emit(Be.TrackSubscriptionPermissionChanged,e,n)}),e.on(Fe.SubscriptionStatusChanged,n=>{this.emit(Be.TrackSubscriptionStatusChanged,e,n)}),e.on(Fe.Subscribed,n=>{this.emit(Be.TrackSubscribed,n,e)}),e.on(Fe.Unsubscribed,n=>{this.emit(Be.TrackUnsubscribed,n,e)}),e.on(Fe.SubscriptionFailed,n=>{this.emit(Be.TrackSubscriptionFailed,e.trackSid,n)})}getTrackPublication(e){const n=super.getTrackPublication(e);if(n)return n}getTrackPublicationByName(e){const n=super.getTrackPublicationByName(e);if(n)return n}setVolume(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Te.Source.Microphone;this.volumeMap.set(n,e);const r=this.getTrackPublication(n);r&&r.track&&r.track.setVolume(e)}getVolume(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Te.Source.Microphone;const n=this.getTrackPublication(e);return n&&n.track?n.track.getVolume():this.volumeMap.get(e)}addSubscribedMediaTrack(e,n,r,i,s,a){let c=this.getTrackPublicationBySid(n);if(c||n.startsWith("TR")||this.trackPublications.forEach(f=>{!c&&e.kind===f.kind.toString()&&(c=f)}),!c){if(a===0){this.log.error("could not find published track",Object.assign(Object.assign({},this.logContext),{trackSid:n})),this.emit(Be.TrackSubscriptionFailed,n);return}a===void 0&&(a=20),setTimeout(()=>{this.addSubscribedMediaTrack(e,n,r,i,s,a-1)},150);return}if(e.readyState==="ended"){this.log.error("unable to subscribe because MediaStreamTrack is ended. Do not call MediaStreamTrack.stop()",Object.assign(Object.assign({},this.logContext),Lt(c))),this.emit(Be.TrackSubscriptionFailed,n);return}const h=e.kind==="video";let d;return h?d=new cH(e,n,i,s):d=new lH(e,n,i,this.audioContext,this.audioOutput),d.source=c.source,d.isMuted=c.isMuted,d.setMediaStream(r),d.start(),c.setTrack(d),this.volumeMap.has(c.source)&&zv(d)&&Ts(d)&&d.setVolume(this.volumeMap.get(c.source)),c}get hasMetadata(){return!!this.participantInfo}getTrackPublicationBySid(e){return this.trackPublications.get(e)}updateInfo(e){if(!super.updateInfo(e))return!1;const n=new Map,r=new Map;return e.tracks.forEach(i=>{var s,a;let c=this.getTrackPublicationBySid(i.sid);if(c)c.updateInfo(i);else{const h=Te.kindFromProto(i.type);if(!h)return;c=new vH(h,i,(s=this.signalClient.connectOptions)===null||s===void 0?void 0:s.autoSubscribe,{loggerContextCb:()=>this.logContext,loggerName:(a=this.loggerOptions)===null||a===void 0?void 0:a.loggerName}),c.updateInfo(i),r.set(i.sid,c);const d=Array.from(this.trackPublications.values()).find(f=>f.source===(c==null?void 0:c.source));d&&c.source!==Te.Source.Unknown&&this.log.debug("received a second track publication for ".concat(this.identity," with the same source: ").concat(c.source),Object.assign(Object.assign({},this.logContext),{oldTrack:Lt(d),newTrack:Lt(c)})),this.addTrackPublication(c)}n.set(i.sid,c)}),this.trackPublications.forEach(i=>{n.has(i.trackSid)||(this.log.trace("detected removed track on remote participant, unpublishing",Object.assign(Object.assign({},this.logContext),Lt(i))),this.unpublishTrack(i.trackSid,!0))}),r.forEach(i=>{this.emit(Be.TrackPublished,i)}),!0}unpublishTrack(e,n){const r=this.trackPublications.get(e);if(!r)return;const{track:i}=r;switch(i&&(i.stop(),r.setTrack(void 0)),this.trackPublications.delete(e),r.kind){case Te.Kind.Audio:this.audioTrackPublications.delete(e);break;case Te.Kind.Video:this.videoTrackPublications.delete(e);break}n&&this.emit(Be.TrackUnpublished,r)}setAudioOutput(e){return H(this,void 0,void 0,function*(){this.audioOutput=e;const n=[];this.audioTrackPublications.forEach(r=>{var i;Ts(r.track)&&zv(r.track)&&n.push(r.track.setSinkId((i=e.deviceId)!==null&&i!==void 0?i:"default"))}),yield Promise.all(n)})}addRemoteDataTrack(e){this.dataTracks.set(e.info.name,e)}removeRemoteDataTrack(e){for(const[n,r]of this.dataTracks.entries())e===r.info.sid&&this.dataTracks.delete(n)}emit(e){for(var n=arguments.length,r=new Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];return this.log.trace("participant event",Object.assign(Object.assign({},this.logContext),{event:e,args:r})),super.emit(e,...r)}}var Xt;(function(t){t.Disconnected="disconnected",t.Connecting="connecting",t.Connected="connected",t.Reconnecting="reconnecting",t.SignalReconnecting="signalReconnecting"})(Xt||(Xt={}));const yH=4*1e3;class Nc extends Di.EventEmitter{get hasE2EESetup(){return this.e2eeManager!==void 0}constructor(e){var n,r,i,s,a,c,h;if(super(),n=this,this.state=Xt.Disconnected,this.activeSpeakers=[],this.isE2EEEnabled=!1,this.audioEnabled=!0,this.e2eeStateMutex=new fr,this.isVideoPlaybackBlocked=!1,this.log=Tt,this.bufferedEvents=[],this.isResuming=!1,this.rpcHandlers=new Map,this.connect=(d,f,p)=>H(this,void 0,void 0,function*(){var g;if(!NV())throw Os()?Error("WebRTC isn't detected, have you called registerGlobals?"):Error("LiveKit doesn't seem to be supported on this browser. Try to update your browser and make sure no browser extensions are disabling webRTC.");const v=yield this.disconnectLock.lock();if(this.state===Xt.Connected)return this.log.info("already connected to room ".concat(this.name),this.logContext),v(),Promise.resolve();if(this.connectFuture)return v(),this.connectFuture.promise;this.setAndEmitConnectionState(Xt.Connecting),((g=this.regionUrlProvider)===null||g===void 0?void 0:g.getServerUrl().toString())!==BP(d)&&(this.regionUrl=void 0,this.regionUrlProvider=void 0),Sc(new URL(d))&&(this.regionUrlProvider===void 0?this.regionUrlProvider=new qt(d,f):this.regionUrlProvider.updateToken(f),this.regionUrlProvider.fetchRegionSettings().then(S=>{var T;(T=this.regionUrlProvider)===null||T===void 0||T.setServerReportedRegions(S)}).catch(S=>{this.log.warn("could not fetch region settings",Object.assign(Object.assign({},this.logContext),{error:S}))}));const k=(S,T,C)=>H(this,void 0,void 0,function*(){var j,R;this.abortController&&this.abortController.abort();const _=new AbortController;this.abortController=_,v==null||v();try{if(yield pc.getInstance().getBackOffPromise(d),_.signal.aborted)throw ht.cancelled("Connection attempt aborted");yield this.attemptConnection(C??d,f,p,_),this.abortController=void 0,S()}catch(I){if(this.regionUrlProvider&&I instanceof ht&&I.reason!==xn.Cancelled&&I.reason!==xn.NotAllowed){let M=null;try{this.log.debug("Fetching next region"),M=yield this.regionUrlProvider.getNextBestRegionUrl((j=this.abortController)===null||j===void 0?void 0:j.signal)}catch(L){if(L instanceof ht&&(L.status===401||L.reason===xn.Cancelled)){this.handleDisconnect(this.options.stopLocalTrackOnUnpublish),T(L);return}}[xn.InternalError,xn.ServerUnreachable,xn.Timeout].includes(I.reason)&&(this.log.debug("Adding failed connection attempt to back off"),pc.getInstance().addFailedConnectionAttempt(d)),M&&!(!((R=this.abortController)===null||R===void 0)&&R.signal.aborted)?(this.log.info("Initial connection failed with ConnectionError: ".concat(I.message,". Retrying with another region: ").concat(M),this.logContext),this.recreateEngine(!0),yield k(S,T,M)):(this.handleDisconnect(this.options.stopLocalTrackOnUnpublish,bC(I)),T(I))}else{let M=ts.UNKNOWN_REASON;I instanceof ht&&(M=bC(I)),this.handleDisconnect(this.options.stopLocalTrackOnUnpublish,M),T(I)}}}),w=this.regionUrl;return this.regionUrl=void 0,this.connectFuture=new Jr((S,T)=>{k(S,T,w)},()=>{this.clearConnectionFutures()}),this.connectFuture.promise}),this.connectSignal=(d,f,p,g,v,k)=>H(this,void 0,void 0,function*(){const{joinResponse:w,serverInfo:S}=yield p.join(d,f,{autoSubscribe:g.autoSubscribe,adaptiveStream:typeof v.adaptiveStream=="object"?!0:v.adaptiveStream,maxRetries:g.maxRetries,e2eeEnabled:!!this.e2eeManager,websocketTimeout:g.websocketTimeout},k.signal,!v.singlePeerConnection);if(this.serverInfo=S,!S.version)throw new lV("unknown server version");return S.version==="0.15.1"&&this.options.dynacast&&(this.log.debug("disabling dynacast due to server version",this.logContext),v.dynacast=!1),w}),this.applyJoinResponse=d=>{const f=d.participant;if(this.localParticipant.sid=f.sid,this.localParticipant.identity=f.identity,this.localParticipant.setEnabledPublishCodecs(d.enabledPublishCodecs),this.e2eeManager)try{this.e2eeManager.setSifTrailer(d.sifTrailer)}catch(p){this.log.error(p instanceof Error?p.message:"Could not set SifTrailer",Object.assign(Object.assign({},this.logContext),{error:p}))}this.handleParticipantUpdates([f,...d.otherParticipants]),d.room&&this.handleRoomUpdate(d.room)},this.attemptConnection=(d,f,p,g)=>H(this,void 0,void 0,function*(){var v,k;this.state===Xt.Reconnecting||this.isResuming||!((v=this.engine)===null||v===void 0)&&v.pendingReconnect?(this.log.info("Reconnection attempt replaced by new connection attempt",this.logContext),this.recreateEngine(!0)):this.maybeCreateEngine(),!((k=this.regionUrlProvider)===null||k===void 0)&&k.isCloud()&&this.engine.setRegionUrlProvider(this.regionUrlProvider),this.acquireAudioContext(),this.connOptions=Object.assign(Object.assign({},Rx),p),this.connOptions.rtcConfig&&(this.engine.rtcConfig=this.connOptions.rtcConfig),this.connOptions.peerConnectionTimeout&&(this.engine.peerConnectionTimeout=this.connOptions.peerConnectionTimeout);try{const w=yield this.connectSignal(d,f,this.engine,this.connOptions,this.options,g);this.applyJoinResponse(w),this.setupLocalParticipantEvents(),this.emit(je.SignalConnected)}catch(w){yield this.engine.close(),this.recreateEngine();const S=g.signal.aborted?ht.cancelled("Signal connection aborted"):ht.serverUnreachable("could not establish signal connection");throw w instanceof Error&&(S.message="".concat(S.message,": ").concat(w.message)),w instanceof ht&&(S.reason=w.reason,S.status=w.status),this.log.debug("error trying to establish signal connection",Object.assign(Object.assign({},this.logContext),{error:w})),S}if(g.signal.aborted)throw yield this.engine.close(),this.recreateEngine(),ht.cancelled("Connection attempt aborted");try{yield this.engine.waitForPCInitialConnection(this.connOptions.peerConnectionTimeout,g)}catch(w){throw yield this.engine.close(),this.recreateEngine(),w}Yr()&&this.options.disconnectOnPageLeave&&(window.addEventListener("pagehide",this.onPageLeave),window.addEventListener("beforeunload",this.onPageLeave)),Yr()&&window.addEventListener("freeze",this.onPageLeave),this.setAndEmitConnectionState(Xt.Connected),this.emit(je.Connected),pc.getInstance().resetFailedConnectionAttempts(d),this.registerConnectionReconcile(),this.regionUrlProvider&&this.regionUrlProvider.notifyConnected()}),this.disconnect=function(){for(var d=arguments.length,f=new Array(d),p=0;p<d;p++)f[p]=arguments[p];return H(n,[...f],void 0,function(){var g=this;let v=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!0;return(function*(){var k,w,S;const T=yield g.disconnectLock.lock();try{if(g.state===Xt.Disconnected){g.log.debug("already disconnected",g.logContext);return}if(g.log.info("disconnect from room",Object.assign({},g.logContext)),g.state===Xt.Connecting||g.state===Xt.Reconnecting||g.isResuming){const C="Abort connection attempt due to user initiated disconnect";g.log.warn(C,g.logContext),(k=g.abortController)===null||k===void 0||k.abort(C),(S=(w=g.connectFuture)===null||w===void 0?void 0:w.reject)===null||S===void 0||S.call(w,ht.cancelled("Client initiated disconnect")),g.connectFuture=void 0}g.engine&&(g.engine.client.isDisconnected||(yield g.engine.client.sendLeave()),yield g.engine.close()),g.handleDisconnect(v,ts.CLIENT_INITIATED),g.engine=void 0}finally{T()}})()})},this.onPageLeave=()=>H(this,void 0,void 0,function*(){this.log.info("Page leave detected, disconnecting",this.logContext),yield this.disconnect()}),this.startAudio=()=>H(this,void 0,void 0,function*(){const d=[],f=Qr();if(f&&f.os==="iOS"){const p="livekit-dummy-audio-el";let g=document.getElementById(p);if(!g){g=document.createElement("audio"),g.id=p,g.autoplay=!0,g.hidden=!0;const v=k0();v.enabled=!0;const k=new MediaStream([v]);g.srcObject=k,document.addEventListener("visibilitychange",()=>{g&&(g.srcObject=document.hidden?null:k,document.hidden||(this.log.debug("page visible again, triggering startAudio to resume playback and update playback status",this.logContext),this.startAudio()))}),document.body.append(g),this.once(je.Disconnected,()=>{g==null||g.remove(),g=null})}d.push(g)}this.remoteParticipants.forEach(p=>{p.audioTrackPublications.forEach(g=>{g.track&&g.track.attachedElements.forEach(v=>{d.push(v)})})});try{yield Promise.all([this.acquireAudioContext(),...d.map(p=>(p.muted=!1,p.play()))]),this.handleAudioPlaybackStarted()}catch(p){throw this.handleAudioPlaybackFailed(p),p}}),this.startVideo=()=>H(this,void 0,void 0,function*(){const d=[];for(const f of this.remoteParticipants.values())f.videoTrackPublications.forEach(p=>{var g;(g=p.track)===null||g===void 0||g.attachedElements.forEach(v=>{d.includes(v)||d.push(v)})});yield Promise.all(d.map(f=>f.play())).then(()=>{this.handleVideoPlaybackStarted()}).catch(f=>{f.name==="NotAllowedError"?this.handleVideoPlaybackFailed():this.log.warn("Resuming video playback failed, make sure you call `startVideo` directly in a user gesture handler",this.logContext)})}),this.handleRestarting=()=>{this.clearConnectionReconcile(),this.isResuming=!1;for(const d of this.remoteParticipants.values())this.handleParticipantDisconnected(d.identity,d);this.setAndEmitConnectionState(Xt.Reconnecting)&&this.emit(je.Reconnecting)},this.handleRestarted=()=>{this.outgoingDataTrackManager.sfuWillRepublishTracks(),this.incomingDataTrackManager.resendSubscriptionUpdates()},this.handleSignalRestarted=d=>H(this,void 0,void 0,function*(){this.log.debug("signal reconnected to server, region ".concat(d.serverRegion),Object.assign(Object.assign({},this.logContext),{region:d.serverRegion})),this.bufferedEvents=[],this.applyJoinResponse(d);try{yield this.localParticipant.republishAllTracks(void 0,!0)}catch(f){this.log.error("error trying to re-publish tracks after reconnection",Object.assign(Object.assign({},this.logContext),{error:f}))}try{yield this.engine.waitForRestarted(),this.log.debug("fully reconnected to server",Object.assign(Object.assign({},this.logContext),{region:d.serverRegion}))}catch{return}this.setAndEmitConnectionState(Xt.Connected),this.emit(je.Reconnected),this.registerConnectionReconcile(),this.emitBufferedEvents()}),this.handleParticipantUpdates=d=>{var f;for(const g of d){if(g.identity===this.localParticipant.identity){this.localParticipant.updateInfo(g);continue}g.identity===""&&(g.identity=(f=this.sidToIdentity.get(g.sid))!==null&&f!==void 0?f:"");let v=this.remoteParticipants.get(g.identity);g.state===cc.DISCONNECTED?this.handleParticipantDisconnected(g.identity,v):v=this.getOrCreateParticipant(g.identity,g)}const p=new Map(d.filter(g=>g.identity!==this.localParticipant.identity).map(g=>[g.identity,g.dataTracks.map(v=>Yf.from(v))]));this.incomingDataTrackManager.receiveSfuPublicationUpdates(p)},this.handleActiveSpeakersUpdate=d=>{const f=[],p={};d.forEach(g=>{if(p[g.sid]=!0,g.sid===this.localParticipant.sid)this.localParticipant.audioLevel=g.level,this.localParticipant.setIsSpeaking(!0),f.push(this.localParticipant);else{const v=this.getRemoteParticipantBySid(g.sid);v&&(v.audioLevel=g.level,v.setIsSpeaking(!0),f.push(v))}}),p[this.localParticipant.sid]||(this.localParticipant.audioLevel=0,this.localParticipant.setIsSpeaking(!1)),this.remoteParticipants.forEach(g=>{p[g.sid]||(g.audioLevel=0,g.setIsSpeaking(!1))}),this.activeSpeakers=f,this.emitWhenConnected(je.ActiveSpeakersChanged,f)},this.handleSpeakersChanged=d=>{const f=new Map;this.activeSpeakers.forEach(g=>{const v=this.remoteParticipants.get(g.identity);v&&v.sid!==g.sid||f.set(g.sid,g)}),d.forEach(g=>{let v=this.getRemoteParticipantBySid(g.sid);g.sid===this.localParticipant.sid&&(v=this.localParticipant),v&&(v.audioLevel=g.level,v.setIsSpeaking(g.active),g.active?f.set(g.sid,v):f.delete(g.sid))});const p=Array.from(f.values());p.sort((g,v)=>v.audioLevel-g.audioLevel),this.activeSpeakers=p,this.emitWhenConnected(je.ActiveSpeakersChanged,p)},this.handleStreamStateUpdate=d=>{d.streamStates.forEach(f=>{const p=this.getRemoteParticipantBySid(f.participantSid);if(!p)return;const g=p.getTrackPublicationBySid(f.trackSid);if(!g||!g.track)return;const v=Te.streamStateFromProto(f.state);g.track.setStreamState(v),v!==g.track.streamState&&(p.emit(Be.TrackStreamStateChanged,g,g.track.streamState),this.emitWhenConnected(je.TrackStreamStateChanged,g,g.track.streamState,p))})},this.handleSubscriptionPermissionUpdate=d=>{const f=this.getRemoteParticipantBySid(d.participantSid);if(!f)return;const p=f.getTrackPublicationBySid(d.trackSid);p&&p.setAllowed(d.allowed)},this.handleSubscriptionError=d=>{const f=Array.from(this.remoteParticipants.values()).find(g=>g.trackPublications.has(d.trackSid));if(!f)return;const p=f.getTrackPublicationBySid(d.trackSid);p&&p.setSubscriptionError(d.err)},this.handleDataPacket=(d,f)=>{const p=this.remoteParticipants.get(d.participantIdentity);if(d.value.case==="user")this.handleUserPacket(p,d.value.value,d.kind,f);else if(d.value.case==="transcription")this.handleTranscription(p,d.value.value);else if(d.value.case==="sipDtmf")this.handleSipDtmf(p,d.value.value);else if(d.value.case==="chatMessage")this.handleChatMessage(p,d.value.value);else if(d.value.case==="metrics")this.handleMetrics(d.value.value,p);else if(d.value.case==="streamHeader"||d.value.case==="streamChunk"||d.value.case==="streamTrailer")this.handleDataStream(d,f);else if(d.value.case==="rpcRequest"){const g=d.value.value;this.handleIncomingRpcRequest(d.participantIdentity,g.id,g.method,g.payload,g.responseTimeoutMs,g.version)}},this.handleUserPacket=(d,f,p,g)=>{this.emit(je.DataReceived,f.payload,d,p,f.topic,g),d==null||d.emit(Be.DataReceived,f.payload,p,g)},this.handleSipDtmf=(d,f)=>{this.emit(je.SipDTMFReceived,f,d),d==null||d.emit(Be.SipDTMFReceived,f)},this.handleTranscription=(d,f)=>{const p=f.transcribedParticipantIdentity===this.localParticipant.identity?this.localParticipant:this.getParticipantByIdentity(f.transcribedParticipantIdentity),g=p==null?void 0:p.trackPublications.get(f.trackId),v=AV(f,this.transcriptionReceivedTimes);g==null||g.emit(Fe.TranscriptionReceived,v),p==null||p.emit(Be.TranscriptionReceived,v,g),this.emit(je.TranscriptionReceived,v,p,g)},this.handleChatMessage=(d,f)=>{const p=OV(f);this.emit(je.ChatMessage,p,d)},this.handleMetrics=(d,f)=>{this.emit(je.MetricsReceived,d,f)},this.handleDataStream=(d,f)=>{this.incomingDataStreamManager.handleDataStreamPacket(d,f)},this.bufferedSegments=new Map,this.handleAudioPlaybackStarted=()=>{this.canPlaybackAudio||(this.audioEnabled=!0,this.emit(je.AudioPlaybackStatusChanged,!0))},this.handleAudioPlaybackFailed=d=>{this.log.warn("could not playback audio",Object.assign(Object.assign({},this.logContext),{error:d})),this.canPlaybackAudio&&(this.audioEnabled=!1,this.emit(je.AudioPlaybackStatusChanged,!1))},this.handleVideoPlaybackStarted=()=>{this.isVideoPlaybackBlocked&&(this.isVideoPlaybackBlocked=!1,this.emit(je.VideoPlaybackStatusChanged,!0))},this.handleVideoPlaybackFailed=()=>{this.isVideoPlaybackBlocked||(this.isVideoPlaybackBlocked=!0,this.emit(je.VideoPlaybackStatusChanged,!1))},this.handleDeviceChange=()=>H(this,void 0,void 0,function*(){var d;((d=Qr())===null||d===void 0?void 0:d.os)!=="iOS"&&(yield this.selectDefaultDevices()),this.emit(je.MediaDevicesChanged)}),this.handleRoomUpdate=d=>{const f=this.roomInfo;this.roomInfo=d,f&&f.metadata!==d.metadata&&this.emitWhenConnected(je.RoomMetadataChanged,d.metadata),(f==null?void 0:f.activeRecording)!==d.activeRecording&&this.emitWhenConnected(je.RecordingStatusChanged,d.activeRecording)},this.handleConnectionQualityUpdate=d=>{d.updates.forEach(f=>{if(f.participantSid===this.localParticipant.sid){this.localParticipant.setConnectionQuality(f.quality);return}const p=this.getRemoteParticipantBySid(f.participantSid);p&&p.setConnectionQuality(f.quality)})},this.onLocalParticipantMetadataChanged=d=>{this.emit(je.ParticipantMetadataChanged,d,this.localParticipant)},this.onLocalParticipantNameChanged=d=>{this.emit(je.ParticipantNameChanged,d,this.localParticipant)},this.onLocalAttributesChanged=d=>{this.emit(je.ParticipantAttributesChanged,d,this.localParticipant)},this.onLocalTrackMuted=d=>{this.emit(je.TrackMuted,d,this.localParticipant)},this.onLocalTrackUnmuted=d=>{this.emit(je.TrackUnmuted,d,this.localParticipant)},this.onTrackProcessorUpdate=d=>{var f;(f=d==null?void 0:d.onPublish)===null||f===void 0||f.call(d,this)},this.onLocalTrackPublished=d=>H(this,void 0,void 0,function*(){var f,p,g,v,k,w;(f=d.track)===null||f===void 0||f.on(Fe.TrackProcessorUpdate,this.onTrackProcessorUpdate),(p=d.track)===null||p===void 0||p.on(Fe.Restarted,this.onLocalTrackRestarted),(k=(v=(g=d.track)===null||g===void 0?void 0:g.getProcessor())===null||v===void 0?void 0:v.onPublish)===null||k===void 0||k.call(v,this),this.emit(je.LocalTrackPublished,d,this.localParticipant),aa(d.track)&&(yield d.track.checkForSilence())&&this.emit(je.LocalAudioSilenceDetected,d);const S=yield(w=d.track)===null||w===void 0?void 0:w.getDeviceId(!1),T=Lv(d.source);T&&S&&S!==this.localParticipant.activeDeviceMap.get(T)&&(this.localParticipant.activeDeviceMap.set(T,S),this.emit(je.ActiveDeviceChanged,T,S))}),this.onLocalTrackUnpublished=d=>{var f,p;(f=d.track)===null||f===void 0||f.off(Fe.TrackProcessorUpdate,this.onTrackProcessorUpdate),(p=d.track)===null||p===void 0||p.off(Fe.Restarted,this.onLocalTrackRestarted),this.emit(je.LocalTrackUnpublished,d,this.localParticipant)},this.onLocalTrackRestarted=d=>H(this,void 0,void 0,function*(){const f=yield d.getDeviceId(!1),p=Lv(d.source);p&&f&&f!==this.localParticipant.activeDeviceMap.get(p)&&(this.log.debug("local track restarted, setting ".concat(p," ").concat(f," active"),this.logContext),this.localParticipant.activeDeviceMap.set(p,f),this.emit(je.ActiveDeviceChanged,p,f))}),this.onLocalConnectionQualityChanged=d=>{this.emit(je.ConnectionQualityChanged,d,this.localParticipant)},this.onMediaDevicesError=(d,f)=>{this.emit(je.MediaDevicesError,d,f)},this.onLocalParticipantPermissionsChanged=d=>{this.emit(je.ParticipantPermissionsChanged,d,this.localParticipant)},this.onLocalChatMessageSent=d=>{this.emit(je.ChatMessage,d,this.localParticipant)},this.setMaxListeners(100),this.remoteParticipants=new Map,this.sidToIdentity=new Map,this.options=Object.assign(Object.assign({},vW),e),this.log=ei((r=this.options.loggerName)!==null&&r!==void 0?r:Nr.Room),this.transcriptionReceivedTimes=new Map,this.options.audioCaptureDefaults=Object.assign(Object.assign({},$P),e==null?void 0:e.audioCaptureDefaults),this.options.videoCaptureDefaults=Object.assign(Object.assign({},VP),e==null?void 0:e.videoCaptureDefaults),this.options.publishDefaults=Object.assign(Object.assign({},gW),e==null?void 0:e.publishDefaults),this.maybeCreateEngine(),this.incomingDataStreamManager=new KW,this.outgoingDataStreamManager=new JW(this.engine,this.log),this.incomingDataTrackManager=new aH({e2eeManager:this.e2eeManager}),this.incomingDataTrackManager.on("sfuUpdateSubscription",d=>{this.engine.client.sendUpdateDataSubscription(d.sid,d.subscribe)}).on("trackPublished",d=>{var f;d.track.publisherIdentity!==this.localParticipant.identity&&(this.emit(je.DataTrackPublished,d.track),(f=this.remoteParticipants.get(d.track.publisherIdentity))===null||f===void 0||f.addRemoteDataTrack(d.track))}).on("trackUnpublished",d=>{var f;d.publisherIdentity!==this.localParticipant.identity&&(this.emit(je.DataTrackUnpublished,d.sid),(f=this.remoteParticipants.get(d.publisherIdentity))===null||f===void 0||f.removeRemoteDataTrack(d.sid))}),this.outgoingDataTrackManager=new Ox({e2eeManager:this.e2eeManager}),this.outgoingDataTrackManager.on("sfuPublishRequest",d=>{this.engine.client.sendPublishDataTrackRequest(d.handle,d.name,d.usesE2ee)}).on("sfuUnpublishRequest",d=>{this.engine.client.sendUnPublishDataTrackRequest(d.handle)}).on("trackPublished",d=>{this.emit(je.LocalDataTrackPublished,d.track)}).on("trackUnpublished",d=>{this.emit(je.LocalDataTrackUnpublished,d.sid)}).on("packetAvailable",d=>{let{bytes:f}=d;this.engine.sendLossyBytes(f,It.DATA_TRACK_LOSSY,"wait")}),this.disconnectLock=new fr,this.localParticipant=new mH("","",this.engine,this.options,this.rpcHandlers,this.outgoingDataStreamManager,this.outgoingDataTrackManager),(this.options.e2ee||this.options.encryption)&&this.setupE2EE(),this.engine.e2eeManager=this.e2eeManager,this.incomingDataTrackManager.updateE2eeManager((i=this.e2eeManager)!==null&&i!==void 0?i:null),this.outgoingDataTrackManager.updateE2eeManager((s=this.e2eeManager)!==null&&s!==void 0?s:null),this.options.videoCaptureDefaults.deviceId&&this.localParticipant.activeDeviceMap.set("videoinput",rl(this.options.videoCaptureDefaults.deviceId)),this.options.audioCaptureDefaults.deviceId&&this.localParticipant.activeDeviceMap.set("audioinput",rl(this.options.audioCaptureDefaults.deviceId)),!((a=this.options.audioOutput)===null||a===void 0)&&a.deviceId&&this.switchActiveDevice("audiooutput",rl(this.options.audioOutput.deviceId)).catch(d=>this.log.warn("Could not set audio output: ".concat(d.message),this.logContext)),Yr()){const d=new AbortController;(h=(c=navigator.mediaDevices)===null||c===void 0?void 0:c.addEventListener)===null||h===void 0||h.call(c,"devicechange",this.handleDeviceChange,{signal:d.signal}),Nc.cleanupRegistry&&Nc.cleanupRegistry.register(this,()=>{d.abort()})}}registerTextStreamHandler(e,n){return this.incomingDataStreamManager.registerTextStreamHandler(e,n)}unregisterTextStreamHandler(e){return this.incomingDataStreamManager.unregisterTextStreamHandler(e)}registerByteStreamHandler(e,n){return this.incomingDataStreamManager.registerByteStreamHandler(e,n)}unregisterByteStreamHandler(e){return this.incomingDataStreamManager.unregisterByteStreamHandler(e)}registerRpcMethod(e,n){if(this.rpcHandlers.has(e))throw Error("RPC handler already registered for method ".concat(e,", unregisterRpcMethod before trying to register again"));this.rpcHandlers.set(e,n)}unregisterRpcMethod(e){this.rpcHandlers.delete(e)}setE2EEEnabled(e){return H(this,void 0,void 0,function*(){const n=yield this.e2eeStateMutex.lock();try{if(this.e2eeManager)this.isE2EEEnabled!==e&&(yield this.localParticipant.setE2EEEnabled(e),this.localParticipant.identity!==""&&this.e2eeManager.setParticipantCryptorEnabled(e,this.localParticipant.identity));else throw Error("e2ee not configured, please set e2ee settings within the room options")}finally{n()}})}setupE2EE(){var e,n;const r=!!this.options.encryption,i=this.options.encryption||this.options.e2ee;i&&("e2eeManager"in i?(this.e2eeManager=i.e2eeManager,this.e2eeManager.isDataChannelEncryptionEnabled=r):this.e2eeManager=new XV(i,r),this.e2eeManager.on(Za.ParticipantEncryptionStatusChanged,(s,a)=>{FV(a)&&(this.isE2EEEnabled=s),this.emit(je.ParticipantEncryptionStatusChanged,s,a)}),this.e2eeManager.on(Za.EncryptionError,(s,a)=>{const c=a?this.getParticipantByIdentity(a):void 0;this.emit(je.EncryptionError,s,c)}),(e=this.e2eeManager)===null||e===void 0||e.setup(this),(n=this.e2eeManager)===null||n===void 0||n.setupEngine(this.engine))}get logContext(){var e;return{room:this.name,roomID:(e=this.roomInfo)===null||e===void 0?void 0:e.sid,participant:this.localParticipant.identity,participantID:this.localParticipant.sid}}get isRecording(){var e,n;return(n=(e=this.roomInfo)===null||e===void 0?void 0:e.activeRecording)!==null&&n!==void 0?n:!1}getSid(){return this.state===Xt.Disconnected?Sr.resolve(""):this.roomInfo&&this.roomInfo.sid!==""?Sr.resolve(this.roomInfo.sid):new Sr((e,n)=>{const r=i=>{i.sid!==""&&(this.engine.off(De.RoomUpdate,r),e(i.sid))};this.engine.on(De.RoomUpdate,r),this.once(je.Disconnected,()=>{this.engine.off(De.RoomUpdate,r),n(new On("Room disconnected before room server id was available"))})})}get name(){var e,n;return(n=(e=this.roomInfo)===null||e===void 0?void 0:e.name)!==null&&n!==void 0?n:""}get metadata(){var e;return(e=this.roomInfo)===null||e===void 0?void 0:e.metadata}get numParticipants(){var e,n;return(n=(e=this.roomInfo)===null||e===void 0?void 0:e.numParticipants)!==null&&n!==void 0?n:0}get numPublishers(){var e,n;return(n=(e=this.roomInfo)===null||e===void 0?void 0:e.numPublishers)!==null&&n!==void 0?n:0}maybeCreateEngine(){this.engine&&(this.engine.isNewlyCreated||!this.engine.isClosed)||(this.engine=new WW(this.options),this.engine.e2eeManager=this.e2eeManager,this.engine.on(De.ParticipantUpdate,this.handleParticipantUpdates).on(De.RoomUpdate,this.handleRoomUpdate).on(De.SpeakersChanged,this.handleSpeakersChanged).on(De.StreamStateChanged,this.handleStreamStateUpdate).on(De.ConnectionQualityUpdate,this.handleConnectionQualityUpdate).on(De.SubscriptionError,this.handleSubscriptionError).on(De.SubscriptionPermissionUpdate,this.handleSubscriptionPermissionUpdate).on(De.MediaTrackAdded,(e,n,r)=>{this.onTrackAdded(e,n,r)}).on(De.Disconnected,e=>{this.handleDisconnect(this.options.stopLocalTrackOnUnpublish,e)}).on(De.ActiveSpeakersUpdate,this.handleActiveSpeakersUpdate).on(De.DataPacketReceived,this.handleDataPacket).on(De.Resuming,()=>{this.clearConnectionReconcile(),this.isResuming=!0,this.log.info("Resuming signal connection",this.logContext),this.setAndEmitConnectionState(Xt.SignalReconnecting)&&this.emit(je.SignalReconnecting)}).on(De.Resumed,()=>{this.registerConnectionReconcile(),this.isResuming=!1,this.log.info("Resumed signal connection",this.logContext),this.updateSubscriptions(),this.emitBufferedEvents(),this.setAndEmitConnectionState(Xt.Connected)&&this.emit(je.Reconnected)}).on(De.SignalResumed,()=>{this.bufferedEvents=[],(this.state===Xt.Reconnecting||this.isResuming)&&this.sendSyncState()}).on(De.Restarting,this.handleRestarting).on(De.Restarted,this.handleRestarted).on(De.SignalRestarted,this.handleSignalRestarted).on(De.Offline,()=>{this.setAndEmitConnectionState(Xt.Reconnecting)&&this.emit(je.Reconnecting)}).on(De.DCBufferStatusChanged,(e,n)=>{this.emit(je.DCBufferStatusChanged,e,n)}).on(De.LocalTrackSubscribed,e=>{this.handleLocalTrackSubscribed(e)}).on(De.RoomMoved,e=>{this.log.debug("room moved",e),e.room&&this.handleRoomUpdate(e.room),this.remoteParticipants.forEach((n,r)=>{this.handleParticipantDisconnected(r,n)}),this.emit(je.Moved,e.room.name),e.participant?this.handleParticipantUpdates([e.participant,...e.otherParticipants]):this.handleParticipantUpdates(e.otherParticipants)}).on(De.PublishDataTrackResponse,e=>{if(!e.info){this.log.warn("received PublishDataTrackResponse, but event.info was ".concat(e.info,", so skipping."),this.logContext);return}this.outgoingDataTrackManager.receivedSfuPublishResponse(e.info.pubHandle,{type:"ok",data:{sid:e.info.sid,pubHandle:e.info.pubHandle,name:e.info.name,usesE2ee:e.info.encryption!==bn.NONE}})}).on(De.UnPublishDataTrackResponse,e=>{if(!e.info){this.log.warn("received UnPublishDataTrackResponse, but event.info was ".concat(e.info,", so skipping."),this.logContext);return}this.outgoingDataTrackManager.receivedSfuUnpublishResponse(e.info.pubHandle)}).on(De.DataTrackSubscriberHandles,e=>{const n=new Map(Object.entries(e.subHandles).map(r=>{let[i,s]=r;return[parseInt(i,10),s.trackSid]}));this.incomingDataTrackManager.receivedSfuSubscriberHandles(n)}).on(De.DataTrackPacketReceived,e=>{try{this.incomingDataTrackManager.packetReceived(e)}catch(n){throw n}}).on(De.Joined,e=>{const n=new Map(e.otherParticipants.map(r=>[r.identity,r.dataTracks.map(i=>Yf.from(i))]));this.incomingDataTrackManager.receiveSfuPublicationUpdates(n)}),this.localParticipant&&this.localParticipant.setupEngine(this.engine),this.e2eeManager&&this.e2eeManager.setupEngine(this.engine),this.outgoingDataStreamManager&&this.outgoingDataStreamManager.setupEngine(this.engine))}static getLocalDevices(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0;return cr.getInstance().getDevices(e,n)}prepareConnection(e,n){return H(this,void 0,void 0,function*(){if(this.state===Xt.Disconnected){this.log.debug("prepareConnection to ".concat(e),this.logContext);try{if(Sc(new URL(e))&&n){this.regionUrlProvider=new qt(e,n);const r=yield this.regionUrlProvider.getNextBestRegionUrl();r&&this.state===Xt.Disconnected&&(this.regionUrl=r,yield fetch(hd(r),{method:"HEAD"}),this.log.debug("prepared connection to ".concat(r),this.logContext))}else yield fetch(hd(e),{method:"HEAD"})}catch(r){this.log.warn("could not prepare connection",Object.assign(Object.assign({},this.logContext),{error:r}))}}})}getParticipantByIdentity(e){return this.localParticipant.identity===e?this.localParticipant:this.remoteParticipants.get(e)}clearConnectionFutures(){this.connectFuture=void 0}simulateScenario(e,n){return H(this,void 0,void 0,function*(){let r=()=>H(this,void 0,void 0,function*(){}),i;switch(e){case"signal-reconnect":yield this.engine.client.handleOnClose("simulate disconnect");break;case"fail-on-v1-path":this.engine.failNextV1Path();break;case"speaker":i=new gs({scenario:{case:"speakerUpdate",value:3}});break;case"node-failure":i=new gs({scenario:{case:"nodeFailure",value:!0}});break;case"server-leave":i=new gs({scenario:{case:"serverLeave",value:!0}});break;case"migration":i=new gs({scenario:{case:"migration",value:!0}});break;case"resume-reconnect":this.engine.failNext(),yield this.engine.client.handleOnClose("simulate resume-disconnect");break;case"disconnect-signal-on-resume":r=()=>H(this,void 0,void 0,function*(){yield this.engine.client.handleOnClose("simulate resume-disconnect")}),i=new gs({scenario:{case:"disconnectSignalOnResume",value:!0}});break;case"disconnect-signal-on-resume-no-messages":r=()=>H(this,void 0,void 0,function*(){yield this.engine.client.handleOnClose("simulate resume-disconnect")}),i=new gs({scenario:{case:"disconnectSignalOnResumeNoMessages",value:!0}});break;case"full-reconnect":this.engine.fullReconnectOnNext=!0,yield this.engine.client.handleOnClose("simulate full-reconnect");break;case"force-tcp":case"force-tls":i=new gs({scenario:{case:"switchCandidateProtocol",value:e==="force-tls"?2:1}}),r=()=>H(this,void 0,void 0,function*(){const s=this.engine.client.onLeave;s&&s(new _p({reason:ts.CLIENT_INITIATED,action:uc.RECONNECT}))});break;case"subscriber-bandwidth":if(n===void 0||typeof n!="number")throw new Error("subscriber-bandwidth requires a number as argument");i=new gs({scenario:{case:"subscriberBandwidth",value:$o(n)}});break;case"leave-full-reconnect":i=new gs({scenario:{case:"leaveRequestFullReconnect",value:!0}})}i&&(yield this.engine.client.sendSimulateScenario(i),yield r())})}get canPlaybackAudio(){return this.audioEnabled}get canPlaybackVideo(){return!this.isVideoPlaybackBlocked}getActiveDevice(e){return this.localParticipant.activeDeviceMap.get(e)}switchActiveDevice(e,n){return H(this,arguments,void 0,function(r,i){var s=this;let a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0;return(function*(){var c,h,d,f,p,g,v;let k=!0,w=!1;const S=a?{exact:i}:i;if(r==="audioinput"){w=s.localParticipant.audioTrackPublications.size===0;const T=(c=s.getActiveDevice(r))!==null&&c!==void 0?c:s.options.audioCaptureDefaults.deviceId;s.options.audioCaptureDefaults.deviceId=S;const C=Array.from(s.localParticipant.audioTrackPublications.values()).filter(R=>R.source===Te.Source.Microphone);try{k=(yield Promise.all(C.map(R=>{var _;return(_=R.audioTrack)===null||_===void 0?void 0:_.setDeviceId(S)}))).every(R=>R===!0)}catch(R){throw s.options.audioCaptureDefaults.deviceId=T,R}const j=C.some(R=>{var _,I;return(I=(_=R.track)===null||_===void 0?void 0:_.isMuted)!==null&&I!==void 0?I:!1});k&&j&&(w=!0)}else if(r==="videoinput"){w=s.localParticipant.videoTrackPublications.size===0;const T=(h=s.getActiveDevice(r))!==null&&h!==void 0?h:s.options.videoCaptureDefaults.deviceId;s.options.videoCaptureDefaults.deviceId=S;const C=Array.from(s.localParticipant.videoTrackPublications.values()).filter(R=>R.source===Te.Source.Camera);try{k=(yield Promise.all(C.map(R=>{var _;return(_=R.videoTrack)===null||_===void 0?void 0:_.setDeviceId(S)}))).every(R=>R===!0)}catch(R){throw s.options.videoCaptureDefaults.deviceId=T,R}const j=C.some(R=>{var _,I;return(I=(_=R.track)===null||_===void 0?void 0:_.isMuted)!==null&&I!==void 0?I:!1});k&&j&&(w=!0)}else if(r==="audiooutput"){if(w=!0,!Bv()&&!s.options.webAudioMix||s.options.webAudioMix&&s.audioContext&&!("setSinkId"in s.audioContext))throw new Error("cannot switch audio output, the current browser does not support it");s.options.webAudioMix&&(i=(d=yield cr.getInstance().normalizeDeviceId("audiooutput",i))!==null&&d!==void 0?d:""),(f=(v=s.options).audioOutput)!==null&&f!==void 0||(v.audioOutput={});const T=(p=s.getActiveDevice(r))!==null&&p!==void 0?p:s.options.audioOutput.deviceId;s.options.audioOutput.deviceId=i;try{s.options.webAudioMix&&((g=s.audioContext)===null||g===void 0||g.setSinkId(i)),yield Promise.all(Array.from(s.remoteParticipants.values()).map(C=>C.setAudioOutput({deviceId:i})))}catch(C){throw s.options.audioOutput.deviceId=T,C}}return w&&(s.localParticipant.activeDeviceMap.set(r,i),s.emit(je.ActiveDeviceChanged,r,i)),k})()})}setupLocalParticipantEvents(){this.localParticipant.on(Be.ParticipantMetadataChanged,this.onLocalParticipantMetadataChanged).on(Be.ParticipantNameChanged,this.onLocalParticipantNameChanged).on(Be.AttributesChanged,this.onLocalAttributesChanged).on(Be.TrackMuted,this.onLocalTrackMuted).on(Be.TrackUnmuted,this.onLocalTrackUnmuted).on(Be.LocalTrackPublished,this.onLocalTrackPublished).on(Be.LocalTrackUnpublished,this.onLocalTrackUnpublished).on(Be.ConnectionQualityChanged,this.onLocalConnectionQualityChanged).on(Be.MediaDevicesError,this.onMediaDevicesError).on(Be.AudioStreamAcquired,this.startAudio).on(Be.ChatMessage,this.onLocalChatMessageSent).on(Be.ParticipantPermissionsChanged,this.onLocalParticipantPermissionsChanged)}recreateEngine(e){const n=this.engine;e&&n&&!n.client.isDisconnected?n.client.sendLeave().finally(()=>n.close()):n==null||n.close(),this.engine=void 0,this.isResuming=!1,this.remoteParticipants.clear(),this.sidToIdentity.clear(),this.bufferedEvents=[],this.maybeCreateEngine()}onTrackAdded(e,n,r){if(this.state===Xt.Connecting||this.state===Xt.Reconnecting){const p=()=>{this.log.debug("deferring on track for later",{mediaTrackId:e.id,mediaStreamId:n.id,tracksInStream:n.getTracks().map(v=>v.id)}),this.onTrackAdded(e,n,r),g()},g=()=>{this.off(je.Reconnected,p),this.off(je.Connected,p),this.off(je.Disconnected,g)};this.once(je.Reconnected,p),this.once(je.Connected,p),this.once(je.Disconnected,g);return}if(this.state===Xt.Disconnected){this.log.warn("skipping incoming track after Room disconnected",this.logContext);return}if(e.readyState==="ended"){this.log.info("skipping incoming track as it already ended",this.logContext);return}const i=SV(n.id),s=i[0];let a=i[1],c=e.id;if(a&&a.startsWith("TR")&&(c=a),s===this.localParticipant.sid){this.log.warn("tried to create RemoteParticipant for local participant",this.logContext);return}const h=Array.from(this.remoteParticipants.values()).find(p=>p.sid===s);if(!h){s.startsWith("PA")&&this.log.error("Tried to add a track for a participant, that's not present. Sid: ".concat(s),this.logContext);return}if(!c.startsWith("TR")){const p=this.engine.getTrackIdForReceiver(r);if(!p){this.log.error("Tried to add a track whose 'sid' could not be found for a participant, that's not present. Sid: ".concat(s),this.logContext);return}c=p}c.startsWith("TR")||this.log.warn("Tried to add a track whose 'sid' could not be determined for a participant, that's not present. Sid: ".concat(s,", streamId: ").concat(a,", trackId: ").concat(c),Object.assign(Object.assign({},this.logContext),{remoteParticipantID:s,streamId:a,trackId:c}));let d;this.options.adaptiveStream&&(typeof this.options.adaptiveStream=="object"?d=this.options.adaptiveStream:d={});const f=h.addSubscribedMediaTrack(e,c,n,r,d);f!=null&&f.isEncrypted&&!this.e2eeManager&&this.emit(je.EncryptionError,new Error("Encrypted ".concat(f.source," track received from participant ").concat(h.sid,", but room does not have encryption enabled!")))}handleLocalTrackSubscribed(e){const n=()=>this.localParticipant.getTrackPublications().find(h=>{let{trackSid:d}=h;return d===e}),r=n();if(r){this.emitLocalTrackSubscribed(r);return}this.log.debug("deferring LocalTrackSubscribed, publication not yet available",Object.assign(Object.assign({},this.logContext),{subscribedSid:e}));const i=1e4;let s;const a=h=>{h.trackSid===e&&(c(),this.emitLocalTrackSubscribed(h))},c=()=>{clearTimeout(s),this.localParticipant.off(Be.LocalTrackPublished,a),this.off(je.Disconnected,c)};this.localParticipant.on(Be.LocalTrackPublished,a),this.once(je.Disconnected,c),s=setTimeout(()=>{c();const h=n();h?this.emitLocalTrackSubscribed(h):this.log.warn("could not find local track publication for LocalTrackSubscribed event after timeout",Object.assign(Object.assign({},this.logContext),{subscribedSid:e}))},i)}emitLocalTrackSubscribed(e){this.localParticipant.emit(Be.LocalTrackSubscribed,e),this.emitWhenConnected(je.LocalTrackSubscribed,e,this.localParticipant)}handleDisconnect(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!0,n=arguments.length>1?arguments[1]:void 0;var r,i;if(this.clearConnectionReconcile(),this.isResuming=!1,this.bufferedEvents=[],this.transcriptionReceivedTimes.clear(),this.incomingDataStreamManager.clearControllers(),this.state!==Xt.Disconnected){this.regionUrl=void 0,this.regionUrlProvider&&this.regionUrlProvider.notifyDisconnected();try{this.remoteParticipants.forEach(s=>{s.trackPublications.forEach(a=>{s.unpublishTrack(a.trackSid)})}),this.localParticipant.trackPublications.forEach(s=>{var a,c,h;s.track&&this.localParticipant.unpublishTrack(s.track,e),e?((a=s.track)===null||a===void 0||a.detach(),(c=s.track)===null||c===void 0||c.stop()):(h=s.track)===null||h===void 0||h.stopMonitor()}),this.localParticipant.off(Be.ParticipantMetadataChanged,this.onLocalParticipantMetadataChanged).off(Be.ParticipantNameChanged,this.onLocalParticipantNameChanged).off(Be.AttributesChanged,this.onLocalAttributesChanged).off(Be.TrackMuted,this.onLocalTrackMuted).off(Be.TrackUnmuted,this.onLocalTrackUnmuted).off(Be.LocalTrackPublished,this.onLocalTrackPublished).off(Be.LocalTrackUnpublished,this.onLocalTrackUnpublished).off(Be.ConnectionQualityChanged,this.onLocalConnectionQualityChanged).off(Be.MediaDevicesError,this.onMediaDevicesError).off(Be.AudioStreamAcquired,this.startAudio).off(Be.ChatMessage,this.onLocalChatMessageSent).off(Be.ParticipantPermissionsChanged,this.onLocalParticipantPermissionsChanged),this.localParticipant.trackPublications.clear(),this.localParticipant.videoTrackPublications.clear(),this.localParticipant.audioTrackPublications.clear(),this.remoteParticipants.clear(),this.sidToIdentity.clear(),this.activeSpeakers=[],this.audioContext&&typeof this.options.webAudioMix=="boolean"&&(this.audioContext.close(),this.audioContext=void 0),Yr()&&(window.removeEventListener("beforeunload",this.onPageLeave),window.removeEventListener("pagehide",this.onPageLeave),window.removeEventListener("freeze",this.onPageLeave),(i=(r=navigator.mediaDevices)===null||r===void 0?void 0:r.removeEventListener)===null||i===void 0||i.call(r,"devicechange",this.handleDeviceChange))}finally{this.setAndEmitConnectionState(Xt.Disconnected),this.emit(je.Disconnected,n)}}}handleParticipantDisconnected(e,n){var r;this.remoteParticipants.delete(e),n&&(this.incomingDataStreamManager.validateParticipantHasNoActiveDataStreams(e),this.incomingDataTrackManager.handleRemoteParticipantDisconnected(e),n.trackPublications.forEach(i=>{n.unpublishTrack(i.trackSid,!0)}),this.emit(je.ParticipantDisconnected,n),n.setDisconnected(),(r=this.localParticipant)===null||r===void 0||r.handleParticipantDisconnected(n.identity))}handleIncomingRpcRequest(e,n,r,i,s,a){return H(this,void 0,void 0,function*(){if(yield this.engine.publishRpcAck(e,n),a!==1){yield this.engine.publishRpcResponse(e,n,null,zn.builtIn("UNSUPPORTED_VERSION"));return}const c=this.rpcHandlers.get(r);if(!c){yield this.engine.publishRpcResponse(e,n,null,zn.builtIn("UNSUPPORTED_METHOD"));return}let h=null,d=null;try{const f=yield c({requestId:n,callerIdentity:e,payload:i,responseTimeout:s});Ix(f)>HP?(h=zn.builtIn("RESPONSE_PAYLOAD_TOO_LARGE"),this.log.warn("RPC Response payload too large for ".concat(r))):d=f}catch(f){f instanceof zn?h=f:(this.log.warn("Uncaught error returned by RPC handler for ".concat(r,". Returning APPLICATION_ERROR instead."),f),h=zn.builtIn("APPLICATION_ERROR"))}yield this.engine.publishRpcResponse(e,n,d,h)})}selectDefaultDevices(){return H(this,void 0,void 0,function*(){var e,n,r;const i=cr.getInstance().previousDevices,s=yield cr.getInstance().getDevices(void 0,!1),a=Qr();if((a==null?void 0:a.name)==="Chrome"&&a.os!=="iOS")for(let h of s){const d=i.find(f=>f.deviceId===h.deviceId);d&&d.label!==""&&d.kind===h.kind&&d.label!==h.label&&this.getActiveDevice(h.kind)==="default"&&this.emit(je.ActiveDeviceChanged,h.kind,h.deviceId)}const c=["audiooutput","audioinput","videoinput"];for(let h of c){const d=pV(h),f=this.localParticipant.getTrackPublication(d);if(f&&(!((e=f.track)===null||e===void 0)&&e.isUserProvided))continue;const p=s.filter(v=>v.kind===h),g=this.getActiveDevice(h);if(g===((n=i.filter(v=>v.kind===h)[0])===null||n===void 0?void 0:n.deviceId)&&p.length>0&&((r=p[0])===null||r===void 0?void 0:r.deviceId)!==g){yield this.switchActiveDevice(h,p[0].deviceId);continue}h==="audioinput"&&!dd()||h==="videoinput"||p.length>0&&!p.find(v=>v.deviceId===this.getActiveDevice(h))&&(h!=="audiooutput"||!dd())&&(yield this.switchActiveDevice(h,p[0].deviceId))}})}acquireAudioContext(){return H(this,void 0,void 0,function*(){var e,n;if(typeof this.options.webAudioMix!="boolean"&&this.options.webAudioMix.audioContext?this.audioContext=this.options.webAudioMix.audioContext:(!this.audioContext||this.audioContext.state==="closed")&&(this.audioContext=(e=AP())!==null&&e!==void 0?e:void 0),this.options.webAudioMix&&this.remoteParticipants.forEach(i=>i.setAudioContext(this.audioContext)),this.localParticipant.setAudioContext(this.audioContext),this.audioContext&&this.audioContext.state==="suspended")try{yield Promise.race([this.audioContext.resume(),Cr(200)])}catch(i){this.log.warn("Could not resume audio context",Object.assign(Object.assign({},this.logContext),{error:i}))}const r=((n=this.audioContext)===null||n===void 0?void 0:n.state)==="running";r!==this.canPlaybackAudio&&(this.audioEnabled=r,this.emit(je.AudioPlaybackStatusChanged,r))})}createParticipant(e,n){var r;let i;return n?i=Zf.fromParticipantInfo(this.engine.client,n,{loggerContextCb:()=>this.logContext,loggerName:this.options.loggerName},this.incomingDataTrackManager):i=new Zf(this.engine.client,"",e,void 0,void 0,void 0,{loggerContextCb:()=>this.logContext,loggerName:this.options.loggerName}),this.options.webAudioMix&&i.setAudioContext(this.audioContext),!((r=this.options.audioOutput)===null||r===void 0)&&r.deviceId&&i.setAudioOutput(this.options.audioOutput).catch(s=>this.log.warn("Could not set audio output: ".concat(s.message),this.logContext)),i}getOrCreateParticipant(e,n){if(this.remoteParticipants.has(e)){const i=this.remoteParticipants.get(e);return n&&i.updateInfo(n)&&this.sidToIdentity.set(n.sid,n.identity),i}const r=this.createParticipant(e,n);return this.remoteParticipants.set(e,r),this.sidToIdentity.set(n.sid,n.identity),this.emitWhenConnected(je.ParticipantConnected,r),r.on(Be.TrackPublished,i=>{this.emitWhenConnected(je.TrackPublished,i,r)}).on(Be.TrackSubscribed,(i,s)=>{i.kind===Te.Kind.Audio?(i.on(Fe.AudioPlaybackStarted,this.handleAudioPlaybackStarted),i.on(Fe.AudioPlaybackFailed,this.handleAudioPlaybackFailed)):i.kind===Te.Kind.Video&&(i.on(Fe.VideoPlaybackFailed,this.handleVideoPlaybackFailed),i.on(Fe.VideoPlaybackStarted,this.handleVideoPlaybackStarted)),this.emitWhenConnected(je.TrackSubscribed,i,s,r)}).on(Be.TrackUnpublished,i=>{this.emit(je.TrackUnpublished,i,r)}).on(Be.TrackUnsubscribed,(i,s)=>{this.emit(je.TrackUnsubscribed,i,s,r)}).on(Be.TrackMuted,i=>{this.emitWhenConnected(je.TrackMuted,i,r)}).on(Be.TrackUnmuted,i=>{this.emitWhenConnected(je.TrackUnmuted,i,r)}).on(Be.ParticipantMetadataChanged,i=>{this.emitWhenConnected(je.ParticipantMetadataChanged,i,r)}).on(Be.ParticipantNameChanged,i=>{this.emitWhenConnected(je.ParticipantNameChanged,i,r)}).on(Be.AttributesChanged,i=>{this.emitWhenConnected(je.ParticipantAttributesChanged,i,r)}).on(Be.ConnectionQualityChanged,i=>{this.emitWhenConnected(je.ConnectionQualityChanged,i,r)}).on(Be.ParticipantPermissionsChanged,i=>{this.emitWhenConnected(je.ParticipantPermissionsChanged,i,r)}).on(Be.TrackSubscriptionStatusChanged,(i,s)=>{this.emitWhenConnected(je.TrackSubscriptionStatusChanged,i,s,r)}).on(Be.TrackSubscriptionFailed,(i,s)=>{this.emit(je.TrackSubscriptionFailed,i,r,s)}).on(Be.TrackSubscriptionPermissionChanged,(i,s)=>{this.emitWhenConnected(je.TrackSubscriptionPermissionChanged,i,s,r)}).on(Be.Active,()=>{this.emitWhenConnected(je.ParticipantActive,r),r.kind===ld.AGENT&&this.localParticipant.setActiveAgent(r)}),n&&r.updateInfo(n),r}sendSyncState(){const e=Array.from(this.remoteParticipants.values()).reduce((i,s)=>(i.push(...s.getTrackPublications()),i),[]),n=this.localParticipant.getTrackPublications(),r=this.outgoingDataTrackManager.queryPublished();this.engine.sendSyncState(e,n,r)}updateSubscriptions(){for(const e of this.remoteParticipants.values())for(const n of e.videoTrackPublications.values())n.isSubscribed&&LV(n)&&n.emitTrackUpdate()}getRemoteParticipantBySid(e){const n=this.sidToIdentity.get(e);if(n)return this.remoteParticipants.get(n)}registerConnectionReconcile(){this.clearConnectionReconcile();let e=0;this.connectionReconcileInterval=Qn.setInterval(()=>{!this.engine||this.engine.isClosed||!this.engine.verifyTransport()?(e++,this.log.warn("detected connection state mismatch",Object.assign(Object.assign({},this.logContext),{numFailures:e,engine:this.engine?{closed:this.engine.isClosed,transportsConnectedOrConnecting:this.engine.verifyTransport()}:void 0})),e>=3&&(this.recreateEngine(),this.handleDisconnect(this.options.stopLocalTrackOnUnpublish,ts.STATE_MISMATCH))):e=0},yH)}clearConnectionReconcile(){this.connectionReconcileInterval&&Qn.clearInterval(this.connectionReconcileInterval)}setAndEmitConnectionState(e){return e===this.state?!1:(this.state=e,this.incomingDataStreamManager.setConnected(e===Xt.Connected),this.emit(je.ConnectionStateChanged,this.state),!0)}emitBufferedEvents(){this.bufferedEvents.forEach(e=>{let[n,r]=e;this.emit(n,...r)}),this.bufferedEvents=[]}emitWhenConnected(e){for(var n=arguments.length,r=new Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];if(this.state===Xt.Reconnecting||this.isResuming||!this.engine||this.engine.pendingReconnect)this.bufferedEvents.push([e,r]);else if(this.state===Xt.Connected)return this.emit(e,...r);return!1}simulateParticipants(e){return H(this,void 0,void 0,function*(){var n,r,i,s;const a=Object.assign({audio:!0,video:!0,useRealTracks:!1},e.publish),c=Object.assign({count:9,audio:!1,video:!0,aspectRatios:[1.66,1.7,1.3]},e.participants);if(this.handleDisconnect(),this.roomInfo=new Tp({sid:"RM_SIMULATED",name:"simulated-room",emptyTimeout:0,maxParticipants:0,creationTime:In.parse(new Date().getTime()),metadata:"",numParticipants:1,numPublishers:1,turnPassword:"",enabledCodecs:[],activeRecording:!1}),this.localParticipant.updateInfo(new ul({identity:"simulated-local",name:"local-name"})),this.setupLocalParticipantEvents(),this.emit(je.SignalConnected),this.emit(je.Connected),this.setAndEmitConnectionState(Xt.Connected),a.video){const h=new Gv(Te.Kind.Video,new nc({source:Xn.CAMERA,sid:Math.floor(Math.random()*1e4).toString(),type:Ki.AUDIO,name:"video-dummy"}),new Xf(a.useRealTracks&&(!((n=window.navigator.mediaDevices)===null||n===void 0)&&n.getUserMedia)?(yield window.navigator.mediaDevices.getUserMedia({video:!0})).getVideoTracks()[0]:xC(160*((r=c.aspectRatios[0])!==null&&r!==void 0?r:1),160,!0,!0),void 0,!1,{loggerName:this.options.loggerName,loggerContextCb:()=>this.logContext}),{loggerName:this.options.loggerName,loggerContextCb:()=>this.logContext});this.localParticipant.addTrackPublication(h),this.localParticipant.emit(Be.LocalTrackPublished,h)}if(a.audio){const h=new Gv(Te.Kind.Audio,new nc({source:Xn.MICROPHONE,sid:Math.floor(Math.random()*1e4).toString(),type:Ki.AUDIO}),new Jf(a.useRealTracks&&(!((i=navigator.mediaDevices)===null||i===void 0)&&i.getUserMedia)?(yield navigator.mediaDevices.getUserMedia({audio:!0})).getAudioTracks()[0]:k0(),void 0,!1,this.audioContext,{loggerName:this.options.loggerName,loggerContextCb:()=>this.logContext}),{loggerName:this.options.loggerName,loggerContextCb:()=>this.logContext});this.localParticipant.addTrackPublication(h),this.localParticipant.emit(Be.LocalTrackPublished,h)}for(let h=0;h<c.count-1;h+=1){let d=new ul({sid:Math.floor(Math.random()*1e4).toString(),identity:"simulated-".concat(h),state:cc.ACTIVE,tracks:[],joinedAt:In.parse(Date.now())});const f=this.getOrCreateParticipant(d.identity,d);if(c.video){const p=xC(160*((s=c.aspectRatios[h%c.aspectRatios.length])!==null&&s!==void 0?s:1),160,!1,!0),g=new nc({source:Xn.CAMERA,sid:Math.floor(Math.random()*1e4).toString(),type:Ki.AUDIO});f.addSubscribedMediaTrack(p,g.sid,new MediaStream([p]),new RTCRtpReceiver),d.tracks=[...d.tracks,g]}if(c.audio){const p=k0(),g=new nc({source:Xn.MICROPHONE,sid:Math.floor(Math.random()*1e4).toString(),type:Ki.AUDIO});f.addSubscribedMediaTrack(p,g.sid,new MediaStream([p]),new RTCRtpReceiver),d.tracks=[...d.tracks,g]}f.updateInfo(d)}})}emit(e){for(var n=arguments.length,r=new Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];if(e!==je.ActiveSpeakersChanged&&e!==je.TranscriptionReceived){const s=a_(r).filter(a=>a!==void 0);(e===je.TrackSubscribed||e===je.TrackUnsubscribed)&&this.log.trace("subscribe trace: ".concat(e),Object.assign(Object.assign({},this.logContext),{event:e,args:s})),this.log.debug("room event ".concat(e),Object.assign(Object.assign({},this.logContext),{event:e,args:s}))}return super.emit(e,...r)}}Nc.cleanupRegistry=typeof FinalizationRegistry<"u"&&new FinalizationRegistry(t=>{t()});function a_(t){return t.map(e=>{if(e)return Array.isArray(e)?a_(e):typeof e=="object"?"logContext"in e?e.logContext:void 0:e})}var Hi;(function(t){t[t.IDLE=0]="IDLE",t[t.RUNNING=1]="RUNNING",t[t.SKIPPED=2]="SKIPPED",t[t.SUCCESS=3]="SUCCESS",t[t.FAILED=4]="FAILED"})(Hi||(Hi={}));class vo extends Di.EventEmitter{constructor(e,n){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};super(),this.status=Hi.IDLE,this.logs=[],this.options={},this.url=e,this.token=n,this.name=this.constructor.name,this.room=new Nc(r.roomOptions),this.connectOptions=r.connectOptions,this.options=r}run(e){return H(this,void 0,void 0,function*(){if(this.status!==Hi.IDLE)throw Error("check is running already");this.setStatus(Hi.RUNNING);try{yield this.perform()}catch(n){n instanceof Error&&(this.options.errorsAsWarnings?this.appendWarning(n.message):this.appendError(n.message))}return yield this.disconnect(),yield new Promise(n=>setTimeout(n,500)),this.status!==Hi.SKIPPED&&this.setStatus(this.isSuccess()?Hi.SUCCESS:Hi.FAILED),e&&e(),this.getInfo()})}isSuccess(){return!this.logs.some(e=>e.level==="error")}connect(e){return H(this,void 0,void 0,function*(){return this.room.state===Xt.Connected?this.room:(e||(e=this.url),yield this.room.connect(e,this.token,this.connectOptions),this.room)})}disconnect(){return H(this,void 0,void 0,function*(){this.room&&this.room.state!==Xt.Disconnected&&(yield this.room.disconnect(),yield new Promise(e=>setTimeout(e,500)))})}skip(){this.setStatus(Hi.SKIPPED)}switchProtocol(e){return H(this,void 0,void 0,function*(){let n=!1,r=!1;if(this.room.on(je.Reconnecting,()=>{n=!0}),this.room.once(je.Reconnected,()=>{r=!0}),this.room.simulateScenario("force-".concat(e)),yield new Promise(s=>setTimeout(s,1e3)),!n)return;const i=Date.now()+1e4;for(;Date.now()<i;){if(r)return;yield Cr(100)}throw new Error("Could not reconnect using ".concat(e," protocol after 10 seconds"))})}appendMessage(e){this.logs.push({level:"info",message:e}),this.emit("update",this.getInfo())}appendWarning(e){this.logs.push({level:"warning",message:e}),this.emit("update",this.getInfo())}appendError(e){this.logs.push({level:"error",message:e}),this.emit("update",this.getInfo())}setStatus(e){this.status=e,this.emit("update",this.getInfo())}get engine(){var e;return(e=this.room)===null||e===void 0?void 0:e.engine}getInfo(){return{logs:this.logs,name:this.name,status:this.status,description:this.description}}}class xH extends vo{get description(){return"Cloud regions"}perform(){return H(this,void 0,void 0,function*(){const e=new qt(this.url,this.token);if(!e.isCloud()){this.skip();return}const n=[],r=new Set;for(let s=0;s<3;s++){const a=yield e.getNextBestRegionUrl();if(!a)break;if(r.has(a))continue;r.add(a);const c=yield this.checkCloudRegion(a);this.appendMessage("".concat(c.region," RTT: ").concat(c.rtt,"ms, duration: ").concat(c.duration,"ms")),n.push(c)}n.sort((s,a)=>(s.duration-a.duration)*.5+(s.rtt-a.rtt)*.5);const i=n[0];this.bestStats=i,this.appendMessage("best Cloud region: ".concat(i.region))})}getInfo(){const e=super.getInfo();return e.data=this.bestStats,e}checkCloudRegion(e){return H(this,void 0,void 0,function*(){var n,r;yield this.connect(e),this.options.protocol==="tcp"&&(yield this.switchProtocol("tcp"));const i=(n=this.room.serverInfo)===null||n===void 0?void 0:n.region;if(!i)throw new Error("Region not found");const s=yield this.room.localParticipant.streamText({topic:"test"}),a=1e3,h=1e6/a,d="A".repeat(a),f=Date.now();for(let k=0;k<h;k++)yield s.write(d);yield s.close();const p=Date.now(),g=yield(r=this.room.engine.pcManager)===null||r===void 0?void 0:r.publisher.getStats(),v={region:i,rtt:1e4,duration:p-f};return g==null||g.forEach(k=>{k.type==="candidate-pair"&&k.nominated&&(v.rtt=k.currentRoundTripTime*1e3)}),yield this.disconnect(),v})}}const I0=1e4;class bH extends vo{get description(){return"Connection via UDP vs TCP"}perform(){return H(this,void 0,void 0,function*(){const e=yield this.checkConnectionProtocol("udp"),n=yield this.checkConnectionProtocol("tcp");this.bestStats=e,e.qualityLimitationDurations.bandwidth-n.qualityLimitationDurations.bandwidth>.5||(e.packetsLost-n.packetsLost)/e.packetsSent>.01?(this.appendMessage("best connection quality via tcp"),this.bestStats=n):this.appendMessage("best connection quality via udp");const r=this.bestStats;this.appendMessage("upstream bitrate: ".concat((r.bitrateTotal/r.count/1e3/1e3).toFixed(2)," mbps")),this.appendMessage("RTT: ".concat((r.rttTotal/r.count*1e3).toFixed(2)," ms")),this.appendMessage("jitter: ".concat((r.jitterTotal/r.count*1e3).toFixed(2)," ms")),r.packetsLost>0&&this.appendWarning("packets lost: ".concat((r.packetsLost/r.packetsSent*100).toFixed(2),"%")),r.qualityLimitationDurations.bandwidth>1&&this.appendWarning("bandwidth limited ".concat((r.qualityLimitationDurations.bandwidth/(I0/1e3)*100).toFixed(2),"%")),r.qualityLimitationDurations.cpu>0&&this.appendWarning("cpu limited ".concat((r.qualityLimitationDurations.cpu/(I0/1e3)*100).toFixed(2),"%"))})}getInfo(){const e=super.getInfo();return e.data=this.bestStats,e}checkConnectionProtocol(e){return H(this,void 0,void 0,function*(){yield this.connect(),e==="tcp"?yield this.switchProtocol("tcp"):yield this.switchProtocol("udp");const n=document.createElement("canvas");n.width=1280,n.height=720;const r=n.getContext("2d");if(!r)throw new Error("Could not get canvas context");let i=0;const s=()=>{i=(i+1)%360,r.fillStyle="hsl(".concat(i,", 100%, 50%)"),r.fillRect(0,0,n.width,n.height),requestAnimationFrame(s)};s();const c=n.captureStream(30).getVideoTracks()[0],d=(yield this.room.localParticipant.publishTrack(c,{simulcast:!1,degradationPreference:"maintain-resolution",videoEncoding:{maxBitrate:2e6}})).track,f={protocol:e,packetsLost:0,packetsSent:0,qualityLimitationDurations:{},rttTotal:0,jitterTotal:0,bitrateTotal:0,count:0},p=setInterval(()=>H(this,void 0,void 0,function*(){const g=yield d.getRTCStatsReport();g==null||g.forEach(v=>{v.type==="outbound-rtp"?(f.packetsSent=v.packetsSent,f.qualityLimitationDurations=v.qualityLimitationDurations,f.bitrateTotal+=v.targetBitrate,f.count++):v.type==="remote-inbound-rtp"&&(f.packetsLost=v.packetsLost,f.rttTotal+=v.roundTripTime,f.jitterTotal+=v.jitter)})}),1e3);return yield new Promise(g=>setTimeout(g,I0)),clearInterval(p),c.stop(),n.remove(),yield this.disconnect(),f})}}class kH extends vo{get description(){return"Can publish audio"}perform(){return H(this,void 0,void 0,function*(){var e;const n=yield this.connect(),r=yield hH();if(yield DP(r,1e3))throw new Error("unable to detect audio from microphone");this.appendMessage("detected audio from microphone"),n.localParticipant.publishTrack(r),yield new Promise(c=>setTimeout(c,3e3));const s=yield(e=r.sender)===null||e===void 0?void 0:e.getStats();if(!s)throw new Error("Could not get RTCStats");let a=0;if(s.forEach(c=>{c.type==="outbound-rtp"&&(c.kind==="audio"||!c.kind&&c.mediaType==="audio")&&(a=c.packetsSent)}),a===0)throw new Error("Could not determine packets are sent");this.appendMessage("published ".concat(a," audio packets"))})}}class wH extends vo{get description(){return"Can publish video"}perform(){return H(this,void 0,void 0,function*(){var e;const n=yield this.connect(),r=yield dH();yield this.checkForVideo(r.mediaStreamTrack),n.localParticipant.publishTrack(r),yield new Promise(a=>setTimeout(a,5e3));const i=yield(e=r.sender)===null||e===void 0?void 0:e.getStats();if(!i)throw new Error("Could not get RTCStats");let s=0;if(i.forEach(a=>{a.type==="outbound-rtp"&&(a.kind==="video"||!a.kind&&a.mediaType==="video")&&(s+=a.packetsSent)}),s===0)throw new Error("Could not determine packets are sent");this.appendMessage("published ".concat(s," video packets"))})}checkForVideo(e){return H(this,void 0,void 0,function*(){const n=new MediaStream;n.addTrack(e.clone());const r=document.createElement("video");r.srcObject=n,r.muted=!0,r.autoplay=!0,r.playsInline=!0,r.setAttribute("playsinline","true"),document.body.appendChild(r),yield new Promise(i=>{r.onplay=()=>{setTimeout(()=>{var s,a,c,h;const d=document.createElement("canvas"),f=e.getSettings(),p=(a=(s=f.width)!==null&&s!==void 0?s:r.videoWidth)!==null&&a!==void 0?a:1280,g=(h=(c=f.height)!==null&&c!==void 0?c:r.videoHeight)!==null&&h!==void 0?h:720;d.width=p,d.height=g;const v=d.getContext("2d");v.drawImage(r,0,0);const w=v.getImageData(0,0,d.width,d.height).data;let S=!0;for(let T=0;T<w.length;T+=4)if(w[T]!==0||w[T+1]!==0||w[T+2]!==0){S=!1;break}S?this.appendError("camera appears to be producing only black frames"):this.appendMessage("received video frames"),i()},1e3)},r.play()}),n.getTracks().forEach(i=>i.stop()),r.remove()})}}class SH extends vo{get description(){return"Resuming connection after interruption"}perform(){return H(this,void 0,void 0,function*(){var e;const n=yield this.connect();let r=!1,i=!1,s;const a=new Promise(d=>{setTimeout(d,5e3),s=d}),c=()=>{r=!0};n.on(je.SignalReconnecting,c).on(je.Reconnecting,c).on(je.Reconnected,()=>{i=!0,s(!0)}),(e=n.engine.client.ws)===null||e===void 0||e.close();const h=n.engine.client.onClose;if(h&&h(""),yield a,r){if(!i||n.state!==Xt.Connected)throw this.appendWarning("reconnection is only possible in Redis-based configurations"),new Error("Not able to reconnect")}else throw new Error("Did not attempt to reconnect")})}}class CH extends vo{get description(){return"Can connect via TURN"}perform(){return H(this,void 0,void 0,function*(){var e,n,r;Sc(new URL(this.url))&&(this.appendMessage("Using region specific url"),this.url=(e=yield new qt(this.url,this.token).getNextBestRegionUrl())!==null&&e!==void 0?e:this.url);const i=new Ex,s=yield i.join(this.url,this.token,{autoSubscribe:!0,maxRetries:0,e2eeEnabled:!1,websocketTimeout:15e3},void 0,!0);let a=!1,c=!1,h=!1;for(let d of s.iceServers)for(let f of d.urls)f.startsWith("turn:")?(c=!0,h=!0):f.startsWith("turns:")&&(c=!0,h=!0,a=!0),f.startsWith("stun:")&&(h=!0);h?c&&!a&&this.appendWarning("TURN is configured server side, but TURN/TLS is unavailable."):this.appendWarning("No STUN servers configured on server side."),yield i.close(),!((r=(n=this.connectOptions)===null||n===void 0?void 0:n.rtcConfig)===null||r===void 0)&&r.iceServers||c?yield this.room.connect(this.url,this.token,{rtcConfig:{iceTransportPolicy:"relay"}}):(this.appendWarning("No TURN servers configured."),this.skip(),yield new Promise(d=>setTimeout(d,0)))})}}class TH extends vo{get description(){return"Establishing WebRTC connection"}perform(){return H(this,void 0,void 0,function*(){let e=!1,n=!1;this.room.on(je.SignalConnected,()=>{var r;const i=this.room.engine.client.onTrickle;this.room.engine.client.onTrickle=(s,a)=>{if(s.candidate){const c=new RTCIceCandidate(s);let h="".concat(c.protocol," ").concat(c.address,":").concat(c.port," ").concat(c.type);c.address&&(NH(c.address)?h+=" (private)":c.protocol==="tcp"&&c.tcpType==="passive"?(e=!0,h+=" (passive)"):c.protocol==="udp"&&(n=!0)),this.appendMessage(h)}i&&i(s,a)},!((r=this.room.engine.pcManager)===null||r===void 0)&&r.subscriber&&(this.room.engine.pcManager.subscriber.onIceCandidateError=s=>{s instanceof RTCPeerConnectionIceErrorEvent&&this.appendWarning("error with ICE candidate: ".concat(s.errorCode," ").concat(s.errorText," ").concat(s.url))})});try{yield this.connect(),Tt.info("now the room is connected")}catch(r){throw this.appendWarning("ports need to be open on firewall in order to connect."),r}e||this.appendWarning("Server is not configured for ICE/TCP"),n||this.appendWarning("No public IPv4 UDP candidates were found. Your server is likely not configured correctly")})}}function NH(t){const e=t.split(".");if(e.length===4){if(e[0]==="10")return!0;if(e[0]==="192"&&e[1]==="168")return!0;if(e[0]==="172"){const n=parseInt(e[1],10);if(n>=16&&n<=31)return!0}}return!1}class EH extends vo{get description(){return"Connecting to signal connection via WebSocket"}perform(){return H(this,void 0,void 0,function*(){var e,n,r;(this.url.startsWith("ws:")||this.url.startsWith("http:"))&&this.appendWarning("Server is insecure, clients may block connections to it");let i=new Ex,s;try{s=yield i.join(this.url,this.token,{autoSubscribe:!0,maxRetries:0,e2eeEnabled:!1,websocketTimeout:15e3},void 0,!0)}catch(a){if(Sc(new URL(this.url))){this.appendMessage("Initial connection failed with error ".concat(a.message,". Retrying with region fallback"));const h=yield new qt(this.url,this.token).getNextBestRegionUrl();h&&(s=yield i.join(h,this.token,{autoSubscribe:!0,maxRetries:0,e2eeEnabled:!1,websocketTimeout:15e3},void 0,!0),this.appendMessage("Fallback to region worked. To avoid initial connections failing, ensure you're calling room.prepareConnection() ahead of time"))}}s?(this.appendMessage("Connected to server, version ".concat(s.serverVersion,".")),((e=s.serverInfo)===null||e===void 0?void 0:e.edition)===A2.Cloud&&(!((n=s.serverInfo)===null||n===void 0)&&n.region)&&this.appendMessage("LiveKit Cloud: ".concat((r=s.serverInfo)===null||r===void 0?void 0:r.region))):this.appendError("Websocket connection could not be established"),yield i.close()})}}class QX extends Di.EventEmitter{constructor(e,n){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};super(),this.options={},this.checkResults=new Map,this.url=e,this.token=n,this.options=r}getNextCheckId(){const e=this.checkResults.size;return this.checkResults.set(e,{logs:[],status:Hi.IDLE,name:"",description:""}),e}updateCheck(e,n){this.checkResults.set(e,n),this.emit("checkUpdate",e,n)}isSuccess(){return Array.from(this.checkResults.values()).every(e=>e.status!==Hi.FAILED)}getResults(){return Array.from(this.checkResults.values())}createAndRunCheck(e){return H(this,void 0,void 0,function*(){const n=this.getNextCheckId(),r=new e(this.url,this.token,this.options),i=a=>{this.updateCheck(n,a)};r.on("update",i);const s=yield r.run();return r.off("update",i),s})}checkWebsocket(){return H(this,void 0,void 0,function*(){return this.createAndRunCheck(EH)})}checkWebRTC(){return H(this,void 0,void 0,function*(){return this.createAndRunCheck(TH)})}checkTURN(){return H(this,void 0,void 0,function*(){return this.createAndRunCheck(CH)})}checkReconnect(){return H(this,void 0,void 0,function*(){return this.createAndRunCheck(SH)})}checkPublishAudio(){return H(this,void 0,void 0,function*(){return this.createAndRunCheck(kH)})}checkPublishVideo(){return H(this,void 0,void 0,function*(){return this.createAndRunCheck(wH)})}checkConnectionProtocol(){return H(this,void 0,void 0,function*(){const e=yield this.createAndRunCheck(bH);if(e.data&&"protocol"in e.data){const n=e.data;this.options.protocol=n.protocol}return e})}checkCloudRegion(){return H(this,void 0,void 0,function*(){return this.createAndRunCheck(xH)})}}function Ut(t,e,n){return(e=PH(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function jH(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function PH(t){var e=jH(t,"string");return typeof e=="symbol"?e:e+""}new TextEncoder;new TextDecoder;class Or extends Error{constructor(e,n){var r;super(e,n),Ut(this,"code","ERR_JOSE_GENERIC"),this.name=this.constructor.name,(r=Error.captureStackTrace)===null||r===void 0||r.call(Error,this,this.constructor)}}Ut(Or,"code","ERR_JOSE_GENERIC");class _H extends Or{constructor(e,n){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:"unspecified",i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:"unspecified";super(e,{cause:{claim:r,reason:i,payload:n}}),Ut(this,"code","ERR_JWT_CLAIM_VALIDATION_FAILED"),Ut(this,"claim",void 0),Ut(this,"reason",void 0),Ut(this,"payload",void 0),this.claim=r,this.reason=i,this.payload=n}}Ut(_H,"code","ERR_JWT_CLAIM_VALIDATION_FAILED");class RH extends Or{constructor(e,n){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:"unspecified",i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:"unspecified";super(e,{cause:{claim:r,reason:i,payload:n}}),Ut(this,"code","ERR_JWT_EXPIRED"),Ut(this,"claim",void 0),Ut(this,"reason",void 0),Ut(this,"payload",void 0),this.claim=r,this.reason=i,this.payload=n}}Ut(RH,"code","ERR_JWT_EXPIRED");class IH extends Or{constructor(){super(...arguments),Ut(this,"code","ERR_JOSE_ALG_NOT_ALLOWED")}}Ut(IH,"code","ERR_JOSE_ALG_NOT_ALLOWED");class MH extends Or{constructor(){super(...arguments),Ut(this,"code","ERR_JOSE_NOT_SUPPORTED")}}Ut(MH,"code","ERR_JOSE_NOT_SUPPORTED");class DH extends Or{constructor(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"decryption operation failed",n=arguments.length>1?arguments[1]:void 0;super(e,n),Ut(this,"code","ERR_JWE_DECRYPTION_FAILED")}}Ut(DH,"code","ERR_JWE_DECRYPTION_FAILED");class AH extends Or{constructor(){super(...arguments),Ut(this,"code","ERR_JWE_INVALID")}}Ut(AH,"code","ERR_JWE_INVALID");class OH extends Or{constructor(){super(...arguments),Ut(this,"code","ERR_JWS_INVALID")}}Ut(OH,"code","ERR_JWS_INVALID");class LH extends Or{constructor(){super(...arguments),Ut(this,"code","ERR_JWT_INVALID")}}Ut(LH,"code","ERR_JWT_INVALID");class FH extends Or{constructor(){super(...arguments),Ut(this,"code","ERR_JWK_INVALID")}}Ut(FH,"code","ERR_JWK_INVALID");class UH extends Or{constructor(){super(...arguments),Ut(this,"code","ERR_JWKS_INVALID")}}Ut(UH,"code","ERR_JWKS_INVALID");class BH extends Or{constructor(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"no applicable key found in the JSON Web Key Set",n=arguments.length>1?arguments[1]:void 0;super(e,n),Ut(this,"code","ERR_JWKS_NO_MATCHING_KEY")}}Ut(BH,"code","ERR_JWKS_NO_MATCHING_KEY");class zH extends Or{constructor(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"multiple matching keys found in the JSON Web Key Set",n=arguments.length>1?arguments[1]:void 0;super(e,n),Ut(this,Symbol.asyncIterator,void 0),Ut(this,"code","ERR_JWKS_MULTIPLE_MATCHING_KEYS")}}Ut(zH,"code","ERR_JWKS_MULTIPLE_MATCHING_KEYS");class $H extends Or{constructor(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"request timed out",n=arguments.length>1?arguments[1]:void 0;super(e,n),Ut(this,"code","ERR_JWKS_TIMEOUT")}}Ut($H,"code","ERR_JWKS_TIMEOUT");class VH extends Or{constructor(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"signature verification failed",n=arguments.length>1?arguments[1]:void 0;super(e,n),Ut(this,"code","ERR_JWS_SIGNATURE_VERIFICATION_FAILED")}}Ut(VH,"code","ERR_JWS_SIGNATURE_VERIFICATION_FAILED");function WH({level:t,status:e,size:n}){const r=x.useRef(null),i=x.useRef(0);return x.useEffect(()=>{const s=r.current;if(!s)return;const a=s.getContext("2d");if(!a)return;let c;const h=()=>{const d=window.devicePixelRatio||1,f=n,p=n;s.width=f*d,s.height=p*d,s.style.width=`${f}px`,s.style.height=`${p}px`,a.setTransform(d,0,0,d,0,0);const g=f/2,v=p/2,k=f*.42;i.current+=e==="speaking"?.025:e==="listening"||e==="capturing"?.012:e==="thinking"?.018:.006;const w=i.current;a.clearRect(0,0,f,p),a.save(),a.beginPath(),a.arc(g,v,k,0,Math.PI*2),a.closePath(),a.clip();const S=5,T=e==="speaking"?.6+t*1.5:e==="capturing"?.5+t*1.2:e==="listening"?.35:e==="thinking"?.4+Math.sin(w*3)*.15:.12;for(let C=0;C<S;C++){const j=C/S*Math.PI*2,R=e==="speaking"?[78,205,196]:e==="thinking"?[108,138,255]:[0,217,255];a.beginPath(),a.lineWidth=1.2+T*1.5;const _=80;for(let M=0;M<=_;M++){const $=M/_*Math.PI*2,E=Math.cos($+w+j)*k*.6,P=Math.sin($*2+w*1.3+j)*k*.35,V=Math.sin($*3+w*2+j)*k*.15*T,F=Math.cos($*5-w*1.5+j*2)*k*.08*T,K=Math.sin($*7+w*3)*k*.05*T,J=g+E+V+K,Q=v+P+F;M===0?a.moveTo(J,Q):a.lineTo(J,Q)}const I=(.15+T*.4)*(1-C*.12);a.strokeStyle=`rgba(${R[0]}, ${R[1]}, ${R[2]}, ${I})`,a.stroke()}a.restore(),c=requestAnimationFrame(h)};return c=requestAnimationFrame(h),()=>cancelAnimationFrame(c)},[t,e,n]),o.jsx("canvas",{ref:r})}const HH=x.forwardRef(function(e,n){const[r,i]=x.useState("idle"),[s,a]=x.useState(null),[c,h]=x.useState(0),d=x.useRef(null),f=x.useRef(!1),p=x.useRef(!1),g=x.useRef(e);g.current=e,x.useImperativeHandle(n,()=>({start:k,stop:w,status:r,active:r!=="idle"&&r!=="error"}),[r]);const v=x.useCallback(()=>{if(d.current&&f.current){try{d.current.disconnect()}catch{}d.current=null}f.current=!1,p.current=!1,h(0)},[]);x.useEffect(()=>()=>v(),[v]);const k=async()=>{if(!(p.current||d.current)){p.current=!0,a(null),i("connecting");try{await we("/api/voice/sidecar/start",{method:"POST"});const C=Date.now(),j=await we("/api/voice/token",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({room:`daemora-${C}`,identity:`user-${C}`})});if(!j.ok)throw new Error(`Token request failed: ${j.status}`);const{token:R,url:_}=await j.json(),I=new Nc({adaptiveStream:!0,dynacast:!0,audioCaptureDefaults:{echoCancellation:!0,noiseSuppression:!0,autoGainControl:!0}});d.current=I,I.on(je.Connected,()=>{i("listening")}).on(je.Disconnected,()=>{i("idle"),v()}).on(je.TrackSubscribed,(M,L,$)=>{if(M.kind===Te.Kind.Audio){const E=M.attach();E.style.display="none",E.autoplay=!0,E.muted=!1,E.volume=1,document.body.appendChild(E),E.play().catch(P=>{console.warn("[voice] audio element play() rejected:",P)}),i("speaking")}}).on(je.TrackUnsubscribed,M=>{M.detach().forEach(L=>L.remove())}).on(je.TranscriptionReceived,(M,L)=>{var V,F,K,J,Q,Z,D,ne,A,z;const $=(L==null?void 0:L.identity)??"",E=$.startsWith("agent-")||$!==I.localParticipant.identity,P=$===I.localParticipant.identity;for(const ee of M)ee.final&&(!P&&(E||$.startsWith("agent"))?((F=(V=g.current).onAssistantDelta)==null||F.call(V,ee.text),(J=(K=g.current).onAssistantDone)==null||J.call(K)):P?(Z=(Q=g.current).onUserTranscript)==null||Z.call(Q,ee.text):((ne=(D=g.current).onAssistantDelta)==null||ne.call(D,ee.text),(z=(A=g.current).onAssistantDone)==null||z.call(A)))}).on(je.ActiveSpeakersChanged,M=>{const L=M.find(E=>E.identity===I.localParticipant.identity);h((L==null?void 0:L.audioLevel)??0),!M.some(E=>E.identity!==I.localParticipant.identity)&&r==="speaking"&&i("listening")}),await I.connect(_,R),f.current=!0;try{await I.startAudio()}catch(M){console.warn("[voice] startAudio failed:",M)}await I.localParticipant.setMicrophoneEnabled(!0)}catch(C){if(a((C==null?void 0:C.message)??"Failed to start voice"),i("error"),d.current){try{d.current.disconnect()}catch{}d.current=null}f.current=!1,p.current=!1,h(0)}}},w=()=>{if(i("idle"),d.current){try{d.current.disconnect()}catch{}d.current=null}f.current=!1,p.current=!1,h(0)},S={idle:"Tap to talk",connecting:"Connecting...",listening:"Listening...",capturing:"Hearing you...",thinking:"Thinking...",speaking:"Speaking...",error:s||"Error"}[r],T={idle:"text-gray-500",connecting:"text-yellow-400",listening:"text-emerald-400",capturing:"text-amber-400",thinking:"text-blue-400",speaking:"text-purple-400",error:"text-red-400"}[r];return o.jsxs("div",{className:"flex flex-col items-center gap-4 py-4",children:[o.jsx("div",{className:`text-[11px] font-mono tracking-wider uppercase ${T}`,children:S}),o.jsx("div",{className:"cursor-pointer",onClick:()=>r==="idle"||r==="error"?k():w(),children:o.jsx(WH,{level:c,status:r,size:180})}),r==="connecting"&&o.jsx($t,{className:"w-4 h-4 animate-spin text-yellow-400"}),r==="error"&&o.jsxs("div",{className:"flex items-center gap-2 text-red-400 text-xs font-mono",children:[o.jsx(Zi,{className:"w-3.5 h-3.5"}),o.jsx("span",{children:s})]})]})}),Xl="main";function qH(){var ue,ke,W;const[t,e]=x.useState([]),[n,r]=x.useState(""),[i,s]=x.useState(!1),[a,c]=x.useState(null),[h,d]=x.useState([]),[f,p]=x.useState(!1),[g,v]=x.useState(!1),k=x.useRef(null),w=x.useRef(null),S=x.useRef(null),T=x.useRef(null),C=x.useRef(sessionStorage.getItem("daemora_active_task")),j=x.useRef(null),[R,_]=x.useState("idle"),I=x.useRef(!1),[M,L]=x.useState([]),[$,E]=x.useState(!1),P=x.useRef(null);function V(q){return q.startsWith("image/")?"image":q.startsWith("audio/")?"audio":q.startsWith("video/")?"video":q==="application/pdf"||q.includes("officedocument")||q==="application/msword"||q==="application/vnd.ms-excel"?"document":"file"}function F(q){const fe=Array.from(q);if(fe.length===0)return;const ve=fe.slice(0,10).map(Se=>({id:`${Date.now()}-${Math.random().toString(36).slice(2,8)}`,file:Se,previewUrl:URL.createObjectURL(Se),kind:V(Se.type||"")}));L(Se=>[...Se,...ve].slice(0,10))}function K(q){L(fe=>{const ve=fe.find(Se=>Se.id===q);return ve&&URL.revokeObjectURL(ve.previewUrl),fe.filter(Se=>Se.id!==q)})}function J(q){return new Promise((fe,ve)=>{const Se=new FileReader;Se.onload=()=>{const Ke=Se.result,dt=Ke.indexOf(",");fe(dt>=0?Ke.slice(dt+1):Ke)},Se.onerror=()=>ve(Se.error??new Error("read failed")),Se.readAsDataURL(q)})}x.useEffect(()=>()=>{M.forEach(q=>URL.revokeObjectURL(q.previewUrl))},[]);const Q=async()=>{try{const q=await we(`/api/sessions/${Xl}`);if(q.ok){const fe=await q.json();e((fe.messages||[]).map(ve=>({...ve,content:ve.role==="user"?ve.content.replace(/^\[Voice mode:[^\]]+\]\s*/,""):ve.content,...ve.attachments&&ve.attachments.length>0?{attachments:ve.attachments.map(Se=>({kind:Se.kind,url:oe(Se.path),filename:Se.filename??Se.path.split("/").pop()??"file",mimeType:Se.mimeType}))}:{}})))}else await we("/api/sessions",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:Xl})})}catch(q){console.error("Failed to load session",q)}finally{p(!0)}},Z=async()=>{v(!1);try{await we(`/api/sessions/${Xl}`,{method:"DELETE"}),await we("/api/sessions",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:Xl})}),e([]),d([]),sessionStorage.removeItem("daemora_active_task"),me.success("Chat history cleared")}catch(q){console.error("Failed to clear history",q),me.error("Failed to clear history")}};x.useEffect(()=>{Q();const q=sessionStorage.getItem("daemora_active_task");q&&we(`/api/tasks/${q}`).then(fe=>fe.ok?fe.json():null).then(fe=>{fe&&(fe.status==="pending"||fe.status==="running")?(s(!0),c("Reconnecting..."),ne(q)):(sessionStorage.removeItem("daemora_active_task"),(fe==null?void 0:fe.status)==="completed"&&Q())}).catch(()=>sessionStorage.removeItem("daemora_active_task"))},[]),x.useEffect(()=>()=>{T.current&&(T.current.close(),T.current=null)},[]),x.useEffect(()=>{const q=new EventSource(X0(`/api/sessions/${Xl}/stream`));let fe=!1,ve=null;return q.addEventListener("task:created",Se=>{try{const Ke=JSON.parse(Se.data),dt=sessionStorage.getItem("daemora_active_task");if(I.current)return;if(Ke.taskId&&Ke.taskId!==dt&&Ke.input){ve=Ke.taskId;const Ge=String(Ke.input).replace(/^\[Voice mode:[^\]]+\]\s*/,"");e(_e=>{const Ve=_e[_e.length-1];return(Ve==null?void 0:Ve.role)==="user"&&(Ve==null?void 0:Ve.content)===Ge?_e:[..._e,{role:"user",content:Ge,timestamp:new Date().toISOString()}]}),fe=!1}}catch{}}),q.addEventListener("text:delta",Se=>{try{const Ke=JSON.parse(Se.data),dt=sessionStorage.getItem("daemora_active_task");if(!Ke.taskId||Ke.taskId===dt)return;const Ge=Ke.delta||"";if(!Ge)return;e(_e=>{if(!fe)return fe=!0,[..._e,{role:"assistant",content:Ge,timestamp:new Date().toISOString()}];const Ve=[..._e],xt=Ve[Ve.length-1];return xt&&xt.role==="assistant"&&(Ve[Ve.length-1]={...xt,content:xt.content+Ge}),Ve})}catch{}}),q.addEventListener("text:end",()=>{fe=!1}),q.addEventListener("task:completed",Se=>{try{const Ke=JSON.parse(Se.data),dt=sessionStorage.getItem("daemora_active_task");Ke!=null&&Ke.id&&Ke.id!==dt&&Q()}catch{}fe=!1,ve=null}),q.addEventListener("task:failed",()=>{fe=!1,ve=null}),()=>q.close()},[]);const D=async()=>{if(!n.trim()&&M.length===0)return;const q=i,fe=n.trim()||(M.length>0?"(see attached)":""),ve=M.map(Ge=>({kind:Ge.kind,url:Ge.previewUrl,filename:Ge.file.name,mimeType:Ge.file.type||"application/octet-stream"})),Se={role:"user",content:fe,timestamp:new Date().toISOString(),...ve.length>0?{attachments:ve}:{}};e(Ge=>[...Ge,Se]);const Ke=fe,dt=M;r(""),L([]),I.current=!0,q?c("Follow-up sent — agent will pick it up between steps"):(s(!0),c("Queuing..."),d([]));try{const Ge=dt.length>0?await Promise.all(dt.map(async xt=>({filename:xt.file.name||`paste-${Date.now()}`,mimeType:xt.file.type||"application/octet-stream",base64:await J(xt.file),kind:xt.kind}))):void 0,_e=await we("/api/chat",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({input:Ke,sessionId:Xl,...Ge?{attachments:Ge}:{}})});if(!_e.ok)throw new Error(`Error: ${_e.statusText}`);const Ve=await _e.json();if(q)return;if(Ve.taskId)ne(Ve.taskId),I.current=!1;else if(Ve.result){const xt={role:"assistant",content:Ve.result||"(No response from system)",timestamp:new Date().toISOString()};e(Pt=>[...Pt,xt]),s(!1),c(null)}}catch(Ge){const _e={role:"assistant",content:`**SYSTEM ERROR:** ${Ge.message}`,timestamp:new Date().toISOString()};e(Ve=>[...Ve,_e]),q||(s(!1),c(null))}},ne=q=>{T.current&&T.current.close(),C.current=q,sessionStorage.setItem("daemora_active_task",q);const fe=()=>{C.current=null,sessionStorage.removeItem("daemora_active_task")},ve=new EventSource(X0(`/api/tasks/${q}/stream`));T.current=ve,ve.addEventListener("task:state",Ge=>{const _e=JSON.parse(Ge.data);_e.status==="completed"&&_e.result?(fe(),s(!1),c(null),Q(),ve.close(),T.current=null):_e.status==="failed"?(fe(),e(Ve=>[...Ve,{role:"assistant",content:`**SYSTEM ERROR:** ${_e.error||"Task failed"}`,timestamp:new Date().toISOString()}]),s(!1),c(null),ve.close(),T.current=null):_e.status==="running"&&c("Processing...")}),ve.addEventListener("model:called",Ge=>{try{const _e=JSON.parse(Ge.data),Ve=_e.iteration||_e.loop||"";c(`Thinking${Ve?` (step ${Ve})`:""}...`)}catch{c("Thinking...")}});const Se=Ge=>{if(!Ge)return"";try{if(Array.isArray(Ge)){const _e=Ge.find(Ve=>typeof Ve=="string");return _e?_e.length>40?_e.slice(0,40)+"…":_e:""}if(typeof Ge=="object")for(const _e of["path","file","filePath","url","query","command","prompt","name"]){const Ve=Ge[_e];if(typeof Ve=="string"&&Ve)return Ve.length>40?Ve.slice(0,40)+"…":Ve}if(typeof Ge=="string")return Ge.length>40?Ge.slice(0,40)+"…":Ge}catch{}return""};ve.addEventListener("tool:before",Ge=>{try{const _e=JSON.parse(Ge.data),Ve=_e.tool_name||_e.tool||"tool",xt=Se(_e.params),Pt=`${Ve}-${Date.now()}-${Math.random().toString(36).slice(2,7)}`;d(mn=>[...mn,{id:Pt,name:Ve,status:"running",preview:xt}]),c(`Running ${Ve}${xt?` · ${xt}`:""}...`)}catch{}}),ve.addEventListener("tool:after",Ge=>{try{const _e=JSON.parse(Ge.data),Ve=_e.tool_name||_e.tool||"tool",xt=typeof _e.duration=="number"?_e.duration:void 0,Pt=_e.error?"error":"done";d(mn=>{const gn=[...mn];for(let jn=gn.length-1;jn>=0;jn--)if(gn[jn].name===Ve&&gn[jn].status==="running")return gn[jn]={...gn[jn],status:Pt,durationMs:xt},gn;return gn}),c(Pt==="error"?`${Ve} failed`:`Using ${Ve}...`)}catch{c("Using tool...")}}),ve.addEventListener("agent:spawned",Ge=>{try{const _e=JSON.parse(Ge.data);c(`Sub-agent spawned${_e.role?`: ${_e.role}`:""}...`)}catch{c("Sub-agent working...")}}),ve.addEventListener("agent:finished",()=>{c("Sub-agent completed, continuing...")});let Ke=!1;ve.addEventListener("text:delta",Ge=>{try{const Ve=JSON.parse(Ge.data).delta||"";if(!Ve)return;c(null),e(xt=>{if(!Ke)return Ke=!0,[...xt,{role:"assistant",content:Ve,timestamp:new Date().toISOString()}];const Pt=[...xt],mn=Pt[Pt.length-1];return mn&&mn.role==="assistant"&&(Pt[Pt.length-1]={...mn,content:mn.content+Ve}),Pt})}catch{}}),ve.addEventListener("text:end",()=>{Ke=!1}),ve.addEventListener("task:completed",Ge=>{fe(),Q(),s(!1),c(null),d([]),ve.close(),T.current=null}),ve.addEventListener("task:failed",Ge=>{fe();const _e=JSON.parse(Ge.data);e(Ve=>[...Ve,{role:"assistant",content:`**SYSTEM ERROR:** ${_e.error||"Task failed"}`,timestamp:new Date().toISOString()}]),s(!1),c(null),ve.close(),T.current=null});let dt=0;ve.onerror=()=>{dt++,(ve.readyState===EventSource.CLOSED||dt>=3)&&(fe(),s(!1),c(null),ve.close(),T.current=null)}},A=()=>{var q;(q=w.current)==null||q.scrollIntoView({behavior:"smooth"})};x.useEffect(()=>{requestAnimationFrame(()=>A())},[t,i]);const z=q=>{const fe=new Date(q);return isNaN(fe.getTime())?new Date().toLocaleTimeString():fe.toLocaleTimeString()},ee=/\.(png|jpg|jpeg|gif|webp|svg|avif|bmp)$/i,B=/\.(mp4|webm|mov|avi|mkv)$/i,X=/\.(mp3|wav|ogg|flac|m4a|aac)$/i,ye=/(?:^|[\s:])(\/?(?:[\w.-]+\/)*[\w.-]+\.(?:png|jpg|jpeg|gif|webp|svg|avif|mp4|webm|mov|mp3|wav|ogg|flac|m4a|pdf|docx|xlsx|pptx|txt|csv|zip))\b/gi;function se(q){const fe=q.match(ye);if(!fe)return[];const ve=new Set;return fe.map(Se=>Se.trim().replace(/^[:\s]+/,"")).filter(Se=>Se.includes("/")&&!ve.has(Se)&&(ve.add(Se),!0)).map(Se=>({path:Se,type:ee.test(Se)?"image":B.test(Se)?"video":X.test(Se)?"audio":"file"}))}function oe(q){var ve;const fe=((ve=document.querySelector('meta[name="api-token"]'))==null?void 0:ve.getAttribute("content"))||"";return`/api/file?path=${encodeURIComponent(q)}&token=${encodeURIComponent(fe)}`}const U=()=>a?a.startsWith("Using ")?o.jsx(PN,{className:"w-3 h-3 text-[#00d9ff] animate-pulse"}):a.startsWith("Thinking")?o.jsx(Q0,{className:"w-3 h-3 text-[#00d9ff] animate-pulse"}):a.startsWith("Sub-agent")?o.jsx(td,{className:"w-3 h-3 text-[#00d9ff] animate-pulse"}):o.jsx($t,{className:"w-3 h-3 text-[#00d9ff] animate-spin"}):null;return o.jsx("div",{className:"flex h-full",children:o.jsxs("div",{className:"flex-1 flex flex-col bg-slate-950/20 overflow-hidden relative min-w-0",children:[o.jsx("div",{className:"absolute inset-0 opacity-[0.03] pointer-events-none bg-[url('https://grainy-gradients.vercel.app/noise.svg')] bg-repeat"}),o.jsxs("div",{className:"flex items-center px-4 py-3 border-b border-slate-800/50 bg-slate-900/40 backdrop-blur-md z-10 h-14 gap-3",children:[o.jsx("div",{className:"flex-1"}),o.jsxs("div",{className:"flex items-center gap-2.5",children:[o.jsx("div",{className:"animate-[bounce-slow_2s_ease-in-out_infinite]",children:o.jsx(Xo,{size:28})}),o.jsx("h2",{className:"text-base font-bold bg-gradient-to-r from-white via-[#00d9ff] to-[#4ECDC4] bg-clip-text text-transparent tracking-tight",children:"Daemora"})]}),o.jsx("div",{className:"flex-1 flex justify-end",children:o.jsxs("button",{onClick:()=>v(!0),disabled:i||t.length===0,title:"Delete chat history",className:"flex items-center gap-1.5 px-2.5 py-1.5 rounded-md text-[11px] font-mono uppercase tracking-wider text-gray-400 hover:text-red-400 hover:bg-red-500/10 border border-slate-800/60 hover:border-red-500/30 transition-colors disabled:opacity-30 disabled:cursor-not-allowed disabled:hover:text-gray-400 disabled:hover:bg-transparent disabled:hover:border-slate-800/60",children:[o.jsx(qn,{className:"w-3.5 h-3.5"}),o.jsx("span",{children:"Clear"})]})})]}),o.jsx(js,{open:g,onOpenChange:v,children:o.jsxs(Ps,{className:"bg-slate-950 border-slate-800/80 text-gray-200 font-mono",children:[o.jsxs(_s,{children:[o.jsxs(Is,{className:"text-white tracking-tight flex items-center gap-2",children:[o.jsx(qn,{className:"w-4 h-4 text-red-400"}),"Clear chat history"]}),o.jsx(Ms,{className:"text-gray-400 text-sm leading-relaxed",children:"This will permanently delete all messages in the current session. This action cannot be undone."})]}),o.jsxs(Rs,{children:[o.jsx(As,{className:"bg-slate-900 border-slate-800 text-gray-300 hover:bg-slate-800 hover:text-white",children:"Cancel"}),o.jsx(Ds,{onClick:Z,className:"bg-red-600 hover:bg-red-500 text-white border border-red-500/40",children:"Delete history"})]})]})}),o.jsxs("div",{className:"flex-1 min-h-0 relative z-10 flex flex-col",children:[o.jsx(sE,{className:"flex-1 min-h-0",ref:k,children:o.jsxs("div",{className:"max-w-5xl mx-auto py-6 px-4 sm:px-6 lg:px-8 space-y-5",children:[f?t.length===0?o.jsxs("div",{className:"flex flex-col items-center py-24 gap-4",children:[o.jsx("div",{className:"animate-[bounce-slow_2s_ease-in-out_infinite]",children:o.jsx(Xo,{size:64})}),o.jsxs("h2",{className:"text-lg font-bold bg-gradient-to-r from-white via-[#00d9ff] to-[#4ECDC4] bg-clip-text text-transparent",children:["Dae",o.jsx("span",{className:"text-[#ff4444]",children:"mora"})]}),o.jsx("p",{className:"text-[10px] text-gray-600 font-mono uppercase tracking-widest",children:"Send a message to begin"})]}):t.map((q,fe)=>o.jsxs("div",{className:`flex gap-3 animate-in slide-in-from-bottom-2 duration-300 ${q.role==="user"?"flex-row-reverse":""}`,children:[q.role==="assistant"&&o.jsx("div",{className:"w-7 h-7 rounded-lg bg-slate-950 border border-slate-800/80 p-1 flex-shrink-0 flex items-center justify-center shadow-lg mt-1",children:o.jsx(Xo,{size:18})}),o.jsx("div",{className:"max-w-[92%] sm:max-w-[88%] lg:max-w-[85%]",children:o.jsxs("div",{className:`rounded-lg p-4 shadow-md border transition-all ${q.role==="user"?"bg-[#00d9ff]/5 border-[#00d9ff]/20 text-white":"bg-slate-800/30 border-slate-800 text-gray-100"}`,children:[q.role==="assistant"?o.jsxs("div",{className:"space-y-3",children:[o.jsx("div",{className:"prose prose-invert prose-sm max-w-none font-mono leading-relaxed text-[13px]",children:o.jsx(Oj,{remarkPlugins:[a2],children:q.content})}),se(q.content).map((ve,Se)=>o.jsxs("div",{className:"mt-2",children:[ve.type==="image"&&o.jsx("a",{href:oe(ve.path),target:"_blank",rel:"noopener noreferrer",children:o.jsx("img",{src:oe(ve.path),alt:ve.path.split("/").pop(),className:"rounded-lg border border-slate-700/50 max-w-full max-h-[400px] object-contain shadow-lg hover:opacity-90 transition-opacity cursor-pointer",onError:Ke=>Ke.currentTarget.style.display="none"})}),ve.type==="video"&&o.jsx("video",{src:oe(ve.path),controls:!0,className:"rounded-lg border border-slate-700/50 max-w-full max-h-[400px] shadow-lg"}),ve.type==="audio"&&o.jsx("audio",{src:oe(ve.path),controls:!0,className:"w-full"}),ve.type==="file"&&o.jsxs("a",{href:oe(ve.path),download:!0,className:"inline-flex items-center gap-2 px-3 py-2 rounded-lg bg-slate-800/50 border border-slate-700/50 text-[11px] font-mono text-[#00d9ff] hover:bg-slate-700/50 transition-colors",children:[o.jsx(kN,{className:"w-3.5 h-3.5"}),ve.path.split("/").pop()]})]},Se))]}):o.jsxs("div",{className:"space-y-2",children:[q.attachments&&q.attachments.length>0&&o.jsx("div",{className:"flex flex-wrap gap-2",children:q.attachments.map((ve,Se)=>o.jsx("div",{children:ve.kind==="image"?o.jsx("a",{href:ve.url,target:"_blank",rel:"noopener noreferrer",children:o.jsx("img",{src:ve.url,alt:ve.filename,className:"rounded-lg border border-[#00d9ff]/20 max-w-[240px] max-h-[240px] object-contain bg-slate-950/40 hover:opacity-90 transition-opacity cursor-pointer",onError:Ke=>Ke.currentTarget.style.display="none"})}):ve.kind==="audio"?o.jsx("audio",{src:ve.url,controls:!0,className:"max-w-[320px]"}):ve.kind==="video"?o.jsx("video",{src:ve.url,controls:!0,className:"rounded-lg max-w-[320px] max-h-[240px]"}):o.jsxs("a",{href:ve.url,download:ve.filename,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 px-3 py-2 rounded-lg bg-slate-900/60 border border-[#00d9ff]/20 text-[11px] font-mono text-[#00d9ff] hover:bg-slate-800/60 transition-colors max-w-[240px]",children:[o.jsx(b1,{className:"w-3.5 h-3.5 flex-shrink-0"}),o.jsx("span",{className:"truncate",children:ve.filename})]})},Se))}),q.content&&o.jsx("p",{className:"whitespace-pre-wrap font-sans text-[14px] leading-relaxed tracking-tight",children:q.content})]}),o.jsxs("div",{className:"text-[8px] text-gray-600 mt-2 font-mono uppercase tracking-widest flex justify-between items-center border-t border-slate-800/20 pt-2 opacity-50",children:[o.jsxs("span",{className:"flex items-center gap-2",children:[q.role==="user"?o.jsx(tv,{className:"w-3 h-3"}):o.jsx(Ny,{className:"w-3 h-3"}),q.role==="user"?"Link":"Core"]}),o.jsx("span",{children:z(q.timestamp)})]})]})}),q.role==="user"&&o.jsx("div",{className:"w-7 h-7 rounded-lg bg-gradient-to-br from-[#00d9ff] to-[#4ECDC4] flex items-center justify-center flex-shrink-0 shadow-lg border border-white/10 p-1.5 mt-1",children:o.jsx(tv,{className:"w-full h-full text-white"})})]},fe)):o.jsxs("div",{className:"flex flex-col items-center py-24 gap-3 opacity-50",children:[o.jsx($t,{className:"w-5 h-5 text-[#00d9ff] animate-spin"}),o.jsx("span",{className:"text-[9px] font-mono text-gray-600 uppercase tracking-widest",children:"Loading..."})]}),i&&(()=>{const q=t[t.length-1],fe=(q==null?void 0:q.role)==="assistant"&&(q==null?void 0:q.content),ve=h.length>0?o.jsx("div",{className:"flex flex-col gap-1 font-mono",children:h.slice(-6).map(Se=>o.jsxs("div",{className:"flex items-center gap-2 text-[10px]",children:[Se.status==="running"&&o.jsx($t,{className:"w-3 h-3 text-[#00d9ff] animate-spin flex-shrink-0"}),Se.status==="done"&&o.jsx(nd,{className:"w-3 h-3 text-[#4ECDC4] flex-shrink-0"}),Se.status==="error"&&o.jsx(ol,{className:"w-3 h-3 text-red-400 flex-shrink-0"}),o.jsx("span",{className:`tracking-wider uppercase ${Se.status==="running"?"text-[#00d9ff]":"text-gray-500"}`,children:Se.name}),Se.preview&&o.jsx("span",{className:"text-gray-600 truncate normal-case tracking-normal",children:Se.preview}),typeof Se.durationMs=="number"&&Se.status!=="running"&&o.jsx("span",{className:"text-gray-700 text-[9px] ml-auto",children:Se.durationMs<1e3?`${Se.durationMs}ms`:`${(Se.durationMs/1e3).toFixed(1)}s`})]},Se.id))}):null;return fe?!a&&!ve?null:o.jsxs("div",{className:"flex flex-col gap-1 pl-10 -mt-2 mb-2 opacity-70",children:[ve,a&&o.jsxs("div",{className:"flex items-center gap-2",children:[U(),o.jsx("span",{className:"text-[9px] text-[#00d9ff]/70 font-mono tracking-[0.2em] uppercase",children:a})]})]}):o.jsxs("div",{className:"flex gap-3",children:[o.jsx("div",{className:"w-7 h-7 rounded-lg bg-slate-950 border border-slate-800/80 p-1 flex-shrink-0 flex items-center justify-center",children:o.jsx(Xo,{size:18})}),o.jsx("div",{className:"max-w-[88%]",children:o.jsxs("div",{className:"rounded-lg p-4 bg-slate-800/30 border border-slate-800 flex flex-col gap-2",children:[ve,o.jsxs("div",{className:"flex items-center gap-3",children:[U(),o.jsx("span",{className:"text-[9px] text-[#00d9ff] font-mono tracking-[0.2em] uppercase animate-pulse",children:a||"Processing..."})]})]})})]})})(),o.jsx("div",{ref:w})]})}),o.jsx(HH,{ref:j,onUserTranscript:q=>{const fe=q.trim();fe&&e(ve=>[...ve,{role:"user",content:fe,timestamp:new Date().toISOString()}])},onAssistantDelta:q=>{q&&e(fe=>{const ve=fe[fe.length-1];return ve&&ve.role==="assistant"?[...fe.slice(0,-1),{...ve,content:ve.content+q}]:[...fe,{role:"assistant",content:q,timestamp:new Date().toISOString()}]})},onAssistantDone:()=>{}}),o.jsx("div",{className:"px-3 sm:px-4 pb-3 sm:pb-4 pt-2 backdrop-blur-xl shrink-0",children:o.jsxs("div",{className:"max-w-5xl mx-auto w-full",onDragOver:q=>{q.preventDefault(),E(!0)},onDragLeave:()=>E(!1),onDrop:q=>{q.preventDefault(),E(!1),q.dataTransfer.files.length&&F(q.dataTransfer.files)},children:[M.length>0&&o.jsx("div",{className:"flex flex-wrap gap-2 mb-2 px-1",children:M.map(q=>o.jsxs("div",{className:"relative group",children:[q.kind==="image"?o.jsx("img",{src:q.previewUrl,alt:q.file.name,className:"w-20 h-20 object-cover rounded-xl border border-slate-700/60 bg-slate-900"}):o.jsxs("div",{className:"w-20 h-20 rounded-xl border border-slate-700/60 bg-slate-900 flex flex-col items-center justify-center p-1",children:[o.jsx(b1,{className:"w-5 h-5 text-[#00d9ff] mb-1"}),o.jsx("span",{className:"text-[8px] text-gray-400 font-mono text-center truncate w-full",children:q.file.name})]}),o.jsx("button",{type:"button",onClick:()=>K(q.id),className:"absolute -top-1.5 -right-1.5 w-5 h-5 rounded-full bg-slate-950 border border-slate-700 flex items-center justify-center opacity-80 group-hover:opacity-100 hover:bg-red-500/20 hover:border-red-500/40 transition-all",title:"Remove",children:o.jsx(ol,{className:"w-3 h-3 text-gray-300"})})]},q.id))}),o.jsxs("div",{className:`flex items-end gap-2 bg-slate-800/60 border rounded-2xl px-3 py-2 shadow-[0_0_30px_rgba(0,0,0,0.3)] transition-all ${$?"border-[#00d9ff] ring-2 ring-[#00d9ff]/30":"border-slate-700/50 focus-within:border-[#00d9ff]/30"}`,children:[o.jsx("input",{ref:P,type:"file",multiple:!0,className:"hidden",onChange:q=>{q.target.files&&F(q.target.files),q.target.value=""}}),o.jsx("button",{type:"button",onClick:()=>{var q;return(q=P.current)==null?void 0:q.click()},title:"Attach files",className:"flex-shrink-0 w-9 h-9 rounded-full flex items-center justify-center text-gray-500 hover:text-[#00d9ff] hover:bg-slate-700/60 transition-all",children:o.jsx(ED,{className:"w-4 h-4"})}),o.jsx(LO,{ref:S,value:n,onChange:q=>r(q.target.value),onKeyDown:q=>{q.key==="Enter"&&!q.shiftKey&&(q.preventDefault(),D())},onPaste:q=>{var Se;const fe=(Se=q.clipboardData)==null?void 0:Se.items;if(!fe)return;const ve=[];for(const Ke of fe)if(Ke.kind==="file"){const dt=Ke.getAsFile();dt&&ve.push(dt)}ve.length>0&&(q.preventDefault(),F(ve))},placeholder:i?"Send a follow-up...":M.length>0?"Add a message or just send...":"Ask anything — paste or drop files",className:"flex-1 min-h-[40px] max-h-[120px] bg-transparent border-0 text-white placeholder:text-gray-500 focus-visible:ring-0 focus-visible:ring-offset-0 text-sm px-2 py-2.5 resize-none shadow-none leading-relaxed"}),o.jsx("button",{onClick:D,disabled:!n.trim()&&M.length===0,className:`flex-shrink-0 w-9 h-9 rounded-full flex items-center justify-center transition-all ${n.trim()||M.length>0?"bg-gradient-to-r from-[#00d9ff] to-[#4ECDC4] text-slate-950 shadow-[0_0_15px_rgba(0,217,255,0.3)]":"bg-slate-700/50 text-gray-600"}`,children:o.jsx(M3,{className:"w-4 h-4"})}),o.jsx("button",{onClick:()=>{const q=j.current;q&&(q.active?q.stop():q.start(),setTimeout(()=>{var fe;return _(((fe=j.current)==null?void 0:fe.status)||"idle")},150))},title:(ue=j.current)!=null&&ue.active?"End voice":"Start voice",className:`flex-shrink-0 w-9 h-9 rounded-full flex items-center justify-center transition-all ${(ke=j.current)!=null&&ke.active?"bg-gradient-to-br from-[#00d9ff] to-[#4ECDC4] text-slate-950 shadow-[0_0_12px_rgba(0,217,255,0.3)]":"bg-slate-700/50 text-gray-500 hover:text-[#00d9ff] hover:bg-slate-700"}`,children:(W=j.current)!=null&&W.active?o.jsx(RD,{className:"w-4 h-4"}):o.jsx(ev,{className:"w-4 h-4"})})]}),o.jsx("div",{className:"text-center mt-1.5",children:o.jsx("span",{className:"text-[8px] text-gray-700 font-mono tracking-widest uppercase",children:"Enter to send // Shift+Enter for newline"})})]})})]})]})})}function Dt({className:t,type:e,...n}){return o.jsx("input",{type:e,"data-slot":"input",className:St("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-md border px-3 py-1 text-base bg-input-background 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","focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]","aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",t),...n})}const KH=[{value:"all",label:"All",color:"text-gray-400 border-gray-700"},{value:"running",label:"Running",color:"text-[#ffaa00] border-[#ffaa00]/30"},{value:"completed",label:"Completed",color:"text-[#00ff88] border-[#00ff88]/30"},{value:"failed",label:"Failed",color:"text-[#ff4458] border-[#ff4458]/30"}];function nT(){const[t,e]=x.useState([]),[n,r]=x.useState(!0),[i,s]=x.useState(""),[a,c]=x.useState("all"),[h,d]=x.useState(new Set),[f,p]=x.useState({}),[g,v]=x.useState({open:!1,title:"",onConfirm:()=>{}}),k=async()=>{try{const E=await we("/api/tasks?limit=100");if(E.ok){const P=await E.json();e(P.tasks||[])}}catch(E){console.error("Failed to fetch logs",E)}finally{r(!1)}};x.useEffect(()=>{r(!0),k();const E=setInterval(k,1e4);return()=>clearInterval(E)},[]);const w=async E=>{const P=new Set(h);if(P.has(E))P.delete(E);else if(P.add(E),!f[E])try{const V=await we(`/api/tasks/${E}/children`);if(V.ok){const F=await V.json();p(K=>({...K,[E]:F.children||[]}))}}catch{}d(P)},S=(E,P,V)=>{if(E.preventDefault(),E.stopPropagation(),V==="running"){me.error("Cannot delete a running entry");return}v({open:!0,title:"Delete this log entry?",description:"This action cannot be undone.",onConfirm:async()=>{const F=me.loading("Deleting...");try{const K=await we(`/api/tasks/${P}`,{method:"DELETE"});if(K.ok)me.success("Entry deleted",{id:F}),k();else{const J=await K.json();me.error(J.error||"Failed to delete",{id:F})}}catch(K){me.error(K.message,{id:F})}}})},T=t.filter(E=>!E.parentTaskId).filter(E=>a==="all"||E.status===a||a==="running"&&E.status==="in_progress").filter(E=>(E.title||E.input||"").toLowerCase().includes(i.toLowerCase())||E.id.toLowerCase().includes(i.toLowerCase())),C=({status:E})=>E==="running"||E==="in_progress"?o.jsx("div",{className:"w-2 h-2 rounded-full bg-[#ffaa00] animate-pulse"}):E==="completed"?o.jsx("div",{className:"w-2 h-2 rounded-full bg-[#00ff88]"}):E==="failed"?o.jsx("div",{className:"w-2 h-2 rounded-full bg-[#ff4458]"}):o.jsx("div",{className:"w-2 h-2 rounded-full bg-gray-600"}),j=({cost:E})=>typeof E=="object"&&(E!=null&&E.estimatedCost)?o.jsxs("span",{children:["$",E.estimatedCost.toFixed(4)]}):typeof E=="number"&&E>0?o.jsxs("span",{children:["$",E.toFixed(4)]}):o.jsx("span",{className:"text-gray-700",children:"-"}),R=(E,P)=>{if(!E)return null;const V=new Date(E).getTime(),F=P?new Date(P).getTime():Date.now(),K=Math.floor((F-V)/1e3);return K<1?"<1s":K<60?`${K}s`:`${Math.floor(K/60)}m ${K%60}s`},_=E=>{var P,V;return(P=E.toolCalls)!=null&&P.length?E.toolCalls.length:typeof E.cost=="object"&&((V=E.cost)!=null&&V.modelCalls)?E.cost.modelCalls:0},I=E=>{var P;return((P=E.subAgents)==null?void 0:P.length)||0},M=t.filter(E=>!E.parentTaskId&&(E.status==="running"||E.status==="in_progress")).length,L=t.filter(E=>!E.parentTaskId&&E.status==="completed").length,$=t.filter(E=>!E.parentTaskId&&E.status==="failed").length;return n&&t.length===0?o.jsx("div",{className:"flex items-center justify-center h-full",children:o.jsx($t,{className:"w-8 h-8 text-[#00d9ff] animate-spin"})}):o.jsxs("div",{className:"space-y-5",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{children:[o.jsx("h2",{className:"text-2xl font-bold text-white uppercase tracking-tighter",children:"Logs"}),o.jsx("p",{className:"text-gray-500 font-mono text-[10px] tracking-widest uppercase",children:"Execution History"})]}),o.jsxs("div",{className:"flex items-center gap-3 text-[10px] font-mono",children:[M>0&&o.jsxs("span",{className:"text-[#ffaa00]",children:[M," running"]}),o.jsxs("span",{className:"text-gray-600",children:[t.filter(E=>!E.parentTaskId).length," total"]})]})]}),o.jsxs("div",{className:"flex gap-3 items-center",children:[o.jsx("div",{className:"flex gap-1.5",children:KH.map(E=>o.jsxs("button",{onClick:()=>c(E.value),className:`px-2.5 py-1 rounded-md text-[9px] font-mono uppercase tracking-wider border transition-all ${a===E.value?`${E.color} bg-white/5`:"text-gray-600 border-transparent hover:text-gray-400"}`,children:[E.label,E.value==="running"&&M>0&&o.jsxs("span",{className:"ml-1",children:["(",M,")"]}),E.value==="completed"&&o.jsxs("span",{className:"ml-1",children:["(",L,")"]}),E.value==="failed"&&$>0&&o.jsxs("span",{className:"ml-1",children:["(",$,")"]})]},E.value))}),o.jsxs("div",{className:"relative flex-1 max-w-md",children:[o.jsx(Wo,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-gray-600"}),o.jsx(Dt,{placeholder:"Search...",value:i,onChange:E=>s(E.target.value),className:"pl-8 h-8 bg-slate-900/50 border-slate-800 text-white font-mono text-[10px] tracking-wider"})]})]}),o.jsx("div",{className:"space-y-1",children:T.length===0?o.jsx("div",{className:"text-center py-20",children:o.jsx("p",{className:"text-gray-700 font-mono uppercase tracking-widest text-[10px]",children:a!=="all"?`No ${a} entries`:"No log entries yet"})}):T.map(E=>{var D,ne;const P=E.subAgents&&E.subAgents.length>0||E.agentCreated,V=h.has(E.id),F=f[E.id]||[],K=_(E),J=I(E),Q=R(E.startedAt||E.createdAt,E.completedAt),Z=typeof E.cost=="object"?(D=E.cost)==null?void 0:D.model:null;return o.jsxs("div",{className:"rounded-lg overflow-hidden",children:[o.jsxs("div",{className:"flex items-center gap-3 px-4 py-3 hover:bg-slate-800/30 transition-colors group",children:[o.jsxs("div",{className:"flex items-center gap-2 w-8 flex-shrink-0",children:[P?o.jsx("button",{onClick:()=>w(E.id),className:"text-gray-600 hover:text-white",children:V?o.jsx(fo,{className:"w-3.5 h-3.5"}):o.jsx(fp,{className:"w-3.5 h-3.5"})}):o.jsx("div",{className:"w-3.5"}),o.jsx(C,{status:E.status})]}),o.jsx(al,{to:`/logs/${E.id}`,className:"flex-1 min-w-0 group-hover:text-[#00d9ff] transition-colors",children:o.jsx("span",{className:"text-sm text-gray-200 font-mono truncate block",children:(E.title||E.input||"").replace(/^\[Voice mode:[^\]]+\]\s*/,"")})}),o.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[o.jsx("span",{className:"text-[8px] font-mono text-gray-600 uppercase bg-slate-800/50 px-1.5 py-0.5 rounded",children:E.channel}),Z&&o.jsx("span",{className:"text-[8px] font-mono text-gray-600 bg-slate-800/50 px-1.5 py-0.5 rounded hidden xl:inline",children:((ne=Z.split("/").pop())==null?void 0:ne.split(":")[0])||Z}),K>0&&o.jsxs("span",{className:"text-[9px] font-mono text-[#7C6AFF] flex items-center gap-0.5",children:[o.jsx(ha,{className:"w-2.5 h-2.5"}),K]}),J>0&&o.jsxs("span",{className:"text-[9px] font-mono text-[#00d9ff] flex items-center gap-0.5",children:[o.jsx(td,{className:"w-2.5 h-2.5"}),J]}),Q&&o.jsx("span",{className:"text-[9px] font-mono text-gray-600 w-12 text-right",children:Q}),o.jsx("span",{className:"text-[9px] font-mono text-[#00ff88] w-16 text-right",children:o.jsx(j,{cost:E.cost})}),o.jsx("span",{className:"text-[9px] font-mono text-gray-700 w-14 text-right hidden lg:inline",children:new Date(E.createdAt).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}),o.jsx("button",{onClick:A=>S(A,E.id,E.status),disabled:E.status==="running",className:"opacity-0 group-hover:opacity-100 transition-opacity text-red-500/30 hover:text-red-500 disabled:opacity-0 p-0.5",children:o.jsx(qn,{className:"w-3 h-3"})})]})]}),V&&E.subAgents&&E.subAgents.length>0&&o.jsx("div",{className:"border-l-2 border-[#7C6AFF]/20 ml-8 bg-slate-900/30",children:E.subAgents.map(A=>{var z;return o.jsxs("div",{className:"flex items-center gap-3 px-4 py-2 text-[11px] font-mono",children:[o.jsx(td,{className:"w-3 h-3 text-[#7C6AFF] flex-shrink-0"}),o.jsx(C,{status:A.status}),o.jsx("span",{className:"text-[#7C6AFF]",children:A.role||"agent"}),o.jsxs("span",{className:"text-gray-700",children:["(",A.agentId.slice(0,8),")"]}),A.model&&o.jsx("span",{className:"text-gray-700 text-[9px]",children:A.model.split("/").pop()}),o.jsx("span",{className:"flex-1"}),(z=A.toolCalls)!=null&&z.length?o.jsxs("span",{className:"text-gray-600 text-[9px]",children:[A.toolCalls.length," tools"]}):null,A.resultPreview&&o.jsx("span",{className:"text-gray-600 text-[9px] max-w-[250px] truncate",children:A.resultPreview})]},A.agentId)})}),V&&F.length>0&&o.jsx("div",{className:"border-l-2 border-[#00d9ff]/20 ml-8 bg-slate-900/30",children:F.map(A=>o.jsxs(al,{to:`/logs/${A.id}`,className:"flex items-center gap-3 px-4 py-2 text-[11px] font-mono hover:bg-[#00d9ff]/5 transition-colors",children:[o.jsx(C,{status:A.status}),o.jsx("span",{className:"text-gray-400 truncate flex-1",children:A.title||A.input}),A.agentId&&o.jsx("span",{className:"text-[8px] text-[#7C6AFF]",children:A.agentId.slice(0,6)}),o.jsx("span",{className:"text-[9px] text-[#00ff88]",children:o.jsx(j,{cost:A.cost})})]},A.id))}),V&&F.length===0&&(!E.subAgents||E.subAgents.length===0)&&o.jsx("div",{className:"border-l-2 border-slate-800/50 ml-8 px-4 py-2",children:o.jsx("span",{className:"text-gray-700 font-mono text-[9px] uppercase",children:"No sub-agents or child entries"})})]},E.id)})}),o.jsx(js,{open:g.open,onOpenChange:E=>v(P=>({...P,open:E})),children:o.jsxs(Ps,{className:"bg-slate-900 border border-slate-700 text-white",children:[o.jsxs(_s,{children:[o.jsx(Is,{className:"text-white font-mono uppercase text-sm tracking-wide",children:g.title}),g.description&&o.jsx(Ms,{className:"text-gray-400 font-mono text-xs",children:g.description})]}),o.jsxs(Rs,{children:[o.jsx(As,{className:"bg-slate-800 border-slate-700 text-gray-300 hover:bg-slate-700 font-mono text-xs uppercase",children:"Cancel"}),o.jsx(Ds,{className:"bg-red-500/20 text-red-400 border border-red-500/30 hover:bg-red-500/30 font-mono text-xs uppercase",onClick:()=>{g.onConfirm(),v(E=>({...E,open:!1}))},children:"Confirm"})]})]})})]})}function o_(t){const e=t+"CollectionProvider",[n,r]=Us(e),[i,s]=n(e,{collectionRef:{current:null},itemMap:new Map}),a=v=>{const{scope:k,children:w}=v,S=Me.useRef(null),T=Me.useRef(new Map).current;return o.jsx(i,{scope:k,itemMap:T,collectionRef:S,children:w})};a.displayName=e;const c=t+"CollectionSlot",h=Me.forwardRef((v,k)=>{const{scope:w,children:S}=v,T=s(c,w),C=sn(k,T.collectionRef);return o.jsx(ao,{ref:C,children:S})});h.displayName=c;const d=t+"CollectionItemSlot",f="data-radix-collection-item",p=Me.forwardRef((v,k)=>{const{scope:w,children:S,...T}=v,C=Me.useRef(null),j=sn(k,C),R=s(d,w);return Me.useEffect(()=>(R.itemMap.set(C,{ref:C,...T}),()=>void R.itemMap.delete(C))),o.jsx(ao,{[f]:"",ref:j,children:S})});p.displayName=d;function g(v){const k=s(t+"CollectionConsumer",v);return Me.useCallback(()=>{const S=k.collectionRef.current;if(!S)return[];const T=Array.from(S.querySelectorAll(`[${f}]`));return Array.from(k.itemMap.values()).sort((R,_)=>T.indexOf(R.ref.current)-T.indexOf(_.ref.current))},[k.collectionRef,k.itemMap])}return[{Provider:a,Slot:h,ItemSlot:p},g,r]}var M0="rovingFocusGroup.onEntryFocus",GH={bubbles:!1,cancelable:!0},Bp="RovingFocusGroup",[Yv,l_,YH]=o_(Bp),[JH,c_]=Us(Bp,[YH]),[XH,QH]=JH(Bp),u_=x.forwardRef((t,e)=>o.jsx(Yv.Provider,{scope:t.__scopeRovingFocusGroup,children:o.jsx(Yv.Slot,{scope:t.__scopeRovingFocusGroup,children:o.jsx(ZH,{...t,ref:e})})}));u_.displayName=Bp;var ZH=x.forwardRef((t,e)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:i=!1,dir:s,currentTabStopId:a,defaultCurrentTabStopId:c,onCurrentTabStopIdChange:h,onEntryFocus:d,preventScrollOnEntryFocus:f=!1,...p}=t,g=x.useRef(null),v=sn(e,g),k=mp(s),[w=null,S]=xc({prop:a,defaultProp:c,onChange:h}),[T,C]=x.useState(!1),j=hr(d),R=l_(n),_=x.useRef(!1),[I,M]=x.useState(0);return x.useEffect(()=>{const L=g.current;if(L)return L.addEventListener(M0,j),()=>L.removeEventListener(M0,j)},[j]),o.jsx(XH,{scope:n,orientation:r,dir:k,loop:i,currentTabStopId:w,onItemFocus:x.useCallback(L=>S(L),[S]),onItemShiftTab:x.useCallback(()=>C(!0),[]),onFocusableItemAdd:x.useCallback(()=>M(L=>L+1),[]),onFocusableItemRemove:x.useCallback(()=>M(L=>L-1),[]),children:o.jsx(_t.div,{tabIndex:T||I===0?-1:0,"data-orientation":r,...p,ref:v,style:{outline:"none",...t.style},onMouseDown:Et(t.onMouseDown,()=>{_.current=!0}),onFocus:Et(t.onFocus,L=>{const $=!_.current;if(L.target===L.currentTarget&&$&&!T){const E=new CustomEvent(M0,GH);if(L.currentTarget.dispatchEvent(E),!E.defaultPrevented){const P=R().filter(Q=>Q.focusable),V=P.find(Q=>Q.active),F=P.find(Q=>Q.id===w),J=[V,F,...P].filter(Boolean).map(Q=>Q.ref.current);f_(J,f)}}_.current=!1}),onBlur:Et(t.onBlur,()=>C(!1))})})}),d_="RovingFocusGroupItem",h_=x.forwardRef((t,e)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:i=!1,tabStopId:s,...a}=t,c=no(),h=s||c,d=QH(d_,n),f=d.currentTabStopId===h,p=l_(n),{onFocusableItemAdd:g,onFocusableItemRemove:v}=d;return x.useEffect(()=>{if(r)return g(),()=>v()},[r,g,v]),o.jsx(Yv.ItemSlot,{scope:n,id:h,focusable:r,active:i,children:o.jsx(_t.span,{tabIndex:f?0:-1,"data-orientation":d.orientation,...a,ref:e,onMouseDown:Et(t.onMouseDown,k=>{r?d.onItemFocus(h):k.preventDefault()}),onFocus:Et(t.onFocus,()=>d.onItemFocus(h)),onKeyDown:Et(t.onKeyDown,k=>{if(k.key==="Tab"&&k.shiftKey){d.onItemShiftTab();return}if(k.target!==k.currentTarget)return;const w=nq(k,d.orientation,d.dir);if(w!==void 0){if(k.metaKey||k.ctrlKey||k.altKey||k.shiftKey)return;k.preventDefault();let T=p().filter(C=>C.focusable).map(C=>C.ref.current);if(w==="last")T.reverse();else if(w==="prev"||w==="next"){w==="prev"&&T.reverse();const C=T.indexOf(k.currentTarget);T=d.loop?rq(T,C+1):T.slice(C+1)}setTimeout(()=>f_(T))}})})})});h_.displayName=d_;var eq={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function tq(t,e){return e!=="rtl"?t:t==="ArrowLeft"?"ArrowRight":t==="ArrowRight"?"ArrowLeft":t}function nq(t,e,n){const r=tq(t.key,n);if(!(e==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(e==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return eq[r]}function f_(t,e=!1){const n=document.activeElement;for(const r of t)if(r===n||(r.focus({preventScroll:e}),document.activeElement!==n))return}function rq(t,e){return t.map((n,r)=>t[(e+r)%t.length])}var iq=u_,sq=h_,Lx="Tabs",[aq]=Us(Lx,[c_]),p_=c_(),[oq,Fx]=aq(Lx),m_=x.forwardRef((t,e)=>{const{__scopeTabs:n,value:r,onValueChange:i,defaultValue:s,orientation:a="horizontal",dir:c,activationMode:h="automatic",...d}=t,f=mp(c),[p,g]=xc({prop:r,onChange:i,defaultProp:s});return o.jsx(oq,{scope:n,baseId:no(),value:p,onValueChange:g,orientation:a,dir:f,activationMode:h,children:o.jsx(_t.div,{dir:f,"data-orientation":a,...d,ref:e})})});m_.displayName=Lx;var g_="TabsList",v_=x.forwardRef((t,e)=>{const{__scopeTabs:n,loop:r=!0,...i}=t,s=Fx(g_,n),a=p_(n);return o.jsx(iq,{asChild:!0,...a,orientation:s.orientation,dir:s.dir,loop:r,children:o.jsx(_t.div,{role:"tablist","aria-orientation":s.orientation,...i,ref:e})})});v_.displayName=g_;var y_="TabsTrigger",x_=x.forwardRef((t,e)=>{const{__scopeTabs:n,value:r,disabled:i=!1,...s}=t,a=Fx(y_,n),c=p_(n),h=w_(a.baseId,r),d=S_(a.baseId,r),f=r===a.value;return o.jsx(sq,{asChild:!0,...c,focusable:!i,active:f,children:o.jsx(_t.button,{type:"button",role:"tab","aria-selected":f,"aria-controls":d,"data-state":f?"active":"inactive","data-disabled":i?"":void 0,disabled:i,id:h,...s,ref:e,onMouseDown:Et(t.onMouseDown,p=>{!i&&p.button===0&&p.ctrlKey===!1?a.onValueChange(r):p.preventDefault()}),onKeyDown:Et(t.onKeyDown,p=>{[" ","Enter"].includes(p.key)&&a.onValueChange(r)}),onFocus:Et(t.onFocus,()=>{const p=a.activationMode!=="manual";!f&&!i&&p&&a.onValueChange(r)})})})});x_.displayName=y_;var b_="TabsContent",k_=x.forwardRef((t,e)=>{const{__scopeTabs:n,value:r,forceMount:i,children:s,...a}=t,c=Fx(b_,n),h=w_(c.baseId,r),d=S_(c.baseId,r),f=r===c.value,p=x.useRef(f);return x.useEffect(()=>{const g=requestAnimationFrame(()=>p.current=!1);return()=>cancelAnimationFrame(g)},[]),o.jsx(ga,{present:i||f,children:({present:g})=>o.jsx(_t.div,{"data-state":f?"active":"inactive","data-orientation":c.orientation,role:"tabpanel","aria-labelledby":h,hidden:!g,id:d,tabIndex:0,...a,ref:e,style:{...t.style,animationDuration:p.current?"0s":void 0},children:g&&s})})});k_.displayName=b_;function w_(t,e){return`${t}-trigger-${e}`}function S_(t,e){return`${t}-content-${e}`}var lq=m_,cq=v_,uq=x_,dq=k_;function C_({className:t,...e}){return o.jsx(lq,{"data-slot":"tabs",className:St("flex flex-col gap-2",t),...e})}function T_({className:t,...e}){return o.jsx(cq,{"data-slot":"tabs-list",className:St("bg-muted text-muted-foreground inline-flex h-9 w-fit items-center justify-center rounded-xl p-[3px] flex",t),...e})}function el({className:t,...e}){return o.jsx(uq,{"data-slot":"tabs-trigger",className:St("data-[state=active]:bg-card dark:data-[state=active]:text-foreground focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:outline-ring dark:data-[state=active]:border-input dark:data-[state=active]:bg-input/30 text-foreground dark:text-muted-foreground inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-xl border border-transparent px-2 py-1 text-sm font-medium whitespace-nowrap transition-[color,box-shadow] focus-visible:ring-[3px] focus-visible:outline-1 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",t),...e})}function tl({className:t,...e}){return o.jsx(dq,{"data-slot":"tabs-content",className:St("flex-1 outline-none",t),...e})}const rT=t=>(t||"").replace(/^\[Voice mode:[^\]]+\]\s*/,"");function iT(){var p,g,v,k,w,S,T,C,j,R;const{id:t}=hM(),e=Pc(),[n,r]=x.useState(null),[i,s]=x.useState(!0),[a,c]=x.useState({open:!1,title:"",onConfirm:()=>{}}),h=()=>{c({open:!0,title:"Delete this task?",description:"This cannot be undone.",onConfirm:async()=>{const _=me.loading("DELETING TASK...");try{const I=await we(`/api/tasks/${t}`,{method:"DELETE"});if(I.ok)me.success("Task deleted",{id:_}),e("/logs");else{const M=await I.json();me.error(M.error||"Failed to delete",{id:_})}}catch(I){me.error(I.message,{id:_})}}})};x.useEffect(()=>{if(!t)return;let _=!0;const I=async()=>{try{const $=await we(`/api/tasks/${t}`);if($.ok&&_){const E=await $.json();return r(E),E}}catch($){console.error("Failed to fetch task",$)}finally{_&&s(!1)}return null};let M=null,L=null;return I().then($=>{!_||!$||!($.status==="running"||$.status==="pending")||(M=new EventSource(X0(`/api/tasks/${t}/stream`)),M.addEventListener("tool:after",()=>I()),M.addEventListener("tool:before",()=>I()),M.addEventListener("task:state",P=>{try{const V=JSON.parse(P.data);(V.status==="completed"||V.status==="failed")&&(I(),M==null||M.close(),M=null)}catch{}}),M.onerror=()=>{},L=setInterval(async()=>{const P=await I();P&&(P.status==="completed"||P.status==="failed")&&(L&&(clearInterval(L),L=null),M==null||M.close(),M=null)},3e3))}),()=>{_=!1,M&&M.close(),L&&clearInterval(L)}},[t]);const d=(_,I)=>{if(!_)return"-";const M=new Date(_).getTime(),L=I?new Date(I).getTime():Date.now(),$=Math.floor((L-M)/1e3);if($<60)return`${$}s`;const E=Math.floor($/60),P=$%60;return`${E}m ${P}s`};if(i)return o.jsx("div",{className:"flex items-center justify-center h-full",children:o.jsx($t,{className:"w-8 h-8 text-[#00d9ff] animate-spin"})});if(!n)return o.jsx("div",{className:"text-center py-12",children:o.jsx("p",{className:"text-red-400 font-mono uppercase",children:"TASK NOT FOUND"})});const f=n.status==="completed"?"bg-[#00ff88]/20 text-[#00ff88] border-[#00ff88]/30":n.status==="failed"?"bg-red-500/20 text-red-400 border-red-500/30":n.status==="running"?"bg-amber-500/20 text-amber-400 border-amber-500/30":"bg-slate-700/20 text-gray-400 border-slate-700/30";return o.jsxs("div",{className:"space-y-6",children:[o.jsxs("div",{className:"flex items-center gap-4",children:[o.jsx(al,{to:"/logs",children:o.jsx(at,{variant:"outline",size:"icon",className:"bg-slate-900 border-slate-800 text-white hover:bg-slate-800",children:o.jsx(R3,{className:"w-5 h-5"})})}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("h2",{className:"text-xl font-bold text-white font-mono uppercase tracking-tight truncate",children:rT(n.input).slice(0,80)}),o.jsxs("p",{className:"text-gray-500 font-mono text-[10px] uppercase tracking-wider mt-1",children:[n.id," // ",n.channel," ",((p=n.cost)==null?void 0:p.model)&&`// ${n.cost.model}`]})]}),o.jsx(Kt,{className:f,children:n.status}),o.jsx(at,{variant:"outline",size:"icon",onClick:h,disabled:n.status==="running",className:"bg-slate-900 border-slate-800 text-red-400 hover:bg-red-500/10 hover:border-red-500/30 disabled:opacity-30",title:"Delete task",children:o.jsx(qn,{className:"w-4 h-4"})})]}),o.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-4",children:[o.jsxs(rn,{className:"bg-slate-900/50 border-slate-800 backdrop-blur-sm",children:[o.jsx(br,{className:"pb-2 pt-4 px-4",children:o.jsx(kr,{className:"text-[10px] font-mono text-gray-500 uppercase tracking-widest",children:"Priority"})}),o.jsx(on,{className:"px-4 pb-4",children:o.jsxs("div",{className:"text-xl font-bold text-white font-mono",children:[n.priority,"/10"]})})]}),o.jsxs(rn,{className:"bg-slate-900/50 border-slate-800 backdrop-blur-sm",children:[o.jsx(br,{className:"pb-2 pt-4 px-4",children:o.jsx(kr,{className:"text-[10px] font-mono text-gray-500 uppercase tracking-widest",children:"Duration"})}),o.jsx(on,{className:"px-4 pb-4",children:o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(es,{className:"w-4 h-4 text-[#00d9ff]"}),o.jsx("div",{className:"text-xl font-bold text-white font-mono",children:d(n.startedAt,n.completedAt)})]})})]}),o.jsxs(rn,{className:"bg-slate-900/50 border-slate-800 backdrop-blur-sm",children:[o.jsx(br,{className:"pb-2 pt-4 px-4",children:o.jsx(kr,{className:"text-[10px] font-mono text-gray-500 uppercase tracking-widest",children:"Cost"})}),o.jsx(on,{className:"px-4 pb-4",children:o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(Rf,{className:"w-4 h-4 text-[#00ff88]"}),o.jsxs("div",{className:"text-xl font-bold text-white font-mono",children:["$",(((g=n.cost)==null?void 0:g.estimatedCost)||0).toFixed(4)]})]})})]}),o.jsxs(rn,{className:"bg-slate-900/50 border-slate-800 backdrop-blur-sm",children:[o.jsx(br,{className:"pb-2 pt-4 px-4",children:o.jsx(kr,{className:"text-[10px] font-mono text-gray-500 uppercase tracking-widest",children:"Tool Calls"})}),o.jsx(on,{className:"px-4 pb-4",children:o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(ha,{className:"w-4 h-4 text-[#7C6AFF]"}),o.jsx("div",{className:"text-xl font-bold text-white font-mono",children:((v=n.toolCalls)==null?void 0:v.length)||0})]})})]})]}),o.jsx(rn,{className:"bg-slate-900/50 border-slate-800 backdrop-blur-sm",children:o.jsx(on,{className:"p-0",children:o.jsxs(C_,{defaultValue:"io",className:"w-full",children:[o.jsxs(T_,{className:`w-full grid bg-slate-800/50 border-b border-slate-700 rounded-none ${(k=n.subAgents)!=null&&k.length?"grid-cols-4":"grid-cols-3"}`,children:[o.jsx(el,{value:"io",className:"data-[state=active]:bg-slate-900 data-[state=active]:text-[#00d9ff] font-mono text-xs uppercase",children:"I/O"}),o.jsxs(el,{value:"tools",className:"data-[state=active]:bg-slate-900 data-[state=active]:text-[#00d9ff] font-mono text-xs uppercase",children:["Tool Calls (",((w=n.toolCalls)==null?void 0:w.length)||0,")"]}),n.subAgents&&n.subAgents.length>0&&o.jsxs(el,{value:"agents",className:"data-[state=active]:bg-slate-900 data-[state=active]:text-[#00d9ff] font-mono text-xs uppercase",children:["Sub-Agents (",n.subAgents.length,")"]}),o.jsx(el,{value:"costs",className:"data-[state=active]:bg-slate-900 data-[state=active]:text-[#00d9ff] font-mono text-xs uppercase",children:"Cost"})]}),o.jsxs(tl,{value:"io",className:"p-6 space-y-6",children:[o.jsxs("div",{children:[o.jsx("h3",{className:"text-xs font-mono text-gray-500 uppercase tracking-widest mb-3",children:"Input"}),o.jsx("div",{className:"bg-slate-800/50 border border-slate-700 rounded-lg p-4",children:o.jsx("pre",{className:"text-gray-300 text-sm font-mono whitespace-pre-wrap",children:rT(n.input)})})]}),o.jsxs("div",{children:[o.jsx("h3",{className:"text-xs font-mono text-gray-500 uppercase tracking-widest mb-3",children:n.error?"Error":"Output"}),o.jsx("div",{className:`bg-slate-800/50 border rounded-lg p-4 ${n.error?"border-red-500/30":"border-slate-700"}`,children:n.error?o.jsxs("div",{className:"flex items-start gap-3",children:[o.jsx(Gr,{className:"w-5 h-5 text-red-400 flex-shrink-0 mt-0.5"}),o.jsx("pre",{className:"text-red-400 text-sm font-mono whitespace-pre-wrap",children:n.error})]}):n.result?o.jsx("div",{className:"prose prose-invert prose-sm max-w-none font-mono leading-relaxed text-[13px]",children:o.jsx(Oj,{remarkPlugins:[a2],children:n.result})}):o.jsx("p",{className:"text-gray-600 font-mono text-sm italic",children:"No output yet..."})})]})]}),o.jsx(tl,{value:"tools",className:"p-6",children:!n.toolCalls||n.toolCalls.length===0?o.jsxs("div",{className:"text-center py-12",children:[o.jsx(ha,{className:"w-8 h-8 text-gray-700 mx-auto mb-3"}),o.jsx("p",{className:"text-gray-600 font-mono uppercase tracking-widest text-xs",children:"No tool calls recorded"})]}):o.jsx("div",{className:"space-y-3",children:n.toolCalls.map((_,I)=>o.jsxs("div",{className:`bg-slate-800/50 border rounded-lg p-4 ${_.error?"border-red-500/20":"border-slate-700"}`,children:[o.jsxs("div",{className:"flex items-center justify-between mb-2",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("div",{className:`w-5 h-5 rounded flex items-center justify-center ${_.error?"bg-red-500/20":"bg-[#00d9ff]/20"}`,children:o.jsxs("span",{className:"text-[9px] font-mono font-bold text-gray-300",children:["#",_.id??I+1]})}),o.jsx("span",{className:"font-bold text-white font-mono text-sm",children:_.toolName??_.tool??"unknown"}),_.error&&o.jsx(Kt,{variant:"outline",className:"text-red-400 border-red-500/30 text-[9px] font-mono",children:"ERROR"})]}),o.jsxs("span",{className:"text-[10px] font-mono text-gray-500",children:[_.durationMs??_.duration??0,"ms"]})]}),(_.args||_.params)&&o.jsxs("div",{className:"mb-2",children:[o.jsx("div",{className:"text-[9px] font-mono text-gray-600 uppercase mb-1",children:"Params"}),o.jsx("pre",{className:"font-mono text-[11px] bg-slate-900/50 p-2 rounded border border-slate-800 text-gray-400 overflow-x-auto max-h-24 overflow-y-auto",children:JSON.stringify(_.args??_.params,null,2)})]}),(_.result||_.output_preview||_.error)&&o.jsxs("div",{children:[o.jsx("div",{className:"text-[9px] font-mono text-gray-600 uppercase mb-1",children:_.error?"Error":"Output"}),o.jsx("pre",{className:`font-mono text-[11px] bg-slate-900/50 p-2 rounded border border-slate-800 overflow-x-auto max-h-32 overflow-y-auto ${_.error?"text-red-400":"text-gray-400"}`,children:_.error??JSON.stringify(_.result??_.output_preview,null,2)})]})]},_.id??I))})}),n.subAgents&&n.subAgents.length>0&&o.jsx(tl,{value:"agents",className:"p-6",children:o.jsx("div",{className:"space-y-3",children:n.subAgents.map((_,I)=>{var M,L,$;return o.jsxs("div",{className:"bg-slate-800/50 border border-slate-700 rounded-lg p-4",children:[o.jsxs("div",{className:"flex items-center justify-between mb-2",children:[o.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[o.jsx(td,{className:"w-4 h-4 text-[#7C6AFF] flex-shrink-0"}),o.jsx("span",{className:"font-mono text-sm text-white",children:_.agentId}),o.jsx(Kt,{variant:"outline",className:`text-[9px] font-mono ${_.status==="completed"?"text-[#00ff88] border-[#00ff88]/30":_.status==="failed"?"text-red-400 border-red-500/30":_.status==="killed"?"text-amber-400 border-amber-500/30":"text-[#00d9ff] border-[#00d9ff]/30"}`,children:_.status}),_.role&&o.jsx(Kt,{variant:"outline",className:"text-[9px] font-mono text-[#7C6AFF] border-[#7C6AFF]/30",children:_.role}),_.depth>0&&o.jsxs("span",{className:"text-[9px] font-mono text-gray-600",children:["depth: ",_.depth]})]}),o.jsxs("div",{className:"flex items-center gap-3",children:[_.toolCalls&&_.toolCalls.length>0&&o.jsxs("span",{className:"text-[10px] font-mono text-gray-500 flex items-center gap-1",children:[o.jsx(ha,{className:"w-3 h-3 text-[#7C6AFF]"}),_.toolCalls.length]}),((M=_.cost)==null?void 0:M.estimatedCost)!=null&&o.jsxs("span",{className:"text-[10px] font-mono text-gray-500",children:["$",_.cost.estimatedCost.toFixed(4)]})]})]}),o.jsx("p",{className:"text-gray-400 font-mono text-xs mb-2",children:_.description}),(_.model||((L=_.cost)==null?void 0:L.model))&&o.jsxs("div",{className:"flex items-center gap-1 mb-2",children:[o.jsx(Ja,{className:"w-3 h-3 text-gray-600"}),o.jsx("span",{className:"text-[10px] font-mono text-gray-600",children:_.model||(($=_.cost)==null?void 0:$.model)})]}),_.resultPreview&&o.jsxs("div",{className:"mt-2",children:[o.jsx("div",{className:"text-[9px] font-mono text-gray-600 uppercase mb-1",children:"Result Preview"}),o.jsx("pre",{className:"font-mono text-[11px] bg-slate-900/50 p-2 rounded border border-slate-800 text-gray-400 overflow-x-auto max-h-24 overflow-y-auto whitespace-pre-wrap",children:_.resultPreview})]}),_.error&&o.jsxs("div",{className:"flex items-start gap-2 mt-2",children:[o.jsx(Gr,{className:"w-3 h-3 text-red-400 flex-shrink-0 mt-0.5"}),o.jsx("p",{className:"text-red-400 font-mono text-xs",children:_.error})]})]},I)})})}),o.jsx(tl,{value:"costs",className:"p-6",children:o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[o.jsxs(rn,{className:"bg-slate-800/50 border-slate-700",children:[o.jsx(br,{className:"pb-2 pt-4 px-4",children:o.jsx(kr,{className:"text-[10px] font-mono text-gray-500 uppercase",children:"Input Tokens"})}),o.jsx(on,{className:"px-4 pb-4",children:o.jsx("div",{className:"text-xl font-bold text-white font-mono",children:(((S=n.cost)==null?void 0:S.inputTokens)||0).toLocaleString()})})]}),o.jsxs(rn,{className:"bg-slate-800/50 border-slate-700",children:[o.jsx(br,{className:"pb-2 pt-4 px-4",children:o.jsx(kr,{className:"text-[10px] font-mono text-gray-500 uppercase",children:"Output Tokens"})}),o.jsx(on,{className:"px-4 pb-4",children:o.jsx("div",{className:"text-xl font-bold text-white font-mono",children:(((T=n.cost)==null?void 0:T.outputTokens)||0).toLocaleString()})})]})]}),o.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[o.jsxs(rn,{className:"bg-slate-800/50 border-slate-700",children:[o.jsx(br,{className:"pb-2 pt-4 px-4",children:o.jsx(kr,{className:"text-[10px] font-mono text-gray-500 uppercase",children:"Model Calls"})}),o.jsx(on,{className:"px-4 pb-4",children:o.jsx("div",{className:"text-xl font-bold text-white font-mono",children:((C=n.cost)==null?void 0:C.modelCalls)||0})})]}),o.jsxs(rn,{className:"bg-slate-800/50 border-slate-700",children:[o.jsx(br,{className:"pb-2 pt-4 px-4",children:o.jsx(kr,{className:"text-[10px] font-mono text-gray-500 uppercase",children:"Total Cost"})}),o.jsx(on,{className:"px-4 pb-4",children:o.jsxs("div",{className:"text-xl font-bold text-[#00ff88] font-mono",children:["$",(((j=n.cost)==null?void 0:j.estimatedCost)||0).toFixed(4)]})})]})]}),((R=n.cost)==null?void 0:R.model)&&o.jsxs("div",{className:"p-3 bg-slate-800/30 rounded-lg border border-slate-800/50",children:[o.jsx("div",{className:"text-[10px] text-gray-500 font-mono uppercase mb-1",children:"Model"}),o.jsx("div",{className:"text-white font-mono text-sm",children:n.cost.model})]}),o.jsxs("div",{className:"grid grid-cols-3 gap-4 text-center",children:[o.jsxs("div",{className:"p-3 bg-slate-800/30 rounded-lg border border-slate-800/50",children:[o.jsx("div",{className:"text-[9px] text-gray-600 font-mono uppercase mb-1",children:"Created"}),o.jsx("div",{className:"text-gray-300 font-mono text-[11px]",children:new Date(n.createdAt).toLocaleString()})]}),o.jsxs("div",{className:"p-3 bg-slate-800/30 rounded-lg border border-slate-800/50",children:[o.jsx("div",{className:"text-[9px] text-gray-600 font-mono uppercase mb-1",children:"Started"}),o.jsx("div",{className:"text-gray-300 font-mono text-[11px]",children:n.startedAt?new Date(n.startedAt).toLocaleString():"-"})]}),o.jsxs("div",{className:"p-3 bg-slate-800/30 rounded-lg border border-slate-800/50",children:[o.jsx("div",{className:"text-[9px] text-gray-600 font-mono uppercase mb-1",children:"Completed"}),o.jsx("div",{className:"text-gray-300 font-mono text-[11px]",children:n.completedAt?new Date(n.completedAt).toLocaleString():"-"})]})]})]})})]})})}),o.jsx(js,{open:a.open,onOpenChange:_=>c(I=>({...I,open:_})),children:o.jsxs(Ps,{className:"bg-slate-900 border border-slate-700 text-white",children:[o.jsxs(_s,{children:[o.jsx(Is,{className:"text-white font-mono uppercase text-sm tracking-wide",children:a.title}),a.description&&o.jsx(Ms,{className:"text-gray-400 font-mono text-xs",children:a.description})]}),o.jsxs(Rs,{children:[o.jsx(As,{className:"bg-slate-800 border-slate-700 text-gray-300 hover:bg-slate-700 font-mono text-xs uppercase",children:"Cancel"}),o.jsx(Ds,{className:"bg-red-500/20 text-red-400 border border-red-500/30 hover:bg-red-500/30 font-mono text-xs uppercase",onClick:()=>{a.onConfirm(),c(_=>({..._,open:!1}))},children:"Confirm"})]})]})})]})}function hq(){const[t,e]=x.useState([]),[n,r]=x.useState(!0),[i,s]=x.useState(null),[a,c]=x.useState({}),[h,d]=x.useState(!1),[f,p]=x.useState(null),[g,v]=x.useState({}),[k,w]=x.useState(null),[S,T]=x.useState(!1),C=async()=>{try{const L=await w3("/api/channels/defs");e(L.channels)}catch{me.error("Failed to load channels")}finally{r(!1)}};x.useEffect(()=>{C()},[]);const j=L=>{if(i===L){s(null),c({});return}s(L),c({}),v({})},R=async()=>{if(k){T(!0);try{const L=await we(`/api/channels/${encodeURIComponent(k.name)}`,{method:"DELETE"});if(!L.ok){const $=await L.json().catch(()=>({}));throw new Error($.error||`Failed (${L.status})`)}me.success(`${k.label} removed`),w(null),s(null),c({}),await C()}catch(L){me.error(L.message||"Failed to remove")}finally{T(!1)}}},_=async L=>{const $={};for(const[E,P]of Object.entries(a))P.trim()&&($[E]=P.trim());if(Object.keys($).length===0){me.error("No values to save");return}d(!0);try{await S3("/api/settings","PUT",{updates:$}),p(L.name),me.success(`${L.label} configuration saved`),setTimeout(()=>p(null),3e3),await C()}catch(E){me.error(E.message||"Failed to save")}finally{d(!1)}};if(n)return o.jsx("div",{className:"flex items-center justify-center h-64",children:o.jsx($t,{className:"w-6 h-6 text-[#00d9ff] animate-spin"})});const I=t.filter(L=>L.running).length,M=t.filter(L=>L.configured).length;return o.jsxs("div",{className:"space-y-6",children:[o.jsx("div",{className:"flex items-center justify-between",children:o.jsxs("div",{children:[o.jsxs("h2",{className:"text-2xl font-bold text-white tracking-tight flex items-center gap-3",children:[o.jsx("div",{className:"w-10 h-10 rounded-xl bg-[#00d9ff]/10 border border-[#00d9ff]/20 flex items-center justify-center",children:o.jsx(Ty,{className:"w-5 h-5 text-[#00d9ff]"})}),"Channels"]}),o.jsxs("p",{className:"text-sm text-gray-500 mt-1 font-mono",children:[t.length," supported · ",M," configured · ",I," running"]})]})}),o.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-4",children:t.map(L=>{const $=i===L.name;return o.jsxs("div",{className:`bg-slate-900/50 border rounded-2xl backdrop-blur-sm transition-all duration-300 overflow-hidden ${$?"border-[#00d9ff]/40 shadow-[0_0_20px_rgba(0,217,255,0.1)] col-span-1 md:col-span-2 xl:col-span-3":L.running?"border-[#00ff88]/20 hover:border-[#00ff88]/40":L.configured?"border-[#ffaa00]/20 hover:border-[#ffaa00]/40":"border-slate-800 hover:border-slate-700"}`,children:[o.jsxs("button",{onClick:()=>j(L.name),className:"w-full flex items-center justify-between px-5 py-4 cursor-pointer group",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx(fq,{running:L.running,configured:L.configured}),o.jsxs("div",{className:"text-left",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"text-white font-semibold text-sm",children:L.label}),o.jsx(pq,{running:L.running,configured:L.configured})]}),o.jsx("p",{className:"text-[11px] font-mono text-gray-500 mt-0.5",children:L.desc})]})]}),o.jsx(fo,{className:`w-4 h-4 text-gray-500 transition-transform duration-300 ${$?"rotate-180":""}`})]}),$&&o.jsxs("div",{className:"px-5 pb-5 pt-1 border-t border-slate-800/50 space-y-5",children:[o.jsxs("div",{children:[o.jsx("h4",{className:"text-xs font-semibold text-[#4ECDC4] uppercase tracking-wider mb-2",children:"Setup Instructions"}),o.jsx("div",{className:"bg-slate-950/50 border border-slate-800 rounded-lg p-3 space-y-1",children:L.setup.map((E,P)=>o.jsx("p",{className:"text-xs font-mono text-gray-400",children:E},P))})]}),o.jsxs("div",{children:[o.jsx("h4",{className:"text-xs font-semibold text-[#4ECDC4] uppercase tracking-wider mb-3",children:"Configuration"}),o.jsx("div",{className:"space-y-3",children:L.prompts.map(E=>o.jsxs("div",{children:[o.jsxs("label",{className:"text-xs font-mono text-gray-400 mb-1 block",children:[E.key,L.envRequired.some(P=>P.split("=")[0]===E.key)&&o.jsx("span",{className:"text-[#ff4458] ml-1",children:"*"})]}),o.jsxs("div",{className:"flex gap-2",children:[o.jsx("input",{type:E.type==="password"&&!g[E.key]?"password":"text",value:a[E.key]??"",onChange:P=>c({...a,[E.key]:P.target.value}),placeholder:E.placeholder||E.initialValue||E.label,className:"flex-1 bg-slate-950/50 border border-slate-800 rounded-lg px-3 py-2 text-sm text-white font-mono placeholder:text-gray-600 focus:outline-none focus:border-[#00d9ff]/50 transition-colors"}),E.type==="password"&&o.jsx("button",{onClick:()=>v({...g,[E.key]:!g[E.key]}),className:"px-2 text-gray-500 hover:text-gray-300 transition-colors",children:g[E.key]?o.jsx(sc,{className:"w-4 h-4"}):o.jsx(Ss,{className:"w-4 h-4"})})]})]},E.key))})]}),L.envOptional.length>0&&o.jsxs("div",{children:[o.jsx("h4",{className:"text-xs font-semibold text-gray-500 uppercase tracking-wider mb-2",children:"Optional"}),o.jsx("div",{className:"space-y-2",children:L.envOptional.map(([E,P])=>o.jsxs("div",{children:[o.jsxs("label",{className:"text-xs font-mono text-gray-500 mb-1 block",title:P,children:[E,o.jsx("span",{className:"text-gray-600 ml-2 font-sans",children:P})]}),o.jsx("input",{type:"text",value:a[E]??"",onChange:V=>c({...a,[E]:V.target.value}),placeholder:P,className:"w-full bg-slate-950/50 border border-slate-800 rounded-lg px-3 py-2 text-sm text-white font-mono placeholder:text-gray-600 focus:outline-none focus:border-[#00d9ff]/50 transition-colors"})]},E))})]}),o.jsxs("div",{className:"flex items-center gap-3 pt-2",children:[o.jsxs("button",{onClick:()=>_(L),disabled:h,className:"flex items-center gap-2 px-4 py-2 rounded-lg bg-[#00d9ff]/10 border border-[#00d9ff]/30 text-[#00d9ff] text-sm font-medium hover:bg-[#00d9ff]/20 disabled:opacity-50 transition-all cursor-pointer",children:[h?o.jsx($t,{className:"w-4 h-4 animate-spin"}):f===L.name?o.jsx(ky,{className:"w-4 h-4"}):o.jsx(rd,{className:"w-4 h-4"}),h?"Saving...":f===L.name?"Saved":"Save"]}),L.configured&&o.jsxs("button",{onClick:()=>w(L),className:"flex items-center gap-2 px-4 py-2 rounded-lg bg-[#ff4458]/10 border border-[#ff4458]/30 text-[#ff4458] text-sm font-medium hover:bg-[#ff4458]/20 transition-all cursor-pointer",children:[o.jsx(qn,{className:"w-4 h-4"}),"Remove"]}),f===L.name&&o.jsxs("span",{className:"flex items-center gap-1.5 text-xs text-[#ffaa00] font-mono",children:[o.jsx(Gr,{className:"w-3 h-3"}),"Restart Daemora to activate"]})]})]})]},L.name)})}),o.jsx(js,{open:!!k,onOpenChange:L=>!L&&w(null),children:o.jsxs(Ps,{children:[o.jsxs(_s,{children:[o.jsxs(Is,{children:["Remove ",k==null?void 0:k.label,"?"]}),o.jsx(Ms,{children:"This stops the channel if running and wipes its secrets from the vault. You can reconfigure it later — the channel itself isn't uninstalled."})]}),o.jsxs(Rs,{children:[o.jsx(As,{disabled:S,children:"Cancel"}),o.jsx(Ds,{onClick:R,disabled:S,children:S?"Removing...":"Remove"})]})]})})]})}function fq({running:t,configured:e}){return t?o.jsx("div",{className:"w-2.5 h-2.5 rounded-full bg-[#00ff88] shadow-[0_0_6px_rgba(0,255,136,0.5)] animate-pulse"}):e?o.jsx("div",{className:"w-2.5 h-2.5 rounded-full bg-[#ffaa00] shadow-[0_0_6px_rgba(255,170,0,0.3)]"}):o.jsx("div",{className:"w-2.5 h-2.5 rounded-full bg-slate-700"})}function pq({running:t,configured:e}){return t?o.jsx("span",{className:"inline-flex items-center px-1.5 py-0.5 rounded text-[9px] font-mono uppercase tracking-wider bg-[#00ff88]/10 text-[#00ff88] border border-[#00ff88]/20",children:"Active"}):e?o.jsx("span",{className:"inline-flex items-center px-1.5 py-0.5 rounded text-[9px] font-mono uppercase tracking-wider bg-[#ffaa00]/10 text-[#ffaa00] border border-[#ffaa00]/20",children:"Configured"}):null}function hi({...t}){return o.jsx(OE,{"data-slot":"dialog",...t})}function fl({...t}){return o.jsx(LE,{"data-slot":"dialog-trigger",...t})}function mq({...t}){return o.jsx(FE,{"data-slot":"dialog-portal",...t})}function gq({className:t,...e}){return o.jsx(UE,{"data-slot":"dialog-overlay",className:St("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/85 backdrop-blur-sm",t),...e})}function fi({className:t,children:e,...n}){return o.jsxs(mq,{"data-slot":"dialog-portal",children:[o.jsx(gq,{}),o.jsxs(BE,{"data-slot":"dialog-content",className:St("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%] gap-4 rounded-lg border p-6 shadow-lg duration-200 sm:max-w-lg",t),...n,children:[e,o.jsxs(Uy,{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:[o.jsx(ol,{}),o.jsx("span",{className:"sr-only",children:"Close"})]})]})]})}function pi({className:t,...e}){return o.jsx("div",{"data-slot":"dialog-header",className:St("flex flex-col gap-2 text-center sm:text-left",t),...e})}function mi({className:t,...e}){return o.jsx(zE,{"data-slot":"dialog-title",className:St("text-lg leading-none font-semibold",t),...e})}function vq({className:t,...e}){return o.jsx($E,{"data-slot":"dialog-description",className:St("text-muted-foreground text-sm",t),...e})}const yq=[{id:"twitter",name:"X / Twitter",tagline:"Post tweets, search, manage DMs, follow/unfollow, and more.",accent:"#ffffff",logo:o.jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor",className:"w-7 h-7",children:o.jsx("path",{d:"M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z"})})},{id:"youtube",name:"YouTube",tagline:"Search, manage your channel, playlists, comments, video metadata.",accent:"#FF0033",logo:o.jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor",className:"w-8 h-8",children:o.jsx("path",{d:"M23.498 6.186a2.999 2.999 0 0 0-2.113-2.12C19.505 3.545 12 3.545 12 3.545s-7.505 0-9.385.521A2.999 2.999 0 0 0 .502 6.186C0 8.07 0 12 0 12s0 3.93.502 5.814a2.999 2.999 0 0 0 2.113 2.12C4.495 20.455 12 20.455 12 20.455s7.505 0 9.385-.521a2.999 2.999 0 0 0 2.113-2.12C24 15.93 24 12 24 12s0-3.93-.502-5.814zM9.545 15.568V8.432L15.818 12l-6.273 3.568z"})})},{id:"facebook",name:"Facebook Pages",tagline:"Manage Pages: post, schedule, upload photos, manage comments, view insights.",accent:"#1877F2",logo:o.jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor",className:"w-8 h-8",children:o.jsx("path",{d:"M24 12a12 12 0 1 0-13.875 11.854v-8.385H7.078V12h3.047V9.356c0-3.007 1.791-4.668 4.533-4.668 1.312 0 2.686.234 2.686.234v2.953h-1.513c-1.49 0-1.955.926-1.955 1.874V12h3.328l-.532 3.469h-2.796v8.385A12.002 12.002 0 0 0 24 12z"})})},{id:"instagram",name:"Instagram",tagline:"Publish images/videos/carousels, manage comments, read insights.",accent:"#E1306C",logo:o.jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor",className:"w-8 h-8",children:o.jsx("path",{d:"M12 2.163c3.204 0 3.584.012 4.85.07 3.252.148 4.771 1.691 4.919 4.919.058 1.265.069 1.645.069 4.849 0 3.205-.012 3.584-.069 4.849-.149 3.225-1.664 4.771-4.919 4.919-1.266.058-1.644.07-4.85.07-3.204 0-3.584-.012-4.849-.07-3.26-.149-4.771-1.699-4.919-4.92-.058-1.265-.07-1.644-.07-4.849 0-3.204.013-3.583.07-4.849.149-3.227 1.664-4.771 4.919-4.919 1.266-.057 1.645-.069 4.849-.069zM12 0C8.741 0 8.333.014 7.053.072 2.695.272.273 2.69.073 7.052.014 8.333 0 8.741 0 12c0 3.259.014 3.668.072 4.948.2 4.358 2.618 6.78 6.98 6.98C8.333 23.986 8.741 24 12 24c3.259 0 3.668-.014 4.948-.072 4.354-.2 6.782-2.618 6.979-6.98.059-1.28.073-1.689.073-4.948 0-3.259-.014-3.667-.072-4.947-.196-4.354-2.617-6.78-6.979-6.98C15.668.014 15.259 0 12 0zm0 5.838a6.162 6.162 0 1 0 0 12.324 6.162 6.162 0 0 0 0-12.324zM12 16a4 4 0 1 1 0-8 4 4 0 0 1 0 8zm6.406-11.845a1.44 1.44 0 1 0 0 2.881 1.44 1.44 0 0 0 0-2.881z"})})},{id:"github",name:"GitHub",tagline:"Triage issues, review PRs, search code, manage workflows — served through GitHub's remote MCP.",accent:"#f0f6fc",logo:o.jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor",className:"w-8 h-8",children:o.jsx("path",{d:"M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61-.546-1.385-1.335-1.755-1.335-1.755-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12"})})},{id:"notion",name:"Notion",tagline:"Pages, databases, comments, relations — OAuth-backed; only sees pages you share at consent.",accent:"#ffffff",logo:o.jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor",className:"w-7 h-7",children:o.jsx("path",{d:"M4.459 4.208c.746.606 1.026.56 2.428.466l13.215-.793c.28 0 .047-.28-.046-.326L17.86 1.968c-.42-.326-.981-.7-2.055-.607L3.01 2.295c-.466.046-.56.28-.374.466zm.793 3.08v13.904c0 .747.373 1.027 1.214.98l14.523-.84c.841-.046.935-.56.935-1.167V6.354c0-.606-.233-.933-.748-.887l-15.177.887c-.56.047-.747.327-.747.933zm14.337.745c.093.42 0 .84-.42.888l-.7.14v10.263c-.608.327-1.168.514-1.635.514-.748 0-.935-.234-1.495-.933l-4.577-7.186v6.952L12.21 19s0 .84-1.168.84l-3.222.186c-.093-.186 0-.653.327-.746l.84-.233V9.854L7.822 9.76c-.094-.42.14-1.026.793-1.073l3.456-.233 4.764 7.279v-6.44l-1.215-.139c-.093-.514.28-.887.747-.933z"})})},{id:"gmail",name:"Gmail",tagline:"Triage inbox, send/reply/draft, search, labels — native Gmail API with OAuth scopes.",accent:"#EA4335",logo:o.jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor",className:"w-8 h-8",children:o.jsx("path",{d:"M24 5.457v13.909c0 .904-.732 1.636-1.636 1.636h-3.819V11.73L12 16.64l-6.545-4.91v9.273H1.636A1.636 1.636 0 0 1 0 19.366V5.457c0-2.023 2.309-3.178 3.927-1.964L5.455 4.64 12 9.548l6.545-4.91 1.528-1.145C21.69 2.28 24 3.434 24 5.457z"})})},{id:"google_calendar",name:"Google Calendar",tagline:"Events, free-busy, invites, quick-add — native Calendar API with multi-calendar support.",accent:"#4285F4",logo:o.jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor",className:"w-7 h-7",children:o.jsx("path",{d:"M19.5 22h-15A2.5 2.5 0 0 1 2 19.5v-15A2.5 2.5 0 0 1 4.5 2h15A2.5 2.5 0 0 1 22 4.5v15a2.5 2.5 0 0 1-2.5 2.5zM4.5 4a.5.5 0 0 0-.5.5v15a.5.5 0 0 0 .5.5h15a.5.5 0 0 0 .5-.5v-15a.5.5 0 0 0-.5-.5h-15z M8 8h8v2H8zM8 12h8v2H8zM8 16h5v2H8z"})})},{id:"reddit",name:"Reddit",tagline:"Subreddit search, post/comment drafts, votes, inbox. Always checks subreddit rules before posting.",accent:"#FF4500",logo:o.jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor",className:"w-8 h-8",children:o.jsx("path",{d:"M12 0A12 12 0 0 0 0 12a12 12 0 0 0 12 12 12 12 0 0 0 12-12A12 12 0 0 0 12 0zm5.01 4.744c.688 0 1.25.561 1.25 1.249a1.25 1.25 0 0 1-2.498.056l-2.597-.547-.8 3.747c1.824.07 3.48.632 4.674 1.488.308-.309.73-.491 1.207-.491.968 0 1.754.786 1.754 1.754 0 .716-.435 1.333-1.01 1.614a3.111 3.111 0 0 1 .042.52c0 2.694-3.13 4.87-7.004 4.87-3.874 0-7.004-2.176-7.004-4.87 0-.183.015-.366.043-.534A1.748 1.748 0 0 1 4.028 12.2c0-.968.786-1.754 1.754-1.754.463 0 .898.196 1.207.49 1.207-.883 2.878-1.43 4.744-1.487l.885-4.182a.342.342 0 0 1 .14-.197.35.35 0 0 1 .238-.042l2.906.617a1.214 1.214 0 0 1 1.108-.701zM9.25 12C8.561 12 8 12.562 8 13.25c0 .687.561 1.248 1.25 1.248.687 0 1.248-.561 1.248-1.249 0-.688-.561-1.249-1.249-1.249zm5.5 0c-.687 0-1.248.561-1.248 1.25 0 .687.561 1.248 1.249 1.248.688 0 1.249-.561 1.249-1.249 0-.687-.562-1.249-1.25-1.249zm-5.466 3.99a.327.327 0 0 0-.231.094.33.33 0 0 0 0 .463c.842.842 2.484.913 2.961.913.477 0 2.105-.056 2.961-.913a.361.361 0 0 0 .029-.463.33.33 0 0 0-.464 0c-.547.533-1.684.73-2.512.73-.828 0-1.979-.196-2.512-.73a.326.326 0 0 0-.232-.095z"})})},{id:"linkedin",name:"LinkedIn",tagline:"Publish to your feed, share articles, comment & like. Member-level scopes; company pages need Partner status.",accent:"#0A66C2",logo:o.jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor",className:"w-8 h-8",children:o.jsx("path",{d:"M20.447 20.452h-3.554v-5.569c0-1.328-.027-3.037-1.852-3.037-1.853 0-2.136 1.445-2.136 2.939v5.667H9.351V9h3.414v1.561h.046c.477-.9 1.637-1.85 3.37-1.85 3.601 0 4.267 2.37 4.267 5.455v6.286zM5.337 7.433a2.062 2.062 0 0 1-2.063-2.065 2.063 2.063 0 1 1 2.063 2.065zm1.782 13.019H3.555V9h3.564v11.452zM22.225 0H1.771C.792 0 0 .774 0 1.729v20.542C0 23.227.792 24 1.771 24h20.451C23.2 24 24 23.227 24 22.271V1.729C24 .774 23.2 0 22.222 0h.003z"})})},{id:"tiktok",name:"TikTok",tagline:"Publish videos, list own videos, manage comments. Pre-audit: videos post as SELF_ONLY until TikTok review.",accent:"#25F4EE",logo:o.jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor",className:"w-8 h-8",children:o.jsx("path",{d:"M12.525.02c1.31-.02 2.61-.01 3.91-.02.08 1.53.63 3.09 1.75 4.17 1.12 1.11 2.7 1.62 4.24 1.79v4.03c-1.44-.05-2.89-.35-4.2-.97-.57-.26-1.1-.59-1.62-.93-.01 2.92.01 5.84-.02 8.75-.08 1.4-.54 2.79-1.35 3.94-1.31 1.92-3.58 3.17-5.91 3.21-1.43.08-2.86-.31-4.08-1.03-2.02-1.19-3.44-3.37-3.65-5.71-.02-.5-.03-1-.01-1.49.18-1.9 1.12-3.72 2.58-4.96 1.66-1.44 3.98-2.13 6.15-1.72.02 1.48-.04 2.96-.04 4.44-.99-.32-2.15-.23-3.02.37-.63.41-1.11 1.04-1.36 1.75-.21.51-.15 1.07-.14 1.61.24 1.64 1.82 3.02 3.5 2.87 1.12-.01 2.19-.66 2.77-1.61.19-.33.4-.67.41-1.06.1-1.79.06-3.57.07-5.36.01-4.03-.01-8.05.02-12.07z"})})}];function xq(){const[t,e]=x.useState(null),[n,r]=x.useState(!0),[i,s]=x.useState(null),[a,c]=x.useState(null),[h,d]=x.useState(null),[f,p]=x.useState({clientId:"",clientSecret:"",extraScopesText:"",redirectMode:"auto",redirectUriOverride:""}),[g,v]=x.useState(!1),[k,w]=x.useState(!1),S=ma(),T=Pc(),C=async()=>{try{const E=await we("/api/integrations");E.ok&&e(await E.json())}catch(E){console.error("integrations fetch failed",E)}finally{r(!1)}};x.useEffect(()=>{C()},[]),x.useEffect(()=>{const E=new URLSearchParams(S.search),P=E.get("connected"),V=E.get("label"),F=E.get("error");P&&V?(me.success(`Connected ${P} — ${V}`),C(),T("/integrations",{replace:!0})):F&&(me.error(`Connect failed: ${decodeURIComponent(F)}`),T("/integrations",{replace:!0}))},[S.search,T]);const j=async E=>{s(E);try{const P=await we(`/api/integrations/${E}/start`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({uiOrigin:window.location.origin})});if(!P.ok){const F=await P.json().catch(()=>({error:"Failed"}));me.error(`Could not start auth: ${F.error??P.statusText}`),s(null);return}const{url:V}=await P.json();window.location.assign(V)}catch(P){me.error(`Could not start auth: ${P.message}`),s(null)}},R=async E=>{try{const P=await we(`/api/integrations/${E}/credentials`);if(!P.ok){const F=await P.json().catch(()=>({error:P.statusText}));me.error(`Could not load credentials: ${F.error??P.statusText}`);return}const V=await P.json();d(V),p({clientId:"",clientSecret:"",extraScopesText:V.extraScopes.join(", "),redirectMode:V.redirectUriOverride&&V.redirectUriOverride.length>0?"pinned":"auto",redirectUriOverride:V.redirectUriOverride??""})}catch(P){me.error(`Could not load credentials: ${P.message}`)}},_=async()=>{if(h){v(!0);try{const E=f.extraScopesText.split(/[\n,]+/).map(F=>F.trim()).filter(Boolean),P={clientId:f.clientId.trim(),extraScopes:E,redirectUriOverride:f.redirectMode==="pinned"?f.redirectUriOverride.trim():""};(h.requiresClientSecret||h.showsClientSecret)&&(P.clientSecret=f.clientSecret.trim());const V=await we(`/api/integrations/${h.integration}/credentials`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(P)});if(!V.ok){const F=await V.json().catch(()=>({error:V.statusText}));me.error(`Save failed: ${F.error??V.statusText}`);return}me.success(h.sharedWith.length>1?`Saved — also unlocks ${h.sharedWith.filter(F=>F!==h.integration).join(", ")}`:"Credentials saved"),d(null),await C()}catch(E){me.error(`Save failed: ${E.message}`)}finally{v(!1)}}},I=()=>{h&&w(!0)},M=async()=>{if(h){w(!1),v(!0);try{const E=await we(`/api/integrations/${h.integration}/credentials`,{method:"DELETE"});if(!E.ok){me.error(`Clear failed: ${E.statusText}`);return}me.success("Credentials cleared"),d(null),await C()}finally{v(!1)}}},L=(E,P)=>{navigator.clipboard.writeText(E).then(()=>me.success(`${P} copied`),()=>me.error(`Couldn't copy ${P}`))},$=async()=>{if(!a)return;const{id:E,accountId:P}=a;c(null),s(E);try{const V=await we(`/api/integrations/${E}/${encodeURIComponent(P)}`,{method:"DELETE"});if(!V.ok){const F=await V.json().catch(()=>({error:"Failed"}));me.error(`Disconnect failed: ${F.error??V.statusText}`);return}me.success(`Disconnected ${E}`),await C()}finally{s(null)}};return n||!t?o.jsxs("div",{className:"p-8 flex items-center gap-3 text-gray-500 font-mono text-[11px]",children:[o.jsx($t,{className:"w-4 h-4 animate-spin"}),"Loading integrations…"]}):o.jsxs("div",{className:"relative flex-1 flex flex-col overflow-y-auto",children:[o.jsx("div",{className:"absolute inset-0 opacity-[0.03] pointer-events-none bg-[url('https://grainy-gradients.vercel.app/noise.svg')] bg-repeat"}),o.jsxs("div",{className:"max-w-5xl mx-auto w-full px-6 py-8 relative z-10",children:[o.jsxs("header",{className:"mb-8",children:[o.jsx("h1",{className:"text-2xl font-bold bg-gradient-to-r from-white via-[#00d9ff] to-[#4ECDC4] bg-clip-text text-transparent",children:"Integrations"}),o.jsx("p",{className:"mt-1 text-xs text-gray-500 font-mono uppercase tracking-widest",children:"Connect services — crews unlock on connect."})]}),o.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:yq.map(E=>{const P=t.availability[E.id],V=t.accounts.filter(K=>K.integration===E.id),F=i===E.id;return o.jsxs("div",{className:"rounded-xl border border-slate-800/60 bg-slate-900/40 backdrop-blur-sm overflow-hidden",children:[o.jsxs("div",{className:"flex items-start gap-4 px-5 py-4",children:[o.jsx("div",{className:"w-12 h-12 rounded-lg flex items-center justify-center flex-shrink-0 shadow-md",style:{color:E.accent,background:"rgba(0,0,0,0.45)",border:`1px solid ${E.accent}40`},children:E.logo}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("h3",{className:"text-sm font-semibold text-white tracking-tight",children:E.name}),V.length>0&&o.jsxs("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded-sm text-[9px] font-mono uppercase tracking-widest text-[#4ECDC4] bg-[#4ECDC4]/10 border border-[#4ECDC4]/30",children:[o.jsx(_i,{className:"w-2.5 h-2.5"})," connected"]})]}),o.jsx("p",{className:"mt-1 text-[11px] text-gray-400 leading-relaxed",children:E.tagline}),!(P!=null&&P.available)&&o.jsxs("div",{className:"mt-2 flex items-start gap-1.5 text-[10px] font-mono text-amber-400/80",children:[o.jsx(Zi,{className:"w-3 h-3 flex-shrink-0 mt-0.5"}),o.jsx("span",{children:(P==null?void 0:P.reason)??"Not configured"})]})]})]}),V.length>0&&o.jsx("div",{className:"px-5 pb-3 space-y-2",children:V.map(K=>o.jsxs("div",{className:"flex items-center justify-between gap-2 px-3 py-2 rounded-md bg-slate-950/40 border border-slate-800/60",children:[o.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[o.jsx("div",{className:"w-1.5 h-1.5 rounded-full flex-shrink-0",style:{background:E.accent}}),o.jsx("span",{className:"text-[11px] font-mono text-gray-200 truncate",children:K.accountLabel}),K.expiresAt>0&&K.expiresAt<Math.floor(Date.now()/1e3)&&o.jsx("span",{className:"text-[9px] font-mono text-amber-400 uppercase tracking-widest",children:"refresh due"})]}),o.jsxs("button",{type:"button",disabled:F,onClick:()=>c({id:E.id,accountId:K.accountId,label:K.accountLabel}),className:"inline-flex items-center gap-1 px-2 py-1 text-[10px] font-mono uppercase tracking-widest text-gray-400 hover:text-red-400 hover:bg-red-500/10 border border-slate-800/60 hover:border-red-500/30 rounded transition-colors disabled:opacity-50",children:[o.jsx(S1,{className:"w-3 h-3"})," disconnect"]})]},K.accountId))}),o.jsxs("div",{className:"px-5 py-3 border-t border-slate-800/60 bg-slate-950/30 flex items-center justify-between gap-2",children:[o.jsx("span",{className:"text-[9px] font-mono text-gray-600 uppercase tracking-widest",children:V.length>0?`${V.length} account${V.length===1?"":"s"}`:"not connected"}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsxs("button",{type:"button",onClick:()=>R(E.id),className:"inline-flex items-center gap-1 px-2 py-1.5 text-[10px] font-mono uppercase tracking-widest rounded text-gray-400 hover:text-white hover:bg-slate-800/60 border border-slate-800/60 hover:border-slate-700 transition-colors",title:"Configure OAuth credentials",children:[o.jsx(pp,{className:"w-3 h-3"})," setup"]}),o.jsxs("button",{type:"button",disabled:!(P!=null&&P.available)||F,onClick:()=>j(E.id),className:["inline-flex items-center gap-1.5 px-3 py-1.5 text-[11px] font-mono uppercase tracking-widest rounded transition-all disabled:opacity-40 disabled:cursor-not-allowed",V.length>0?"text-[#4ECDC4] bg-[#4ECDC4]/10 border border-[#4ECDC4]/30 hover:bg-[#4ECDC4]/20":"text-[#00d9ff] bg-[#00d9ff]/10 border border-[#00d9ff]/40 hover:bg-[#00d9ff]/20"].join(" "),children:[F?o.jsx($t,{className:"w-3 h-3 animate-spin"}):o.jsx(yD,{className:"w-3 h-3"}),V.length>0?"add account":"connect"]})]})]})]},E.id)})}),o.jsx(hi,{open:h!==null,onOpenChange:E=>!E&&!g&&d(null),children:o.jsx(fi,{className:"bg-slate-950 border border-slate-800 text-gray-200 font-mono w-[92vw] max-w-[480px] p-0 overflow-hidden shadow-2xl shadow-[#00d9ff]/5",children:h&&o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"px-5 py-4 pr-10 border-b border-slate-800 bg-gradient-to-r from-slate-900/80 to-slate-950",children:o.jsxs(pi,{children:[o.jsxs(mi,{className:"text-sm font-semibold text-white tracking-tight uppercase flex items-center gap-2 pr-2",children:[o.jsx("span",{className:"w-1 h-4 bg-[#00d9ff] rounded-sm"}),o.jsxs("span",{children:["Configure ",h.provider]}),h.configured&&o.jsxs("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-[9px] tracking-widest text-[#4ECDC4] bg-[#4ECDC4]/10 border border-[#4ECDC4]/30",children:[o.jsx(_i,{className:"w-2.5 h-2.5"})," SAVED"]})]}),o.jsxs(vq,{className:"sr-only",children:["Configure OAuth credentials for ",h.provider,"."]})]})}),o.jsxs("div",{className:"px-5 py-4 space-y-4 max-h-[70vh] overflow-y-auto",children:[h.sharedWith.length>1&&o.jsxs("div",{className:"flex items-start gap-2 px-3 py-2 bg-[#00d9ff]/5 border-l-2 border-[#00d9ff] rounded-r",children:[o.jsx(Zi,{className:"w-3.5 h-3.5 text-[#00d9ff] flex-shrink-0 mt-0.5"}),o.jsxs("p",{className:"text-[11px] text-gray-300 leading-relaxed",children:["Saves credentials for ",o.jsx("span",{className:"text-[#00d9ff]",children:h.sharedWith.join(", ")})," — they share one OAuth app."]})]}),o.jsxs("a",{href:h.consoleUrl,target:"_blank",rel:"noopener noreferrer",className:"flex items-center justify-between px-3 py-2 rounded text-[11px] text-[#00d9ff] bg-[#00d9ff]/5 border border-[#00d9ff]/20 hover:bg-[#00d9ff]/10 hover:border-[#00d9ff]/40 transition-colors",children:[o.jsxs("span",{children:["Open ",h.provider," developer console"]}),o.jsx(nD,{className:"w-3 h-3"})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-[10px] uppercase tracking-widest text-gray-500 mb-1.5",children:"Step 1 — Authorized redirect URI"}),o.jsxs("div",{className:"flex items-stretch rounded overflow-hidden border border-slate-800 bg-slate-900",children:[o.jsx("code",{className:"flex-1 px-3 py-2 text-[11px] text-gray-300 truncate",children:h.redirectUri}),o.jsx("button",{type:"button",onClick:()=>L(h.redirectUri,"Redirect URI"),className:"px-3 border-l border-slate-800 text-gray-400 hover:text-[#00d9ff] hover:bg-slate-800/60 transition-colors",title:"Copy",children:o.jsx(df,{className:"w-3.5 h-3.5"})})]}),o.jsx("p",{className:"mt-1 text-[10px] text-gray-500",children:"Paste this verbatim into the provider's console."})]}),o.jsxs("div",{children:[o.jsxs("div",{className:"flex items-baseline justify-between mb-2",children:[o.jsx("label",{className:"text-[10px] uppercase tracking-widest text-gray-500",children:"Redirect URI mode"}),o.jsxs("span",{className:"text-[9px] tracking-normal text-gray-600 normal-case",children:["Affects what daemora sends as ",o.jsx("code",{children:"redirect_uri"})]})]}),o.jsxs("div",{className:"grid grid-cols-2 gap-1 p-1 rounded border border-slate-800 bg-slate-900/50",children:[o.jsx("button",{type:"button",onClick:()=>p({...f,redirectMode:"auto"}),className:`px-3 py-1.5 rounded text-[10px] font-mono uppercase tracking-wider transition-colors ${f.redirectMode==="auto"?"bg-[#00d9ff]/15 text-[#00d9ff] border border-[#00d9ff]/40":"text-gray-500 hover:text-gray-300 border border-transparent"}`,children:"Auto · browser URL"}),o.jsx("button",{type:"button",onClick:()=>p({...f,redirectMode:"pinned"}),className:`px-3 py-1.5 rounded text-[10px] font-mono uppercase tracking-wider transition-colors ${f.redirectMode==="pinned"?"bg-[#00d9ff]/15 text-[#00d9ff] border border-[#00d9ff]/40":"text-gray-500 hover:text-gray-300 border border-transparent"}`,children:"Pinned · custom"})]}),f.redirectMode==="auto"?(()=>{const E=`${window.location.origin}/oauth/callback`,P=h.redirectUri,V=E!==P;return o.jsxs("div",{className:"mt-2 space-y-1.5",children:[o.jsxs("p",{className:"text-[10px] text-gray-500 leading-relaxed",children:["Auto sends your ",o.jsx("em",{children:"browser's"})," URL — right now: ",o.jsx("code",{className:"text-gray-300",children:E}),"."]}),V&&o.jsxs("div",{className:"flex items-start gap-2 px-2.5 py-1.5 rounded border border-amber-500/30 bg-amber-500/5",children:[o.jsx(Zi,{className:"w-3 h-3 text-amber-400 flex-shrink-0 mt-0.5"}),o.jsxs("p",{className:"text-[10px] text-amber-300 leading-relaxed",children:["This ",o.jsx("strong",{children:"doesn't match"})," the URL in Step 1 (",o.jsx("code",{className:"text-amber-200",children:P}),") — Auto mode will send your browser's URL instead. Switch to ",o.jsx("strong",{children:"Pinned"})," and paste the registered URL, or reopen daemora at that URL."]})]})]})})():o.jsxs("div",{className:"mt-2",children:[o.jsx("input",{type:"url",value:f.redirectUriOverride,onChange:E=>p({...f,redirectUriOverride:E.target.value}),placeholder:"https://your-tunnel.example.com/oauth/callback",className:"w-full px-3 py-2.5 text-[12px] rounded bg-slate-900 border border-slate-800 text-white placeholder:text-gray-600 focus:outline-none focus:border-[#00d9ff] focus:ring-1 focus:ring-[#00d9ff]/40 transition-colors"}),o.jsxs("p",{className:"mt-1 text-[10px] text-gray-500 leading-relaxed",children:["Sent verbatim — must match what's registered in the provider's portal. Useful when the URL bar disagrees with the registered URL (e.g. TikTok rejects ",o.jsx("code",{children:"http://localhost"})," and needs an HTTPS tunnel)."]})]})]}),o.jsxs("div",{children:[o.jsxs("label",{className:"flex items-baseline justify-between text-[10px] uppercase tracking-widest text-gray-500 mb-1.5",children:[o.jsxs("span",{children:["Step 2 — ",h.clientIdLabel]}),h.hasClientId&&o.jsx("span",{className:"text-[#4ECDC4] normal-case tracking-normal text-[10px]",children:"saved · leave blank to keep"})]}),o.jsx("input",{type:"text",value:f.clientId,onChange:E=>p({...f,clientId:E.target.value}),placeholder:h.hasClientId?"•••••••• overwrite to change":"Paste from console",className:"w-full px-3 py-2.5 text-[12px] rounded bg-slate-900 border border-slate-800 text-white placeholder:text-gray-600 focus:outline-none focus:border-[#00d9ff] focus:ring-1 focus:ring-[#00d9ff]/40 transition-colors"})]}),(h.requiresClientSecret||h.showsClientSecret)&&h.clientSecretLabel&&o.jsxs("div",{children:[o.jsxs("label",{className:"flex items-baseline justify-between text-[10px] uppercase tracking-widest text-gray-500 mb-1.5",children:[o.jsxs("span",{children:["Step 3 — ",h.clientSecretLabel]}),h.hasClientSecret&&o.jsx("span",{className:"text-[#4ECDC4] normal-case tracking-normal text-[10px]",children:"saved · leave blank to keep"})]}),o.jsx("input",{type:"password",value:f.clientSecret,onChange:E=>p({...f,clientSecret:E.target.value}),placeholder:h.hasClientSecret?"•••••••• overwrite to change":"Paste from console",className:"w-full px-3 py-2.5 text-[12px] rounded bg-slate-900 border border-slate-800 text-white placeholder:text-gray-600 focus:outline-none focus:border-[#00d9ff] focus:ring-1 focus:ring-[#00d9ff]/40 transition-colors"})]}),h.defaultScopes.length>0&&o.jsxs("details",{className:"group",children:[o.jsxs("summary",{className:"cursor-pointer text-[10px] uppercase tracking-widest text-gray-500 hover:text-gray-300 transition-colors flex items-center gap-1.5",children:[o.jsx(fp,{className:"w-3 h-3 group-open:rotate-90 transition-transform"}),"Default scopes (",h.defaultScopes.length,") — included automatically"]}),o.jsx("div",{className:"mt-2 space-y-1 max-h-32 overflow-y-auto pr-1",children:h.defaultScopes.map(E=>o.jsx("div",{className:"text-[10px] px-2 py-1 rounded bg-slate-900 border border-slate-800/60 text-gray-400 font-mono break-all",children:E},E))})]}),o.jsxs("div",{children:[o.jsxs("label",{className:"block text-[10px] uppercase tracking-widest text-gray-500 mb-1.5",children:["Extra scopes ",o.jsx("span",{className:"normal-case tracking-normal text-gray-600",children:"· comma-separated · optional"})]}),o.jsx("input",{type:"text",value:f.extraScopesText,onChange:E=>p({...f,extraScopesText:E.target.value}),placeholder:"https://www.googleapis.com/auth/drive.readonly, ...",className:"w-full px-3 py-2.5 text-[11px] rounded bg-slate-900 border border-slate-800 text-white placeholder:text-gray-600 focus:outline-none focus:border-[#00d9ff] focus:ring-1 focus:ring-[#00d9ff]/40 transition-colors font-mono"}),o.jsx("p",{className:"mt-1 text-[10px] text-gray-500",children:"Applied on next connect. Existing accounts keep their scopes until reconnected."})]})]}),o.jsxs("div",{className:"px-5 py-3 border-t border-slate-800 bg-slate-950 flex items-center justify-between gap-2",children:[h.configured?o.jsxs("button",{type:"button",onClick:I,disabled:g,className:"inline-flex items-center gap-1 px-2.5 py-1.5 text-[10px] font-mono uppercase tracking-widest text-red-400 hover:text-red-300 hover:bg-red-500/10 border border-red-500/30 hover:border-red-500/50 rounded transition-colors disabled:opacity-50",children:[o.jsx(qn,{className:"w-3 h-3"})," clear"]}):o.jsx("span",{}),o.jsxs("div",{className:"flex gap-2",children:[o.jsx("button",{type:"button",onClick:()=>d(null),disabled:g,className:"px-3 py-1.5 text-[11px] font-mono uppercase tracking-widest rounded bg-slate-900 border border-slate-800 text-gray-300 hover:bg-slate-800 hover:text-white disabled:opacity-50",children:"Cancel"}),o.jsxs("button",{type:"button",onClick:_,disabled:g||!(h!=null&&h.hasClientId)&&!f.clientId.trim()||(h==null?void 0:h.requiresClientSecret)&&!(h!=null&&h.hasClientSecret)&&!f.clientSecret.trim(),className:"inline-flex items-center gap-1.5 px-3 py-1.5 text-[11px] font-mono uppercase tracking-widest rounded text-[#00d9ff] bg-[#00d9ff]/10 border border-[#00d9ff]/40 hover:bg-[#00d9ff]/20 hover:shadow-[0_0_12px_rgba(0,217,255,0.25)] disabled:opacity-40 disabled:cursor-not-allowed transition-all",children:[g?o.jsx($t,{className:"w-3 h-3 animate-spin"}):o.jsx(_i,{className:"w-3 h-3"}),"save"]})]})]})]})})}),o.jsx(js,{open:k,onOpenChange:w,children:o.jsxs(Ps,{className:"bg-slate-950 border-slate-800/80 text-gray-200 font-mono",children:[o.jsxs(_s,{children:[o.jsxs(Is,{className:"text-white tracking-tight flex items-center gap-2",children:[o.jsx(qn,{className:"w-4 h-4 text-red-400"}),"Remove credentials for ",h==null?void 0:h.provider]}),o.jsx(Ms,{className:"text-gray-400 text-sm leading-relaxed",children:"Stored Client ID, Client Secret (if any), and Extra Scopes will be deleted from the vault. Already-connected accounts keep working until their access tokens expire — at that point you'll need to reconfigure to refresh."})]}),o.jsxs(Rs,{children:[o.jsx(As,{className:"bg-slate-900 border-slate-800 text-gray-300 hover:bg-slate-800 hover:text-white",children:"Cancel"}),o.jsx(Ds,{onClick:M,disabled:g,className:"bg-red-600 hover:bg-red-500 text-white border border-red-500/40",children:g?"Removing…":"Remove"})]})]})}),o.jsx(js,{open:a!==null,onOpenChange:E=>!E&&c(null),children:o.jsxs(Ps,{className:"bg-slate-950 border-slate-800/80 text-gray-200 font-mono",children:[o.jsxs(_s,{children:[o.jsxs(Is,{className:"text-white tracking-tight flex items-center gap-2",children:[o.jsx(S1,{className:"w-4 h-4 text-red-400"}),"Disconnect ",a==null?void 0:a.id]}),o.jsx(Ms,{className:"text-gray-400 text-sm leading-relaxed",children:a&&o.jsxs(o.Fragment,{children:["This will disconnect ",o.jsx("span",{className:"text-[#00d9ff]",children:a.label}),". The ",o.jsxs("code",{children:[a.id,"-crew"]})," will disappear from the agent's crew list until you reconnect. Your stored posts and history stay intact."]})})]}),o.jsxs(Rs,{children:[o.jsx(As,{className:"bg-slate-900 border-slate-800 text-gray-300 hover:bg-slate-800 hover:text-white",children:"Cancel"}),o.jsx(Ds,{onClick:$,className:"bg-red-600 hover:bg-red-500 text-white border border-red-500/40",children:"Disconnect"})]})]})}),o.jsxs("div",{className:"mt-8 p-4 rounded-xl border border-slate-800/60 bg-slate-900/40",children:[o.jsx("h4",{className:"text-[11px] font-mono uppercase tracking-widest text-gray-400 mb-2",children:"How this works"}),o.jsxs("ul",{className:"text-[12px] text-gray-500 leading-relaxed space-y-1 list-disc list-inside",children:[o.jsxs("li",{children:["Click ",o.jsx("em",{children:"connect"})," — you're redirected to the provider to grant access."]}),o.jsxs("li",{children:["On return, a crew appears (e.g. ",o.jsx("code",{className:"text-[#00d9ff]",children:"twitter-crew"}),") with all that platform's tools."]}),o.jsx("li",{children:"Tokens are refreshed automatically while a refresh grant is valid; you only re-connect on revocation or scope changes."}),o.jsx("li",{children:"Disconnect hides the crew instantly; reconnect to restore it."})]})]})]})]})}const bq=["top","right","bottom","left"],co=Math.min,ci=Math.max,ep=Math.round,tf=Math.floor,Ns=t=>({x:t,y:t}),kq={left:"right",right:"left",bottom:"top",top:"bottom"};function Jv(t,e,n){return ci(t,co(e,n))}function fa(t,e){return typeof t=="function"?t(e):t}function pa(t){return t.split("-")[0]}function Dc(t){return t.split("-")[1]}function Ux(t){return t==="x"?"y":"x"}function Bx(t){return t==="y"?"height":"width"}function bs(t){const e=t[0];return e==="t"||e==="b"?"y":"x"}function zx(t){return Ux(bs(t))}function wq(t,e,n){n===void 0&&(n=!1);const r=Dc(t),i=zx(t),s=Bx(i);let a=i==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return e.reference[s]>e.floating[s]&&(a=tp(a)),[a,tp(a)]}function Sq(t){const e=tp(t);return[Xv(t),e,Xv(e)]}function Xv(t){return t.includes("start")?t.replace("start","end"):t.replace("end","start")}const sT=["left","right"],aT=["right","left"],Cq=["top","bottom"],Tq=["bottom","top"];function Nq(t,e,n){switch(t){case"top":case"bottom":return n?e?aT:sT:e?sT:aT;case"left":case"right":return e?Cq:Tq;default:return[]}}function Eq(t,e,n,r){const i=Dc(t);let s=Nq(pa(t),n==="start",r);return i&&(s=s.map(a=>a+"-"+i),e&&(s=s.concat(s.map(Xv)))),s}function tp(t){const e=pa(t);return kq[e]+t.slice(e.length)}function jq(t){return{top:0,right:0,bottom:0,left:0,...t}}function N_(t){return typeof t!="number"?jq(t):{top:t,right:t,bottom:t,left:t}}function np(t){const{x:e,y:n,width:r,height:i}=t;return{width:r,height:i,top:n,left:e,right:e+r,bottom:n+i,x:e,y:n}}function oT(t,e,n){let{reference:r,floating:i}=t;const s=bs(e),a=zx(e),c=Bx(a),h=pa(e),d=s==="y",f=r.x+r.width/2-i.width/2,p=r.y+r.height/2-i.height/2,g=r[c]/2-i[c]/2;let v;switch(h){case"top":v={x:f,y:r.y-i.height};break;case"bottom":v={x:f,y:r.y+r.height};break;case"right":v={x:r.x+r.width,y:p};break;case"left":v={x:r.x-i.width,y:p};break;default:v={x:r.x,y:r.y}}switch(Dc(e)){case"start":v[a]-=g*(n&&d?-1:1);break;case"end":v[a]+=g*(n&&d?-1:1);break}return v}async function Pq(t,e){var n;e===void 0&&(e={});const{x:r,y:i,platform:s,rects:a,elements:c,strategy:h}=t,{boundary:d="clippingAncestors",rootBoundary:f="viewport",elementContext:p="floating",altBoundary:g=!1,padding:v=0}=fa(e,t),k=N_(v),S=c[g?p==="floating"?"reference":"floating":p],T=np(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(S)))==null||n?S:S.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(c.floating)),boundary:d,rootBoundary:f,strategy:h})),C=p==="floating"?{x:r,y:i,width:a.floating.width,height:a.floating.height}:a.reference,j=await(s.getOffsetParent==null?void 0:s.getOffsetParent(c.floating)),R=await(s.isElement==null?void 0:s.isElement(j))?await(s.getScale==null?void 0:s.getScale(j))||{x:1,y:1}:{x:1,y:1},_=np(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:c,rect:C,offsetParent:j,strategy:h}):C);return{top:(T.top-_.top+k.top)/R.y,bottom:(_.bottom-T.bottom+k.bottom)/R.y,left:(T.left-_.left+k.left)/R.x,right:(_.right-T.right+k.right)/R.x}}const _q=50,Rq=async(t,e,n)=>{const{placement:r="bottom",strategy:i="absolute",middleware:s=[],platform:a}=n,c=a.detectOverflow?a:{...a,detectOverflow:Pq},h=await(a.isRTL==null?void 0:a.isRTL(e));let d=await a.getElementRects({reference:t,floating:e,strategy:i}),{x:f,y:p}=oT(d,r,h),g=r,v=0;const k={};for(let w=0;w<s.length;w++){const S=s[w];if(!S)continue;const{name:T,fn:C}=S,{x:j,y:R,data:_,reset:I}=await C({x:f,y:p,initialPlacement:r,placement:g,strategy:i,middlewareData:k,rects:d,platform:c,elements:{reference:t,floating:e}});f=j??f,p=R??p,k[T]={...k[T],..._},I&&v<_q&&(v++,typeof I=="object"&&(I.placement&&(g=I.placement),I.rects&&(d=I.rects===!0?await a.getElementRects({reference:t,floating:e,strategy:i}):I.rects),{x:f,y:p}=oT(d,g,h)),w=-1)}return{x:f,y:p,placement:g,strategy:i,middlewareData:k}},Iq=t=>({name:"arrow",options:t,async fn(e){const{x:n,y:r,placement:i,rects:s,platform:a,elements:c,middlewareData:h}=e,{element:d,padding:f=0}=fa(t,e)||{};if(d==null)return{};const p=N_(f),g={x:n,y:r},v=zx(i),k=Bx(v),w=await a.getDimensions(d),S=v==="y",T=S?"top":"left",C=S?"bottom":"right",j=S?"clientHeight":"clientWidth",R=s.reference[k]+s.reference[v]-g[v]-s.floating[k],_=g[v]-s.reference[v],I=await(a.getOffsetParent==null?void 0:a.getOffsetParent(d));let M=I?I[j]:0;(!M||!await(a.isElement==null?void 0:a.isElement(I)))&&(M=c.floating[j]||s.floating[k]);const L=R/2-_/2,$=M/2-w[k]/2-1,E=co(p[T],$),P=co(p[C],$),V=E,F=M-w[k]-P,K=M/2-w[k]/2+L,J=Jv(V,K,F),Q=!h.arrow&&Dc(i)!=null&&K!==J&&s.reference[k]/2-(K<V?E:P)-w[k]/2<0,Z=Q?K<V?K-V:K-F:0;return{[v]:g[v]+Z,data:{[v]:J,centerOffset:K-J-Z,...Q&&{alignmentOffset:Z}},reset:Q}}}),Mq=function(t){return t===void 0&&(t={}),{name:"flip",options:t,async fn(e){var n,r;const{placement:i,middlewareData:s,rects:a,initialPlacement:c,platform:h,elements:d}=e,{mainAxis:f=!0,crossAxis:p=!0,fallbackPlacements:g,fallbackStrategy:v="bestFit",fallbackAxisSideDirection:k="none",flipAlignment:w=!0,...S}=fa(t,e);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const T=pa(i),C=bs(c),j=pa(c)===c,R=await(h.isRTL==null?void 0:h.isRTL(d.floating)),_=g||(j||!w?[tp(c)]:Sq(c)),I=k!=="none";!g&&I&&_.push(...Eq(c,w,k,R));const M=[c,..._],L=await h.detectOverflow(e,S),$=[];let E=((r=s.flip)==null?void 0:r.overflows)||[];if(f&&$.push(L[T]),p){const K=wq(i,a,R);$.push(L[K[0]],L[K[1]])}if(E=[...E,{placement:i,overflows:$}],!$.every(K=>K<=0)){var P,V;const K=(((P=s.flip)==null?void 0:P.index)||0)+1,J=M[K];if(J&&(!(p==="alignment"?C!==bs(J):!1)||E.every(D=>bs(D.placement)===C?D.overflows[0]>0:!0)))return{data:{index:K,overflows:E},reset:{placement:J}};let Q=(V=E.filter(Z=>Z.overflows[0]<=0).sort((Z,D)=>Z.overflows[1]-D.overflows[1])[0])==null?void 0:V.placement;if(!Q)switch(v){case"bestFit":{var F;const Z=(F=E.filter(D=>{if(I){const ne=bs(D.placement);return ne===C||ne==="y"}return!0}).map(D=>[D.placement,D.overflows.filter(ne=>ne>0).reduce((ne,A)=>ne+A,0)]).sort((D,ne)=>D[1]-ne[1])[0])==null?void 0:F[0];Z&&(Q=Z);break}case"initialPlacement":Q=c;break}if(i!==Q)return{reset:{placement:Q}}}return{}}}};function lT(t,e){return{top:t.top-e.height,right:t.right-e.width,bottom:t.bottom-e.height,left:t.left-e.width}}function cT(t){return bq.some(e=>t[e]>=0)}const Dq=function(t){return t===void 0&&(t={}),{name:"hide",options:t,async fn(e){const{rects:n,platform:r}=e,{strategy:i="referenceHidden",...s}=fa(t,e);switch(i){case"referenceHidden":{const a=await r.detectOverflow(e,{...s,elementContext:"reference"}),c=lT(a,n.reference);return{data:{referenceHiddenOffsets:c,referenceHidden:cT(c)}}}case"escaped":{const a=await r.detectOverflow(e,{...s,altBoundary:!0}),c=lT(a,n.floating);return{data:{escapedOffsets:c,escaped:cT(c)}}}default:return{}}}}},E_=new Set(["left","top"]);async function Aq(t,e){const{placement:n,platform:r,elements:i}=t,s=await(r.isRTL==null?void 0:r.isRTL(i.floating)),a=pa(n),c=Dc(n),h=bs(n)==="y",d=E_.has(a)?-1:1,f=s&&h?-1:1,p=fa(e,t);let{mainAxis:g,crossAxis:v,alignmentAxis:k}=typeof p=="number"?{mainAxis:p,crossAxis:0,alignmentAxis:null}:{mainAxis:p.mainAxis||0,crossAxis:p.crossAxis||0,alignmentAxis:p.alignmentAxis};return c&&typeof k=="number"&&(v=c==="end"?k*-1:k),h?{x:v*f,y:g*d}:{x:g*d,y:v*f}}const Oq=function(t){return t===void 0&&(t=0),{name:"offset",options:t,async fn(e){var n,r;const{x:i,y:s,placement:a,middlewareData:c}=e,h=await Aq(e,t);return a===((n=c.offset)==null?void 0:n.placement)&&(r=c.arrow)!=null&&r.alignmentOffset?{}:{x:i+h.x,y:s+h.y,data:{...h,placement:a}}}}},Lq=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(e){const{x:n,y:r,placement:i,platform:s}=e,{mainAxis:a=!0,crossAxis:c=!1,limiter:h={fn:T=>{let{x:C,y:j}=T;return{x:C,y:j}}},...d}=fa(t,e),f={x:n,y:r},p=await s.detectOverflow(e,d),g=bs(pa(i)),v=Ux(g);let k=f[v],w=f[g];if(a){const T=v==="y"?"top":"left",C=v==="y"?"bottom":"right",j=k+p[T],R=k-p[C];k=Jv(j,k,R)}if(c){const T=g==="y"?"top":"left",C=g==="y"?"bottom":"right",j=w+p[T],R=w-p[C];w=Jv(j,w,R)}const S=h.fn({...e,[v]:k,[g]:w});return{...S,data:{x:S.x-n,y:S.y-r,enabled:{[v]:a,[g]:c}}}}}},Fq=function(t){return t===void 0&&(t={}),{options:t,fn(e){const{x:n,y:r,placement:i,rects:s,middlewareData:a}=e,{offset:c=0,mainAxis:h=!0,crossAxis:d=!0}=fa(t,e),f={x:n,y:r},p=bs(i),g=Ux(p);let v=f[g],k=f[p];const w=fa(c,e),S=typeof w=="number"?{mainAxis:w,crossAxis:0}:{mainAxis:0,crossAxis:0,...w};if(h){const j=g==="y"?"height":"width",R=s.reference[g]-s.floating[j]+S.mainAxis,_=s.reference[g]+s.reference[j]-S.mainAxis;v<R?v=R:v>_&&(v=_)}if(d){var T,C;const j=g==="y"?"width":"height",R=E_.has(pa(i)),_=s.reference[p]-s.floating[j]+(R&&((T=a.offset)==null?void 0:T[p])||0)+(R?0:S.crossAxis),I=s.reference[p]+s.reference[j]+(R?0:((C=a.offset)==null?void 0:C[p])||0)-(R?S.crossAxis:0);k<_?k=_:k>I&&(k=I)}return{[g]:v,[p]:k}}}},Uq=function(t){return t===void 0&&(t={}),{name:"size",options:t,async fn(e){var n,r;const{placement:i,rects:s,platform:a,elements:c}=e,{apply:h=()=>{},...d}=fa(t,e),f=await a.detectOverflow(e,d),p=pa(i),g=Dc(i),v=bs(i)==="y",{width:k,height:w}=s.floating;let S,T;p==="top"||p==="bottom"?(S=p,T=g===(await(a.isRTL==null?void 0:a.isRTL(c.floating))?"start":"end")?"left":"right"):(T=p,S=g==="end"?"top":"bottom");const C=w-f.top-f.bottom,j=k-f.left-f.right,R=co(w-f[S],C),_=co(k-f[T],j),I=!e.middlewareData.shift;let M=R,L=_;if((n=e.middlewareData.shift)!=null&&n.enabled.x&&(L=j),(r=e.middlewareData.shift)!=null&&r.enabled.y&&(M=C),I&&!g){const E=ci(f.left,0),P=ci(f.right,0),V=ci(f.top,0),F=ci(f.bottom,0);v?L=k-2*(E!==0||P!==0?E+P:ci(f.left,f.right)):M=w-2*(V!==0||F!==0?V+F:ci(f.top,f.bottom))}await h({...e,availableWidth:L,availableHeight:M});const $=await a.getDimensions(c.floating);return k!==$.width||w!==$.height?{reset:{rects:!0}}:{}}}};function zp(){return typeof window<"u"}function Ac(t){return j_(t)?(t.nodeName||"").toLowerCase():"#document"}function gi(t){var e;return(t==null||(e=t.ownerDocument)==null?void 0:e.defaultView)||window}function $s(t){var e;return(e=(j_(t)?t.ownerDocument:t.document)||window.document)==null?void 0:e.documentElement}function j_(t){return zp()?t instanceof Node||t instanceof gi(t).Node:!1}function is(t){return zp()?t instanceof Element||t instanceof gi(t).Element:!1}function xa(t){return zp()?t instanceof HTMLElement||t instanceof gi(t).HTMLElement:!1}function uT(t){return!zp()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof gi(t).ShadowRoot}function Ed(t){const{overflow:e,overflowX:n,overflowY:r,display:i}=ss(t);return/auto|scroll|overlay|hidden|clip/.test(e+r+n)&&i!=="inline"&&i!=="contents"}function Bq(t){return/^(table|td|th)$/.test(Ac(t))}function $p(t){try{if(t.matches(":popover-open"))return!0}catch{}try{return t.matches(":modal")}catch{return!1}}const zq=/transform|translate|scale|rotate|perspective|filter/,$q=/paint|layout|strict|content/,Fo=t=>!!t&&t!=="none";let D0;function $x(t){const e=is(t)?ss(t):t;return Fo(e.transform)||Fo(e.translate)||Fo(e.scale)||Fo(e.rotate)||Fo(e.perspective)||!Vx()&&(Fo(e.backdropFilter)||Fo(e.filter))||zq.test(e.willChange||"")||$q.test(e.contain||"")}function Vq(t){let e=uo(t);for(;xa(e)&&!Ec(e);){if($x(e))return e;if($p(e))return null;e=uo(e)}return null}function Vx(){return D0==null&&(D0=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),D0}function Ec(t){return/^(html|body|#document)$/.test(Ac(t))}function ss(t){return gi(t).getComputedStyle(t)}function Vp(t){return is(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function uo(t){if(Ac(t)==="html")return t;const e=t.assignedSlot||t.parentNode||uT(t)&&t.host||$s(t);return uT(e)?e.host:e}function P_(t){const e=uo(t);return Ec(e)?t.ownerDocument?t.ownerDocument.body:t.body:xa(e)&&Ed(e)?e:P_(e)}function gd(t,e,n){var r;e===void 0&&(e=[]),n===void 0&&(n=!0);const i=P_(t),s=i===((r=t.ownerDocument)==null?void 0:r.body),a=gi(i);if(s){const c=Qv(a);return e.concat(a,a.visualViewport||[],Ed(i)?i:[],c&&n?gd(c):[])}else return e.concat(i,gd(i,[],n))}function Qv(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function __(t){const e=ss(t);let n=parseFloat(e.width)||0,r=parseFloat(e.height)||0;const i=xa(t),s=i?t.offsetWidth:n,a=i?t.offsetHeight:r,c=ep(n)!==s||ep(r)!==a;return c&&(n=s,r=a),{width:n,height:r,$:c}}function Wx(t){return is(t)?t:t.contextElement}function vc(t){const e=Wx(t);if(!xa(e))return Ns(1);const n=e.getBoundingClientRect(),{width:r,height:i,$:s}=__(e);let a=(s?ep(n.width):n.width)/r,c=(s?ep(n.height):n.height)/i;return(!a||!Number.isFinite(a))&&(a=1),(!c||!Number.isFinite(c))&&(c=1),{x:a,y:c}}const Wq=Ns(0);function R_(t){const e=gi(t);return!Vx()||!e.visualViewport?Wq:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function Hq(t,e,n){return e===void 0&&(e=!1),!n||e&&n!==gi(t)?!1:e}function pl(t,e,n,r){e===void 0&&(e=!1),n===void 0&&(n=!1);const i=t.getBoundingClientRect(),s=Wx(t);let a=Ns(1);e&&(r?is(r)&&(a=vc(r)):a=vc(t));const c=Hq(s,n,r)?R_(s):Ns(0);let h=(i.left+c.x)/a.x,d=(i.top+c.y)/a.y,f=i.width/a.x,p=i.height/a.y;if(s){const g=gi(s),v=r&&is(r)?gi(r):r;let k=g,w=Qv(k);for(;w&&r&&v!==k;){const S=vc(w),T=w.getBoundingClientRect(),C=ss(w),j=T.left+(w.clientLeft+parseFloat(C.paddingLeft))*S.x,R=T.top+(w.clientTop+parseFloat(C.paddingTop))*S.y;h*=S.x,d*=S.y,f*=S.x,p*=S.y,h+=j,d+=R,k=gi(w),w=Qv(k)}}return np({width:f,height:p,x:h,y:d})}function Wp(t,e){const n=Vp(t).scrollLeft;return e?e.left+n:pl($s(t)).left+n}function I_(t,e){const n=t.getBoundingClientRect(),r=n.left+e.scrollLeft-Wp(t,n),i=n.top+e.scrollTop;return{x:r,y:i}}function qq(t){let{elements:e,rect:n,offsetParent:r,strategy:i}=t;const s=i==="fixed",a=$s(r),c=e?$p(e.floating):!1;if(r===a||c&&s)return n;let h={scrollLeft:0,scrollTop:0},d=Ns(1);const f=Ns(0),p=xa(r);if((p||!p&&!s)&&((Ac(r)!=="body"||Ed(a))&&(h=Vp(r)),p)){const v=pl(r);d=vc(r),f.x=v.x+r.clientLeft,f.y=v.y+r.clientTop}const g=a&&!p&&!s?I_(a,h):Ns(0);return{width:n.width*d.x,height:n.height*d.y,x:n.x*d.x-h.scrollLeft*d.x+f.x+g.x,y:n.y*d.y-h.scrollTop*d.y+f.y+g.y}}function Kq(t){return Array.from(t.getClientRects())}function Gq(t){const e=$s(t),n=Vp(t),r=t.ownerDocument.body,i=ci(e.scrollWidth,e.clientWidth,r.scrollWidth,r.clientWidth),s=ci(e.scrollHeight,e.clientHeight,r.scrollHeight,r.clientHeight);let a=-n.scrollLeft+Wp(t);const c=-n.scrollTop;return ss(r).direction==="rtl"&&(a+=ci(e.clientWidth,r.clientWidth)-i),{width:i,height:s,x:a,y:c}}const dT=25;function Yq(t,e){const n=gi(t),r=$s(t),i=n.visualViewport;let s=r.clientWidth,a=r.clientHeight,c=0,h=0;if(i){s=i.width,a=i.height;const f=Vx();(!f||f&&e==="fixed")&&(c=i.offsetLeft,h=i.offsetTop)}const d=Wp(r);if(d<=0){const f=r.ownerDocument,p=f.body,g=getComputedStyle(p),v=f.compatMode==="CSS1Compat"&&parseFloat(g.marginLeft)+parseFloat(g.marginRight)||0,k=Math.abs(r.clientWidth-p.clientWidth-v);k<=dT&&(s-=k)}else d<=dT&&(s+=d);return{width:s,height:a,x:c,y:h}}function Jq(t,e){const n=pl(t,!0,e==="fixed"),r=n.top+t.clientTop,i=n.left+t.clientLeft,s=xa(t)?vc(t):Ns(1),a=t.clientWidth*s.x,c=t.clientHeight*s.y,h=i*s.x,d=r*s.y;return{width:a,height:c,x:h,y:d}}function hT(t,e,n){let r;if(e==="viewport")r=Yq(t,n);else if(e==="document")r=Gq($s(t));else if(is(e))r=Jq(e,n);else{const i=R_(t);r={x:e.x-i.x,y:e.y-i.y,width:e.width,height:e.height}}return np(r)}function M_(t,e){const n=uo(t);return n===e||!is(n)||Ec(n)?!1:ss(n).position==="fixed"||M_(n,e)}function Xq(t,e){const n=e.get(t);if(n)return n;let r=gd(t,[],!1).filter(c=>is(c)&&Ac(c)!=="body"),i=null;const s=ss(t).position==="fixed";let a=s?uo(t):t;for(;is(a)&&!Ec(a);){const c=ss(a),h=$x(a);!h&&c.position==="fixed"&&(i=null),(s?!h&&!i:!h&&c.position==="static"&&!!i&&(i.position==="absolute"||i.position==="fixed")||Ed(a)&&!h&&M_(t,a))?r=r.filter(f=>f!==a):i=c,a=uo(a)}return e.set(t,r),r}function Qq(t){let{element:e,boundary:n,rootBoundary:r,strategy:i}=t;const a=[...n==="clippingAncestors"?$p(e)?[]:Xq(e,this._c):[].concat(n),r],c=hT(e,a[0],i);let h=c.top,d=c.right,f=c.bottom,p=c.left;for(let g=1;g<a.length;g++){const v=hT(e,a[g],i);h=ci(v.top,h),d=co(v.right,d),f=co(v.bottom,f),p=ci(v.left,p)}return{width:d-p,height:f-h,x:p,y:h}}function Zq(t){const{width:e,height:n}=__(t);return{width:e,height:n}}function eK(t,e,n){const r=xa(e),i=$s(e),s=n==="fixed",a=pl(t,!0,s,e);let c={scrollLeft:0,scrollTop:0};const h=Ns(0);function d(){h.x=Wp(i)}if(r||!r&&!s)if((Ac(e)!=="body"||Ed(i))&&(c=Vp(e)),r){const v=pl(e,!0,s,e);h.x=v.x+e.clientLeft,h.y=v.y+e.clientTop}else i&&d();s&&!r&&i&&d();const f=i&&!r&&!s?I_(i,c):Ns(0),p=a.left+c.scrollLeft-h.x-f.x,g=a.top+c.scrollTop-h.y-f.y;return{x:p,y:g,width:a.width,height:a.height}}function A0(t){return ss(t).position==="static"}function fT(t,e){if(!xa(t)||ss(t).position==="fixed")return null;if(e)return e(t);let n=t.offsetParent;return $s(t)===n&&(n=n.ownerDocument.body),n}function D_(t,e){const n=gi(t);if($p(t))return n;if(!xa(t)){let i=uo(t);for(;i&&!Ec(i);){if(is(i)&&!A0(i))return i;i=uo(i)}return n}let r=fT(t,e);for(;r&&Bq(r)&&A0(r);)r=fT(r,e);return r&&Ec(r)&&A0(r)&&!$x(r)?n:r||Vq(t)||n}const tK=async function(t){const e=this.getOffsetParent||D_,n=this.getDimensions,r=await n(t.floating);return{reference:eK(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function nK(t){return ss(t).direction==="rtl"}const rK={convertOffsetParentRelativeRectToViewportRelativeRect:qq,getDocumentElement:$s,getClippingRect:Qq,getOffsetParent:D_,getElementRects:tK,getClientRects:Kq,getDimensions:Zq,getScale:vc,isElement:is,isRTL:nK};function A_(t,e){return t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height}function iK(t,e){let n=null,r;const i=$s(t);function s(){var c;clearTimeout(r),(c=n)==null||c.disconnect(),n=null}function a(c,h){c===void 0&&(c=!1),h===void 0&&(h=1),s();const d=t.getBoundingClientRect(),{left:f,top:p,width:g,height:v}=d;if(c||e(),!g||!v)return;const k=tf(p),w=tf(i.clientWidth-(f+g)),S=tf(i.clientHeight-(p+v)),T=tf(f),j={rootMargin:-k+"px "+-w+"px "+-S+"px "+-T+"px",threshold:ci(0,co(1,h))||1};let R=!0;function _(I){const M=I[0].intersectionRatio;if(M!==h){if(!R)return a();M?a(!1,M):r=setTimeout(()=>{a(!1,1e-7)},1e3)}M===1&&!A_(d,t.getBoundingClientRect())&&a(),R=!1}try{n=new IntersectionObserver(_,{...j,root:i.ownerDocument})}catch{n=new IntersectionObserver(_,j)}n.observe(t)}return a(!0),s}function sK(t,e,n,r){r===void 0&&(r={});const{ancestorScroll:i=!0,ancestorResize:s=!0,elementResize:a=typeof ResizeObserver=="function",layoutShift:c=typeof IntersectionObserver=="function",animationFrame:h=!1}=r,d=Wx(t),f=i||s?[...d?gd(d):[],...e?gd(e):[]]:[];f.forEach(T=>{i&&T.addEventListener("scroll",n,{passive:!0}),s&&T.addEventListener("resize",n)});const p=d&&c?iK(d,n):null;let g=-1,v=null;a&&(v=new ResizeObserver(T=>{let[C]=T;C&&C.target===d&&v&&e&&(v.unobserve(e),cancelAnimationFrame(g),g=requestAnimationFrame(()=>{var j;(j=v)==null||j.observe(e)})),n()}),d&&!h&&v.observe(d),e&&v.observe(e));let k,w=h?pl(t):null;h&&S();function S(){const T=pl(t);w&&!A_(w,T)&&n(),w=T,k=requestAnimationFrame(S)}return n(),()=>{var T;f.forEach(C=>{i&&C.removeEventListener("scroll",n),s&&C.removeEventListener("resize",n)}),p==null||p(),(T=v)==null||T.disconnect(),v=null,h&&cancelAnimationFrame(k)}}const aK=Oq,oK=Lq,lK=Mq,cK=Uq,uK=Dq,pT=Iq,dK=Fq,hK=(t,e,n)=>{const r=new Map,i={platform:rK,...n},s={...i.platform,_c:r};return Rq(t,e,{...i,platform:s})};var fK=typeof document<"u",pK=function(){},jf=fK?x.useLayoutEffect:pK;function rp(t,e){if(t===e)return!0;if(typeof t!=typeof e)return!1;if(typeof t=="function"&&t.toString()===e.toString())return!0;let n,r,i;if(t&&e&&typeof t=="object"){if(Array.isArray(t)){if(n=t.length,n!==e.length)return!1;for(r=n;r--!==0;)if(!rp(t[r],e[r]))return!1;return!0}if(i=Object.keys(t),n=i.length,n!==Object.keys(e).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(e,i[r]))return!1;for(r=n;r--!==0;){const s=i[r];if(!(s==="_owner"&&t.$$typeof)&&!rp(t[s],e[s]))return!1}return!0}return t!==t&&e!==e}function O_(t){return typeof window>"u"?1:(t.ownerDocument.defaultView||window).devicePixelRatio||1}function mT(t,e){const n=O_(t);return Math.round(e*n)/n}function O0(t){const e=x.useRef(t);return jf(()=>{e.current=t}),e}function mK(t){t===void 0&&(t={});const{placement:e="bottom",strategy:n="absolute",middleware:r=[],platform:i,elements:{reference:s,floating:a}={},transform:c=!0,whileElementsMounted:h,open:d}=t,[f,p]=x.useState({x:0,y:0,strategy:n,placement:e,middlewareData:{},isPositioned:!1}),[g,v]=x.useState(r);rp(g,r)||v(r);const[k,w]=x.useState(null),[S,T]=x.useState(null),C=x.useCallback(D=>{D!==I.current&&(I.current=D,w(D))},[]),j=x.useCallback(D=>{D!==M.current&&(M.current=D,T(D))},[]),R=s||k,_=a||S,I=x.useRef(null),M=x.useRef(null),L=x.useRef(f),$=h!=null,E=O0(h),P=O0(i),V=O0(d),F=x.useCallback(()=>{if(!I.current||!M.current)return;const D={placement:e,strategy:n,middleware:g};P.current&&(D.platform=P.current),hK(I.current,M.current,D).then(ne=>{const A={...ne,isPositioned:V.current!==!1};K.current&&!rp(L.current,A)&&(L.current=A,Sd.flushSync(()=>{p(A)}))})},[g,e,n,P,V]);jf(()=>{d===!1&&L.current.isPositioned&&(L.current.isPositioned=!1,p(D=>({...D,isPositioned:!1})))},[d]);const K=x.useRef(!1);jf(()=>(K.current=!0,()=>{K.current=!1}),[]),jf(()=>{if(R&&(I.current=R),_&&(M.current=_),R&&_){if(E.current)return E.current(R,_,F);F()}},[R,_,F,E,$]);const J=x.useMemo(()=>({reference:I,floating:M,setReference:C,setFloating:j}),[C,j]),Q=x.useMemo(()=>({reference:R,floating:_}),[R,_]),Z=x.useMemo(()=>{const D={position:n,left:0,top:0};if(!Q.floating)return D;const ne=mT(Q.floating,f.x),A=mT(Q.floating,f.y);return c?{...D,transform:"translate("+ne+"px, "+A+"px)",...O_(Q.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:ne,top:A}},[n,c,Q.floating,f.x,f.y]);return x.useMemo(()=>({...f,update:F,refs:J,elements:Q,floatingStyles:Z}),[f,F,J,Q,Z])}const gK=t=>{function e(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:t,fn(n){const{element:r,padding:i}=typeof t=="function"?t(n):t;return r&&e(r)?r.current!=null?pT({element:r.current,padding:i}).fn(n):{}:r?pT({element:r,padding:i}).fn(n):{}}}},vK=(t,e)=>{const n=aK(t);return{name:n.name,fn:n.fn,options:[t,e]}},yK=(t,e)=>{const n=oK(t);return{name:n.name,fn:n.fn,options:[t,e]}},xK=(t,e)=>({fn:dK(t).fn,options:[t,e]}),bK=(t,e)=>{const n=lK(t);return{name:n.name,fn:n.fn,options:[t,e]}},kK=(t,e)=>{const n=cK(t);return{name:n.name,fn:n.fn,options:[t,e]}},wK=(t,e)=>{const n=uK(t);return{name:n.name,fn:n.fn,options:[t,e]}},SK=(t,e)=>{const n=gK(t);return{name:n.name,fn:n.fn,options:[t,e]}};var CK="Arrow",L_=x.forwardRef((t,e)=>{const{children:n,width:r=10,height:i=5,...s}=t;return o.jsx(_t.svg,{...s,ref:e,width:r,height:i,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:t.asChild?n:o.jsx("polygon",{points:"0,0 30,0 15,10"})})});L_.displayName=CK;var TK=L_;function F_(t){const[e,n]=x.useState(void 0);return Tr(()=>{if(t){n({width:t.offsetWidth,height:t.offsetHeight});const r=new ResizeObserver(i=>{if(!Array.isArray(i)||!i.length)return;const s=i[0];let a,c;if("borderBoxSize"in s){const h=s.borderBoxSize,d=Array.isArray(h)?h[0]:h;a=d.inlineSize,c=d.blockSize}else a=t.offsetWidth,c=t.offsetHeight;n({width:a,height:c})});return r.observe(t,{box:"border-box"}),()=>r.unobserve(t)}else n(void 0)},[t]),e}var Hx="Popper",[U_,B_]=Us(Hx),[NK,z_]=U_(Hx),$_=t=>{const{__scopePopper:e,children:n}=t,[r,i]=x.useState(null);return o.jsx(NK,{scope:e,anchor:r,onAnchorChange:i,children:n})};$_.displayName=Hx;var V_="PopperAnchor",W_=x.forwardRef((t,e)=>{const{__scopePopper:n,virtualRef:r,...i}=t,s=z_(V_,n),a=x.useRef(null),c=sn(e,a);return x.useEffect(()=>{s.onAnchorChange((r==null?void 0:r.current)||a.current)}),r?null:o.jsx(_t.div,{...i,ref:c})});W_.displayName=V_;var qx="PopperContent",[EK,jK]=U_(qx),H_=x.forwardRef((t,e)=>{var oe,U,ue,ke,W,q;const{__scopePopper:n,side:r="bottom",sideOffset:i=0,align:s="center",alignOffset:a=0,arrowPadding:c=0,avoidCollisions:h=!0,collisionBoundary:d=[],collisionPadding:f=0,sticky:p="partial",hideWhenDetached:g=!1,updatePositionStrategy:v="optimized",onPlaced:k,...w}=t,S=z_(qx,n),[T,C]=x.useState(null),j=sn(e,fe=>C(fe)),[R,_]=x.useState(null),I=F_(R),M=(I==null?void 0:I.width)??0,L=(I==null?void 0:I.height)??0,$=r+(s!=="center"?"-"+s:""),E=typeof f=="number"?f:{top:0,right:0,bottom:0,left:0,...f},P=Array.isArray(d)?d:[d],V=P.length>0,F={padding:E,boundary:P.filter(_K),altBoundary:V},{refs:K,floatingStyles:J,placement:Q,isPositioned:Z,middlewareData:D}=mK({strategy:"fixed",placement:$,whileElementsMounted:(...fe)=>sK(...fe,{animationFrame:v==="always"}),elements:{reference:S.anchor},middleware:[vK({mainAxis:i+L,alignmentAxis:a}),h&&yK({mainAxis:!0,crossAxis:!1,limiter:p==="partial"?xK():void 0,...F}),h&&bK({...F}),kK({...F,apply:({elements:fe,rects:ve,availableWidth:Se,availableHeight:Ke})=>{const{width:dt,height:Ge}=ve.reference,_e=fe.floating.style;_e.setProperty("--radix-popper-available-width",`${Se}px`),_e.setProperty("--radix-popper-available-height",`${Ke}px`),_e.setProperty("--radix-popper-anchor-width",`${dt}px`),_e.setProperty("--radix-popper-anchor-height",`${Ge}px`)}}),R&&SK({element:R,padding:c}),RK({arrowWidth:M,arrowHeight:L}),g&&wK({strategy:"referenceHidden",...F})]}),[ne,A]=G_(Q),z=hr(k);Tr(()=>{Z&&(z==null||z())},[Z,z]);const ee=(oe=D.arrow)==null?void 0:oe.x,B=(U=D.arrow)==null?void 0:U.y,X=((ue=D.arrow)==null?void 0:ue.centerOffset)!==0,[ye,se]=x.useState();return Tr(()=>{T&&se(window.getComputedStyle(T).zIndex)},[T]),o.jsx("div",{ref:K.setFloating,"data-radix-popper-content-wrapper":"",style:{...J,transform:Z?J.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:ye,"--radix-popper-transform-origin":[(ke=D.transformOrigin)==null?void 0:ke.x,(W=D.transformOrigin)==null?void 0:W.y].join(" "),...((q=D.hide)==null?void 0:q.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:t.dir,children:o.jsx(EK,{scope:n,placedSide:ne,onArrowChange:_,arrowX:ee,arrowY:B,shouldHideArrow:X,children:o.jsx(_t.div,{"data-side":ne,"data-align":A,...w,ref:j,style:{...w.style,animation:Z?void 0:"none"}})})})});H_.displayName=qx;var q_="PopperArrow",PK={top:"bottom",right:"left",bottom:"top",left:"right"},K_=x.forwardRef(function(e,n){const{__scopePopper:r,...i}=e,s=jK(q_,r),a=PK[s.placedSide];return o.jsx("span",{ref:s.onArrowChange,style:{position:"absolute",left:s.arrowX,top:s.arrowY,[a]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[s.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[s.placedSide],visibility:s.shouldHideArrow?"hidden":void 0},children:o.jsx(TK,{...i,ref:n,style:{...i.style,display:"block"}})})});K_.displayName=q_;function _K(t){return t!==null}var RK=t=>({name:"transformOrigin",options:t,fn(e){var S,T,C;const{placement:n,rects:r,middlewareData:i}=e,a=((S=i.arrow)==null?void 0:S.centerOffset)!==0,c=a?0:t.arrowWidth,h=a?0:t.arrowHeight,[d,f]=G_(n),p={start:"0%",center:"50%",end:"100%"}[f],g=(((T=i.arrow)==null?void 0:T.x)??0)+c/2,v=(((C=i.arrow)==null?void 0:C.y)??0)+h/2;let k="",w="";return d==="bottom"?(k=a?p:`${g}px`,w=`${-h}px`):d==="top"?(k=a?p:`${g}px`,w=`${r.floating.height+h}px`):d==="right"?(k=`${-h}px`,w=a?p:`${v}px`):d==="left"&&(k=`${r.floating.width+h}px`,w=a?p:`${v}px`),{data:{x:k,y:w}}}});function G_(t){const[e,n="center"]=t.split("-");return[e,n]}var IK=$_,MK=W_,DK=H_,AK=K_;function Y_(t){const e=x.useRef({value:t,previous:t});return x.useMemo(()=>(e.current.value!==t&&(e.current.previous=e.current.value,e.current.value=t),e.current.previous),[t])}var OK="VisuallyHidden",J_=x.forwardRef((t,e)=>o.jsx(_t.span,{...t,ref:e,style:{position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal",...t.style}}));J_.displayName=OK;var LK=[" ","Enter","ArrowUp","ArrowDown"],FK=[" ","Enter"],jd="Select",[Hp,qp,UK]=o_(jd),[Oc]=Us(jd,[UK,B_]),Kp=B_(),[BK,yo]=Oc(jd),[zK,$K]=Oc(jd),X_=t=>{const{__scopeSelect:e,children:n,open:r,defaultOpen:i,onOpenChange:s,value:a,defaultValue:c,onValueChange:h,dir:d,name:f,autoComplete:p,disabled:g,required:v,form:k}=t,w=Kp(e),[S,T]=x.useState(null),[C,j]=x.useState(null),[R,_]=x.useState(!1),I=mp(d),[M=!1,L]=xc({prop:r,defaultProp:i,onChange:s}),[$,E]=xc({prop:a,defaultProp:c,onChange:h}),P=x.useRef(null),V=S?k||!!S.closest("form"):!0,[F,K]=x.useState(new Set),J=Array.from(F).map(Q=>Q.props.value).join(";");return o.jsx(IK,{...w,children:o.jsxs(BK,{required:v,scope:e,trigger:S,onTriggerChange:T,valueNode:C,onValueNodeChange:j,valueNodeHasChildren:R,onValueNodeHasChildrenChange:_,contentId:no(),value:$,onValueChange:E,open:M,onOpenChange:L,dir:I,triggerPointerDownPosRef:P,disabled:g,children:[o.jsx(Hp.Provider,{scope:e,children:o.jsx(zK,{scope:t.__scopeSelect,onNativeOptionAdd:x.useCallback(Q=>{K(Z=>new Set(Z).add(Q))},[]),onNativeOptionRemove:x.useCallback(Q=>{K(Z=>{const D=new Set(Z);return D.delete(Q),D})},[]),children:n})}),V?o.jsxs(bR,{"aria-hidden":!0,required:v,tabIndex:-1,name:f,autoComplete:p,value:$,onChange:Q=>E(Q.target.value),disabled:g,form:k,children:[$===void 0?o.jsx("option",{value:""}):null,Array.from(F)]},J):null]})})};X_.displayName=jd;var Q_="SelectTrigger",Z_=x.forwardRef((t,e)=>{const{__scopeSelect:n,disabled:r=!1,...i}=t,s=Kp(n),a=yo(Q_,n),c=a.disabled||r,h=sn(e,a.onTriggerChange),d=qp(n),f=x.useRef("touch"),[p,g,v]=kR(w=>{const S=d().filter(j=>!j.disabled),T=S.find(j=>j.value===a.value),C=wR(S,w,T);C!==void 0&&a.onValueChange(C.value)}),k=w=>{c||(a.onOpenChange(!0),v()),w&&(a.triggerPointerDownPosRef.current={x:Math.round(w.pageX),y:Math.round(w.pageY)})};return o.jsx(MK,{asChild:!0,...s,children:o.jsx(_t.button,{type:"button",role:"combobox","aria-controls":a.contentId,"aria-expanded":a.open,"aria-required":a.required,"aria-autocomplete":"none",dir:a.dir,"data-state":a.open?"open":"closed",disabled:c,"data-disabled":c?"":void 0,"data-placeholder":xR(a.value)?"":void 0,...i,ref:h,onClick:Et(i.onClick,w=>{w.currentTarget.focus(),f.current!=="mouse"&&k(w)}),onPointerDown:Et(i.onPointerDown,w=>{f.current=w.pointerType;const S=w.target;S.hasPointerCapture(w.pointerId)&&S.releasePointerCapture(w.pointerId),w.button===0&&w.ctrlKey===!1&&w.pointerType==="mouse"&&(k(w),w.preventDefault())}),onKeyDown:Et(i.onKeyDown,w=>{const S=p.current!=="";!(w.ctrlKey||w.altKey||w.metaKey)&&w.key.length===1&&g(w.key),!(S&&w.key===" ")&&LK.includes(w.key)&&(k(),w.preventDefault())})})})});Z_.displayName=Q_;var eR="SelectValue",tR=x.forwardRef((t,e)=>{const{__scopeSelect:n,className:r,style:i,children:s,placeholder:a="",...c}=t,h=yo(eR,n),{onValueNodeHasChildrenChange:d}=h,f=s!==void 0,p=sn(e,h.onValueNodeChange);return Tr(()=>{d(f)},[d,f]),o.jsx(_t.span,{...c,ref:p,style:{pointerEvents:"none"},children:xR(h.value)?o.jsx(o.Fragment,{children:a}):s})});tR.displayName=eR;var VK="SelectIcon",nR=x.forwardRef((t,e)=>{const{__scopeSelect:n,children:r,...i}=t;return o.jsx(_t.span,{"aria-hidden":!0,...i,ref:e,children:r||"▼"})});nR.displayName=VK;var WK="SelectPortal",rR=t=>o.jsx(My,{asChild:!0,...t});rR.displayName=WK;var ml="SelectContent",iR=x.forwardRef((t,e)=>{const n=yo(ml,t.__scopeSelect),[r,i]=x.useState();if(Tr(()=>{i(new DocumentFragment)},[]),!n.open){const s=r;return s?Sd.createPortal(o.jsx(sR,{scope:t.__scopeSelect,children:o.jsx(Hp.Slot,{scope:t.__scopeSelect,children:o.jsx("div",{children:t.children})})}),s):null}return o.jsx(aR,{...t,ref:e})});iR.displayName=ml;var Wi=10,[sR,xo]=Oc(ml),HK="SelectContentImpl",aR=x.forwardRef((t,e)=>{const{__scopeSelect:n,position:r="item-aligned",onCloseAutoFocus:i,onEscapeKeyDown:s,onPointerDownOutside:a,side:c,sideOffset:h,align:d,alignOffset:f,arrowPadding:p,collisionBoundary:g,collisionPadding:v,sticky:k,hideWhenDetached:w,avoidCollisions:S,...T}=t,C=yo(ml,n),[j,R]=x.useState(null),[_,I]=x.useState(null),M=sn(e,oe=>R(oe)),[L,$]=x.useState(null),[E,P]=x.useState(null),V=qp(n),[F,K]=x.useState(!1),J=x.useRef(!1);x.useEffect(()=>{if(j)return yE(j)},[j]),cE();const Q=x.useCallback(oe=>{const[U,...ue]=V().map(q=>q.ref.current),[ke]=ue.slice(-1),W=document.activeElement;for(const q of oe)if(q===W||(q==null||q.scrollIntoView({block:"nearest"}),q===U&&_&&(_.scrollTop=0),q===ke&&_&&(_.scrollTop=_.scrollHeight),q==null||q.focus(),document.activeElement!==W))return},[V,_]),Z=x.useCallback(()=>Q([L,j]),[Q,L,j]);x.useEffect(()=>{F&&Z()},[F,Z]);const{onOpenChange:D,triggerPointerDownPosRef:ne}=C;x.useEffect(()=>{if(j){let oe={x:0,y:0};const U=ke=>{var W,q;oe={x:Math.abs(Math.round(ke.pageX)-(((W=ne.current)==null?void 0:W.x)??0)),y:Math.abs(Math.round(ke.pageY)-(((q=ne.current)==null?void 0:q.y)??0))}},ue=ke=>{oe.x<=10&&oe.y<=10?ke.preventDefault():j.contains(ke.target)||D(!1),document.removeEventListener("pointermove",U),ne.current=null};return ne.current!==null&&(document.addEventListener("pointermove",U),document.addEventListener("pointerup",ue,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",U),document.removeEventListener("pointerup",ue,{capture:!0})}}},[j,D,ne]),x.useEffect(()=>{const oe=()=>D(!1);return window.addEventListener("blur",oe),window.addEventListener("resize",oe),()=>{window.removeEventListener("blur",oe),window.removeEventListener("resize",oe)}},[D]);const[A,z]=kR(oe=>{const U=V().filter(W=>!W.disabled),ue=U.find(W=>W.ref.current===document.activeElement),ke=wR(U,oe,ue);ke&&setTimeout(()=>ke.ref.current.focus())}),ee=x.useCallback((oe,U,ue)=>{const ke=!J.current&&!ue;(C.value!==void 0&&C.value===U||ke)&&($(oe),ke&&(J.current=!0))},[C.value]),B=x.useCallback(()=>j==null?void 0:j.focus(),[j]),X=x.useCallback((oe,U,ue)=>{const ke=!J.current&&!ue;(C.value!==void 0&&C.value===U||ke)&&P(oe)},[C.value]),ye=r==="popper"?Zv:oR,se=ye===Zv?{side:c,sideOffset:h,align:d,alignOffset:f,arrowPadding:p,collisionBoundary:g,collisionPadding:v,sticky:k,hideWhenDetached:w,avoidCollisions:S}:{};return o.jsx(sR,{scope:n,content:j,viewport:_,onViewportChange:I,itemRefCallback:ee,selectedItem:L,onItemLeave:B,itemTextRefCallback:X,focusSelectedItem:Z,selectedItemText:E,position:r,isPositioned:F,searchRef:A,children:o.jsx(Dy,{as:ao,allowPinchZoom:!0,children:o.jsx(Iy,{asChild:!0,trapped:C.open,onMountAutoFocus:oe=>{oe.preventDefault()},onUnmountAutoFocus:Et(i,oe=>{var U;(U=C.trigger)==null||U.focus({preventScroll:!0}),oe.preventDefault()}),children:o.jsx(Ry,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:a,onFocusOutside:oe=>oe.preventDefault(),onDismiss:()=>C.onOpenChange(!1),children:o.jsx(ye,{role:"listbox",id:C.contentId,"data-state":C.open?"open":"closed",dir:C.dir,onContextMenu:oe=>oe.preventDefault(),...T,...se,onPlaced:()=>K(!0),ref:M,style:{display:"flex",flexDirection:"column",outline:"none",...T.style},onKeyDown:Et(T.onKeyDown,oe=>{const U=oe.ctrlKey||oe.altKey||oe.metaKey;if(oe.key==="Tab"&&oe.preventDefault(),!U&&oe.key.length===1&&z(oe.key),["ArrowUp","ArrowDown","Home","End"].includes(oe.key)){let ke=V().filter(W=>!W.disabled).map(W=>W.ref.current);if(["ArrowUp","End"].includes(oe.key)&&(ke=ke.slice().reverse()),["ArrowUp","ArrowDown"].includes(oe.key)){const W=oe.target,q=ke.indexOf(W);ke=ke.slice(q+1)}setTimeout(()=>Q(ke)),oe.preventDefault()}})})})})})})});aR.displayName=HK;var qK="SelectItemAlignedPosition",oR=x.forwardRef((t,e)=>{const{__scopeSelect:n,onPlaced:r,...i}=t,s=yo(ml,n),a=xo(ml,n),[c,h]=x.useState(null),[d,f]=x.useState(null),p=sn(e,M=>f(M)),g=qp(n),v=x.useRef(!1),k=x.useRef(!0),{viewport:w,selectedItem:S,selectedItemText:T,focusSelectedItem:C}=a,j=x.useCallback(()=>{if(s.trigger&&s.valueNode&&c&&d&&w&&S&&T){const M=s.trigger.getBoundingClientRect(),L=d.getBoundingClientRect(),$=s.valueNode.getBoundingClientRect(),E=T.getBoundingClientRect();if(s.dir!=="rtl"){const W=E.left-L.left,q=$.left-W,fe=M.left-q,ve=M.width+fe,Se=Math.max(ve,L.width),Ke=window.innerWidth-Wi,dt=ov(q,[Wi,Math.max(Wi,Ke-Se)]);c.style.minWidth=ve+"px",c.style.left=dt+"px"}else{const W=L.right-E.right,q=window.innerWidth-$.right-W,fe=window.innerWidth-M.right-q,ve=M.width+fe,Se=Math.max(ve,L.width),Ke=window.innerWidth-Wi,dt=ov(q,[Wi,Math.max(Wi,Ke-Se)]);c.style.minWidth=ve+"px",c.style.right=dt+"px"}const P=g(),V=window.innerHeight-Wi*2,F=w.scrollHeight,K=window.getComputedStyle(d),J=parseInt(K.borderTopWidth,10),Q=parseInt(K.paddingTop,10),Z=parseInt(K.borderBottomWidth,10),D=parseInt(K.paddingBottom,10),ne=J+Q+F+D+Z,A=Math.min(S.offsetHeight*5,ne),z=window.getComputedStyle(w),ee=parseInt(z.paddingTop,10),B=parseInt(z.paddingBottom,10),X=M.top+M.height/2-Wi,ye=V-X,se=S.offsetHeight/2,oe=S.offsetTop+se,U=J+Q+oe,ue=ne-U;if(U<=X){const W=P.length>0&&S===P[P.length-1].ref.current;c.style.bottom="0px";const q=d.clientHeight-w.offsetTop-w.offsetHeight,fe=Math.max(ye,se+(W?B:0)+q+Z),ve=U+fe;c.style.height=ve+"px"}else{const W=P.length>0&&S===P[0].ref.current;c.style.top="0px";const fe=Math.max(X,J+w.offsetTop+(W?ee:0)+se)+ue;c.style.height=fe+"px",w.scrollTop=U-X+w.offsetTop}c.style.margin=`${Wi}px 0`,c.style.minHeight=A+"px",c.style.maxHeight=V+"px",r==null||r(),requestAnimationFrame(()=>v.current=!0)}},[g,s.trigger,s.valueNode,c,d,w,S,T,s.dir,r]);Tr(()=>j(),[j]);const[R,_]=x.useState();Tr(()=>{d&&_(window.getComputedStyle(d).zIndex)},[d]);const I=x.useCallback(M=>{M&&k.current===!0&&(j(),C==null||C(),k.current=!1)},[j,C]);return o.jsx(GK,{scope:n,contentWrapper:c,shouldExpandOnScrollRef:v,onScrollButtonChange:I,children:o.jsx("div",{ref:h,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:R},children:o.jsx(_t.div,{...i,ref:p,style:{boxSizing:"border-box",maxHeight:"100%",...i.style}})})})});oR.displayName=qK;var KK="SelectPopperPosition",Zv=x.forwardRef((t,e)=>{const{__scopeSelect:n,align:r="start",collisionPadding:i=Wi,...s}=t,a=Kp(n);return o.jsx(DK,{...a,...s,ref:e,align:r,collisionPadding:i,style:{boxSizing:"border-box",...s.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)"}})});Zv.displayName=KK;var[GK,Kx]=Oc(ml,{}),ey="SelectViewport",lR=x.forwardRef((t,e)=>{const{__scopeSelect:n,nonce:r,...i}=t,s=xo(ey,n),a=Kx(ey,n),c=sn(e,s.onViewportChange),h=x.useRef(0);return o.jsxs(o.Fragment,{children:[o.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}),o.jsx(Hp.Slot,{scope:n,children:o.jsx(_t.div,{"data-radix-select-viewport":"",role:"presentation",...i,ref:c,style:{position:"relative",flex:1,overflow:"hidden auto",...i.style},onScroll:Et(i.onScroll,d=>{const f=d.currentTarget,{contentWrapper:p,shouldExpandOnScrollRef:g}=a;if(g!=null&&g.current&&p){const v=Math.abs(h.current-f.scrollTop);if(v>0){const k=window.innerHeight-Wi*2,w=parseFloat(p.style.minHeight),S=parseFloat(p.style.height),T=Math.max(w,S);if(T<k){const C=T+v,j=Math.min(k,C),R=C-j;p.style.height=j+"px",p.style.bottom==="0px"&&(f.scrollTop=R>0?R:0,p.style.justifyContent="flex-end")}}}h.current=f.scrollTop})})})]})});lR.displayName=ey;var cR="SelectGroup",[YK,JK]=Oc(cR),XK=x.forwardRef((t,e)=>{const{__scopeSelect:n,...r}=t,i=no();return o.jsx(YK,{scope:n,id:i,children:o.jsx(_t.div,{role:"group","aria-labelledby":i,...r,ref:e})})});XK.displayName=cR;var uR="SelectLabel",QK=x.forwardRef((t,e)=>{const{__scopeSelect:n,...r}=t,i=JK(uR,n);return o.jsx(_t.div,{id:i.id,...r,ref:e})});QK.displayName=uR;var ip="SelectItem",[ZK,dR]=Oc(ip),hR=x.forwardRef((t,e)=>{const{__scopeSelect:n,value:r,disabled:i=!1,textValue:s,...a}=t,c=yo(ip,n),h=xo(ip,n),d=c.value===r,[f,p]=x.useState(s??""),[g,v]=x.useState(!1),k=sn(e,C=>{var j;return(j=h.itemRefCallback)==null?void 0:j.call(h,C,r,i)}),w=no(),S=x.useRef("touch"),T=()=>{i||(c.onValueChange(r),c.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 o.jsx(ZK,{scope:n,value:r,disabled:i,textId:w,isSelected:d,onItemTextChange:x.useCallback(C=>{p(j=>j||((C==null?void 0:C.textContent)??"").trim())},[]),children:o.jsx(Hp.ItemSlot,{scope:n,value:r,disabled:i,textValue:f,children:o.jsx(_t.div,{role:"option","aria-labelledby":w,"data-highlighted":g?"":void 0,"aria-selected":d&&g,"data-state":d?"checked":"unchecked","aria-disabled":i||void 0,"data-disabled":i?"":void 0,tabIndex:i?void 0:-1,...a,ref:k,onFocus:Et(a.onFocus,()=>v(!0)),onBlur:Et(a.onBlur,()=>v(!1)),onClick:Et(a.onClick,()=>{S.current!=="mouse"&&T()}),onPointerUp:Et(a.onPointerUp,()=>{S.current==="mouse"&&T()}),onPointerDown:Et(a.onPointerDown,C=>{S.current=C.pointerType}),onPointerMove:Et(a.onPointerMove,C=>{var j;S.current=C.pointerType,i?(j=h.onItemLeave)==null||j.call(h):S.current==="mouse"&&C.currentTarget.focus({preventScroll:!0})}),onPointerLeave:Et(a.onPointerLeave,C=>{var j;C.currentTarget===document.activeElement&&((j=h.onItemLeave)==null||j.call(h))}),onKeyDown:Et(a.onKeyDown,C=>{var R;((R=h.searchRef)==null?void 0:R.current)!==""&&C.key===" "||(FK.includes(C.key)&&T(),C.key===" "&&C.preventDefault())})})})})});hR.displayName=ip;var Uu="SelectItemText",fR=x.forwardRef((t,e)=>{const{__scopeSelect:n,className:r,style:i,...s}=t,a=yo(Uu,n),c=xo(Uu,n),h=dR(Uu,n),d=$K(Uu,n),[f,p]=x.useState(null),g=sn(e,T=>p(T),h.onItemTextChange,T=>{var C;return(C=c.itemTextRefCallback)==null?void 0:C.call(c,T,h.value,h.disabled)}),v=f==null?void 0:f.textContent,k=x.useMemo(()=>o.jsx("option",{value:h.value,disabled:h.disabled,children:v},h.value),[h.disabled,h.value,v]),{onNativeOptionAdd:w,onNativeOptionRemove:S}=d;return Tr(()=>(w(k),()=>S(k)),[w,S,k]),o.jsxs(o.Fragment,{children:[o.jsx(_t.span,{id:h.textId,...s,ref:g}),h.isSelected&&a.valueNode&&!a.valueNodeHasChildren?Sd.createPortal(s.children,a.valueNode):null]})});fR.displayName=Uu;var pR="SelectItemIndicator",mR=x.forwardRef((t,e)=>{const{__scopeSelect:n,...r}=t;return dR(pR,n).isSelected?o.jsx(_t.span,{"aria-hidden":!0,...r,ref:e}):null});mR.displayName=pR;var ty="SelectScrollUpButton",gR=x.forwardRef((t,e)=>{const n=xo(ty,t.__scopeSelect),r=Kx(ty,t.__scopeSelect),[i,s]=x.useState(!1),a=sn(e,r.onScrollButtonChange);return Tr(()=>{if(n.viewport&&n.isPositioned){let c=function(){const d=h.scrollTop>0;s(d)};const h=n.viewport;return c(),h.addEventListener("scroll",c),()=>h.removeEventListener("scroll",c)}},[n.viewport,n.isPositioned]),i?o.jsx(yR,{...t,ref:a,onAutoScroll:()=>{const{viewport:c,selectedItem:h}=n;c&&h&&(c.scrollTop=c.scrollTop-h.offsetHeight)}}):null});gR.displayName=ty;var ny="SelectScrollDownButton",vR=x.forwardRef((t,e)=>{const n=xo(ny,t.__scopeSelect),r=Kx(ny,t.__scopeSelect),[i,s]=x.useState(!1),a=sn(e,r.onScrollButtonChange);return Tr(()=>{if(n.viewport&&n.isPositioned){let c=function(){const d=h.scrollHeight-h.clientHeight,f=Math.ceil(h.scrollTop)<d;s(f)};const h=n.viewport;return c(),h.addEventListener("scroll",c),()=>h.removeEventListener("scroll",c)}},[n.viewport,n.isPositioned]),i?o.jsx(yR,{...t,ref:a,onAutoScroll:()=>{const{viewport:c,selectedItem:h}=n;c&&h&&(c.scrollTop=c.scrollTop+h.offsetHeight)}}):null});vR.displayName=ny;var yR=x.forwardRef((t,e)=>{const{__scopeSelect:n,onAutoScroll:r,...i}=t,s=xo("SelectScrollButton",n),a=x.useRef(null),c=qp(n),h=x.useCallback(()=>{a.current!==null&&(window.clearInterval(a.current),a.current=null)},[]);return x.useEffect(()=>()=>h(),[h]),Tr(()=>{var f;const d=c().find(p=>p.ref.current===document.activeElement);(f=d==null?void 0:d.ref.current)==null||f.scrollIntoView({block:"nearest"})},[c]),o.jsx(_t.div,{"aria-hidden":!0,...i,ref:e,style:{flexShrink:0,...i.style},onPointerDown:Et(i.onPointerDown,()=>{a.current===null&&(a.current=window.setInterval(r,50))}),onPointerMove:Et(i.onPointerMove,()=>{var d;(d=s.onItemLeave)==null||d.call(s),a.current===null&&(a.current=window.setInterval(r,50))}),onPointerLeave:Et(i.onPointerLeave,()=>{h()})})}),eG="SelectSeparator",tG=x.forwardRef((t,e)=>{const{__scopeSelect:n,...r}=t;return o.jsx(_t.div,{"aria-hidden":!0,...r,ref:e})});tG.displayName=eG;var ry="SelectArrow",nG=x.forwardRef((t,e)=>{const{__scopeSelect:n,...r}=t,i=Kp(n),s=yo(ry,n),a=xo(ry,n);return s.open&&a.position==="popper"?o.jsx(AK,{...i,...r,ref:e}):null});nG.displayName=ry;function xR(t){return t===""||t===void 0}var bR=x.forwardRef((t,e)=>{const{value:n,...r}=t,i=x.useRef(null),s=sn(e,i),a=Y_(n);return x.useEffect(()=>{const c=i.current,h=window.HTMLSelectElement.prototype,f=Object.getOwnPropertyDescriptor(h,"value").set;if(a!==n&&f){const p=new Event("change",{bubbles:!0});f.call(c,n),c.dispatchEvent(p)}},[a,n]),o.jsx(J_,{asChild:!0,children:o.jsx("select",{...r,ref:s,defaultValue:n})})});bR.displayName="BubbleSelect";function kR(t){const e=hr(t),n=x.useRef(""),r=x.useRef(0),i=x.useCallback(a=>{const c=n.current+a;e(c),(function h(d){n.current=d,window.clearTimeout(r.current),d!==""&&(r.current=window.setTimeout(()=>h(""),1e3))})(c)},[e]),s=x.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return x.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,i,s]}function wR(t,e,n){const i=e.length>1&&Array.from(e).every(d=>d===e[0])?e[0]:e,s=n?t.indexOf(n):-1;let a=rG(t,Math.max(s,0));i.length===1&&(a=a.filter(d=>d!==n));const h=a.find(d=>d.textValue.toLowerCase().startsWith(i.toLowerCase()));return h!==n?h:void 0}function rG(t,e){return t.map((n,r)=>t[(e+r)%t.length])}var iG=X_,sG=Z_,aG=tR,oG=nR,lG=rR,cG=iR,uG=lR,dG=hR,hG=fR,fG=mR,pG=gR,mG=vR;function Qt({...t}){return o.jsx(iG,{"data-slot":"select",...t})}function Zt({...t}){return o.jsx(aG,{"data-slot":"select-value",...t})}function en({className:t,size:e="default",children:n,...r}){return o.jsxs(sG,{"data-slot":"select-trigger","data-size":e,className:St("border-input data-[placeholder]:text-muted-foreground [&_svg:not([class*='text-'])]:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 dark:hover:bg-input/50 flex w-full items-center justify-between gap-2 rounded-md border bg-input-background px-3 py-2 text-sm whitespace-nowrap transition-[color,box-shadow] outline-none focus-visible:ring-[3px] 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",t),...r,children:[n,o.jsx(oG,{asChild:!0,children:o.jsx(fo,{className:"size-4 opacity-50"})})]})}function tn({className:t,children:e,position:n="popper",...r}){return o.jsx(lG,{children:o.jsxs(cG,{"data-slot":"select-content",className:St("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 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 shadow-md",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",t),position:n,...r,children:[o.jsx(gG,{}),o.jsx(uG,{className:St("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1"),children:e}),o.jsx(vG,{})]})})}function st({className:t,children:e,...n}){return o.jsxs(dG,{"data-slot":"select-item",className:St("focus:bg-accent focus:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",t),...n,children:[o.jsx("span",{className:"absolute right-2 flex size-3.5 items-center justify-center",children:o.jsx(fG,{children:o.jsx(nd,{className:"size-4"})})}),o.jsx(hG,{children:e})]})}function gG({className:t,...e}){return o.jsx(pG,{"data-slot":"select-scroll-up-button",className:St("flex cursor-default items-center justify-center py-1",t),...e,children:o.jsx(by,{className:"size-4"})})}function vG({className:t,...e}){return o.jsx(mG,{"data-slot":"select-scroll-down-button",className:St("flex cursor-default items-center justify-center py-1",t),...e,children:o.jsx(fo,{className:"size-4"})})}function yG(){const[t,e]=x.useState([]),[n,r]=x.useState(!0),[i,s]=x.useState(!1),[a,c]=x.useState({name:"",type:"stdio",command:"",url:"",description:""}),[h,d]=x.useState([]),[f,p]=x.useState([]),[g,v]=x.useState(null),[k,w]=x.useState([]),[S,T]=x.useState(!1),[C,j]=x.useState({open:!1,title:"",onConfirm:()=>{}}),R=async()=>{try{const D=await we("/api/mcp");if(D.ok){const ne=await D.json();e(ne.servers||[])}}catch(D){console.error("Failed to fetch MCP servers",D)}finally{r(!1)}};x.useEffect(()=>{R()},[]);const _=async(D,ne)=>{const A=me.loading(`Reloading ${D}...`);try{const z=await we(`/api/mcp/${D}/${ne}`,{method:"POST"});if(z.ok)me.success(`${D} ${ne}d successfully`,{id:A}),R();else{const ee=await z.json();me.error(ee.error||`Failed to ${ne} server`,{id:A})}}catch(z){me.error(z.message,{id:A})}},I=D=>{j({open:!0,title:`Remove ${D}?`,description:"Are you sure you want to remove this MCP server?",onConfirm:async()=>{try{(await we(`/api/mcp/${D}`,{method:"DELETE"})).ok&&(me.success(`${D} removed`),R())}catch(ne){me.error(ne.message)}}})},M=()=>{c({name:"",type:"stdio",command:"",url:"",description:""}),d([]),p([])},L=async()=>{if(a.name)try{const D={};h.forEach(ee=>{ee.key.trim()&&(D[ee.key.trim()]=ee.value)});const ne={};f.forEach(ee=>{ee.key.trim()&&(ne[ee.key.trim()]=ee.value)});const A={name:a.name};a.description.trim()&&(A.description=a.description.trim()),a.type==="stdio"?(A.command=a.command,Object.keys(D).length>0&&(A.env=D)):(A.url=a.url,a.type==="sse"&&(A.transport="sse"),Object.keys(ne).length>0&&(A.headers=ne));const z=await we("/api/mcp",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(A)});if(z.ok)me.success("Server added successfully"),s(!1),M(),R();else{const ee=await z.json();me.error(ee.error||"Failed to add server")}}catch(D){me.error(D.message)}},$=D=>{var z,ee;const ne=((z=D.missingEnv)==null?void 0:z.length)??0,A=(((ee=D.argFields)==null?void 0:ee.length)??0)>0;return ne>0||A},E=D=>{const ne=[];for(const A of D.requiredEnv??[])ne.push({key:A,value:""});for(const A of D.argFields??[])ne.push({key:`__arg_${A.index}`,value:A.value});w(ne),v(D)},P=async(D,ne)=>{var ee;const A=await we(`/api/mcp/${D}/activate`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(ne)});if(A.ok)return!0;const z=await A.json().catch(()=>({error:`HTTP ${A.status}`}));return A.status===423?me.error("Vault is locked — unlock it in Settings first."):A.status===400&&((ee=z.missingEnv)!=null&&ee.length)?me.error(`Missing: ${z.missingEnv.join(", ")}`):me.error(z.error||"Activation failed"),!1},V=async D=>{const ne=me.loading(`Activating ${D.name}...`);await P(D.name,{})?me.success(`${D.name} activated`,{id:ne}):me.dismiss(ne),R()},F=async D=>{const ne=me.loading(`Deactivating ${D.name}...`);(await we(`/api/mcp/${D.name}/deactivate`,{method:"POST"})).ok?me.success(`${D.name} deactivated`,{id:ne}):me.error("Failed to deactivate",{id:ne}),R()},K=async()=>{if(g){T(!0);try{const D={},ne={};for(const B of k){const X=B.key.trim(),ye=B.value.trim();X&&(X.startsWith("__arg_")?ye&&(ne[X.replace("__arg_","")]=ye):ye&&(D[X]=ye))}const A=(g.missingEnv??[]).filter(B=>!D[B]);if(Object.keys(D).length===0&&Object.keys(ne).length===0&&A.length>0){me.error(`Fill in: ${A.join(", ")}`),T(!1);return}const z={};Object.keys(D).length>0&&(z.env=D),Object.keys(ne).length>0&&(z.args=ne),await P(g.name,z)&&(me.success(`${g.name} activated`),v(null),w([])),R()}catch(D){me.error(D.message)}finally{T(!1)}}},J=(D,ne)=>{ne([...D,{key:"",value:""}])},Q=(D,ne,A,z,ee)=>{const B=[...D];B[A][z]=ee,ne(B)},Z=(D,ne,A)=>{ne(D.filter((z,ee)=>ee!==A))};return n?o.jsx("div",{className:"flex items-center justify-center h-full",children:o.jsx($t,{className:"w-8 h-8 text-[#00d9ff] animate-spin"})}):o.jsxs("div",{className:"space-y-6",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{children:[o.jsx("h2",{className:"text-3xl font-bold text-white mb-2 uppercase tracking-tighter",children:"MCP Servers"}),o.jsx("p",{className:"text-gray-400 font-mono text-sm tracking-widest",children:"EXTERNAL TOOL INTEGRATIONS"})]}),o.jsxs(hi,{open:i,onOpenChange:D=>{s(D),D||M()},children:[o.jsx(fl,{asChild:!0,children:o.jsxs(at,{className:"bg-gradient-to-r from-[#00d9ff] to-[#4ECDC4] hover:opacity-90 text-white font-mono text-xs uppercase tracking-wider",children:[o.jsx(Cs,{className:"w-4 h-4 mr-2"}),"Add Server"]})}),o.jsxs(fi,{className:"bg-slate-950 border-slate-800 text-white border-2 shadow-[0_0_30px_rgba(0,217,255,0.1)] max-h-[85vh] overflow-y-auto",children:[o.jsx(pi,{children:o.jsx(mi,{className:"text-white uppercase font-bold tracking-widest border-b border-slate-800 pb-4",children:"New MCP Connection"})}),o.jsxs("div",{className:"space-y-4 pt-4 font-mono",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx("label",{className:"text-[10px] text-gray-500 uppercase",children:"Server Name"}),o.jsx(Dt,{value:a.name,onChange:D=>c({...a,name:D.target.value}),placeholder:"e.g. github, slack, postgres",className:"bg-slate-900 border-slate-800 text-[#00d9ff] text-xs"})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx("label",{className:"text-[10px] text-gray-500 uppercase",children:"Description (optional)"}),o.jsx(Dt,{value:a.description,onChange:D=>c({...a,description:D.target.value}),placeholder:"e.g. GitHub repos, PRs, issues",className:"bg-slate-900 border-slate-800 text-white text-xs"})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx("label",{className:"text-[10px] text-gray-500 uppercase",children:"Transport Protocol"}),o.jsxs(Qt,{value:a.type,onValueChange:D=>c({...a,type:D}),children:[o.jsx(en,{className:"bg-slate-900 border-slate-800 text-white text-xs",children:o.jsx(Zt,{})}),o.jsxs(tn,{className:"bg-slate-950 border-slate-800 text-white",children:[o.jsx(st,{value:"stdio",className:"text-xs",children:"STDIO (LOCAL PROCESS)"}),o.jsx(st,{value:"http",className:"text-xs",children:"HTTP (STREAMABLE)"}),o.jsx(st,{value:"sse",className:"text-xs",children:"SSE (LEGACY)"})]})]})]}),a.type==="stdio"?o.jsxs("div",{className:"space-y-2",children:[o.jsx("label",{className:"text-[10px] text-gray-500 uppercase",children:"Command"}),o.jsx(Dt,{value:a.command,onChange:D=>c({...a,command:D.target.value}),placeholder:"npx -y @modelcontextprotocol/server-github",className:"bg-slate-900 border-slate-800 text-white text-xs"})]}):o.jsxs("div",{className:"space-y-2",children:[o.jsx("label",{className:"text-[10px] text-gray-500 uppercase",children:"Endpoint URL"}),o.jsx(Dt,{value:a.url,onChange:D=>c({...a,url:D.target.value}),placeholder:"https://mcp.example.com/sse",className:"bg-slate-900 border-slate-800 text-white text-xs"})]}),a.type==="stdio"&&o.jsxs("div",{className:"space-y-2",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("label",{className:"text-[10px] text-gray-500 uppercase flex items-center gap-1",children:[o.jsx(xu,{className:"w-3 h-3"})," Environment Variables"]}),o.jsxs(at,{type:"button",variant:"ghost",size:"sm",onClick:()=>J(h,d),className:"text-[10px] text-[#00d9ff] hover:bg-[#00d9ff]/10 h-6 px-2",children:[o.jsx(Cs,{className:"w-3 h-3 mr-1"})," Add"]})]}),h.length===0&&o.jsx("p",{className:"text-[10px] text-gray-600 italic",children:"No env vars. Click Add if server needs API keys."}),h.map((D,ne)=>o.jsxs("div",{className:"flex gap-2 items-center",children:[o.jsx(Dt,{value:D.key,onChange:A=>Q(h,d,ne,"key",A.target.value),placeholder:"GITHUB_TOKEN",className:"bg-slate-900 border-slate-800 text-gray-300 text-xs flex-1"}),o.jsx(Dt,{type:"password",value:D.value,onChange:A=>Q(h,d,ne,"value",A.target.value),placeholder:"value or ${ENV_VAR}",className:"bg-slate-900 border-slate-800 text-gray-300 text-xs flex-1"}),o.jsx("button",{onClick:()=>Z(h,d,ne),className:"text-gray-600 hover:text-red-400 shrink-0",children:o.jsx(ol,{className:"w-3.5 h-3.5"})})]},ne))]}),(a.type==="http"||a.type==="sse")&&o.jsxs("div",{className:"space-y-2",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("label",{className:"text-[10px] text-gray-500 uppercase flex items-center gap-1",children:[o.jsx(xu,{className:"w-3 h-3"})," Auth Headers"]}),o.jsxs(at,{type:"button",variant:"ghost",size:"sm",onClick:()=>J(f,p),className:"text-[10px] text-[#00d9ff] hover:bg-[#00d9ff]/10 h-6 px-2",children:[o.jsx(Cs,{className:"w-3 h-3 mr-1"})," Add"]})]}),f.length===0&&o.jsx("p",{className:"text-[10px] text-gray-600 italic",children:"No headers. Click Add for auth (e.g. Authorization: Bearer token)."}),f.map((D,ne)=>o.jsxs("div",{className:"flex gap-2 items-center",children:[o.jsx(Dt,{value:D.key,onChange:A=>Q(f,p,ne,"key",A.target.value),placeholder:"Authorization",className:"bg-slate-900 border-slate-800 text-gray-300 text-xs flex-[0.8]"}),o.jsx(Dt,{type:"password",value:D.value,onChange:A=>Q(f,p,ne,"value",A.target.value),placeholder:"Bearer ${MY_TOKEN}",className:"bg-slate-900 border-slate-800 text-gray-300 text-xs flex-1"}),o.jsx("button",{onClick:()=>Z(f,p,ne),className:"text-gray-600 hover:text-red-400 shrink-0",children:o.jsx(ol,{className:"w-3.5 h-3.5"})})]},ne)),f.length>0&&o.jsxs("p",{className:"text-[9px] text-gray-600",children:["Use ","${ENV_VAR}"," to reference .env values instead of pasting secrets."]})]}),o.jsx(at,{onClick:L,disabled:!a.name||(a.type==="stdio"?!a.command:!a.url),className:"w-full bg-gradient-to-r from-[#00d9ff] to-[#4ECDC4] hover:opacity-90 text-white mt-4 uppercase tracking-tighter",children:"Add Server"})]})]})]})]}),o.jsx(hi,{open:!!g,onOpenChange:D=>{D||(v(null),w([]))},children:o.jsxs(fi,{className:"bg-slate-950 border-slate-800 text-white border-2 shadow-[0_0_30px_rgba(0,217,255,0.1)]",children:[o.jsx(pi,{children:o.jsxs(mi,{className:"text-white uppercase font-bold tracking-widest border-b border-slate-800 pb-4 flex items-center gap-2",children:[o.jsx(xu,{className:"w-4 h-4 text-[#00d9ff]"}),"Configure ",g==null?void 0:g.name]})}),o.jsxs("div",{className:"space-y-4 pt-2 font-mono",children:[o.jsx("p",{className:"text-[10px] text-gray-500 uppercase tracking-wider leading-relaxed",children:"Secrets (API keys, tokens) go to the encrypted vault. Paths and connection strings stay in mcp.json. Leave any field blank to keep its current stored value."}),k.map((D,ne)=>{var X,ye;const A=D.key.startsWith("__arg_"),z=A?(X=g==null?void 0:g.argFields)==null?void 0:X.find(se=>`__arg_${se.index}`===D.key):void 0,ee=A?(z==null?void 0:z.label)??`Argument [${D.key.replace("__arg_","")}]`:D.key,B=A?z==null?void 0:z.hint:(ye=g==null?void 0:g.missingEnv)!=null&&ye.includes(D.key)?"Required — not yet set":"Already stored in vault (leave blank to keep)";return o.jsxs("div",{className:"space-y-1.5",children:[o.jsx("label",{className:"text-[10px] text-gray-400 uppercase",children:ee}),o.jsx(Dt,{type:A?"text":"password",value:D.value,onChange:se=>{const oe=[...k];oe[ne].value=se.target.value,w(oe)},placeholder:A?(z==null?void 0:z.value)??"":`Enter ${D.key}…`,className:"bg-slate-900 border-slate-800 text-white text-xs"}),B&&o.jsx("p",{className:"text-[9px] text-gray-600 font-mono",children:B})]},ne)}),k.length===0&&o.jsx("p",{className:"text-[10px] text-gray-600 italic",children:"No required fields — this server can be activated directly."}),o.jsxs(at,{onClick:K,disabled:S,className:"w-full bg-gradient-to-r from-[#00d9ff] to-[#4ECDC4] hover:opacity-90 text-white mt-2 uppercase tracking-tighter",children:[S?o.jsx($t,{className:"w-4 h-4 mr-2 animate-spin"}):o.jsx(xu,{className:"w-4 h-4 mr-2"}),"Save & Activate"]})]})]})}),o.jsx("div",{className:"grid grid-cols-1 gap-4",children:t.length===0?o.jsx("div",{className:"text-center py-20 border-2 border-dashed border-slate-800 rounded-xl bg-slate-900/20",children:o.jsx("p",{className:"text-gray-600 font-mono uppercase tracking-widest text-xs",children:"NO MCP SERVERS CONFIGURED"})}):t.map(D=>{var ee,B,X,ye,se;const ne=(((ee=D.requiredEnv)==null?void 0:ee.length)??0)>0||(((B=D.argFields)==null?void 0:B.length)??0)>0,A=!D.configured,z=D.enabled&&!D.connected;return o.jsxs(rn,{className:`bg-slate-900/50 border-slate-800 backdrop-blur-sm shadow-xl transition-all border-l-4 ${D.connected?"border-l-[#00ff88]":"border-l-slate-700"}`,children:[o.jsx(br,{className:"py-4",children:o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{className:"flex items-center gap-4",children:[o.jsx("div",{className:`w-2 h-2 rounded-full ${D.connected?"bg-[#00ff88] shadow-[0_0_8px_rgba(0,255,136,0.5)]":"bg-slate-700"}`}),o.jsxs("div",{children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(kr,{className:"text-white font-mono text-lg uppercase tracking-tight",children:D.name}),D.enabled&&D.connected&&o.jsx(Kt,{variant:"outline",className:"text-[9px] text-[#00ff88] border-[#00ff88]/40 bg-[#00ff88]/5",children:"ACTIVE"}),z&&o.jsxs("div",{className:"flex items-center gap-1 text-[9px] text-red-400 font-mono uppercase bg-red-500/10 px-1.5 py-0.5 rounded border border-red-500/20",children:[o.jsx(Gr,{className:"w-2.5 h-2.5"}),"Connection Failed"]}),!D.enabled&&A&&o.jsx(Kt,{variant:"outline",className:"text-[9px] text-amber-500 border-amber-700/40 bg-amber-500/5",children:"NEEDS CONFIG"}),!D.enabled&&!A&&o.jsx(Kt,{variant:"outline",className:"text-[9px] text-sky-400 border-sky-700/40 bg-sky-500/5",children:"CONFIGURED"})]}),D.description&&o.jsx("p",{className:"text-gray-400 text-[11px] mt-0.5",children:D.description}),o.jsxs(to,{className:"text-gray-500 font-mono text-[10px] mt-0.5 uppercase flex items-center gap-2",children:[D.transport==="stdio"||D.type==="stdio"?o.jsx(Ja,{className:"w-3 h-3"}):o.jsx(wN,{className:"w-3 h-3"}),D.transport==="stdio"||D.type==="stdio"?D.command:D.url]}),(((X=D.requiredEnv)==null?void 0:X.length)??0)>0&&o.jsxs("div",{className:"flex items-center gap-1.5 mt-1 flex-wrap",children:[o.jsx(xu,{className:"w-3 h-3 text-gray-600"}),(ye=D.requiredEnv)==null?void 0:ye.map(oe=>{const U=(D.missingEnv??[]).includes(oe);return o.jsxs(Kt,{variant:"outline",className:`text-[8px] font-mono ${U?"text-amber-500 border-amber-900/40":"text-emerald-500/80 border-emerald-900/40"}`,children:[U?"✗":"✓"," ",oe]},oe)})]})]})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[ne&&o.jsxs(at,{variant:"ghost",size:"sm",onClick:()=>E(D),className:`font-mono text-[10px] uppercase ${A?"text-amber-500 hover:bg-amber-500/10":"text-gray-400 hover:bg-slate-800"}`,children:[o.jsx(pp,{className:"w-3 h-3 mr-1"}),"Configure"]}),o.jsxs(at,{variant:"ghost",size:"sm",onClick:()=>{if(D.enabled){F(D);return}$(D)?E(D):V(D)},className:`font-mono text-[10px] uppercase ${D.enabled?"text-amber-500 hover:bg-amber-500/10":"text-[#00ff88] hover:bg-[#00ff88]/10"}`,children:[D.enabled?o.jsx(CN,{className:"w-3 h-3 mr-1"}):o.jsx(Cy,{className:"w-3 h-3 mr-1"}),D.enabled?"Suspend":"Activate"]}),o.jsxs(at,{variant:"ghost",size:"sm",onClick:()=>_(D.name,"reload"),className:"text-gray-400 hover:text-white font-mono text-[10px] uppercase hover:bg-slate-800",children:[o.jsx(so,{className:"w-3 h-3 mr-1"}),"Sync"]}),o.jsxs(at,{variant:"ghost",size:"sm",onClick:()=>I(D.name),className:"text-red-500/70 hover:text-red-500 font-mono text-[10px] uppercase hover:bg-red-500/10",children:[o.jsx(qn,{className:"w-3 h-3 mr-1"}),"Remove"]})]})]})}),o.jsx(on,{className:"pb-4",children:o.jsxs("div",{className:"space-y-3",children:[o.jsxs("div",{className:"flex items-center justify-between text-[10px] font-mono text-gray-500 uppercase tracking-widest border-b border-slate-800 pb-2",children:[o.jsx("span",{children:"Active Tools"}),o.jsxs("span",{className:"text-[#00d9ff]",children:[((se=D.tools)==null?void 0:se.length)||0," Tools"]})]}),o.jsx("div",{className:"flex flex-wrap gap-1.5 pt-1",children:!D.connected&&D.enabled?o.jsx("div",{className:"p-3 bg-slate-950/50 border border-slate-800 rounded w-full",children:o.jsx("p",{className:"text-[10px] text-amber-500/70 font-mono leading-relaxed uppercase",children:"Server offline. Check credentials or CLI configuration. Some servers require valid API keys to connect."})}):D.tools&&D.tools.length>0?D.tools.map(oe=>o.jsx(Kt,{variant:"outline",className:"bg-slate-950/50 text-gray-400 border-slate-800 font-mono text-[10px] hover:text-[#00d9ff] hover:border-[#00d9ff]/30 transition-colors",children:oe.name||oe},oe.name||oe)):o.jsx("span",{className:"text-[10px] text-gray-600 font-mono italic lowercase tracking-tight",children:D.enabled?"no tools exported":D.needsConfig?"configure credentials to activate":"server disabled"})})]})})]},D.name)})}),o.jsx(js,{open:C.open,onOpenChange:D=>j(ne=>({...ne,open:D})),children:o.jsxs(Ps,{className:"bg-slate-900 border border-slate-700 text-white",children:[o.jsxs(_s,{children:[o.jsx(Is,{className:"text-white font-mono uppercase text-sm tracking-wide",children:C.title}),C.description&&o.jsx(Ms,{className:"text-gray-400 font-mono text-xs",children:C.description})]}),o.jsxs(Rs,{children:[o.jsx(As,{className:"bg-slate-800 border-slate-700 text-gray-300 hover:bg-slate-700 font-mono text-xs uppercase",children:"Cancel"}),o.jsx(Ds,{className:"bg-red-500/20 text-red-400 border border-red-500/30 hover:bg-red-500/30 font-mono text-xs uppercase",onClick:()=>{C.onConfirm(),j(D=>({...D,open:!1}))},children:"Confirm"})]})]})})]})}function xG(){const[t,e]=x.useState([]),[n,r]=x.useState(!0),i=async()=>{try{const a=await we("/api/skills");if(a.ok){const c=await a.json();e(c.skills||[])}}catch(a){console.error("Failed to fetch skills",a)}finally{r(!1)}};x.useEffect(()=>{i()},[]);const s=async()=>{const a=me.loading("Reloading skills...");try{const c=await we("/api/skills/reload",{method:"POST"});if(!c.ok){me.error("Failed to reload skills",{id:a});return}const h=await c.json(),d=await we("/api/skills");if(d.ok){const f=await d.json();e(f.skills||[])}me.success(`Skills reloaded (${h.loaded??0} loaded)`,{id:a})}catch{me.error("Failed to reload skills",{id:a})}};return n?o.jsx("div",{className:"flex items-center justify-center h-full",children:o.jsx($t,{className:"w-8 h-8 text-[#00d9ff] animate-spin"})}):o.jsxs("div",{className:"space-y-6",children:[o.jsxs("div",{children:[o.jsx("h2",{className:"text-3xl font-bold text-white mb-2 uppercase tracking-tighter",children:"Skills"}),o.jsx("p",{className:"text-gray-400 font-mono text-sm tracking-widest",children:"AGENT CAPABILITIES"})]}),o.jsx("div",{children:o.jsxs(rn,{className:"bg-slate-900/50 border-slate-800 backdrop-blur-sm shadow-xl",children:[o.jsx(br,{className:"border-b border-slate-800/50",children:o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx(EN,{className:"w-6 h-6 text-[#00d9ff]"}),o.jsxs("div",{children:[o.jsx(kr,{className:"text-white uppercase tracking-tight",children:"Loaded Skills"}),o.jsx(to,{className:"text-gray-500 font-mono text-[10px] uppercase",children:"AVAILABLE CAPABILITIES"})]})]}),o.jsxs(at,{onClick:s,variant:"ghost",size:"sm",className:"text-gray-400 hover:text-[#00d9ff] font-mono text-[10px] uppercase tracking-wider",children:[o.jsx(so,{className:"w-3 h-3 mr-2"}),"Reload"]})]})}),o.jsx(on,{className:"pt-6",children:o.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:t.length===0?o.jsx("div",{className:"col-span-full text-center py-12 text-gray-600 font-mono uppercase text-xs",children:"No skills detected in /skills directory"}):t.map(a=>o.jsxs("div",{className:"p-4 bg-slate-800/30 border border-slate-800 rounded-lg hover:border-[#00d9ff]/30 transition-colors group",children:[o.jsx("div",{className:"font-mono text-sm text-[#00d9ff] uppercase tracking-tighter mb-1 group-hover:text-white transition-colors",children:a.name}),o.jsx("p",{className:"text-xs text-gray-500 font-mono leading-relaxed lowercase",children:a.description})]},a.name))})})]})})]})}const gT={minimal:{label:"MINIMAL",desc:"Read-only tools only",color:"text-[#00ff88]"},standard:{label:"STANDARD",desc:"Read + write + sandboxed commands",color:"text-[#00d9ff]"},full:{label:"FULL",desc:"All tools including dangerous ones",color:"text-[#ff4458]"}};function bG(t){return t.trim()?t.startsWith("/")?t.includes("..")?"Path cannot contain '..'":/[\x00-\x1f]/.test(t)?"Path cannot contain control characters":null:"Path must be absolute (start with /)":"Path cannot be empty"}function kG({dirty:t,saving:e,saved:n,onSave:r}){return o.jsxs("button",{onClick:r,disabled:!t||e,className:`flex items-center gap-1.5 px-3.5 py-2 rounded-lg text-[10px] font-mono uppercase tracking-wider transition-all ${t?"bg-[#00d9ff]/15 text-[#00d9ff] border border-[#00d9ff]/40 hover:bg-[#00d9ff]/25 cursor-pointer shadow-[0_0_12px_rgba(0,217,255,0.1)]":n?"bg-[#00ff88]/10 text-[#00ff88] border border-[#00ff88]/30":"bg-slate-800/50 text-gray-600 border border-slate-700/50 cursor-not-allowed"}`,children:[e?o.jsx($t,{className:"w-3.5 h-3.5 animate-spin"}):n?o.jsx(ky,{className:"w-3.5 h-3.5"}):o.jsx(rd,{className:"w-3.5 h-3.5"}),e?"Saving...":n?"Saved":"Save"]})}function vT({paths:t,onRemove:e,variant:n="default"}){if(!t.length)return o.jsx("span",{className:"text-[10px] text-gray-600 font-mono italic",children:"None configured"});const r=n==="danger"?"bg-red-500/10 border-red-500/30 text-red-400":"bg-[#00d9ff]/10 border-[#00d9ff]/30 text-[#00d9ff]";return o.jsx("div",{className:"flex flex-wrap gap-1.5",children:t.map((i,s)=>o.jsxs("span",{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded text-[10px] font-mono border ${r}`,children:[i,o.jsx("button",{onClick:()=>e(s),className:"hover:text-white transition-colors ml-0.5",children:o.jsx(ol,{className:"w-3 h-3"})})]},s))})}function wG(){var ye;const[t,e]=x.useState({exists:!1,unlocked:!1}),[n,r]=x.useState(null),[i,s]=x.useState(""),[a,c]=x.useState(!0),[h,d]=x.useState(!1),[f,p]=x.useState("standard"),[g,v]=x.useState("moderate"),[k,w]=x.useState([]),[S,T]=x.useState([]),[C,j]=x.useState([]),[R,_]=x.useState({}),[I,M]=x.useState(""),[L,$]=x.useState(""),[E,P]=x.useState(!1),[V,F]=x.useState(!1),[K,J]=x.useState(!1),Q=()=>{P(!0),J(!1)},Z=async()=>{var se;try{const[oe,U]=await Promise.all([we("/api/settings"),we("/api/security/fs")]);if(oe.ok){const ke=(await oe.json()).vars||{};p(ke.PERMISSION_TIER||"standard")}if(U.ok){const ue=await U.json();v(ue.mode||"moderate"),w(Array.isArray(ue.allow)?ue.allow:[]),T(Array.isArray(ue.deny)?ue.deny:[]),j(((se=ue.effective)==null?void 0:se.allow)??[]),_(ue.doc??{})}}catch(oe){console.error("Failed to load security settings",oe)}},D=async()=>{try{const[se,oe]=await Promise.all([we("/api/vault/status"),we("/api/audit"),Z()]);se.ok&&e(await se.json()),oe.ok&&r(await oe.json())}catch(se){console.error("Security data fetch failed",se)}finally{c(!1)}};x.useEffect(()=>{D()},[]);const ne=async()=>{try{const se=await we("/auth/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({passphrase:i})});if(se.ok)sessionStorage.setItem("daemora_vault_pass",i),me.success("Vault unlocked successfully"),d(!1),s(""),D();else{const oe=await se.json().catch(()=>({}));me.error(oe.error||"ACCESS DENIED")}}catch{me.error("Failed to unlock vault")}},A=async()=>{try{(await we("/api/vault/lock",{method:"POST"})).ok&&(me.success("Vault locked successfully"),D())}catch{me.error("Failed to lock vault")}},z=async()=>{F(!0);try{const se=await we("/api/settings",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({updates:{PERMISSION_TIER:f}})}),oe=await we("/api/security/fs",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({mode:g,allow:k,deny:S})});if(se.ok&&oe.ok)J(!0),P(!1),me.success("Security settings saved"),await Z();else{const U=await(oe.ok?se:oe).json().catch(()=>({}));me.error(U.error||"Failed to save settings")}}catch{me.error("Failed to save settings")}finally{F(!1)}},ee=se=>{const oe=se==="allowed"?I:L,U=bG(oe);if(U){me.error(U);return}const ue=oe.trim();if(se==="allowed"){if(k.includes(ue)){me.error("Path already added");return}w(ke=>[...ke,ue]),M("")}else{if(S.includes(ue)){me.error("Path already added");return}T(ke=>[...ke,ue]),$("")}Q()},B=(se,oe)=>{se==="allowed"?w(U=>U.filter((ue,ke)=>ke!==oe)):T(U=>U.filter((ue,ke)=>ke!==oe)),Q()},X=se=>{switch(se){case"info":return"text-[#00d9ff]";case"warning":return"text-[#ffaa00]";case"critical":return"text-[#ff4458]";default:return"text-gray-500"}};return a?o.jsx("div",{className:"flex items-center justify-center h-full",children:o.jsx($t,{className:"w-8 h-8 text-[#00d9ff] animate-spin"})}):o.jsxs("div",{className:"space-y-6",children:[o.jsxs("div",{children:[o.jsx("h2",{className:"text-3xl font-bold text-white mb-2 uppercase tracking-tighter",children:"Security"}),o.jsx("p",{className:"text-gray-400 font-mono text-sm tracking-widest",children:"VAULT · AUDIT · PERMISSIONS · SANDBOX"})]}),o.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[o.jsxs(rn,{className:"bg-slate-900/50 border-slate-800 backdrop-blur-sm shadow-xl h-full",children:[o.jsx(br,{children:o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx(zu,{className:"w-6 h-6 text-[#00d9ff]"}),o.jsxs("div",{children:[o.jsx(kr,{className:"text-white uppercase tracking-tight",children:"Secret Vault"}),o.jsx(to,{className:"text-gray-500 font-mono text-[10px] uppercase",children:"ENCRYPTED CREDENTIAL STORAGE"})]})]})}),o.jsxs(on,{className:"space-y-6",children:[o.jsxs("div",{className:"flex items-center justify-between p-6 bg-slate-800/30 border border-slate-800 rounded-xl",children:[o.jsxs("div",{className:"flex items-center gap-4",children:[t.unlocked?o.jsx(Z0,{className:"w-10 h-10 text-[#00ff88]"}):o.jsxs("div",{className:"relative",children:[o.jsx(If,{className:"w-10 h-10 text-[#ff4458]"}),o.jsx("div",{className:"absolute inset-0 animate-ping bg-[#ff4458]/20 rounded-full scale-150 opacity-20"})]}),o.jsxs("div",{children:[o.jsx("div",{className:"font-mono font-bold text-xl text-white uppercase tracking-wider",children:t.unlocked?"SYSTEM UNLOCKED":"ENCRYPTED"}),o.jsx("div",{className:"text-[10px] text-gray-500 font-mono uppercase tracking-widest mt-1",children:t.unlocked?"Secrets loaded into memory":"AES-256-GCM Protection Active"})]})]}),t.unlocked?o.jsxs(at,{onClick:A,variant:"outline",className:"border-slate-700 text-gray-400 hover:text-white font-mono text-xs uppercase",children:[o.jsx(If,{className:"w-4 h-4 mr-2"}),"Purge Keys"]}):o.jsxs(hi,{open:h,onOpenChange:d,children:[o.jsx(fl,{asChild:!0,children:o.jsx(at,{className:"bg-[#ff4458] hover:bg-red-600 text-white font-mono text-xs uppercase tracking-widest px-6 shadow-[0_0_20px_rgba(255,68,88,0.2)]",children:"Decrypt"})}),o.jsxs(fi,{className:"bg-slate-950 border-slate-800 text-white font-mono",children:[o.jsx(pi,{children:o.jsx(mi,{className:"uppercase tracking-widest text-sm border-b border-slate-800 pb-4",children:"Auth Required"})}),o.jsxs("div",{className:"space-y-4 pt-4",children:[o.jsxs("div",{className:"flex items-start gap-3 p-3 bg-red-500/10 border border-red-500/20 rounded-lg",children:[o.jsx(Gr,{className:"w-4 h-4 text-red-500 flex-shrink-0 mt-0.5"}),o.jsx("p",{className:"text-[10px] text-gray-400 uppercase leading-relaxed",children:"Enter master passphrase to unlock API credentials. Multi-factor verification active."})]}),o.jsx(Dt,{type:"password",value:i,onChange:se=>s(se.target.value),onKeyDown:se=>se.key==="Enter"&&ne(),placeholder:"PASSPHRASE...",className:"bg-slate-900 border-slate-800 text-[#00ff88] text-center tracking-[0.5em]"}),o.jsx(at,{onClick:ne,disabled:!i,className:"w-full bg-white text-black hover:bg-gray-200 uppercase text-xs font-bold",children:"Execute Decryption"})]})]})]})]}),o.jsxs("div",{className:"p-4 bg-slate-950/50 border border-slate-800 rounded-lg",children:[o.jsx("h4",{className:"text-[10px] font-mono text-gray-500 uppercase tracking-widest mb-3",children:"Security Parameters"}),o.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[o.jsxs("div",{children:[o.jsx("div",{className:"text-[9px] text-gray-600 uppercase mb-1",children:"Local Mode"}),o.jsx(Kt,{variant:"outline",className:"border-[#00ff88]/30 text-[#00ff88] font-mono text-[10px]",children:"ENFORCED"})]}),o.jsxs("div",{children:[o.jsx("div",{className:"text-[9px] text-gray-600 uppercase mb-1",children:"Vault Status"}),o.jsx(Kt,{variant:"outline",className:"border-slate-800 text-gray-400 font-mono text-[10px]",children:t.exists?"PERSISTED":"NOT FOUND"})]})]})]})]})]}),o.jsxs(rn,{className:"bg-slate-900/50 border-slate-800 backdrop-blur-sm shadow-xl h-full flex flex-col",children:[o.jsx(br,{children:o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx(Ss,{className:"w-6 h-6 text-[#7C6AFF]"}),o.jsxs("div",{children:[o.jsx(kr,{className:"text-white uppercase tracking-tight",children:"Audit Log"}),o.jsx(to,{className:"text-gray-500 font-mono text-[10px] uppercase",children:"SECURITY EVENTS"})]})]})}),o.jsx(on,{className:"flex-1 overflow-hidden p-0",children:o.jsx(sE,{className:"h-[400px] px-6",children:o.jsx("div",{className:"space-y-4 py-6",children:!n||!n.recentEvents||n.recentEvents.length===0?o.jsx("div",{className:"text-center py-20 text-gray-700 font-mono uppercase text-[10px] tracking-widest italic",children:"No security events logged"}):n.recentEvents.map((se,oe)=>o.jsxs("div",{className:"p-3 bg-slate-800/20 border border-slate-800/50 rounded-lg font-mono",children:[o.jsxs("div",{className:"flex items-start justify-between mb-1",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("div",{className:`w-1.5 h-1.5 rounded-full ${se.level==="critical"?"bg-red-500":se.level==="warning"?"bg-amber-500":"bg-[#00d9ff]"}`}),o.jsx("span",{className:"text-[10px] font-bold text-white uppercase tracking-tight",children:se.type})]}),o.jsx(Kt,{variant:"outline",className:`text-[8px] h-4 uppercase ${X(se.level)} border-current opacity-50`,children:se.level})]}),o.jsx("p",{className:"text-[10px] text-gray-400 leading-relaxed lowercase mb-2",children:se.message}),o.jsx("div",{className:"text-[8px] text-gray-600 uppercase tracking-tighter",children:new Date(se.timestamp).toLocaleString()})]},oe))})})})]})]}),o.jsxs(rn,{className:"bg-slate-900/50 border-slate-800 backdrop-blur-sm shadow-xl",children:[o.jsx(br,{children:o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx(dD,{className:"w-6 h-6 text-[#ffaa00]"}),o.jsxs("div",{children:[o.jsx(kr,{className:"text-white uppercase tracking-tight",children:"Permission & Sandbox"}),o.jsx(to,{className:"text-gray-500 font-mono text-[10px] uppercase",children:"GLOBAL DEFAULTS"})]})]})}),o.jsxs(on,{className:"space-y-6",children:[o.jsx("div",{className:"p-4 bg-slate-800/30 border border-slate-800 rounded-xl space-y-3",children:o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{children:[o.jsx("h4",{className:"text-xs font-mono text-white uppercase tracking-wider",children:"Permission Tier"}),o.jsx("p",{className:"text-[10px] text-gray-500 font-mono mt-0.5",children:((ye=gT[f])==null?void 0:ye.desc)||"Controls which tools the agent can use"})]}),o.jsxs(Qt,{value:f,onValueChange:se=>{p(se),Q()},children:[o.jsx(en,{className:"w-[160px] bg-slate-950 border-slate-700 text-white font-mono text-[10px] uppercase h-8",children:o.jsx(Zt,{placeholder:"STANDARD"})}),o.jsx(tn,{className:"bg-slate-950 border-slate-700",children:Object.entries(gT).map(([se,oe])=>o.jsx(st,{value:se,className:`font-mono text-[10px] uppercase ${oe.color}`,children:oe.label},se))})]})]})}),o.jsxs("div",{className:"p-4 bg-slate-800/30 border border-slate-800 rounded-xl space-y-4",children:[o.jsxs("div",{className:"flex items-center justify-between gap-4",children:[o.jsxs("div",{className:"flex-1",children:[o.jsx("h4",{className:"text-xs font-mono text-white uppercase tracking-wider",children:"Filesystem Guard"}),o.jsx("p",{className:"text-[10px] text-gray-500 font-mono mt-0.5",children:R[g]||"Controls which paths the agent can read, write, or execute"})]}),o.jsxs(Qt,{value:g,onValueChange:se=>{v(se),Q()},children:[o.jsx(en,{className:"w-[160px] bg-slate-950 border-slate-700 text-white font-mono text-[10px] uppercase h-8",children:o.jsx(Zt,{})}),o.jsxs(tn,{className:"bg-slate-950 border-slate-700",children:[o.jsx(st,{value:"off",className:"font-mono text-[10px] uppercase text-gray-400",children:"OFF"}),o.jsx(st,{value:"moderate",className:"font-mono text-[10px] uppercase text-[#00d9ff]",children:"MODERATE"}),o.jsx(st,{value:"strict",className:"font-mono text-[10px] uppercase text-[#ffaa00]",children:"STRICT"}),o.jsx(st,{value:"sandbox",className:"font-mono text-[10px] uppercase text-[#ff4458]",children:"SANDBOX"})]})]})]}),(g==="strict"||g==="sandbox")&&o.jsxs("div",{className:"space-y-2",children:[o.jsxs("div",{className:"text-[10px] font-mono text-gray-400 uppercase tracking-wider",children:["Allowed Paths ",g==="sandbox"?"(only these are reachable)":"(in addition to $HOME)"]}),o.jsx(vT,{paths:k,onRemove:se=>B("allowed",se)}),o.jsxs("div",{className:"flex gap-2",children:[o.jsx(Dt,{value:I,onChange:se=>M(se.target.value),onKeyDown:se=>se.key==="Enter"&&ee("allowed"),placeholder:"/path/to/allow",className:"bg-slate-950 border-slate-700 text-white font-mono text-xs h-8 flex-1"}),o.jsx(at,{onClick:()=>ee("allowed"),size:"sm",className:"bg-[#00d9ff]/15 text-[#00d9ff] border border-[#00d9ff]/30 hover:bg-[#00d9ff]/25 h-8 px-3",children:o.jsx(Cs,{className:"w-3.5 h-3.5"})})]})]}),g!=="off"&&o.jsxs("div",{className:"space-y-2",children:[o.jsx("div",{className:"text-[10px] font-mono text-gray-400 uppercase tracking-wider",children:"Extra Blocked Paths"}),o.jsx(vT,{paths:S,onRemove:se=>B("blocked",se),variant:"danger"}),o.jsxs("div",{className:"flex gap-2",children:[o.jsx(Dt,{value:L,onChange:se=>$(se.target.value),onKeyDown:se=>se.key==="Enter"&&ee("blocked"),placeholder:"/path/to/block",className:"bg-slate-950 border-slate-700 text-white font-mono text-xs h-8 flex-1"}),o.jsx(at,{onClick:()=>ee("blocked"),size:"sm",className:"bg-red-500/15 text-red-400 border border-red-500/30 hover:bg-red-500/25 h-8 px-3",children:o.jsx(Cs,{className:"w-3.5 h-3.5"})})]}),o.jsx("p",{className:"text-[10px] text-gray-600 font-mono",children:"~/.ssh, ~/.aws, /etc are always blocked in moderate/strict/sandbox."})]}),C.length>0&&o.jsxs("details",{className:"text-[10px] font-mono text-gray-500",children:[o.jsx("summary",{className:"cursor-pointer hover:text-gray-300",children:"Effective allow-list (resolved)"}),o.jsx("ul",{className:"mt-2 space-y-0.5 pl-4",children:C.map(se=>o.jsxs("li",{children:["· ",se]},se))})]})]})]})]}),(E||K)&&o.jsx("div",{className:"flex justify-end",children:o.jsx(kG,{dirty:E,saving:V,saved:K,onSave:z})})]})}var Gx="Progress",Yx=100,[SG]=Us(Gx),[CG,TG]=SG(Gx),SR=x.forwardRef((t,e)=>{const{__scopeProgress:n,value:r=null,max:i,getValueLabel:s=NG,...a}=t;(i||i===0)&&!yT(i)&&console.error(EG(`${i}`,"Progress"));const c=yT(i)?i:Yx;r!==null&&!xT(r,c)&&console.error(jG(`${r}`,"Progress"));const h=xT(r,c)?r:null,d=sp(h)?s(h,c):void 0;return o.jsx(CG,{scope:n,value:h,max:c,children:o.jsx(_t.div,{"aria-valuemax":c,"aria-valuemin":0,"aria-valuenow":sp(h)?h:void 0,"aria-valuetext":d,role:"progressbar","data-state":NR(h,c),"data-value":h??void 0,"data-max":c,...a,ref:e})})});SR.displayName=Gx;var CR="ProgressIndicator",TR=x.forwardRef((t,e)=>{const{__scopeProgress:n,...r}=t,i=TG(CR,n);return o.jsx(_t.div,{"data-state":NR(i.value,i.max),"data-value":i.value??void 0,"data-max":i.max,...r,ref:e})});TR.displayName=CR;function NG(t,e){return`${Math.round(t/e*100)}%`}function NR(t,e){return t==null?"indeterminate":t===e?"complete":"loading"}function sp(t){return typeof t=="number"}function yT(t){return sp(t)&&!isNaN(t)&&t>0}function xT(t,e){return sp(t)&&!isNaN(t)&&t<=e&&t>=0}function EG(t,e){return`Invalid prop \`max\` of value \`${t}\` supplied to \`${e}\`. Only numbers greater than 0 are valid max values. Defaulting to \`${Yx}\`.`}function jG(t,e){return`Invalid prop \`value\` of value \`${t}\` supplied to \`${e}\`. The \`value\` prop must be:
563
+ - a positive number
564
+ - less than the value passed to \`max\` (or ${Yx} if no \`max\` prop is set)
565
+ - \`null\` or \`undefined\` if the progress is indeterminate.
566
+
567
+ Defaulting to \`null\`.`}var PG=SR,_G=TR;function RG({className:t,value:e,indicatorClassName:n,...r}){return o.jsx(PG,{"data-slot":"progress",className:St("bg-primary/20 relative h-2 w-full overflow-hidden rounded-full",t),...r,children:o.jsx(_G,{"data-slot":"progress-indicator",className:St("bg-primary h-full w-full flex-1 transition-all",n),style:{transform:`translateX(-${100-(e||0)}%)`}})})}function IG(){const[t,e]=x.useState(null),[n,r]=x.useState(!0),i=async()=>{try{const c=await we("/api/costs/today");c.ok&&e(await c.json())}catch(c){console.error("Failed to fetch cost data",c)}finally{r(!1)}};if(x.useEffect(()=>{i()},[]),n||!t)return o.jsx("div",{className:"flex items-center justify-center h-full",children:o.jsx($t,{className:"w-8 h-8 text-[#00d9ff] animate-spin"})});const s=t.totalCost/(t.dailyLimit||1)*100,a=s>80;return o.jsxs("div",{className:"space-y-6",children:[o.jsxs("div",{children:[o.jsx("h2",{className:"text-3xl font-bold text-white mb-2 uppercase tracking-tighter",children:"Costs"}),o.jsx("p",{className:"text-gray-400 font-mono text-sm tracking-widest",children:"USAGE & SPENDING"})]}),o.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[o.jsxs(rn,{className:"lg:col-span-2 bg-slate-900/50 border-slate-800 backdrop-blur-sm shadow-xl",children:[o.jsx(br,{children:o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx(Rf,{className:"w-6 h-6 text-[#00d9ff]"}),o.jsxs("div",{children:[o.jsx(kr,{className:"text-white uppercase tracking-tight",children:"Daily Spend"}),o.jsx(to,{className:"text-gray-500 font-mono text-[10px] uppercase",children:"CURRENT USAGE VS. LIMIT"})]})]})}),o.jsxs(on,{className:"space-y-8 pt-4",children:[o.jsxs("div",{className:"flex items-end justify-between",children:[o.jsxs("div",{children:[o.jsxs("div",{className:"text-5xl font-bold text-white font-mono tracking-tighter",children:["$",t.totalCost.toFixed(3)]}),o.jsxs("div",{className:"text-[10px] text-gray-500 font-mono uppercase mt-2",children:["Of $",t.dailyLimit.toFixed(2)," configured limit"]})]}),o.jsxs("div",{className:"text-right",children:[o.jsxs(Kt,{variant:"outline",className:a?"bg-[#ff4458]/10 text-[#ff4458] border-[#ff4458]/30 font-mono":"bg-[#00ff88]/10 text-[#00ff88] border-[#00ff88]/30 font-mono",children:[s.toFixed(1),"% CONSUMED"]}),o.jsxs("div",{className:"text-[10px] text-gray-600 font-mono uppercase mt-2",children:["Remaining: $",t.remaining.toFixed(3)]})]})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(RG,{value:s,className:"h-2 bg-slate-800"}),o.jsxs("div",{className:"flex justify-between text-[8px] font-mono text-gray-600 uppercase tracking-widest",children:[o.jsx("span",{children:"0.00"}),o.jsx("span",{children:"Threshold"}),o.jsx("span",{children:t.dailyLimit.toFixed(2)})]})]}),a&&o.jsxs("div",{className:"flex items-center gap-3 p-4 bg-red-500/10 border border-red-500/20 rounded-xl",children:[o.jsx(Zi,{className:"w-5 h-5 text-red-500 flex-shrink-0"}),o.jsx("p",{className:"text-[10px] text-red-400 font-mono uppercase tracking-tight",children:"WARNING: APPROACHING DAILY COST LIMIT. TASKS MAY BE THROTTLED."})]})]})]}),o.jsx("div",{className:"space-y-6"})]})]})}var Jx="Switch",[MG]=Us(Jx),[DG,AG]=MG(Jx),ER=x.forwardRef((t,e)=>{const{__scopeSwitch:n,name:r,checked:i,defaultChecked:s,required:a,disabled:c,value:h="on",onCheckedChange:d,form:f,...p}=t,[g,v]=x.useState(null),k=sn(e,j=>v(j)),w=x.useRef(!1),S=g?f||!!g.closest("form"):!0,[T=!1,C]=xc({prop:i,defaultProp:s,onChange:d});return o.jsxs(DG,{scope:n,checked:T,disabled:c,children:[o.jsx(_t.button,{type:"button",role:"switch","aria-checked":T,"aria-required":a,"data-state":_R(T),"data-disabled":c?"":void 0,disabled:c,value:h,...p,ref:k,onClick:Et(t.onClick,j=>{C(R=>!R),S&&(w.current=j.isPropagationStopped(),w.current||j.stopPropagation())})}),S&&o.jsx(OG,{control:g,bubbles:!w.current,name:r,value:h,checked:T,required:a,disabled:c,form:f,style:{transform:"translateX(-100%)"}})]})});ER.displayName=Jx;var jR="SwitchThumb",PR=x.forwardRef((t,e)=>{const{__scopeSwitch:n,...r}=t,i=AG(jR,n);return o.jsx(_t.span,{"data-state":_R(i.checked),"data-disabled":i.disabled?"":void 0,...r,ref:e})});PR.displayName=jR;var OG=t=>{const{control:e,checked:n,bubbles:r=!0,...i}=t,s=x.useRef(null),a=Y_(n),c=F_(e);return x.useEffect(()=>{const h=s.current,d=window.HTMLInputElement.prototype,p=Object.getOwnPropertyDescriptor(d,"checked").set;if(a!==n&&p){const g=new Event("click",{bubbles:r});p.call(h,n),h.dispatchEvent(g)}},[a,n,r]),o.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:n,...i,tabIndex:-1,ref:s,style:{...t.style,...c,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})};function _R(t){return t?"checked":"unchecked"}var LG=ER,FG=PR;function Pd({className:t,...e}){return o.jsx(LG,{"data-slot":"switch",className:St("peer data-[state=checked]:bg-primary data-[state=unchecked]:bg-switch-background focus-visible:border-ring focus-visible:ring-ring/50 dark:data-[state=unchecked]:bg-input/80 inline-flex h-[1.15rem] w-8 shrink-0 items-center rounded-full border border-transparent transition-all outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",t),...e,children:o.jsx(FG,{"data-slot":"switch-thumb",className:St("bg-card dark:data-[state=unchecked]:bg-card-foreground dark:data-[state=checked]:bg-primary-foreground pointer-events-none block size-4 rounded-full ring-0 transition-transform data-[state=checked]:translate-x-[calc(100%-2px)] data-[state=unchecked]:translate-x-0")})})}var RR={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},bT=Me.createContext&&Me.createContext(RR),UG=["attr","size","title"];function BG(t,e){if(t==null)return{};var n,r,i=zG(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function zG(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}function ap(){return ap=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},ap.apply(null,arguments)}function kT(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function op(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?kT(Object(n),!0).forEach(function(r){$G(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):kT(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function $G(t,e,n){return(e=VG(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function VG(t){var e=WG(t,"string");return typeof e=="symbol"?e:e+""}function WG(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function IR(t){return t&&t.map((e,n)=>Me.createElement(e.tag,op({key:n},e.attr),IR(e.child)))}function Xx(t){return e=>Me.createElement(HG,ap({attr:op({},t.attr)},e),IR(t.child))}function HG(t){var e=n=>{var{attr:r,size:i,title:s}=t,a=BG(t,UG),c=i||n.size||"1em",h;return n.className&&(h=n.className),t.className&&(h=(h?h+" ":"")+t.className),Me.createElement("svg",ap({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},n.attr,r,a,{className:h,style:op(op({color:t.color||n.color},n.style),t.style),height:c,width:c,xmlns:"http://www.w3.org/2000/svg"}),s&&Me.createElement("title",null,s),t.children)};return bT!==void 0?Me.createElement(bT.Consumer,null,n=>e(n)):e(RR)}function qG(t){return Xx({attr:{role:"img",viewBox:"0 0 24 24"},child:[{tag:"path",attr:{d:"M22.2819 9.8211a5.9847 5.9847 0 0 0-.5157-4.9108 6.0462 6.0462 0 0 0-6.5098-2.9A6.0651 6.0651 0 0 0 4.9807 4.1818a5.9847 5.9847 0 0 0-3.9977 2.9 6.0462 6.0462 0 0 0 .7427 7.0966 5.98 5.98 0 0 0 .511 4.9107 6.051 6.051 0 0 0 6.5146 2.9001A5.9847 5.9847 0 0 0 13.2599 24a6.0557 6.0557 0 0 0 5.7718-4.2058 5.9894 5.9894 0 0 0 3.9977-2.9001 6.0557 6.0557 0 0 0-.7475-7.0729zm-9.022 12.6081a4.4755 4.4755 0 0 1-2.8764-1.0408l.1419-.0804 4.7783-2.7582a.7948.7948 0 0 0 .3927-.6813v-6.7369l2.02 1.1686a.071.071 0 0 1 .038.052v5.5826a4.504 4.504 0 0 1-4.4945 4.4944zm-9.6607-4.1254a4.4708 4.4708 0 0 1-.5346-3.0137l.142.0852 4.783 2.7582a.7712.7712 0 0 0 .7806 0l5.8428-3.3685v2.3324a.0804.0804 0 0 1-.0332.0615L9.74 19.9502a4.4992 4.4992 0 0 1-6.1408-1.6464zM2.3408 7.8956a4.485 4.485 0 0 1 2.3655-1.9728V11.6a.7664.7664 0 0 0 .3879.6765l5.8144 3.3543-2.0201 1.1685a.0757.0757 0 0 1-.071 0l-4.8303-2.7865A4.504 4.504 0 0 1 2.3408 7.872zm16.5963 3.8558L13.1038 8.364 15.1192 7.2a.0757.0757 0 0 1 .071 0l4.8303 2.7913a4.4944 4.4944 0 0 1-.6765 8.1042v-5.6772a.79.79 0 0 0-.407-.667zm2.0107-3.0231l-.142-.0852-4.7735-2.7818a.7759.7759 0 0 0-.7854 0L9.409 9.2297V6.8974a.0662.0662 0 0 1 .0284-.0615l4.8303-2.7866a4.4992 4.4992 0 0 1 6.6802 4.66zM8.3065 12.863l-2.02-1.1638a.0804.0804 0 0 1-.038-.0567V6.0742a4.4992 4.4992 0 0 1 7.3757-3.4537l-.142.0805L8.704 5.459a.7948.7948 0 0 0-.3927.6813zm1.0976-2.3654l2.602-1.4998 2.6069 1.4998v2.9994l-2.5974 1.4997-2.6067-1.4997Z"},child:[]}]})(t)}function wT(t){return Xx({attr:{role:"img",viewBox:"0 0 24 24"},child:[{tag:"path",attr:{d:"M11.04 19.32Q12 21.51 12 24q0-2.49.93-4.68.96-2.19 2.58-3.81t3.81-2.55Q21.51 12 24 12q-2.49 0-4.68-.93a12.3 12.3 0 0 1-3.81-2.58 12.3 12.3 0 0 1-2.58-3.81Q12 2.49 12 0q0 2.49-.96 4.68-.93 2.19-2.55 3.81a12.3 12.3 0 0 1-3.81 2.58Q2.49 12 0 12q2.49 0 4.68.96 2.19.93 3.81 2.55t2.55 3.81"},child:[]}]})(t)}function KG(t){return Xx({attr:{role:"img",viewBox:"0 0 24 24"},child:[{tag:"path",attr:{d:"M17.3041 3.541h-3.6718l6.696 16.918H24Zm-10.6082 0L0 20.459h3.7442l1.3693-3.5527h7.0052l1.3693 3.5528h3.7442L10.5363 3.5409Zm-.3712 10.2232 2.2914-5.9456 2.2914 5.9456Z"},child:[]}]})(t)}const GG=({className:t=""})=>o.jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor",className:t,children:o.jsx("path",{d:"M16.778 1.844v1.919q-.569-.026-1.138-.032-.708-.008-1.415.037c-1.93.126-4.023.728-6.149 2.237-2.911 2.066-2.731 1.95-4.14 2.75-.396.223-1.342.574-2.185.798-.841.225-1.753.333-1.751.333v4.229s.768.108 1.61.333c.842.224 1.789.575 2.185.799 1.41.798 1.228.683 4.14 2.75 2.126 1.509 4.22 2.11 6.148 2.236.88.058 1.716.041 2.555.005v1.918l7.222-4.168-7.222-4.17v2.176c-.86.038-1.611.065-2.278.021-1.364-.09-2.417-.357-3.979-1.465-2.244-1.593-2.866-2.027-3.68-2.508.889-.518 1.449-.906 3.822-2.59 1.56-1.109 2.614-1.377 3.978-1.466.667-.044 1.418-.017 2.278.02v2.176L24 6.014Z"})});function Ha({icon:t,title:e,subtitle:n,badge:r,defaultOpen:i=!1,actions:s,children:a}){const[c,h]=x.useState(i),d=x.useRef(null),[f,p]=x.useState(i?void 0:0);return x.useEffect(()=>{if(d.current)if(c){p(d.current.scrollHeight);const g=setTimeout(()=>p(void 0),350);return()=>clearTimeout(g)}else p(d.current.scrollHeight),requestAnimationFrame(()=>p(0))},[c]),o.jsxs("div",{className:`bg-slate-900/50 border border-slate-800 rounded-2xl backdrop-blur-sm shadow-xl transition-all duration-300 hover:border-slate-700/80 ${c?"relative z-20":""}`,children:[o.jsxs("button",{onClick:()=>h(!c),className:"w-full flex items-center justify-between px-6 py-5 group cursor-pointer",children:[o.jsxs("div",{className:"flex items-center gap-4",children:[o.jsx("div",{className:"w-10 h-10 rounded-xl bg-[#00d9ff]/10 border border-[#00d9ff]/20 flex items-center justify-center group-hover:bg-[#00d9ff]/15 transition-colors",children:o.jsx(t,{className:"w-5 h-5 text-[#00d9ff]"})}),o.jsxs("div",{className:"text-left",children:[o.jsxs("div",{className:"flex items-center gap-2.5",children:[o.jsx("span",{className:"text-white font-semibold text-[15px] uppercase tracking-tight",children:e}),r]}),n&&o.jsx("p",{className:"text-[11px] font-mono text-gray-500 mt-0.5",children:n})]})]}),o.jsxs("div",{className:"flex items-center gap-3",children:[c&&s&&o.jsx("div",{onClick:g=>g.stopPropagation(),children:s}),o.jsx(fo,{className:`w-5 h-5 text-gray-500 transition-transform duration-300 ${c?"rotate-180":""}`})]})]}),o.jsx("div",{ref:d,style:{height:f!==void 0?`${f}px`:"auto"},className:`transition-[height] duration-350 ease-in-out ${f!==void 0?"overflow-hidden":"overflow-visible"}`,children:o.jsx("div",{className:"px-6 pb-6 pt-1",children:a})})]})}function ST({value:t,onChange:e,modelsByProvider:n}){const[r,i]=x.useState(!1),[s,a]=x.useState(""),[c,h]=x.useState("configured"),d=x.useRef(null),f=x.useRef(null);x.useEffect(()=>{const T=C=>{d.current&&!d.current.contains(C.target)&&i(!1)};return document.addEventListener("mousedown",T),()=>document.removeEventListener("mousedown",T)},[]);const p=s.toLowerCase(),g={};for(const[T,C]of Object.entries(n)){const j=C.filter(R=>{const _=R.id.toLowerCase().includes(p)||T.toLowerCase().includes(p),I=c==="all"||R.available!==!1;return _&&I});j.length>0&&(g[T]=j)}const v=Object.values(n).flat().filter(T=>T.available!==!1).length,k=Object.values(n).flat().length,w=t?t.split(":")[1]||t:"Same as main agent (default)",S=T=>T?T==="cheap"||T==="free"?"text-[#00ff88]":T==="expensive"?"text-amber-400":"text-gray-400":"text-gray-500";return o.jsxs("div",{ref:d,className:"relative",children:[o.jsxs("button",{type:"button",onClick:()=>{i(!r),r||setTimeout(()=>{var T;return(T=f.current)==null?void 0:T.focus()},50)},className:"w-full bg-slate-950/60 border border-slate-700/50 rounded-xl px-4 py-3 text-sm font-mono text-left flex items-center justify-between hover:border-slate-600/60 focus:border-[#00d9ff]/50 focus:outline-none focus:ring-1 focus:ring-[#00d9ff]/20 transition-colors",children:[o.jsx("span",{className:t?"text-white":"text-gray-500",children:w}),o.jsx(fo,{className:`w-4 h-4 text-gray-500 transition-transform duration-200 ${r?"rotate-180":""}`})]}),r&&o.jsxs("div",{className:"absolute z-50 top-full mt-1.5 w-full bg-slate-950 border border-slate-700/60 rounded-xl shadow-2xl shadow-black/50 overflow-hidden",children:[o.jsxs("div",{className:"flex items-center gap-2.5 px-4 py-3 border-b border-slate-800/60",children:[o.jsx(Wo,{className:"w-4 h-4 text-gray-500 shrink-0"}),o.jsx("input",{ref:f,value:s,onChange:T=>a(T.target.value),placeholder:"Search models...",className:"w-full bg-transparent text-sm font-mono text-white placeholder-gray-600 outline-none"}),s&&o.jsx("button",{onClick:()=>a(""),className:"text-gray-500 hover:text-gray-300",children:o.jsx(ol,{className:"w-3.5 h-3.5"})})]}),o.jsxs("div",{className:"flex gap-1 px-3 py-2 border-b border-slate-800/60",children:[o.jsxs("button",{onClick:()=>h("configured"),className:`px-3 py-1.5 rounded-lg text-[10px] font-mono uppercase tracking-wider transition-colors ${c==="configured"?"bg-[#00ff88]/10 text-[#00ff88] border border-[#00ff88]/20":"text-gray-500 hover:text-gray-300"}`,children:["Configured (",v,")"]}),o.jsxs("button",{onClick:()=>h("all"),className:`px-3 py-1.5 rounded-lg text-[10px] font-mono uppercase tracking-wider transition-colors ${c==="all"?"bg-[#00d9ff]/10 text-[#00d9ff] border border-[#00d9ff]/20":"text-gray-500 hover:text-gray-300"}`,children:["All (",k,")"]})]}),o.jsxs("div",{className:"max-h-[280px] overflow-y-auto overscroll-contain",children:[o.jsxs("button",{onClick:()=>{e(""),i(!1),a("")},className:`w-full flex items-center gap-3 px-4 py-3 text-sm font-mono text-left hover:bg-slate-800/50 transition-colors ${t?"text-gray-400":"text-[#00d9ff]"}`,children:[t?o.jsx("div",{className:"w-4"}):o.jsx(nd,{className:"w-4 h-4 text-[#00d9ff] shrink-0"}),"Same as main agent (default)"]}),Object.keys(g).length===0?o.jsxs("div",{className:"px-4 py-6 text-center text-gray-600 font-mono text-xs",children:['No models match "',s,'"']}):Object.entries(g).map(([T,C])=>o.jsxs("div",{children:[o.jsx("div",{className:"px-4 py-2 text-[10px] font-mono text-gray-500 uppercase tracking-widest bg-slate-900/80 sticky top-0 border-t border-slate-800/40",children:T}),C.map(j=>{const R=j.id===t,_=j.id.split(":")[1]||j.id,I=j.available!==!1;return o.jsxs("button",{onClick:()=>{e(j.id),i(!1),a("")},className:`w-full flex items-center gap-3 px-4 py-2.5 text-sm font-mono text-left hover:bg-slate-800/50 transition-colors ${R?"text-[#00d9ff] bg-[#00d9ff]/5":I?"text-gray-300":"text-gray-600"}`,children:[R?o.jsx(nd,{className:"w-4 h-4 text-[#00d9ff] shrink-0"}):o.jsx("div",{className:"w-4"}),o.jsx("span",{className:"flex-1 truncate",children:_}),!I&&o.jsx("span",{className:"text-[8px] uppercase tracking-wider text-gray-600 border border-slate-800 px-1.5 py-0.5 rounded",children:"no key"}),j.tier&&o.jsx("span",{className:`text-[9px] uppercase tracking-wider ${S(j.tier)}`,children:j.tier})]},j.id)})]},T))]})]})]})}function Uo({dirty:t,saving:e,saved:n,onSave:r}){return o.jsxs("button",{onClick:r,disabled:!t||e,className:`flex items-center gap-1.5 px-3.5 py-2 rounded-lg text-[10px] font-mono uppercase tracking-wider transition-all ${t?"bg-[#00d9ff]/15 text-[#00d9ff] border border-[#00d9ff]/40 hover:bg-[#00d9ff]/25 cursor-pointer shadow-[0_0_12px_rgba(0,217,255,0.1)]":n?"bg-[#00ff88]/10 text-[#00ff88] border border-[#00ff88]/30":"bg-slate-800/50 text-gray-600 border border-slate-700/50 cursor-not-allowed"}`,children:[e?o.jsx($t,{className:"w-3.5 h-3.5 animate-spin"}):n?o.jsx(ky,{className:"w-3.5 h-3.5"}):o.jsx(rd,{className:"w-3.5 h-3.5"}),e?"Saving...":n?"Saved":"Save"]})}function L0({label:t,description:e,checked:n,onChange:r}){return o.jsxs("div",{className:"flex items-start justify-between gap-4 p-3 bg-slate-800/20 rounded-xl border border-slate-800/40",children:[o.jsxs("div",{className:"flex-1",children:[o.jsx("div",{className:"text-sm font-mono text-white",children:t}),o.jsx("div",{className:"text-[11px] text-gray-500 mt-0.5 leading-relaxed",children:e})]}),o.jsx(Pd,{checked:n,onCheckedChange:r})]})}function CT(){const[t,e]=x.useState(null),[n,r]=x.useState(!0),[i,s]=x.useState({}),[a,c]=x.useState(new Set),[h,d]=x.useState(null),[f,p]=x.useState(!1);async function g(){if(!h)return;const{key:ce,name:be}=h;p(!0);try{const We=await we(`/api/settings/${ce}`,{method:"DELETE"});if(We.ok){const Ct=await we("/api/settings").then(ut=>ut.json());e(Ct),toast.success(`${be} key deleted`),d(null)}else{const Ct=await We.text().catch(()=>"");toast.error(`Failed to delete ${be} key${Ct?": "+Ct.slice(0,80):""}`)}}catch(We){toast.error(`Delete failed: ${(We==null?void 0:We.message)||We}`)}finally{p(!1)}}const[v,k]=x.useState(!1),[w,S]=x.useState(!1),[T,C]=x.useState(!1),[j,R]=x.useState({subAgentModel:""}),[_,I]=x.useState(!1),[M,L]=x.useState(!1),[$,E]=x.useState(!1),[P,V]=x.useState([]),[F,K]=x.useState(!1),[J,Q]=x.useState({name:"",description:"",triggers:"",content:""}),[Z,D]=x.useState(!1),[ne,A]=x.useState(""),[z,ee]=x.useState(!1),[B,X]=x.useState(!1),[ye,se]=x.useState(!1),[oe,U]=x.useState([]),[ue,ke]=x.useState([]),[W,q]=x.useState({}),[fe,ve]=x.useState(!1),[Se,Ke]=x.useState(!1),[dt,Ge]=x.useState(!1),[_e,Ve]=x.useState({exists:!1,unlocked:!1}),[xt,Pt]=x.useState(""),[mn,gn]=x.useState(!1),[jn,xe]=x.useState(""),[Re,Qe]=x.useState({stt:[],tts:[],image:[],video:[]});x.useEffect(()=>{Promise.all([we("/api/settings").then(ce=>ce.json()),we("/api/profile").then(ce=>ce.json()),Promise.resolve({skills:[]}),we("/api/memory").then(ce=>ce.json()),we("/api/models").then(ce=>ce.json()),we("/api/vault/status").then(ce=>ce.json()),we("/api/config").then(ce=>ce.json()),we("/api/models/all").then(ce=>ce.json()).catch(()=>({models:[]})),we("/api/voice/providers").then(ce=>ce.json()).catch(()=>({stt:[],tts:[],image:[],video:[]}))]).then(([ce,be,We,Ct,ut,Yt,kt,Bt,ln])=>{Qe({stt:(ln==null?void 0:ln.stt)??[],tts:(ln==null?void 0:ln.tts)??[],image:(ln==null?void 0:ln.image)??[],video:(ln==null?void 0:ln.video)??[]}),e(ce);const Y=(ce==null?void 0:ce.vars)??{},re={...kt||{}},de={defaultModel:"DEFAULT_MODEL",permissionTier:"PERMISSION_TIER",maxCostPerTask:"MAX_COST_PER_TASK",maxDailyCost:"MAX_DAILY_COST",sttProvider:"DAEMORA_STT_PROVIDER",sttModel:"STT_MODEL",ttsProvider:"DAEMORA_TTS_PROVIDER",ttsModel:"TTS_MODEL",ttsVoice:"TTS_VOICE",ttsGroqModel:"TTS_GROQ_MODEL",meetingLlm:"MEETING_LLM",ollamaBaseUrl:"OLLAMA_BASE_URL",imageGenModel:"IMAGE_GEN_MODEL",videoGenModel:"VIDEO_GEN_MODEL",wakeWord:"WAKE_WORD",heartbeatIntervalMinutes:"HEARTBEAT_INTERVAL_MINUTES"};for(const[Ae,Je]of Object.entries(de))Y[Je]!=null&&Y[Je]!==""&&(re[Ae]=Y[Je]);const Ce={heartbeatEnabled:"HEARTBEAT_ENABLED",wakeWordEnabled:"WAKE_WORD_ENABLED",authEnabled:"AUTH_ENABLED"};for(const[Ae,Je]of Object.entries(Ce)){const lt=Y[Je];lt!=null&&(re[Ae]=lt==="true"||lt===!0)}q(re),R({subAgentModel:be.subAgentModel||""}),V(We.skills||[]),A(Ct.content||""),U(ut.available||[]),ke(Bt.models||[]),Ve(Yt),r(!1)}).catch(()=>r(!1))},[]);const He=(ce,be)=>{q(We=>({...We,[ce]:be})),ve(!0),Ge(!1)},gt=(ce,be)=>{const[We,...Ct]=be.split("|"),ut=Ct.join("|");q(Yt=>{const kt={...Yt};return ce==="stt"?(kt.sttProvider=We??"",kt.sttModel=ut??""):(We!==Yt.ttsProvider&&(kt.ttsVoice=""),kt.ttsProvider=We??"",kt.ttsModel=ut??""),kt}),ve(!0),Ge(!1)},hn=async()=>{Ke(!0);try{const ce={defaultModel:"DEFAULT_MODEL",permissionTier:"PERMISSION_TIER",maxCostPerTask:"MAX_COST_PER_TASK",maxDailyCost:"MAX_DAILY_COST",sttProvider:"DAEMORA_STT_PROVIDER",sttModel:"STT_MODEL",ttsProvider:"DAEMORA_TTS_PROVIDER",ttsModel:"TTS_MODEL",ttsVoice:"TTS_VOICE",ttsGroqModel:"TTS_GROQ_MODEL",meetingLlm:"MEETING_LLM",ollamaBaseUrl:"OLLAMA_BASE_URL",imageGenModel:"IMAGE_GEN_MODEL",videoGenModel:"VIDEO_GEN_MODEL",wakeWord:"WAKE_WORD",heartbeatIntervalMinutes:"HEARTBEAT_INTERVAL_MINUTES",heartbeatEnabled:"HEARTBEAT_ENABLED",wakeWordEnabled:"WAKE_WORD_ENABLED",authEnabled:"AUTH_ENABLED"},be={};for(const[Ct,ut]of Object.entries(ce))W[Ct]!==void 0&&(be[ut]=String(W[Ct]));if((await we("/api/settings",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({updates:be})})).ok){Ge(!0),ve(!1);const[Ct,ut]=await Promise.all([we("/api/config").then(Bt=>Bt.json()),we("/api/settings").then(Bt=>Bt.json())]),Yt=(ut==null?void 0:ut.vars)??{},kt={...Ct||{}};for(const[Bt,ln]of Object.entries(ce))Yt[ln]!=null&&Yt[ln]!==""&&(kt[Bt]=Yt[ln]);for(const Bt of["heartbeatEnabled","wakeWordEnabled","authEnabled"])typeof kt[Bt]=="string"&&(kt[Bt]=kt[Bt]==="true");q(kt)}}catch{}finally{Ke(!1)}},vn=async()=>{if(xt){gn(!0),xe("");try{const ce=await we("/auth/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({passphrase:xt})});if(ce.ok){sessionStorage.setItem("daemora_vault_pass",xt),Ve({exists:!0,unlocked:!0}),Pt("");const be=await we("/api/settings").then(We=>We.json());e(be)}else{const be=await ce.json().catch(()=>({}));xe(be.error||"Failed to unlock vault")}}catch{xe("Connection error")}finally{gn(!1)}}},Fn=async()=>{await we("/api/vault/lock",{method:"POST"}),sessionStorage.removeItem("daemora_vault_pass"),Ve({exists:!0,unlocked:!1});const ce=await we("/api/settings").then(be=>be.json());e(ce)},pe=ce=>{c(be=>{const We=new Set(be);return We.has(ce)?We.delete(ce):We.add(ce),We})},Ue=(ce,be)=>{s(We=>({...We,[ce]:be})),C(!0),S(!1)},ze=async()=>{const ce={};for(const[be,We]of Object.entries(i))We!==void 0&&We!==""&&(ce[be]=We);if(Object.keys(ce).length!==0){k(!0);try{if((await we("/api/settings",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({updates:ce})})).ok){S(!0),C(!1);const We=await we("/api/settings").then(Ct=>Ct.json());e(We),s({})}}catch{}finally{k(!1)}}},Wt=(ce,be)=>{R(We=>({...We,[ce]:be})),I(!0),E(!1)},bt=async()=>{L(!0);try{(await we("/api/profile",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(j)})).ok&&(E(!0),I(!1))}catch{}finally{L(!1)}},Tn=async()=>{X(!0);try{(await we("/api/memory",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:ne})})).ok&&(se(!0),ee(!1))}catch{}finally{X(!1)}};if(n)return o.jsx("div",{className:"flex items-center justify-center h-full",children:o.jsx($t,{className:"w-8 h-8 text-[#00d9ff] animate-spin"})});if(!t)return o.jsx("div",{className:"text-center py-12",children:o.jsx("p",{className:"text-red-400 font-mono",children:"ERROR: COULD NOT LOAD SETTINGS"})});const nn={},Kn=ue.length>0?ue:oe.map(ce=>({...ce,available:!0}));for(const ce of Kn){const be=ce.provider||"other";nn[be]||(nn[be]=[]),nn[be].push(ce)}const Mn="w-full bg-slate-950/60 border border-slate-700/50 rounded-xl px-4 py-3 text-sm font-mono text-white placeholder-gray-600 focus:border-[#00d9ff]/50 focus:outline-none focus:ring-1 focus:ring-[#00d9ff]/20 transition-colors";return o.jsxs("div",{className:"space-y-5 pb-10",children:[o.jsxs("div",{className:"mb-8 flex items-end justify-between gap-4",children:[o.jsxs("div",{children:[o.jsx("h2",{className:"text-3xl font-bold text-white mb-2 uppercase tracking-tighter",children:"Settings"}),o.jsx("p",{className:"text-gray-500 font-mono text-xs tracking-widest uppercase",children:"Configure your agent's identity, skills, memory & environment"})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("a",{href:"/setup?force=1",className:"px-3 py-1.5 text-[11px] font-mono uppercase tracking-wider text-[#38bdf8] hover:text-white border border-[#38bdf8]/30 hover:border-[#38bdf8] rounded-lg transition-colors",title:"Re-run the onboarding wizard",children:"Re-run Setup"}),o.jsx("button",{onClick:async()=>{const ce=`${window.location.origin}/setup`;try{await navigator.clipboard.writeText(ce),toast.success("Setup URL copied")}catch{toast.error("Couldn't copy — open "+ce)}},className:"px-3 py-1.5 text-[11px] font-mono uppercase tracking-wider text-gray-400 hover:text-white border border-slate-700 hover:border-slate-500 rounded-lg transition-colors",title:"Copy a link teammates can open in their browser to configure Daemora on this machine",children:"Share Setup Link"})]})]}),o.jsx(Ha,{icon:Ja,title:"Global Config",subtitle:"Core agent settings - model, permissions, cost limits",defaultOpen:!0,actions:o.jsx(Uo,{dirty:fe,saving:Se,saved:dt,onSave:hn}),children:o.jsxs("div",{className:"space-y-5",children:[o.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[o.jsxs("div",{children:[o.jsx("label",{className:"text-[11px] font-mono text-gray-400 uppercase mb-2 block tracking-wider",children:"Default Model"}),o.jsx(ST,{value:W.defaultModel||"",onChange:ce=>He("defaultModel",ce),modelsByProvider:nn})]}),o.jsxs("div",{children:[o.jsx("label",{className:"text-[11px] font-mono text-gray-400 uppercase mb-2 block tracking-wider",children:"Permission Tier"}),o.jsxs(Qt,{value:W.permissionTier||"standard",onValueChange:ce=>He("permissionTier",ce),children:[o.jsx(en,{className:"w-full bg-slate-950/60 border border-slate-700/50 rounded-xl px-4 py-3 text-sm font-mono text-white",children:o.jsx(Zt,{})}),o.jsxs(tn,{className:"bg-slate-950 border-slate-800 text-white",children:[o.jsx(st,{value:"minimal",className:"text-xs font-mono",children:"MINIMAL - read-only tools, no shell"}),o.jsx(st,{value:"standard",className:"text-xs font-mono",children:"STANDARD - most tools, guarded shell"}),o.jsx(st,{value:"full",className:"text-xs font-mono",children:"FULL - all tools, unrestricted"})]})]})]})]}),o.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[o.jsxs("div",{children:[o.jsx("label",{className:"text-[11px] font-mono text-gray-400 uppercase mb-2 block tracking-wider",children:"Transcription Model (STT)"}),o.jsxs("select",{className:"w-full bg-slate-950/60 border border-slate-700/50 rounded-xl px-4 py-3 text-sm font-mono text-white focus:border-[#00d9ff]/50 focus:outline-none appearance-none cursor-pointer",value:W.sttProvider&&W.sttModel?`${W.sttProvider}|${W.sttModel}`:"",onChange:ce=>gt("stt",ce.target.value),children:[o.jsx("option",{value:"",children:"Auto (detect from API key)"}),Re.stt.filter(ce=>ce.configured&&ce.models.length>0).map(ce=>o.jsx("optgroup",{label:ce.name,children:ce.models.map(be=>o.jsx("option",{value:`${ce.id}|${be.id}`,children:be.name},`${ce.id}|${be.id}`))},ce.id))]})]}),o.jsxs("div",{children:[o.jsx("label",{className:"text-[11px] font-mono text-gray-400 uppercase mb-2 block tracking-wider",children:"Speech Model (TTS)"}),o.jsxs("select",{className:"w-full bg-slate-950/60 border border-slate-700/50 rounded-xl px-4 py-3 text-sm font-mono text-white focus:border-[#00d9ff]/50 focus:outline-none appearance-none cursor-pointer",value:W.ttsProvider&&W.ttsModel?`${W.ttsProvider}|${W.ttsModel}`:"",onChange:ce=>gt("tts",ce.target.value),children:[o.jsx("option",{value:"",children:"Auto (detect from API key)"}),Re.tts.filter(ce=>ce.configured&&ce.models.length>0).map(ce=>o.jsx("optgroup",{label:ce.name,children:ce.models.map(be=>o.jsx("option",{value:`${ce.id}|${be.id}`,children:be.name},`${ce.id}|${be.id}`))},ce.id))]})]})]}),o.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[o.jsxs("div",{children:[o.jsx("label",{className:"text-[11px] font-mono text-gray-400 uppercase mb-2 block tracking-wider",children:"TTS Voice"}),o.jsxs("select",{className:"w-full bg-slate-950/60 border border-slate-700/50 rounded-xl px-4 py-3 text-sm font-mono text-white focus:border-[#00d9ff]/50 focus:outline-none appearance-none cursor-pointer",value:W.ttsVoice||"",onChange:ce=>He("ttsVoice",ce.target.value),disabled:!W.ttsProvider,children:[o.jsx("option",{value:"",children:W.ttsProvider?"Auto (provider default)":"Select a TTS model first"}),(()=>{const ce=Re.tts.find(be=>be.id===W.ttsProvider);return ce?ce.voices.map(be=>o.jsxs("option",{value:be.id,children:[be.name,be.gender?` — ${be.gender}`:""]},be.id)):null})()]})]}),o.jsxs("div",{children:[o.jsx("label",{className:"text-[11px] font-mono text-gray-400 uppercase mb-2 block tracking-wider",children:"Meeting LLM"}),o.jsxs("div",{className:"relative",children:[o.jsx("input",{type:"text",list:"meeting-llm-models",className:"w-full bg-slate-950/60 border border-slate-700/50 rounded-xl px-4 py-3 text-sm font-mono text-white placeholder-gray-600 focus:border-[#00d9ff]/50 focus:outline-none",placeholder:"auto (best available)",value:W.meetingLlm||"",onChange:ce=>He("meetingLlm",ce.target.value)}),o.jsxs("datalist",{id:"meeting-llm-models",children:[o.jsx("option",{value:"openai:gpt-4o-mini",children:"gpt-4o-mini - fast, cheap"}),o.jsx("option",{value:"groq:llama-3.3-70b-versatile",children:"groq llama-3.3-70b - fast free"}),o.jsx("option",{value:"anthropic:claude-haiku-4-5-20251001",children:"claude haiku - fast"}),o.jsx("option",{value:"ollama:llama3.2",children:"ollama llama3.2 - local"})]})]})]})]}),o.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[o.jsxs("div",{children:[o.jsx("label",{className:"text-[11px] font-mono text-gray-400 uppercase mb-2 block tracking-wider",children:"Image Generation Model"}),o.jsxs("select",{className:"w-full bg-slate-950/60 border border-slate-700/50 rounded-xl px-4 py-3 text-sm font-mono text-white focus:border-[#00d9ff]/50 focus:outline-none appearance-none cursor-pointer",value:W.imageGenModel||"",onChange:ce=>He("imageGenModel",ce.target.value),children:[o.jsx("option",{value:"",children:"Auto (first configured provider)"}),Re.image.filter(ce=>ce.configured&&ce.models.length>0).map(ce=>o.jsx("optgroup",{label:ce.name,children:ce.models.map(be=>o.jsx("option",{value:`${ce.id}:${be.id}`,children:be.name},`${ce.id}:${be.id}`))},ce.id))]})]}),o.jsxs("div",{children:[o.jsx("label",{className:"text-[11px] font-mono text-gray-400 uppercase mb-2 block tracking-wider",children:"Video Generation Model"}),o.jsxs("select",{className:"w-full bg-slate-950/60 border border-slate-700/50 rounded-xl px-4 py-3 text-sm font-mono text-white focus:border-[#00d9ff]/50 focus:outline-none appearance-none cursor-pointer",value:W.videoGenModel||"",onChange:ce=>He("videoGenModel",ce.target.value),children:[o.jsx("option",{value:"",children:"Auto (first configured provider)"}),Re.video.filter(ce=>ce.configured&&ce.models.length>0).map(ce=>o.jsx("optgroup",{label:ce.name,children:ce.models.map(be=>o.jsx("option",{value:`${ce.id}:${be.id}`,children:be.name},`${ce.id}:${be.id}`))},ce.id))]})]})]}),o.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:o.jsxs("div",{children:[o.jsx("label",{className:"text-[11px] font-mono text-gray-400 uppercase mb-2 block tracking-wider",children:"Ollama Base URL"}),o.jsx("input",{type:"text",className:"w-full bg-slate-950/60 border border-slate-700/50 rounded-xl px-4 py-3 text-sm font-mono text-white placeholder-gray-600 focus:border-[#00d9ff]/50 focus:outline-none",placeholder:"http://localhost:11434/v1",value:W.ollamaBaseUrl||"",onChange:ce=>He("ollamaBaseUrl",ce.target.value)})]})}),o.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[o.jsxs("div",{children:[o.jsxs("label",{className:"text-[11px] font-mono text-gray-400 uppercase mb-2 block tracking-wider flex items-center gap-1.5",children:[o.jsx(Rf,{className:"w-3.5 h-3.5"})," Max Cost / Task"]}),o.jsx("input",{type:"number",step:"0.01",className:Mn,placeholder:"e.g. 0.50",value:W.maxCostPerTask??"",onChange:ce=>He("maxCostPerTask",ce.target.value)})]}),o.jsxs("div",{children:[o.jsxs("label",{className:"text-[11px] font-mono text-gray-400 uppercase mb-2 block tracking-wider flex items-center gap-1.5",children:[o.jsx(Rf,{className:"w-3.5 h-3.5"})," Max Daily Cost"]}),o.jsx("input",{type:"number",step:"0.01",className:Mn,placeholder:"e.g. 10.00",value:W.maxDailyCost??"",onChange:ce=>He("maxDailyCost",ce.target.value)})]})]}),W.daemonMode!==void 0&&o.jsxs("div",{className:"flex items-center gap-3 p-3 bg-slate-800/20 rounded-xl border border-slate-800/40",children:[o.jsx("span",{className:`w-2 h-2 rounded-full ${W.daemonMode?"bg-[#00ff88]":"bg-gray-600"}`}),o.jsxs("span",{className:"text-[11px] font-mono text-gray-400",children:["Daemon Mode: ",o.jsx("span",{className:W.daemonMode?"text-[#00ff88]":"text-gray-500",children:W.daemonMode?"ACTIVE":"OFF"})]})]})]})}),o.jsx(Ha,{icon:ha,title:"Behaviour",subtitle:"Background loops, wake-word listener, sign-in gating",defaultOpen:!1,actions:o.jsx(Uo,{dirty:fe,saving:Se,saved:dt,onSave:hn}),children:o.jsxs("div",{className:"space-y-4",children:[o.jsx(L0,{label:"Heartbeat (proactive check)",description:"Periodic loop that lets the agent decide if any task needs doing on its own. Off = no autonomous wakes.",checked:!!W.heartbeatEnabled,onChange:ce=>He("heartbeatEnabled",ce)}),W.heartbeatEnabled?o.jsxs("div",{className:"ml-1",children:[o.jsx("label",{className:"text-[11px] font-mono text-gray-400 uppercase mb-2 block tracking-wider",children:"Heartbeat interval (minutes)"}),o.jsx("input",{type:"number",min:0,step:1,className:Mn,placeholder:"240",value:W.heartbeatIntervalMinutes??"",onChange:ce=>He("heartbeatIntervalMinutes",ce.target.value)})]}):null,o.jsx(L0,{label:"Wake word listener",description:"Always-on mic that activates voice mode when it hears the trigger phrase.",checked:!!W.wakeWordEnabled,onChange:ce=>He("wakeWordEnabled",ce)}),W.wakeWordEnabled?o.jsxs("div",{className:"ml-1",children:[o.jsx("label",{className:"text-[11px] font-mono text-gray-400 uppercase mb-2 block tracking-wider",children:"Wake word"}),o.jsx("input",{type:"text",className:Mn,placeholder:"hey_jarvis",value:W.wakeWord??"",onChange:ce=>He("wakeWord",ce.target.value)})]}):null,o.jsx(L0,{label:"Require sign-in",description:"When on, /api/* requires a passphrase login. Loopback scripts still work via the local auth-token file.",checked:!!W.authEnabled,onChange:ce=>He("authEnabled",ce)})]})}),o.jsx(Ha,{icon:_e.unlocked?w1:zu,title:"Secret Vault",subtitle:"Encrypted storage for API keys & tokens (AES-256-GCM)",badge:_e.unlocked?o.jsxs("span",{className:"text-[9px] font-mono text-[#00ff88] bg-[#00ff88]/10 px-2 py-0.5 rounded-md border border-[#00ff88]/20 flex items-center gap-1",children:[o.jsx(Z0,{className:"w-2.5 h-2.5"})," unlocked"]}):_e.exists?o.jsxs("span",{className:"text-[9px] font-mono text-amber-400 bg-amber-400/10 px-2 py-0.5 rounded-md border border-amber-400/20 flex items-center gap-1",children:[o.jsx(If,{className:"w-2.5 h-2.5"})," locked"]}):null,defaultOpen:!_e.unlocked&&_e.exists,children:_e.unlocked?o.jsxs("div",{className:"flex items-center gap-4 p-4 bg-[#00ff88]/5 rounded-xl border border-[#00ff88]/20",children:[o.jsx(w1,{className:"w-6 h-6 text-[#00ff88] shrink-0"}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("p",{className:"text-sm font-mono text-[#00ff88] font-medium",children:"Vault is unlocked"}),o.jsx("p",{className:"text-[11px] font-mono text-gray-500 mt-1",children:"Sensitive keys are encrypted at rest. Non-sensitive config stays in .env."})]}),o.jsxs("button",{onClick:Fn,className:"flex items-center gap-2 px-4 py-2.5 rounded-xl text-xs font-mono uppercase tracking-wider bg-slate-800/60 text-gray-400 border border-slate-700/50 hover:text-white hover:border-slate-600 transition-colors",children:[o.jsx(If,{className:"w-3.5 h-3.5"})," Lock"]})]}):_e.exists?o.jsxs("div",{className:"space-y-4",children:[o.jsx("p",{className:"text-sm font-mono text-gray-400",children:"Enter your vault passphrase to unlock encrypted secrets."}),o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("input",{type:"password",className:Mn,placeholder:"Vault passphrase",value:xt,onChange:ce=>{Pt(ce.target.value),xe("")},onKeyDown:ce=>ce.key==="Enter"&&vn()}),o.jsxs("button",{onClick:vn,disabled:!xt||mn,className:"flex items-center gap-2 px-5 py-3 rounded-xl text-sm font-mono uppercase tracking-wider bg-[#00d9ff]/15 text-[#00d9ff] border border-[#00d9ff]/40 hover:bg-[#00d9ff]/25 transition-colors disabled:opacity-40 disabled:cursor-not-allowed whitespace-nowrap",children:[mn?o.jsx($t,{className:"w-4 h-4 animate-spin"}):o.jsx(Z0,{className:"w-4 h-4"}),"Unlock"]})]}),jn&&o.jsx("p",{className:"text-sm font-mono text-red-400",children:jn})]}):o.jsxs("div",{className:"space-y-3",children:[o.jsx("p",{className:"text-sm font-mono text-gray-400",children:"No vault configured. Set up encrypted storage via CLI:"}),o.jsx("code",{className:"block text-sm font-mono text-[#00d9ff]/80 bg-slate-950/60 rounded-xl px-4 py-3 border border-slate-800/50",children:"daemora vault import <passphrase>"}),o.jsx("p",{className:"text-[11px] font-mono text-gray-600",children:"This imports your .env keys into an encrypted vault and removes them from plaintext."})]})}),o.jsx(Ha,{icon:td,title:"Sub-Agent Model",subtitle:"Model used when spawning sub-agents for parallel tasks",actions:o.jsx(Uo,{dirty:_,saving:M,saved:$,onSave:bt}),children:o.jsx(ST,{value:j.subAgentModel,onChange:ce=>Wt("subAgentModel",ce),modelsByProvider:nn})}),!1,o.jsx(Ha,{icon:Q0,title:"Agent Memory",subtitle:"Persistent knowledge the agent reads at the start of every task",actions:o.jsx(Uo,{dirty:z,saving:B,saved:ye,onSave:Tn}),children:o.jsxs("div",{children:[o.jsx("textarea",{className:Mn+" min-h-[200px] resize-y",placeholder:`Write persistent instructions, preferences, project context...
568
+
569
+ The agent reads this at the start of every conversation.`,value:ne,onChange:ce=>{A(ce.target.value),ee(!0),se(!1)},rows:8}),o.jsxs("p",{className:"text-[11px] font-mono text-gray-600 mt-3 flex items-center gap-2",children:[o.jsx(Q0,{className:"w-3.5 h-3.5"}),"Injected into the system prompt - the agent learns from this across all sessions"]})]})}),o.jsx(Ha,{icon:mD,title:"AI Provider Keys",subtitle:"API keys for LLM providers - encrypted in vault",badge:(()=>{const ce=["OPENAI_API_KEY","ANTHROPIC_API_KEY","GOOGLE_AI_API_KEY","GOOGLE_VERTEX_API_KEY","OPENROUTER_API_KEY","XAI_API_KEY","DEEPSEEK_API_KEY","MISTRAL_API_KEY","GROQ_API_KEY","NVIDIA_API_KEY"],be=ce.filter(We=>t.vars[We]);return be.length>0?o.jsxs("span",{className:"text-[9px] font-mono text-[#00ff88] bg-[#00ff88]/10 px-2 py-0.5 rounded-md border border-[#00ff88]/20",children:[be.length,"/",ce.length," set"]}):null})(),actions:o.jsx(Uo,{dirty:T,saving:v,saved:w,onSave:ze}),children:o.jsx("div",{className:"space-y-3",children:[{name:"OpenAI",key:"OPENAI_API_KEY",color:"#00d9ff",icon:o.jsx(qG,{className:"w-3.5 h-3.5"})},{name:"Anthropic",key:"ANTHROPIC_API_KEY",color:"#d4a574",icon:o.jsx(KG,{className:"w-3.5 h-3.5"})},{name:"Google AI",key:"GOOGLE_AI_API_KEY",color:"#4285f4",icon:o.jsx(wT,{className:"w-3.5 h-3.5"})},{name:"Vertex AI (Express)",key:"GOOGLE_VERTEX_API_KEY",color:"#34a853",icon:o.jsx(wT,{className:"w-3.5 h-3.5"})},{name:"xAI (Grok)",key:"XAI_API_KEY",color:"#1DA1F2",icon:o.jsx(Ja,{className:"w-3.5 h-3.5"})},{name:"DeepSeek",key:"DEEPSEEK_API_KEY",color:"#4f6ef7",icon:o.jsx(Ja,{className:"w-3.5 h-3.5"})},{name:"Mistral",key:"MISTRAL_API_KEY",color:"#ff7000",icon:o.jsx(Ja,{className:"w-3.5 h-3.5"})},{name:"Groq",key:"GROQ_API_KEY",color:"#f55036",icon:o.jsx(ha,{className:"w-3.5 h-3.5"})},{name:"NVIDIA NIM",key:"NVIDIA_API_KEY",color:"#76b900",icon:o.jsx(Ja,{className:"w-3.5 h-3.5"})},{name:"OpenRouter",key:"OPENROUTER_API_KEY",color:"#6366f1",icon:o.jsx(GG,{className:"w-3.5 h-3.5"})}].map(({name:ce,key:be,color:We,icon:Ct})=>{const ut=!!t.vars[be],Yt=i[be]!==void 0;return o.jsxs("div",{className:"p-4 bg-slate-800/20 rounded-xl border border-slate-800/40",children:[o.jsxs("div",{className:"flex items-center gap-2 mb-2.5",children:[o.jsx("span",{style:{color:We},children:Ct}),o.jsx("span",{className:"text-[12px] font-mono font-medium",style:{color:We},children:ce}),ut&&!Yt&&o.jsx("span",{className:"text-[8px] font-mono text-[#00ff88] bg-[#00ff88]/8 px-1.5 py-0.5 rounded border border-[#00ff88]/15",children:"CONFIGURED"}),t.vaultActive&&ut&&o.jsxs("span",{className:"text-[8px] font-mono text-[#00d9ff] bg-[#00d9ff]/8 px-1.5 py-0.5 rounded border border-[#00d9ff]/15 flex items-center gap-0.5",children:[o.jsx(zu,{className:"w-2.5 h-2.5"})," vault"]}),Yt&&o.jsx("span",{className:"text-[8px] font-mono text-amber-400 bg-amber-400/8 px-1.5 py-0.5 rounded border border-amber-400/15",children:"modified"})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("input",{type:a.has(be)?"text":"password",placeholder:ut?t.vars[be]:"Not set",value:i[be]??"",onChange:kt=>Ue(be,kt.target.value),className:Mn}),o.jsx("button",{onClick:()=>pe(be),className:"p-2.5 text-gray-500 hover:text-[#00d9ff] transition-colors rounded-xl hover:bg-slate-800/50",title:"Show/hide",children:a.has(be)?o.jsx(sc,{className:"w-4 h-4"}):o.jsx(Ss,{className:"w-4 h-4"})}),ut&&o.jsx("button",{onClick:()=>d({key:be,name:ce}),className:"p-2.5 text-gray-500 hover:text-red-400 transition-colors rounded-xl hover:bg-red-500/10",title:`Delete ${ce} key`,children:o.jsx(qn,{className:"w-4 h-4"})})]})]},be)})})}),o.jsx(Ha,{icon:Wo,title:"Web Search & Fetch",subtitle:"API keys for web search and page extraction tools",badge:(()=>{const ce=["BRAVE_API_KEY","TAVILY_API_KEY","PERPLEXITY_API_KEY","FIRECRAWL_API_KEY","SEARXNG_URL"],be=ce.filter(We=>t.vars[We]);return be.length>0?o.jsxs("span",{className:"text-[9px] font-mono text-[#00ff88] bg-[#00ff88]/10 px-2 py-0.5 rounded-md border border-[#00ff88]/20",children:[be.length,"/",ce.length," set"]}):null})(),actions:o.jsx(Uo,{dirty:T,saving:v,saved:w,onSave:ze}),children:o.jsx("div",{className:"space-y-3",children:[{name:"Brave Search",key:"BRAVE_API_KEY",color:"#fb542b",icon:o.jsx(Wo,{className:"w-3.5 h-3.5"}),isUrl:!1},{name:"Tavily",key:"TAVILY_API_KEY",color:"#6366f1",icon:o.jsx(Wo,{className:"w-3.5 h-3.5"}),isUrl:!1},{name:"Perplexity",key:"PERPLEXITY_API_KEY",color:"#20b2aa",icon:o.jsx(Wo,{className:"w-3.5 h-3.5"}),isUrl:!1},{name:"Firecrawl",key:"FIRECRAWL_API_KEY",color:"#ff6b35",icon:o.jsx(ha,{className:"w-3.5 h-3.5"}),isUrl:!1},{name:"SearXNG URL",key:"SEARXNG_URL",color:"#4caf50",icon:o.jsx(Wo,{className:"w-3.5 h-3.5"}),isUrl:!0}].map(({name:ce,key:be,color:We,icon:Ct,isUrl:ut})=>{const Yt=!!t.vars[be],kt=i[be]!==void 0;return o.jsxs("div",{className:"p-4 bg-slate-800/20 rounded-xl border border-slate-800/40",children:[o.jsxs("div",{className:"flex items-center gap-2 mb-2.5",children:[o.jsx("span",{style:{color:We},children:Ct}),o.jsx("span",{className:"text-[12px] font-mono font-medium",style:{color:We},children:ce}),Yt&&!kt&&o.jsx("span",{className:"text-[8px] font-mono text-[#00ff88] bg-[#00ff88]/8 px-1.5 py-0.5 rounded border border-[#00ff88]/15",children:"CONFIGURED"}),t.vaultActive&&Yt&&!ut&&o.jsxs("span",{className:"text-[8px] font-mono text-[#00d9ff] bg-[#00d9ff]/8 px-1.5 py-0.5 rounded border border-[#00d9ff]/15 flex items-center gap-0.5",children:[o.jsx(zu,{className:"w-2.5 h-2.5"})," vault"]}),kt&&o.jsx("span",{className:"text-[8px] font-mono text-amber-400 bg-amber-400/8 px-1.5 py-0.5 rounded border border-amber-400/15",children:"modified"})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("input",{type:ut||a.has(be)?"text":"password",placeholder:Yt?t.vars[be]:"Not set",value:i[be]??"",onChange:Bt=>Ue(be,Bt.target.value),className:Mn}),!ut&&o.jsx("button",{onClick:()=>pe(be),className:"p-2.5 text-gray-500 hover:text-[#00d9ff] transition-colors rounded-xl hover:bg-slate-800/50",title:"Show/hide",children:a.has(be)?o.jsx(sc,{className:"w-4 h-4"}):o.jsx(Ss,{className:"w-4 h-4"})}),Yt&&o.jsx("button",{onClick:()=>d({key:be,name:ce}),className:"p-2.5 text-gray-500 hover:text-red-400 transition-colors rounded-xl hover:bg-red-500/10",title:`Delete ${ce} key`,children:o.jsx(qn,{className:"w-4 h-4"})})]})]},be)})})}),o.jsx(Ha,{icon:pp,title:"Tool Config",subtitle:"API keys and settings for built-in tools",badge:(()=>{const be=["ELEVENLABS_API_KEY","SUNO_API_KEY"].filter(We=>t.vars[We]);return be.length>0?o.jsxs("span",{className:"text-[9px] font-mono text-[#00ff88] bg-[#00ff88]/10 px-2 py-0.5 rounded-md border border-[#00ff88]/20",children:[be.length," configured"]}):null})(),actions:o.jsx(Uo,{dirty:T,saving:v,saved:w,onSave:ze}),children:o.jsx("div",{className:"space-y-3",children:[{name:"Text-to-Speech (ElevenLabs)",color:"#f0883e",keys:[{key:"ELEVENLABS_API_KEY",label:"API Key"}]},{name:"Music Generation (Suno)",color:"#8b5cf6",keys:[{key:"SUNO_API_KEY",label:"API Key"}]}].map(({name:ce,color:be,keys:We})=>{const Ct=We.some(ut=>t.vars[ut.key]);return o.jsxs("div",{className:"p-4 bg-slate-800/20 rounded-xl border border-slate-800/40",children:[o.jsxs("div",{className:"flex items-center justify-between mb-3",children:[o.jsx("span",{className:"text-[13px] font-mono font-medium",style:{color:be},children:ce}),Ct&&o.jsx("span",{className:"text-[8px] font-mono text-[#00ff88] bg-[#00ff88]/8 px-2 py-0.5 rounded border border-[#00ff88]/15",children:"CONFIGURED"})]}),o.jsx("div",{className:"space-y-2",children:We.map(({key:ut,label:Yt})=>{const kt=!!t.vars[ut],Bt=i[ut]!==void 0;return o.jsxs("div",{children:[o.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[o.jsx("span",{className:"text-[10px] font-mono text-gray-500",children:Yt}),kt&&!Bt&&o.jsx("span",{className:"text-[7px] font-mono text-[#00ff88]/60",children:"set"})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("input",{type:a.has(ut)?"text":"password",placeholder:kt?t.vars[ut]:"Not set",value:i[ut]??"",onChange:ln=>Ue(ut,ln.target.value),className:Mn+" !py-2 !text-xs"}),o.jsx("button",{onClick:()=>pe(ut),className:"p-2 text-gray-600 hover:text-[#00d9ff] transition-colors",children:a.has(ut)?o.jsx(sc,{className:"w-3.5 h-3.5"}):o.jsx(Ss,{className:"w-3.5 h-3.5"})})]})]},ut)})})]},ce)})})}),o.jsx(js,{open:!!h,onOpenChange:ce=>!ce&&d(null),children:o.jsxs(Ps,{className:"bg-slate-950 border-slate-800/80 text-gray-200 font-mono",children:[o.jsxs(_s,{children:[o.jsxs(Is,{className:"text-white tracking-tight flex items-center gap-2",children:[o.jsx(qn,{className:"w-4 h-4 text-red-400"}),"Delete ",h==null?void 0:h.name," key"]}),o.jsx(Ms,{className:"text-gray-400 text-sm leading-relaxed",children:"The key will be removed from the vault and any models that depend on it will stop working until you paste it back."})]}),o.jsxs(Rs,{children:[o.jsx(As,{className:"bg-slate-900 border-slate-800 text-gray-300 hover:bg-slate-800 hover:text-white",children:"Cancel"}),o.jsx(Ds,{onClick:g,disabled:f,className:"bg-red-600 hover:bg-red-500 text-white border border-red-500/40",children:f?"Deleting...":"Delete key"})]})]})})]})}function Gt(t){const e=Object.prototype.toString.call(t);return t instanceof Date||typeof t=="object"&&e==="[object Date]"?new t.constructor(+t):typeof t=="number"||e==="[object Number]"||typeof t=="string"||e==="[object String]"?new Date(t):new Date(NaN)}function vi(t,e){return t instanceof Date?new t.constructor(e):new Date(e)}function Ir(t,e){const n=Gt(t);return isNaN(e)?vi(t,NaN):(e&&n.setDate(n.getDate()+e),n)}function as(t,e){const n=Gt(t);if(isNaN(e))return vi(t,NaN);if(!e)return n;const r=n.getDate(),i=vi(t,n.getTime());i.setMonth(n.getMonth()+e+1,0);const s=i.getDate();return r>=s?i:(n.setFullYear(i.getFullYear(),i.getMonth(),r),n)}const Qx=6048e5,YG=864e5;let JG={};function _d(){return JG}function Fs(t,e){var c,h,d,f;const n=_d(),r=(e==null?void 0:e.weekStartsOn)??((h=(c=e==null?void 0:e.locale)==null?void 0:c.options)==null?void 0:h.weekStartsOn)??n.weekStartsOn??((f=(d=n.locale)==null?void 0:d.options)==null?void 0:f.weekStartsOn)??0,i=Gt(t),s=i.getDay(),a=(s<r?7:0)+s-r;return i.setDate(i.getDate()-a),i.setHours(0,0,0,0),i}function gl(t){return Fs(t,{weekStartsOn:1})}function MR(t){const e=Gt(t),n=e.getFullYear(),r=vi(t,0);r.setFullYear(n+1,0,4),r.setHours(0,0,0,0);const i=gl(r),s=vi(t,0);s.setFullYear(n,0,4),s.setHours(0,0,0,0);const a=gl(s);return e.getTime()>=i.getTime()?n+1:e.getTime()>=a.getTime()?n:n-1}function jc(t){const e=Gt(t);return e.setHours(0,0,0,0),e}function lp(t){const e=Gt(t),n=new Date(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds()));return n.setUTCFullYear(e.getFullYear()),+t-+n}function ks(t,e){const n=jc(t),r=jc(e),i=+n-lp(n),s=+r-lp(r);return Math.round((i-s)/YG)}function XG(t){const e=MR(t),n=vi(t,0);return n.setFullYear(e,0,4),n.setHours(0,0,0,0),gl(n)}function iy(t,e){const n=e*7;return Ir(t,n)}function QG(t,e){return as(t,e*12)}function ZG(t){let e;return t.forEach(function(n){const r=Gt(n);(e===void 0||e<r||isNaN(Number(r)))&&(e=r)}),e||new Date(NaN)}function eY(t){let e;return t.forEach(n=>{const r=Gt(n);(!e||e>r||isNaN(+r))&&(e=r)}),e||new Date(NaN)}function Xr(t,e){const n=jc(t),r=jc(e);return+n==+r}function Zx(t){return t instanceof Date||typeof t=="object"&&Object.prototype.toString.call(t)==="[object Date]"}function tY(t){if(!Zx(t)&&typeof t!="number")return!1;const e=Gt(t);return!isNaN(Number(e))}function vd(t,e){const n=Gt(t),r=Gt(e),i=n.getFullYear()-r.getFullYear(),s=n.getMonth()-r.getMonth();return i*12+s}function nY(t,e,n){const r=Fs(t,n),i=Fs(e,n),s=+r-lp(r),a=+i-lp(i);return Math.round((s-a)/Qx)}function eb(t){const e=Gt(t),n=e.getMonth();return e.setFullYear(e.getFullYear(),n+1,0),e.setHours(23,59,59,999),e}function Zr(t){const e=Gt(t);return e.setDate(1),e.setHours(0,0,0,0),e}function DR(t){const e=Gt(t),n=vi(t,0);return n.setFullYear(e.getFullYear(),0,1),n.setHours(0,0,0,0),n}function tb(t,e){var c,h,d,f;const n=_d(),r=(e==null?void 0:e.weekStartsOn)??((h=(c=e==null?void 0:e.locale)==null?void 0:c.options)==null?void 0:h.weekStartsOn)??n.weekStartsOn??((f=(d=n.locale)==null?void 0:d.options)==null?void 0:f.weekStartsOn)??0,i=Gt(t),s=i.getDay(),a=(s<r?-7:0)+6-(s-r);return i.setDate(i.getDate()+a),i.setHours(23,59,59,999),i}function AR(t){return tb(t,{weekStartsOn:1})}const rY={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}},iY=(t,e,n)=>{let r;const i=rY[t];return typeof i=="string"?r=i:e===1?r=i.one:r=i.other.replace("{{count}}",e.toString()),n!=null&&n.addSuffix?n.comparison&&n.comparison>0?"in "+r:r+" ago":r};function F0(t){return(e={})=>{const n=e.width?String(e.width):t.defaultWidth;return t.formats[n]||t.formats[t.defaultWidth]}}const sY={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},aY={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},oY={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},lY={date:F0({formats:sY,defaultWidth:"full"}),time:F0({formats:aY,defaultWidth:"full"}),dateTime:F0({formats:oY,defaultWidth:"full"})},cY={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},uY=(t,e,n,r)=>cY[t];function Ru(t){return(e,n)=>{const r=n!=null&&n.context?String(n.context):"standalone";let i;if(r==="formatting"&&t.formattingValues){const a=t.defaultFormattingWidth||t.defaultWidth,c=n!=null&&n.width?String(n.width):a;i=t.formattingValues[c]||t.formattingValues[a]}else{const a=t.defaultWidth,c=n!=null&&n.width?String(n.width):t.defaultWidth;i=t.values[c]||t.values[a]}const s=t.argumentCallback?t.argumentCallback(e):e;return i[s]}}const dY={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},hY={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},fY={narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},pY={narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},mY={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},gY={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},vY=(t,e)=>{const n=Number(t),r=n%100;if(r>20||r<10)switch(r%10){case 1:return n+"st";case 2:return n+"nd";case 3:return n+"rd"}return n+"th"},yY={ordinalNumber:vY,era:Ru({values:dY,defaultWidth:"wide"}),quarter:Ru({values:hY,defaultWidth:"wide",argumentCallback:t=>t-1}),month:Ru({values:fY,defaultWidth:"wide"}),day:Ru({values:pY,defaultWidth:"wide"}),dayPeriod:Ru({values:mY,defaultWidth:"wide",formattingValues:gY,defaultFormattingWidth:"wide"})};function Iu(t){return(e,n={})=>{const r=n.width,i=r&&t.matchPatterns[r]||t.matchPatterns[t.defaultMatchWidth],s=e.match(i);if(!s)return null;const a=s[0],c=r&&t.parsePatterns[r]||t.parsePatterns[t.defaultParseWidth],h=Array.isArray(c)?bY(c,p=>p.test(a)):xY(c,p=>p.test(a));let d;d=t.valueCallback?t.valueCallback(h):h,d=n.valueCallback?n.valueCallback(d):d;const f=e.slice(a.length);return{value:d,rest:f}}}function xY(t,e){for(const n in t)if(Object.prototype.hasOwnProperty.call(t,n)&&e(t[n]))return n}function bY(t,e){for(let n=0;n<t.length;n++)if(e(t[n]))return n}function kY(t){return(e,n={})=>{const r=e.match(t.matchPattern);if(!r)return null;const i=r[0],s=e.match(t.parsePattern);if(!s)return null;let a=t.valueCallback?t.valueCallback(s[0]):s[0];a=n.valueCallback?n.valueCallback(a):a;const c=e.slice(i.length);return{value:a,rest:c}}}const wY=/^(\d+)(th|st|nd|rd)?/i,SY=/\d+/i,CY={narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},TY={any:[/^b/i,/^(a|c)/i]},NY={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},EY={any:[/1/i,/2/i,/3/i,/4/i]},jY={narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},PY={narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},_Y={narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},RY={narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},IY={narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},MY={any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},DY={ordinalNumber:kY({matchPattern:wY,parsePattern:SY,valueCallback:t=>parseInt(t,10)}),era:Iu({matchPatterns:CY,defaultMatchWidth:"wide",parsePatterns:TY,defaultParseWidth:"any"}),quarter:Iu({matchPatterns:NY,defaultMatchWidth:"wide",parsePatterns:EY,defaultParseWidth:"any",valueCallback:t=>t+1}),month:Iu({matchPatterns:jY,defaultMatchWidth:"wide",parsePatterns:PY,defaultParseWidth:"any"}),day:Iu({matchPatterns:_Y,defaultMatchWidth:"wide",parsePatterns:RY,defaultParseWidth:"any"}),dayPeriod:Iu({matchPatterns:IY,defaultMatchWidth:"any",parsePatterns:MY,defaultParseWidth:"any"})},OR={code:"en-US",formatDistance:iY,formatLong:lY,formatRelative:uY,localize:yY,match:DY,options:{weekStartsOn:0,firstWeekContainsDate:1}};function AY(t){const e=Gt(t);return ks(e,DR(e))+1}function LR(t){const e=Gt(t),n=+gl(e)-+XG(e);return Math.round(n/Qx)+1}function FR(t,e){var f,p,g,v;const n=Gt(t),r=n.getFullYear(),i=_d(),s=(e==null?void 0:e.firstWeekContainsDate)??((p=(f=e==null?void 0:e.locale)==null?void 0:f.options)==null?void 0:p.firstWeekContainsDate)??i.firstWeekContainsDate??((v=(g=i.locale)==null?void 0:g.options)==null?void 0:v.firstWeekContainsDate)??1,a=vi(t,0);a.setFullYear(r+1,0,s),a.setHours(0,0,0,0);const c=Fs(a,e),h=vi(t,0);h.setFullYear(r,0,s),h.setHours(0,0,0,0);const d=Fs(h,e);return n.getTime()>=c.getTime()?r+1:n.getTime()>=d.getTime()?r:r-1}function OY(t,e){var c,h,d,f;const n=_d(),r=(e==null?void 0:e.firstWeekContainsDate)??((h=(c=e==null?void 0:e.locale)==null?void 0:c.options)==null?void 0:h.firstWeekContainsDate)??n.firstWeekContainsDate??((f=(d=n.locale)==null?void 0:d.options)==null?void 0:f.firstWeekContainsDate)??1,i=FR(t,e),s=vi(t,0);return s.setFullYear(i,0,r),s.setHours(0,0,0,0),Fs(s,e)}function UR(t,e){const n=Gt(t),r=+Fs(n,e)-+OY(n,e);return Math.round(r/Qx)+1}function dn(t,e){const n=t<0?"-":"",r=Math.abs(t).toString().padStart(e,"0");return n+r}const qa={y(t,e){const n=t.getFullYear(),r=n>0?n:1-n;return dn(e==="yy"?r%100:r,e.length)},M(t,e){const n=t.getMonth();return e==="M"?String(n+1):dn(n+1,2)},d(t,e){return dn(t.getDate(),e.length)},a(t,e){const n=t.getHours()/12>=1?"pm":"am";switch(e){case"a":case"aa":return n.toUpperCase();case"aaa":return n;case"aaaaa":return n[0];case"aaaa":default:return n==="am"?"a.m.":"p.m."}},h(t,e){return dn(t.getHours()%12||12,e.length)},H(t,e){return dn(t.getHours(),e.length)},m(t,e){return dn(t.getMinutes(),e.length)},s(t,e){return dn(t.getSeconds(),e.length)},S(t,e){const n=e.length,r=t.getMilliseconds(),i=Math.trunc(r*Math.pow(10,n-3));return dn(i,e.length)}},Ql={midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},TT={G:function(t,e,n){const r=t.getFullYear()>0?1:0;switch(e){case"G":case"GG":case"GGG":return n.era(r,{width:"abbreviated"});case"GGGGG":return n.era(r,{width:"narrow"});case"GGGG":default:return n.era(r,{width:"wide"})}},y:function(t,e,n){if(e==="yo"){const r=t.getFullYear(),i=r>0?r:1-r;return n.ordinalNumber(i,{unit:"year"})}return qa.y(t,e)},Y:function(t,e,n,r){const i=FR(t,r),s=i>0?i:1-i;if(e==="YY"){const a=s%100;return dn(a,2)}return e==="Yo"?n.ordinalNumber(s,{unit:"year"}):dn(s,e.length)},R:function(t,e){const n=MR(t);return dn(n,e.length)},u:function(t,e){const n=t.getFullYear();return dn(n,e.length)},Q:function(t,e,n){const r=Math.ceil((t.getMonth()+1)/3);switch(e){case"Q":return String(r);case"QQ":return dn(r,2);case"Qo":return n.ordinalNumber(r,{unit:"quarter"});case"QQQ":return n.quarter(r,{width:"abbreviated",context:"formatting"});case"QQQQQ":return n.quarter(r,{width:"narrow",context:"formatting"});case"QQQQ":default:return n.quarter(r,{width:"wide",context:"formatting"})}},q:function(t,e,n){const r=Math.ceil((t.getMonth()+1)/3);switch(e){case"q":return String(r);case"qq":return dn(r,2);case"qo":return n.ordinalNumber(r,{unit:"quarter"});case"qqq":return n.quarter(r,{width:"abbreviated",context:"standalone"});case"qqqqq":return n.quarter(r,{width:"narrow",context:"standalone"});case"qqqq":default:return n.quarter(r,{width:"wide",context:"standalone"})}},M:function(t,e,n){const r=t.getMonth();switch(e){case"M":case"MM":return qa.M(t,e);case"Mo":return n.ordinalNumber(r+1,{unit:"month"});case"MMM":return n.month(r,{width:"abbreviated",context:"formatting"});case"MMMMM":return n.month(r,{width:"narrow",context:"formatting"});case"MMMM":default:return n.month(r,{width:"wide",context:"formatting"})}},L:function(t,e,n){const r=t.getMonth();switch(e){case"L":return String(r+1);case"LL":return dn(r+1,2);case"Lo":return n.ordinalNumber(r+1,{unit:"month"});case"LLL":return n.month(r,{width:"abbreviated",context:"standalone"});case"LLLLL":return n.month(r,{width:"narrow",context:"standalone"});case"LLLL":default:return n.month(r,{width:"wide",context:"standalone"})}},w:function(t,e,n,r){const i=UR(t,r);return e==="wo"?n.ordinalNumber(i,{unit:"week"}):dn(i,e.length)},I:function(t,e,n){const r=LR(t);return e==="Io"?n.ordinalNumber(r,{unit:"week"}):dn(r,e.length)},d:function(t,e,n){return e==="do"?n.ordinalNumber(t.getDate(),{unit:"date"}):qa.d(t,e)},D:function(t,e,n){const r=AY(t);return e==="Do"?n.ordinalNumber(r,{unit:"dayOfYear"}):dn(r,e.length)},E:function(t,e,n){const r=t.getDay();switch(e){case"E":case"EE":case"EEE":return n.day(r,{width:"abbreviated",context:"formatting"});case"EEEEE":return n.day(r,{width:"narrow",context:"formatting"});case"EEEEEE":return n.day(r,{width:"short",context:"formatting"});case"EEEE":default:return n.day(r,{width:"wide",context:"formatting"})}},e:function(t,e,n,r){const i=t.getDay(),s=(i-r.weekStartsOn+8)%7||7;switch(e){case"e":return String(s);case"ee":return dn(s,2);case"eo":return n.ordinalNumber(s,{unit:"day"});case"eee":return n.day(i,{width:"abbreviated",context:"formatting"});case"eeeee":return n.day(i,{width:"narrow",context:"formatting"});case"eeeeee":return n.day(i,{width:"short",context:"formatting"});case"eeee":default:return n.day(i,{width:"wide",context:"formatting"})}},c:function(t,e,n,r){const i=t.getDay(),s=(i-r.weekStartsOn+8)%7||7;switch(e){case"c":return String(s);case"cc":return dn(s,e.length);case"co":return n.ordinalNumber(s,{unit:"day"});case"ccc":return n.day(i,{width:"abbreviated",context:"standalone"});case"ccccc":return n.day(i,{width:"narrow",context:"standalone"});case"cccccc":return n.day(i,{width:"short",context:"standalone"});case"cccc":default:return n.day(i,{width:"wide",context:"standalone"})}},i:function(t,e,n){const r=t.getDay(),i=r===0?7:r;switch(e){case"i":return String(i);case"ii":return dn(i,e.length);case"io":return n.ordinalNumber(i,{unit:"day"});case"iii":return n.day(r,{width:"abbreviated",context:"formatting"});case"iiiii":return n.day(r,{width:"narrow",context:"formatting"});case"iiiiii":return n.day(r,{width:"short",context:"formatting"});case"iiii":default:return n.day(r,{width:"wide",context:"formatting"})}},a:function(t,e,n){const i=t.getHours()/12>=1?"pm":"am";switch(e){case"a":case"aa":return n.dayPeriod(i,{width:"abbreviated",context:"formatting"});case"aaa":return n.dayPeriod(i,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return n.dayPeriod(i,{width:"narrow",context:"formatting"});case"aaaa":default:return n.dayPeriod(i,{width:"wide",context:"formatting"})}},b:function(t,e,n){const r=t.getHours();let i;switch(r===12?i=Ql.noon:r===0?i=Ql.midnight:i=r/12>=1?"pm":"am",e){case"b":case"bb":return n.dayPeriod(i,{width:"abbreviated",context:"formatting"});case"bbb":return n.dayPeriod(i,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return n.dayPeriod(i,{width:"narrow",context:"formatting"});case"bbbb":default:return n.dayPeriod(i,{width:"wide",context:"formatting"})}},B:function(t,e,n){const r=t.getHours();let i;switch(r>=17?i=Ql.evening:r>=12?i=Ql.afternoon:r>=4?i=Ql.morning:i=Ql.night,e){case"B":case"BB":case"BBB":return n.dayPeriod(i,{width:"abbreviated",context:"formatting"});case"BBBBB":return n.dayPeriod(i,{width:"narrow",context:"formatting"});case"BBBB":default:return n.dayPeriod(i,{width:"wide",context:"formatting"})}},h:function(t,e,n){if(e==="ho"){let r=t.getHours()%12;return r===0&&(r=12),n.ordinalNumber(r,{unit:"hour"})}return qa.h(t,e)},H:function(t,e,n){return e==="Ho"?n.ordinalNumber(t.getHours(),{unit:"hour"}):qa.H(t,e)},K:function(t,e,n){const r=t.getHours()%12;return e==="Ko"?n.ordinalNumber(r,{unit:"hour"}):dn(r,e.length)},k:function(t,e,n){let r=t.getHours();return r===0&&(r=24),e==="ko"?n.ordinalNumber(r,{unit:"hour"}):dn(r,e.length)},m:function(t,e,n){return e==="mo"?n.ordinalNumber(t.getMinutes(),{unit:"minute"}):qa.m(t,e)},s:function(t,e,n){return e==="so"?n.ordinalNumber(t.getSeconds(),{unit:"second"}):qa.s(t,e)},S:function(t,e){return qa.S(t,e)},X:function(t,e,n){const r=t.getTimezoneOffset();if(r===0)return"Z";switch(e){case"X":return ET(r);case"XXXX":case"XX":return Vo(r);case"XXXXX":case"XXX":default:return Vo(r,":")}},x:function(t,e,n){const r=t.getTimezoneOffset();switch(e){case"x":return ET(r);case"xxxx":case"xx":return Vo(r);case"xxxxx":case"xxx":default:return Vo(r,":")}},O:function(t,e,n){const r=t.getTimezoneOffset();switch(e){case"O":case"OO":case"OOO":return"GMT"+NT(r,":");case"OOOO":default:return"GMT"+Vo(r,":")}},z:function(t,e,n){const r=t.getTimezoneOffset();switch(e){case"z":case"zz":case"zzz":return"GMT"+NT(r,":");case"zzzz":default:return"GMT"+Vo(r,":")}},t:function(t,e,n){const r=Math.trunc(t.getTime()/1e3);return dn(r,e.length)},T:function(t,e,n){const r=t.getTime();return dn(r,e.length)}};function NT(t,e=""){const n=t>0?"-":"+",r=Math.abs(t),i=Math.trunc(r/60),s=r%60;return s===0?n+String(i):n+String(i)+e+dn(s,2)}function ET(t,e){return t%60===0?(t>0?"-":"+")+dn(Math.abs(t)/60,2):Vo(t,e)}function Vo(t,e=""){const n=t>0?"-":"+",r=Math.abs(t),i=dn(Math.trunc(r/60),2),s=dn(r%60,2);return n+i+e+s}const jT=(t,e)=>{switch(t){case"P":return e.date({width:"short"});case"PP":return e.date({width:"medium"});case"PPP":return e.date({width:"long"});case"PPPP":default:return e.date({width:"full"})}},BR=(t,e)=>{switch(t){case"p":return e.time({width:"short"});case"pp":return e.time({width:"medium"});case"ppp":return e.time({width:"long"});case"pppp":default:return e.time({width:"full"})}},LY=(t,e)=>{const n=t.match(/(P+)(p+)?/)||[],r=n[1],i=n[2];if(!i)return jT(t,e);let s;switch(r){case"P":s=e.dateTime({width:"short"});break;case"PP":s=e.dateTime({width:"medium"});break;case"PPP":s=e.dateTime({width:"long"});break;case"PPPP":default:s=e.dateTime({width:"full"});break}return s.replace("{{date}}",jT(r,e)).replace("{{time}}",BR(i,e))},FY={p:BR,P:LY},UY=/^D+$/,BY=/^Y+$/,zY=["D","DD","YY","YYYY"];function $Y(t){return UY.test(t)}function VY(t){return BY.test(t)}function WY(t,e,n){const r=HY(t,e,n);if(console.warn(r),zY.includes(t))throw new RangeError(r)}function HY(t,e,n){const r=t[0]==="Y"?"years":"days of the month";return`Use \`${t.toLowerCase()}\` instead of \`${t}\` (in \`${e}\`) for formatting ${r} to the input \`${n}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}const qY=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,KY=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,GY=/^'([^]*?)'?$/,YY=/''/g,JY=/[a-zA-Z]/;function bl(t,e,n){var f,p,g,v,k,w,S,T;const r=_d(),i=(n==null?void 0:n.locale)??r.locale??OR,s=(n==null?void 0:n.firstWeekContainsDate)??((p=(f=n==null?void 0:n.locale)==null?void 0:f.options)==null?void 0:p.firstWeekContainsDate)??r.firstWeekContainsDate??((v=(g=r.locale)==null?void 0:g.options)==null?void 0:v.firstWeekContainsDate)??1,a=(n==null?void 0:n.weekStartsOn)??((w=(k=n==null?void 0:n.locale)==null?void 0:k.options)==null?void 0:w.weekStartsOn)??r.weekStartsOn??((T=(S=r.locale)==null?void 0:S.options)==null?void 0:T.weekStartsOn)??0,c=Gt(t);if(!tY(c))throw new RangeError("Invalid time value");let h=e.match(KY).map(C=>{const j=C[0];if(j==="p"||j==="P"){const R=FY[j];return R(C,i.formatLong)}return C}).join("").match(qY).map(C=>{if(C==="''")return{isToken:!1,value:"'"};const j=C[0];if(j==="'")return{isToken:!1,value:XY(C)};if(TT[j])return{isToken:!0,value:C};if(j.match(JY))throw new RangeError("Format string contains an unescaped latin alphabet character `"+j+"`");return{isToken:!1,value:C}});i.localize.preprocessor&&(h=i.localize.preprocessor(c,h));const d={firstWeekContainsDate:s,weekStartsOn:a,locale:i};return h.map(C=>{if(!C.isToken)return C.value;const j=C.value;(!(n!=null&&n.useAdditionalWeekYearTokens)&&VY(j)||!(n!=null&&n.useAdditionalDayOfYearTokens)&&$Y(j))&&WY(j,e,String(t));const R=TT[j[0]];return R(c,j,i.localize,d)}).join("")}function XY(t){const e=t.match(GY);return e?e[1].replace(YY,"'"):t}function QY(t){const e=Gt(t),n=e.getFullYear(),r=e.getMonth(),i=vi(t,0);return i.setFullYear(n,r+1,0),i.setHours(0,0,0,0),i.getDate()}function ZY(t){return Math.trunc(+Gt(t)/1e3)}function eJ(t){const e=Gt(t),n=e.getMonth();return e.setFullYear(e.getFullYear(),n+1,0),e.setHours(0,0,0,0),e}function tJ(t,e){return nY(eJ(t),Zr(t),e)+1}function sy(t,e){const n=Gt(t),r=Gt(e);return n.getTime()>r.getTime()}function zR(t,e){const n=Gt(t),r=Gt(e);return+n<+r}function nb(t,e){const n=Gt(t),r=Gt(e);return n.getFullYear()===r.getFullYear()&&n.getMonth()===r.getMonth()}function nJ(t,e){const n=Gt(t),r=Gt(e);return n.getFullYear()===r.getFullYear()}function U0(t,e){return Ir(t,-e)}function B0(t,e){const n=Gt(t),r=n.getFullYear(),i=n.getDate(),s=vi(t,0);s.setFullYear(r,e,15),s.setHours(0,0,0,0);const a=QY(s);return n.setMonth(e,Math.min(i,a)),n}function PT(t,e){const n=Gt(t);return isNaN(+n)?vi(t,NaN):(n.setFullYear(e),n)}var vt=function(){return vt=Object.assign||function(e){for(var n,r=1,i=arguments.length;r<i;r++){n=arguments[r];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(e[s]=n[s])}return e},vt.apply(this,arguments)};function rJ(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,r=Object.getOwnPropertySymbols(t);i<r.length;i++)e.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(t,r[i])&&(n[r[i]]=t[r[i]]);return n}function $R(t,e,n){for(var r=0,i=e.length,s;r<i;r++)(s||!(r in e))&&(s||(s=Array.prototype.slice.call(e,0,r)),s[r]=e[r]);return t.concat(s||Array.prototype.slice.call(e))}function Rd(t){return t.mode==="multiple"}function Id(t){return t.mode==="range"}function Gp(t){return t.mode==="single"}var iJ={root:"rdp",multiple_months:"rdp-multiple_months",with_weeknumber:"rdp-with_weeknumber",vhidden:"rdp-vhidden",button_reset:"rdp-button_reset",button:"rdp-button",caption:"rdp-caption",caption_start:"rdp-caption_start",caption_end:"rdp-caption_end",caption_between:"rdp-caption_between",caption_label:"rdp-caption_label",caption_dropdowns:"rdp-caption_dropdowns",dropdown:"rdp-dropdown",dropdown_month:"rdp-dropdown_month",dropdown_year:"rdp-dropdown_year",dropdown_icon:"rdp-dropdown_icon",months:"rdp-months",month:"rdp-month",table:"rdp-table",tbody:"rdp-tbody",tfoot:"rdp-tfoot",head:"rdp-head",head_row:"rdp-head_row",head_cell:"rdp-head_cell",nav:"rdp-nav",nav_button:"rdp-nav_button",nav_button_previous:"rdp-nav_button_previous",nav_button_next:"rdp-nav_button_next",nav_icon:"rdp-nav_icon",row:"rdp-row",weeknumber:"rdp-weeknumber",cell:"rdp-cell",day:"rdp-day",day_today:"rdp-day_today",day_outside:"rdp-day_outside",day_selected:"rdp-day_selected",day_disabled:"rdp-day_disabled",day_hidden:"rdp-day_hidden",day_range_start:"rdp-day_range_start",day_range_end:"rdp-day_range_end",day_range_middle:"rdp-day_range_middle"};function sJ(t,e){return bl(t,"LLLL y",e)}function aJ(t,e){return bl(t,"d",e)}function oJ(t,e){return bl(t,"LLLL",e)}function lJ(t){return"".concat(t)}function cJ(t,e){return bl(t,"cccccc",e)}function uJ(t,e){return bl(t,"yyyy",e)}var dJ=Object.freeze({__proto__:null,formatCaption:sJ,formatDay:aJ,formatMonthCaption:oJ,formatWeekNumber:lJ,formatWeekdayName:cJ,formatYearCaption:uJ}),hJ=function(t,e,n){return bl(t,"do MMMM (EEEE)",n)},fJ=function(){return"Month: "},pJ=function(){return"Go to next month"},mJ=function(){return"Go to previous month"},gJ=function(t,e){return bl(t,"cccc",e)},vJ=function(t){return"Week n. ".concat(t)},yJ=function(){return"Year: "},xJ=Object.freeze({__proto__:null,labelDay:hJ,labelMonthDropdown:fJ,labelNext:pJ,labelPrevious:mJ,labelWeekNumber:vJ,labelWeekday:gJ,labelYearDropdown:yJ});function bJ(){var t="buttons",e=iJ,n=OR,r={},i={},s=1,a={},c=new Date;return{captionLayout:t,classNames:e,formatters:dJ,labels:xJ,locale:n,modifiersClassNames:r,modifiers:i,numberOfMonths:s,styles:a,today:c,mode:"default"}}function kJ(t){var e=t.fromYear,n=t.toYear,r=t.fromMonth,i=t.toMonth,s=t.fromDate,a=t.toDate;return r?s=Zr(r):e&&(s=new Date(e,0,1)),i?a=eb(i):n&&(a=new Date(n,11,31)),{fromDate:s?jc(s):void 0,toDate:a?jc(a):void 0}}var VR=x.createContext(void 0);function wJ(t){var e,n=t.initialProps,r=bJ(),i=kJ(n),s=i.fromDate,a=i.toDate,c=(e=n.captionLayout)!==null&&e!==void 0?e:r.captionLayout;c!=="buttons"&&(!s||!a)&&(c="buttons");var h;(Gp(n)||Rd(n)||Id(n))&&(h=n.onSelect);var d=vt(vt(vt({},r),n),{captionLayout:c,classNames:vt(vt({},r.classNames),n.classNames),components:vt({},n.components),formatters:vt(vt({},r.formatters),n.formatters),fromDate:s,labels:vt(vt({},r.labels),n.labels),mode:n.mode||r.mode,modifiers:vt(vt({},r.modifiers),n.modifiers),modifiersClassNames:vt(vt({},r.modifiersClassNames),n.modifiersClassNames),onSelect:h,styles:vt(vt({},r.styles),n.styles),toDate:a});return o.jsx(VR.Provider,{value:d,children:t.children})}function Cn(){var t=x.useContext(VR);if(!t)throw new Error("useDayPicker must be used within a DayPickerProvider.");return t}function WR(t){var e=Cn(),n=e.locale,r=e.classNames,i=e.styles,s=e.formatters.formatCaption;return o.jsx("div",{className:r.caption_label,style:i.caption_label,"aria-live":"polite",role:"presentation",id:t.id,children:s(t.displayMonth,{locale:n})})}function SJ(t){return o.jsx("svg",vt({width:"8px",height:"8px",viewBox:"0 0 120 120","data-testid":"iconDropdown"},t,{children:o.jsx("path",{d:"M4.22182541,48.2218254 C8.44222828,44.0014225 15.2388494,43.9273804 19.5496459,47.9996989 L19.7781746,48.2218254 L60,88.443 L100.221825,48.2218254 C104.442228,44.0014225 111.238849,43.9273804 115.549646,47.9996989 L115.778175,48.2218254 C119.998577,52.4422283 120.07262,59.2388494 116.000301,63.5496459 L115.778175,63.7781746 L67.7781746,111.778175 C63.5577717,115.998577 56.7611506,116.07262 52.4503541,112.000301 L52.2218254,111.778175 L4.22182541,63.7781746 C-0.0739418023,59.4824074 -0.0739418023,52.5175926 4.22182541,48.2218254 Z",fill:"currentColor",fillRule:"nonzero"})}))}function HR(t){var e,n,r=t.onChange,i=t.value,s=t.children,a=t.caption,c=t.className,h=t.style,d=Cn(),f=(n=(e=d.components)===null||e===void 0?void 0:e.IconDropdown)!==null&&n!==void 0?n:SJ;return o.jsxs("div",{className:c,style:h,children:[o.jsx("span",{className:d.classNames.vhidden,children:t["aria-label"]}),o.jsx("select",{name:t.name,"aria-label":t["aria-label"],className:d.classNames.dropdown,style:d.styles.dropdown,value:i,onChange:r,children:s}),o.jsxs("div",{className:d.classNames.caption_label,style:d.styles.caption_label,"aria-hidden":"true",children:[a,o.jsx(f,{className:d.classNames.dropdown_icon,style:d.styles.dropdown_icon})]})]})}function CJ(t){var e,n=Cn(),r=n.fromDate,i=n.toDate,s=n.styles,a=n.locale,c=n.formatters.formatMonthCaption,h=n.classNames,d=n.components,f=n.labels.labelMonthDropdown;if(!r)return o.jsx(o.Fragment,{});if(!i)return o.jsx(o.Fragment,{});var p=[];if(nJ(r,i))for(var g=Zr(r),v=r.getMonth();v<=i.getMonth();v++)p.push(B0(g,v));else for(var g=Zr(new Date),v=0;v<=11;v++)p.push(B0(g,v));var k=function(S){var T=Number(S.target.value),C=B0(Zr(t.displayMonth),T);t.onChange(C)},w=(e=d==null?void 0:d.Dropdown)!==null&&e!==void 0?e:HR;return o.jsx(w,{name:"months","aria-label":f(),className:h.dropdown_month,style:s.dropdown_month,onChange:k,value:t.displayMonth.getMonth(),caption:c(t.displayMonth,{locale:a}),children:p.map(function(S){return o.jsx("option",{value:S.getMonth(),children:c(S,{locale:a})},S.getMonth())})})}function TJ(t){var e,n=t.displayMonth,r=Cn(),i=r.fromDate,s=r.toDate,a=r.locale,c=r.styles,h=r.classNames,d=r.components,f=r.formatters.formatYearCaption,p=r.labels.labelYearDropdown,g=[];if(!i)return o.jsx(o.Fragment,{});if(!s)return o.jsx(o.Fragment,{});for(var v=i.getFullYear(),k=s.getFullYear(),w=v;w<=k;w++)g.push(PT(DR(new Date),w));var S=function(C){var j=PT(Zr(n),Number(C.target.value));t.onChange(j)},T=(e=d==null?void 0:d.Dropdown)!==null&&e!==void 0?e:HR;return o.jsx(T,{name:"years","aria-label":p(),className:h.dropdown_year,style:c.dropdown_year,onChange:S,value:n.getFullYear(),caption:f(n,{locale:a}),children:g.map(function(C){return o.jsx("option",{value:C.getFullYear(),children:f(C,{locale:a})},C.getFullYear())})})}function NJ(t,e){var n=x.useState(t),r=n[0],i=n[1],s=e===void 0?r:e;return[s,i]}function EJ(t){var e=t.month,n=t.defaultMonth,r=t.today,i=e||n||r||new Date,s=t.toDate,a=t.fromDate,c=t.numberOfMonths,h=c===void 0?1:c;if(s&&vd(s,i)<0){var d=-1*(h-1);i=as(s,d)}return a&&vd(i,a)<0&&(i=a),Zr(i)}function jJ(){var t=Cn(),e=EJ(t),n=NJ(e,t.month),r=n[0],i=n[1],s=function(a){var c;if(!t.disableNavigation){var h=Zr(a);i(h),(c=t.onMonthChange)===null||c===void 0||c.call(t,h)}};return[r,s]}function PJ(t,e){for(var n=e.reverseMonths,r=e.numberOfMonths,i=Zr(t),s=Zr(as(i,r)),a=vd(s,i),c=[],h=0;h<a;h++){var d=as(i,h);c.push(d)}return n&&(c=c.reverse()),c}function _J(t,e){if(!e.disableNavigation){var n=e.toDate,r=e.pagedNavigation,i=e.numberOfMonths,s=i===void 0?1:i,a=r?s:1,c=Zr(t);if(!n)return as(c,a);var h=vd(n,t);if(!(h<s))return as(c,a)}}function RJ(t,e){if(!e.disableNavigation){var n=e.fromDate,r=e.pagedNavigation,i=e.numberOfMonths,s=i===void 0?1:i,a=r?s:1,c=Zr(t);if(!n)return as(c,-a);var h=vd(c,n);if(!(h<=0))return as(c,-a)}}var qR=x.createContext(void 0);function IJ(t){var e=Cn(),n=jJ(),r=n[0],i=n[1],s=PJ(r,e),a=_J(r,e),c=RJ(r,e),h=function(p){return s.some(function(g){return nb(p,g)})},d=function(p,g){h(p)||(g&&zR(p,g)?i(as(p,1+e.numberOfMonths*-1)):i(p))},f={currentMonth:r,displayMonths:s,goToMonth:i,goToDate:d,previousMonth:c,nextMonth:a,isDateDisplayed:h};return o.jsx(qR.Provider,{value:f,children:t.children})}function Md(){var t=x.useContext(qR);if(!t)throw new Error("useNavigation must be used within a NavigationProvider");return t}function _T(t){var e,n=Cn(),r=n.classNames,i=n.styles,s=n.components,a=Md().goToMonth,c=function(f){a(as(f,t.displayIndex?-t.displayIndex:0))},h=(e=s==null?void 0:s.CaptionLabel)!==null&&e!==void 0?e:WR,d=o.jsx(h,{id:t.id,displayMonth:t.displayMonth});return o.jsxs("div",{className:r.caption_dropdowns,style:i.caption_dropdowns,children:[o.jsx("div",{className:r.vhidden,children:d}),o.jsx(CJ,{onChange:c,displayMonth:t.displayMonth}),o.jsx(TJ,{onChange:c,displayMonth:t.displayMonth})]})}function MJ(t){return o.jsx("svg",vt({width:"16px",height:"16px",viewBox:"0 0 120 120"},t,{children:o.jsx("path",{d:"M69.490332,3.34314575 C72.6145263,0.218951416 77.6798462,0.218951416 80.8040405,3.34314575 C83.8617626,6.40086786 83.9268205,11.3179931 80.9992143,14.4548388 L80.8040405,14.6568542 L35.461,60 L80.8040405,105.343146 C83.8617626,108.400868 83.9268205,113.317993 80.9992143,116.454839 L80.8040405,116.656854 C77.7463184,119.714576 72.8291931,119.779634 69.6923475,116.852028 L69.490332,116.656854 L18.490332,65.6568542 C15.4326099,62.5991321 15.367552,57.6820069 18.2951583,54.5451612 L18.490332,54.3431458 L69.490332,3.34314575 Z",fill:"currentColor",fillRule:"nonzero"})}))}function DJ(t){return o.jsx("svg",vt({width:"16px",height:"16px",viewBox:"0 0 120 120"},t,{children:o.jsx("path",{d:"M49.8040405,3.34314575 C46.6798462,0.218951416 41.6145263,0.218951416 38.490332,3.34314575 C35.4326099,6.40086786 35.367552,11.3179931 38.2951583,14.4548388 L38.490332,14.6568542 L83.8333725,60 L38.490332,105.343146 C35.4326099,108.400868 35.367552,113.317993 38.2951583,116.454839 L38.490332,116.656854 C41.5480541,119.714576 46.4651794,119.779634 49.602025,116.852028 L49.8040405,116.656854 L100.804041,65.6568542 C103.861763,62.5991321 103.926821,57.6820069 100.999214,54.5451612 L100.804041,54.3431458 L49.8040405,3.34314575 Z",fill:"currentColor"})}))}var cp=x.forwardRef(function(t,e){var n=Cn(),r=n.classNames,i=n.styles,s=[r.button_reset,r.button];t.className&&s.push(t.className);var a=s.join(" "),c=vt(vt({},i.button_reset),i.button);return t.style&&Object.assign(c,t.style),o.jsx("button",vt({},t,{ref:e,type:"button",className:a,style:c}))});function AJ(t){var e,n,r=Cn(),i=r.dir,s=r.locale,a=r.classNames,c=r.styles,h=r.labels,d=h.labelPrevious,f=h.labelNext,p=r.components;if(!t.nextMonth&&!t.previousMonth)return o.jsx(o.Fragment,{});var g=d(t.previousMonth,{locale:s}),v=[a.nav_button,a.nav_button_previous].join(" "),k=f(t.nextMonth,{locale:s}),w=[a.nav_button,a.nav_button_next].join(" "),S=(e=p==null?void 0:p.IconRight)!==null&&e!==void 0?e:DJ,T=(n=p==null?void 0:p.IconLeft)!==null&&n!==void 0?n:MJ;return o.jsxs("div",{className:a.nav,style:c.nav,children:[!t.hidePrevious&&o.jsx(cp,{name:"previous-month","aria-label":g,className:v,style:c.nav_button_previous,disabled:!t.previousMonth,onClick:t.onPreviousClick,children:i==="rtl"?o.jsx(S,{className:a.nav_icon,style:c.nav_icon}):o.jsx(T,{className:a.nav_icon,style:c.nav_icon})}),!t.hideNext&&o.jsx(cp,{name:"next-month","aria-label":k,className:w,style:c.nav_button_next,disabled:!t.nextMonth,onClick:t.onNextClick,children:i==="rtl"?o.jsx(T,{className:a.nav_icon,style:c.nav_icon}):o.jsx(S,{className:a.nav_icon,style:c.nav_icon})})]})}function RT(t){var e=Cn().numberOfMonths,n=Md(),r=n.previousMonth,i=n.nextMonth,s=n.goToMonth,a=n.displayMonths,c=a.findIndex(function(k){return nb(t.displayMonth,k)}),h=c===0,d=c===a.length-1,f=e>1&&(h||!d),p=e>1&&(d||!h),g=function(){r&&s(r)},v=function(){i&&s(i)};return o.jsx(AJ,{displayMonth:t.displayMonth,hideNext:f,hidePrevious:p,nextMonth:i,previousMonth:r,onPreviousClick:g,onNextClick:v})}function OJ(t){var e,n=Cn(),r=n.classNames,i=n.disableNavigation,s=n.styles,a=n.captionLayout,c=n.components,h=(e=c==null?void 0:c.CaptionLabel)!==null&&e!==void 0?e:WR,d;return i?d=o.jsx(h,{id:t.id,displayMonth:t.displayMonth}):a==="dropdown"?d=o.jsx(_T,{displayMonth:t.displayMonth,id:t.id}):a==="dropdown-buttons"?d=o.jsxs(o.Fragment,{children:[o.jsx(_T,{displayMonth:t.displayMonth,displayIndex:t.displayIndex,id:t.id}),o.jsx(RT,{displayMonth:t.displayMonth,displayIndex:t.displayIndex,id:t.id})]}):d=o.jsxs(o.Fragment,{children:[o.jsx(h,{id:t.id,displayMonth:t.displayMonth,displayIndex:t.displayIndex}),o.jsx(RT,{displayMonth:t.displayMonth,id:t.id})]}),o.jsx("div",{className:r.caption,style:s.caption,children:d})}function LJ(t){var e=Cn(),n=e.footer,r=e.styles,i=e.classNames.tfoot;return n?o.jsx("tfoot",{className:i,style:r.tfoot,children:o.jsx("tr",{children:o.jsx("td",{colSpan:8,children:n})})}):o.jsx(o.Fragment,{})}function FJ(t,e,n){for(var r=n?gl(new Date):Fs(new Date,{locale:t,weekStartsOn:e}),i=[],s=0;s<7;s++){var a=Ir(r,s);i.push(a)}return i}function UJ(){var t=Cn(),e=t.classNames,n=t.styles,r=t.showWeekNumber,i=t.locale,s=t.weekStartsOn,a=t.ISOWeek,c=t.formatters.formatWeekdayName,h=t.labels.labelWeekday,d=FJ(i,s,a);return o.jsxs("tr",{style:n.head_row,className:e.head_row,children:[r&&o.jsx("td",{style:n.head_cell,className:e.head_cell}),d.map(function(f,p){return o.jsx("th",{scope:"col",className:e.head_cell,style:n.head_cell,"aria-label":h(f,{locale:i}),children:c(f,{locale:i})},p)})]})}function BJ(){var t,e=Cn(),n=e.classNames,r=e.styles,i=e.components,s=(t=i==null?void 0:i.HeadRow)!==null&&t!==void 0?t:UJ;return o.jsx("thead",{style:r.head,className:n.head,children:o.jsx(s,{})})}function zJ(t){var e=Cn(),n=e.locale,r=e.formatters.formatDay;return o.jsx(o.Fragment,{children:r(t.date,{locale:n})})}var rb=x.createContext(void 0);function $J(t){if(!Rd(t.initialProps)){var e={selected:void 0,modifiers:{disabled:[]}};return o.jsx(rb.Provider,{value:e,children:t.children})}return o.jsx(VJ,{initialProps:t.initialProps,children:t.children})}function VJ(t){var e=t.initialProps,n=t.children,r=e.selected,i=e.min,s=e.max,a=function(d,f,p){var g,v;(g=e.onDayClick)===null||g===void 0||g.call(e,d,f,p);var k=!!(f.selected&&i&&(r==null?void 0:r.length)===i);if(!k){var w=!!(!f.selected&&s&&(r==null?void 0:r.length)===s);if(!w){var S=r?$R([],r):[];if(f.selected){var T=S.findIndex(function(C){return Xr(d,C)});S.splice(T,1)}else S.push(d);(v=e.onSelect)===null||v===void 0||v.call(e,S,d,f,p)}}},c={disabled:[]};r&&c.disabled.push(function(d){var f=s&&r.length>s-1,p=r.some(function(g){return Xr(g,d)});return!!(f&&!p)});var h={selected:r,onDayClick:a,modifiers:c};return o.jsx(rb.Provider,{value:h,children:n})}function ib(){var t=x.useContext(rb);if(!t)throw new Error("useSelectMultiple must be used within a SelectMultipleProvider");return t}function WJ(t,e){var n=e||{},r=n.from,i=n.to;return r&&i?Xr(i,t)&&Xr(r,t)?void 0:Xr(i,t)?{from:i,to:void 0}:Xr(r,t)?void 0:sy(r,t)?{from:t,to:i}:{from:r,to:t}:i?sy(t,i)?{from:i,to:t}:{from:t,to:i}:r?zR(t,r)?{from:t,to:r}:{from:r,to:t}:{from:t,to:void 0}}var sb=x.createContext(void 0);function HJ(t){if(!Id(t.initialProps)){var e={selected:void 0,modifiers:{range_start:[],range_end:[],range_middle:[],disabled:[]}};return o.jsx(sb.Provider,{value:e,children:t.children})}return o.jsx(qJ,{initialProps:t.initialProps,children:t.children})}function qJ(t){var e=t.initialProps,n=t.children,r=e.selected,i=r||{},s=i.from,a=i.to,c=e.min,h=e.max,d=function(v,k,w){var S,T;(S=e.onDayClick)===null||S===void 0||S.call(e,v,k,w);var C=WJ(v,r);(T=e.onSelect)===null||T===void 0||T.call(e,C,v,k,w)},f={range_start:[],range_end:[],range_middle:[],disabled:[]};if(s?(f.range_start=[s],a?(f.range_end=[a],Xr(s,a)||(f.range_middle=[{after:s,before:a}])):f.range_end=[s]):a&&(f.range_start=[a],f.range_end=[a]),c&&(s&&!a&&f.disabled.push({after:U0(s,c-1),before:Ir(s,c-1)}),s&&a&&f.disabled.push({after:s,before:Ir(s,c-1)}),!s&&a&&f.disabled.push({after:U0(a,c-1),before:Ir(a,c-1)})),h){if(s&&!a&&(f.disabled.push({before:Ir(s,-h+1)}),f.disabled.push({after:Ir(s,h-1)})),s&&a){var p=ks(a,s)+1,g=h-p;f.disabled.push({before:U0(s,g)}),f.disabled.push({after:Ir(a,g)})}!s&&a&&(f.disabled.push({before:Ir(a,-h+1)}),f.disabled.push({after:Ir(a,h-1)}))}return o.jsx(sb.Provider,{value:{selected:r,onDayClick:d,modifiers:f},children:n})}function ab(){var t=x.useContext(sb);if(!t)throw new Error("useSelectRange must be used within a SelectRangeProvider");return t}function Pf(t){return Array.isArray(t)?$R([],t):t!==void 0?[t]:[]}function KJ(t){var e={};return Object.entries(t).forEach(function(n){var r=n[0],i=n[1];e[r]=Pf(i)}),e}var os;(function(t){t.Outside="outside",t.Disabled="disabled",t.Selected="selected",t.Hidden="hidden",t.Today="today",t.RangeStart="range_start",t.RangeEnd="range_end",t.RangeMiddle="range_middle"})(os||(os={}));var GJ=os.Selected,ra=os.Disabled,YJ=os.Hidden,JJ=os.Today,z0=os.RangeEnd,$0=os.RangeMiddle,V0=os.RangeStart,XJ=os.Outside;function QJ(t,e,n){var r,i=(r={},r[GJ]=Pf(t.selected),r[ra]=Pf(t.disabled),r[YJ]=Pf(t.hidden),r[JJ]=[t.today],r[z0]=[],r[$0]=[],r[V0]=[],r[XJ]=[],r);return t.fromDate&&i[ra].push({before:t.fromDate}),t.toDate&&i[ra].push({after:t.toDate}),Rd(t)?i[ra]=i[ra].concat(e.modifiers[ra]):Id(t)&&(i[ra]=i[ra].concat(n.modifiers[ra]),i[V0]=n.modifiers[V0],i[$0]=n.modifiers[$0],i[z0]=n.modifiers[z0]),i}var KR=x.createContext(void 0);function ZJ(t){var e=Cn(),n=ib(),r=ab(),i=QJ(e,n,r),s=KJ(e.modifiers),a=vt(vt({},i),s);return o.jsx(KR.Provider,{value:a,children:t.children})}function GR(){var t=x.useContext(KR);if(!t)throw new Error("useModifiers must be used within a ModifiersProvider");return t}function eX(t){return!!(t&&typeof t=="object"&&"before"in t&&"after"in t)}function tX(t){return!!(t&&typeof t=="object"&&"from"in t)}function nX(t){return!!(t&&typeof t=="object"&&"after"in t)}function rX(t){return!!(t&&typeof t=="object"&&"before"in t)}function iX(t){return!!(t&&typeof t=="object"&&"dayOfWeek"in t)}function sX(t,e){var n,r=e.from,i=e.to;if(r&&i){var s=ks(i,r)<0;s&&(n=[i,r],r=n[0],i=n[1]);var a=ks(t,r)>=0&&ks(i,t)>=0;return a}return i?Xr(i,t):r?Xr(r,t):!1}function aX(t){return Zx(t)}function oX(t){return Array.isArray(t)&&t.every(Zx)}function lX(t,e){return e.some(function(n){if(typeof n=="boolean")return n;if(aX(n))return Xr(t,n);if(oX(n))return n.includes(t);if(tX(n))return sX(t,n);if(iX(n))return n.dayOfWeek.includes(t.getDay());if(eX(n)){var r=ks(n.before,t),i=ks(n.after,t),s=r>0,a=i<0,c=sy(n.before,n.after);return c?a&&s:s||a}return nX(n)?ks(t,n.after)>0:rX(n)?ks(n.before,t)>0:typeof n=="function"?n(t):!1})}function ob(t,e,n){var r=Object.keys(e).reduce(function(s,a){var c=e[a];return lX(t,c)&&s.push(a),s},[]),i={};return r.forEach(function(s){return i[s]=!0}),n&&!nb(t,n)&&(i.outside=!0),i}function cX(t,e){for(var n=Zr(t[0]),r=eb(t[t.length-1]),i,s,a=n;a<=r;){var c=ob(a,e),h=!c.disabled&&!c.hidden;if(!h){a=Ir(a,1);continue}if(c.selected)return a;c.today&&!s&&(s=a),i||(i=a),a=Ir(a,1)}return s||i}var uX=365;function YR(t,e){var n=e.moveBy,r=e.direction,i=e.context,s=e.modifiers,a=e.retry,c=a===void 0?{count:0,lastFocused:t}:a,h=i.weekStartsOn,d=i.fromDate,f=i.toDate,p=i.locale,g={day:Ir,week:iy,month:as,year:QG,startOfWeek:function(S){return i.ISOWeek?gl(S):Fs(S,{locale:p,weekStartsOn:h})},endOfWeek:function(S){return i.ISOWeek?AR(S):tb(S,{locale:p,weekStartsOn:h})}},v=g[n](t,r==="after"?1:-1);r==="before"&&d?v=ZG([d,v]):r==="after"&&f&&(v=eY([f,v]));var k=!0;if(s){var w=ob(v,s);k=!w.disabled&&!w.hidden}return k?v:c.count>uX?c.lastFocused:YR(v,{moveBy:n,direction:r,context:i,modifiers:s,retry:vt(vt({},c),{count:c.count+1})})}var JR=x.createContext(void 0);function dX(t){var e=Md(),n=GR(),r=x.useState(),i=r[0],s=r[1],a=x.useState(),c=a[0],h=a[1],d=cX(e.displayMonths,n),f=i??(c&&e.isDateDisplayed(c))?c:d,p=function(){h(i),s(void 0)},g=function(S){s(S)},v=Cn(),k=function(S,T){if(i){var C=YR(i,{moveBy:S,direction:T,context:v,modifiers:n});Xr(i,C)||(e.goToDate(C,i),g(C))}},w={focusedDay:i,focusTarget:f,blur:p,focus:g,focusDayAfter:function(){return k("day","after")},focusDayBefore:function(){return k("day","before")},focusWeekAfter:function(){return k("week","after")},focusWeekBefore:function(){return k("week","before")},focusMonthBefore:function(){return k("month","before")},focusMonthAfter:function(){return k("month","after")},focusYearBefore:function(){return k("year","before")},focusYearAfter:function(){return k("year","after")},focusStartOfWeek:function(){return k("startOfWeek","before")},focusEndOfWeek:function(){return k("endOfWeek","after")}};return o.jsx(JR.Provider,{value:w,children:t.children})}function lb(){var t=x.useContext(JR);if(!t)throw new Error("useFocusContext must be used within a FocusProvider");return t}function hX(t,e){var n=GR(),r=ob(t,n,e);return r}var cb=x.createContext(void 0);function fX(t){if(!Gp(t.initialProps)){var e={selected:void 0};return o.jsx(cb.Provider,{value:e,children:t.children})}return o.jsx(pX,{initialProps:t.initialProps,children:t.children})}function pX(t){var e=t.initialProps,n=t.children,r=function(s,a,c){var h,d,f;if((h=e.onDayClick)===null||h===void 0||h.call(e,s,a,c),a.selected&&!e.required){(d=e.onSelect)===null||d===void 0||d.call(e,void 0,s,a,c);return}(f=e.onSelect)===null||f===void 0||f.call(e,s,s,a,c)},i={selected:e.selected,onDayClick:r};return o.jsx(cb.Provider,{value:i,children:n})}function XR(){var t=x.useContext(cb);if(!t)throw new Error("useSelectSingle must be used within a SelectSingleProvider");return t}function mX(t,e){var n=Cn(),r=XR(),i=ib(),s=ab(),a=lb(),c=a.focusDayAfter,h=a.focusDayBefore,d=a.focusWeekAfter,f=a.focusWeekBefore,p=a.blur,g=a.focus,v=a.focusMonthBefore,k=a.focusMonthAfter,w=a.focusYearBefore,S=a.focusYearAfter,T=a.focusStartOfWeek,C=a.focusEndOfWeek,j=function(Z){var D,ne,A,z;Gp(n)?(D=r.onDayClick)===null||D===void 0||D.call(r,t,e,Z):Rd(n)?(ne=i.onDayClick)===null||ne===void 0||ne.call(i,t,e,Z):Id(n)?(A=s.onDayClick)===null||A===void 0||A.call(s,t,e,Z):(z=n.onDayClick)===null||z===void 0||z.call(n,t,e,Z)},R=function(Z){var D;g(t),(D=n.onDayFocus)===null||D===void 0||D.call(n,t,e,Z)},_=function(Z){var D;p(),(D=n.onDayBlur)===null||D===void 0||D.call(n,t,e,Z)},I=function(Z){var D;(D=n.onDayMouseEnter)===null||D===void 0||D.call(n,t,e,Z)},M=function(Z){var D;(D=n.onDayMouseLeave)===null||D===void 0||D.call(n,t,e,Z)},L=function(Z){var D;(D=n.onDayPointerEnter)===null||D===void 0||D.call(n,t,e,Z)},$=function(Z){var D;(D=n.onDayPointerLeave)===null||D===void 0||D.call(n,t,e,Z)},E=function(Z){var D;(D=n.onDayTouchCancel)===null||D===void 0||D.call(n,t,e,Z)},P=function(Z){var D;(D=n.onDayTouchEnd)===null||D===void 0||D.call(n,t,e,Z)},V=function(Z){var D;(D=n.onDayTouchMove)===null||D===void 0||D.call(n,t,e,Z)},F=function(Z){var D;(D=n.onDayTouchStart)===null||D===void 0||D.call(n,t,e,Z)},K=function(Z){var D;(D=n.onDayKeyUp)===null||D===void 0||D.call(n,t,e,Z)},J=function(Z){var D;switch(Z.key){case"ArrowLeft":Z.preventDefault(),Z.stopPropagation(),n.dir==="rtl"?c():h();break;case"ArrowRight":Z.preventDefault(),Z.stopPropagation(),n.dir==="rtl"?h():c();break;case"ArrowDown":Z.preventDefault(),Z.stopPropagation(),d();break;case"ArrowUp":Z.preventDefault(),Z.stopPropagation(),f();break;case"PageUp":Z.preventDefault(),Z.stopPropagation(),Z.shiftKey?w():v();break;case"PageDown":Z.preventDefault(),Z.stopPropagation(),Z.shiftKey?S():k();break;case"Home":Z.preventDefault(),Z.stopPropagation(),T();break;case"End":Z.preventDefault(),Z.stopPropagation(),C();break}(D=n.onDayKeyDown)===null||D===void 0||D.call(n,t,e,Z)},Q={onClick:j,onFocus:R,onBlur:_,onKeyDown:J,onKeyUp:K,onMouseEnter:I,onMouseLeave:M,onPointerEnter:L,onPointerLeave:$,onTouchCancel:E,onTouchEnd:P,onTouchMove:V,onTouchStart:F};return Q}function gX(){var t=Cn(),e=XR(),n=ib(),r=ab(),i=Gp(t)?e.selected:Rd(t)?n.selected:Id(t)?r.selected:void 0;return i}function vX(t){return Object.values(os).includes(t)}function yX(t,e){var n=[t.classNames.day];return Object.keys(e).forEach(function(r){var i=t.modifiersClassNames[r];if(i)n.push(i);else if(vX(r)){var s=t.classNames["day_".concat(r)];s&&n.push(s)}}),n}function xX(t,e){var n=vt({},t.styles.day);return Object.keys(e).forEach(function(r){var i;n=vt(vt({},n),(i=t.modifiersStyles)===null||i===void 0?void 0:i[r])}),n}function bX(t,e,n){var r,i,s,a=Cn(),c=lb(),h=hX(t,e),d=mX(t,h),f=gX(),p=!!(a.onDayClick||a.mode!=="default");x.useEffect(function(){var I;h.outside||c.focusedDay&&p&&Xr(c.focusedDay,t)&&((I=n.current)===null||I===void 0||I.focus())},[c.focusedDay,t,n,p,h.outside]);var g=yX(a,h).join(" "),v=xX(a,h),k=!!(h.outside&&!a.showOutsideDays||h.hidden),w=(s=(i=a.components)===null||i===void 0?void 0:i.DayContent)!==null&&s!==void 0?s:zJ,S=o.jsx(w,{date:t,displayMonth:e,activeModifiers:h}),T={style:v,className:g,children:S,role:"gridcell"},C=c.focusTarget&&Xr(c.focusTarget,t)&&!h.outside,j=c.focusedDay&&Xr(c.focusedDay,t),R=vt(vt(vt({},T),(r={disabled:h.disabled,role:"gridcell"},r["aria-selected"]=h.selected,r.tabIndex=j||C?0:-1,r)),d),_={isButton:p,isHidden:k,activeModifiers:h,selectedDays:f,buttonProps:R,divProps:T};return _}function kX(t){var e=x.useRef(null),n=bX(t.date,t.displayMonth,e);return n.isHidden?o.jsx("div",{role:"gridcell"}):n.isButton?o.jsx(cp,vt({name:"day",ref:e},n.buttonProps)):o.jsx("div",vt({},n.divProps))}function wX(t){var e=t.number,n=t.dates,r=Cn(),i=r.onWeekNumberClick,s=r.styles,a=r.classNames,c=r.locale,h=r.labels.labelWeekNumber,d=r.formatters.formatWeekNumber,f=d(Number(e),{locale:c});if(!i)return o.jsx("span",{className:a.weeknumber,style:s.weeknumber,children:f});var p=h(Number(e),{locale:c}),g=function(v){i(e,n,v)};return o.jsx(cp,{name:"week-number","aria-label":p,className:a.weeknumber,style:s.weeknumber,onClick:g,children:f})}function SX(t){var e,n,r=Cn(),i=r.styles,s=r.classNames,a=r.showWeekNumber,c=r.components,h=(e=c==null?void 0:c.Day)!==null&&e!==void 0?e:kX,d=(n=c==null?void 0:c.WeekNumber)!==null&&n!==void 0?n:wX,f;return a&&(f=o.jsx("td",{className:s.cell,style:i.cell,children:o.jsx(d,{number:t.weekNumber,dates:t.dates})})),o.jsxs("tr",{className:s.row,style:i.row,children:[f,t.dates.map(function(p){return o.jsx("td",{className:s.cell,style:i.cell,role:"presentation",children:o.jsx(h,{displayMonth:t.displayMonth,date:p})},ZY(p))})]})}function IT(t,e,n){for(var r=n!=null&&n.ISOWeek?AR(e):tb(e,n),i=n!=null&&n.ISOWeek?gl(t):Fs(t,n),s=ks(r,i),a=[],c=0;c<=s;c++)a.push(Ir(i,c));var h=a.reduce(function(d,f){var p=n!=null&&n.ISOWeek?LR(f):UR(f,n),g=d.find(function(v){return v.weekNumber===p});return g?(g.dates.push(f),d):(d.push({weekNumber:p,dates:[f]}),d)},[]);return h}function CX(t,e){var n=IT(Zr(t),eb(t),e);if(e!=null&&e.useFixedWeeks){var r=tJ(t,e);if(r<6){var i=n[n.length-1],s=i.dates[i.dates.length-1],a=iy(s,6-r),c=IT(iy(s,1),a,e);n.push.apply(n,c)}}return n}function TX(t){var e,n,r,i=Cn(),s=i.locale,a=i.classNames,c=i.styles,h=i.hideHead,d=i.fixedWeeks,f=i.components,p=i.weekStartsOn,g=i.firstWeekContainsDate,v=i.ISOWeek,k=CX(t.displayMonth,{useFixedWeeks:!!d,ISOWeek:v,locale:s,weekStartsOn:p,firstWeekContainsDate:g}),w=(e=f==null?void 0:f.Head)!==null&&e!==void 0?e:BJ,S=(n=f==null?void 0:f.Row)!==null&&n!==void 0?n:SX,T=(r=f==null?void 0:f.Footer)!==null&&r!==void 0?r:LJ;return o.jsxs("table",{id:t.id,className:a.table,style:c.table,role:"grid","aria-labelledby":t["aria-labelledby"],children:[!h&&o.jsx(w,{}),o.jsx("tbody",{className:a.tbody,style:c.tbody,children:k.map(function(C){return o.jsx(S,{displayMonth:t.displayMonth,dates:C.dates,weekNumber:C.weekNumber},C.weekNumber)})}),o.jsx(T,{displayMonth:t.displayMonth})]})}function NX(){return!!(typeof window<"u"&&window.document&&window.document.createElement)}var EX=NX()?x.useLayoutEffect:x.useEffect,W0=!1,jX=0;function MT(){return"react-day-picker-".concat(++jX)}function PX(t){var e,n=t??(W0?MT():null),r=x.useState(n),i=r[0],s=r[1];return EX(function(){i===null&&s(MT())},[]),x.useEffect(function(){W0===!1&&(W0=!0)},[]),(e=t??i)!==null&&e!==void 0?e:void 0}function _X(t){var e,n,r=Cn(),i=r.dir,s=r.classNames,a=r.styles,c=r.components,h=Md().displayMonths,d=PX(r.id?"".concat(r.id,"-").concat(t.displayIndex):void 0),f=r.id?"".concat(r.id,"-grid-").concat(t.displayIndex):void 0,p=[s.month],g=a.month,v=t.displayIndex===0,k=t.displayIndex===h.length-1,w=!v&&!k;i==="rtl"&&(e=[v,k],k=e[0],v=e[1]),v&&(p.push(s.caption_start),g=vt(vt({},g),a.caption_start)),k&&(p.push(s.caption_end),g=vt(vt({},g),a.caption_end)),w&&(p.push(s.caption_between),g=vt(vt({},g),a.caption_between));var S=(n=c==null?void 0:c.Caption)!==null&&n!==void 0?n:OJ;return o.jsxs("div",{className:p.join(" "),style:g,children:[o.jsx(S,{id:d,displayMonth:t.displayMonth,displayIndex:t.displayIndex}),o.jsx(TX,{id:f,"aria-labelledby":d,displayMonth:t.displayMonth})]},t.displayIndex)}function RX(t){var e=Cn(),n=e.classNames,r=e.styles;return o.jsx("div",{className:n.months,style:r.months,children:t.children})}function IX(t){var e,n,r=t.initialProps,i=Cn(),s=lb(),a=Md(),c=x.useState(!1),h=c[0],d=c[1];x.useEffect(function(){i.initialFocus&&s.focusTarget&&(h||(s.focus(s.focusTarget),d(!0)))},[i.initialFocus,h,s.focus,s.focusTarget,s]);var f=[i.classNames.root,i.className];i.numberOfMonths>1&&f.push(i.classNames.multiple_months),i.showWeekNumber&&f.push(i.classNames.with_weeknumber);var p=vt(vt({},i.styles.root),i.style),g=Object.keys(r).filter(function(k){return k.startsWith("data-")}).reduce(function(k,w){var S;return vt(vt({},k),(S={},S[w]=r[w],S))},{}),v=(n=(e=r.components)===null||e===void 0?void 0:e.Months)!==null&&n!==void 0?n:RX;return o.jsx("div",vt({className:f.join(" "),style:p,dir:i.dir,id:i.id,nonce:r.nonce,title:r.title,lang:r.lang},g,{children:o.jsx(v,{children:a.displayMonths.map(function(k,w){return o.jsx(_X,{displayIndex:w,displayMonth:k},w)})})}))}function MX(t){var e=t.children,n=rJ(t,["children"]);return o.jsx(wJ,{initialProps:n,children:o.jsx(IJ,{children:o.jsx(fX,{initialProps:n,children:o.jsx($J,{initialProps:n,children:o.jsx(HJ,{initialProps:n,children:o.jsx(ZJ,{children:o.jsx(dX,{children:e})})})})})})})}function DX(t){return o.jsx(MX,vt({},t,{children:o.jsx(IX,{initialProps:t})}))}function AX({className:t,classNames:e,showOutsideDays:n=!0,...r}){return o.jsx(DX,{showOutsideDays:n,className:St("p-3",t),classNames:{months:"flex flex-col sm:flex-row gap-2",month:"flex flex-col gap-4",caption:"flex justify-center pt-1 relative items-center w-full",caption_label:"text-sm font-medium",nav:"flex items-center gap-1",nav_button:St(id({variant:"outline"}),"size-7 bg-transparent p-0 opacity-50 hover:opacity-100"),nav_button_previous:"absolute left-1",nav_button_next:"absolute right-1",table:"w-full border-collapse space-x-1",head_row:"flex",head_cell:"text-muted-foreground rounded-md w-8 font-normal text-[0.8rem]",row:"flex w-full mt-2",cell:St("relative p-0 text-center text-sm focus-within:relative focus-within:z-20 [&:has([aria-selected])]:bg-accent [&:has([aria-selected].day-range-end)]:rounded-r-md",r.mode==="range"?"[&:has(>.day-range-end)]:rounded-r-md [&:has(>.day-range-start)]:rounded-l-md first:[&:has([aria-selected])]:rounded-l-md last:[&:has([aria-selected])]:rounded-r-md":"[&:has([aria-selected])]:rounded-md"),day:St(id({variant:"ghost"}),"size-8 p-0 font-normal aria-selected:opacity-100"),day_range_start:"day-range-start aria-selected:bg-primary aria-selected:text-primary-foreground",day_range_end:"day-range-end aria-selected:bg-primary aria-selected:text-primary-foreground",day_selected:"bg-primary text-primary-foreground hover:bg-primary hover:text-primary-foreground focus:bg-primary focus:text-primary-foreground",day_today:"bg-accent text-accent-foreground",day_outside:"day-outside text-muted-foreground aria-selected:text-muted-foreground",day_disabled:"text-muted-foreground opacity-50",day_range_middle:"aria-selected:bg-accent aria-selected:text-accent-foreground",day_hidden:"invisible",...e},components:{IconLeft:({className:i,...s})=>o.jsx(bN,{className:St("size-4",i),...s}),IconRight:({className:i,...s})=>o.jsx(fp,{className:St("size-4",i),...s})},...r})}const Mu=["UTC","America/New_York","America/Chicago","America/Denver","America/Los_Angeles","America/Toronto","America/Sao_Paulo","Europe/London","Europe/Paris","Europe/Berlin","Europe/Moscow","Asia/Dubai","Asia/Karachi","Asia/Kolkata","Asia/Shanghai","Asia/Tokyo","Asia/Singapore","Australia/Sydney","Pacific/Auckland"],QR=[{label:"Mon",value:1},{label:"Tue",value:2},{label:"Wed",value:3},{label:"Thu",value:4},{label:"Fri",value:5},{label:"Sat",value:6},{label:"Sun",value:0}];function OX(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return"UTC"}}function DT(t){return t.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}function ay({value:t,onChange:e,showOnce:n=!0,defaultMode:r="recurring",className:i}){const[s,a]=x.useState(r),[c,h]=x.useState("daily"),[d,f]=x.useState(void 0),[p,g]=x.useState(!0),[v,k]=x.useState("09:00"),[w,S]=x.useState(t.timezone||OX()),[T,C]=x.useState([1]),[j,R]=x.useState("1"),[_,I]=x.useState("4"),[M,L]=x.useState("h"),[$,E]=x.useState(t.cronExpression||"");return x.useEffect(()=>{if(t.at){a("once");try{const P=new Date(t.at);f(P),k(`${String(P.getHours()).padStart(2,"0")}:${String(P.getMinutes()).padStart(2,"0")}`)}catch{}}else if(t.every){a("recurring"),h("hourly");const P=t.every.match(/^(\d+)(s|m|h|d)$/);P&&(I(P[1]),L(P[2]))}else if(t.cronExpression){const P=FX(t.cronExpression);P?(a("recurring"),h(P.frequency),P.time&&k(P.time),P.days&&C(P.days),P.monthDay&&R(P.monthDay),P.intervalValue&&I(P.intervalValue),P.intervalUnit&&L(P.intervalUnit)):(a("advanced"),E(t.cronExpression))}t.timezone&&S(t.timezone)},[]),x.useEffect(()=>{const P={timezone:w};if(s==="once"&&d){const[V,F]=v.split(":").map(Number),K=new Date(d);K.setHours(V||0,F||0,0,0),P.at=K.toISOString()}else if(s==="recurring"){if(c==="hourly")P.every=`${_}${M}`;else if(c==="daily"){const[V,F]=v.split(":").map(Number);P.cronExpression=`${F||0} ${V||9} * * *`}else if(c==="weekly"){const[V,F]=v.split(":").map(Number),K=T.sort().join(",");P.cronExpression=`${F||0} ${V||9} * * ${K||"1"}`}else if(c==="monthly"){const[V,F]=v.split(":").map(Number);P.cronExpression=`${F||0} ${V||9} ${j||"1"} * *`}}else s==="advanced"&&(P.cronExpression=$);e(P)},[s,c,d,v,w,T,j,_,M,$]),o.jsxs("div",{className:`space-y-3 ${i||""}`,children:[o.jsxs("div",{className:"flex gap-1 p-1 bg-slate-800/50 rounded-lg",children:[n&&o.jsxs("button",{onClick:()=>a("once"),className:`flex-1 flex items-center justify-center gap-1.5 px-3 py-1.5 rounded text-xs font-medium transition-colors ${s==="once"?"bg-[#00d9ff]/20 text-[#00d9ff]":"text-gray-400 hover:text-white"}`,children:[o.jsx(x1,{className:"w-3.5 h-3.5"})," Once"]}),o.jsxs("button",{onClick:()=>a("recurring"),className:`flex-1 flex items-center justify-center gap-1.5 px-3 py-1.5 rounded text-xs font-medium transition-colors ${s==="recurring"?"bg-[#00d9ff]/20 text-[#00d9ff]":"text-gray-400 hover:text-white"}`,children:[o.jsx(NN,{className:"w-3.5 h-3.5"})," Recurring"]}),o.jsxs("button",{onClick:()=>a("advanced"),className:`flex-1 flex items-center justify-center gap-1.5 px-3 py-1.5 rounded text-xs font-medium transition-colors ${s==="advanced"?"bg-[#00d9ff]/20 text-[#00d9ff]":"text-gray-400 hover:text-white"}`,children:[o.jsx(Ny,{className:"w-3.5 h-3.5"})," Advanced"]})]}),s==="once"&&o.jsxs("div",{className:"space-y-3",children:[o.jsxs("div",{children:[o.jsx("label",{className:"text-xs text-gray-400 mb-1 block",children:"Date"}),d&&!p&&o.jsxs("button",{onClick:()=>g(!0),className:"w-full text-left text-sm text-white bg-slate-800 border border-slate-700 rounded-md px-3 py-2 flex items-center gap-2 hover:border-slate-600",children:[o.jsx(x1,{className:"w-4 h-4 text-[#00d9ff]"}),DT(d),o.jsx("span",{className:"text-[10px] text-gray-500 ml-auto",children:"click to change"})]}),p&&o.jsx("div",{className:"bg-slate-800/50 border border-slate-700 rounded-lg p-1",children:o.jsx(AX,{mode:"single",selected:d,onSelect:P=>{f(P),g(!1)},disabled:P=>P<new Date(new Date().setHours(0,0,0,0)),className:"!bg-transparent"})})]}),o.jsx("div",{className:"grid grid-cols-2 gap-3",children:o.jsxs("div",{children:[o.jsx("label",{className:"text-xs text-gray-400 mb-1 block",children:"Time"}),o.jsxs("div",{className:"flex gap-1",children:[o.jsxs(Qt,{value:v.split(":")[0],onValueChange:P=>k(`${P}:${v.split(":")[1]||"00"}`),children:[o.jsx(en,{className:"bg-slate-800 border-slate-700 text-white w-20",children:o.jsx(Zt,{})}),o.jsx(tn,{className:"bg-slate-800 border-slate-700 max-h-48",children:Array.from({length:24},(P,V)=>String(V).padStart(2,"0")).map(P=>o.jsx(st,{value:P,children:P},P))})]}),o.jsx("span",{className:"text-gray-400 self-center",children:":"}),o.jsxs(Qt,{value:v.split(":")[1]||"00",onValueChange:P=>k(`${v.split(":")[0]||"09"}:${P}`),children:[o.jsx(en,{className:"bg-slate-800 border-slate-700 text-white w-20",children:o.jsx(Zt,{})}),o.jsx(tn,{className:"bg-slate-800 border-slate-700 max-h-48",children:Array.from({length:60},(P,V)=>String(V).padStart(2,"0")).map(P=>o.jsx(st,{value:P,children:P},P))})]})]})]})}),o.jsxs("div",{children:[o.jsx("label",{className:"text-xs text-gray-400 mb-1 block",children:"Timezone"}),o.jsxs(Qt,{value:w,onValueChange:S,children:[o.jsx(en,{className:"bg-slate-800 border-slate-700 text-white",children:o.jsx(Zt,{})}),o.jsx(tn,{className:"bg-slate-800 border-slate-700 max-h-48",children:Mu.map(P=>o.jsx(st,{value:P,children:P.replace(/_/g," ")},P))})]})]}),d&&o.jsxs("p",{className:"text-[10px] text-[#00d9ff]",children:["Will run on ",DT(d)," at ",v," (",w,")"]})]}),s==="recurring"&&o.jsxs("div",{className:"space-y-3",children:[o.jsxs("div",{children:[o.jsx("label",{className:"text-xs text-gray-400 mb-1 block",children:"Frequency"}),o.jsx("div",{className:"grid grid-cols-4 gap-1",children:["hourly","daily","weekly","monthly"].map(P=>o.jsx("button",{onClick:()=>h(P),className:`px-2 py-1.5 rounded text-xs font-medium transition-colors ${c===P?"bg-[#00d9ff]/20 text-[#00d9ff] border border-[#00d9ff]/30":"bg-slate-800 text-gray-400 border border-slate-700 hover:text-white"}`,children:P.charAt(0).toUpperCase()+P.slice(1)},P))})]}),c==="hourly"&&o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"text-xs text-gray-400",children:"Every"}),o.jsx(Dt,{type:"number",min:"1",max:"720",value:_,onChange:P=>I(P.target.value),className:"w-20 bg-slate-800 border-slate-700 text-white text-center"}),o.jsxs(Qt,{value:M,onValueChange:L,children:[o.jsx(en,{className:"w-28 bg-slate-800 border-slate-700 text-white",children:o.jsx(Zt,{})}),o.jsxs(tn,{className:"bg-slate-800 border-slate-700",children:[o.jsx(st,{value:"m",children:"minutes"}),o.jsx(st,{value:"h",children:"hours"})]})]})]}),c==="daily"&&o.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[o.jsxs("div",{children:[o.jsx("label",{className:"text-xs text-gray-400 mb-1 block",children:"At"}),o.jsxs("div",{className:"flex gap-1",children:[o.jsxs(Qt,{value:v.split(":")[0],onValueChange:P=>k(`${P}:${v.split(":")[1]||"00"}`),children:[o.jsx(en,{className:"bg-slate-800 border-slate-700 text-white w-20",children:o.jsx(Zt,{})}),o.jsx(tn,{className:"bg-slate-800 border-slate-700 max-h-48",children:Array.from({length:24},(P,V)=>String(V).padStart(2,"0")).map(P=>o.jsx(st,{value:P,children:P},P))})]}),o.jsx("span",{className:"text-gray-400 self-center",children:":"}),o.jsxs(Qt,{value:v.split(":")[1]||"00",onValueChange:P=>k(`${v.split(":")[0]||"09"}:${P}`),children:[o.jsx(en,{className:"bg-slate-800 border-slate-700 text-white w-20",children:o.jsx(Zt,{})}),o.jsx(tn,{className:"bg-slate-800 border-slate-700 max-h-48",children:Array.from({length:60},(P,V)=>String(V).padStart(2,"0")).map(P=>o.jsx(st,{value:P,children:P},P))})]})]})]}),o.jsxs("div",{children:[o.jsx("label",{className:"text-xs text-gray-400 mb-1 block",children:"Timezone"}),o.jsxs(Qt,{value:w,onValueChange:S,children:[o.jsx(en,{className:"bg-slate-800 border-slate-700 text-white",children:o.jsx(Zt,{})}),o.jsx(tn,{className:"bg-slate-800 border-slate-700 max-h-48",children:Mu.map(P=>o.jsx(st,{value:P,children:P.replace(/_/g," ")},P))})]})]})]}),c==="weekly"&&o.jsxs("div",{className:"space-y-3",children:[o.jsxs("div",{children:[o.jsx("label",{className:"text-xs text-gray-400 mb-1 block",children:"Days"}),o.jsx("div",{className:"flex gap-1",children:QR.map(P=>o.jsx("button",{onClick:()=>{C(V=>V.includes(P.value)?V.filter(F=>F!==P.value):[...V,P.value])},className:`flex-1 py-1.5 rounded text-xs font-medium transition-colors ${T.includes(P.value)?"bg-[#00d9ff]/20 text-[#00d9ff] border border-[#00d9ff]/30":"bg-slate-800 text-gray-400 border border-slate-700 hover:text-white"}`,children:P.label},P.value))})]}),o.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[o.jsxs("div",{children:[o.jsx("label",{className:"text-xs text-gray-400 mb-1 block",children:"At"}),o.jsxs("div",{className:"flex gap-1",children:[o.jsxs(Qt,{value:v.split(":")[0],onValueChange:P=>k(`${P}:${v.split(":")[1]||"00"}`),children:[o.jsx(en,{className:"bg-slate-800 border-slate-700 text-white w-20",children:o.jsx(Zt,{})}),o.jsx(tn,{className:"bg-slate-800 border-slate-700 max-h-48",children:Array.from({length:24},(P,V)=>String(V).padStart(2,"0")).map(P=>o.jsx(st,{value:P,children:P},P))})]}),o.jsx("span",{className:"text-gray-400 self-center",children:":"}),o.jsxs(Qt,{value:v.split(":")[1]||"00",onValueChange:P=>k(`${v.split(":")[0]||"09"}:${P}`),children:[o.jsx(en,{className:"bg-slate-800 border-slate-700 text-white w-20",children:o.jsx(Zt,{})}),o.jsx(tn,{className:"bg-slate-800 border-slate-700 max-h-48",children:Array.from({length:60},(P,V)=>String(V).padStart(2,"0")).map(P=>o.jsx(st,{value:P,children:P},P))})]})]})]}),o.jsxs("div",{children:[o.jsx("label",{className:"text-xs text-gray-400 mb-1 block",children:"Timezone"}),o.jsxs(Qt,{value:w,onValueChange:S,children:[o.jsx(en,{className:"bg-slate-800 border-slate-700 text-white",children:o.jsx(Zt,{})}),o.jsx(tn,{className:"bg-slate-800 border-slate-700 max-h-48",children:Mu.map(P=>o.jsx(st,{value:P,children:P.replace(/_/g," ")},P))})]})]})]})]}),c==="monthly"&&o.jsx("div",{className:"space-y-3",children:o.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[o.jsxs("div",{children:[o.jsx("label",{className:"text-xs text-gray-400 mb-1 block",children:"Day of month"}),o.jsxs(Qt,{value:j,onValueChange:R,children:[o.jsx(en,{className:"bg-slate-800 border-slate-700 text-white",children:o.jsx(Zt,{})}),o.jsx(tn,{className:"bg-slate-800 border-slate-700 max-h-48",children:Array.from({length:28},(P,V)=>o.jsx(st,{value:String(V+1),children:ZR(V+1)},V+1))})]})]}),o.jsxs("div",{children:[o.jsx("label",{className:"text-xs text-gray-400 mb-1 block",children:"At"}),o.jsxs("div",{className:"flex gap-1",children:[o.jsxs(Qt,{value:v.split(":")[0],onValueChange:P=>k(`${P}:${v.split(":")[1]||"00"}`),children:[o.jsx(en,{className:"bg-slate-800 border-slate-700 text-white w-20",children:o.jsx(Zt,{})}),o.jsx(tn,{className:"bg-slate-800 border-slate-700 max-h-48",children:Array.from({length:24},(P,V)=>String(V).padStart(2,"0")).map(P=>o.jsx(st,{value:P,children:P},P))})]}),o.jsx("span",{className:"text-gray-400 self-center",children:":"}),o.jsxs(Qt,{value:v.split(":")[1]||"00",onValueChange:P=>k(`${v.split(":")[0]||"09"}:${P}`),children:[o.jsx(en,{className:"bg-slate-800 border-slate-700 text-white w-20",children:o.jsx(Zt,{})}),o.jsx(tn,{className:"bg-slate-800 border-slate-700 max-h-48",children:Array.from({length:60},(P,V)=>String(V).padStart(2,"0")).map(P=>o.jsx(st,{value:P,children:P},P))})]})]})]}),o.jsxs("div",{children:[o.jsx("label",{className:"text-xs text-gray-400 mb-1 block",children:"Timezone"}),o.jsxs(Qt,{value:w,onValueChange:S,children:[o.jsx(en,{className:"bg-slate-800 border-slate-700 text-white",children:o.jsx(Zt,{})}),o.jsx(tn,{className:"bg-slate-800 border-slate-700 max-h-48",children:Mu.map(P=>o.jsx(st,{value:P,children:P.replace(/_/g," ")},P))})]})]})]})}),o.jsx("p",{className:"text-[10px] text-[#00d9ff]",children:LX(s,c,v,w,T,j,_,M)})]}),s==="advanced"&&o.jsxs("div",{className:"space-y-2",children:[o.jsxs("div",{children:[o.jsx("label",{className:"text-xs text-gray-400 mb-1 block",children:"Cron Expression"}),o.jsx(Dt,{value:$,onChange:P=>E(P.target.value),className:"bg-slate-800 border-slate-700 text-white font-mono",placeholder:"0 9 * * *"}),o.jsx("p",{className:"text-[10px] text-gray-500 mt-1",children:'Format: minute hour day month weekday - e.g. "0 9 * * 1-5" = weekdays at 9am'})]}),o.jsxs("div",{children:[o.jsx("label",{className:"text-xs text-gray-400 mb-1 block",children:"Timezone"}),o.jsxs(Qt,{value:w,onValueChange:S,children:[o.jsx(en,{className:"bg-slate-800 border-slate-700 text-white",children:o.jsx(Zt,{})}),o.jsx(tn,{className:"bg-slate-800 border-slate-700 max-h-48",children:Mu.map(P=>o.jsx(st,{value:P,children:P.replace(/_/g," ")},P))})]})]})]})]})}function ZR(t){const e=["th","st","nd","rd"],n=t%100;return t+(e[(n-20)%10]||e[n]||e[0])}function LX(t,e,n,r,i,s,a,c){var d;if(t!=="recurring")return"";const h=((d=r.split("/").pop())==null?void 0:d.replace(/_/g," "))||r;return e==="hourly"?`Every ${a} ${c==="m"?"minute":"hour"}${Number(a)>1?"s":""}`:e==="daily"?`Every day at ${n} (${h})`:e==="weekly"?`Every ${i.sort().map(p=>{var g;return(g=QR.find(v=>v.value===p))==null?void 0:g.label}).filter(Boolean).join(", ")} at ${n} (${h})`:e==="monthly"?`${ZR(Number(s))} of every month at ${n} (${h})`:""}function FX(t){const e=t.trim().split(/\s+/);if(e.length!==5)return null;const[n,r,i,,s]=e;if(i==="*"&&s==="*"){if(r.startsWith("*/")&&n==="0")return{frequency:"hourly",intervalValue:r.slice(2),intervalUnit:"h"};if(n.startsWith("*/")&&r==="*")return{frequency:"hourly",intervalValue:n.slice(2),intervalUnit:"m"}}if(i==="*"&&s==="*"&&!n.includes("/")&&!r.includes("/"))return{frequency:"daily",time:`${r.padStart(2,"0")}:${n.padStart(2,"0")}`};if(i==="*"&&s!=="*"&&!n.includes("/")&&!r.includes("/")){const a=s.split(",").map(Number).filter(c=>!isNaN(c));return{frequency:"weekly",time:`${r.padStart(2,"0")}:${n.padStart(2,"0")}`,days:a}}return i!=="*"&&s==="*"&&!n.includes("/")&&!r.includes("/")?{frequency:"monthly",time:`${r.padStart(2,"0")}:${n.padStart(2,"0")}`,monthDay:i}:null}const nf={name:"",scheduleKind:"cron",cronExpr:"",timezone:"",everyInterval:"",atTime:"",taskInput:"",model:"",maxRetries:"0",timeoutSeconds:"7200",deliveryMode:"none"};function UX(){const[t,e]=x.useState([]),[n,r]=x.useState(null),[i,s]=x.useState([]),[a,c]=x.useState(null),[h,d]=x.useState(!0),[f,p]=x.useState(!1),[g,v]=x.useState(nf),[k,w]=x.useState("jobs"),[S,T]=x.useState([]),[C,j]=x.useState([]),[R,_]=x.useState([]),[I,M]=x.useState(""),[L,$]=x.useState({name:"",description:""}),[E,P]=x.useState(!1),[V,F]=x.useState(!1),[K,J]=x.useState(null),Q=x.useCallback(async()=>{try{const[U,ue]=await Promise.all([we("/api/cron/jobs"),we("/api/cron/status")]);U.ok&&e((await U.json()).jobs||[]),ue.ok&&r(await ue.json())}catch(U){console.error("Failed to fetch cron data",U)}finally{d(!1)}},[]),Z=x.useCallback(async U=>{try{const ue=U?`/api/cron/jobs/${U}/runs?limit=50`:"/api/cron/runs?limit=50",ke=await we(ue);ke.ok&&s((await ke.json()).runs||[])}catch(ue){console.error("Failed to fetch runs",ue)}},[]),D=x.useCallback(async()=>{try{const[U,ue]=await Promise.all([we("/api/channels/destinations"),we("/api/cron/presets")]);if(U.ok){const W=((await U.json()).destinations||[]).filter(q=>q.channelMeta).map(q=>{const fe=q.channelMeta,ve=(fe==null?void 0:fe.authorUsername)||(fe==null?void 0:fe.userName)||(fe==null?void 0:fe.username)||(fe==null?void 0:fe.chatId)||(fe==null?void 0:fe.userId)||"user";return{...q,label:q.label||`${q.channel} → ${ve}`}});T(W)}ue.ok&&_((await ue.json()).presets||[])}catch{}},[]);x.useEffect(()=>{Q()},[Q]),x.useEffect(()=>{k==="history"&&Z(a||void 0),k==="presets"&&D()},[k,a,Z,D]),x.useEffect(()=>{f&&D()},[f,D]);const ne=async()=>{if(!g.taskInput)return me.error("Task input is required");const U={name:g.name||void 0,taskInput:g.taskInput,model:g.model||void 0,maxRetries:parseInt(g.maxRetries)||0,timeoutSeconds:parseInt(g.timeoutSeconds)||7200};if(g.scheduleKind==="cron"){if(!g.cronExpr)return me.error("Cron expression is required");U.schedule={kind:"cron",expr:g.cronExpr,tz:g.timezone||null}}else if(g.scheduleKind==="every"){if(!g.everyInterval)return me.error("Interval is required");U.every=g.everyInterval}else if(g.scheduleKind==="at"){if(!g.atTime)return me.error("Date/time is required");U.at=new Date(g.atTime).toISOString()}if(g.deliveryMode==="preset"&&I)U.delivery={mode:"preset",presetId:I};else if(g.deliveryMode==="channels"&&C.length>0){const ue=C.map(ke=>{var W,q;return{tenantId:null,channel:ke.channel,userId:((W=ke.channelMeta)==null?void 0:W.userId)||((q=ke.channelMeta)==null?void 0:q.chatId)||null,channelMeta:ke.channelMeta}});U.delivery={mode:"multi",targets:ue}}else g.deliveryMode==="webhook"&&(U.delivery={mode:"webhook"});try{const ue=await we("/api/cron/jobs",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(U)});if(ue.ok)me.success("Job created"),p(!1),v(nf),Q();else{const ke=await ue.json();me.error(ke.error||"Failed to create job")}}catch{me.error("API connection error")}},A=async(U,ue)=>{try{(await we(`/api/cron/jobs/${U}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:ue})})).ok&&(me.success(ue?"Job enabled":"Job paused"),Q())}catch{me.error("Failed to update job")}},z=async U=>{try{(await we(`/api/cron/jobs/${U}`,{method:"DELETE"})).ok&&(me.success("Job deleted"),Q())}catch{me.error("Failed to delete job")}},ee=async U=>{try{(await we(`/api/cron/jobs/${U}/run`,{method:"POST"})).ok&&(me.success("Job triggered"),setTimeout(Q,2e3))}catch{me.error("Failed to trigger job")}},B=U=>{var q,fe,ve,Se;J(U.id);const ue=U.schedule.everyMs;let ke="";ue&&(ue>=864e5?ke=`${Math.round(ue/864e5)}d`:ue>=36e5?ke=`${Math.round(ue/36e5)}h`:ue>=6e4?ke=`${Math.round(ue/6e4)}m`:ke=`${Math.round(ue/1e3)}s`);const W=((q=U.delivery)==null?void 0:q.mode)==="multi"?"channels":((fe=U.delivery)==null?void 0:fe.mode)||"none";if(v({name:U.name||"",scheduleKind:U.schedule.kind,cronExpr:U.schedule.expr||"",timezone:U.schedule.tz||"",everyInterval:ke,atTime:U.schedule.at?new Date(U.schedule.at).toISOString().slice(0,16):"",taskInput:U.taskInput||"",model:U.model||"",maxRetries:String(U.maxRetries||0),timeoutSeconds:String(U.timeoutSeconds||7200),deliveryMode:W}),((ve=U.delivery)==null?void 0:ve.mode)==="preset"&&U.delivery.presetId&&M(U.delivery.presetId),((Se=U.delivery)==null?void 0:Se.mode)==="multi"&&U.delivery.targets){const Ke=U.delivery.targets;j(Ke.map(dt=>{var Ge,_e,Ve;return{channel:dt.channel,label:`${dt.channel} → ${((Ge=dt.channelMeta)==null?void 0:Ge.userName)||((_e=dt.channelMeta)==null?void 0:_e.userId)||((Ve=dt.channelMeta)==null?void 0:Ve.chatId)||"user"}`,channelMeta:dt.channelMeta}}))}D(),F(!0)},X=async()=>{if(!K||!g.taskInput)return me.error("Task input is required");const U={name:g.name||void 0,taskInput:g.taskInput,model:g.model||null,maxRetries:parseInt(g.maxRetries)||0,timeoutSeconds:parseInt(g.timeoutSeconds)||7200};if(g.scheduleKind==="cron"){if(!g.cronExpr)return me.error("Cron expression is required");U.schedule={kind:"cron",expr:g.cronExpr,tz:g.timezone||null}}else if(g.scheduleKind==="every"){if(!g.everyInterval)return me.error("Interval is required");const ue=g.everyInterval.match(/^(\d+)\s*(s|m|h|d)$/i);if(!ue)return me.error('Invalid interval format (e.g. "30s", "5m", "2h", "1d")');const ke=parseInt(ue[1]),W={s:1e3,m:6e4,h:36e5,d:864e5};U.schedule={kind:"every",everyMs:ke*W[ue[2].toLowerCase()]}}else if(g.scheduleKind==="at"){if(!g.atTime)return me.error("Date/time is required");U.schedule={kind:"at",at:new Date(g.atTime).toISOString()}}if(g.deliveryMode==="preset"&&I)U.delivery={mode:"preset",presetId:I};else if(g.deliveryMode==="channels"&&C.length>0){const ue=C.map(ke=>{var W,q;return{tenantId:null,channel:ke.channel,userId:((W=ke.channelMeta)==null?void 0:W.userId)||((q=ke.channelMeta)==null?void 0:q.chatId)||null,channelMeta:ke.channelMeta}});U.delivery={mode:"multi",targets:ue}}else g.deliveryMode==="webhook"?U.delivery={mode:"webhook"}:g.deliveryMode==="none"&&(U.delivery={mode:"none"});try{const ue=await we(`/api/cron/jobs/${K}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(U)});if(ue.ok)me.success("Job updated"),F(!1),J(null),v(nf),Q();else{const ke=await ue.json();me.error(ke.error||"Failed to update job")}}catch{me.error("API connection error")}},ye=U=>{if(U.kind==="cron")return U.expr||"";if(U.kind==="every"&&U.everyMs){const ue=U.everyMs/1e3;return ue>=86400?`every ${Math.round(ue/86400)}d`:ue>=3600?`every ${Math.round(ue/3600)}h`:ue>=60?`every ${Math.round(ue/60)}m`:`every ${ue}s`}return U.kind==="at"?`at ${new Date(U.at).toLocaleString()}`:"unknown"},se=U=>U==="ok"?o.jsx(_i,{className:"w-3 h-3 text-emerald-400"}):U==="error"||U==="timeout"?o.jsx(wy,{className:"w-3 h-3 text-red-400"}):U==="skipped"?o.jsx(CN,{className:"w-3 h-3 text-yellow-400"}):o.jsx(es,{className:"w-3 h-3 text-gray-600"}),oe=U=>U==="cron"?o.jsx(NN,{className:"w-3 h-3"}):U==="every"?o.jsx(jN,{className:"w-3 h-3"}):o.jsx(es,{className:"w-3 h-3"});return h?o.jsx("div",{className:"flex items-center justify-center h-full",children:o.jsx($t,{className:"w-8 h-8 text-[#00d9ff] animate-spin"})}):o.jsxs("div",{className:"space-y-6",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{children:[o.jsx("h2",{className:"text-3xl font-bold text-white mb-2 uppercase tracking-tighter",children:"Scheduler"}),o.jsx("p",{className:"text-gray-400 text-sm tracking-widest",children:"SCHEDULED JOBS & RUN HISTORY"})]}),o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsxs(at,{onClick:Q,variant:"ghost",size:"sm",className:"text-gray-400 hover:text-[#00d9ff] font-mono text-[10px] uppercase",children:[o.jsx(so,{className:"w-3 h-3 mr-2"}),"Refresh"]}),o.jsxs(hi,{open:f,onOpenChange:U=>{p(U),U||(j([]),M(""))},children:[o.jsx(fl,{asChild:!0,children:o.jsxs(at,{size:"sm",className:"bg-gradient-to-r from-[#0891b2] to-[#0d9488] text-white uppercase text-xs tracking-tighter",children:[o.jsx(Cs,{className:"w-3 h-3 mr-2"}),"New Job"]})}),o.jsxs(fi,{className:"bg-slate-950 border-slate-800 text-white max-w-3xl",children:[o.jsx(pi,{children:o.jsx(mi,{className:"uppercase tracking-widest text-sm border-b border-slate-800 pb-4",children:"Create Scheduled Job"})}),o.jsxs("div",{className:"space-y-4 pt-4 max-h-[70vh] overflow-y-auto",children:[o.jsxs("div",{className:"space-y-1",children:[o.jsx("label",{className:"text-xs text-gray-400",children:"Name"}),o.jsx(Dt,{value:g.name,onChange:U=>v({...g,name:U.target.value}),placeholder:"Daily Report",className:"bg-slate-900 border-slate-800 text-sm"})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx("label",{className:"text-xs text-gray-400",children:"Schedule"}),o.jsx(ay,{showOnce:!0,defaultMode:g.scheduleKind==="at"?"once":(g.scheduleKind==="every","recurring"),value:{cronExpression:g.scheduleKind==="cron"?g.cronExpr:void 0,every:g.scheduleKind==="every"?g.everyInterval:void 0,at:g.scheduleKind==="at"&&g.atTime?new Date(g.atTime).toISOString():void 0,timezone:g.timezone},onChange:U=>{U.at?v({...g,scheduleKind:"at",atTime:U.at.slice(0,16),timezone:U.timezone||g.timezone}):U.every?v({...g,scheduleKind:"every",everyInterval:U.every,timezone:U.timezone||g.timezone}):U.cronExpression&&v({...g,scheduleKind:"cron",cronExpr:U.cronExpression,timezone:U.timezone||g.timezone})}})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx("label",{className:"text-xs text-gray-400",children:"Task Input (Agent Prompt)"}),o.jsx("textarea",{value:g.taskInput,onChange:U=>v({...g,taskInput:U.target.value}),placeholder:"What should the agent do when this job runs?",className:"w-full bg-slate-900 border border-slate-800 rounded-md text-sm p-3 min-h-[80px] text-white resize-y"})]}),o.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[o.jsxs("div",{className:"space-y-1",children:[o.jsx("label",{className:"text-xs text-gray-400",children:"Model (optional)"}),o.jsx(Dt,{value:g.model,onChange:U=>v({...g,model:U.target.value}),placeholder:"openai:gpt-4.1-mini",className:"bg-slate-900 border-slate-800 text-sm"})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx("label",{className:"text-xs text-gray-400",children:"Max Retries"}),o.jsx(Dt,{type:"number",value:g.maxRetries,onChange:U=>v({...g,maxRetries:U.target.value}),className:"bg-slate-900 border-slate-800 text-sm"})]})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx("label",{className:"text-xs text-gray-400",children:"Timeout (seconds)"}),o.jsx(Dt,{type:"number",value:g.timeoutSeconds,onChange:U=>v({...g,timeoutSeconds:U.target.value}),className:"bg-slate-900 border-slate-800 text-sm"})]}),o.jsxs("div",{className:"space-y-2 border-t border-slate-800 pt-4",children:[o.jsxs("label",{className:"text-xs text-gray-400 flex items-center gap-1",children:[o.jsx(k1,{className:"w-3 h-3"})," Delivery"]}),o.jsxs(Qt,{value:g.deliveryMode,onValueChange:U=>{v({...g,deliveryMode:U}),j([]),M("")},children:[o.jsx(en,{className:"bg-slate-900 border-slate-800 text-sm",children:o.jsx(Zt,{})}),o.jsxs(tn,{className:"bg-slate-950 border-slate-800",children:[o.jsx(st,{value:"none",children:"None"}),o.jsx(st,{value:"channels",children:"Active channels"}),o.jsx(st,{value:"preset",children:"Preset (saved group)"}),o.jsx(st,{value:"webhook",children:"Webhook URL"})]})]}),g.deliveryMode==="preset"&&o.jsxs(Qt,{value:I,onValueChange:M,children:[o.jsx(en,{className:"bg-slate-900 border-slate-800 text-sm",children:o.jsx(Zt,{placeholder:"Select preset..."})}),o.jsx(tn,{className:"bg-slate-950 border-slate-800",children:R.map(U=>o.jsxs(st,{value:U.id,children:[U.name," (",U.targets.length," targets)"]},U.id))})]}),g.deliveryMode==="channels"&&(S.length>0?o.jsxs("div",{className:"bg-slate-900/50 border border-slate-800 rounded-lg p-3 max-h-48 overflow-y-auto space-y-1",children:[o.jsxs("div",{className:"flex items-center justify-between mb-2",children:[o.jsxs("span",{className:"text-xs text-gray-400",children:[C.length," selected"]}),o.jsx("button",{className:"text-xs text-[#38bdf8] hover:underline",onClick:()=>j(C.length===S.length?[]:[...S]),children:C.length>0?"Deselect All":"Select All"})]}),S.map((U,ue)=>{const ke=C.some(W=>W.channel===U.channel&&JSON.stringify(W.channelMeta)===JSON.stringify(U.channelMeta));return o.jsxs("label",{className:"flex items-center gap-2 py-1 px-1 hover:bg-slate-800/50 rounded cursor-pointer",children:[o.jsx("input",{type:"checkbox",checked:ke,onChange:()=>{j(ke?C.filter(W=>!(W.channel===U.channel&&JSON.stringify(W.channelMeta)===JSON.stringify(U.channelMeta))):[...C,U])},className:"accent-[#00d9ff]"}),o.jsx("span",{className:"text-sm text-gray-300",children:U.label})]},`${U.channel}-${ue}`)})]}):o.jsxs("div",{className:"flex items-center gap-2 p-2.5 bg-slate-900/50 border border-slate-800 rounded-lg",children:[o.jsx(Gr,{className:"w-4 h-4 text-amber-400 shrink-0"}),o.jsx("p",{className:"text-xs text-gray-400",children:"No active channel destinations. Send a message on Discord/Telegram first so the system knows where to deliver."})]}))]}),o.jsx(at,{onClick:ne,className:"w-full bg-gradient-to-r from-[#0891b2] to-[#0d9488] text-white uppercase text-xs tracking-tighter",children:"Create Job"})]})]})]})]})]}),o.jsx(hi,{open:V,onOpenChange:U=>{F(U),U||(J(null),v(nf),j([]),M(""))},children:o.jsxs(fi,{className:"bg-slate-950 border-slate-800 text-white max-w-3xl",children:[o.jsx(pi,{children:o.jsx(mi,{className:"uppercase tracking-widest text-sm border-b border-slate-800 pb-4",children:"Edit Cron Job"})}),o.jsxs("div",{className:"space-y-4 pt-4 max-h-[70vh] overflow-y-auto",children:[o.jsxs("div",{className:"space-y-1",children:[o.jsx("label",{className:"text-xs text-gray-400",children:"Name"}),o.jsx(Dt,{value:g.name,onChange:U=>v({...g,name:U.target.value}),placeholder:"Daily Report",className:"bg-slate-900 border-slate-800 text-sm"})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx("label",{className:"text-xs text-gray-400",children:"Schedule"}),o.jsx(ay,{showOnce:!0,defaultMode:g.scheduleKind==="at"?"once":(g.scheduleKind==="every","recurring"),value:{cronExpression:g.scheduleKind==="cron"?g.cronExpr:void 0,every:g.scheduleKind==="every"?g.everyInterval:void 0,at:g.scheduleKind==="at"&&g.atTime?new Date(g.atTime).toISOString():void 0,timezone:g.timezone},onChange:U=>{U.at?v({...g,scheduleKind:"at",atTime:U.at.slice(0,16),timezone:U.timezone||g.timezone}):U.every?v({...g,scheduleKind:"every",everyInterval:U.every,timezone:U.timezone||g.timezone}):U.cronExpression&&v({...g,scheduleKind:"cron",cronExpr:U.cronExpression,timezone:U.timezone||g.timezone})}})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx("label",{className:"text-xs text-gray-400",children:"Task Input (Agent Prompt)"}),o.jsx("textarea",{value:g.taskInput,onChange:U=>v({...g,taskInput:U.target.value}),placeholder:"What should the agent do when this job runs?",className:"w-full bg-slate-900 border border-slate-800 rounded-md text-sm p-3 min-h-[80px] text-white resize-y"})]}),o.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[o.jsxs("div",{className:"space-y-1",children:[o.jsx("label",{className:"text-xs text-gray-400",children:"Model (optional)"}),o.jsx(Dt,{value:g.model,onChange:U=>v({...g,model:U.target.value}),placeholder:"openai:gpt-4.1-mini",className:"bg-slate-900 border-slate-800 text-sm"})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx("label",{className:"text-xs text-gray-400",children:"Max Retries"}),o.jsx(Dt,{type:"number",value:g.maxRetries,onChange:U=>v({...g,maxRetries:U.target.value}),className:"bg-slate-900 border-slate-800 text-sm"})]})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx("label",{className:"text-xs text-gray-400",children:"Timeout (seconds)"}),o.jsx(Dt,{type:"number",value:g.timeoutSeconds,onChange:U=>v({...g,timeoutSeconds:U.target.value}),className:"bg-slate-900 border-slate-800 text-sm"})]}),o.jsxs("div",{className:"space-y-2 border-t border-slate-800 pt-4",children:[o.jsxs("label",{className:"text-xs text-gray-400 flex items-center gap-1",children:[o.jsx(k1,{className:"w-3 h-3"})," Delivery"]}),o.jsxs(Qt,{value:g.deliveryMode,onValueChange:U=>{v({...g,deliveryMode:U}),j([]),M("")},children:[o.jsx(en,{className:"bg-slate-900 border-slate-800 text-sm",children:o.jsx(Zt,{})}),o.jsxs(tn,{className:"bg-slate-950 border-slate-800",children:[o.jsx(st,{value:"none",children:"None"}),o.jsx(st,{value:"channels",children:"Active channels"}),o.jsx(st,{value:"preset",children:"Preset (saved group)"}),o.jsx(st,{value:"webhook",children:"Webhook URL"})]})]}),g.deliveryMode==="preset"&&o.jsxs(Qt,{value:I,onValueChange:M,children:[o.jsx(en,{className:"bg-slate-900 border-slate-800 text-sm",children:o.jsx(Zt,{placeholder:"Select preset..."})}),o.jsx(tn,{className:"bg-slate-950 border-slate-800",children:R.map(U=>o.jsxs(st,{value:U.id,children:[U.name," (",U.targets.length," targets)"]},U.id))})]}),g.deliveryMode==="channels"&&(S.length>0?o.jsxs("div",{className:"bg-slate-900/50 border border-slate-800 rounded-lg p-3 max-h-48 overflow-y-auto space-y-1",children:[o.jsxs("div",{className:"flex items-center justify-between mb-2",children:[o.jsxs("span",{className:"text-xs text-gray-400",children:[C.length," selected"]}),o.jsx("button",{className:"text-xs text-[#38bdf8] hover:underline",onClick:()=>j(C.length===S.length?[]:[...S]),children:C.length>0?"Deselect All":"Select All"})]}),S.map((U,ue)=>{const ke=C.some(W=>W.channel===U.channel&&JSON.stringify(W.channelMeta)===JSON.stringify(U.channelMeta));return o.jsxs("label",{className:"flex items-center gap-2 py-1 px-1 hover:bg-slate-800/50 rounded cursor-pointer",children:[o.jsx("input",{type:"checkbox",checked:ke,onChange:()=>{j(ke?C.filter(W=>!(W.channel===U.channel&&JSON.stringify(W.channelMeta)===JSON.stringify(U.channelMeta))):[...C,U])},className:"accent-[#00d9ff]"}),o.jsx("span",{className:"text-sm text-gray-300",children:U.label})]},`${U.channel}-${ue}`)})]}):o.jsxs("div",{className:"flex items-center gap-2 p-2.5 bg-slate-900/50 border border-slate-800 rounded-lg",children:[o.jsx(Gr,{className:"w-4 h-4 text-amber-400 shrink-0"}),o.jsx("p",{className:"text-xs text-gray-400",children:"No active channel destinations. Send a message on Discord/Telegram first."})]}))]}),o.jsx(at,{onClick:X,className:"w-full bg-gradient-to-r from-amber-600 to-amber-500 text-white uppercase text-xs tracking-tighter",children:"Update Job"})]})]})}),n&&o.jsxs("div",{className:"flex items-center gap-6 text-xs font-mono text-gray-500",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("div",{className:`w-2 h-2 rounded-full ${n.running?"bg-emerald-400 animate-pulse":"bg-red-400"}`}),o.jsx("span",{className:"uppercase",children:n.running?"Running":"Stopped"})]}),o.jsxs("span",{children:[n.totalJobs," jobs"]}),o.jsxs("span",{children:[n.enabledJobs," enabled"]}),n.runningNow>0&&o.jsxs("span",{className:"text-yellow-400",children:[n.runningNow," running now"]}),n.nextWakeAt&&o.jsxs("span",{children:["Next: ",new Date(n.nextWakeAt).toLocaleString()]})]}),o.jsxs(C_,{value:k,onValueChange:w,children:[o.jsxs(T_,{className:"bg-slate-900/50 border border-slate-800",children:[o.jsxs(el,{value:"jobs",className:"data-[state=active]:bg-slate-800 data-[state=active]:text-white font-mono text-xs uppercase",children:[o.jsx(es,{className:"w-3 h-3 mr-2"}),"Jobs"]}),o.jsxs(el,{value:"history",className:"data-[state=active]:bg-slate-800 data-[state=active]:text-white font-mono text-xs uppercase",children:[o.jsx(Ug,{className:"w-3 h-3 mr-2"}),"Run History"]}),o.jsxs(el,{value:"presets",className:"data-[state=active]:bg-slate-800 data-[state=active]:text-white font-mono text-xs uppercase",children:[o.jsx(Qo,{className:"w-3 h-3 mr-2"}),"Presets"]})]}),o.jsx(tl,{value:"jobs",className:"mt-4",children:t.length===0?o.jsx(rn,{className:"bg-slate-900/50 border-slate-800",children:o.jsxs(on,{className:"py-16 text-center",children:[o.jsx(es,{className:"w-12 h-12 text-gray-700 mx-auto mb-4"}),o.jsx("p",{className:"text-gray-600 font-mono uppercase text-xs tracking-widest",children:"No cron jobs configured"}),o.jsx("p",{className:"text-gray-700 font-mono text-[10px] mt-2",children:"Create one to schedule recurring agent tasks"})]})}):o.jsx("div",{className:"space-y-3",children:t.map(U=>{var ue;return o.jsx(rn,{className:`bg-slate-900/50 border-slate-800 hover:border-slate-700 transition-colors ${U.runningSince?"border-yellow-500/30":""}`,children:o.jsx(on,{className:"p-4",children:o.jsxs("div",{className:"flex items-start justify-between gap-4",children:[o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[oe(U.schedule.kind),o.jsx("span",{className:"font-mono text-sm text-white uppercase tracking-tight truncate",children:U.name}),o.jsx(Kt,{variant:"outline",className:`text-[9px] ${U.enabled?"border-emerald-500/30 text-emerald-400":"border-gray-700 text-gray-500"}`,children:U.runningSince?"RUNNING":U.enabled?"ENABLED":"PAUSED"}),o.jsx(Kt,{variant:"outline",className:"text-[9px] border-[#00d9ff]/20 text-[#00d9ff]",children:U.schedule.kind}),((ue=U.delivery)==null?void 0:ue.mode)!=="none"&&o.jsx(Kt,{variant:"outline",className:"text-[9px] border-[#00d9ff]/20 text-[#00d9ff]",children:U.delivery.mode})]}),o.jsxs("div",{className:"flex items-center gap-4 text-[10px] font-mono text-gray-500 mb-2",children:[o.jsx("span",{className:"text-[#00ff88]",children:ye(U.schedule)}),U.schedule.tz&&o.jsxs("span",{className:"flex items-center gap-1",children:[o.jsx(wN,{className:"w-2.5 h-2.5"}),U.schedule.tz]}),U.maxRetries>0&&o.jsxs("span",{children:["retries: ",U.maxRetries]})]}),o.jsx("p",{className:"text-[10px] text-gray-600 font-mono truncate lowercase italic",children:U.taskInput}),o.jsxs("div",{className:"flex items-center gap-4 mt-2 text-[10px] font-mono text-gray-600",children:[o.jsxs("span",{className:"flex items-center gap-1",children:[se(U.lastStatus)," ",U.lastStatus||"never run"]}),o.jsxs("span",{children:["runs: ",U.runCount]}),U.lastDurationMs&&o.jsxs("span",{children:[Math.round(U.lastDurationMs/1e3),"s"]}),U.consecutiveErrors>0&&o.jsxs("span",{className:"text-red-400 flex items-center gap-1",children:[o.jsx(Gr,{className:"w-2.5 h-2.5"}),U.consecutiveErrors," errors"]}),U.nextRunAt&&o.jsxs("span",{children:["next: ",new Date(U.nextRunAt).toLocaleString()]})]}),U.lastError&&o.jsx("p",{className:"text-[9px] text-red-400/70 font-mono mt-1 truncate",children:U.lastError})]}),o.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[o.jsx(Pd,{checked:U.enabled,onCheckedChange:ke=>A(U.id,ke),className:"data-[state=checked]:bg-emerald-500"}),o.jsx(at,{variant:"ghost",size:"icon",onClick:()=>ee(U.id),className:"text-gray-500 hover:text-[#00d9ff]",title:"Run now",children:o.jsx(Cy,{className:"w-3 h-3"})}),o.jsx(at,{variant:"ghost",size:"icon",onClick:()=>B(U),className:"text-gray-500 hover:text-amber-400",title:"Edit",children:o.jsx(Sy,{className:"w-3 h-3"})}),o.jsx(at,{variant:"ghost",size:"icon",onClick:()=>{c(U.id),w("history")},className:"text-gray-500 hover:text-purple-400",title:"View history",children:o.jsx(Ug,{className:"w-3 h-3"})}),o.jsx(at,{variant:"ghost",size:"icon",onClick:()=>z(U.id),className:"text-gray-500 hover:text-red-400",title:"Delete",children:o.jsx(qn,{className:"w-3 h-3"})})]})]})})},U.id)})})}),o.jsx(tl,{value:"history",className:"mt-4",children:o.jsxs(rn,{className:"bg-slate-900/50 border-slate-800",children:[o.jsx(br,{className:"border-b border-slate-800/50 pb-4",children:o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx(Ug,{className:"w-5 h-5 text-[#00d9ff]"}),o.jsxs("div",{children:[o.jsx(kr,{className:"text-white uppercase tracking-tight text-sm",children:"Run History"}),o.jsx(to,{className:"text-gray-500 font-mono text-[10px] uppercase",children:a?`Job ${a.slice(0,8)}`:"All Jobs"})]})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[a&&o.jsx(at,{variant:"ghost",size:"sm",onClick:()=>{c(null),Z()},className:"text-gray-400 hover:text-white font-mono text-[10px] uppercase",children:"Show All"}),o.jsxs(at,{variant:"ghost",size:"sm",onClick:()=>Z(a||void 0),className:"text-gray-400 hover:text-[#00d9ff] font-mono text-[10px] uppercase",children:[o.jsx(so,{className:"w-3 h-3 mr-1"})," Refresh"]})]})]})}),o.jsx(on,{className:"pt-4",children:i.length===0?o.jsx("div",{className:"text-center py-12 text-gray-700 font-mono uppercase text-[10px] tracking-widest",children:"No run history"}):o.jsx("div",{className:"space-y-2",children:i.map(U=>o.jsxs("div",{className:"flex items-center gap-3 p-3 bg-slate-800/20 border border-slate-800/50 rounded-lg text-xs font-mono",children:[se(U.status),o.jsx("span",{className:"text-gray-400 w-40 shrink-0",children:new Date(U.started_at).toLocaleString()}),o.jsx(Kt,{variant:"outline",className:`text-[9px] ${U.status==="ok"?"border-emerald-500/20 text-emerald-400":U.status==="error"?"border-red-500/20 text-red-400":U.status==="timeout"?"border-orange-500/20 text-orange-400":"border-gray-700 text-gray-500"}`,children:U.status}),U.duration_ms&&o.jsxs("span",{className:"text-gray-600",children:[Math.round(U.duration_ms/1e3),"s"]}),U.retry_attempt>0&&o.jsxs("span",{className:"text-yellow-500",children:["retry #",U.retry_attempt]}),U.delivery_status!=="not-requested"&&o.jsx(Kt,{variant:"outline",className:"text-[9px] border-[#00d9ff]/20 text-[#00d9ff]",children:U.delivery_status}),U.error&&o.jsx("span",{className:"text-red-400/60 truncate flex-1",children:U.error}),U.result_preview&&!U.error&&o.jsx("span",{className:"text-gray-600 truncate flex-1",children:U.result_preview.slice(0,80)})]},U.id))})})]})}),o.jsxs(tl,{value:"presets",className:"mt-4",children:[o.jsxs("div",{className:"flex items-center justify-between mb-4",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(Qo,{className:"w-5 h-5 text-[#00d9ff]"}),o.jsx("span",{className:"text-sm font-mono text-white uppercase tracking-tight",children:"Delivery Presets"}),o.jsxs("span",{className:"text-[9px] font-mono text-gray-600",children:[R.length," presets"]})]}),o.jsxs(hi,{open:E,onOpenChange:U=>{P(U),U||j([])},children:[o.jsx(fl,{asChild:!0,children:o.jsxs(at,{size:"sm",className:"bg-gradient-to-r from-[#0891b2] to-[#0d9488] text-white uppercase text-xs tracking-tighter",children:[o.jsx(Cs,{className:"w-3 h-3 mr-2"}),"New Preset"]})}),o.jsxs(fi,{className:"bg-slate-950 border-slate-800 text-white max-w-3xl",children:[o.jsx(pi,{children:o.jsx(mi,{className:"uppercase tracking-widest text-sm border-b border-slate-800 pb-4",children:"Create Delivery Preset"})}),o.jsxs("div",{className:"space-y-4 pt-4 max-h-[70vh] overflow-y-auto",children:[o.jsxs("div",{className:"space-y-1",children:[o.jsx("label",{className:"text-xs text-gray-400",children:"Name"}),o.jsx(Dt,{value:L.name,onChange:U=>$({...L,name:U.target.value}),placeholder:"e.g. team, alerts, daily-digest",className:"bg-slate-900 border-slate-800 text-sm"})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx("label",{className:"text-xs text-gray-400",children:"Description"}),o.jsx(Dt,{value:L.description,onChange:U=>$({...L,description:U.target.value}),placeholder:"Optional description",className:"bg-slate-900 border-slate-800 text-sm"})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx("label",{className:"text-xs text-gray-400",children:"Select Channel Destinations"}),S.length>0?o.jsxs("div",{className:"bg-slate-900/50 border border-slate-800 rounded-lg p-3 max-h-48 overflow-y-auto space-y-1",children:[o.jsxs("div",{className:"flex items-center justify-between mb-2",children:[o.jsxs("span",{className:"text-xs text-gray-400",children:[C.length," selected"]}),o.jsx("button",{className:"text-xs text-[#38bdf8] hover:underline",onClick:()=>j(C.length===S.length?[]:[...S]),children:C.length>0?"Deselect All":"Select All"})]}),S.map((U,ue)=>{const ke=C.some(W=>W.channel===U.channel&&JSON.stringify(W.channelMeta)===JSON.stringify(U.channelMeta));return o.jsxs("label",{className:"flex items-center gap-2 py-1 px-1 hover:bg-slate-800/50 rounded cursor-pointer",children:[o.jsx("input",{type:"checkbox",checked:ke,onChange:()=>{j(ke?C.filter(W=>!(W.channel===U.channel&&JSON.stringify(W.channelMeta)===JSON.stringify(U.channelMeta))):[...C,U])},className:"accent-[#00d9ff]"}),o.jsx("span",{className:"text-sm text-gray-300",children:U.label})]},`${U.channel}-${ue}`)})]}):o.jsxs("div",{className:"flex items-center gap-2 p-2.5 bg-slate-900/50 border border-slate-800 rounded-lg",children:[o.jsx(Gr,{className:"w-4 h-4 text-amber-400 shrink-0"}),o.jsx("p",{className:"text-xs text-gray-400",children:"No active channel destinations. Send a message on Discord/Telegram first."})]})]}),o.jsx(at,{onClick:async()=>{if(!L.name)return me.error("Name is required");if(C.length===0)return me.error("Select at least one destination");const U=C.map(ue=>{var ke,W;return{tenantId:null,channel:ue.channel,userId:((ke=ue.channelMeta)==null?void 0:ke.userId)||((W=ue.channelMeta)==null?void 0:W.chatId)||null,channelMeta:ue.channelMeta}});try{const ue=await we("/api/cron/presets",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:L.name,description:L.description||null,targets:U})});if(ue.ok)me.success("Preset created"),P(!1),$({name:"",description:""}),j([]),D();else{const ke=await ue.json();me.error(ke.error||"Failed to create preset")}}catch{me.error("API error")}},className:"w-full bg-gradient-to-r from-[#0891b2] to-[#0d9488] text-white uppercase text-xs tracking-tighter",children:"Create Preset"})]})]})]})]}),R.length===0?o.jsx(rn,{className:"bg-slate-900/50 border-slate-800",children:o.jsxs(on,{className:"py-16 text-center",children:[o.jsx(Qo,{className:"w-12 h-12 text-gray-700 mx-auto mb-4"}),o.jsx("p",{className:"text-gray-600 font-mono uppercase text-xs tracking-widest",children:"No delivery presets"}),o.jsx("p",{className:"text-gray-700 font-mono text-[10px] mt-2",children:'Create presets like "engineers" or "team-leads" for reusable delivery groups'})]})}):o.jsx("div",{className:"space-y-3",children:R.map(U=>o.jsx(rn,{className:"bg-slate-900/50 border-slate-800",children:o.jsx(on,{className:"p-4",children:o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{children:[o.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[o.jsx(Qo,{className:"w-3 h-3 text-[#00d9ff]"}),o.jsx("span",{className:"font-mono text-sm text-white uppercase tracking-tight",children:U.name}),o.jsxs(Kt,{variant:"outline",className:"text-[9px] border-[#00d9ff]/20 text-[#00d9ff]",children:[U.targets.length," targets"]})]}),U.description&&o.jsx("p",{className:"text-[10px] text-gray-600 font-mono",children:U.description}),o.jsx("div",{className:"flex flex-wrap gap-1 mt-2",children:U.targets.map((ue,ke)=>o.jsx("span",{className:"text-[9px] bg-slate-800/50 px-2 py-0.5 rounded text-gray-400",children:ue.tenantId?`${ue.tenantId.split(":").pop()}:${ue.channel}`:`global:${ue.channel}`},ke))})]}),o.jsx(at,{variant:"ghost",size:"icon",onClick:async()=>{try{await we(`/api/cron/presets/${U.id}`,{method:"DELETE"}),me.success("Preset deleted"),D()}catch{me.error("Failed to delete")}},className:"text-gray-500 hover:text-red-400",children:o.jsx(qn,{className:"w-3 h-3"})})]})})},U.id))})]})]})]})}const e4=[{label:"Every 15 minutes",cron:"*/15 * * * *"},{label:"Every 30 minutes",cron:"*/30 * * * *"},{label:"Every hour",cron:"0 * * * *"},{label:"Every 2 hours",cron:"0 */2 * * *"},{label:"Every 4 hours",cron:"0 */4 * * *"},{label:"Every 6 hours",cron:"0 */6 * * *"},{label:"Every 12 hours",cron:"0 */12 * * *"},{label:"Daily at midnight",cron:"0 0 * * *"},{label:"Daily at 9am",cron:"0 9 * * *"},{label:"Every Monday at 9am",cron:"0 9 * * 1"}];function BX(t){const e=e4.find(n=>n.cron===t);return(e==null?void 0:e.label)||`Custom: ${t}`}function rf(t){const e=e4.find(n=>n.cron===t);return e?e.cron:"custom"}const AT={active:"bg-emerald-500/20 text-emerald-400 border-emerald-500/30",paused:"bg-yellow-500/20 text-yellow-400 border-yellow-500/30",completed:"bg-blue-500/20 text-blue-400 border-blue-500/30",failed:"bg-red-500/20 text-red-400 border-red-500/30"},Bo={title:"",description:"",strategy:"",checkSchedule:"0 */4 * * *",timezone:"",priority:"5",maxFailures:"5"};function zX(){const[t,e]=x.useState([]),[n,r]=x.useState(!0),[i,s]=x.useState(!1),[a,c]=x.useState(null),[h,d]=x.useState({...Bo}),[f,p]=x.useState(!1),[g,v]=x.useState(null),[k,w]=x.useState(()=>rf(Bo.checkSchedule)),S=x.useCallback(async()=>{try{r(!0);const K=await(await we("/api/goals")).json();e(Array.isArray(K)?K:K.goals||[])}catch(F){me.error("Failed to load goals: "+F.message)}finally{r(!1)}},[]);x.useEffect(()=>{S()},[S]);const T=async()=>{if(!h.title.trim()){me.error("Title required");return}p(!0);try{const F={title:h.title.trim(),description:h.description.trim()||null,strategy:h.strategy.trim()||null,checkSchedule:h.checkSchedule.trim(),timezone:h.timezone.trim()||null,priority:parseInt(h.priority)||5,maxFailures:parseInt(h.maxFailures)||5};a?(await we(`/api/goals/${a}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(F)}),me.success("Goal updated")):(await we("/api/goals",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(F)}),me.success("Goal created")),s(!1),c(null),d({...Bo}),S()}catch(F){me.error(F.message)}finally{p(!1)}},C=async F=>{const K=F.status==="active"?"paused":"active";try{await we(`/api/goals/${F.id}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({status:K})}),me.success(K==="paused"?"Goal paused":"Goal resumed"),S()}catch(J){me.error(J.message)}},[j,R]=x.useState(null),[_,I]=x.useState(!1),M=F=>R(F),L=async()=>{if(j){I(!0);try{await we(`/api/goals/${j}`,{method:"DELETE"}),me.success("Goal deleted"),S(),R(null)}catch(F){me.error(F.message)}finally{I(!1)}}},$=async F=>{v(F);try{await we(`/api/goals/${F}/check`,{method:"POST"}),me.success("Check triggered"),S()}catch(K){me.error(K.message)}finally{v(null)}},E=F=>{c(F.id),d({title:F.title,description:F.description||"",strategy:F.strategy||"",checkSchedule:F.checkSchedule||"0 */4 * * *",timezone:F.timezone||"",priority:String(F.priority||5),maxFailures:String(F.maxFailures||5)}),w(rf(F.checkSchedule||"0 */4 * * *")),s(!0)},P=()=>{c(null),d({...Bo}),w(rf(Bo.checkSchedule)),s(!0)},V=t.filter(F=>F.status==="active").length;return o.jsxs("div",{className:"space-y-6",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{children:[o.jsxs("h2",{className:"text-2xl font-bold text-white flex items-center gap-3",children:[o.jsx(Mf,{className:"w-7 h-7 text-[#00d9ff]"}),"Goals"]}),o.jsx("p",{className:"text-[10px] text-gray-500 font-mono uppercase tracking-[0.3em] mt-1",children:"Autonomous Objectives - Agent Works Toward Them 24/7"})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(at,{variant:"outline",size:"sm",onClick:S,className:"border-slate-700 text-gray-400 hover:text-white hover:border-slate-500",children:o.jsx(so,{className:"w-4 h-4"})}),o.jsxs(hi,{open:i,onOpenChange:F=>{s(F),F||(c(null),d({...Bo}),w(rf(Bo.checkSchedule)))},children:[o.jsx(fl,{asChild:!0,children:o.jsxs(at,{size:"sm",onClick:P,className:"bg-[#00d9ff]/20 text-[#00d9ff] border border-[#00d9ff]/30 hover:bg-[#00d9ff]/30",children:[o.jsx(Cs,{className:"w-4 h-4 mr-1"})," New Goal"]})}),o.jsxs(fi,{className:"bg-slate-900 border-slate-700 text-white max-w-lg",children:[o.jsx(pi,{children:o.jsx(mi,{children:a?"Edit Goal":"New Goal"})}),o.jsxs("div",{className:"space-y-4 mt-4",children:[o.jsxs("div",{children:[o.jsx("label",{className:"text-xs text-gray-400 mb-1 block",children:"Title"}),o.jsx(Dt,{className:"bg-slate-800 border-slate-700 text-white",value:h.title,onChange:F=>d({...h,title:F.target.value}),placeholder:"e.g. Monitor competitor pricing"})]}),o.jsxs("div",{children:[o.jsx("label",{className:"text-xs text-gray-400 mb-1 block",children:"Description"}),o.jsx("textarea",{className:"w-full bg-slate-800 border border-slate-700 rounded-md px-3 py-2 text-sm text-white resize-none h-20",value:h.description,onChange:F=>d({...h,description:F.target.value}),placeholder:"What should the agent accomplish?"})]}),o.jsxs("div",{children:[o.jsx("label",{className:"text-xs text-gray-400 mb-1 block",children:"Strategy"}),o.jsx("textarea",{className:"w-full bg-slate-800 border border-slate-700 rounded-md px-3 py-2 text-sm text-white resize-none h-16",value:h.strategy,onChange:F=>d({...h,strategy:F.target.value}),placeholder:"How should the agent approach this?"})]}),o.jsxs("div",{children:[o.jsx("label",{className:"text-xs text-gray-400 mb-2 block",children:"Check Schedule"}),o.jsx(ay,{showOnce:!1,defaultMode:"recurring",value:{cronExpression:h.checkSchedule,timezone:h.timezone},onChange:F=>{d({...h,checkSchedule:F.cronExpression||F.every||h.checkSchedule,timezone:F.timezone||h.timezone})}})]}),o.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[o.jsxs("div",{children:[o.jsx("label",{className:"text-xs text-gray-400 mb-1 block",children:"Priority (1-10)"}),o.jsx(Dt,{type:"number",min:"1",max:"10",className:"bg-slate-800 border-slate-700 text-white",value:h.priority,onChange:F=>d({...h,priority:F.target.value})})]}),o.jsxs("div",{children:[o.jsx("label",{className:"text-xs text-gray-400 mb-1 block",children:"Max Failures"}),o.jsx(Dt,{type:"number",min:"1",className:"bg-slate-800 border-slate-700 text-white",value:h.maxFailures,onChange:F=>d({...h,maxFailures:F.target.value})})]})]}),o.jsxs(at,{onClick:T,disabled:f,className:"w-full bg-[#00d9ff]/20 text-[#00d9ff] border border-[#00d9ff]/30 hover:bg-[#00d9ff]/30",children:[f?o.jsx($t,{className:"w-4 h-4 animate-spin mr-2"}):null,a?"Update Goal":"Create Goal"]})]})]})]})]})]}),o.jsxs("div",{className:"flex gap-4",children:[o.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 bg-slate-800/50 border border-slate-700/50 rounded-lg",children:[o.jsx("span",{className:"text-xs text-gray-400",children:"Total"}),o.jsx("span",{className:"text-sm font-mono text-white",children:t.length})]}),o.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 bg-slate-800/50 border border-slate-700/50 rounded-lg",children:[o.jsx("div",{className:"w-2 h-2 bg-emerald-400 rounded-full"}),o.jsx("span",{className:"text-xs text-gray-400",children:"Active"}),o.jsx("span",{className:"text-sm font-mono text-emerald-400",children:V})]})]}),n?o.jsx("div",{className:"flex items-center justify-center py-20",children:o.jsx($t,{className:"w-6 h-6 animate-spin text-[#00d9ff]"})}):t.length===0?o.jsx(rn,{className:"bg-slate-900/50 border-slate-800",children:o.jsxs(on,{className:"py-12 text-center text-gray-500",children:[o.jsx(Mf,{className:"w-10 h-10 mx-auto mb-3 opacity-30"}),o.jsx("p",{children:"No goals yet. Create one to get started."})]})}):o.jsx("div",{className:"space-y-3",children:t.map(F=>o.jsx(rn,{className:"bg-slate-900/50 border-slate-800 hover:border-slate-700 transition-colors",children:o.jsx(on,{className:"p-4",children:o.jsxs("div",{className:"flex items-start justify-between gap-4",children:[o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[o.jsx("h3",{className:"text-sm font-semibold text-white truncate",children:F.title}),o.jsx(Kt,{className:`text-[10px] ${AT[F.status]||AT.active}`,children:F.status}),o.jsxs(Kt,{className:"bg-slate-700/50 text-gray-400 border-slate-600 text-[10px]",children:["P",F.priority]})]}),F.description&&o.jsx("p",{className:"text-xs text-gray-400 mb-2 line-clamp-2",children:F.description}),o.jsxs("div",{className:"flex items-center gap-4 text-[10px] text-gray-500 font-mono",children:[o.jsxs("span",{className:"flex items-center gap-1",children:[o.jsx(es,{className:"w-3 h-3"}),BX(F.checkSchedule)]}),F.lastCheckAt&&o.jsxs("span",{children:["Last: ",new Date(F.lastCheckAt).toLocaleString()]}),F.consecutiveFailures>0&&o.jsxs("span",{className:"text-red-400 flex items-center gap-1",children:[o.jsx(Gr,{className:"w-3 h-3"}),F.consecutiveFailures," failures"]})]}),F.lastResult&&o.jsx("p",{className:"text-[10px] text-gray-500 mt-1 truncate max-w-xl",children:F.lastResult})]}),o.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[o.jsx(Pd,{checked:F.status==="active",onCheckedChange:()=>C(F),className:"data-[state=checked]:bg-emerald-500"}),o.jsx(at,{variant:"ghost",size:"icon",className:"h-7 w-7 text-gray-400 hover:text-[#00d9ff]",onClick:()=>$(F.id),disabled:g===F.id,children:g===F.id?o.jsx($t,{className:"w-3.5 h-3.5 animate-spin"}):o.jsx(Cy,{className:"w-3.5 h-3.5"})}),o.jsx(at,{variant:"ghost",size:"icon",className:"h-7 w-7 text-gray-400 hover:text-white",onClick:()=>E(F),children:o.jsx(Sy,{className:"w-3.5 h-3.5"})}),o.jsx(at,{variant:"ghost",size:"icon",className:"h-7 w-7 text-gray-400 hover:text-red-400",onClick:()=>M(F.id),children:o.jsx(qn,{className:"w-3.5 h-3.5"})})]})]})})},F.id))}),o.jsx(js,{open:!!j,onOpenChange:F=>!F&&R(null),children:o.jsxs(Ps,{className:"bg-slate-950 border-slate-800/80 text-gray-200 font-mono",children:[o.jsxs(_s,{children:[o.jsxs(Is,{className:"text-white tracking-tight flex items-center gap-2",children:[o.jsx(qn,{className:"w-4 h-4 text-red-400"}),"Delete goal"]}),o.jsx(Ms,{className:"text-gray-400 text-sm leading-relaxed",children:"This goal and its check history will be permanently removed."})]}),o.jsxs(Rs,{children:[o.jsx(As,{className:"bg-slate-900 border-slate-800 text-gray-300 hover:bg-slate-800 hover:text-white",children:"Cancel"}),o.jsx(Ds,{onClick:L,disabled:_,className:"bg-red-600 hover:bg-red-500 text-white border border-red-500/40",children:_?"Deleting...":"Delete goal"})]})]})})]})}const sf={name:"",description:"",action:"",triggerType:"webhook",pattern:"",context:"",destinations:[],cooldownSeconds:"60",integration:"",event:"",eventParams:{},pollIntervalSeconds:"300"},af=[{label:"GitHub - Push",value:'{"event": "push"}',desc:"When code is pushed to a repository"},{label:"GitHub - Issue Opened",value:'{"action": "opened"}',desc:"When a new issue is created"},{label:"GitHub - PR Created",value:'{"action": "opened", "pull_request": "/.*/"}',desc:"When a pull request is opened"},{label:"Stripe - Payment Failed",value:'{"type": "payment_intent.payment_failed"}',desc:"When a payment fails"},{label:"Stripe - Subscription Canceled",value:'{"type": "customer.subscription.deleted"}',desc:"When a subscription is canceled"},{label:"Custom",value:"",desc:"Write your own JSON pattern"}];function $X(){var ue,ke;const[t,e]=x.useState([]),[n,r]=x.useState([]),[i,s]=x.useState([]),[a,c]=x.useState([]),[h,d]=x.useState([]),[f,p]=x.useState([]),[g,v]=x.useState(!0),[k,w]=x.useState(!1),[S,T]=x.useState(null),[C,j]=x.useState({...sf}),[R,_]=x.useState(!1),[I,M]=x.useState(null),[L,$]=x.useState(null),[E,P]=x.useState(null),[V,F]=x.useState(null),[K,J]=x.useState(null),Q=x.useCallback(async()=>{try{v(!0);const q=await(await we("/api/watchers")).json();e(Array.isArray(q)?q:q.watchers||[])}catch(W){me.error("Failed to load watchers: "+W.message)}finally{v(!1)}},[]),Z=x.useCallback(async()=>{try{const q=await(await we("/api/channels")).json();r(q.channels||[])}catch{}try{const fe=((await(await we("/api/channels/destinations")).json()).destinations||[]).map(ve=>{const Se=ve.channelMeta,Ke=(Se==null?void 0:Se.authorUsername)||(Se==null?void 0:Se.userName)||(Se==null?void 0:Se.username)||(Se==null?void 0:Se.chatId)||(Se==null?void 0:Se.userId)||"user";return{...ve,label:ve.label||`${ve.channel} → ${Ke}`}});s(fe)}catch{}try{const q=await(await we("/api/watchers/templates")).json();c(q.templates||[])}catch{}try{const q=await(await we("/api/watchers/integration-events")).json();d(q.events||[]),p(q.unavailableIntegrations||[])}catch{}},[]),D=x.useCallback(async()=>{try{const q=await(await we("/api/health")).json();q.publicUrl&&P(q.publicUrl),q.webhookToken&&F(q.webhookToken)}catch{}},[]);x.useEffect(()=>{Q(),Z(),D()},[Q,Z,D]);const ne=async()=>{var W,q;if(!C.name.trim()){me.error("Give your watcher a name");return}if(!C.action.trim()){me.error("Tell the agent what to do when triggered");return}_(!0);try{let fe=null;if(C.triggerType==="integration"){if(!C.integration||!C.event){me.error("Pick an integration and an event"),_(!1);return}const Se=h.find(_e=>_e.integration===C.integration&&_e.event===C.event),Ke=(Se==null?void 0:Se.params.filter(_e=>{var Ve;return _e.required&&!((Ve=C.eventParams[_e.key])!=null&&Ve.trim())}))??[];if(Ke.length>0){me.error(`Missing: ${Ke.map(_e=>_e.label).join(", ")}`),_(!1);return}const dt=Math.max(30,parseInt(C.pollIntervalSeconds)||300)*1e3,Ge={};for(const[_e,Ve]of Object.entries(C.eventParams)){const xt=String(Ve??"").trim();xt&&(Ge[_e]=xt)}fe={__integration:C.integration,__event:C.event,__intervalMs:dt,__params:Ge}}else if(C.pattern.trim())try{fe=JSON.parse(C.pattern)}catch{me.error("Pattern must be valid JSON"),_(!1);return}const ve={name:C.name.trim(),description:C.description.trim()||null,action:C.action.trim(),triggerType:C.triggerType,pattern:fe,destinations:C.destinations.filter(Se=>Se.channelMeta),channel:((W=C.destinations[0])==null?void 0:W.channel)||null,channelMeta:((q=C.destinations[0])==null?void 0:q.channelMeta)||null,context:C.context.trim()||null,cooldownSeconds:parseInt(C.cooldownSeconds)||60};S?(await we(`/api/watchers/${S}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(ve)}),me.success("Watcher updated")):(await we("/api/watchers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(ve)}),me.success("Watcher created - webhook URL shown below")),w(!1),T(null),j({...sf}),Q()}catch(fe){me.error(fe.message)}finally{_(!1)}},A=async W=>{try{await we(`/api/watchers/${W.id}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:!W.enabled})}),me.success(W.enabled?"Watcher paused":"Watcher activated"),Q()}catch(q){me.error(q.message)}},z=async()=>{if(K)try{await we(`/api/watchers/${K.id}`,{method:"DELETE"}),me.success(`"${K.name}" deleted`),J(null),Q()}catch(W){me.error(W.message)}},ee=W=>{T(W.id);const q=W.triggerType==="integration"?"integration":"webhook",fe=W.pattern??{},ve=q==="integration",Se=typeof fe.__intervalMs=="number"?fe.__intervalMs:3e5;j({name:W.name,description:W.description||"",action:W.action,triggerType:q,pattern:ve?"":W.pattern?JSON.stringify(W.pattern,null,2):"",destinations:W.destinations||[],context:W.context||"",cooldownSeconds:String(W.cooldownSeconds||60),integration:ve?String(fe.__integration??""):"",event:ve?String(fe.__event??""):"",eventParams:ve?fe.__params??{}:{},pollIntervalSeconds:ve?String(Math.round(Se/1e3)):"300"}),w(!0)},B=()=>{T(null),j({...sf}),w(!0)},X=(W,q)=>{navigator.clipboard.writeText(W),$(q),me.success("Copied to clipboard"),setTimeout(()=>$(null),2e3)},ye=W=>`${E||window.location.origin}/hooks/watch/${encodeURIComponent(W)}`,se=!E||E.includes("localhost")||E.includes("127.0.0.1"),oe=t.filter(W=>W.enabled).length,U=n.filter(W=>W.running);return o.jsxs("div",{className:"space-y-6",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{children:[o.jsxs("h2",{className:"text-2xl font-bold text-white flex items-center gap-3",children:[o.jsx(Ss,{className:"w-7 h-7 text-[#00d9ff]"}),"Watchers"]}),o.jsx("p",{className:"text-[10px] text-gray-500 font-mono uppercase tracking-[0.3em] mt-1",children:"Event-Driven Triggers - When X Happens, Agent Does Y"})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(at,{variant:"outline",size:"sm",onClick:()=>{Q(),Z()},className:"border-slate-700 text-gray-400 hover:text-white hover:border-slate-500",children:o.jsx(so,{className:"w-4 h-4"})}),o.jsxs(hi,{open:k,onOpenChange:W=>{w(W),W||(T(null),j({...sf}))},children:[o.jsx(fl,{asChild:!0,children:o.jsxs(at,{size:"sm",onClick:B,className:"bg-[#00d9ff]/20 text-[#00d9ff] border border-[#00d9ff]/30 hover:bg-[#00d9ff]/30",children:[o.jsx(Cs,{className:"w-4 h-4 mr-1"})," New Watcher"]})}),o.jsxs(fi,{className:"bg-slate-900 border-slate-700 text-white max-w-lg",children:[o.jsx(pi,{children:o.jsx(mi,{children:S?"Edit Watcher":"New Watcher"})}),o.jsxs("div",{className:"space-y-4 mt-4",children:[!S&&a.length>0&&o.jsxs("div",{children:[o.jsx("label",{className:"text-xs text-gray-400 mb-1 block",children:"Start from Template"}),o.jsxs(Qt,{value:"__blank__",onValueChange:W=>{if(W==="__blank__")return;const q=a.find(fe=>fe.id===W);q&&j({...C,name:q.name,description:q.description,action:q.action,pattern:q.pattern?JSON.stringify(q.pattern,null,2):"",cooldownSeconds:String(q.cooldownSeconds),context:""})},children:[o.jsx(en,{className:"bg-slate-800 border-slate-700 text-white",children:o.jsx(Zt,{placeholder:"Blank (configure manually)"})}),o.jsxs(tn,{className:"bg-slate-800 border-slate-700 max-h-64",children:[o.jsx(st,{value:"__blank__",children:"Blank - configure manually"}),["DevOps","Business","General"].map(W=>{const q=a.filter(fe=>fe.category===W);return q.length===0?null:q.map(fe=>o.jsxs(st,{value:fe.id,children:[o.jsx("span",{className:"font-medium",children:fe.label}),o.jsx("span",{className:"text-[10px] text-gray-500 ml-2",children:fe.description.slice(0,50)})]},fe.id))})]})]}),o.jsx("p",{className:"text-[10px] text-gray-500 mt-1",children:"Pre-fills the form. You can edit everything before saving."})]}),o.jsxs("div",{children:[o.jsx("label",{className:"text-xs text-gray-400 mb-1 block",children:"Watcher Name"}),o.jsx(Dt,{className:"bg-slate-800 border-slate-700 text-white",value:C.name,onChange:W=>j({...C,name:W.target.value}),placeholder:"e.g. github-issue-triage"}),o.jsx("p",{className:"text-[10px] text-gray-500 mt-1",children:"Used in the webhook URL. Keep it short, no spaces."})]}),o.jsxs("div",{children:[o.jsx("label",{className:"text-xs text-gray-400 mb-1 block",children:"What does this watcher do?"}),o.jsx(Dt,{className:"bg-slate-800 border-slate-700 text-white",value:C.description,onChange:W=>j({...C,description:W.target.value}),placeholder:"e.g. Triages new GitHub issues and notifies the team"})]}),o.jsxs("div",{children:[o.jsx("label",{className:"text-xs text-gray-400 mb-1 block",children:"Agent Instructions"}),o.jsx("textarea",{className:"w-full bg-slate-800 border border-slate-700 rounded-md px-3 py-2 text-sm text-white resize-none h-20",value:C.action,onChange:W=>j({...C,action:W.target.value}),placeholder:"e.g. Read the incoming webhook payload. If it's a new issue, assign a priority label and post a summary to the team channel."}),o.jsx("p",{className:"text-[10px] text-gray-500 mt-1",children:"The full prompt given to the agent when this watcher fires. Be specific."})]}),o.jsxs("div",{children:[o.jsx("label",{className:"text-xs text-gray-400 mb-1 block",children:"Deliver Results To"}),i.filter(W=>W.channelMeta).length>0?o.jsx("div",{className:"space-y-2 p-3 bg-slate-800/30 border border-slate-700 rounded-md max-h-48 overflow-y-auto",children:i.filter(W=>W.channelMeta).map((W,q)=>{const fe=C.destinations.some(ve=>ve.channel===W.channel&&JSON.stringify(ve.channelMeta)===JSON.stringify(W.channelMeta));return o.jsxs("label",{className:"flex items-center gap-3 cursor-pointer hover:bg-slate-700/30 rounded p-1.5 -m-1.5",children:[o.jsx("input",{type:"checkbox",checked:fe,onChange:()=>{j(fe?{...C,destinations:C.destinations.filter(ve=>!(ve.channel===W.channel&&JSON.stringify(ve.channelMeta)===JSON.stringify(W.channelMeta)))}:{...C,destinations:[...C.destinations,{channel:W.channel,channelMeta:W.channelMeta,label:W.label,tenantId:W.tenantId}]})},className:"rounded border-slate-600 bg-slate-800 text-[#00d9ff] focus:ring-[#00d9ff]/50"}),o.jsx("span",{className:"text-sm text-gray-300",children:W.label})]},`${W.channel}-${q}`)})}):U.length>0?o.jsxs("div",{className:"flex items-center gap-2 p-2.5 bg-slate-800/50 border border-slate-700 rounded-md",children:[o.jsx(Zi,{className:"w-4 h-4 text-amber-400 shrink-0"}),o.jsx("p",{className:"text-xs text-gray-400",children:"Channels are running but no conversations yet. Send a message on Discord/Telegram first so the system knows where to deliver."})]}):o.jsxs("div",{className:"flex items-center gap-2 p-2.5 bg-slate-800/50 border border-slate-700 rounded-md",children:[o.jsx(Zi,{className:"w-4 h-4 text-amber-400 shrink-0"}),o.jsx("p",{className:"text-xs text-gray-400",children:"No channels active. Enable a channel (Telegram, Discord, etc.) in the Channels page first."})]}),C.destinations.length>0&&o.jsxs("p",{className:"text-[10px] text-[#00d9ff] mt-1",children:[C.destinations.length," destination",C.destinations.length>1?"s":""," selected"]}),C.destinations.length===0&&i.filter(W=>W.channelMeta).length>0&&o.jsx("p",{className:"text-[10px] text-gray-500 mt-1",children:"No destinations selected - results will be stored only."})]}),o.jsxs("div",{children:[o.jsx("label",{className:"text-xs text-gray-400 mb-1.5 block",children:"Trigger Source"}),o.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[o.jsxs("button",{type:"button",onClick:()=>j({...C,triggerType:"webhook"}),className:`flex items-center gap-2 px-3 py-2 rounded-md border text-sm transition-colors ${C.triggerType==="webhook"?"bg-[#00d9ff]/10 border-[#00d9ff]/50 text-[#00d9ff]":"bg-slate-800/60 border-slate-700 text-gray-400 hover:text-white hover:border-slate-600"}`,children:[o.jsx(hA,{className:"w-4 h-4"}),o.jsx("span",{className:"flex-1 text-left",children:"Webhook"})]}),o.jsxs("button",{type:"button",onClick:()=>j({...C,triggerType:"integration"}),className:`flex items-center gap-2 px-3 py-2 rounded-md border text-sm transition-colors ${C.triggerType==="integration"?"bg-[#00d9ff]/10 border-[#00d9ff]/50 text-[#00d9ff]":"bg-slate-800/60 border-slate-700 text-gray-400 hover:text-white hover:border-slate-600"}`,children:[o.jsx(ha,{className:"w-4 h-4"}),o.jsx("span",{className:"flex-1 text-left",children:"Integration Event"})]})]})]}),C.triggerType==="integration"&&o.jsx("div",{className:"space-y-3 p-3 rounded-md bg-slate-900/40 border border-slate-800",children:h.length===0?o.jsxs("div",{className:"flex items-start gap-2 text-xs text-amber-400/80",children:[o.jsx(Zi,{className:"w-4 h-4 shrink-0 mt-0.5"}),o.jsxs("div",{children:[o.jsx("p",{children:"No connected integrations support watcher events yet."}),f.length>0&&o.jsxs("p",{className:"text-gray-500 mt-1",children:["Connect one of: ",f.join(", ")," — then come back."]})]})]}):o.jsxs(o.Fragment,{children:[o.jsxs("div",{children:[o.jsx("label",{className:"text-xs text-gray-400 mb-1 block",children:"Integration"}),o.jsxs(Qt,{value:C.integration,onValueChange:W=>j({...C,integration:W,event:"",eventParams:{}}),children:[o.jsx(en,{className:"bg-slate-800 border-slate-700 text-white",children:o.jsx(Zt,{placeholder:"Pick a connected integration"})}),o.jsx(tn,{className:"bg-slate-800 border-slate-700",children:Array.from(new Set(h.map(W=>W.integration))).map(W=>o.jsx(st,{value:W,children:W},W))})]})]}),C.integration&&o.jsxs("div",{children:[o.jsx("label",{className:"text-xs text-gray-400 mb-1 block",children:"Event"}),o.jsxs(Qt,{value:C.event,onValueChange:W=>j({...C,event:W,eventParams:{}}),children:[o.jsx(en,{className:"bg-slate-800 border-slate-700 text-white",children:o.jsx(Zt,{placeholder:"Pick an event"})}),o.jsx(tn,{className:"bg-slate-800 border-slate-700",children:h.filter(W=>W.integration===C.integration).map(W=>o.jsx(st,{value:W.event,children:o.jsxs("div",{children:[o.jsx("span",{children:W.label}),o.jsx("span",{className:"text-[10px] text-gray-500 ml-2",children:W.description})]})},W.event))})]})]}),C.event&&(()=>{const W=h.find(q=>q.integration===C.integration&&q.event===C.event);return!W||W.params.length===0?o.jsx("p",{className:"text-[11px] text-gray-500",children:"No parameters — fires on any matching event for the connected account."}):o.jsx("div",{className:"space-y-2",children:W.params.map(q=>o.jsxs("div",{children:[o.jsxs("label",{className:"text-[11px] text-gray-400 mb-1 block",children:[q.label," ",q.required&&o.jsx("span",{className:"text-red-400",children:"*"})]}),o.jsx(Dt,{className:"bg-slate-800 border-slate-700 text-white text-sm",value:C.eventParams[q.key]??"",onChange:fe=>j({...C,eventParams:{...C.eventParams,[q.key]:fe.target.value}}),placeholder:q.hint??""}),q.hint&&o.jsx("p",{className:"text-[10px] text-gray-500 mt-0.5",children:q.hint})]},q.key))})})(),o.jsxs("div",{children:[o.jsx("label",{className:"text-xs text-gray-400 mb-1 block",children:"Poll interval"}),o.jsxs(Qt,{value:C.pollIntervalSeconds,onValueChange:W=>j({...C,pollIntervalSeconds:W}),children:[o.jsx(en,{className:"bg-slate-800 border-slate-700 text-white",children:o.jsx(Zt,{})}),o.jsxs(tn,{className:"bg-slate-800 border-slate-700",children:[o.jsx(st,{value:"30",children:"30 seconds (min)"}),o.jsx(st,{value:"60",children:"1 minute"}),o.jsx(st,{value:"300",children:"5 minutes"}),o.jsx(st,{value:"900",children:"15 minutes"}),o.jsx(st,{value:"1800",children:"30 minutes"}),o.jsx(st,{value:"3600",children:"1 hour"})]})]}),o.jsx("p",{className:"text-[10px] text-gray-500 mt-1",children:"How often to check the provider. Providers rate-limit — don't go too aggressive."})]})]})}),C.triggerType==="webhook"&&o.jsxs("div",{children:[o.jsx("label",{className:"text-xs text-gray-400 mb-1 block",children:"Match Pattern"}),o.jsxs(Qt,{value:((ue=af.find(W=>W.value===C.pattern))==null?void 0:ue.label)||"Custom",onValueChange:W=>{const q=af.find(fe=>fe.label===W);q&&j({...C,pattern:q.value})},children:[o.jsx(en,{className:"bg-slate-800 border-slate-700 text-white mb-2",children:o.jsx(Zt,{placeholder:"Pick a common pattern or write custom"})}),o.jsx(tn,{className:"bg-slate-800 border-slate-700",children:af.map(W=>o.jsx(st,{value:W.label,children:o.jsxs("div",{children:[o.jsx("span",{children:W.label}),o.jsx("span",{className:"text-[10px] text-gray-500 ml-2",children:W.desc})]})},W.label))})]}),(C.pattern||((ke=af.find(W=>W.value===C.pattern))==null?void 0:ke.label)==="Custom")&&o.jsx("textarea",{className:"w-full bg-slate-800 border border-slate-700 rounded-md px-3 py-2 text-sm text-white font-mono resize-none h-16",value:C.pattern,onChange:W=>j({...C,pattern:W.target.value}),placeholder:'{"event": "push"}'}),o.jsx("p",{className:"text-[10px] text-gray-500 mt-1",children:"Leave empty to trigger on any incoming webhook. Add a pattern to only fire on matching payloads."})]}),o.jsxs("div",{children:[o.jsx("label",{className:"text-xs text-gray-400 mb-1 block",children:"Cooldown"}),o.jsxs(Qt,{value:C.cooldownSeconds,onValueChange:W=>j({...C,cooldownSeconds:W}),children:[o.jsx(en,{className:"bg-slate-800 border-slate-700 text-white",children:o.jsx(Zt,{})}),o.jsxs(tn,{className:"bg-slate-800 border-slate-700",children:[o.jsx(st,{value:"0",children:"No cooldown - fire every time"}),o.jsx(st,{value:"10",children:"10 seconds"}),o.jsx(st,{value:"30",children:"30 seconds"}),o.jsx(st,{value:"60",children:"1 minute"}),o.jsx(st,{value:"300",children:"5 minutes"}),o.jsx(st,{value:"600",children:"10 minutes"}),o.jsx(st,{value:"3600",children:"1 hour"})]})]}),o.jsx("p",{className:"text-[10px] text-gray-500 mt-1",children:"Prevents duplicate triggers. If multiple events arrive within the cooldown window, only the first fires."})]}),o.jsxs("div",{children:[o.jsxs("label",{className:"text-xs text-gray-400 mb-1 block",children:["Project Context ",o.jsx("span",{className:"text-gray-600",children:"(optional)"})]}),o.jsx("textarea",{className:"w-full bg-slate-800 border border-slate-700 rounded-md px-3 py-2 text-sm text-white resize-none h-16",value:C.context,onChange:W=>j({...C,context:W.target.value}),placeholder:"e.g. Repo: daemora/daemora, Stack: Node.js + SQLite, Main branch: main, Team: @umar @ali"}),o.jsx("p",{className:"text-[10px] text-gray-500 mt-1",children:"Background knowledge injected when this watcher fires. Helps the agent understand the project without reading docs every time."})]}),o.jsxs(at,{onClick:ne,disabled:R,className:"w-full bg-[#00d9ff]/20 text-[#00d9ff] border border-[#00d9ff]/30 hover:bg-[#00d9ff]/30",children:[R?o.jsx($t,{className:"w-4 h-4 animate-spin mr-2"}):null,S?"Update Watcher":"Create Watcher"]})]})]})]})]})]}),o.jsxs("div",{className:"flex gap-4",children:[o.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 bg-slate-800/50 border border-slate-700/50 rounded-lg",children:[o.jsx("span",{className:"text-xs text-gray-400",children:"Total"}),o.jsx("span",{className:"text-sm font-mono text-white",children:t.length})]}),o.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 bg-slate-800/50 border border-slate-700/50 rounded-lg",children:[o.jsx("div",{className:"w-2 h-2 bg-emerald-400 rounded-full"}),o.jsx("span",{className:"text-xs text-gray-400",children:"Active"}),o.jsx("span",{className:"text-sm font-mono text-emerald-400",children:oe})]})]}),g?o.jsx("div",{className:"flex items-center justify-center py-20",children:o.jsx($t,{className:"w-6 h-6 animate-spin text-[#00d9ff]"})}):t.length===0?o.jsx(rn,{className:"bg-slate-900/50 border-slate-800",children:o.jsxs(on,{className:"py-12 text-center",children:[o.jsx(Ss,{className:"w-10 h-10 mx-auto mb-3 opacity-30 text-gray-600"}),o.jsx("p",{className:"text-gray-400 mb-2",children:"No watchers yet"}),o.jsx("p",{className:"text-xs text-gray-500 max-w-md mx-auto",children:"Watchers listen for external events (webhooks from GitHub, Stripe, monitoring tools, etc.) and automatically run an agent task when triggered."})]})}):o.jsx("div",{className:"space-y-3",children:t.map(W=>{var ve;const q=I===W.id,fe=ye(W.name);return o.jsx(rn,{className:"bg-slate-900/50 border-slate-800 hover:border-slate-700 transition-colors",children:o.jsxs(on,{className:"p-4",children:[o.jsxs("div",{className:"flex items-start justify-between gap-4",children:[o.jsxs("div",{className:"flex-1 min-w-0 cursor-pointer",onClick:()=>M(q?null:W.id),children:[o.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[o.jsx("h3",{className:"text-sm font-semibold text-white truncate",children:W.name}),o.jsx(Kt,{className:`text-[10px] ${W.enabled?"bg-emerald-500/20 text-emerald-400 border-emerald-500/30":"bg-slate-700/50 text-gray-500 border-slate-600"}`,children:W.enabled?"Active":"Paused"}),(((ve=W.destinations)==null?void 0:ve.length)>0?W.destinations:W.channel?[{channel:W.channel}]:[]).map((Se,Ke)=>o.jsxs(Kt,{className:"bg-purple-500/20 text-purple-400 border-purple-500/30 text-[10px]",children:["→ ",Se.label||Se.channel]},Ke))]}),W.description&&o.jsx("p",{className:"text-xs text-gray-400 mb-1.5",children:W.description}),o.jsxs("div",{className:"flex items-center gap-4 text-[10px] text-gray-500 font-mono",children:[o.jsxs("span",{children:["Fired ",W.triggerCount," time",W.triggerCount!==1?"s":""]}),W.lastTriggeredAt&&o.jsxs("span",{children:["Last: ",new Date(W.lastTriggeredAt).toLocaleString()]}),W.cooldownSeconds>0&&o.jsxs("span",{className:"flex items-center gap-1",children:[o.jsx(es,{className:"w-3 h-3"}),W.cooldownSeconds>=3600?`${W.cooldownSeconds/3600}h`:W.cooldownSeconds>=60?`${W.cooldownSeconds/60}m`:`${W.cooldownSeconds}s`," cooldown"]}),q?o.jsx(by,{className:"w-3 h-3"}):o.jsx(fo,{className:"w-3 h-3"})]})]}),o.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[o.jsx(Pd,{checked:!!W.enabled,onCheckedChange:()=>A(W),className:"data-[state=checked]:bg-emerald-500"}),o.jsx(at,{variant:"ghost",size:"icon",className:"h-7 w-7 text-gray-400 hover:text-white",onClick:()=>ee(W),children:o.jsx(Sy,{className:"w-3.5 h-3.5"})}),o.jsx(at,{variant:"ghost",size:"icon",className:"h-7 w-7 text-gray-400 hover:text-red-400",onClick:()=>J(W),children:o.jsx(qn,{className:"w-3.5 h-3.5"})})]})]}),q&&o.jsxs("div",{className:"mt-4 pt-4 border-t border-slate-800 space-y-3",children:[o.jsxs("div",{children:[o.jsx("label",{className:"text-[10px] text-gray-500 uppercase tracking-wider",children:"Agent Instructions"}),o.jsx("p",{className:"text-xs text-gray-300 mt-1 bg-slate-800/50 rounded p-2",children:W.action})]}),W.pattern&&o.jsxs("div",{children:[o.jsx("label",{className:"text-[10px] text-gray-500 uppercase tracking-wider",children:"Match Pattern"}),o.jsx("pre",{className:"text-xs text-gray-300 mt-1 bg-slate-800/50 rounded p-2 font-mono overflow-x-auto",children:JSON.stringify(W.pattern,null,2)})]}),o.jsxs("div",{children:[o.jsx("label",{className:"text-[10px] text-gray-500 uppercase tracking-wider",children:"Webhook URL"}),se&&o.jsxs("div",{className:"flex items-center gap-2 mt-1 mb-2 p-2 bg-amber-500/10 border border-amber-500/20 rounded",children:[o.jsx(Zi,{className:"w-4 h-4 text-amber-400 shrink-0"}),o.jsx("p",{className:"text-[10px] text-amber-300",children:"This is a local URL. External services (GitHub, Stripe) can't reach it. Enable a tunnel in Settings or set DAEMORA_PUBLIC_URL to get a public URL."})]}),o.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[o.jsx("code",{className:"flex-1 text-xs text-[#00d9ff] bg-slate-800/50 rounded p-2 font-mono truncate",children:fe}),o.jsx(at,{variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0 text-gray-400 hover:text-white",onClick:()=>X(fe,W.id+"-url"),children:L===W.id+"-url"?o.jsx(_i,{className:"w-3.5 h-3.5 text-emerald-400"}):o.jsx(df,{className:"w-3.5 h-3.5"})})]})]}),V&&o.jsxs("div",{children:[o.jsx("label",{className:"text-[10px] text-gray-500 uppercase tracking-wider",children:"Auth Header (required)"}),o.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[o.jsxs("code",{className:"flex-1 text-xs text-gray-300 bg-slate-800/50 rounded p-2 font-mono truncate",children:["Authorization: Bearer ",V]}),o.jsx(at,{variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0 text-gray-400 hover:text-white",onClick:()=>X(`Bearer ${V}`,W.id+"-token"),children:L===W.id+"-token"?o.jsx(_i,{className:"w-3.5 h-3.5 text-emerald-400"}):o.jsx(df,{className:"w-3.5 h-3.5"})})]})]}),o.jsxs("div",{children:[o.jsx("label",{className:"text-[10px] text-gray-500 uppercase tracking-wider",children:"Test with cURL"}),o.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[o.jsxs("code",{className:"flex-1 text-[10px] text-gray-400 bg-slate-800/50 rounded p-2 font-mono overflow-x-auto whitespace-nowrap",children:["curl -X POST ",fe,' -H "Content-Type: application/json" ',V?`-H "Authorization: Bearer ${V}" `:"","-d '","{}","'"]}),o.jsx(at,{variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0 text-gray-400 hover:text-white",onClick:()=>X(`curl -X POST ${fe} -H "Content-Type: application/json" ${V?`-H "Authorization: Bearer ${V}" `:""}-d '{}'`,W.id+"-curl"),children:L===W.id+"-curl"?o.jsx(_i,{className:"w-3.5 h-3.5 text-emerald-400"}):o.jsx(df,{className:"w-3.5 h-3.5"})})]})]})]})]})},W.id)})}),o.jsx(hi,{open:!!K,onOpenChange:W=>{W||J(null)},children:o.jsxs(fi,{className:"bg-slate-900 border-slate-700 text-white max-w-sm",children:[o.jsx(pi,{children:o.jsxs(mi,{className:"flex items-center gap-2 text-red-400",children:[o.jsx(qn,{className:"w-5 h-5"}),"Delete Watcher"]})}),o.jsxs("div",{className:"mt-2 space-y-4",children:[o.jsxs("p",{className:"text-sm text-gray-300",children:["Are you sure you want to delete ",o.jsxs("span",{className:"font-semibold text-white",children:['"',K==null?void 0:K.name,'"']}),"? External services sending webhooks to this endpoint will get 404 errors."]}),o.jsxs("div",{className:"flex gap-3 justify-end",children:[o.jsx(at,{variant:"outline",size:"sm",className:"border-slate-700 text-gray-400 hover:text-white",onClick:()=>J(null),children:"Cancel"}),o.jsx(at,{size:"sm",className:"bg-red-500/20 text-red-400 border border-red-500/30 hover:bg-red-500/30",onClick:z,children:"Delete"})]})]})]})})]})}function VX(){const[t,e]=x.useState([]),[n,r]=x.useState(!0),[i,s]=x.useState(""),[a,c]=x.useState(!1),[h,d]=x.useState(null),[f,p]=x.useState({}),[g,v]=x.useState(!1),[k,w]=x.useState(new Set),[S,T]=x.useState({}),[C,j]=x.useState([]),[R,_]=x.useState(""),[I,M]=x.useState(.7),[L,$]=x.useState(!1),E=x.useCallback(async()=>{try{const X=await we("/api/crew");if(X.ok){const se=(await X.json()).crew||[];e(se);const oe={};for(const U of se)if(U.configSchema&&Object.keys(U.configSchema).length>0)try{const ue=await we(`/api/crew/${U.id}/config`);if(ue.ok){const ke=await ue.json(),W=[];for(const[q,fe]of Object.entries(ke.schema))fe.required&&!ke.values[q]&&W.push(fe.label||q);oe[U.id]={configured:W.length===0,missing:W}}}catch{}T(oe)}}catch{}finally{r(!1)}},[]);x.useEffect(()=>{E()},[E]);const P=async(X,ye)=>{try{const se=await we(`/api/crew/${X}/${ye?"enable":"disable"}`,{method:"POST"});se.ok?(me.success(ye?"Crew member enabled":"Crew member disabled"),E()):me.error((await se.json()).error||"Failed")}catch{me.error("API error")}},V=async X=>{try{const ye=await we(`/api/crew/${X}/reload`,{method:"POST"});ye.ok?(me.success("Crew member reloaded"),E()):me.error((await ye.json()).error||"Reload failed")}catch{me.error("API error")}},F=async()=>{if(i.trim()){c(!0);try{const X=await we("/api/crew/install",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({pkg:i.trim()})});X.ok?(me.success(`Installed: ${i}`),s(""),E()):me.error((await X.json()).error||"Install failed")}catch{me.error("Install failed")}finally{c(!1)}}},[K,J]=x.useState(null),[Q,Z]=x.useState(!1),D=X=>J(X),ne=async()=>{if(K){Z(!0);try{const X=await we(`/api/crew/${K}/uninstall`,{method:"DELETE"});X.ok?(me.success("Crew member removed"),E(),J(null)):me.error((await X.json()).error||"Remove failed")}catch{me.error("Remove failed")}finally{Z(!1)}}},A=async X=>{d(X),w(new Set),_(X.model??""),M(typeof X.temperature=="number"?X.temperature:.7);const[ye,se]=await Promise.allSettled([X.configSchema&&Object.keys(X.configSchema).length>0?we(`/api/crew/${X.id}/config`):Promise.resolve(null),we("/api/providers")]);if(ye.status==="fulfilled"&&ye.value&&ye.value.ok)try{const oe=await ye.value.json();p(oe.values||{})}catch{}else p({});if(se.status==="fulfilled"&&se.value.ok)try{const oe=await se.value.json();j(oe.providers||[])}catch{}},z=async()=>{if(h){$(!0);try{const X={model:R===""?null:R,temperature:I},ye=await we(`/api/crew/${h.id}/profile`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(X)});ye.ok?(me.success("Model settings saved"),E()):me.error((await ye.json()).error||"Save failed")}catch{me.error("Save failed")}finally{$(!1)}}},ee=async()=>{if(h){v(!0);try{const X=await we(`/api/crew/${h.id}/config`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({updates:f})});X.ok?(me.success("Config saved"),d(null)):me.error((await X.json()).error||"Save failed")}catch{me.error("Save failed")}finally{v(!1)}}},B=X=>{if(X.status==="disabled")return o.jsx(LD,{className:"w-4 h-4 text-gray-500"});if(X.status==="error")return o.jsx(wy,{className:"w-4 h-4 text-red-400"});const ye=S[X.id];return ye&&!ye.configured?o.jsx(Gr,{className:"w-4 h-4 text-amber-400"}):o.jsx(_i,{className:"w-4 h-4 text-emerald-400"})};return n?o.jsx("div",{className:"flex items-center justify-center h-full",children:o.jsx($t,{className:"w-8 h-8 text-[#38bdf8] animate-spin"})}):o.jsxs("div",{className:"space-y-6",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{children:[o.jsx("h2",{className:"text-3xl font-bold text-white mb-2",children:"Crew"}),o.jsx("p",{className:"text-gray-400 text-sm",children:"Your Daemora Crew"})]}),o.jsxs(at,{onClick:E,variant:"ghost",size:"sm",className:"text-gray-400 hover:text-[#38bdf8] text-sm",children:[o.jsx(so,{className:"w-4 h-4 mr-2"})," Refresh"]})]}),o.jsx(rn,{className:"bg-slate-900/50 border-slate-800",children:o.jsx(on,{className:"p-5",children:o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx(kN,{className:"w-5 h-5 text-[#38bdf8] shrink-0"}),o.jsx(Dt,{value:i,onChange:X=>s(X.target.value),placeholder:"Install from npm - e.g. daemora-crew-weather",className:"bg-slate-900 border-slate-700 text-sm flex-1",onKeyDown:X=>X.key==="Enter"&&F()}),o.jsx(at,{onClick:F,disabled:!i.trim()||a,size:"sm",className:"bg-gradient-to-r from-[#0891b2] to-[#0d9488] text-white text-sm px-6",children:a?o.jsx($t,{className:"w-4 h-4 animate-spin"}):"Install"})]})})}),o.jsxs("div",{className:"flex items-center gap-6 text-sm text-gray-500",children:[o.jsxs("span",{children:[t.length," crew member(s)"]}),o.jsxs("span",{className:"text-emerald-400",children:[t.filter(X=>X.status==="loaded").length," active"]}),t.some(X=>X.status==="error")&&o.jsxs("span",{className:"text-red-400",children:[t.filter(X=>X.status==="error").length," error(s)"]}),o.jsxs("span",{children:[t.reduce((X,ye)=>X+ye.toolNames.length,0)," tools"]})]}),t.length===0?o.jsx(rn,{className:"bg-slate-900/50 border-slate-800",children:o.jsxs(on,{className:"py-16 text-center",children:[o.jsx(TN,{className:"w-12 h-12 text-gray-700 mx-auto mb-4"}),o.jsx("p",{className:"text-gray-500 text-base mb-2",children:"No crew members installed"}),o.jsxs("p",{className:"text-gray-600 text-sm",children:["Install from npm above, or drop folders in ",o.jsx("code",{className:"text-[#38bdf8] bg-slate-800 px-2 py-0.5 rounded",children:"crew/"})]})]})}):o.jsx("div",{className:"space-y-3",children:t.map(X=>o.jsx(rn,{className:`bg-slate-900/50 border-slate-800 hover:border-slate-700 transition-colors ${X.status==="error"?"border-red-500/30":""}`,children:o.jsx(on,{className:"p-5",children:o.jsxs("div",{className:"flex items-start justify-between gap-4",children:[o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[B(X),o.jsx("span",{className:"text-base font-semibold text-white",children:X.name}),o.jsxs("span",{className:"text-sm text-gray-500",children:["v",X.version||"0.0.0"]}),o.jsx(Kt,{variant:"outline",className:`text-xs ${X.status==="error"?"border-red-500/30 text-red-400":X.status==="disabled"?"border-gray-700 text-gray-500":S[X.id]&&!S[X.id].configured?"border-amber-500/30 text-amber-400":"border-emerald-500/30 text-emerald-400"}`,children:X.status==="error"?"error":X.status==="disabled"?"disabled":X.status==="needs-config"||S[X.id]&&!S[X.id].configured?"needs config":"active"})]}),X.description&&o.jsx("p",{className:"text-sm text-gray-400 mb-2",children:X.description}),S[X.id]&&!S[X.id].configured&&o.jsxs("div",{className:"flex items-center gap-2 mb-3 p-2 bg-amber-500/5 border border-amber-500/20 rounded-lg",children:[o.jsx(Gr,{className:"w-4 h-4 text-amber-400 shrink-0"}),o.jsxs("span",{className:"text-sm text-amber-400",children:["Missing: ",S[X.id].missing.join(", ")]}),o.jsx("button",{onClick:()=>A(X),className:"text-xs text-[#38bdf8] hover:underline ml-auto",children:"Configure"})]}),o.jsxs("div",{className:"flex flex-wrap gap-3 text-sm text-gray-500",children:[X.toolNames.length>0&&o.jsxs("span",{className:"flex items-center gap-1",children:[o.jsx(PN,{className:"w-3.5 h-3.5"}),X.toolNames.length," tool",X.toolNames.length>1?"s":"",o.jsxs("span",{className:"text-xs text-gray-600",children:["(",X.toolNames.join(", "),")"]})]}),X.channelIds.length>0&&o.jsxs("span",{className:"flex items-center gap-1",children:[o.jsx(Ty,{className:"w-3.5 h-3.5"}),X.channelIds.join(", ")]}),X.hookEvents.length>0&&o.jsxs("span",{className:"text-xs text-gray-600",children:["hooks: ",X.hookEvents.join(", ")]}),X.serviceIds.length>0&&o.jsxs("span",{className:"text-xs text-gray-600",children:["services: ",X.serviceIds.join(", ")]}),o.jsxs("span",{className:"text-xs text-gray-600",children:["model: ",o.jsx("span",{className:"text-gray-400",children:X.model??"default"})]})]}),X.error&&o.jsxs("div",{className:"flex items-center gap-2 mt-2 text-sm text-red-400",children:[o.jsx(Gr,{className:"w-3.5 h-3.5"}),X.error]})]}),o.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[o.jsx(at,{variant:"ghost",size:"icon",onClick:()=>A(X),className:"text-gray-500 hover:text-[#38bdf8]",title:"Configure",children:o.jsx(JD,{className:"w-4 h-4"})}),o.jsx(Pd,{checked:X.enabled,onCheckedChange:ye=>P(X.id,ye),className:"data-[state=checked]:bg-emerald-500"}),o.jsx(at,{variant:"ghost",size:"icon",onClick:()=>V(X.id),className:"text-gray-500 hover:text-[#38bdf8]",title:"Reload",children:o.jsx(VD,{className:"w-4 h-4"})}),o.jsx(at,{variant:"ghost",size:"icon",onClick:()=>D(X.id),className:"text-gray-500 hover:text-red-400",title:"Remove",children:o.jsx(qn,{className:"w-4 h-4"})})]})]})})},X.id))}),o.jsx(hi,{open:!!h,onOpenChange:X=>{X||d(null)},children:o.jsxs(fi,{className:"bg-slate-950 border-slate-800 text-white max-w-xl",children:[o.jsx(pi,{children:o.jsxs(mi,{className:"text-lg border-b border-slate-800 pb-4",children:["Configure: ",h==null?void 0:h.name]})}),o.jsxs("div",{className:"space-y-6 pt-4 max-h-[70vh] overflow-y-auto pr-1",children:[o.jsxs("section",{className:"space-y-3",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("h3",{className:"text-sm font-semibold text-gray-200",children:"Model"}),o.jsx("span",{className:"text-[11px] text-gray-500",children:"Overrides main agent's model for this crew"})]}),o.jsxs("div",{className:"space-y-1.5",children:[o.jsx("label",{className:"text-xs text-gray-400",children:"Provider : model"}),o.jsxs("select",{value:R,onChange:X=>_(X.target.value),className:"w-full bg-slate-900 border border-slate-700 rounded-md text-sm px-3 py-2 text-gray-200 focus:outline-none focus:ring-1 focus:ring-[#38bdf8]",children:[o.jsx("option",{value:"",children:"Use main agent's default"}),C.filter(X=>X.configured&&X.models.length>0).map(X=>o.jsx("optgroup",{label:X.name,children:X.models.map(ye=>o.jsx("option",{value:ye.id,children:ye.name},ye.id))},X.id))]}),C.length>0&&C.every(X=>!X.configured)&&o.jsx("p",{className:"text-[11px] text-amber-400",children:"No providers configured — add an API key in Settings → Secrets."})]}),o.jsxs("div",{className:"space-y-1.5",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("label",{className:"text-xs text-gray-400",children:"Temperature"}),o.jsx("span",{className:"text-xs text-gray-300 tabular-nums",children:I.toFixed(2)})]}),o.jsx("input",{type:"range",min:0,max:2,step:.05,value:I,onChange:X=>M(Number(X.target.value)),className:"w-full accent-[#38bdf8]"}),o.jsxs("div",{className:"flex justify-between text-[10px] text-gray-600",children:[o.jsx("span",{children:"focused"}),o.jsx("span",{children:"creative"})]})]}),o.jsxs(at,{onClick:z,disabled:L,className:"w-full bg-gradient-to-r from-[#0891b2] to-[#0d9488] text-white text-sm",children:[L?o.jsx($t,{className:"w-4 h-4 animate-spin mr-2"}):o.jsx(rd,{className:"w-4 h-4 mr-2"}),"Save Model Settings"]}),o.jsx("p",{className:"text-[11px] text-gray-500",children:"Takes effect on the next delegation — no restart needed."})]}),(h==null?void 0:h.configSchema)&&Object.keys(h.configSchema).length>0&&o.jsxs("section",{className:"space-y-3 border-t border-slate-800 pt-5",children:[o.jsx("h3",{className:"text-sm font-semibold text-gray-200",children:"Plugin Settings"}),Object.entries(h.configSchema).map(([X,ye])=>{const se=ye.type==="secret"||ye.type==="password",oe=k.has(X);return o.jsxs("div",{className:"space-y-1.5",children:[o.jsxs("label",{className:"text-sm text-gray-300 flex items-center gap-2",children:[ye.label||X,ye.required&&o.jsx("span",{className:"text-red-400 text-xs",children:"required"})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(Dt,{type:se&&!oe?"password":"text",value:f[X]||"",onChange:U=>p(ue=>({...ue,[X]:U.target.value})),placeholder:ye.default||`Enter ${ye.label||X}`,className:"bg-slate-900 border-slate-700 text-sm flex-1"}),se&&o.jsx(at,{variant:"ghost",size:"icon",onClick:()=>{const U=new Set(k);U.has(X)?U.delete(X):U.add(X),w(U)},className:"text-gray-500 hover:text-[#38bdf8]",children:oe?o.jsx(sc,{className:"w-4 h-4"}):o.jsx(Ss,{className:"w-4 h-4"})})]}),ye.type&&ye.type!=="secret"&&ye.type!=="password"&&ye.type!=="string"&&o.jsxs("p",{className:"text-xs text-gray-600",children:["Type: ",ye.type]})]},X)}),o.jsxs(at,{onClick:ee,disabled:g,className:"w-full bg-slate-800 hover:bg-slate-700 text-white text-sm",children:[g?o.jsx($t,{className:"w-4 h-4 animate-spin mr-2"}):o.jsx(rd,{className:"w-4 h-4 mr-2"}),"Save Plugin Settings"]})]})]})]})}),o.jsx(js,{open:!!K,onOpenChange:X=>!X&&J(null),children:o.jsxs(Ps,{className:"bg-slate-950 border-slate-800/80 text-gray-200 font-mono",children:[o.jsxs(_s,{children:[o.jsxs(Is,{className:"text-white tracking-tight flex items-center gap-2",children:[o.jsx(qn,{className:"w-4 h-4 text-red-400"}),"Remove ",K]}),o.jsx(Ms,{className:"text-gray-400 text-sm leading-relaxed",children:"Deletes the crew member folder. You'll need to reinstall to get it back."})]}),o.jsxs(Rs,{children:[o.jsx(As,{className:"bg-slate-900 border-slate-800 text-gray-300 hover:bg-slate-800 hover:text-white",children:"Cancel"}),o.jsx(Ds,{onClick:ne,disabled:Q,className:"bg-red-600 hover:bg-red-500 text-white border border-red-500/40",children:Q?"Removing...":"Remove"})]})]})})]})}const ia={active:"bg-emerald-500/20 text-emerald-400 border-emerald-500/30",completed:"bg-blue-500/20 text-blue-400 border-blue-500/30",paused:"bg-amber-500/20 text-amber-400 border-amber-500/30",disbanded:"bg-red-500/20 text-red-400 border-red-500/30",working:"bg-cyan-500/20 text-cyan-400 border-cyan-500/30",done:"bg-emerald-500/20 text-emerald-400 border-emerald-500/30",failed:"bg-red-500/20 text-red-400 border-red-500/30",idle:"bg-slate-700/50 text-gray-400 border-slate-600",pending:"bg-slate-700/50 text-gray-400 border-slate-600",assigned:"bg-amber-500/20 text-amber-400 border-amber-500/30",plan_submitted:"bg-purple-500/20 text-purple-400 border-purple-500/30",in_progress:"bg-cyan-500/20 text-cyan-400 border-cyan-500/30",blocked:"bg-red-500/20 text-red-400 border-red-500/30"},WX={completed:_i,failed:wy,in_progress:$t,blocked:Gr,pending:es,assigned:es,plan_submitted:SN};function HX(){var P,V;const[t,e]=x.useState([]),[n,r]=x.useState(!0),[i,s]=x.useState(null),[a,c]=x.useState(null),[h,d]=x.useState(!1),[f,p]=x.useState(!1),[g,v]=x.useState(!1),[k,w]=x.useState([]),[S,T]=x.useState([]),[C,j]=x.useState([]),[R,_]=x.useState({name:"",task:"",context:"",projectType:"coding",projectRepo:"",projectStack:"",templateId:"",pollInterval:"30",workers:[{name:"",profile:"coder",crew:"",task:""}]}),I=x.useCallback(async()=>{try{r(!0);const K=await(await we("/api/teams")).json();e(K.teams||[])}catch(F){me.error("Failed to load teams: "+F.message)}finally{r(!1)}},[]);x.useEffect(()=>{I(),we("/api/teams/templates").then(F=>F.json()).then(F=>w(F.templates||[])).catch(()=>{}),we("/api/tools").then(F=>F.json()).then(F=>{var J;const K=(((J=F.descriptions)==null?void 0:J.spawnAgent)||"").match(/Available profiles: (.+)/);K&&T(K[1].split(" · ").map(Q=>Q.replace(/\(.+\)/,"").trim()))}).catch(()=>{}),we("/api/crew").then(F=>F.json()).then(F=>{const K=(F.crew||[]).filter(J=>{var Q;return J.status==="loaded"&&((Q=J.toolNames)==null?void 0:Q.length)>0});j(K.map(J=>({id:J.id,name:J.name})))}).catch(()=>{})},[I]);const M=async()=>{if(!R.task){me.error("What should this team accomplish?");return}v(!0);try{const F={name:R.name||R.task.slice(0,30),task:R.task,context:R.context||void 0,project:R.name||R.task.slice(0,30),projectType:R.projectType||void 0,projectRepo:R.projectRepo||void 0,projectStack:R.projectStack||void 0};if(R.templateId)F.templateId=R.templateId;else if(F.workers=R.workers.filter(J=>J.name&&J.task).map(J=>({name:J.name,task:J.task,...J.crew?{crew:J.crew}:{profile:J.profile}})),F.workers.length===0){me.error("Add at least one worker"),v(!1);return}const K=await we("/api/teams",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(F)});if(!K.ok){const J=await K.json();throw new Error(J.error)}me.success("Team launched!"),p(!1),_({name:"",task:"",context:"",projectType:"coding",projectRepo:"",projectStack:"",templateId:"",pollInterval:"30",workers:[{name:"",profile:"coder",crew:"",task:""}]}),setTimeout(I,2e3)}catch(F){me.error(F.message)}finally{v(!1)}};x.useEffect(()=>{const F=setInterval(I,1e4);return()=>clearInterval(F)},[I]);const L=async F=>{d(!0);try{const J=await(await we(`/api/teams/${F}`)).json();c(J)}catch(K){me.error(K.message)}finally{d(!1)}},$=async F=>{try{await we(`/api/teams/${F}/disband`,{method:"POST"}),me.success("Team disbanded"),I(),c(null)}catch(K){me.error(K.message)}},E=t.filter(F=>F.status==="active").length;return o.jsxs("div",{className:"space-y-6",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{children:[o.jsxs("h2",{className:"text-2xl font-bold text-white flex items-center gap-3",children:[o.jsx(Qo,{className:"w-7 h-7 text-[#00d9ff]"}),"Teams"]}),o.jsx("p",{className:"text-[10px] text-gray-500 font-mono uppercase tracking-[0.3em] mt-1",children:"Project Teams - Lead + Workers Coordination"})]}),o.jsxs("div",{className:"flex gap-2",children:[o.jsx(at,{variant:"outline",size:"sm",onClick:I,className:"border-slate-700 text-gray-400 hover:text-white hover:border-slate-500",children:o.jsx(so,{className:"w-4 h-4"})}),o.jsxs(hi,{open:f,onOpenChange:p,children:[o.jsx(fl,{asChild:!0,children:o.jsxs(at,{size:"sm",className:"bg-[#00d9ff]/20 text-[#00d9ff] border border-[#00d9ff]/30 hover:bg-[#00d9ff]/30",children:[o.jsx(Cs,{className:"w-4 h-4 mr-1"})," New Team"]})}),o.jsxs(fi,{className:"bg-slate-900 border-slate-700 text-white max-w-lg max-h-[85vh] overflow-y-auto",children:[o.jsx(pi,{children:o.jsx(mi,{children:"Launch a Team"})}),o.jsxs("div",{className:"space-y-4 mt-4",children:[k.length>0&&o.jsxs("div",{children:[o.jsx("label",{className:"text-xs text-gray-400 mb-1 block",children:"Start from Template"}),o.jsxs(Qt,{value:R.templateId||"__custom__",onValueChange:F=>_({...R,templateId:F==="__custom__"?"":F}),children:[o.jsx(en,{className:"bg-slate-800 border-slate-700 text-white",children:o.jsx(Zt,{})}),o.jsxs(tn,{className:"bg-slate-800 border-slate-700",children:[o.jsx(st,{value:"__custom__",children:"Custom - define workers manually"}),k.map(F=>{var K;return o.jsxs(st,{value:F.id,children:[F.name," - ",(K=F.workers)==null?void 0:K.length," workers"]},F.id)})]})]})]}),o.jsxs("div",{children:[o.jsx("label",{className:"text-xs text-gray-400 mb-1 block",children:"Project Name"}),o.jsx(Dt,{className:"bg-slate-800 border-slate-700 text-white",value:R.name,onChange:F=>_({...R,name:F.target.value}),placeholder:"e.g. auth-system, q4-research"})]}),o.jsxs("div",{children:[o.jsx("label",{className:"text-xs text-gray-400 mb-1 block",children:"What should this team accomplish?"}),o.jsx("textarea",{className:"w-full bg-slate-800 border border-slate-700 rounded-md px-3 py-2 text-sm text-white resize-none h-20",value:R.task,onChange:F=>_({...R,task:F.target.value}),placeholder:"Build a complete login system with Google OAuth, including backend API, frontend UI, and tests"})]}),o.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[o.jsxs("div",{children:[o.jsx("label",{className:"text-xs text-gray-400 mb-1 block",children:"Type"}),o.jsxs(Qt,{value:R.projectType,onValueChange:F=>_({...R,projectType:F}),children:[o.jsx(en,{className:"bg-slate-800 border-slate-700 text-white",children:o.jsx(Zt,{})}),o.jsxs(tn,{className:"bg-slate-800 border-slate-700",children:[o.jsx(st,{value:"coding",children:"Coding"}),o.jsx(st,{value:"research",children:"Research"}),o.jsx(st,{value:"design",children:"Design"})]})]})]}),o.jsxs("div",{children:[o.jsx("label",{className:"text-xs text-gray-400 mb-1 block",children:"Stack"}),o.jsx(Dt,{className:"bg-slate-800 border-slate-700 text-white",value:R.projectStack,onChange:F=>_({...R,projectStack:F.target.value}),placeholder:"Node.js, React, PostgreSQL"})]})]}),o.jsxs("div",{children:[o.jsxs("label",{className:"text-xs text-gray-400 mb-1 block",children:["Repo URL ",o.jsx("span",{className:"text-gray-600",children:"(optional)"})]}),o.jsx(Dt,{className:"bg-slate-800 border-slate-700 text-white",value:R.projectRepo,onChange:F=>_({...R,projectRepo:F.target.value}),placeholder:"https://github.com/org/repo"})]}),o.jsxs("div",{children:[o.jsxs("label",{className:"text-xs text-gray-400 mb-1 block",children:["Additional Context ",o.jsx("span",{className:"text-gray-600",children:"(optional)"})]}),o.jsx("textarea",{className:"w-full bg-slate-800 border border-slate-700 rounded-md px-3 py-2 text-sm text-white resize-none h-16",value:R.context,onChange:F=>_({...R,context:F.target.value}),placeholder:"Existing codebase uses Express, auth via JWT, database has users table..."})]}),!R.templateId&&o.jsxs("div",{children:[o.jsx("label",{className:"text-xs text-gray-400 mb-1 block",children:"Workers"}),R.workers.map((F,K)=>o.jsxs("div",{className:"grid grid-cols-12 gap-2 mb-2",children:[o.jsx(Dt,{className:"col-span-3 bg-slate-800 border-slate-700 text-white text-xs",value:F.name,onChange:J=>{const Q=[...R.workers];Q[K].name=J.target.value,_({...R,workers:Q})},placeholder:"Name"}),o.jsxs(Qt,{value:F.crew||F.profile,onValueChange:J=>{const Q=[...R.workers];C.some(D=>D.id===J)?(Q[K].crew=J,Q[K].profile=""):(Q[K].profile=J,Q[K].crew=""),_({...R,workers:Q})},children:[o.jsx(en,{className:"col-span-3 bg-slate-800 border-slate-700 text-white text-xs",children:o.jsx(Zt,{})}),o.jsxs(tn,{className:"bg-slate-800 border-slate-700 max-h-48",children:[(S.length>0?S:["coder","frontend","tester","researcher","writer","analyst","devops","architect"]).map(J=>o.jsx(st,{value:J,children:J},J)),C.length>0&&C.map(J=>o.jsxs(st,{value:J.id,children:["🔧 ",J.name," (crew)"]},J.id))]})]}),o.jsx(Dt,{className:"col-span-5 bg-slate-800 border-slate-700 text-white text-xs",value:F.task,onChange:J=>{const Q=[...R.workers];Q[K].task=J.target.value,_({...R,workers:Q})},placeholder:"Task assignment"}),o.jsx(at,{variant:"ghost",size:"icon",className:"col-span-1 h-8 w-8 text-gray-400 hover:text-red-400",onClick:()=>{const J=R.workers.filter((Q,Z)=>Z!==K);_({...R,workers:J.length?J:[{name:"",profile:"coder",crew:"",task:""}]})},children:o.jsx(qn,{className:"w-3 h-3"})})]},K)),o.jsx(at,{variant:"outline",size:"sm",className:"border-slate-700 text-gray-400 text-xs",onClick:()=>_({...R,workers:[...R.workers,{name:"",profile:"coder",crew:"",task:""}]}),children:"+ Add Worker"})]}),o.jsxs(at,{onClick:M,disabled:g,className:"w-full bg-[#00d9ff]/20 text-[#00d9ff] border border-[#00d9ff]/30 hover:bg-[#00d9ff]/30",children:[g?o.jsx($t,{className:"w-4 h-4 animate-spin mr-2"}):null,"Launch Team"]})]})]})]})]})]}),o.jsxs("div",{className:"flex gap-4",children:[o.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 bg-slate-800/50 border border-slate-700/50 rounded-lg",children:[o.jsx("span",{className:"text-xs text-gray-400",children:"Total"}),o.jsx("span",{className:"text-sm font-mono text-white",children:t.length})]}),o.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 bg-slate-800/50 border border-slate-700/50 rounded-lg",children:[o.jsx("div",{className:"w-2 h-2 bg-emerald-400 rounded-full"}),o.jsx("span",{className:"text-xs text-gray-400",children:"Active"}),o.jsx("span",{className:"text-sm font-mono text-emerald-400",children:E})]})]}),n?o.jsx("div",{className:"flex items-center justify-center py-20",children:o.jsx($t,{className:"w-6 h-6 animate-spin text-[#00d9ff]"})}):t.length===0?o.jsx(rn,{className:"bg-slate-900/50 border-slate-800",children:o.jsxs(on,{className:"py-12 text-center",children:[o.jsx(Qo,{className:"w-10 h-10 mx-auto mb-3 opacity-30 text-gray-600"}),o.jsx("p",{className:"text-gray-400 mb-2",children:"No teams yet"}),o.jsx("p",{className:"text-xs text-gray-500 max-w-md mx-auto",children:'Teams are created by the agent when you ask for multi-stage work. Try: "Build a login system with backend, frontend, and tests."'})]})}):o.jsx("div",{className:"space-y-3",children:t.map(F=>{var ne;const K=i===F.id,J=((ne=F.members)==null?void 0:ne.filter(A=>A.role!=="lead"))||[],Q=F.tasks||[],Z=Q.filter(A=>A.status==="completed").length,D=Q.length;return o.jsx(rn,{className:"bg-slate-900/50 border-slate-800 hover:border-slate-700 transition-colors",children:o.jsxs(on,{className:"p-4",children:[o.jsxs("div",{className:"flex items-start justify-between gap-4",children:[o.jsxs("div",{className:"flex-1 cursor-pointer",onClick:()=>s(K?null:F.id),children:[o.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[o.jsx("h3",{className:"text-sm font-semibold text-white",children:F.project||F.name}),o.jsx(Kt,{className:`text-[10px] ${ia[F.status]||ia.idle}`,children:F.status}),F.projectType&&o.jsx(Kt,{className:"bg-slate-700/50 text-gray-400 border-slate-600 text-[10px]",children:F.projectType})]}),o.jsxs("div",{className:"flex items-center gap-4 text-[10px] text-gray-500 font-mono",children:[o.jsxs("span",{children:[J.length," worker",J.length!==1?"s":""]}),o.jsxs("span",{children:[Z,"/",D," tasks done"]}),F.projectStack&&o.jsx("span",{children:F.projectStack}),o.jsx("span",{children:new Date(F.createdAt).toLocaleDateString()}),K?o.jsx(by,{className:"w-3 h-3"}):o.jsx(fo,{className:"w-3 h-3"})]})]}),o.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[o.jsx(at,{variant:"ghost",size:"icon",className:"h-7 w-7 text-gray-400 hover:text-white",onClick:()=>L(F.id),children:o.jsx(Mf,{className:"w-3.5 h-3.5"})}),F.status==="active"&&o.jsx(at,{variant:"ghost",size:"icon",className:"h-7 w-7 text-gray-400 hover:text-red-400",onClick:()=>$(F.id),children:o.jsx(qn,{className:"w-3.5 h-3.5"})})]})]}),K&&o.jsxs("div",{className:"mt-4 pt-4 border-t border-slate-800 space-y-4",children:[o.jsxs("div",{children:[o.jsx("label",{className:"text-[10px] text-gray-500 uppercase tracking-wider",children:"Workers"}),o.jsxs("div",{className:"mt-1 space-y-1",children:[J.map(A=>o.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[o.jsx(Kt,{className:`text-[9px] ${ia[A.status]||ia.idle}`,children:A.status}),o.jsx("span",{className:"text-white",children:A.name}),o.jsx("span",{className:"text-gray-500",children:A.profile})]},A.id)),J.length===0&&o.jsx("span",{className:"text-xs text-gray-500",children:"No workers yet"})]})]}),o.jsxs("div",{children:[o.jsx("label",{className:"text-[10px] text-gray-500 uppercase tracking-wider",children:"Tasks"}),o.jsxs("div",{className:"mt-1 space-y-1",children:[Q.map(A=>{const z=WX[A.status]||es;return o.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[o.jsx(z,{className:`w-3 h-3 ${A.status==="in_progress"?"animate-spin text-cyan-400":A.status==="completed"?"text-emerald-400":A.status==="failed"?"text-red-400":"text-gray-500"}`}),o.jsx("span",{className:"text-white truncate max-w-xs",children:A.title}),o.jsxs("span",{className:"text-gray-500",children:["→ ",A.assignee||"unassigned"]}),o.jsx(Kt,{className:`text-[9px] ${ia[A.status]||ia.pending}`,children:A.status})]},A.id)}),Q.length===0&&o.jsx("span",{className:"text-xs text-gray-500",children:"No tasks yet"})]})]}),D>0&&o.jsx("div",{className:"w-full bg-slate-800 rounded-full h-1.5",children:o.jsx("div",{className:"bg-[#00d9ff] h-1.5 rounded-full transition-all",style:{width:`${Z/D*100}%`}})})]})]})},F.id)})}),o.jsx(hi,{open:!!a,onOpenChange:F=>{F||c(null)},children:o.jsxs(fi,{className:"bg-slate-900 border-slate-700 text-white max-w-2xl max-h-[80vh] overflow-y-auto",children:[o.jsx(pi,{children:o.jsxs(mi,{className:"flex items-center gap-2",children:[o.jsx(Qo,{className:"w-5 h-5 text-[#00d9ff]"}),(a==null?void 0:a.project)||(a==null?void 0:a.name)]})}),h?o.jsx("div",{className:"py-8 text-center",children:o.jsx($t,{className:"w-6 h-6 animate-spin text-[#00d9ff] mx-auto"})}):a&&o.jsxs("div",{className:"space-y-4 mt-4",children:[o.jsxs("div",{className:"grid grid-cols-2 gap-3 text-xs",children:[o.jsxs("div",{children:[o.jsx("span",{className:"text-gray-500",children:"Status:"})," ",o.jsx(Kt,{className:`text-[9px] ml-1 ${ia[a.status]}`,children:a.status})]}),o.jsxs("div",{children:[o.jsx("span",{className:"text-gray-500",children:"Type:"})," ",o.jsx("span",{className:"text-white ml-1",children:a.projectType||"general"})]}),a.projectRepo&&o.jsxs("div",{className:"col-span-2",children:[o.jsx("span",{className:"text-gray-500",children:"Repo:"})," ",o.jsx("span",{className:"text-[#00d9ff] ml-1",children:a.projectRepo})]}),a.projectStack&&o.jsxs("div",{className:"col-span-2",children:[o.jsx("span",{className:"text-gray-500",children:"Stack:"})," ",o.jsx("span",{className:"text-white ml-1",children:a.projectStack})]})]}),a.requirements&&o.jsxs("div",{children:[o.jsx("label",{className:"text-[10px] text-gray-500 uppercase tracking-wider",children:"Requirements"}),o.jsx("p",{className:"text-xs text-gray-300 mt-1 bg-slate-800/50 rounded p-2",children:a.requirements.slice(0,500)})]}),o.jsxs("div",{children:[o.jsx("label",{className:"text-[10px] text-gray-500 uppercase tracking-wider",children:"Team Members"}),o.jsx("div",{className:"mt-1 space-y-1",children:(P=a.members)==null?void 0:P.map(F=>o.jsxs("div",{className:"flex items-center gap-2 text-xs bg-slate-800/30 rounded px-2 py-1",children:[o.jsx(Kt,{className:`text-[9px] ${ia[F.status]}`,children:F.status}),o.jsx("span",{className:"text-white font-medium",children:F.name}),o.jsxs("span",{className:"text-gray-500",children:[F.role," / ",F.profile]})]},F.id))})]}),o.jsxs("div",{children:[o.jsx("label",{className:"text-[10px] text-gray-500 uppercase tracking-wider",children:"Tasks"}),o.jsx("div",{className:"mt-1 space-y-1",children:(V=a.tasks)==null?void 0:V.map(F=>o.jsxs("div",{className:"bg-slate-800/30 rounded px-2 py-1.5",children:[o.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[o.jsx(Kt,{className:`text-[9px] ${ia[F.status]}`,children:F.status}),o.jsx("span",{className:"text-white",children:F.title}),o.jsx("span",{className:"text-gray-500 ml-auto",children:F.assignee})]}),F.result&&o.jsxs("p",{className:"text-[10px] text-gray-400 mt-1 pl-2",children:["Result: ",F.result.slice(0,200)]}),F.plan&&o.jsxs("p",{className:"text-[10px] text-gray-500 mt-1 pl-2",children:["Plan: ",F.plan.slice(0,200)]})]},F.id))})]}),a.messages&&a.messages.length>0&&o.jsxs("div",{children:[o.jsx("label",{className:"text-[10px] text-gray-500 uppercase tracking-wider",children:"Recent Messages"}),o.jsx("div",{className:"mt-1 max-h-48 overflow-y-auto space-y-1",children:a.messages.map(F=>{var K;return o.jsxs("div",{className:"text-[10px] bg-slate-800/30 rounded px-2 py-1",children:[o.jsx("span",{className:"text-[#00d9ff]",children:F.from}),o.jsx("span",{className:"text-gray-600",children:" → "}),o.jsx("span",{className:"text-gray-400",children:F.to}),o.jsx(Kt,{className:"text-[8px] ml-1 bg-slate-700/50 text-gray-500 border-slate-600",children:F.msgType}),o.jsx("p",{className:"text-gray-300 mt-0.5",children:(K=F.content)==null?void 0:K.slice(0,200)})]},F.id)})})]})]})]})})]})}const Du={anthropic:{name:"Anthropic",detail:"Claude 4.5 / Haiku",key:"ANTHROPIC_API_KEY",model:"anthropic:claude-haiku-4-5"},openai:{name:"OpenAI",detail:"GPT-4o / o3",key:"OPENAI_API_KEY",model:"openai:gpt-4o-mini"},google:{name:"Google",detail:"Gemini 2.5",key:"GOOGLE_GENERATIVE_AI_API_KEY",model:"google:gemini-2.5-flash"},groq:{name:"Groq",detail:"GPT-OSS / Llama",key:"GROQ_API_KEY",model:"groq:openai/gpt-oss-120b"}},H0=[{value:"groq",label:"Groq Whisper",detail:"Fast, free tier",keyEnv:"GROQ_API_KEY"},{value:"deepgram",label:"Deepgram Nova",detail:"Accurate streaming",keyEnv:"DEEPGRAM_API_KEY"},{value:"openai",label:"OpenAI Whisper",detail:"Multilingual",keyEnv:"OPENAI_API_KEY"},{value:"assemblyai",label:"AssemblyAI",detail:"Best accuracy",keyEnv:"ASSEMBLYAI_API_KEY"}],q0=[{value:"openai",label:"OpenAI TTS",detail:"Natural voices",keyEnv:"OPENAI_API_KEY"},{value:"groq",label:"Groq Orpheus",detail:"Ultra-fast",keyEnv:"GROQ_API_KEY"},{value:"elevenlabs",label:"ElevenLabs",detail:"Premium quality",keyEnv:"ELEVENLABS_API_KEY"},{value:"cartesia",label:"Cartesia Sonic",detail:"Low latency",keyEnv:"CARTESIA_API_KEY"}],OT=[{value:"concise",label:"Concise",detail:"Short, direct answers"},{value:"detailed",label:"Detailed",detail:"Thorough with context"},{value:"casual",label:"Casual",detail:"Warm and conversational"},{value:"formal",label:"Formal",detail:"Professional tone"}],qX=[{value:"hey_jarvis",label:"Hey Jarvis",detail:"Most accurate"},{value:"hey_daemora",label:"Hey Daemora",detail:"Falls back to Jarvis"},{value:"hey_mycroft",label:"Hey Mycroft",detail:"Classic open-source"},{value:"hey_rhasspy",label:"Hey Rhasspy",detail:"Alternative phrase"},{value:"alexa",label:"Alexa",detail:"If you like the name"}];function KX(){const t=Pc(),[e,n]=x.useState("vault"),[r,i]=x.useState(!1),[s,a]=x.useState(!0),[c,h]=x.useState(null),[d,f]=x.useState(""),[p,g]=x.useState(""),[v,k]=x.useState(!1),[w,S]=x.useState(!1),[T,C]=x.useState(null),[j,R]=x.useState(""),[_,I]=x.useState(!1),[M,L]=x.useState("groq"),[$,E]=x.useState("openai"),[P,V]=x.useState({}),[F,K]=x.useState(null),[J,Q]=x.useState("hey_jarvis"),[Z,D]=x.useState(""),[ne,A]=x.useState(""),[z,ee]=x.useState(typeof Intl<"u"?Intl.DateTimeFormat().resolvedOptions().timeZone:""),[B,X]=x.useState("concise"),[ye,se]=x.useState(!1),[oe,U]=x.useState([]),[ue,ke]=x.useState(!1),[W,q]=x.useState(null),[fe,ve]=x.useState({}),[Se,Ke]=x.useState(!1),[dt,Ge]=x.useState(null);x.useEffect(()=>{Ve()},[]);async function _e(pe,Ue){let ze=await we(pe,Ue);if(ze.ok||!d)return ze;const Wt=ze.clone();let bt=null;try{bt=await Wt.json()}catch{}return!(String((bt==null?void 0:bt.message)??(bt==null?void 0:bt.error)??"").toLowerCase().includes("vault is locked")||(bt==null?void 0:bt.code)==="vault_locked")||!(await we("/auth/login",{method:"POST",body:JSON.stringify({passphrase:d})})).ok?ze:we(pe,Ue)}async function Ve(){try{const pe=await we("/api/setup/status");if(pe.ok){const Ue=await pe.json(),ze=new URLSearchParams(window.location.search).get("force")==="1";if(Ue.completed&&!ze){t("/",{replace:!0});return}i(Ue.vaultExists),Ue.vaultExists&&(Ue.vaultUnlocked?Ue.hasProvider||Ue.hasAnyLlmKey?n("voice"):n("provider"):n("vault"))}}catch{}a(!1)}async function xt(){if(h(null),r){if(!d){h("Enter your passphrase");return}S(!0);try{const pe=await we("/auth/login",{method:"POST",body:JSON.stringify({passphrase:d})});if(!pe.ok){const Ue=await pe.json().catch(()=>({}));throw new Error(Ue.error||"Wrong passphrase")}sessionStorage.setItem("daemora_vault_pass",d),n("provider")}catch(pe){h(pe.message||String(pe))}S(!1)}else{if(d.length<8){h("Passphrase must be at least 8 characters");return}if(d!==p){h("Passphrases don't match");return}S(!0);try{const pe=await we("/api/vault/unlock",{method:"POST",body:JSON.stringify({passphrase:d})});if(!pe.ok){const ze=await pe.json().catch(()=>({}));throw new Error(ze.error||"Failed to create vault")}const Ue=await we("/auth/login",{method:"POST",body:JSON.stringify({passphrase:d})});if(!Ue.ok){const ze=await Ue.json().catch(()=>({}));throw new Error(ze.error||"Vault created but login failed")}sessionStorage.setItem("daemora_vault_pass",d),n("provider")}catch(pe){h(pe.message||String(pe))}S(!1)}}async function Pt(){if(h(null),!T||!j.trim()){h("Select a provider and enter your API key");return}I(!0);try{const pe=Du[T],Ue=await _e("/api/settings",{method:"PUT",body:JSON.stringify({updates:{[pe.key]:j.trim(),DEFAULT_MODEL:pe.model}})});if(!Ue.ok){const ze=await Ue.json().catch(()=>({}));throw new Error((ze==null?void 0:ze.message)||(ze==null?void 0:ze.error)||"Failed to save")}n("voice")}catch(pe){h(pe.message||String(pe))}I(!1)}async function mn(){K(null);const pe=H0.find(nn=>nn.value===M),Ue=q0.find(nn=>nn.value===$),ze=new Set;pe!=null&&pe.keyEnv&&ze.add(pe.keyEnv),Ue!=null&&Ue.keyEnv&&ze.add(Ue.keyEnv);const Wt=Array.from(ze).filter(nn=>!P[nn]),bt=[];for(const nn of Wt)(T?Du[T].key:null)!==nn&&bt.push(nn);if(bt.length>0){K(`Enter API key for: ${bt.join(", ")}`);return}const Tn={DAEMORA_STT_PROVIDER:M,DAEMORA_TTS_PROVIDER:$};for(const[nn,Kn]of Object.entries(P))Kn!=null&&Kn.trim()&&(Tn[nn]=Kn.trim());try{await _e("/api/settings",{method:"PUT",body:JSON.stringify({updates:Tn})})}catch{}n("wake")}async function gn(){try{await _e("/api/settings",{method:"PUT",body:JSON.stringify({updates:{WAKE_WORD:J,WAKE_WORD_ENABLED:"true"}})}),await we("/api/voice/wake/start",{method:"POST",body:JSON.stringify({wake_word:J})}).catch(()=>{})}catch{}n("profile")}async function jn(){se(!0);try{const pe=[];if(Z.trim()&&pe.push(`User's name is ${Z.trim()}.`),ne.trim()&&pe.push(`User's role: ${ne.trim()}.`),z.trim()&&pe.push(`User's timezone is ${z.trim()}.`),B){const Ue=OT.find(ze=>ze.value===B);Ue&&pe.push(`User prefers ${Ue.label.toLowerCase()} responses (${Ue.detail.toLowerCase()}).`)}for(const Ue of pe)await _e("/api/brain/user",{method:"POST",body:JSON.stringify({action:"add",content:Ue})}).catch(()=>{})}catch{}se(!1),await xe(),n("connect")}async function xe(){ke(!0);try{const pe=await we("/api/channels");if(pe.ok){const Ue=await pe.json();U((Ue.channels??[]).map(ze=>({id:ze.id,label:ze.name??ze.id,description:ze.description??"",configured:!!ze.configured,running:!!ze.running,requiredKeys:ze.requiredKeys??[],missingKeys:ze.missingKeys??[]})))}}catch{}ke(!1)}function Re(pe){q(pe.id),Ge(null);const Ue={};for(const ze of pe.requiredKeys)Ue[ze.key]="";ve(Ue)}async function Qe(pe){Ke(!0),Ge(null);try{const Ue=[],ze={};for(const Wt of pe.requiredKeys){const bt=(fe[Wt.key]??"").trim();bt&&(Wt.secret?Ue.push([Wt.key,bt]):ze[Wt.key]=bt)}for(const[Wt,bt]of Ue){const Tn=await _e(`/api/vault/${encodeURIComponent(Wt)}`,{method:"PUT",body:JSON.stringify({value:bt})});if(!Tn.ok){const nn=await Tn.json().catch(()=>({}));throw new Error(nn.error||nn.message||`${Wt}: ${Tn.status}`)}}if(Object.keys(ze).length>0&&!(await _e("/api/settings",{method:"PUT",body:JSON.stringify({updates:ze})})).ok)throw new Error("settings save failed");await we(`/api/channels/${pe.id}/start`,{method:"POST"}).catch(()=>{}),await xe(),q(null),ve({})}catch(Ue){Ge((Ue==null?void 0:Ue.message)||String(Ue))}Ke(!1)}async function He(){try{await _e("/api/settings",{method:"PUT",body:JSON.stringify({updates:{SETUP_COMPLETED:new Date().toISOString()}})})}catch{}n("complete"),setTimeout(()=>t("/",{replace:!0}),1500)}async function gt(pe,Ue){const ze=Ue?`/api/channels/${pe}/stop`:`/api/channels/${pe}/start`;try{await we(ze,{method:"POST"})}catch{}await xe()}function hn(){const pe=H0.find(bt=>bt.value===M),Ue=q0.find(bt=>bt.value===$),ze=new Set;pe!=null&&pe.keyEnv&&ze.add(pe.keyEnv),Ue!=null&&Ue.keyEnv&&ze.add(Ue.keyEnv);const Wt=T?Du[T].key:null;return Wt&&ze.delete(Wt),Array.from(ze)}const vn=["vault","provider","voice","wake","profile","connect","complete"],Fn=vn.indexOf(e);return s?o.jsx("div",{className:"fixed inset-0 bg-[#0a0f1a] flex items-center justify-center",children:o.jsx("div",{className:"animate-pulse text-[#00d9ff] font-mono text-sm",children:"Loading..."})}):o.jsxs("div",{className:"fixed inset-0 bg-[#0a0f1a] flex items-center justify-center overflow-auto",children:[o.jsx("div",{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-[600px] h-[600px] bg-[#00d9ff] opacity-[0.03] rounded-full blur-[120px] pointer-events-none"}),o.jsxs("div",{className:"relative z-10 w-full max-w-md px-6 py-12 flex flex-col items-center gap-6",children:[o.jsxs("div",{className:"flex flex-col items-center gap-3",children:[o.jsx("div",{className:"w-14 h-14",children:o.jsx(Xo,{})}),o.jsx("h1",{className:"text-2xl font-bold tracking-[3px] bg-gradient-to-r from-[#00d9ff] to-[#4ECDC4] bg-clip-text text-transparent",children:"DAEMORA"})]}),o.jsx("div",{className:"flex items-center gap-2",children:vn.slice(0,-1).map((pe,Ue)=>o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("div",{className:`w-2 h-2 rounded-full transition-all duration-300 ${Ue<Fn?"bg-[#4ECDC4]":Ue===Fn?"bg-[#00d9ff] shadow-[0_0_8px_rgba(0,217,255,0.5)]":"bg-[#1e2d45]"}`}),Ue<vn.length-2&&o.jsx("div",{className:`w-5 h-px transition-colors ${Ue<Fn?"bg-[#4ECDC4]":"bg-[#1e2d45]"}`})]},pe))}),o.jsxs("div",{className:"w-full animate-in fade-in slide-in-from-bottom-2 duration-300",children:[e==="vault"&&o.jsxs("div",{className:"flex flex-col gap-4",children:[o.jsxs("div",{className:"text-center",children:[o.jsx("div",{className:"inline-flex items-center justify-center w-12 h-12 rounded-xl bg-[#131b2e] border border-[#1e2d45] mb-3",children:o.jsx(zu,{className:"w-6 h-6 text-[#00d9ff]"})}),o.jsx("h2",{className:"text-lg font-semibold text-white",children:"Secure Your Keys"}),o.jsx("p",{className:"text-sm text-[#6b7a8d] mt-1",children:"Create a passphrase to encrypt your API keys. You'll enter this each time you open Daemora. Choose something you'll remember — if you forget it, your keys can't be recovered."})]}),o.jsxs("div",{className:"relative",children:[o.jsx("input",{type:v?"text":"password",value:d,onChange:pe=>f(pe.target.value),onKeyDown:pe=>pe.key==="Enter"&&xt(),placeholder:r?"Vault passphrase":"Create passphrase (8+ chars)",className:"w-full px-4 py-3 bg-[#131b2e] border border-[#1e2d45] rounded-lg text-white font-mono text-sm outline-none focus:border-[#00d9ff] focus:shadow-[0_0_0_2px_rgba(0,217,255,0.12)] transition-all",autoFocus:!0}),o.jsx("button",{onClick:()=>k(!v),className:"absolute right-3 top-1/2 -translate-y-1/2 text-[#4a5568] hover:text-[#00d9ff] transition-colors",children:v?o.jsx(sc,{size:16}):o.jsx(Ss,{size:16})})]}),!r&&o.jsx("input",{type:"password",value:p,onChange:pe=>g(pe.target.value),onKeyDown:pe=>pe.key==="Enter"&&xt(),placeholder:"Confirm passphrase",className:"w-full px-4 py-3 bg-[#131b2e] border border-[#1e2d45] rounded-lg text-white font-mono text-sm outline-none focus:border-[#00d9ff] focus:shadow-[0_0_0_2px_rgba(0,217,255,0.12)] transition-all"}),c&&o.jsx("p",{className:"text-xs text-red-400 text-center",children:c}),o.jsx("button",{onClick:xt,disabled:w,className:"w-full py-3 bg-gradient-to-r from-[#00d9ff] to-[#4ECDC4] text-[#0a0f1a] font-bold rounded-lg text-sm tracking-wide hover:opacity-90 active:scale-[0.98] transition-all disabled:opacity-40",children:w?"Starting...":r?"Unlock":"Create & Continue"})]}),e==="provider"&&o.jsxs("div",{className:"flex flex-col gap-4",children:[o.jsxs("div",{className:"text-center",children:[o.jsx("div",{className:"inline-flex items-center justify-center w-12 h-12 rounded-xl bg-[#131b2e] border border-[#1e2d45] mb-3",children:o.jsx(Ja,{className:"w-6 h-6 text-[#00d9ff]"})}),o.jsx("h2",{className:"text-lg font-semibold text-white",children:"AI Model"}),o.jsx("p",{className:"text-sm text-[#6b7a8d] mt-1",children:"Pick your AI provider and enter the API key."})]}),o.jsx("div",{className:"grid grid-cols-2 gap-2",children:Object.entries(Du).map(([pe,Ue])=>o.jsxs("button",{onClick:()=>{C(pe),h(null)},className:`p-3 rounded-lg border text-left transition-all ${T===pe?"border-[#00d9ff] bg-[#0d1a2d] shadow-[0_0_12px_rgba(0,217,255,0.1)]":"border-[#1e2d45] bg-[#131b2e] hover:border-[#00d9ff]/50"}`,children:[o.jsx("div",{className:"text-sm font-semibold text-white",children:Ue.name}),o.jsx("div",{className:"text-[10px] text-[#4a5568] mt-0.5",children:Ue.detail})]},pe))}),T&&o.jsx("input",{type:"password",value:j,onChange:pe=>R(pe.target.value),onKeyDown:pe=>pe.key==="Enter"&&Pt(),placeholder:`${Du[T].name} API key`,className:"w-full px-4 py-3 bg-[#131b2e] border border-[#1e2d45] rounded-lg text-white font-mono text-sm outline-none focus:border-[#00d9ff] focus:shadow-[0_0_0_2px_rgba(0,217,255,0.12)] transition-all",autoFocus:!0}),c&&o.jsx("p",{className:"text-xs text-red-400 text-center",children:c}),o.jsx("button",{onClick:Pt,disabled:_||!T,className:"w-full py-3 bg-gradient-to-r from-[#00d9ff] to-[#4ECDC4] text-[#0a0f1a] font-bold rounded-lg text-sm tracking-wide hover:opacity-90 active:scale-[0.98] transition-all disabled:opacity-40",children:_?"Saving...":"Continue"})]}),e==="voice"&&o.jsxs("div",{className:"flex flex-col gap-4",children:[o.jsxs("div",{className:"text-center",children:[o.jsx("div",{className:"inline-flex items-center justify-center w-12 h-12 rounded-xl bg-[#131b2e] border border-[#1e2d45] mb-3",children:o.jsx(ev,{className:"w-6 h-6 text-[#00d9ff]"})}),o.jsx("h2",{className:"text-lg font-semibold text-white",children:"Voice"}),o.jsx("p",{className:"text-sm text-[#6b7a8d] mt-1",children:"Choose speech-to-text and text-to-speech providers."})]}),o.jsxs("div",{children:[o.jsx("label",{className:"text-[10px] uppercase tracking-wider text-[#6b7a8d] mb-1 block",children:"Speech-to-Text"}),o.jsx("div",{className:"grid grid-cols-2 gap-2",children:H0.map(pe=>o.jsxs("button",{onClick:()=>L(pe.value),className:`p-2.5 rounded-lg border text-left transition-all ${M===pe.value?"border-[#00d9ff] bg-[#0d1a2d]":"border-[#1e2d45] bg-[#131b2e] hover:border-[#00d9ff]/50"}`,children:[o.jsx("div",{className:"text-xs font-semibold text-white",children:pe.label}),o.jsx("div",{className:"text-[9px] text-[#4a5568]",children:pe.detail})]},pe.value))})]}),o.jsxs("div",{children:[o.jsx("label",{className:"text-[10px] uppercase tracking-wider text-[#6b7a8d] mb-1 block",children:"Text-to-Speech"}),o.jsx("div",{className:"grid grid-cols-2 gap-2",children:q0.map(pe=>o.jsxs("button",{onClick:()=>E(pe.value),className:`p-2.5 rounded-lg border text-left transition-all ${$===pe.value?"border-[#4ECDC4] bg-[#0d1a2d]":"border-[#1e2d45] bg-[#131b2e] hover:border-[#4ECDC4]/50"}`,children:[o.jsx("div",{className:"text-xs font-semibold text-white",children:pe.label}),o.jsx("div",{className:"text-[9px] text-[#4a5568]",children:pe.detail})]},pe.value))})]}),hn().length>0&&o.jsxs("div",{className:"flex flex-col gap-2 border-t border-[#1e2d45] pt-3",children:[o.jsx("label",{className:"text-[10px] uppercase tracking-wider text-[#6b7a8d]",children:"API Keys for Voice"}),hn().map(pe=>o.jsx("input",{type:"password",value:P[pe]||"",onChange:Ue=>V({...P,[pe]:Ue.target.value}),placeholder:`${pe}`,className:"w-full px-4 py-2.5 bg-[#131b2e] border border-[#1e2d45] rounded-lg text-white font-mono text-xs outline-none focus:border-[#00d9ff] transition-colors"},pe))]}),F&&o.jsx("p",{className:"text-xs text-red-400 text-center",children:F}),o.jsx("button",{onClick:mn,className:"w-full py-3 bg-gradient-to-r from-[#00d9ff] to-[#4ECDC4] text-[#0a0f1a] font-bold rounded-lg text-sm tracking-wide hover:opacity-90 active:scale-[0.98] transition-all",children:"Finish Setup"}),o.jsx("button",{onClick:()=>{K(""),n("wake")},className:"w-full py-2 text-xs text-[#6b7a8d] hover:text-[#00d9ff] transition-colors",children:"Skip voice setup — configure later in Settings"})]}),e==="wake"&&o.jsxs("div",{className:"flex flex-col gap-4",children:[o.jsxs("div",{className:"text-center",children:[o.jsx("div",{className:"inline-flex items-center justify-center w-12 h-12 rounded-xl bg-[#131b2e] border border-[#1e2d45] mb-3",children:o.jsx(ev,{className:"w-6 h-6 text-[#00d9ff]"})}),o.jsx("h2",{className:"text-lg font-semibold text-white",children:"Wake Word"}),o.jsx("p",{className:"text-sm text-[#6b7a8d] mt-1",children:"Daemora listens for this phrase and activates voice mode when heard. Say the phrase, wait for the beep, then speak."})]}),o.jsx("div",{className:"grid grid-cols-1 gap-2",children:qX.map(pe=>o.jsxs("button",{onClick:()=>Q(pe.value),className:`p-3 rounded-lg border text-left transition-all flex items-center justify-between ${J===pe.value?"border-[#00d9ff] bg-[#0d1a2d] shadow-[0_0_12px_rgba(0,217,255,0.1)]":"border-[#1e2d45] bg-[#131b2e] hover:border-[#00d9ff]/50"}`,children:[o.jsxs("div",{children:[o.jsxs("div",{className:"text-sm font-semibold text-white",children:['"',pe.label,'"']}),o.jsx("div",{className:"text-[10px] text-[#4a5568]",children:pe.detail})]}),J===pe.value&&o.jsx(nd,{className:"w-4 h-4 text-[#00d9ff]"})]},pe.value))}),o.jsx("button",{onClick:gn,className:"w-full py-3 bg-gradient-to-r from-[#00d9ff] to-[#4ECDC4] text-[#0a0f1a] font-bold rounded-lg text-sm tracking-wide hover:opacity-90 active:scale-[0.98] transition-all",children:"Finish Setup"}),o.jsx("button",{onClick:async()=>{try{await _e("/api/settings",{method:"PUT",body:JSON.stringify({updates:{WAKE_WORD_ENABLED:"false"}})})}catch{}n("profile")},className:"w-full py-2 text-xs text-[#6b7a8d] hover:text-[#00d9ff] transition-colors",children:"Skip — I'll enable wake word later"})]}),e==="profile"&&o.jsxs("div",{className:"flex flex-col gap-4",children:[o.jsxs("div",{className:"text-center",children:[o.jsx("div",{className:"inline-flex items-center justify-center w-12 h-12 rounded-xl bg-[#131b2e] border border-[#1e2d45] mb-3",children:o.jsx(tv,{className:"w-6 h-6 text-[#00d9ff]"})}),o.jsx("h2",{className:"text-lg font-semibold text-white",children:"Tell Daemora About You"}),o.jsx("p",{className:"text-sm text-[#6b7a8d] mt-1",children:"This goes into long-term memory (USER.md). Daemora reads it at the start of every session so you don't have to repeat yourself."})]}),o.jsx("input",{type:"text",value:Z,onChange:pe=>D(pe.target.value),placeholder:"Your name",className:"w-full px-4 py-2.5 bg-[#131b2e] border border-[#1e2d45] rounded-lg text-white font-mono text-sm outline-none focus:border-[#00d9ff] focus:shadow-[0_0_0_2px_rgba(0,217,255,0.12)] transition-all"}),o.jsx("input",{type:"text",value:ne,onChange:pe=>A(pe.target.value),placeholder:"Your role (e.g. Software engineer)",className:"w-full px-4 py-2.5 bg-[#131b2e] border border-[#1e2d45] rounded-lg text-white font-mono text-sm outline-none focus:border-[#00d9ff] focus:shadow-[0_0_0_2px_rgba(0,217,255,0.12)] transition-all"}),o.jsx("input",{type:"text",value:z,onChange:pe=>ee(pe.target.value),placeholder:"Timezone (e.g. Asia/Karachi)",className:"w-full px-4 py-2.5 bg-[#131b2e] border border-[#1e2d45] rounded-lg text-white font-mono text-sm outline-none focus:border-[#00d9ff] focus:shadow-[0_0_0_2px_rgba(0,217,255,0.12)] transition-all"}),o.jsxs("div",{children:[o.jsx("label",{className:"text-[10px] uppercase tracking-wider text-[#6b7a8d] mb-1 block",children:"Communication Style"}),o.jsx("div",{className:"grid grid-cols-2 gap-2",children:OT.map(pe=>o.jsxs("button",{onClick:()=>X(pe.value),className:`p-2.5 rounded-lg border text-left transition-all ${B===pe.value?"border-[#00d9ff] bg-[#0d1a2d]":"border-[#1e2d45] bg-[#131b2e] hover:border-[#00d9ff]/50"}`,children:[o.jsx("div",{className:"text-xs font-semibold text-white",children:pe.label}),o.jsx("div",{className:"text-[9px] text-[#4a5568]",children:pe.detail})]},pe.value))})]}),o.jsx("button",{onClick:jn,disabled:ye,className:"w-full py-3 bg-gradient-to-r from-[#00d9ff] to-[#4ECDC4] text-[#0a0f1a] font-bold rounded-lg text-sm tracking-wide hover:opacity-90 active:scale-[0.98] transition-all disabled:opacity-40",children:ye?"Saving...":"Continue"}),o.jsx("button",{onClick:async()=>{await xe(),n("connect")},className:"w-full py-2 text-xs text-[#6b7a8d] hover:text-[#00d9ff] transition-colors",children:"Skip — I'll add this later"})]}),e==="connect"&&o.jsxs("div",{className:"flex flex-col gap-4",children:[o.jsxs("div",{className:"text-center",children:[o.jsx("div",{className:"inline-flex items-center justify-center w-12 h-12 rounded-xl bg-[#131b2e] border border-[#1e2d45] mb-3",children:o.jsx(SN,{className:"w-6 h-6 text-[#00d9ff]"})}),o.jsx("h2",{className:"text-lg font-semibold text-white",children:"Connect Your Channels"}),o.jsx("p",{className:"text-sm text-[#6b7a8d] mt-1",children:"Reach Daemora from wherever you already chat. Configure keys later from Settings → Channels."})]}),ue&&o.jsx("p",{className:"text-xs text-[#6b7a8d] text-center",children:"Loading channels…"}),!ue&&oe.length===0&&o.jsx("p",{className:"text-xs text-[#6b7a8d] text-center",children:"No channels registered."}),o.jsx("div",{className:"flex flex-col gap-2 max-h-[360px] overflow-auto",children:oe.map(pe=>o.jsxs("div",{className:"rounded-lg border border-[#1e2d45] bg-[#131b2e]",children:[o.jsxs("div",{className:"flex items-center justify-between p-3",children:[o.jsxs("div",{children:[o.jsx("div",{className:"text-sm font-semibold text-white",children:pe.label}),o.jsxs("div",{className:"text-[10px] text-[#4a5568]",children:[pe.configured?"Configured":"Needs API key",pe.running?" · Running":"",pe.description?` · ${pe.description}`:""]})]}),pe.configured?o.jsx("button",{onClick:()=>gt(pe.id,pe.running),className:`px-3 py-1.5 rounded text-xs font-medium transition-all ${pe.running?"border border-[#4ECDC4] text-[#4ECDC4]":"bg-gradient-to-r from-[#00d9ff] to-[#4ECDC4] text-[#0a0f1a]"}`,children:pe.running?"Stop":"Start"}):o.jsx("button",{onClick:()=>W===pe.id?q(null):Re(pe),className:"px-3 py-1.5 rounded text-xs font-medium bg-gradient-to-r from-[#00d9ff] to-[#4ECDC4] text-[#0a0f1a] hover:opacity-90",children:W===pe.id?"Cancel":"Configure"})]}),W===pe.id&&o.jsxs("div",{className:"px-3 pb-3 border-t border-[#1e2d45] pt-3 flex flex-col gap-2",children:[pe.requiredKeys.map(Ue=>o.jsxs("div",{children:[o.jsxs("label",{className:"text-[10px] uppercase tracking-wider text-[#6b7a8d] mb-1 block",children:[Ue.label," ",o.jsxs("span",{className:"text-[#4a5568] normal-case tracking-normal",children:["(",Ue.key,")"]})]}),o.jsx("input",{type:Ue.secret?"password":"text",value:fe[Ue.key]??"",onChange:ze=>ve({...fe,[Ue.key]:ze.target.value}),placeholder:Ue.secret?"•••••••":"",className:"w-full px-3 py-2 bg-[#0a0f1a] border border-[#1e2d45] rounded text-white font-mono text-xs outline-none focus:border-[#00d9ff] transition-colors"})]},Ue.key)),dt&&o.jsx("p",{className:"text-[10px] text-red-400",children:dt}),o.jsx("button",{onClick:()=>Qe(pe),disabled:Se,className:"w-full py-2 bg-gradient-to-r from-[#00d9ff] to-[#4ECDC4] text-[#0a0f1a] font-bold rounded text-xs tracking-wide hover:opacity-90 disabled:opacity-40",children:Se?"Saving...":"Save & Start"})]})]},pe.id))}),o.jsx("button",{onClick:He,className:"w-full py-3 bg-gradient-to-r from-[#00d9ff] to-[#4ECDC4] text-[#0a0f1a] font-bold rounded-lg text-sm tracking-wide hover:opacity-90 active:scale-[0.98] transition-all",children:"Finish Setup"}),o.jsx("button",{onClick:He,className:"w-full py-2 text-xs text-[#6b7a8d] hover:text-[#00d9ff] transition-colors",children:"Skip — I'll connect later"})]}),e==="complete"&&o.jsxs("div",{className:"flex flex-col items-center gap-4 py-8",children:[o.jsx("div",{className:"w-16 h-16 rounded-full bg-gradient-to-br from-[#00d9ff] to-[#4ECDC4] flex items-center justify-center animate-in zoom-in duration-500",children:o.jsx(EN,{className:"w-8 h-8 text-[#0a0f1a]"})}),o.jsx("h2",{className:"text-xl font-bold text-white",children:"You're All Set"}),o.jsx("p",{className:"text-sm text-[#6b7a8d]",children:"Launching Daemora..."}),o.jsxs("div",{className:"flex gap-1.5 mt-2",children:[o.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-[#00d9ff] animate-pulse"}),o.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-[#00d9ff] animate-pulse [animation-delay:0.2s]"}),o.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-[#00d9ff] animate-pulse [animation-delay:0.4s]"})]})]})]})]})]})}const GX=s3([{path:"/setup",Component:KX},{path:"/",Component:()=>x.createElement(b3,null,x.createElement(vA)),children:[{index:!0,Component:OO},{path:"chat",Component:qH},{path:"logs",Component:nT},{path:"logs/:id",Component:iT},{path:"tasks",Component:nT},{path:"tasks/:id",Component:iT},{path:"config",Component:CT},{path:"channels",Component:hq},{path:"integrations",Component:xq},{path:"mcp",Component:yG},{path:"skills",Component:xG},{path:"cron",Component:UX},{path:"goals",Component:zX},{path:"watchers",Component:$X},{path:"security",Component:wG},{path:"costs",Component:IG},{path:"crew",Component:VX},{path:"teams",Component:HX},{path:"settings",Component:CT}]}]),YX=t=>o.jsx(AO,{theme:"dark",className:"toaster group",closeButton:!0,style:{"--normal-bg":"#0f172a","--normal-text":"#f0f0f3","--normal-border":"#1e293b"},...t});function JX(){return o.jsxs(o.Fragment,{children:[o.jsx(RM,{router:GX}),o.jsx(YX,{position:"top-right"})]})}WI.createRoot(document.getElementById("root")).render(o.jsx(JX,{}));